{"action":"created","comment":{"url":"https://api.github.com/repos/Sylius/Sylius/pulls/comments/56712831","id":56712831,"diff_hunk":"@@ -368,6 +380,43 @@ public function deleteAction(Request $request)\n      *\n      * @return RedirectResponse\n      */\n+    public function applyStateMachineTransitionAction(Request $request)\n+    {\n+        $configuration = $this->requestConfigurationFactory->create($this->metadata, $request);\n+\n+        $this->isGrantedOr403($configuration, ResourceActions::UPDATE);\n+        $resource = $this->findOr404($configuration);\n+\n+        $event = $this->eventDispatcher->dispatchPreEvent(ResourceActions::UPDATE, $configuration, $resource);\n+\n+        if ($event->isStopped() && !$configuration->isHtmlRequest()) {\n+            throw new HttpException($event->getErrorCode(), $event->getMessage());\n+        }\n+        if ($event->isStopped()) {\n+            $this->flashHelper->addFlashFromEvent($configuration, $event);\n+\n+            return $this->redirectHandler->redirectToResource($configuration, $resource);\n+        }\n+\n+        $this->stateMachine->apply($configuration, $resource);\n+        $this->manager->flush();\n+\n+        $this->eventDispatcher->dispatchPostEvent(ResourceActions::UPDATE, $configuration, $resource);\n+\n+        if (!$configuration->isHtmlRequest()) {\n+            return $this->viewHandler->handle($configuration, View::create(null, 204));","path":"src/Sylius/Bundle/ResourceBundle/Controller/ResourceController.php","position":77,"original_position":77,"commit_id":"e4e04e5a00ab05d5d77ed82838faa09244c3ed5b","original_commit_id":"e4e04e5a00ab05d5d77ed82838faa09244c3ed5b","user":{"login":"liverbool","id":206804,"avatar_url":"https://avatars.githubusercontent.com/u/206804?v=3","gravatar_id":"","url":"https://api.github.com/users/liverbool","html_url":"https://github.com/liverbool","followers_url":"https://api.github.com/users/liverbool/followers","following_url":"https://api.github.com/users/liverbool/following{/other_user}","gists_url":"https://api.github.com/users/liverbool/gists{/gist_id}","starred_url":"https://api.github.com/users/liverbool/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/liverbool/subscriptions","organizations_url":"https://api.github.com/users/liverbool/orgs","repos_url":"https://api.github.com/users/liverbool/repos","events_url":"https://api.github.com/users/liverbool/events{/privacy}","received_events_url":"https://api.github.com/users/liverbool/received_events","type":"User","site_admin":false},"body":"Amm, I think should return `200` status and response `resource` to get new state of resource, The client can't know about what's new state changed to.","created_at":"2016-03-18T19:51:36Z","updated_at":"2016-03-18T19:51:36Z","html_url":"https://github.com/Sylius/Sylius/pull/4542#discussion_r56712831","pull_request_url":"https://api.github.com/repos/Sylius/Sylius/pulls/4542","_links":{"self":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/comments/56712831"},"html":{"href":"https://github.com/Sylius/Sylius/pull/4542#discussion_r56712831"},"pull_request":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/4542"}}},"pull_request":{"url":"https://api.github.com/repos/Sylius/Sylius/pulls/4542","id":63244333,"html_url":"https://github.com/Sylius/Sylius/pull/4542","diff_url":"https://github.com/Sylius/Sylius/pull/4542.diff","patch_url":"https://github.com/Sylius/Sylius/pull/4542.patch","issue_url":"https://api.github.com/repos/Sylius/Sylius/issues/4542","number":4542,"state":"open","locked":false,"title":"[ResourceBundle] Allow applying transition when updating resources","user":{"login":"pjedrzejewski","id":614970,"avatar_url":"https://avatars.githubusercontent.com/u/614970?v=3","gravatar_id":"","url":"https://api.github.com/users/pjedrzejewski","html_url":"https://github.com/pjedrzejewski","followers_url":"https://api.github.com/users/pjedrzejewski/followers","following_url":"https://api.github.com/users/pjedrzejewski/following{/other_user}","gists_url":"https://api.github.com/users/pjedrzejewski/gists{/gist_id}","starred_url":"https://api.github.com/users/pjedrzejewski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pjedrzejewski/subscriptions","organizations_url":"https://api.github.com/users/pjedrzejewski/orgs","repos_url":"https://api.github.com/users/pjedrzejewski/repos","events_url":"https://api.github.com/users/pjedrzejewski/events{/privacy}","received_events_url":"https://api.github.com/users/pjedrzejewski/received_events","type":"User","site_admin":false},"body":"| Q               | A\r\n| --------------- | ---\r\n| Bug fix?        | no\r\n| New feature?    | yes\r\n| BC breaks?      | yes\r\n| Deprecations?   | no\r\n| Related tickets | -\r\n| License         | MIT\r\n| Doc PR          | -\r\n\r\nSummary:\r\n\r\n* Renamed ``updateStateAction`` to ``applyStateMachineTransitionAction`` in ResourceController;\r\n* Extracted logic to separate service;\r\n* Reimplemented the action from scratch BDD wayyy;\r\n* Added ability to execute transition during updateAction :tada: \r\n\r\nThe most important is the last point. Use cases:\r\n\r\nAny action that needs to edit something on the resource and apply transition. Simplest example: shipping a shipment. We want to specify tracking code and apply \"ship\" transition - doable with routing configuration alone now.\r\n\r\nMore crazy use-case: simplified checkout process. Our checkout right now is:\r\n\r\n* edit order via form (change address, select shipping method, select payment method)\r\n* apply transition\r\n* save\r\n* redirect\r\n\r\nUsing FlowBundle for all that is quite an overkill and does not work via API nicely. With this action we can do it with HTML/XML/JSON. :D I recall pasing some examples in another issue, but can't find it.\r\n\r\n\r\n","created_at":"2016-03-17T15:44:56Z","updated_at":"2016-03-18T19:51:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5500cb1a1171137cc66cc2abc187ff369aa53f8b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Sylius/Sylius/pulls/4542/commits","review_comments_url":"https://api.github.com/repos/Sylius/Sylius/pulls/4542/comments","review_comment_url":"https://api.github.com/repos/Sylius/Sylius/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Sylius/Sylius/issues/4542/comments","statuses_url":"https://api.github.com/repos/Sylius/Sylius/statuses/e4e04e5a00ab05d5d77ed82838faa09244c3ed5b","head":{"label":"pjedrzejewski:state-machine-on-update-action","ref":"state-machine-on-update-action","sha":"e4e04e5a00ab05d5d77ed82838faa09244c3ed5b","user":{"login":"pjedrzejewski","id":614970,"avatar_url":"https://avatars.githubusercontent.com/u/614970?v=3","gravatar_id":"","url":"https://api.github.com/users/pjedrzejewski","html_url":"https://github.com/pjedrzejewski","followers_url":"https://api.github.com/users/pjedrzejewski/followers","following_url":"https://api.github.com/users/pjedrzejewski/following{/other_user}","gists_url":"https://api.github.com/users/pjedrzejewski/gists{/gist_id}","starred_url":"https://api.github.com/users/pjedrzejewski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pjedrzejewski/subscriptions","organizations_url":"https://api.github.com/users/pjedrzejewski/orgs","repos_url":"https://api.github.com/users/pjedrzejewski/repos","events_url":"https://api.github.com/users/pjedrzejewski/events{/privacy}","received_events_url":"https://api.github.com/users/pjedrzejewski/received_events","type":"User","site_admin":false},"repo":{"id":14465495,"name":"Sylius","full_name":"pjedrzejewski/Sylius","owner":{"login":"pjedrzejewski","id":614970,"avatar_url":"https://avatars.githubusercontent.com/u/614970?v=3","gravatar_id":"","url":"https://api.github.com/users/pjedrzejewski","html_url":"https://github.com/pjedrzejewski","followers_url":"https://api.github.com/users/pjedrzejewski/followers","following_url":"https://api.github.com/users/pjedrzejewski/following{/other_user}","gists_url":"https://api.github.com/users/pjedrzejewski/gists{/gist_id}","starred_url":"https://api.github.com/users/pjedrzejewski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pjedrzejewski/subscriptions","organizations_url":"https://api.github.com/users/pjedrzejewski/orgs","repos_url":"https://api.github.com/users/pjedrzejewski/repos","events_url":"https://api.github.com/users/pjedrzejewski/events{/privacy}","received_events_url":"https://api.github.com/users/pjedrzejewski/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/pjedrzejewski/Sylius","description":"Modern e-commerce for PHP, based on the Symfony2 framework.","fork":true,"url":"https://api.github.com/repos/pjedrzejewski/Sylius","forks_url":"https://api.github.com/repos/pjedrzejewski/Sylius/forks","keys_url":"https://api.github.com/repos/pjedrzejewski/Sylius/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pjedrzejewski/Sylius/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pjedrzejewski/Sylius/teams","hooks_url":"https://api.github.com/repos/pjedrzejewski/Sylius/hooks","issue_events_url":"https://api.github.com/repos/pjedrzejewski/Sylius/issues/events{/number}","events_url":"https://api.github.com/repos/pjedrzejewski/Sylius/events","assignees_url":"https://api.github.com/repos/pjedrzejewski/Sylius/assignees{/user}","branches_url":"https://api.github.com/repos/pjedrzejewski/Sylius/branches{/branch}","tags_url":"https://api.github.com/repos/pjedrzejewski/Sylius/tags","blobs_url":"https://api.github.com/repos/pjedrzejewski/Sylius/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pjedrzejewski/Sylius/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pjedrzejewski/Sylius/git/refs{/sha}","trees_url":"https://api.github.com/repos/pjedrzejewski/Sylius/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pjedrzejewski/Sylius/statuses/{sha}","languages_url":"https://api.github.com/repos/pjedrzejewski/Sylius/languages","stargazers_url":"https://api.github.com/repos/pjedrzejewski/Sylius/stargazers","contributors_url":"https://api.github.com/repos/pjedrzejewski/Sylius/contributors","subscribers_url":"https://api.github.com/repos/pjedrzejewski/Sylius/subscribers","subscription_url":"https://api.github.com/repos/pjedrzejewski/Sylius/subscription","commits_url":"https://api.github.com/repos/pjedrzejewski/Sylius/commits{/sha}","git_commits_url":"https://api.github.com/repos/pjedrzejewski/Sylius/git/commits{/sha}","comments_url":"https://api.github.com/repos/pjedrzejewski/Sylius/comments{/number}","issue_comment_url":"https://api.github.com/repos/pjedrzejewski/Sylius/issues/comments{/number}","contents_url":"https://api.github.com/repos/pjedrzejewski/Sylius/contents/{+path}","compare_url":"https://api.github.com/repos/pjedrzejewski/Sylius/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pjedrzejewski/Sylius/merges","archive_url":"https://api.github.com/repos/pjedrzejewski/Sylius/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pjedrzejewski/Sylius/downloads","issues_url":"https://api.github.com/repos/pjedrzejewski/Sylius/issues{/number}","pulls_url":"https://api.github.com/repos/pjedrzejewski/Sylius/pulls{/number}","milestones_url":"https://api.github.com/repos/pjedrzejewski/Sylius/milestones{/number}","notifications_url":"https://api.github.com/repos/pjedrzejewski/Sylius/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pjedrzejewski/Sylius/labels{/name}","releases_url":"https://api.github.com/repos/pjedrzejewski/Sylius/releases{/id}","deployments_url":"https://api.github.com/repos/pjedrzejewski/Sylius/deployments","created_at":"2013-11-17T11:15:26Z","updated_at":"2015-05-04T15:19:45Z","pushed_at":"2016-03-17T18:53:50Z","git_url":"git://github.com/pjedrzejewski/Sylius.git","ssh_url":"git@github.com:pjedrzejewski/Sylius.git","clone_url":"https://github.com/pjedrzejewski/Sylius.git","svn_url":"https://github.com/pjedrzejewski/Sylius","homepage":"Sylius.org","size":29254,"stargazers_count":7,"watchers_count":7,"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":7,"default_branch":"master"}},"base":{"label":"Sylius:master","ref":"master","sha":"33d1e1daa131a1e2139072546fb7f42c1178505d","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":"eCommerce PHP framework built on top of Symfony with component-based architecture and format-agnostic rendering. (HTML/JSON/XML)","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}","deployments_url":"https://api.github.com/repos/Sylius/Sylius/deployments","created_at":"2011-11-05T22:05:52Z","updated_at":"2016-03-18T12:56:22Z","pushed_at":"2016-03-18T19:10:46Z","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":"http://Sylius.org","size":58791,"stargazers_count":2214,"watchers_count":2214,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":808,"mirror_url":null,"open_issues_count":591,"forks":808,"open_issues":591,"watchers":2214,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/4542"},"html":{"href":"https://github.com/Sylius/Sylius/pull/4542"},"issue":{"href":"https://api.github.com/repos/Sylius/Sylius/issues/4542"},"comments":{"href":"https://api.github.com/repos/Sylius/Sylius/issues/4542/comments"},"review_comments":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/4542/comments"},"review_comment":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/4542/commits"},"statuses":{"href":"https://api.github.com/repos/Sylius/Sylius/statuses/e4e04e5a00ab05d5d77ed82838faa09244c3ed5b"}}}}