{"action":"created","comment":{"url":"https://api.github.com/repos/jackalope/jackalope/pulls/comments/35429199","id":35429199,"diff_hunk":"@@ -245,5 +247,172 @@ private function createFrozenNode(NodeInterface $versionNode, NodeInterface $nod\n \n             $frozenNode->setProperty($propertyName, $property->getValue());\n         }\n+\n+        foreach ($node->getNodes() as $childNode) {\n+            /** @var NodeInterface $childNode */\n+            // TODO also use the commented lines when getDefinition is implemented\n+            //$onParentVersion = $childNode->getDefinition()->getOnParentVersion();\n+\n+            //if ($onParentVersion == OnParentVersionAction::COPY) {\n+            // can't use the workspace copy command, because the parent node already has to exist\n+            // TODO distinguish between COPY and VERSION onParentVersion\n+            $this->copyIntoNode($childNode, $frozenNode);\n+            //}\n+        }\n+    }\n+\n+    public function restoreItem($removeExisting, $versionPath, $path)\n+    {\n+        $node = $this->objectManager->getNodeByPath($path);\n+\n+        if ($node->isModified()) {\n+            throw new InvalidItemStateException(\n+                sprintf(\n+                    'Node \"%s\" contains unsaved changes',\n+                    $path\n+                )\n+            );\n+        }\n+\n+        $versionNode = $this->objectManager->getNodeByPath($versionPath, 'Version\\Version');\n+        $frozenNode = $versionNode->getNode('jcr:frozenNode');\n+\n+        if ($frozenNode->getPropertyValue('jcr:frozenUuid') != $node->getPropertyValue('jcr:uuid')) {\n+            throw new RepositoryException(sprintf(\n+                'The frozen node uuid \"%s\" does not match the actual node uuid \"%s\". This should never happen.',\n+                $frozenNode->getPropertyValue('jcr:frozenUuid'),\n+                $node->getPropertyValue('jcr:uuid'))\n+            );\n+        }\n+\n+        // TODO reset primary type once the primary type can be changed\n+        // also see (https://github.com/jackalope/jackalope/issues/247)\n+\n+        if ($frozenNode->hasProperty('jcr:frozenMixinTypes')) {\n+            $node->setProperty('jcr:mixinTypes', $frozenNode->getPropertyValue('jcr:frozenMixinTypes'));\n+        } elseif ($node->hasProperty('jcr:mixinTypes')) {\n+            $node->getProperty('jcr:mixinTypes')->remove();\n+        }\n+\n+        // handle properties present on the frozen node\n+        foreach ($frozenNode->getProperties() as $property) {\n+            /** @var PropertyInterface $property */\n+            $propertyName = $property->getName();\n+            if ($propertyName == 'jcr:frozenPrimaryType'\n+                || $propertyName == 'jcr:frozenMixinTypes'\n+                || $propertyName == 'jcr:frozenUuid'\n+            ) {\n+                continue;\n+            }\n+\n+            if ($node->hasProperty($propertyName)) {\n+                $nodeProperty = $node->getProperty($propertyName);\n+                $onParentVersion = $nodeProperty->getDefinition()->getOnParentVersion();\n+                if ($onParentVersion == OnParentVersionAction::COPY || $onParentVersion == OnParentVersionAction::VERSION) {","path":"src/Jackalope/Version/VersionHandler.php","position":103,"original_position":103,"commit_id":"50605510439beb88b34b4a80c8a5903ef607f868","original_commit_id":"50605510439beb88b34b4a80c8a5903ef607f868","user":{"login":"dbu","id":76576,"avatar_url":"https://avatars.githubusercontent.com/u/76576?v=3","gravatar_id":"","url":"https://api.github.com/users/dbu","html_url":"https://github.com/dbu","followers_url":"https://api.github.com/users/dbu/followers","following_url":"https://api.github.com/users/dbu/following{/other_user}","gists_url":"https://api.github.com/users/dbu/gists{/gist_id}","starred_url":"https://api.github.com/users/dbu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dbu/subscriptions","organizations_url":"https://api.github.com/users/dbu/orgs","repos_url":"https://api.github.com/users/dbu/repos","events_url":"https://api.github.com/users/dbu/events{/privacy}","received_events_url":"https://api.github.com/users/dbu/received_events","type":"User","site_admin":false},"body":"i think you should check this on the properties of the frozen node and just integrate this into the check above and `continue` if the property is not to be copied.","created_at":"2015-07-24T14:48:43Z","updated_at":"2015-07-24T14:48:43Z","html_url":"https://github.com/jackalope/jackalope/pull/289#discussion_r35429199","pull_request_url":"https://api.github.com/repos/jackalope/jackalope/pulls/289","_links":{"self":{"href":"https://api.github.com/repos/jackalope/jackalope/pulls/comments/35429199"},"html":{"href":"https://github.com/jackalope/jackalope/pull/289#discussion_r35429199"},"pull_request":{"href":"https://api.github.com/repos/jackalope/jackalope/pulls/289"}}},"pull_request":{"url":"https://api.github.com/repos/jackalope/jackalope/pulls/289","id":37469794,"html_url":"https://github.com/jackalope/jackalope/pull/289","diff_url":"https://github.com/jackalope/jackalope/pull/289.diff","patch_url":"https://github.com/jackalope/jackalope/pull/289.patch","issue_url":"https://api.github.com/repos/jackalope/jackalope/issues/289","number":289,"state":"open","locked":false,"title":"Adding restore functionality for versioning support","user":{"login":"danrot","id":405874,"avatar_url":"https://avatars.githubusercontent.com/u/405874?v=3","gravatar_id":"","url":"https://api.github.com/users/danrot","html_url":"https://github.com/danrot","followers_url":"https://api.github.com/users/danrot/followers","following_url":"https://api.github.com/users/danrot/following{/other_user}","gists_url":"https://api.github.com/users/danrot/gists{/gist_id}","starred_url":"https://api.github.com/users/danrot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danrot/subscriptions","organizations_url":"https://api.github.com/users/danrot/orgs","repos_url":"https://api.github.com/users/danrot/repos","events_url":"https://api.github.com/users/danrot/events{/privacy}","received_events_url":"https://api.github.com/users/danrot/received_events","type":"User","site_admin":false},"body":"This PR adds restoring capabilities to the `VersionHandler`.\r\n\r\nIn order to use this functionality with jackalope-doctrine-dbal https://github.com/jackalope/jackalope-doctrine-dbal/pull/283 also needs to be merged.","created_at":"2015-06-11T14:34:28Z","updated_at":"2015-07-24T14:48:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"dfad6211e8f8a1548113474986972723ecd18122","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/jackalope/jackalope/pulls/289/commits","review_comments_url":"https://api.github.com/repos/jackalope/jackalope/pulls/289/comments","review_comment_url":"https://api.github.com/repos/jackalope/jackalope/pulls/comments{/number}","comments_url":"https://api.github.com/repos/jackalope/jackalope/issues/289/comments","statuses_url":"https://api.github.com/repos/jackalope/jackalope/statuses/50605510439beb88b34b4a80c8a5903ef607f868","head":{"label":"danrot:version-restore","ref":"version-restore","sha":"50605510439beb88b34b4a80c8a5903ef607f868","user":{"login":"danrot","id":405874,"avatar_url":"https://avatars.githubusercontent.com/u/405874?v=3","gravatar_id":"","url":"https://api.github.com/users/danrot","html_url":"https://github.com/danrot","followers_url":"https://api.github.com/users/danrot/followers","following_url":"https://api.github.com/users/danrot/following{/other_user}","gists_url":"https://api.github.com/users/danrot/gists{/gist_id}","starred_url":"https://api.github.com/users/danrot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danrot/subscriptions","organizations_url":"https://api.github.com/users/danrot/orgs","repos_url":"https://api.github.com/users/danrot/repos","events_url":"https://api.github.com/users/danrot/events{/privacy}","received_events_url":"https://api.github.com/users/danrot/received_events","type":"User","site_admin":false},"repo":{"id":30755794,"name":"jackalope","full_name":"danrot/jackalope","owner":{"login":"danrot","id":405874,"avatar_url":"https://avatars.githubusercontent.com/u/405874?v=3","gravatar_id":"","url":"https://api.github.com/users/danrot","html_url":"https://github.com/danrot","followers_url":"https://api.github.com/users/danrot/followers","following_url":"https://api.github.com/users/danrot/following{/other_user}","gists_url":"https://api.github.com/users/danrot/gists{/gist_id}","starred_url":"https://api.github.com/users/danrot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danrot/subscriptions","organizations_url":"https://api.github.com/users/danrot/orgs","repos_url":"https://api.github.com/users/danrot/repos","events_url":"https://api.github.com/users/danrot/events{/privacy}","received_events_url":"https://api.github.com/users/danrot/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/danrot/jackalope","description":"Jackalope implements the PHPCR API. This modular library contains bindings to store data with the Doctrine DBAL or in the Jackrabbit JCR server part","fork":true,"url":"https://api.github.com/repos/danrot/jackalope","forks_url":"https://api.github.com/repos/danrot/jackalope/forks","keys_url":"https://api.github.com/repos/danrot/jackalope/keys{/key_id}","collaborators_url":"https://api.github.com/repos/danrot/jackalope/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/danrot/jackalope/teams","hooks_url":"https://api.github.com/repos/danrot/jackalope/hooks","issue_events_url":"https://api.github.com/repos/danrot/jackalope/issues/events{/number}","events_url":"https://api.github.com/repos/danrot/jackalope/events","assignees_url":"https://api.github.com/repos/danrot/jackalope/assignees{/user}","branches_url":"https://api.github.com/repos/danrot/jackalope/branches{/branch}","tags_url":"https://api.github.com/repos/danrot/jackalope/tags","blobs_url":"https://api.github.com/repos/danrot/jackalope/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/danrot/jackalope/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/danrot/jackalope/git/refs{/sha}","trees_url":"https://api.github.com/repos/danrot/jackalope/git/trees{/sha}","statuses_url":"https://api.github.com/repos/danrot/jackalope/statuses/{sha}","languages_url":"https://api.github.com/repos/danrot/jackalope/languages","stargazers_url":"https://api.github.com/repos/danrot/jackalope/stargazers","contributors_url":"https://api.github.com/repos/danrot/jackalope/contributors","subscribers_url":"https://api.github.com/repos/danrot/jackalope/subscribers","subscription_url":"https://api.github.com/repos/danrot/jackalope/subscription","commits_url":"https://api.github.com/repos/danrot/jackalope/commits{/sha}","git_commits_url":"https://api.github.com/repos/danrot/jackalope/git/commits{/sha}","comments_url":"https://api.github.com/repos/danrot/jackalope/comments{/number}","issue_comment_url":"https://api.github.com/repos/danrot/jackalope/issues/comments{/number}","contents_url":"https://api.github.com/repos/danrot/jackalope/contents/{+path}","compare_url":"https://api.github.com/repos/danrot/jackalope/compare/{base}...{head}","merges_url":"https://api.github.com/repos/danrot/jackalope/merges","archive_url":"https://api.github.com/repos/danrot/jackalope/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/danrot/jackalope/downloads","issues_url":"https://api.github.com/repos/danrot/jackalope/issues{/number}","pulls_url":"https://api.github.com/repos/danrot/jackalope/pulls{/number}","milestones_url":"https://api.github.com/repos/danrot/jackalope/milestones{/number}","notifications_url":"https://api.github.com/repos/danrot/jackalope/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/danrot/jackalope/labels{/name}","releases_url":"https://api.github.com/repos/danrot/jackalope/releases{/id}","created_at":"2015-02-13T12:38:14Z","updated_at":"2015-06-02T17:23:17Z","pushed_at":"2015-06-25T13:16:18Z","git_url":"git://github.com/danrot/jackalope.git","ssh_url":"git@github.com:danrot/jackalope.git","clone_url":"https://github.com/danrot/jackalope.git","svn_url":"https://github.com/danrot/jackalope","homepage":"http://jackalope.github.io","size":9757,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"jackalope:versioning","ref":"versioning","sha":"0dc3dc0ebb7135799f0f483717731ad49509ea2d","user":{"login":"jackalope","id":70245,"avatar_url":"https://avatars.githubusercontent.com/u/70245?v=3","gravatar_id":"","url":"https://api.github.com/users/jackalope","html_url":"https://github.com/jackalope","followers_url":"https://api.github.com/users/jackalope/followers","following_url":"https://api.github.com/users/jackalope/following{/other_user}","gists_url":"https://api.github.com/users/jackalope/gists{/gist_id}","starred_url":"https://api.github.com/users/jackalope/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jackalope/subscriptions","organizations_url":"https://api.github.com/users/jackalope/orgs","repos_url":"https://api.github.com/users/jackalope/repos","events_url":"https://api.github.com/users/jackalope/events{/privacy}","received_events_url":"https://api.github.com/users/jackalope/received_events","type":"Organization","site_admin":false},"repo":{"id":563272,"name":"jackalope","full_name":"jackalope/jackalope","owner":{"login":"jackalope","id":70245,"avatar_url":"https://avatars.githubusercontent.com/u/70245?v=3","gravatar_id":"","url":"https://api.github.com/users/jackalope","html_url":"https://github.com/jackalope","followers_url":"https://api.github.com/users/jackalope/followers","following_url":"https://api.github.com/users/jackalope/following{/other_user}","gists_url":"https://api.github.com/users/jackalope/gists{/gist_id}","starred_url":"https://api.github.com/users/jackalope/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jackalope/subscriptions","organizations_url":"https://api.github.com/users/jackalope/orgs","repos_url":"https://api.github.com/users/jackalope/repos","events_url":"https://api.github.com/users/jackalope/events{/privacy}","received_events_url":"https://api.github.com/users/jackalope/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/jackalope/jackalope","description":"Jackalope implements the PHPCR API. This modular library contains bindings to store data with the Doctrine DBAL or in the Jackrabbit JCR server part","fork":false,"url":"https://api.github.com/repos/jackalope/jackalope","forks_url":"https://api.github.com/repos/jackalope/jackalope/forks","keys_url":"https://api.github.com/repos/jackalope/jackalope/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jackalope/jackalope/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jackalope/jackalope/teams","hooks_url":"https://api.github.com/repos/jackalope/jackalope/hooks","issue_events_url":"https://api.github.com/repos/jackalope/jackalope/issues/events{/number}","events_url":"https://api.github.com/repos/jackalope/jackalope/events","assignees_url":"https://api.github.com/repos/jackalope/jackalope/assignees{/user}","branches_url":"https://api.github.com/repos/jackalope/jackalope/branches{/branch}","tags_url":"https://api.github.com/repos/jackalope/jackalope/tags","blobs_url":"https://api.github.com/repos/jackalope/jackalope/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jackalope/jackalope/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jackalope/jackalope/git/refs{/sha}","trees_url":"https://api.github.com/repos/jackalope/jackalope/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jackalope/jackalope/statuses/{sha}","languages_url":"https://api.github.com/repos/jackalope/jackalope/languages","stargazers_url":"https://api.github.com/repos/jackalope/jackalope/stargazers","contributors_url":"https://api.github.com/repos/jackalope/jackalope/contributors","subscribers_url":"https://api.github.com/repos/jackalope/jackalope/subscribers","subscription_url":"https://api.github.com/repos/jackalope/jackalope/subscription","commits_url":"https://api.github.com/repos/jackalope/jackalope/commits{/sha}","git_commits_url":"https://api.github.com/repos/jackalope/jackalope/git/commits{/sha}","comments_url":"https://api.github.com/repos/jackalope/jackalope/comments{/number}","issue_comment_url":"https://api.github.com/repos/jackalope/jackalope/issues/comments{/number}","contents_url":"https://api.github.com/repos/jackalope/jackalope/contents/{+path}","compare_url":"https://api.github.com/repos/jackalope/jackalope/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jackalope/jackalope/merges","archive_url":"https://api.github.com/repos/jackalope/jackalope/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jackalope/jackalope/downloads","issues_url":"https://api.github.com/repos/jackalope/jackalope/issues{/number}","pulls_url":"https://api.github.com/repos/jackalope/jackalope/pulls{/number}","milestones_url":"https://api.github.com/repos/jackalope/jackalope/milestones{/number}","notifications_url":"https://api.github.com/repos/jackalope/jackalope/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jackalope/jackalope/labels{/name}","releases_url":"https://api.github.com/repos/jackalope/jackalope/releases{/id}","created_at":"2010-03-15T13:51:08Z","updated_at":"2015-07-07T09:03:01Z","pushed_at":"2015-07-22T06:41:31Z","git_url":"git://github.com/jackalope/jackalope.git","ssh_url":"git@github.com:jackalope/jackalope.git","clone_url":"https://github.com/jackalope/jackalope.git","svn_url":"https://github.com/jackalope/jackalope","homepage":"http://jackalope.github.io","size":11308,"stargazers_count":182,"watchers_count":182,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":59,"mirror_url":null,"open_issues_count":45,"forks":59,"open_issues":45,"watchers":182,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/jackalope/jackalope/pulls/289"},"html":{"href":"https://github.com/jackalope/jackalope/pull/289"},"issue":{"href":"https://api.github.com/repos/jackalope/jackalope/issues/289"},"comments":{"href":"https://api.github.com/repos/jackalope/jackalope/issues/289/comments"},"review_comments":{"href":"https://api.github.com/repos/jackalope/jackalope/pulls/289/comments"},"review_comment":{"href":"https://api.github.com/repos/jackalope/jackalope/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/jackalope/jackalope/pulls/289/commits"},"statuses":{"href":"https://api.github.com/repos/jackalope/jackalope/statuses/50605510439beb88b34b4a80c8a5903ef607f868"}}}}