{"action":"created","comment":{"url":"https://api.github.com/repos/Sylius/Sylius/pulls/comments/24166222","id":24166222,"diff_hunk":"@@ -0,0 +1,83 @@\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\\Bundle\\CoreBundle\\EventListener;\n+\n+use Symfony\\Component\\Routing\\RouterInterface;\n+use Presta\\SitemapBundle\\Service\\SitemapListenerInterface;\n+use Presta\\SitemapBundle\\Event\\SitemapPopulateEvent;\n+use Presta\\SitemapBundle\\Sitemap\\Url\\UrlConcrete;\n+use \\Sylius\\Component\\Resource\\Repository\\RepositoryInterface;\n+\n+/**\n+ * Sitemap listener.\n+ *\n+ * @author Bartosz Siejka <bartosz.siejka@lakion.com>\n+ */\n+class SitemapListener implements SitemapListenerInterface\n+{\n+    private $event;\n+    private $router;\n+    private $dynamicRouter;\n+    private $productRepository;\n+    private $taxonRepository;\n+\n+    public function __construct(RouterInterface $router, RouterInterface $dynamicRouter, RepositoryInterface $productRepository, RepositoryInterface $taxonRepository)\n+    {\n+        $this->router = $router;\n+        $this->dynamicRouter = $dynamicRouter;\n+        $this->productRepository = $productRepository;\n+        $this->taxonRepository = $taxonRepository;\n+    }\n+\n+    public function populateSitemap(SitemapPopulateEvent $event)\n+    {\n+        $this->event = $event;\n+        $section = $event->getSection();\n+\n+        if (is_null($section) || $section == 'default') {\n+            $homepage = $this->router->generate('sylius_homepage', array(), true);\n+            $products = $this->productRepository->findAll();\n+            $taxons = $this->taxonRepository->findAll();\n+            $statics = $this->dynamicRouter->getRouteCollection()->all();\n+\n+            $this->createSiteMapEntry($homepage, null, UrlConcrete::CHANGEFREQ_YEARLY, 1);\n+\n+            foreach ($products as $product) {\n+                $url = $this->router->generate($product, array(), true);\n+                $this->createSiteMapEntry($url, $product->getUpdatedAt(), UrlConcrete::CHANGEFREQ_MONTHLY, 0.7);\n+            }\n+\n+            foreach ($taxons as $taxon) {\n+                $url = $this->router->generate($taxon, array(), true);\n+                $this->createSiteMapEntry($url, $taxon->getUpdatedAt(), UrlConcrete::CHANGEFREQ_MONTHLY, 0.5);\n+            }\n+\n+            foreach ($statics as $static) {\n+                $url = $this->router->generate($static, array(), true);\n+                $this->createSiteMapEntry($url, null, UrlConcrete::CHANGEFREQ_MONTHLY, 0.3);\n+            }\n+        }\n+    }\n+\n+    private function createSiteMapEntry($url, $modifiedDate, $changeFrequency, $priority)","path":"src/Sylius/Bundle/CoreBundle/EventListener/SitemapListener.php","position":71,"original_position":71,"commit_id":"6d6d32373d9f8898e34cdeee3876266105db1158","original_commit_id":"6d6d32373d9f8898e34cdeee3876266105db1158","user":{"login":"aRn0D","id":3585922,"avatar_url":"https://avatars.githubusercontent.com/u/3585922?v=3","gravatar_id":"","url":"https://api.github.com/users/aRn0D","html_url":"https://github.com/aRn0D","followers_url":"https://api.github.com/users/aRn0D/followers","following_url":"https://api.github.com/users/aRn0D/following{/other_user}","gists_url":"https://api.github.com/users/aRn0D/gists{/gist_id}","starred_url":"https://api.github.com/users/aRn0D/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aRn0D/subscriptions","organizations_url":"https://api.github.com/users/aRn0D/orgs","repos_url":"https://api.github.com/users/aRn0D/repos","events_url":"https://api.github.com/users/aRn0D/events{/privacy}","received_events_url":"https://api.github.com/users/aRn0D/received_events","type":"User","site_admin":false},"body":"protected, no ?","created_at":"2015-02-05T14:32:34Z","updated_at":"2015-02-05T14:32:34Z","html_url":"https://github.com/Sylius/Sylius/pull/2435#discussion_r24166222","pull_request_url":"https://api.github.com/repos/Sylius/Sylius/pulls/2435","_links":{"self":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/comments/24166222"},"html":{"href":"https://github.com/Sylius/Sylius/pull/2435#discussion_r24166222"},"pull_request":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/2435"}}},"pull_request":{"url":"https://api.github.com/repos/Sylius/Sylius/pulls/2435","id":28726654,"html_url":"https://github.com/Sylius/Sylius/pull/2435","diff_url":"https://github.com/Sylius/Sylius/pull/2435.diff","patch_url":"https://github.com/Sylius/Sylius/pull/2435.patch","issue_url":"https://api.github.com/repos/Sylius/Sylius/issues/2435","number":2435,"state":"open","locked":false,"title":"[WIP] Sylius-10 Add sitemap bundle #494","user":{"login":"BartoszSiejka","id":9444949,"avatar_url":"https://avatars.githubusercontent.com/u/9444949?v=3","gravatar_id":"","url":"https://api.github.com/users/BartoszSiejka","html_url":"https://github.com/BartoszSiejka","followers_url":"https://api.github.com/users/BartoszSiejka/followers","following_url":"https://api.github.com/users/BartoszSiejka/following{/other_user}","gists_url":"https://api.github.com/users/BartoszSiejka/gists{/gist_id}","starred_url":"https://api.github.com/users/BartoszSiejka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BartoszSiejka/subscriptions","organizations_url":"https://api.github.com/users/BartoszSiejka/orgs","repos_url":"https://api.github.com/users/BartoszSiejka/repos","events_url":"https://api.github.com/users/BartoszSiejka/events{/privacy}","received_events_url":"https://api.github.com/users/BartoszSiejka/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?    | no\r\n| Deprecations? | no\r\n| Fixed tickets | \r\n| License       | MIT\r\n| Doc PR        | ","created_at":"2015-02-05T14:06:11Z","updated_at":"2015-02-05T14:32:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cb7a5d4d392ddebb63771e1cc9f26e0f06c0d360","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Sylius/Sylius/pulls/2435/commits","review_comments_url":"https://api.github.com/repos/Sylius/Sylius/pulls/2435/comments","review_comment_url":"https://api.github.com/repos/Sylius/Sylius/pulls/comments/{number}","comments_url":"https://api.github.com/repos/Sylius/Sylius/issues/2435/comments","statuses_url":"https://api.github.com/repos/Sylius/Sylius/statuses/6d6d32373d9f8898e34cdeee3876266105db1158","head":{"label":"BartoszSiejka:sitemap-bundle","ref":"sitemap-bundle","sha":"6d6d32373d9f8898e34cdeee3876266105db1158","user":{"login":"BartoszSiejka","id":9444949,"avatar_url":"https://avatars.githubusercontent.com/u/9444949?v=3","gravatar_id":"","url":"https://api.github.com/users/BartoszSiejka","html_url":"https://github.com/BartoszSiejka","followers_url":"https://api.github.com/users/BartoszSiejka/followers","following_url":"https://api.github.com/users/BartoszSiejka/following{/other_user}","gists_url":"https://api.github.com/users/BartoszSiejka/gists{/gist_id}","starred_url":"https://api.github.com/users/BartoszSiejka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BartoszSiejka/subscriptions","organizations_url":"https://api.github.com/users/BartoszSiejka/orgs","repos_url":"https://api.github.com/users/BartoszSiejka/repos","events_url":"https://api.github.com/users/BartoszSiejka/events{/privacy}","received_events_url":"https://api.github.com/users/BartoszSiejka/received_events","type":"User","site_admin":false},"repo":{"id":26264334,"name":"Sylius","full_name":"BartoszSiejka/Sylius","owner":{"login":"BartoszSiejka","id":9444949,"avatar_url":"https://avatars.githubusercontent.com/u/9444949?v=3","gravatar_id":"","url":"https://api.github.com/users/BartoszSiejka","html_url":"https://github.com/BartoszSiejka","followers_url":"https://api.github.com/users/BartoszSiejka/followers","following_url":"https://api.github.com/users/BartoszSiejka/following{/other_user}","gists_url":"https://api.github.com/users/BartoszSiejka/gists{/gist_id}","starred_url":"https://api.github.com/users/BartoszSiejka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BartoszSiejka/subscriptions","organizations_url":"https://api.github.com/users/BartoszSiejka/orgs","repos_url":"https://api.github.com/users/BartoszSiejka/repos","events_url":"https://api.github.com/users/BartoszSiejka/events{/privacy}","received_events_url":"https://api.github.com/users/BartoszSiejka/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/BartoszSiejka/Sylius","description":"Modern e-commerce for PHP, based on the Symfony2 framework.","fork":true,"url":"https://api.github.com/repos/BartoszSiejka/Sylius","forks_url":"https://api.github.com/repos/BartoszSiejka/Sylius/forks","keys_url":"https://api.github.com/repos/BartoszSiejka/Sylius/keys{/key_id}","collaborators_url":"https://api.github.com/repos/BartoszSiejka/Sylius/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/BartoszSiejka/Sylius/teams","hooks_url":"https://api.github.com/repos/BartoszSiejka/Sylius/hooks","issue_events_url":"https://api.github.com/repos/BartoszSiejka/Sylius/issues/events{/number}","events_url":"https://api.github.com/repos/BartoszSiejka/Sylius/events","assignees_url":"https://api.github.com/repos/BartoszSiejka/Sylius/assignees{/user}","branches_url":"https://api.github.com/repos/BartoszSiejka/Sylius/branches{/branch}","tags_url":"https://api.github.com/repos/BartoszSiejka/Sylius/tags","blobs_url":"https://api.github.com/repos/BartoszSiejka/Sylius/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/BartoszSiejka/Sylius/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/BartoszSiejka/Sylius/git/refs{/sha}","trees_url":"https://api.github.com/repos/BartoszSiejka/Sylius/git/trees{/sha}","statuses_url":"https://api.github.com/repos/BartoszSiejka/Sylius/statuses/{sha}","languages_url":"https://api.github.com/repos/BartoszSiejka/Sylius/languages","stargazers_url":"https://api.github.com/repos/BartoszSiejka/Sylius/stargazers","contributors_url":"https://api.github.com/repos/BartoszSiejka/Sylius/contributors","subscribers_url":"https://api.github.com/repos/BartoszSiejka/Sylius/subscribers","subscription_url":"https://api.github.com/repos/BartoszSiejka/Sylius/subscription","commits_url":"https://api.github.com/repos/BartoszSiejka/Sylius/commits{/sha}","git_commits_url":"https://api.github.com/repos/BartoszSiejka/Sylius/git/commits{/sha}","comments_url":"https://api.github.com/repos/BartoszSiejka/Sylius/comments{/number}","issue_comment_url":"https://api.github.com/repos/BartoszSiejka/Sylius/issues/comments/{number}","contents_url":"https://api.github.com/repos/BartoszSiejka/Sylius/contents/{+path}","compare_url":"https://api.github.com/repos/BartoszSiejka/Sylius/compare/{base}...{head}","merges_url":"https://api.github.com/repos/BartoszSiejka/Sylius/merges","archive_url":"https://api.github.com/repos/BartoszSiejka/Sylius/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/BartoszSiejka/Sylius/downloads","issues_url":"https://api.github.com/repos/BartoszSiejka/Sylius/issues{/number}","pulls_url":"https://api.github.com/repos/BartoszSiejka/Sylius/pulls{/number}","milestones_url":"https://api.github.com/repos/BartoszSiejka/Sylius/milestones{/number}","notifications_url":"https://api.github.com/repos/BartoszSiejka/Sylius/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/BartoszSiejka/Sylius/labels{/name}","releases_url":"https://api.github.com/repos/BartoszSiejka/Sylius/releases{/id}","created_at":"2014-11-06T10:07:02Z","updated_at":"2014-11-05T21:59:51Z","pushed_at":"2015-02-05T14:26:57Z","git_url":"git://github.com/BartoszSiejka/Sylius.git","ssh_url":"git@github.com:BartoszSiejka/Sylius.git","clone_url":"https://github.com/BartoszSiejka/Sylius.git","svn_url":"https://github.com/BartoszSiejka/Sylius","homepage":"Sylius.org","size":15853,"stargazers_count":0,"watchers_count":0,"language":null,"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":"90f7c45eb0de6ff5cdc92d872cbeccca7801d43e","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-02-05T09:43:18Z","pushed_at":"2015-02-05T12:01:47Z","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":41408,"stargazers_count":1580,"watchers_count":1580,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":533,"mirror_url":null,"open_issues_count":381,"forks":533,"open_issues":381,"watchers":1580,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/2435"},"html":{"href":"https://github.com/Sylius/Sylius/pull/2435"},"issue":{"href":"https://api.github.com/repos/Sylius/Sylius/issues/2435"},"comments":{"href":"https://api.github.com/repos/Sylius/Sylius/issues/2435/comments"},"review_comments":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/2435/comments"},"review_comment":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/2435/commits"},"statuses":{"href":"https://api.github.com/repos/Sylius/Sylius/statuses/6d6d32373d9f8898e34cdeee3876266105db1158"}}}}