{"action":"created","comment":{"url":"https://api.github.com/repos/Sylius/Sylius/pulls/comments/71528158","id":71528158,"diff_hunk":"@@ -0,0 +1,78 @@\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\\Component\\Core\\Cart\\Provider;\n+\n+use Sylius\\Component\\Cart\\Model\\CartInterface;\n+use Sylius\\Component\\Cart\\Provider\\CartProviderInterface;\n+use Sylius\\Component\\Channel\\Context\\ChannelNotFoundException;\n+use Sylius\\Component\\Core\\Context\\ShopperContextInterface;\n+use Sylius\\Component\\Core\\Model\\OrderInterface;\n+\n+/**\n+ * @author Paweł Jędrzejewski <pawel@sylius.org>\n+ */\n+class NewCartProvider implements CartProviderInterface\n+{\n+    /**\n+     * @var CartProviderInterface\n+     */\n+    private $decoratedCartProvider;\n+\n+    /**\n+     * @var ShopperContextInterface\n+     */\n+    private $shopperContext;\n+\n+    /**\n+     * @var CartInterface\n+     */\n+    private $cart;\n+\n+    /**\n+     * @param CartProviderInterface $decoratedCartProvider\n+     * @param ShopperContextInterface $shopperContext\n+     */\n+    public function __construct(CartProviderInterface $decoratedCartProvider, ShopperContextInterface $shopperContext)\n+    {\n+        $this->decoratedCartProvider = $decoratedCartProvider;\n+        $this->shopperContext = $shopperContext;\n+    }\n+\n+    /**\n+     * {@inheritdoc}\n+     */\n+    public function getCart()\n+    {\n+        if (null !== $this->cart) {\n+            return $this->cart;\n+        }\n+\n+        /** @var OrderInterface $cart */\n+        $cart = $this->decoratedCartProvider->getCart();\n+\n+        if (null === $cart) {\n+            throw new \\LogicException('Decorated cart provider must return a cart instance, null given.');\n+        }\n+\n+        try {\n+            $cart->setChannel($this->shopperContext->getChannel());\n+        } catch (ChannelNotFoundException $exception) {\n+            $cart->setChannel();","path":"src/Sylius/Component/Core/Cart/Provider/NewCartProvider.php","position":69,"original_position":69,"commit_id":"3ba8673c92faeecdd5410d4a4978da5581e23942","original_commit_id":"3ba8673c92faeecdd5410d4a4978da5581e23942","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":"Anyway, `$cart->setChannel(null);`","created_at":"2016-07-20T13:54:05Z","updated_at":"2016-07-20T13:54:05Z","html_url":"https://github.com/Sylius/Sylius/pull/5197#discussion_r71528158","pull_request_url":"https://api.github.com/repos/Sylius/Sylius/pulls/5197","_links":{"self":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/comments/71528158"},"html":{"href":"https://github.com/Sylius/Sylius/pull/5197#discussion_r71528158"},"pull_request":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/5197"}}},"pull_request":{"url":"https://api.github.com/repos/Sylius/Sylius/pulls/5197","id":72963880,"html_url":"https://github.com/Sylius/Sylius/pull/5197","diff_url":"https://github.com/Sylius/Sylius/pull/5197.diff","patch_url":"https://github.com/Sylius/Sylius/pull/5197.patch","issue_url":"https://api.github.com/repos/Sylius/Sylius/issues/5197","number":5197,"state":"open","locked":false,"title":"[Cart][Core] Rework the logic behind the cart","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?        | yes\r\n| New feature?    | yes\r\n| BC breaks?      | yes\r\n| Related tickets | -\r\n| License         | MIT\r\n\r\nBased on #5196.\r\n\r\nSummary of changes:\r\n\r\n* Simplified getting the cart to ``sylius.context.cart`` service and ``getCart`` method;\r\n* Context uses a prioritized list of services tagged as ``sylius.cart_provider``;\r\n* It returns the cart from the first provider that actually figures out how to get the cart\r\n\r\nCurrently there is:\r\n\r\n* NewCartProvider - it always returns an empty cart (Cart component)\r\n* NewCartProvider (decorates the 1st one) - it always returns an empty cart, but also assigns the channel, currency, customer (if defined) and in the near future also the locale (Core component)\r\n* SessionCartProvider - it tries to find the cart id in the session (CartBundle), shall be used for not logged in customers;\r\n* ExistingCartProvider - Tries to find the cart of currently logged customer (this will give us persistent carts quite easily)\r\n\r\nPrevious logic was a mess, so I am trying to clean up these things a bit and make it more consistent with the rest of the platform.\r\n\r\nTodo:\r\n\r\n- [x] Update all other occurrences of CartProvider in both specs and code\r\n- [x] Finish implementation of existing cart provider\r\n- [x] Figure out a nice way to save the id of the cart in the session (for the sake of SessionCartProvider)\r\n\r\nExample usage:\r\n\r\n``` yaml\r\nservices:\r\n    app.cart_provider.custom:\r\n        class: App\\Cart\\Provider\\CustomCartProvider\r\n        tags:\r\n            - { name: sylius.cart_provider, priority: 1000 }\r\n```\r\n\r\nAnd next ``sylius.context.cart::getCart()`` call uses your logic to get the cart, if you do not return it - it fallbacks to Sylius logic (further providers try to return the cart)... Simple as that. :)\r\n","created_at":"2016-06-07T23:13:41Z","updated_at":"2016-07-20T13:54:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4ed3d4a4977fbc497116ac097e5d85f9323baf9c","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Sylius/Sylius/pulls/5197/commits","review_comments_url":"https://api.github.com/repos/Sylius/Sylius/pulls/5197/comments","review_comment_url":"https://api.github.com/repos/Sylius/Sylius/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Sylius/Sylius/issues/5197/comments","statuses_url":"https://api.github.com/repos/Sylius/Sylius/statuses/3ba8673c92faeecdd5410d4a4978da5581e23942","head":{"label":"pjedrzejewski:experimental/cart-providing-refactoring","ref":"experimental/cart-providing-refactoring","sha":"3ba8673c92faeecdd5410d4a4978da5581e23942","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-07-20T09:16:35Z","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":40324,"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":"51cb232174014d8cef2aab9f03fe7afdc1652576","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-07-19T15:11:00Z","pushed_at":"2016-07-20T13:44: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":"http://Sylius.org","size":73682,"stargazers_count":2380,"watchers_count":2380,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":877,"mirror_url":null,"open_issues_count":733,"forks":877,"open_issues":733,"watchers":2380,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/5197"},"html":{"href":"https://github.com/Sylius/Sylius/pull/5197"},"issue":{"href":"https://api.github.com/repos/Sylius/Sylius/issues/5197"},"comments":{"href":"https://api.github.com/repos/Sylius/Sylius/issues/5197/comments"},"review_comments":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/5197/comments"},"review_comment":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/5197/commits"},"statuses":{"href":"https://api.github.com/repos/Sylius/Sylius/statuses/3ba8673c92faeecdd5410d4a4978da5581e23942"}}}}
{"actor":{"display_login":"pamil"}}