{"action":"created","comment":{"url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/pulls/comments/41097329","id":41097329,"diff_hunk":"@@ -0,0 +1,158 @@\n+<?php\n+/**\n+ * @license For full copyright and license information view LICENSE file distributed with this source code.\n+ */\n+\n+namespace EzSystems\\PlatformUIBundle\\Rest;\n+\n+use eZ\\Publish\\API\\Repository\\Repository;\n+use eZ\\Publish\\API\\Repository\\UserService;\n+use eZ\\Publish\\Core\\Repository\\Values\\User\\UserCreateStruct;\n+use eZ\\Publish\\Core\\REST\\Common\\Input\\Dispatcher;\n+use eZ\\Publish\\Core\\REST\\Common\\Message;\n+use eZ\\Publish\\Core\\REST\\Server\\Values\\CreatedContent;\n+use eZ\\Publish\\Core\\REST\\Server\\Values\\CreatedUser;\n+use eZ\\Publish\\Core\\REST\\Server\\Values\\RestContent;\n+use eZ\\Publish\\Core\\REST\\Server\\Values\\RestContentCreateStruct;\n+use eZ\\Publish\\Core\\REST\\Server\\Values\\RestUser;\n+use eZ\\Publish\\Core\\REST\\Server\\View\\AcceptHeaderVisitorDispatcher;\n+use Symfony\\Component\\EventDispatcher\\EventSubscriberInterface;\n+use Symfony\\Component\\HttpFoundation\\Request;\n+use Symfony\\Component\\HttpKernel\\Event\\FilterControllerEvent;\n+use Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent;\n+use Symfony\\Component\\HttpKernel\\KernelEvents;\n+use eZ\\Publish\\Core\\FieldType\\User\\Value as UserFieldValue;\n+\n+class ContentUserGateway implements EventSubscriberInterface\n+{\n+    /** @var \\eZ\\Publish\\Core\\REST\\Common\\Input\\Dispatcher */\n+    private $restInputDispatcher;\n+\n+    /** @var \\eZ\\Publish\\API\\Repository\\Repository */\n+    private $repository;\n+\n+    /** @var \\eZ\\Publish\\Core\\REST\\Server\\View\\AcceptHeaderVisitorDispatcher */\n+    private $viewDispatcher;\n+\n+    public function __construct(Dispatcher $restInputDispatcher, AcceptHeaderVisitorDispatcher $viewDispatcher, Repository $repository)\n+    {\n+        $this->restInputDispatcher = $restInputDispatcher;\n+        $this->repository = $repository;\n+        $this->viewDispatcher = $viewDispatcher;\n+    }\n+\n+    public static function getSubscribedEvents()\n+    {\n+        return [KernelEvents::REQUEST => ['onKernelRequest', -1000]];\n+    }\n+\n+    public function onKernelRequest(GetResponseEvent $event)\n+    {\n+        $request = $event->getRequest();\n+        if (!$request->attributes->get('is_rest_request')) {\n+            return;\n+        }\n+\n+        if (!$contentTypeHeaderValue = $request->headers->get('content-type')) {\n+            return;\n+        }\n+\n+        list($mediaType) = explode('+', $contentTypeHeaderValue);\n+        if (strtolower($mediaType) ==! 'application/vnd.ez.api.contentcreate') {\n+            return;\n+        }\n+\n+        $message = $this->buildMessage($request);\n+        if (!$message->body) {\n+            return;\n+        }\n+        $result = $this->restInputDispatcher->parse($message);\n+        if (!$result instanceof RestContentCreateStruct) {\n+            return;\n+        }\n+\n+        // Not a user\n+        if (($createData = $this->mapContentCreateToUserCreate($result)) === false) {","path":"Rest/ContentUserGateway.php","position":70,"original_position":75,"commit_id":"ad935544a99d90f1a8df7c09164b91f35ab988e7","original_commit_id":"204adeba1cbdf489ba96b2c3880f48091b2071e1","user":{"login":"andrerom","id":289757,"avatar_url":"https://avatars.githubusercontent.com/u/289757?v=3","gravatar_id":"","url":"https://api.github.com/users/andrerom","html_url":"https://github.com/andrerom","followers_url":"https://api.github.com/users/andrerom/followers","following_url":"https://api.github.com/users/andrerom/following{/other_user}","gists_url":"https://api.github.com/users/andrerom/gists{/gist_id}","starred_url":"https://api.github.com/users/andrerom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrerom/subscriptions","organizations_url":"https://api.github.com/users/andrerom/orgs","repos_url":"https://api.github.com/users/andrerom/repos","events_url":"https://api.github.com/users/andrerom/events{/privacy}","received_events_url":"https://api.github.com/users/andrerom/received_events","type":"User","site_admin":false},"body":"nitpick, but  `$userCreateData`","created_at":"2015-10-04T12:40:38Z","updated_at":"2015-10-04T12:40:38Z","html_url":"https://github.com/ezsystems/PlatformUIBundle/pull/360#discussion_r41097329","pull_request_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/pulls/360","_links":{"self":{"href":"https://api.github.com/repos/ezsystems/PlatformUIBundle/pulls/comments/41097329"},"html":{"href":"https://github.com/ezsystems/PlatformUIBundle/pull/360#discussion_r41097329"},"pull_request":{"href":"https://api.github.com/repos/ezsystems/PlatformUIBundle/pulls/360"}}},"pull_request":{"url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/pulls/360","id":46722960,"html_url":"https://github.com/ezsystems/PlatformUIBundle/pull/360","diff_url":"https://github.com/ezsystems/PlatformUIBundle/pull/360.diff","patch_url":"https://github.com/ezsystems/PlatformUIBundle/pull/360.patch","issue_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/issues/360","number":360,"state":"open","locked":false,"title":"Implemented ContentCreate/UserCreate gateway","user":{"login":"bdunogier","id":235928,"avatar_url":"https://avatars.githubusercontent.com/u/235928?v=3","gravatar_id":"","url":"https://api.github.com/users/bdunogier","html_url":"https://github.com/bdunogier","followers_url":"https://api.github.com/users/bdunogier/followers","following_url":"https://api.github.com/users/bdunogier/following{/other_user}","gists_url":"https://api.github.com/users/bdunogier/gists{/gist_id}","starred_url":"https://api.github.com/users/bdunogier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bdunogier/subscriptions","organizations_url":"https://api.github.com/users/bdunogier/orgs","repos_url":"https://api.github.com/users/bdunogier/repos","events_url":"https://api.github.com/users/bdunogier/events{/privacy}","received_events_url":"https://api.github.com/users/bdunogier/received_events","type":"User","site_admin":false},"body":"When a ContentCreate for a User is POSTed, it is handled by the ContentUserGateway.\r\n\r\nIt creates the user, using the User API, from the request, and returns the created user.\r\nNo controller is used in the process, it all happens in the event.","created_at":"2015-10-04T10:30:06Z","updated_at":"2015-10-04T12:40:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"df063796e05a1f45207a4aea54dd5ebb86ffb31c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/pulls/360/commits","review_comments_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/pulls/360/comments","review_comment_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/issues/360/comments","statuses_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/statuses/ad935544a99d90f1a8df7c09164b91f35ab988e7","head":{"label":"ezsystems:user_content_proxy","ref":"user_content_proxy","sha":"ad935544a99d90f1a8df7c09164b91f35ab988e7","user":{"login":"ezsystems","id":295311,"avatar_url":"https://avatars.githubusercontent.com/u/295311?v=3","gravatar_id":"","url":"https://api.github.com/users/ezsystems","html_url":"https://github.com/ezsystems","followers_url":"https://api.github.com/users/ezsystems/followers","following_url":"https://api.github.com/users/ezsystems/following{/other_user}","gists_url":"https://api.github.com/users/ezsystems/gists{/gist_id}","starred_url":"https://api.github.com/users/ezsystems/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ezsystems/subscriptions","organizations_url":"https://api.github.com/users/ezsystems/orgs","repos_url":"https://api.github.com/users/ezsystems/repos","events_url":"https://api.github.com/users/ezsystems/events{/privacy}","received_events_url":"https://api.github.com/users/ezsystems/received_events","type":"Organization","site_admin":false},"repo":{"id":11221607,"name":"PlatformUIBundle","full_name":"ezsystems/PlatformUIBundle","owner":{"login":"ezsystems","id":295311,"avatar_url":"https://avatars.githubusercontent.com/u/295311?v=3","gravatar_id":"","url":"https://api.github.com/users/ezsystems","html_url":"https://github.com/ezsystems","followers_url":"https://api.github.com/users/ezsystems/followers","following_url":"https://api.github.com/users/ezsystems/following{/other_user}","gists_url":"https://api.github.com/users/ezsystems/gists{/gist_id}","starred_url":"https://api.github.com/users/ezsystems/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ezsystems/subscriptions","organizations_url":"https://api.github.com/users/ezsystems/orgs","repos_url":"https://api.github.com/users/ezsystems/repos","events_url":"https://api.github.com/users/ezsystems/events{/privacy}","received_events_url":"https://api.github.com/users/ezsystems/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ezsystems/PlatformUIBundle","description":"","fork":false,"url":"https://api.github.com/repos/ezsystems/PlatformUIBundle","forks_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/forks","keys_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/teams","hooks_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/hooks","issue_events_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/issues/events{/number}","events_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/events","assignees_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/assignees{/user}","branches_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/branches{/branch}","tags_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/tags","blobs_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/git/refs{/sha}","trees_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/statuses/{sha}","languages_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/languages","stargazers_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/stargazers","contributors_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/contributors","subscribers_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/subscribers","subscription_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/subscription","commits_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/commits{/sha}","git_commits_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/git/commits{/sha}","comments_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/comments{/number}","issue_comment_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/issues/comments{/number}","contents_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/contents/{+path}","compare_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/merges","archive_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/downloads","issues_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/issues{/number}","pulls_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/pulls{/number}","milestones_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/milestones{/number}","notifications_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/labels{/name}","releases_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/releases{/id}","created_at":"2013-07-06T17:21:40Z","updated_at":"2015-09-01T10:58:26Z","pushed_at":"2015-10-04T12:39:12Z","git_url":"git://github.com/ezsystems/PlatformUIBundle.git","ssh_url":"git@github.com:ezsystems/PlatformUIBundle.git","clone_url":"https://github.com/ezsystems/PlatformUIBundle.git","svn_url":"https://github.com/ezsystems/PlatformUIBundle","homepage":"","size":9975,"stargazers_count":23,"watchers_count":23,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":19,"mirror_url":null,"open_issues_count":13,"forks":19,"open_issues":13,"watchers":23,"default_branch":"master"}},"base":{"label":"ezsystems:master","ref":"master","sha":"cebe3ef82ee78fab1407574a3ef250812d7bf92c","user":{"login":"ezsystems","id":295311,"avatar_url":"https://avatars.githubusercontent.com/u/295311?v=3","gravatar_id":"","url":"https://api.github.com/users/ezsystems","html_url":"https://github.com/ezsystems","followers_url":"https://api.github.com/users/ezsystems/followers","following_url":"https://api.github.com/users/ezsystems/following{/other_user}","gists_url":"https://api.github.com/users/ezsystems/gists{/gist_id}","starred_url":"https://api.github.com/users/ezsystems/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ezsystems/subscriptions","organizations_url":"https://api.github.com/users/ezsystems/orgs","repos_url":"https://api.github.com/users/ezsystems/repos","events_url":"https://api.github.com/users/ezsystems/events{/privacy}","received_events_url":"https://api.github.com/users/ezsystems/received_events","type":"Organization","site_admin":false},"repo":{"id":11221607,"name":"PlatformUIBundle","full_name":"ezsystems/PlatformUIBundle","owner":{"login":"ezsystems","id":295311,"avatar_url":"https://avatars.githubusercontent.com/u/295311?v=3","gravatar_id":"","url":"https://api.github.com/users/ezsystems","html_url":"https://github.com/ezsystems","followers_url":"https://api.github.com/users/ezsystems/followers","following_url":"https://api.github.com/users/ezsystems/following{/other_user}","gists_url":"https://api.github.com/users/ezsystems/gists{/gist_id}","starred_url":"https://api.github.com/users/ezsystems/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ezsystems/subscriptions","organizations_url":"https://api.github.com/users/ezsystems/orgs","repos_url":"https://api.github.com/users/ezsystems/repos","events_url":"https://api.github.com/users/ezsystems/events{/privacy}","received_events_url":"https://api.github.com/users/ezsystems/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ezsystems/PlatformUIBundle","description":"","fork":false,"url":"https://api.github.com/repos/ezsystems/PlatformUIBundle","forks_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/forks","keys_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/teams","hooks_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/hooks","issue_events_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/issues/events{/number}","events_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/events","assignees_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/assignees{/user}","branches_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/branches{/branch}","tags_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/tags","blobs_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/git/refs{/sha}","trees_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/statuses/{sha}","languages_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/languages","stargazers_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/stargazers","contributors_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/contributors","subscribers_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/subscribers","subscription_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/subscription","commits_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/commits{/sha}","git_commits_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/git/commits{/sha}","comments_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/comments{/number}","issue_comment_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/issues/comments{/number}","contents_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/contents/{+path}","compare_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/merges","archive_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/downloads","issues_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/issues{/number}","pulls_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/pulls{/number}","milestones_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/milestones{/number}","notifications_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/labels{/name}","releases_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/releases{/id}","created_at":"2013-07-06T17:21:40Z","updated_at":"2015-09-01T10:58:26Z","pushed_at":"2015-10-04T12:39:12Z","git_url":"git://github.com/ezsystems/PlatformUIBundle.git","ssh_url":"git@github.com:ezsystems/PlatformUIBundle.git","clone_url":"https://github.com/ezsystems/PlatformUIBundle.git","svn_url":"https://github.com/ezsystems/PlatformUIBundle","homepage":"","size":9975,"stargazers_count":23,"watchers_count":23,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":19,"mirror_url":null,"open_issues_count":13,"forks":19,"open_issues":13,"watchers":23,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ezsystems/PlatformUIBundle/pulls/360"},"html":{"href":"https://github.com/ezsystems/PlatformUIBundle/pull/360"},"issue":{"href":"https://api.github.com/repos/ezsystems/PlatformUIBundle/issues/360"},"comments":{"href":"https://api.github.com/repos/ezsystems/PlatformUIBundle/issues/360/comments"},"review_comments":{"href":"https://api.github.com/repos/ezsystems/PlatformUIBundle/pulls/360/comments"},"review_comment":{"href":"https://api.github.com/repos/ezsystems/PlatformUIBundle/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ezsystems/PlatformUIBundle/pulls/360/commits"},"statuses":{"href":"https://api.github.com/repos/ezsystems/PlatformUIBundle/statuses/ad935544a99d90f1a8df7c09164b91f35ab988e7"}}}}