{"action":"created","comment":{"url":"https://api.github.com/repos/Sylius/Sylius-Docs/pulls/comments/44276964","id":44276964,"diff_hunk":"@@ -0,0 +1,148 @@\n+Basic Usage\n+===========\n+\n+.. _component_promotion_generator_coupon-generator:\n+\n+CouponGenerator\n+---------------\n+\n+In order to automate the process of coupon generation the component provides us with a Coupon Generator.\n+\n+.. code-block:: php\n+\n+    <?php\n+\n+    use Sylius\\Component\\Promotion\\Model\\Promotion;\n+    use Sylius\\Component\\Promotion\\Generator\\Instruction;\n+    use Sylius\\Component\\Promotion\\Generator\\CouponGenerator;\n+\n+    $promotion = new Promotion();\n+\n+    $instruction = new Instruction(); // $amount = 5 by default\n+\n+    /**\n+     * @param RepositoryInterface    $repository\n+     * @param EntityManagerInterface $manager\n+     */\n+    $generator = new CouponGenerator($repository, $manager);\n+\n+    //This will generate and persist 5 coupons into the database\n+    //basing on the instruction provided for the given promotion object\n+    $generator->generate($promotion, $instruction);\n+\n+    // We can also generate one unique code, and assign it to a new Coupon.\n+    $code = $gen->generateUniqueCode();\n+    $coupon = new Coupon();\n+    $coupon->setCode($code);\n+\n+\n+.. _component_promotion_checker_promotion-eligibility-checker:\n+\n+PromotionEligibilityChecker\n+---------------------------\n+\n+.. code-block:: php\n+\n+    <?php\n+\n+    use Sylius\\Component\\Promotion\\Model\\Promotion;\n+    use Sylius\\Component\\Core\\Model\\OrderItem;\n+    use Sylius\\Component\\Promotion\\Model\\Rule;\n+    use Sylius\\Component\\Promotion\\Model\\Action;\n+    use Sylius\\Component\\Promotion\\Checker\\PromotionEligibilityChecker;\n+\n+    /**\n+     * @param ServiceRegistryInterface $registry\n+     * @param EventDispatcherInterface $dispatcher\n+     */\n+    $checker = new PromotionEligibilityChecker($registry, $dispatcher);\n+\n+    // Let's create a new promotion\n+    $promotion = new Promotion();\n+    $promotion->setName('Test');\n+    $promotion->setUsageLimit(0);\n+    $promotion->setUsed(0);\n+\n+    // And a new action for that promotion, that will give a fixed discount of 10\n+    $action = new Action();\n+    $action->setType('fixed_discount');\n+    $action->setConfiguration(array('amount' => 10));\n+    $action->setPromotion($promotion);\n+\n+    // That promotion will also have a rule - works for item amounts over 3\n+    $rule = new Rule();\n+    $rule->setType('item_count');\n+    $rule->setConfiguration(array('count' => 3));\n+\n+    $promotion->addRule($rule);\n+\n+    // Now we need an object that implements the PromotionSubjectInterface\n+    $orderItem = new OrderItem();\n+    $orderItem->setUnitPrice(10);\n+    $orderItem->setQuantity(4);\n+    $orderItem->addPromotion($promotion);\n+\n+    $checker->isEligible($orderItem, $promotion); // Returns true\n+\n+.. note::\n+\n+    It implements ``PromotionEligibilityCheckerInterface``\n+\n+\n+.. _component_promotion_action_promotion-applicator:\n+\n+PromotionApplicator\n+-------------------\n+\n+In order to automate the process of promotion application the component provides us with a Promotion Applicator.\n+\n+.. code-block:: php\n+\n+    <?php\n+\n+    use Sylius\\Component\\Promotion\\Action\\PromotionApplicator;\n+    use Sylius\\Component\\Registry\\ServiceRegistry;\n+    use Sylius\\Component\\Promotion\\Model\\Promotion;\n+\n+    $registry = new ServiceRegistry('interface');","path":"components/Promotion/basic_usage.rst","position":107,"original_position":107,"commit_id":"5aa56c87cf755e531de2aea0679c3e025c47cf6f","original_commit_id":"5aa56c87cf755e531de2aea0679c3e025c47cf6f","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":"Here, the ``interface`` should be concrete interface. (action interface)","created_at":"2015-11-09T14:02:24Z","updated_at":"2015-11-09T14:02:24Z","html_url":"https://github.com/Sylius/Sylius-Docs/pull/335#discussion_r44276964","pull_request_url":"https://api.github.com/repos/Sylius/Sylius-Docs/pulls/335","_links":{"self":{"href":"https://api.github.com/repos/Sylius/Sylius-Docs/pulls/comments/44276964"},"html":{"href":"https://github.com/Sylius/Sylius-Docs/pull/335#discussion_r44276964"},"pull_request":{"href":"https://api.github.com/repos/Sylius/Sylius-Docs/pulls/335"}}},"pull_request":{"url":"https://api.github.com/repos/Sylius/Sylius-Docs/pulls/335","id":47669340,"html_url":"https://github.com/Sylius/Sylius-Docs/pull/335","diff_url":"https://github.com/Sylius/Sylius-Docs/pull/335.diff","patch_url":"https://github.com/Sylius/Sylius-Docs/pull/335.patch","issue_url":"https://api.github.com/repos/Sylius/Sylius-Docs/issues/335","number":335,"state":"open","locked":false,"title":"[Promotion] Component docs update","user":{"login":"TheMadeleine","id":13198869,"avatar_url":"https://avatars.githubusercontent.com/u/13198869?v=3","gravatar_id":"","url":"https://api.github.com/users/TheMadeleine","html_url":"https://github.com/TheMadeleine","followers_url":"https://api.github.com/users/TheMadeleine/followers","following_url":"https://api.github.com/users/TheMadeleine/following{/other_user}","gists_url":"https://api.github.com/users/TheMadeleine/gists{/gist_id}","starred_url":"https://api.github.com/users/TheMadeleine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheMadeleine/subscriptions","organizations_url":"https://api.github.com/users/TheMadeleine/orgs","repos_url":"https://api.github.com/users/TheMadeleine/repos","events_url":"https://api.github.com/users/TheMadeleine/events{/privacy}","received_events_url":"https://api.github.com/users/TheMadeleine/received_events","type":"User","site_admin":false},"body":"| Q             | A\r\n| ------------- | ---\r\n| Doc fix?      | yes\r\n| New docs?     | yes\r\n| Fixed tickets | ","created_at":"2015-10-14T14:50:10Z","updated_at":"2015-11-09T14:02:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"71a680e5653a1643b962e34cb21d75424ea625b2","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Sylius/Sylius-Docs/pulls/335/commits","review_comments_url":"https://api.github.com/repos/Sylius/Sylius-Docs/pulls/335/comments","review_comment_url":"https://api.github.com/repos/Sylius/Sylius-Docs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Sylius/Sylius-Docs/issues/335/comments","statuses_url":"https://api.github.com/repos/Sylius/Sylius-Docs/statuses/5aa56c87cf755e531de2aea0679c3e025c47cf6f","head":{"label":"TheMadeleine:sylius-promotion","ref":"sylius-promotion","sha":"5aa56c87cf755e531de2aea0679c3e025c47cf6f","user":{"login":"TheMadeleine","id":13198869,"avatar_url":"https://avatars.githubusercontent.com/u/13198869?v=3","gravatar_id":"","url":"https://api.github.com/users/TheMadeleine","html_url":"https://github.com/TheMadeleine","followers_url":"https://api.github.com/users/TheMadeleine/followers","following_url":"https://api.github.com/users/TheMadeleine/following{/other_user}","gists_url":"https://api.github.com/users/TheMadeleine/gists{/gist_id}","starred_url":"https://api.github.com/users/TheMadeleine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheMadeleine/subscriptions","organizations_url":"https://api.github.com/users/TheMadeleine/orgs","repos_url":"https://api.github.com/users/TheMadeleine/repos","events_url":"https://api.github.com/users/TheMadeleine/events{/privacy}","received_events_url":"https://api.github.com/users/TheMadeleine/received_events","type":"User","site_admin":false},"repo":{"id":43821427,"name":"Sylius-Docs","full_name":"TheMadeleine/Sylius-Docs","owner":{"login":"TheMadeleine","id":13198869,"avatar_url":"https://avatars.githubusercontent.com/u/13198869?v=3","gravatar_id":"","url":"https://api.github.com/users/TheMadeleine","html_url":"https://github.com/TheMadeleine","followers_url":"https://api.github.com/users/TheMadeleine/followers","following_url":"https://api.github.com/users/TheMadeleine/following{/other_user}","gists_url":"https://api.github.com/users/TheMadeleine/gists{/gist_id}","starred_url":"https://api.github.com/users/TheMadeleine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheMadeleine/subscriptions","organizations_url":"https://api.github.com/users/TheMadeleine/orgs","repos_url":"https://api.github.com/users/TheMadeleine/repos","events_url":"https://api.github.com/users/TheMadeleine/events{/privacy}","received_events_url":"https://api.github.com/users/TheMadeleine/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/TheMadeleine/Sylius-Docs","description":"Official documentation repository, hosted on readthedocs.org.","fork":true,"url":"https://api.github.com/repos/TheMadeleine/Sylius-Docs","forks_url":"https://api.github.com/repos/TheMadeleine/Sylius-Docs/forks","keys_url":"https://api.github.com/repos/TheMadeleine/Sylius-Docs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/TheMadeleine/Sylius-Docs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/TheMadeleine/Sylius-Docs/teams","hooks_url":"https://api.github.com/repos/TheMadeleine/Sylius-Docs/hooks","issue_events_url":"https://api.github.com/repos/TheMadeleine/Sylius-Docs/issues/events{/number}","events_url":"https://api.github.com/repos/TheMadeleine/Sylius-Docs/events","assignees_url":"https://api.github.com/repos/TheMadeleine/Sylius-Docs/assignees{/user}","branches_url":"https://api.github.com/repos/TheMadeleine/Sylius-Docs/branches{/branch}","tags_url":"https://api.github.com/repos/TheMadeleine/Sylius-Docs/tags","blobs_url":"https://api.github.com/repos/TheMadeleine/Sylius-Docs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/TheMadeleine/Sylius-Docs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/TheMadeleine/Sylius-Docs/git/refs{/sha}","trees_url":"https://api.github.com/repos/TheMadeleine/Sylius-Docs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/TheMadeleine/Sylius-Docs/statuses/{sha}","languages_url":"https://api.github.com/repos/TheMadeleine/Sylius-Docs/languages","stargazers_url":"https://api.github.com/repos/TheMadeleine/Sylius-Docs/stargazers","contributors_url":"https://api.github.com/repos/TheMadeleine/Sylius-Docs/contributors","subscribers_url":"https://api.github.com/repos/TheMadeleine/Sylius-Docs/subscribers","subscription_url":"https://api.github.com/repos/TheMadeleine/Sylius-Docs/subscription","commits_url":"https://api.github.com/repos/TheMadeleine/Sylius-Docs/commits{/sha}","git_commits_url":"https://api.github.com/repos/TheMadeleine/Sylius-Docs/git/commits{/sha}","comments_url":"https://api.github.com/repos/TheMadeleine/Sylius-Docs/comments{/number}","issue_comment_url":"https://api.github.com/repos/TheMadeleine/Sylius-Docs/issues/comments{/number}","contents_url":"https://api.github.com/repos/TheMadeleine/Sylius-Docs/contents/{+path}","compare_url":"https://api.github.com/repos/TheMadeleine/Sylius-Docs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/TheMadeleine/Sylius-Docs/merges","archive_url":"https://api.github.com/repos/TheMadeleine/Sylius-Docs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/TheMadeleine/Sylius-Docs/downloads","issues_url":"https://api.github.com/repos/TheMadeleine/Sylius-Docs/issues{/number}","pulls_url":"https://api.github.com/repos/TheMadeleine/Sylius-Docs/pulls{/number}","milestones_url":"https://api.github.com/repos/TheMadeleine/Sylius-Docs/milestones{/number}","notifications_url":"https://api.github.com/repos/TheMadeleine/Sylius-Docs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/TheMadeleine/Sylius-Docs/labels{/name}","releases_url":"https://api.github.com/repos/TheMadeleine/Sylius-Docs/releases{/id}","created_at":"2015-10-07T14:28:53Z","updated_at":"2015-10-07T14:28:55Z","pushed_at":"2015-11-09T10:45:35Z","git_url":"git://github.com/TheMadeleine/Sylius-Docs.git","ssh_url":"git@github.com:TheMadeleine/Sylius-Docs.git","clone_url":"https://github.com/TheMadeleine/Sylius-Docs.git","svn_url":"https://github.com/TheMadeleine/Sylius-Docs","homepage":"Sylius.org","size":1152,"stargazers_count":0,"watchers_count":0,"language":"HTML","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":"Sylius:master","ref":"master","sha":"19320bbba9fa484c74008eedfe0518deffb6ce99","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":2892960,"name":"Sylius-Docs","full_name":"Sylius/Sylius-Docs","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-Docs","description":"Official documentation repository, hosted on readthedocs.org.","fork":false,"url":"https://api.github.com/repos/Sylius/Sylius-Docs","forks_url":"https://api.github.com/repos/Sylius/Sylius-Docs/forks","keys_url":"https://api.github.com/repos/Sylius/Sylius-Docs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Sylius/Sylius-Docs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Sylius/Sylius-Docs/teams","hooks_url":"https://api.github.com/repos/Sylius/Sylius-Docs/hooks","issue_events_url":"https://api.github.com/repos/Sylius/Sylius-Docs/issues/events{/number}","events_url":"https://api.github.com/repos/Sylius/Sylius-Docs/events","assignees_url":"https://api.github.com/repos/Sylius/Sylius-Docs/assignees{/user}","branches_url":"https://api.github.com/repos/Sylius/Sylius-Docs/branches{/branch}","tags_url":"https://api.github.com/repos/Sylius/Sylius-Docs/tags","blobs_url":"https://api.github.com/repos/Sylius/Sylius-Docs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Sylius/Sylius-Docs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Sylius/Sylius-Docs/git/refs{/sha}","trees_url":"https://api.github.com/repos/Sylius/Sylius-Docs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Sylius/Sylius-Docs/statuses/{sha}","languages_url":"https://api.github.com/repos/Sylius/Sylius-Docs/languages","stargazers_url":"https://api.github.com/repos/Sylius/Sylius-Docs/stargazers","contributors_url":"https://api.github.com/repos/Sylius/Sylius-Docs/contributors","subscribers_url":"https://api.github.com/repos/Sylius/Sylius-Docs/subscribers","subscription_url":"https://api.github.com/repos/Sylius/Sylius-Docs/subscription","commits_url":"https://api.github.com/repos/Sylius/Sylius-Docs/commits{/sha}","git_commits_url":"https://api.github.com/repos/Sylius/Sylius-Docs/git/commits{/sha}","comments_url":"https://api.github.com/repos/Sylius/Sylius-Docs/comments{/number}","issue_comment_url":"https://api.github.com/repos/Sylius/Sylius-Docs/issues/comments{/number}","contents_url":"https://api.github.com/repos/Sylius/Sylius-Docs/contents/{+path}","compare_url":"https://api.github.com/repos/Sylius/Sylius-Docs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Sylius/Sylius-Docs/merges","archive_url":"https://api.github.com/repos/Sylius/Sylius-Docs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Sylius/Sylius-Docs/downloads","issues_url":"https://api.github.com/repos/Sylius/Sylius-Docs/issues{/number}","pulls_url":"https://api.github.com/repos/Sylius/Sylius-Docs/pulls{/number}","milestones_url":"https://api.github.com/repos/Sylius/Sylius-Docs/milestones{/number}","notifications_url":"https://api.github.com/repos/Sylius/Sylius-Docs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Sylius/Sylius-Docs/labels{/name}","releases_url":"https://api.github.com/repos/Sylius/Sylius-Docs/releases{/id}","created_at":"2011-12-01T17:58:56Z","updated_at":"2015-11-06T09:15:36Z","pushed_at":"2015-11-09T13:47:31Z","git_url":"git://github.com/Sylius/Sylius-Docs.git","ssh_url":"git@github.com:Sylius/Sylius-Docs.git","clone_url":"https://github.com/Sylius/Sylius-Docs.git","svn_url":"https://github.com/Sylius/Sylius-Docs","homepage":"Sylius.org","size":3607,"stargazers_count":54,"watchers_count":54,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":127,"mirror_url":null,"open_issues_count":48,"forks":127,"open_issues":48,"watchers":54,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Sylius/Sylius-Docs/pulls/335"},"html":{"href":"https://github.com/Sylius/Sylius-Docs/pull/335"},"issue":{"href":"https://api.github.com/repos/Sylius/Sylius-Docs/issues/335"},"comments":{"href":"https://api.github.com/repos/Sylius/Sylius-Docs/issues/335/comments"},"review_comments":{"href":"https://api.github.com/repos/Sylius/Sylius-Docs/pulls/335/comments"},"review_comment":{"href":"https://api.github.com/repos/Sylius/Sylius-Docs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Sylius/Sylius-Docs/pulls/335/commits"},"statuses":{"href":"https://api.github.com/repos/Sylius/Sylius-Docs/statuses/5aa56c87cf755e531de2aea0679c3e025c47cf6f"}}}}