{"action":"created","comment":{"url":"https://api.github.com/repos/Sylius/Sylius/pulls/comments/47887386","id":47887386,"diff_hunk":"@@ -0,0 +1,74 @@\n+<?php\n+\n+/*\n+ * This file is part of the Sylius package.\n+ *\n+ * (c) Paweł Jędrzejewski\n+ *\n+ * For the full copyright and license information, please view the LICENSE\n+ * file that was distributed with this source code.\n+ */\n+\n+namespace Sylius\\Bundle\\RbacBundle\\Form\\EventSubscriber;\n+\n+use Sylius\\Bundle\\RbacBundle\\Form\\Exception\\UnexpectedTypeException;\n+use Sylius\\Component\\Rbac\\Model\\PermissionInterface;\n+use Sylius\\Component\\Rbac\\Model\\RoleInterface;\n+use Symfony\\Component\\EventDispatcher\\EventSubscriberInterface;\n+use Symfony\\Component\\Form\\FormEvent;\n+use Symfony\\Component\\Form\\FormEvents;\n+\n+/**\n+ * @author Anna Walasek <anna.walasek@lakion.com>\n+ */\n+class AddParentFormSubscriber implements EventSubscriberInterface\n+{\n+    /**\n+     * @var string\n+     */\n+    private $type;\n+\n+    /**\n+     * @param string $type\n+     */\n+    public function __construct($type)\n+    {\n+        $this->type  = $type;\n+    }\n+\n+    /**\n+     * {@inheritdoc}\n+     */\n+    public static function getSubscribedEvents()\n+    {\n+        return array(\n+            FormEvents::PRE_SET_DATA => 'preSetData',\n+        );\n+    }\n+\n+    /**\n+     * @param FormEvent $event\n+     */\n+    public function preSetData(FormEvent $event)\n+    {\n+        $resource = $event->getData();\n+        $form = $event->getForm();\n+\n+        if (null === $resource) {\n+            return;\n+        }\n+\n+        if(!$resource instanceof RoleInterface && !$resource instanceof PermissionInterface) {\n+            throw new UnexpectedTypeException($resource, RoleInterface::class, PermissionInterface::class);\n+        }\n+\n+        if (!(null === $resource->getId() xor null === $resource->getParent())) {","path":"src/Sylius/Bundle/RbacBundle/Form/EventSubscriber/AddParentFormSubscriber.php","position":65,"original_position":65,"commit_id":"7f3be22f14b07be16169e8203e827d2fffdce672","original_commit_id":"7f3be22f14b07be16169e8203e827d2fffdce672","user":{"login":"tuka217","id":8963048,"avatar_url":"https://avatars.githubusercontent.com/u/8963048?v=3","gravatar_id":"","url":"https://api.github.com/users/tuka217","html_url":"https://github.com/tuka217","followers_url":"https://api.github.com/users/tuka217/followers","following_url":"https://api.github.com/users/tuka217/following{/other_user}","gists_url":"https://api.github.com/users/tuka217/gists{/gist_id}","starred_url":"https://api.github.com/users/tuka217/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tuka217/subscriptions","organizations_url":"https://api.github.com/users/tuka217/orgs","repos_url":"https://api.github.com/users/tuka217/repos","events_url":"https://api.github.com/users/tuka217/events{/privacy}","received_events_url":"https://api.github.com/users/tuka217/received_events","type":"User","site_admin":false},"body":":+1: ","created_at":"2015-12-17T09:57:24Z","updated_at":"2015-12-17T09:57:24Z","html_url":"https://github.com/Sylius/Sylius/pull/3730#discussion_r47887386","pull_request_url":"https://api.github.com/repos/Sylius/Sylius/pulls/3730","_links":{"self":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/comments/47887386"},"html":{"href":"https://github.com/Sylius/Sylius/pull/3730#discussion_r47887386"},"pull_request":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/3730"}}},"pull_request":{"url":"https://api.github.com/repos/Sylius/Sylius/pulls/3730","id":53843247,"html_url":"https://github.com/Sylius/Sylius/pull/3730","diff_url":"https://github.com/Sylius/Sylius/pull/3730.diff","patch_url":"https://github.com/Sylius/Sylius/pull/3730.patch","issue_url":"https://api.github.com/repos/Sylius/Sylius/issues/3730","number":3730,"state":"open","locked":false,"title":"[Rbac][RbacBundle] Introduce code for Rbac","user":{"login":"tuka217","id":8963048,"avatar_url":"https://avatars.githubusercontent.com/u/8963048?v=3","gravatar_id":"","url":"https://api.github.com/users/tuka217","html_url":"https://github.com/tuka217","followers_url":"https://api.github.com/users/tuka217/followers","following_url":"https://api.github.com/users/tuka217/following{/other_user}","gists_url":"https://api.github.com/users/tuka217/gists{/gist_id}","starred_url":"https://api.github.com/users/tuka217/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tuka217/subscriptions","organizations_url":"https://api.github.com/users/tuka217/orgs","repos_url":"https://api.github.com/users/tuka217/repos","events_url":"https://api.github.com/users/tuka217/events{/privacy}","received_events_url":"https://api.github.com/users/tuka217/received_events","type":"User","site_admin":false},"body":"Q \t|A\r\n-------|-------\r\nBug fix?| \tno\r\nNew feature?| \tyes\r\nBC breaks?| \tno\r\nDeprecations?| \tno\r\nFixed tickets| \t-\r\nLicense| \tMIT\r\nDoc PR| \t-","created_at":"2015-12-16T13:51:27Z","updated_at":"2015-12-17T09:57:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2c0a9fe96c5cf332f5e5c875b49323d3c90e6555","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Sylius/Sylius/pulls/3730/commits","review_comments_url":"https://api.github.com/repos/Sylius/Sylius/pulls/3730/comments","review_comment_url":"https://api.github.com/repos/Sylius/Sylius/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Sylius/Sylius/issues/3730/comments","statuses_url":"https://api.github.com/repos/Sylius/Sylius/statuses/7f3be22f14b07be16169e8203e827d2fffdce672","head":{"label":"tuka217:immutable-code-rbac","ref":"immutable-code-rbac","sha":"7f3be22f14b07be16169e8203e827d2fffdce672","user":{"login":"tuka217","id":8963048,"avatar_url":"https://avatars.githubusercontent.com/u/8963048?v=3","gravatar_id":"","url":"https://api.github.com/users/tuka217","html_url":"https://github.com/tuka217","followers_url":"https://api.github.com/users/tuka217/followers","following_url":"https://api.github.com/users/tuka217/following{/other_user}","gists_url":"https://api.github.com/users/tuka217/gists{/gist_id}","starred_url":"https://api.github.com/users/tuka217/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tuka217/subscriptions","organizations_url":"https://api.github.com/users/tuka217/orgs","repos_url":"https://api.github.com/users/tuka217/repos","events_url":"https://api.github.com/users/tuka217/events{/privacy}","received_events_url":"https://api.github.com/users/tuka217/received_events","type":"User","site_admin":false},"repo":{"id":42645712,"name":"Sylius","full_name":"tuka217/Sylius","owner":{"login":"tuka217","id":8963048,"avatar_url":"https://avatars.githubusercontent.com/u/8963048?v=3","gravatar_id":"","url":"https://api.github.com/users/tuka217","html_url":"https://github.com/tuka217","followers_url":"https://api.github.com/users/tuka217/followers","following_url":"https://api.github.com/users/tuka217/following{/other_user}","gists_url":"https://api.github.com/users/tuka217/gists{/gist_id}","starred_url":"https://api.github.com/users/tuka217/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tuka217/subscriptions","organizations_url":"https://api.github.com/users/tuka217/orgs","repos_url":"https://api.github.com/users/tuka217/repos","events_url":"https://api.github.com/users/tuka217/events{/privacy}","received_events_url":"https://api.github.com/users/tuka217/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tuka217/Sylius","description":"Modern e-commerce for PHP, based on the Symfony2 framework.","fork":true,"url":"https://api.github.com/repos/tuka217/Sylius","forks_url":"https://api.github.com/repos/tuka217/Sylius/forks","keys_url":"https://api.github.com/repos/tuka217/Sylius/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tuka217/Sylius/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tuka217/Sylius/teams","hooks_url":"https://api.github.com/repos/tuka217/Sylius/hooks","issue_events_url":"https://api.github.com/repos/tuka217/Sylius/issues/events{/number}","events_url":"https://api.github.com/repos/tuka217/Sylius/events","assignees_url":"https://api.github.com/repos/tuka217/Sylius/assignees{/user}","branches_url":"https://api.github.com/repos/tuka217/Sylius/branches{/branch}","tags_url":"https://api.github.com/repos/tuka217/Sylius/tags","blobs_url":"https://api.github.com/repos/tuka217/Sylius/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tuka217/Sylius/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tuka217/Sylius/git/refs{/sha}","trees_url":"https://api.github.com/repos/tuka217/Sylius/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tuka217/Sylius/statuses/{sha}","languages_url":"https://api.github.com/repos/tuka217/Sylius/languages","stargazers_url":"https://api.github.com/repos/tuka217/Sylius/stargazers","contributors_url":"https://api.github.com/repos/tuka217/Sylius/contributors","subscribers_url":"https://api.github.com/repos/tuka217/Sylius/subscribers","subscription_url":"https://api.github.com/repos/tuka217/Sylius/subscription","commits_url":"https://api.github.com/repos/tuka217/Sylius/commits{/sha}","git_commits_url":"https://api.github.com/repos/tuka217/Sylius/git/commits{/sha}","comments_url":"https://api.github.com/repos/tuka217/Sylius/comments{/number}","issue_comment_url":"https://api.github.com/repos/tuka217/Sylius/issues/comments{/number}","contents_url":"https://api.github.com/repos/tuka217/Sylius/contents/{+path}","compare_url":"https://api.github.com/repos/tuka217/Sylius/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tuka217/Sylius/merges","archive_url":"https://api.github.com/repos/tuka217/Sylius/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tuka217/Sylius/downloads","issues_url":"https://api.github.com/repos/tuka217/Sylius/issues{/number}","pulls_url":"https://api.github.com/repos/tuka217/Sylius/pulls{/number}","milestones_url":"https://api.github.com/repos/tuka217/Sylius/milestones{/number}","notifications_url":"https://api.github.com/repos/tuka217/Sylius/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tuka217/Sylius/labels{/name}","releases_url":"https://api.github.com/repos/tuka217/Sylius/releases{/id}","created_at":"2015-09-17T08:53:41Z","updated_at":"2015-09-17T08:53:48Z","pushed_at":"2015-12-17T08:13:35Z","git_url":"git://github.com/tuka217/Sylius.git","ssh_url":"git@github.com:tuka217/Sylius.git","clone_url":"https://github.com/tuka217/Sylius.git","svn_url":"https://github.com/tuka217/Sylius","homepage":"Sylius.org","size":19697,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Sylius:master","ref":"master","sha":"88d8feb9c89e3ca8b4eb522aeea4bb53d3758be0","user":{"login":"Sylius","id":719423,"avatar_url":"https://avatars.githubusercontent.com/u/719423?v=3","gravatar_id":"","url":"https://api.github.com/users/Sylius","html_url":"https://github.com/Sylius","followers_url":"https://api.github.com/users/Sylius/followers","following_url":"https://api.github.com/users/Sylius/following{/other_user}","gists_url":"https://api.github.com/users/Sylius/gists{/gist_id}","starred_url":"https://api.github.com/users/Sylius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Sylius/subscriptions","organizations_url":"https://api.github.com/users/Sylius/orgs","repos_url":"https://api.github.com/users/Sylius/repos","events_url":"https://api.github.com/users/Sylius/events{/privacy}","received_events_url":"https://api.github.com/users/Sylius/received_events","type":"Organization","site_admin":false},"repo":{"id":2717549,"name":"Sylius","full_name":"Sylius/Sylius","owner":{"login":"Sylius","id":719423,"avatar_url":"https://avatars.githubusercontent.com/u/719423?v=3","gravatar_id":"","url":"https://api.github.com/users/Sylius","html_url":"https://github.com/Sylius","followers_url":"https://api.github.com/users/Sylius/followers","following_url":"https://api.github.com/users/Sylius/following{/other_user}","gists_url":"https://api.github.com/users/Sylius/gists{/gist_id}","starred_url":"https://api.github.com/users/Sylius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Sylius/subscriptions","organizations_url":"https://api.github.com/users/Sylius/orgs","repos_url":"https://api.github.com/users/Sylius/repos","events_url":"https://api.github.com/users/Sylius/events{/privacy}","received_events_url":"https://api.github.com/users/Sylius/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Sylius/Sylius","description":"Modern e-commerce for PHP, based on the Symfony2 framework.","fork":false,"url":"https://api.github.com/repos/Sylius/Sylius","forks_url":"https://api.github.com/repos/Sylius/Sylius/forks","keys_url":"https://api.github.com/repos/Sylius/Sylius/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Sylius/Sylius/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Sylius/Sylius/teams","hooks_url":"https://api.github.com/repos/Sylius/Sylius/hooks","issue_events_url":"https://api.github.com/repos/Sylius/Sylius/issues/events{/number}","events_url":"https://api.github.com/repos/Sylius/Sylius/events","assignees_url":"https://api.github.com/repos/Sylius/Sylius/assignees{/user}","branches_url":"https://api.github.com/repos/Sylius/Sylius/branches{/branch}","tags_url":"https://api.github.com/repos/Sylius/Sylius/tags","blobs_url":"https://api.github.com/repos/Sylius/Sylius/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Sylius/Sylius/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Sylius/Sylius/git/refs{/sha}","trees_url":"https://api.github.com/repos/Sylius/Sylius/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Sylius/Sylius/statuses/{sha}","languages_url":"https://api.github.com/repos/Sylius/Sylius/languages","stargazers_url":"https://api.github.com/repos/Sylius/Sylius/stargazers","contributors_url":"https://api.github.com/repos/Sylius/Sylius/contributors","subscribers_url":"https://api.github.com/repos/Sylius/Sylius/subscribers","subscription_url":"https://api.github.com/repos/Sylius/Sylius/subscription","commits_url":"https://api.github.com/repos/Sylius/Sylius/commits{/sha}","git_commits_url":"https://api.github.com/repos/Sylius/Sylius/git/commits{/sha}","comments_url":"https://api.github.com/repos/Sylius/Sylius/comments{/number}","issue_comment_url":"https://api.github.com/repos/Sylius/Sylius/issues/comments{/number}","contents_url":"https://api.github.com/repos/Sylius/Sylius/contents/{+path}","compare_url":"https://api.github.com/repos/Sylius/Sylius/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Sylius/Sylius/merges","archive_url":"https://api.github.com/repos/Sylius/Sylius/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Sylius/Sylius/downloads","issues_url":"https://api.github.com/repos/Sylius/Sylius/issues{/number}","pulls_url":"https://api.github.com/repos/Sylius/Sylius/pulls{/number}","milestones_url":"https://api.github.com/repos/Sylius/Sylius/milestones{/number}","notifications_url":"https://api.github.com/repos/Sylius/Sylius/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Sylius/Sylius/labels{/name}","releases_url":"https://api.github.com/repos/Sylius/Sylius/releases{/id}","created_at":"2011-11-05T22:05:52Z","updated_at":"2015-12-16T19:54:30Z","pushed_at":"2015-12-17T09:37:06Z","git_url":"git://github.com/Sylius/Sylius.git","ssh_url":"git@github.com:Sylius/Sylius.git","clone_url":"https://github.com/Sylius/Sylius.git","svn_url":"https://github.com/Sylius/Sylius","homepage":"Sylius.org","size":46113,"stargazers_count":2091,"watchers_count":2091,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":760,"mirror_url":null,"open_issues_count":461,"forks":760,"open_issues":461,"watchers":2091,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/3730"},"html":{"href":"https://github.com/Sylius/Sylius/pull/3730"},"issue":{"href":"https://api.github.com/repos/Sylius/Sylius/issues/3730"},"comments":{"href":"https://api.github.com/repos/Sylius/Sylius/issues/3730/comments"},"review_comments":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/3730/comments"},"review_comment":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/3730/commits"},"statuses":{"href":"https://api.github.com/repos/Sylius/Sylius/statuses/7f3be22f14b07be16169e8203e827d2fffdce672"}}}}