{"action":"created","comment":{"url":"https://api.github.com/repos/dunglas/DunglasApiBundle/pulls/comments/36479809","id":36479809,"diff_hunk":"@@ -0,0 +1,64 @@\n+<?php\n+\n+/*\n+ * This file is part of the DunglasApiBundle package.\n+ *\n+ * (c) Kévin Dunglas <dunglas@gmail.com>\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 Dunglas\\ApiBundle\\FosUser;\n+\n+use FOS\\UserBundle\\Model\\UserManagerInterface;\n+use FOS\\UserBundle\\Model\\UserInterface;\n+use Symfony\\Component\\HttpFoundation\\Request;\n+use Symfony\\Component\\HttpKernel\\Event\\GetResponseForControllerResultEvent;\n+\n+/**\n+ * Bridges between FOSUserBundle and DunglasApiBundle.\n+ *\n+ * @author Kévin Dunglas <dunglas@gmail.com>\n+ * @author Théo FIDRY <theo.fidry@gmail.com>\n+ */\n+class EventListener\n+{\n+    /**\n+     * @var UserManagerInterface\n+     */\n+    private $userManager;\n+\n+    public function __construct(UserManagerInterface $userManager)\n+    {\n+        $this->userManager = $userManager;\n+    }\n+\n+    /**\n+     * Persists, updates or delete data return by the controller if applicable.\n+     *\n+     * @param GetResponseForControllerResultEvent $event\n+     *\n+     * @return mixed\n+     */\n+    public function onKernelView(GetResponseForControllerResultEvent $event)\n+    {\n+        $controllerResult = $event->getControllerResult();\n+        if (!$controllerResult instanceof UserInterface) {\n+            return $controllerResult;\n+        }\n+\n+        switch ($event->getRequest()->getMethod()) {\n+\n+            case Request::METHOD_POST:\n+            case Request::METHOD_PUT:\n+                $this->userManager->updateUser($controllerResult, false);","path":"FosUser/EventListener.php","position":55,"original_position":55,"commit_id":"5c7516e31effc1b4d66ad06f8cc6c4434b643928","original_commit_id":"5c7516e31effc1b4d66ad06f8cc6c4434b643928","user":{"login":"dunglas","id":57224,"avatar_url":"https://avatars.githubusercontent.com/u/57224?v=3","gravatar_id":"","url":"https://api.github.com/users/dunglas","html_url":"https://github.com/dunglas","followers_url":"https://api.github.com/users/dunglas/followers","following_url":"https://api.github.com/users/dunglas/following{/other_user}","gists_url":"https://api.github.com/users/dunglas/gists{/gist_id}","starred_url":"https://api.github.com/users/dunglas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dunglas/subscriptions","organizations_url":"https://api.github.com/users/dunglas/orgs","repos_url":"https://api.github.com/users/dunglas/repos","events_url":"https://api.github.com/users/dunglas/events{/privacy}","received_events_url":"https://api.github.com/users/dunglas/received_events","type":"User","site_admin":false},"body":"For me it's OK. It allows an user to add a listener with an higher priority than the FOSUser listener but lower than the Doctrine one.","created_at":"2015-08-06T23:56:04Z","updated_at":"2015-08-06T23:56:04Z","html_url":"https://github.com/dunglas/DunglasApiBundle/pull/211#discussion_r36479809","pull_request_url":"https://api.github.com/repos/dunglas/DunglasApiBundle/pulls/211","_links":{"self":{"href":"https://api.github.com/repos/dunglas/DunglasApiBundle/pulls/comments/36479809"},"html":{"href":"https://github.com/dunglas/DunglasApiBundle/pull/211#discussion_r36479809"},"pull_request":{"href":"https://api.github.com/repos/dunglas/DunglasApiBundle/pulls/211"}}},"pull_request":{"url":"https://api.github.com/repos/dunglas/DunglasApiBundle/pulls/211","id":41715338,"html_url":"https://github.com/dunglas/DunglasApiBundle/pull/211","diff_url":"https://github.com/dunglas/DunglasApiBundle/pull/211.diff","patch_url":"https://github.com/dunglas/DunglasApiBundle/pull/211.patch","issue_url":"https://api.github.com/repos/dunglas/DunglasApiBundle/issues/211","number":211,"state":"open","locked":false,"title":"Updated FOSUser bridge according to the new event system","user":{"login":"theofidry","id":5175937,"avatar_url":"https://avatars.githubusercontent.com/u/5175937?v=3","gravatar_id":"","url":"https://api.github.com/users/theofidry","html_url":"https://github.com/theofidry","followers_url":"https://api.github.com/users/theofidry/followers","following_url":"https://api.github.com/users/theofidry/following{/other_user}","gists_url":"https://api.github.com/users/theofidry/gists{/gist_id}","starred_url":"https://api.github.com/users/theofidry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/theofidry/subscriptions","organizations_url":"https://api.github.com/users/theofidry/orgs","repos_url":"https://api.github.com/users/theofidry/repos","events_url":"https://api.github.com/users/theofidry/events{/privacy}","received_events_url":"https://api.github.com/users/theofidry/received_events","type":"User","site_admin":false},"body":"@dunglas I'm not really sure this is the right way to do it, so waiting for your feedback. I can't test right now due to an error with NelmioApiBundle and don't have much time tonight ;)\r\n\r\n* [x] update event listener\r\n* [ ] add tests\r\n* [ ] check doc","created_at":"2015-08-05T19:17:42Z","updated_at":"2015-08-06T23:56:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9687f9a49aacae68507918e213de22aa5855fb9f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/dunglas/DunglasApiBundle/pulls/211/commits","review_comments_url":"https://api.github.com/repos/dunglas/DunglasApiBundle/pulls/211/comments","review_comment_url":"https://api.github.com/repos/dunglas/DunglasApiBundle/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dunglas/DunglasApiBundle/issues/211/comments","statuses_url":"https://api.github.com/repos/dunglas/DunglasApiBundle/statuses/5c7516e31effc1b4d66ad06f8cc6c4434b643928","head":{"label":"theofidry:bugfix/fos-user","ref":"bugfix/fos-user","sha":"5c7516e31effc1b4d66ad06f8cc6c4434b643928","user":{"login":"theofidry","id":5175937,"avatar_url":"https://avatars.githubusercontent.com/u/5175937?v=3","gravatar_id":"","url":"https://api.github.com/users/theofidry","html_url":"https://github.com/theofidry","followers_url":"https://api.github.com/users/theofidry/followers","following_url":"https://api.github.com/users/theofidry/following{/other_user}","gists_url":"https://api.github.com/users/theofidry/gists{/gist_id}","starred_url":"https://api.github.com/users/theofidry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/theofidry/subscriptions","organizations_url":"https://api.github.com/users/theofidry/orgs","repos_url":"https://api.github.com/users/theofidry/repos","events_url":"https://api.github.com/users/theofidry/events{/privacy}","received_events_url":"https://api.github.com/users/theofidry/received_events","type":"User","site_admin":false},"repo":{"id":37906789,"name":"DunglasApiBundle","full_name":"theofidry/DunglasApiBundle","owner":{"login":"theofidry","id":5175937,"avatar_url":"https://avatars.githubusercontent.com/u/5175937?v=3","gravatar_id":"","url":"https://api.github.com/users/theofidry","html_url":"https://github.com/theofidry","followers_url":"https://api.github.com/users/theofidry/followers","following_url":"https://api.github.com/users/theofidry/following{/other_user}","gists_url":"https://api.github.com/users/theofidry/gists{/gist_id}","starred_url":"https://api.github.com/users/theofidry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/theofidry/subscriptions","organizations_url":"https://api.github.com/users/theofidry/orgs","repos_url":"https://api.github.com/users/theofidry/repos","events_url":"https://api.github.com/users/theofidry/events{/privacy}","received_events_url":"https://api.github.com/users/theofidry/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/theofidry/DunglasApiBundle","description":"Hypermedia REST API for Symfony and Api Platform with JSON-LD and Hydra support","fork":true,"url":"https://api.github.com/repos/theofidry/DunglasApiBundle","forks_url":"https://api.github.com/repos/theofidry/DunglasApiBundle/forks","keys_url":"https://api.github.com/repos/theofidry/DunglasApiBundle/keys{/key_id}","collaborators_url":"https://api.github.com/repos/theofidry/DunglasApiBundle/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/theofidry/DunglasApiBundle/teams","hooks_url":"https://api.github.com/repos/theofidry/DunglasApiBundle/hooks","issue_events_url":"https://api.github.com/repos/theofidry/DunglasApiBundle/issues/events{/number}","events_url":"https://api.github.com/repos/theofidry/DunglasApiBundle/events","assignees_url":"https://api.github.com/repos/theofidry/DunglasApiBundle/assignees{/user}","branches_url":"https://api.github.com/repos/theofidry/DunglasApiBundle/branches{/branch}","tags_url":"https://api.github.com/repos/theofidry/DunglasApiBundle/tags","blobs_url":"https://api.github.com/repos/theofidry/DunglasApiBundle/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/theofidry/DunglasApiBundle/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/theofidry/DunglasApiBundle/git/refs{/sha}","trees_url":"https://api.github.com/repos/theofidry/DunglasApiBundle/git/trees{/sha}","statuses_url":"https://api.github.com/repos/theofidry/DunglasApiBundle/statuses/{sha}","languages_url":"https://api.github.com/repos/theofidry/DunglasApiBundle/languages","stargazers_url":"https://api.github.com/repos/theofidry/DunglasApiBundle/stargazers","contributors_url":"https://api.github.com/repos/theofidry/DunglasApiBundle/contributors","subscribers_url":"https://api.github.com/repos/theofidry/DunglasApiBundle/subscribers","subscription_url":"https://api.github.com/repos/theofidry/DunglasApiBundle/subscription","commits_url":"https://api.github.com/repos/theofidry/DunglasApiBundle/commits{/sha}","git_commits_url":"https://api.github.com/repos/theofidry/DunglasApiBundle/git/commits{/sha}","comments_url":"https://api.github.com/repos/theofidry/DunglasApiBundle/comments{/number}","issue_comment_url":"https://api.github.com/repos/theofidry/DunglasApiBundle/issues/comments{/number}","contents_url":"https://api.github.com/repos/theofidry/DunglasApiBundle/contents/{+path}","compare_url":"https://api.github.com/repos/theofidry/DunglasApiBundle/compare/{base}...{head}","merges_url":"https://api.github.com/repos/theofidry/DunglasApiBundle/merges","archive_url":"https://api.github.com/repos/theofidry/DunglasApiBundle/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/theofidry/DunglasApiBundle/downloads","issues_url":"https://api.github.com/repos/theofidry/DunglasApiBundle/issues{/number}","pulls_url":"https://api.github.com/repos/theofidry/DunglasApiBundle/pulls{/number}","milestones_url":"https://api.github.com/repos/theofidry/DunglasApiBundle/milestones{/number}","notifications_url":"https://api.github.com/repos/theofidry/DunglasApiBundle/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/theofidry/DunglasApiBundle/labels{/name}","releases_url":"https://api.github.com/repos/theofidry/DunglasApiBundle/releases{/id}","created_at":"2015-06-23T08:30:46Z","updated_at":"2015-07-09T10:19:45Z","pushed_at":"2015-08-06T22:00:40Z","git_url":"git://github.com/theofidry/DunglasApiBundle.git","ssh_url":"git@github.com:theofidry/DunglasApiBundle.git","clone_url":"https://github.com/theofidry/DunglasApiBundle.git","svn_url":"https://github.com/theofidry/DunglasApiBundle","homepage":"http://api-platform.com","size":995,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"dunglas:master","ref":"master","sha":"2e6785c7ac7baf3ef14961445687987dd0667718","user":{"login":"dunglas","id":57224,"avatar_url":"https://avatars.githubusercontent.com/u/57224?v=3","gravatar_id":"","url":"https://api.github.com/users/dunglas","html_url":"https://github.com/dunglas","followers_url":"https://api.github.com/users/dunglas/followers","following_url":"https://api.github.com/users/dunglas/following{/other_user}","gists_url":"https://api.github.com/users/dunglas/gists{/gist_id}","starred_url":"https://api.github.com/users/dunglas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dunglas/subscriptions","organizations_url":"https://api.github.com/users/dunglas/orgs","repos_url":"https://api.github.com/users/dunglas/repos","events_url":"https://api.github.com/users/dunglas/events{/privacy}","received_events_url":"https://api.github.com/users/dunglas/received_events","type":"User","site_admin":false},"repo":{"id":29501260,"name":"DunglasApiBundle","full_name":"dunglas/DunglasApiBundle","owner":{"login":"dunglas","id":57224,"avatar_url":"https://avatars.githubusercontent.com/u/57224?v=3","gravatar_id":"","url":"https://api.github.com/users/dunglas","html_url":"https://github.com/dunglas","followers_url":"https://api.github.com/users/dunglas/followers","following_url":"https://api.github.com/users/dunglas/following{/other_user}","gists_url":"https://api.github.com/users/dunglas/gists{/gist_id}","starred_url":"https://api.github.com/users/dunglas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dunglas/subscriptions","organizations_url":"https://api.github.com/users/dunglas/orgs","repos_url":"https://api.github.com/users/dunglas/repos","events_url":"https://api.github.com/users/dunglas/events{/privacy}","received_events_url":"https://api.github.com/users/dunglas/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dunglas/DunglasApiBundle","description":"The Hypermedia REST API component of API Platform: JSON-LD and Hydra support, works with Symfony too","fork":false,"url":"https://api.github.com/repos/dunglas/DunglasApiBundle","forks_url":"https://api.github.com/repos/dunglas/DunglasApiBundle/forks","keys_url":"https://api.github.com/repos/dunglas/DunglasApiBundle/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dunglas/DunglasApiBundle/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dunglas/DunglasApiBundle/teams","hooks_url":"https://api.github.com/repos/dunglas/DunglasApiBundle/hooks","issue_events_url":"https://api.github.com/repos/dunglas/DunglasApiBundle/issues/events{/number}","events_url":"https://api.github.com/repos/dunglas/DunglasApiBundle/events","assignees_url":"https://api.github.com/repos/dunglas/DunglasApiBundle/assignees{/user}","branches_url":"https://api.github.com/repos/dunglas/DunglasApiBundle/branches{/branch}","tags_url":"https://api.github.com/repos/dunglas/DunglasApiBundle/tags","blobs_url":"https://api.github.com/repos/dunglas/DunglasApiBundle/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dunglas/DunglasApiBundle/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dunglas/DunglasApiBundle/git/refs{/sha}","trees_url":"https://api.github.com/repos/dunglas/DunglasApiBundle/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dunglas/DunglasApiBundle/statuses/{sha}","languages_url":"https://api.github.com/repos/dunglas/DunglasApiBundle/languages","stargazers_url":"https://api.github.com/repos/dunglas/DunglasApiBundle/stargazers","contributors_url":"https://api.github.com/repos/dunglas/DunglasApiBundle/contributors","subscribers_url":"https://api.github.com/repos/dunglas/DunglasApiBundle/subscribers","subscription_url":"https://api.github.com/repos/dunglas/DunglasApiBundle/subscription","commits_url":"https://api.github.com/repos/dunglas/DunglasApiBundle/commits{/sha}","git_commits_url":"https://api.github.com/repos/dunglas/DunglasApiBundle/git/commits{/sha}","comments_url":"https://api.github.com/repos/dunglas/DunglasApiBundle/comments{/number}","issue_comment_url":"https://api.github.com/repos/dunglas/DunglasApiBundle/issues/comments{/number}","contents_url":"https://api.github.com/repos/dunglas/DunglasApiBundle/contents/{+path}","compare_url":"https://api.github.com/repos/dunglas/DunglasApiBundle/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dunglas/DunglasApiBundle/merges","archive_url":"https://api.github.com/repos/dunglas/DunglasApiBundle/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dunglas/DunglasApiBundle/downloads","issues_url":"https://api.github.com/repos/dunglas/DunglasApiBundle/issues{/number}","pulls_url":"https://api.github.com/repos/dunglas/DunglasApiBundle/pulls{/number}","milestones_url":"https://api.github.com/repos/dunglas/DunglasApiBundle/milestones{/number}","notifications_url":"https://api.github.com/repos/dunglas/DunglasApiBundle/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dunglas/DunglasApiBundle/labels{/name}","releases_url":"https://api.github.com/repos/dunglas/DunglasApiBundle/releases{/id}","created_at":"2015-01-19T23:05:56Z","updated_at":"2015-08-05T13:59:20Z","pushed_at":"2015-08-06T22:00:40Z","git_url":"git://github.com/dunglas/DunglasApiBundle.git","ssh_url":"git@github.com:dunglas/DunglasApiBundle.git","clone_url":"https://github.com/dunglas/DunglasApiBundle.git","svn_url":"https://github.com/dunglas/DunglasApiBundle","homepage":"https://api-platform.com","size":2300,"stargazers_count":206,"watchers_count":206,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":37,"mirror_url":null,"open_issues_count":48,"forks":37,"open_issues":48,"watchers":206,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dunglas/DunglasApiBundle/pulls/211"},"html":{"href":"https://github.com/dunglas/DunglasApiBundle/pull/211"},"issue":{"href":"https://api.github.com/repos/dunglas/DunglasApiBundle/issues/211"},"comments":{"href":"https://api.github.com/repos/dunglas/DunglasApiBundle/issues/211/comments"},"review_comments":{"href":"https://api.github.com/repos/dunglas/DunglasApiBundle/pulls/211/comments"},"review_comment":{"href":"https://api.github.com/repos/dunglas/DunglasApiBundle/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dunglas/DunglasApiBundle/pulls/211/commits"},"statuses":{"href":"https://api.github.com/repos/dunglas/DunglasApiBundle/statuses/5c7516e31effc1b4d66ad06f8cc6c4434b643928"}}}}