{"action":"created","comment":{"url":"https://api.github.com/repos/Sylius/Sylius/pulls/comments/74008640","id":74008640,"diff_hunk":"@@ -53,49 +36,79 @@ public function addAction(Request $request)\n     {\n         $configuration = $this->requestConfigurationFactory->create($this->metadata, $request);\n \n-        $cart = $this->getCurrentCart();\n-        $emptyItem = $this->newResourceFactory->create($configuration, $this->factory);\n+        $this->isGrantedOr403($configuration, ResourceActions::CREATE);\n+        $newResource = $this->newResourceFactory->create($configuration, $this->factory);\n \n-        $eventDispatcher = $this->getEventDispatcher();\n+        $itemQuantityModifier = $this->get('sylius.order_item_quantity_modifier');\n+        $itemQuantityModifier->modify($newResource, 1);\n \n-        try {\n-            $item = $this->getResolver()->resolve($emptyItem, $request);\n-        } catch (ItemResolvingException $exception) {\n-            // Write flash message\n-            $eventDispatcher->dispatch(SyliusCartEvents::ITEM_ADD_ERROR, new FlashEvent($exception->getMessage()));\n+        $form = $this->resourceFormFactory->create($configuration, $newResource);\n \n-            return $this->redirectAfterAdd($configuration);\n-        }\n+        if ($request->isMethod('POST') && $form->submit($request)->isValid()) {\n+            $newResource = $form->getData();\n \n-        $event = new CartItemEvent($cart, $item);\n+            $event = $this->eventDispatcher->dispatchPreEvent(ResourceActions::CREATE, $configuration, $newResource);\n \n-        // Update models\n-        $eventDispatcher->dispatch(SyliusCartEvents::ITEM_ADD_INITIALIZE, $event);\n-        $eventDispatcher->dispatch(SyliusCartEvents::CART_CHANGE, new GenericEvent($cart));\n-        $eventDispatcher->dispatch(SyliusCartEvents::CART_SAVE_INITIALIZE, $event);\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-        // Write flash message\n-        $eventDispatcher->dispatch(SyliusCartEvents::ITEM_ADD_COMPLETED, new FlashEvent());\n+                return $this->redirectHandler->redirectToIndex($configuration, $newResource);\n+            }\n \n-        return $this->redirectAfterAdd($configuration);\n-    }\n+            $cart = $this->getCurrentCart();\n \n-    /**\n-     * Redirect to specific URL or to cart.\n-     *\n-     * @param Request $request\n-     *\n-     * @return RedirectResponse\n-     */\n-    private function redirectAfterAdd(RequestConfiguration $configuration)\n-    {\n-        $request = $configuration->getRequest();\n+            $isItemInCart = false;","path":"src/Sylius/Bundle/CartBundle/Controller/CartItemController.php","position":102,"original_position":102,"commit_id":"5e202f2d43dafecd9ba09d394a818a5f241516fa","original_commit_id":"5e202f2d43dafecd9ba09d394a818a5f241516fa","user":{"login":"pamil","id":1897953,"avatar_url":"https://avatars.githubusercontent.com/u/1897953?v=3","gravatar_id":"","url":"https://api.github.com/users/pamil","html_url":"https://github.com/pamil","followers_url":"https://api.github.com/users/pamil/followers","following_url":"https://api.github.com/users/pamil/following{/other_user}","gists_url":"https://api.github.com/users/pamil/gists{/gist_id}","starred_url":"https://api.github.com/users/pamil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pamil/subscriptions","organizations_url":"https://api.github.com/users/pamil/orgs","repos_url":"https://api.github.com/users/pamil/repos","events_url":"https://api.github.com/users/pamil/events{/privacy}","received_events_url":"https://api.github.com/users/pamil/received_events","type":"User","site_admin":false},"body":"?","created_at":"2016-08-09T07:17:04Z","updated_at":"2016-08-09T07:17:04Z","html_url":"https://github.com/Sylius/Sylius/pull/5690#discussion_r74008640","pull_request_url":"https://api.github.com/repos/Sylius/Sylius/pulls/5690","_links":{"self":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/comments/74008640"},"html":{"href":"https://github.com/Sylius/Sylius/pull/5690#discussion_r74008640"},"pull_request":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/5690"}}},"pull_request":{"url":"https://api.github.com/repos/Sylius/Sylius/pulls/5690","id":79908538,"html_url":"https://github.com/Sylius/Sylius/pull/5690","diff_url":"https://github.com/Sylius/Sylius/pull/5690.diff","patch_url":"https://github.com/Sylius/Sylius/pull/5690.patch","issue_url":"https://api.github.com/repos/Sylius/Sylius/issues/5690","number":5690,"state":"open","locked":false,"title":"[Cart] Refactor adding to cart","user":{"login":"GSadee","id":6140884,"avatar_url":"https://avatars.githubusercontent.com/u/6140884?v=3","gravatar_id":"","url":"https://api.github.com/users/GSadee","html_url":"https://github.com/GSadee","followers_url":"https://api.github.com/users/GSadee/followers","following_url":"https://api.github.com/users/GSadee/following{/other_user}","gists_url":"https://api.github.com/users/GSadee/gists{/gist_id}","starred_url":"https://api.github.com/users/GSadee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GSadee/subscriptions","organizations_url":"https://api.github.com/users/GSadee/orgs","repos_url":"https://api.github.com/users/GSadee/repos","events_url":"https://api.github.com/users/GSadee/events{/privacy}","received_events_url":"https://api.github.com/users/GSadee/received_events","type":"User","site_admin":false},"body":"| Q               | A\r\n| --------------- | ---\r\n| Bug fix?        | no\r\n| New feature?    | no\r\n| BC breaks?      | yes\r\n| Related tickets | \r\n| License         | MIT\r\n","created_at":"2016-08-03T13:45:36Z","updated_at":"2016-08-09T07:17:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"94c911ed55d556ecc96ef4c6b129eabfd0cd8669","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Sylius/Sylius/pulls/5690/commits","review_comments_url":"https://api.github.com/repos/Sylius/Sylius/pulls/5690/comments","review_comment_url":"https://api.github.com/repos/Sylius/Sylius/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Sylius/Sylius/issues/5690/comments","statuses_url":"https://api.github.com/repos/Sylius/Sylius/statuses/5e202f2d43dafecd9ba09d394a818a5f241516fa","head":{"label":"GSadee:refactor-adding-to-cart","ref":"refactor-adding-to-cart","sha":"5e202f2d43dafecd9ba09d394a818a5f241516fa","user":{"login":"GSadee","id":6140884,"avatar_url":"https://avatars.githubusercontent.com/u/6140884?v=3","gravatar_id":"","url":"https://api.github.com/users/GSadee","html_url":"https://github.com/GSadee","followers_url":"https://api.github.com/users/GSadee/followers","following_url":"https://api.github.com/users/GSadee/following{/other_user}","gists_url":"https://api.github.com/users/GSadee/gists{/gist_id}","starred_url":"https://api.github.com/users/GSadee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GSadee/subscriptions","organizations_url":"https://api.github.com/users/GSadee/orgs","repos_url":"https://api.github.com/users/GSadee/repos","events_url":"https://api.github.com/users/GSadee/events{/privacy}","received_events_url":"https://api.github.com/users/GSadee/received_events","type":"User","site_admin":false},"repo":{"id":41030239,"name":"Sylius","full_name":"GSadee/Sylius","owner":{"login":"GSadee","id":6140884,"avatar_url":"https://avatars.githubusercontent.com/u/6140884?v=3","gravatar_id":"","url":"https://api.github.com/users/GSadee","html_url":"https://github.com/GSadee","followers_url":"https://api.github.com/users/GSadee/followers","following_url":"https://api.github.com/users/GSadee/following{/other_user}","gists_url":"https://api.github.com/users/GSadee/gists{/gist_id}","starred_url":"https://api.github.com/users/GSadee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GSadee/subscriptions","organizations_url":"https://api.github.com/users/GSadee/orgs","repos_url":"https://api.github.com/users/GSadee/repos","events_url":"https://api.github.com/users/GSadee/events{/privacy}","received_events_url":"https://api.github.com/users/GSadee/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/GSadee/Sylius","description":"Modern e-commerce for PHP, based on the Symfony2 framework.","fork":true,"url":"https://api.github.com/repos/GSadee/Sylius","forks_url":"https://api.github.com/repos/GSadee/Sylius/forks","keys_url":"https://api.github.com/repos/GSadee/Sylius/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GSadee/Sylius/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GSadee/Sylius/teams","hooks_url":"https://api.github.com/repos/GSadee/Sylius/hooks","issue_events_url":"https://api.github.com/repos/GSadee/Sylius/issues/events{/number}","events_url":"https://api.github.com/repos/GSadee/Sylius/events","assignees_url":"https://api.github.com/repos/GSadee/Sylius/assignees{/user}","branches_url":"https://api.github.com/repos/GSadee/Sylius/branches{/branch}","tags_url":"https://api.github.com/repos/GSadee/Sylius/tags","blobs_url":"https://api.github.com/repos/GSadee/Sylius/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GSadee/Sylius/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GSadee/Sylius/git/refs{/sha}","trees_url":"https://api.github.com/repos/GSadee/Sylius/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GSadee/Sylius/statuses/{sha}","languages_url":"https://api.github.com/repos/GSadee/Sylius/languages","stargazers_url":"https://api.github.com/repos/GSadee/Sylius/stargazers","contributors_url":"https://api.github.com/repos/GSadee/Sylius/contributors","subscribers_url":"https://api.github.com/repos/GSadee/Sylius/subscribers","subscription_url":"https://api.github.com/repos/GSadee/Sylius/subscription","commits_url":"https://api.github.com/repos/GSadee/Sylius/commits{/sha}","git_commits_url":"https://api.github.com/repos/GSadee/Sylius/git/commits{/sha}","comments_url":"https://api.github.com/repos/GSadee/Sylius/comments{/number}","issue_comment_url":"https://api.github.com/repos/GSadee/Sylius/issues/comments{/number}","contents_url":"https://api.github.com/repos/GSadee/Sylius/contents/{+path}","compare_url":"https://api.github.com/repos/GSadee/Sylius/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GSadee/Sylius/merges","archive_url":"https://api.github.com/repos/GSadee/Sylius/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GSadee/Sylius/downloads","issues_url":"https://api.github.com/repos/GSadee/Sylius/issues{/number}","pulls_url":"https://api.github.com/repos/GSadee/Sylius/pulls{/number}","milestones_url":"https://api.github.com/repos/GSadee/Sylius/milestones{/number}","notifications_url":"https://api.github.com/repos/GSadee/Sylius/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GSadee/Sylius/labels{/name}","releases_url":"https://api.github.com/repos/GSadee/Sylius/releases{/id}","deployments_url":"https://api.github.com/repos/GSadee/Sylius/deployments","created_at":"2015-08-19T11:32:38Z","updated_at":"2016-03-04T07:43:28Z","pushed_at":"2016-08-08T09:02:33Z","git_url":"git://github.com/GSadee/Sylius.git","ssh_url":"git@github.com:GSadee/Sylius.git","clone_url":"https://github.com/GSadee/Sylius.git","svn_url":"https://github.com/GSadee/Sylius","homepage":"Sylius.org","size":41071,"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":"475bf607a7b58f24b8a063faf1670b82d6f66fad","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-08-08T17:58:49Z","pushed_at":"2016-08-09T05:54:51Z","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":75977,"stargazers_count":2399,"watchers_count":2399,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":887,"mirror_url":null,"open_issues_count":766,"forks":887,"open_issues":766,"watchers":2399,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/5690"},"html":{"href":"https://github.com/Sylius/Sylius/pull/5690"},"issue":{"href":"https://api.github.com/repos/Sylius/Sylius/issues/5690"},"comments":{"href":"https://api.github.com/repos/Sylius/Sylius/issues/5690/comments"},"review_comments":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/5690/comments"},"review_comment":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/5690/commits"},"statuses":{"href":"https://api.github.com/repos/Sylius/Sylius/statuses/5e202f2d43dafecd9ba09d394a818a5f241516fa"}}}}
{"actor":{"display_login":"pamil"}}