{"action":"created","comment":{"url":"https://api.github.com/repos/Sylius/Sylius/pulls/comments/38895405","id":38895405,"diff_hunk":"@@ -0,0 +1,123 @@\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\\Inventory\\Factory;\n+\n+use Doctrine\\Common\\Collections\\ArrayCollection;\n+use Doctrine\\Common\\Persistence\\ObjectManager;\n+use Sylius\\Component\\Inventory\\Model\\StockItemInterface;\n+use Sylius\\Component\\Inventory\\Model\\StockLocationInterface;\n+use Sylius\\Component\\Inventory\\Model\\StockableInterface;\n+use Sylius\\Component\\Inventory\\Repository\\StockItemRepositoryInterface;\n+use Sylius\\Component\\Resource\\Repository\\RepositoryInterface;\n+\n+/**\n+ * Stock item factory.\n+ *\n+ * @author Paweł Jędrzejewski <pawel@sylius.org>\n+ */\n+class StockItemFactory implements StockItemFactoryInterface\n+{\n+    /**\n+     * @var StockItemRepositoryInterface\n+     */\n+    protected $stockItemRepository;\n+\n+    /**\n+     * @var ObjectManager\n+     */\n+    protected $stockItemManager;\n+\n+    /**\n+     * @var RepositoryInterface\n+     */\n+    protected $stockLocationRepository;\n+\n+    /**\n+     * @var RepositoryInterface\n+     */\n+    protected $stockableRepository;\n+\n+    /**\n+     * Constructor.\n+     *\n+     * @param StockRepositoryInterface $stockItemRepository\n+     * @param ObjectManager            $stockItemManager\n+     * @param RepositoryInterface      $stockLocationRepository\n+     * @param RepositoryInterface      $stockableRepository\n+     */\n+    public function __construct(\n+        StockItemRepositoryInterface $stockItemRepository,\n+        ObjectManager $stockItemManager,\n+        RepositoryInterface $stockLocationRepository,\n+        RepositoryInterface $stockableRepository\n+    )\n+    {\n+        $this->stockItemRepository = $stockItemRepository;\n+        $this->stockItemManager = $stockItemManager;\n+        $this->stockLocationRepository = $stockLocationRepository;\n+        $this->stockableRepository = $stockableRepository;\n+    }\n+\n+    /**\n+     * {@inheritdoc}\n+     */\n+    public function create(StockableInterface $stockable, StockLocationInterface $location)\n+    {\n+        if (null !== $item = $this->stockItemRepository->findByStockableAndLocation($stockable, $location)) {\n+            return $item;\n+        }\n+\n+        $item = $this->stockItemRepository->createNew();\n+        $item\n+            ->setStockable($stockable)\n+            ->setLocation($location)","path":"src/Sylius/Component/Inventory/Factory/StockItemFactory.php","position":82,"original_position":82,"commit_id":"ff13abbecf5f1b43dec84755d81e28a615e7f94f","original_commit_id":"ff13abbecf5f1b43dec84755d81e28a615e7f94f","user":{"login":"stloyd","id":67402,"avatar_url":"https://avatars.githubusercontent.com/u/67402?v=3","gravatar_id":"","url":"https://api.github.com/users/stloyd","html_url":"https://github.com/stloyd","followers_url":"https://api.github.com/users/stloyd/followers","following_url":"https://api.github.com/users/stloyd/following{/other_user}","gists_url":"https://api.github.com/users/stloyd/gists{/gist_id}","starred_url":"https://api.github.com/users/stloyd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stloyd/subscriptions","organizations_url":"https://api.github.com/users/stloyd/orgs","repos_url":"https://api.github.com/users/stloyd/repos","events_url":"https://api.github.com/users/stloyd/events{/privacy}","received_events_url":"https://api.github.com/users/stloyd/received_events","type":"User","site_admin":false},"body":"Don't use fluent interface.","created_at":"2015-09-08T07:14:17Z","updated_at":"2015-09-08T07:14:17Z","html_url":"https://github.com/Sylius/Sylius/pull/3233#discussion_r38895405","pull_request_url":"https://api.github.com/repos/Sylius/Sylius/pulls/3233","_links":{"self":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/comments/38895405"},"html":{"href":"https://github.com/Sylius/Sylius/pull/3233#discussion_r38895405"},"pull_request":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/3233"}}},"pull_request":{"url":"https://api.github.com/repos/Sylius/Sylius/pulls/3233","id":44398534,"html_url":"https://github.com/Sylius/Sylius/pull/3233","diff_url":"https://github.com/Sylius/Sylius/pull/3233.diff","patch_url":"https://github.com/Sylius/Sylius/pull/3233.patch","issue_url":"https://api.github.com/repos/Sylius/Sylius/issues/3233","number":3233,"state":"open","locked":false,"title":"[WIP] Multi stock ","user":{"login":"umpirsky","id":208957,"avatar_url":"https://avatars.githubusercontent.com/u/208957?v=3","gravatar_id":"","url":"https://api.github.com/users/umpirsky","html_url":"https://github.com/umpirsky","followers_url":"https://api.github.com/users/umpirsky/followers","following_url":"https://api.github.com/users/umpirsky/following{/other_user}","gists_url":"https://api.github.com/users/umpirsky/gists{/gist_id}","starred_url":"https://api.github.com/users/umpirsky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/umpirsky/subscriptions","organizations_url":"https://api.github.com/users/umpirsky/orgs","repos_url":"https://api.github.com/users/umpirsky/repos","events_url":"https://api.github.com/users/umpirsky/events{/privacy}","received_events_url":"https://api.github.com/users/umpirsky/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-09-08T07:01:36Z","updated_at":"2015-09-08T07:14:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2a3f2d812ef2e2b2e0f40f57d8091ea03a14c38c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Sylius/Sylius/pulls/3233/commits","review_comments_url":"https://api.github.com/repos/Sylius/Sylius/pulls/3233/comments","review_comment_url":"https://api.github.com/repos/Sylius/Sylius/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Sylius/Sylius/issues/3233/comments","statuses_url":"https://api.github.com/repos/Sylius/Sylius/statuses/ff13abbecf5f1b43dec84755d81e28a615e7f94f","head":{"label":"Sylius:feature/multi-stock","ref":"feature/multi-stock","sha":"ff13abbecf5f1b43dec84755d81e28a615e7f94f","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":"Modern e-commerce for PHP, based on the Symfony2 framework.","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}","created_at":"2011-11-05T22:05:52Z","updated_at":"2015-09-08T06:34:39Z","pushed_at":"2015-09-08T07:01:36Z","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":"Sylius.org","size":67873,"stargazers_count":1927,"watchers_count":1927,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":694,"mirror_url":null,"open_issues_count":488,"forks":694,"open_issues":488,"watchers":1927,"default_branch":"master"}},"base":{"label":"Sylius:master","ref":"master","sha":"16d0b8eb5c7477a9a46758337a8ef4415826751e","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":"Modern e-commerce for PHP, based on the Symfony2 framework.","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}","created_at":"2011-11-05T22:05:52Z","updated_at":"2015-09-08T06:34:39Z","pushed_at":"2015-09-08T07:01:36Z","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":"Sylius.org","size":67873,"stargazers_count":1927,"watchers_count":1927,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":694,"mirror_url":null,"open_issues_count":488,"forks":694,"open_issues":488,"watchers":1927,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/3233"},"html":{"href":"https://github.com/Sylius/Sylius/pull/3233"},"issue":{"href":"https://api.github.com/repos/Sylius/Sylius/issues/3233"},"comments":{"href":"https://api.github.com/repos/Sylius/Sylius/issues/3233/comments"},"review_comments":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/3233/comments"},"review_comment":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/3233/commits"},"statuses":{"href":"https://api.github.com/repos/Sylius/Sylius/statuses/ff13abbecf5f1b43dec84755d81e28a615e7f94f"}}}}