{"action":"created","comment":{"url":"https://api.github.com/repos/sulu/SuluRouteBundle/pulls/comments/59384032","id":59384032,"diff_hunk":"@@ -0,0 +1,87 @@\n+<?php\n+\n+/*\n+ * This file is part of Sulu.\n+ *\n+ * (c) MASSIVE ART WebServices GmbH\n+ *\n+ * This source file is subject to the MIT license that is bundled\n+ * with this source code in the file LICENSE.\n+ */\n+\n+namespace Sulu\\Bundle\\RouteBundle\\Command;\n+\n+use Doctrine\\ORM\\EntityManagerInterface;\n+use Doctrine\\ORM\\EntityRepository;\n+use Symfony\\Bundle\\FrameworkBundle\\Command\\ContainerAwareCommand;\n+use Symfony\\Component\\Console\\Helper\\ProgressBar;\n+use Symfony\\Component\\Console\\Input\\InputArgument;\n+use Symfony\\Component\\Console\\Input\\InputInterface;\n+use Symfony\\Component\\Console\\Output\\OutputInterface;\n+\n+/**\n+ * Update the routes for all entities which will be returned by the repository of given entity service.\n+ */\n+class UpdateRouteCommand extends ContainerAwareCommand\n+{\n+    /**\n+     * {@inheritdoc}\n+     */\n+    protected function configure()\n+    {\n+        $this->setName('sulu:route:update')\n+            ->addArgument('entity', InputArgument::REQUIRED)\n+            ->setDescription('Update the routes for all entities.')\n+            ->setHelp(\n+                <<<'EOT'\n+Update the routes for all entities which will be returned by the repository of given entity service:\n+\n+    $ %command.full_name% sulu.repository.example\n+EOT\n+            );\n+    }\n+\n+    /**\n+     * {@inheritdoc}\n+     */\n+    protected function execute(InputInterface $input, OutputInterface $output)\n+    {\n+        /** @var EntityManagerInterface $entityManager */\n+        $entityManager = $this->getContainer()->get('doctrine.orm.entity_manager');\n+        $routeManager = $this->getContainer()->get('sulu_route.manager.route_manager');\n+        /** @var EntityRepository $repository */\n+        $repository = $entityManager->getRepository($input->getArgument('entity'));\n+\n+        $query = $repository->createQueryBuilder('entity')->select('count(entity.id)')->getQuery();\n+        $result = $query->getResult();\n+        $count = (int) $result[0][1];\n+\n+        $query = $repository->createQueryBuilder('entity')->getQuery();\n+        $output->writeln(\n+            sprintf(\n+                '<comment>updating route for \"%s\" instances of \"%s\"</comment>',\n+                $count,\n+                $input->getArgument('entity')\n+            )\n+        );\n+        $progressBar = new ProgressBar($output, $count);\n+        $progressBar->display();\n+\n+        foreach ($query->iterate() as $entity) {\n+            if (null !== $entity[0]->getRoute()) {","path":"Command/UpdateRouteCommand.php","position":71,"original_position":71,"commit_id":"e6df651a1a27fe44214276f658355e5a38e6907f","original_commit_id":"e6df651a1a27fe44214276f658355e5a38e6907f","user":{"login":"chirimoya","id":627313,"avatar_url":"https://avatars.githubusercontent.com/u/627313?v=3","gravatar_id":"","url":"https://api.github.com/users/chirimoya","html_url":"https://github.com/chirimoya","followers_url":"https://api.github.com/users/chirimoya/followers","following_url":"https://api.github.com/users/chirimoya/following{/other_user}","gists_url":"https://api.github.com/users/chirimoya/gists{/gist_id}","starred_url":"https://api.github.com/users/chirimoya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chirimoya/subscriptions","organizations_url":"https://api.github.com/users/chirimoya/orgs","repos_url":"https://api.github.com/users/chirimoya/repos","events_url":"https://api.github.com/users/chirimoya/events{/privacy}","received_events_url":"https://api.github.com/users/chirimoya/received_events","type":"User","site_admin":false},"body":"`$item = $entity[0];`","created_at":"2016-04-12T14:20:47Z","updated_at":"2016-04-12T14:20:47Z","html_url":"https://github.com/sulu/SuluRouteBundle/pull/4#discussion_r59384032","pull_request_url":"https://api.github.com/repos/sulu/SuluRouteBundle/pulls/4","_links":{"self":{"href":"https://api.github.com/repos/sulu/SuluRouteBundle/pulls/comments/59384032"},"html":{"href":"https://github.com/sulu/SuluRouteBundle/pull/4#discussion_r59384032"},"pull_request":{"href":"https://api.github.com/repos/sulu/SuluRouteBundle/pulls/4"}}},"pull_request":{"url":"https://api.github.com/repos/sulu/SuluRouteBundle/pulls/4","id":66131691,"html_url":"https://github.com/sulu/SuluRouteBundle/pull/4","diff_url":"https://github.com/sulu/SuluRouteBundle/pull/4.diff","patch_url":"https://github.com/sulu/SuluRouteBundle/pull/4.patch","issue_url":"https://api.github.com/repos/sulu/SuluRouteBundle/issues/4","number":4,"state":"open","locked":false,"title":"Added route-manager update method and history handling","user":{"login":"wachterjohannes","id":1464615,"avatar_url":"https://avatars.githubusercontent.com/u/1464615?v=3","gravatar_id":"","url":"https://api.github.com/users/wachterjohannes","html_url":"https://github.com/wachterjohannes","followers_url":"https://api.github.com/users/wachterjohannes/followers","following_url":"https://api.github.com/users/wachterjohannes/following{/other_user}","gists_url":"https://api.github.com/users/wachterjohannes/gists{/gist_id}","starred_url":"https://api.github.com/users/wachterjohannes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wachterjohannes/subscriptions","organizations_url":"https://api.github.com/users/wachterjohannes/orgs","repos_url":"https://api.github.com/users/wachterjohannes/repos","events_url":"https://api.github.com/users/wachterjohannes/events{/privacy}","received_events_url":"https://api.github.com/users/wachterjohannes/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 | none\r\n| Related issues/PRs | none\r\n| License | MIT\r\n| Documentation PR | none\r\n\r\n#### What's in this PR?\r\n\r\nThis PR add the route-manager create and automatic route creation.\r\n\r\n#### Todo\r\n\r\n- [x] tests","created_at":"2016-04-12T10:09:33Z","updated_at":"2016-04-12T14:20:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2ad3d17b84c6ea1ed2403bd5670ee51cc6fb2458","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/sulu/SuluRouteBundle/pulls/4/commits","review_comments_url":"https://api.github.com/repos/sulu/SuluRouteBundle/pulls/4/comments","review_comment_url":"https://api.github.com/repos/sulu/SuluRouteBundle/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sulu/SuluRouteBundle/issues/4/comments","statuses_url":"https://api.github.com/repos/sulu/SuluRouteBundle/statuses/e6df651a1a27fe44214276f658355e5a38e6907f","head":{"label":"wachterjohannes:feature/update-route","ref":"feature/update-route","sha":"e6df651a1a27fe44214276f658355e5a38e6907f","user":{"login":"wachterjohannes","id":1464615,"avatar_url":"https://avatars.githubusercontent.com/u/1464615?v=3","gravatar_id":"","url":"https://api.github.com/users/wachterjohannes","html_url":"https://github.com/wachterjohannes","followers_url":"https://api.github.com/users/wachterjohannes/followers","following_url":"https://api.github.com/users/wachterjohannes/following{/other_user}","gists_url":"https://api.github.com/users/wachterjohannes/gists{/gist_id}","starred_url":"https://api.github.com/users/wachterjohannes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wachterjohannes/subscriptions","organizations_url":"https://api.github.com/users/wachterjohannes/orgs","repos_url":"https://api.github.com/users/wachterjohannes/repos","events_url":"https://api.github.com/users/wachterjohannes/events{/privacy}","received_events_url":"https://api.github.com/users/wachterjohannes/received_events","type":"User","site_admin":false},"repo":{"id":55595681,"name":"SuluRouteBundle","full_name":"wachterjohannes/SuluRouteBundle","owner":{"login":"wachterjohannes","id":1464615,"avatar_url":"https://avatars.githubusercontent.com/u/1464615?v=3","gravatar_id":"","url":"https://api.github.com/users/wachterjohannes","html_url":"https://github.com/wachterjohannes","followers_url":"https://api.github.com/users/wachterjohannes/followers","following_url":"https://api.github.com/users/wachterjohannes/following{/other_user}","gists_url":"https://api.github.com/users/wachterjohannes/gists{/gist_id}","starred_url":"https://api.github.com/users/wachterjohannes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wachterjohannes/subscriptions","organizations_url":"https://api.github.com/users/wachterjohannes/orgs","repos_url":"https://api.github.com/users/wachterjohannes/repos","events_url":"https://api.github.com/users/wachterjohannes/events{/privacy}","received_events_url":"https://api.github.com/users/wachterjohannes/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/wachterjohannes/SuluRouteBundle","description":"Sulu URL bundle","fork":true,"url":"https://api.github.com/repos/wachterjohannes/SuluRouteBundle","forks_url":"https://api.github.com/repos/wachterjohannes/SuluRouteBundle/forks","keys_url":"https://api.github.com/repos/wachterjohannes/SuluRouteBundle/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wachterjohannes/SuluRouteBundle/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wachterjohannes/SuluRouteBundle/teams","hooks_url":"https://api.github.com/repos/wachterjohannes/SuluRouteBundle/hooks","issue_events_url":"https://api.github.com/repos/wachterjohannes/SuluRouteBundle/issues/events{/number}","events_url":"https://api.github.com/repos/wachterjohannes/SuluRouteBundle/events","assignees_url":"https://api.github.com/repos/wachterjohannes/SuluRouteBundle/assignees{/user}","branches_url":"https://api.github.com/repos/wachterjohannes/SuluRouteBundle/branches{/branch}","tags_url":"https://api.github.com/repos/wachterjohannes/SuluRouteBundle/tags","blobs_url":"https://api.github.com/repos/wachterjohannes/SuluRouteBundle/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wachterjohannes/SuluRouteBundle/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wachterjohannes/SuluRouteBundle/git/refs{/sha}","trees_url":"https://api.github.com/repos/wachterjohannes/SuluRouteBundle/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wachterjohannes/SuluRouteBundle/statuses/{sha}","languages_url":"https://api.github.com/repos/wachterjohannes/SuluRouteBundle/languages","stargazers_url":"https://api.github.com/repos/wachterjohannes/SuluRouteBundle/stargazers","contributors_url":"https://api.github.com/repos/wachterjohannes/SuluRouteBundle/contributors","subscribers_url":"https://api.github.com/repos/wachterjohannes/SuluRouteBundle/subscribers","subscription_url":"https://api.github.com/repos/wachterjohannes/SuluRouteBundle/subscription","commits_url":"https://api.github.com/repos/wachterjohannes/SuluRouteBundle/commits{/sha}","git_commits_url":"https://api.github.com/repos/wachterjohannes/SuluRouteBundle/git/commits{/sha}","comments_url":"https://api.github.com/repos/wachterjohannes/SuluRouteBundle/comments{/number}","issue_comment_url":"https://api.github.com/repos/wachterjohannes/SuluRouteBundle/issues/comments{/number}","contents_url":"https://api.github.com/repos/wachterjohannes/SuluRouteBundle/contents/{+path}","compare_url":"https://api.github.com/repos/wachterjohannes/SuluRouteBundle/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wachterjohannes/SuluRouteBundle/merges","archive_url":"https://api.github.com/repos/wachterjohannes/SuluRouteBundle/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wachterjohannes/SuluRouteBundle/downloads","issues_url":"https://api.github.com/repos/wachterjohannes/SuluRouteBundle/issues{/number}","pulls_url":"https://api.github.com/repos/wachterjohannes/SuluRouteBundle/pulls{/number}","milestones_url":"https://api.github.com/repos/wachterjohannes/SuluRouteBundle/milestones{/number}","notifications_url":"https://api.github.com/repos/wachterjohannes/SuluRouteBundle/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wachterjohannes/SuluRouteBundle/labels{/name}","releases_url":"https://api.github.com/repos/wachterjohannes/SuluRouteBundle/releases{/id}","deployments_url":"https://api.github.com/repos/wachterjohannes/SuluRouteBundle/deployments","created_at":"2016-04-06T10:07:02Z","updated_at":"2016-04-06T10:07:03Z","pushed_at":"2016-04-12T14:17:44Z","git_url":"git://github.com/wachterjohannes/SuluRouteBundle.git","ssh_url":"git@github.com:wachterjohannes/SuluRouteBundle.git","clone_url":"https://github.com/wachterjohannes/SuluRouteBundle.git","svn_url":"https://github.com/wachterjohannes/SuluRouteBundle","homepage":"","size":45,"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":"sulu:master","ref":"master","sha":"45e9cb35d382e7c73d8e038984cb8ffefcf31a7a","user":{"login":"sulu","id":5717006,"avatar_url":"https://avatars.githubusercontent.com/u/5717006?v=3","gravatar_id":"","url":"https://api.github.com/users/sulu","html_url":"https://github.com/sulu","followers_url":"https://api.github.com/users/sulu/followers","following_url":"https://api.github.com/users/sulu/following{/other_user}","gists_url":"https://api.github.com/users/sulu/gists{/gist_id}","starred_url":"https://api.github.com/users/sulu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sulu/subscriptions","organizations_url":"https://api.github.com/users/sulu/orgs","repos_url":"https://api.github.com/users/sulu/repos","events_url":"https://api.github.com/users/sulu/events{/privacy}","received_events_url":"https://api.github.com/users/sulu/received_events","type":"Organization","site_admin":false},"repo":{"id":55480370,"name":"SuluRouteBundle","full_name":"sulu/SuluRouteBundle","owner":{"login":"sulu","id":5717006,"avatar_url":"https://avatars.githubusercontent.com/u/5717006?v=3","gravatar_id":"","url":"https://api.github.com/users/sulu","html_url":"https://github.com/sulu","followers_url":"https://api.github.com/users/sulu/followers","following_url":"https://api.github.com/users/sulu/following{/other_user}","gists_url":"https://api.github.com/users/sulu/gists{/gist_id}","starred_url":"https://api.github.com/users/sulu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sulu/subscriptions","organizations_url":"https://api.github.com/users/sulu/orgs","repos_url":"https://api.github.com/users/sulu/repos","events_url":"https://api.github.com/users/sulu/events{/privacy}","received_events_url":"https://api.github.com/users/sulu/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sulu/SuluRouteBundle","description":"Sulu Route bundle","fork":false,"url":"https://api.github.com/repos/sulu/SuluRouteBundle","forks_url":"https://api.github.com/repos/sulu/SuluRouteBundle/forks","keys_url":"https://api.github.com/repos/sulu/SuluRouteBundle/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sulu/SuluRouteBundle/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sulu/SuluRouteBundle/teams","hooks_url":"https://api.github.com/repos/sulu/SuluRouteBundle/hooks","issue_events_url":"https://api.github.com/repos/sulu/SuluRouteBundle/issues/events{/number}","events_url":"https://api.github.com/repos/sulu/SuluRouteBundle/events","assignees_url":"https://api.github.com/repos/sulu/SuluRouteBundle/assignees{/user}","branches_url":"https://api.github.com/repos/sulu/SuluRouteBundle/branches{/branch}","tags_url":"https://api.github.com/repos/sulu/SuluRouteBundle/tags","blobs_url":"https://api.github.com/repos/sulu/SuluRouteBundle/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sulu/SuluRouteBundle/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sulu/SuluRouteBundle/git/refs{/sha}","trees_url":"https://api.github.com/repos/sulu/SuluRouteBundle/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sulu/SuluRouteBundle/statuses/{sha}","languages_url":"https://api.github.com/repos/sulu/SuluRouteBundle/languages","stargazers_url":"https://api.github.com/repos/sulu/SuluRouteBundle/stargazers","contributors_url":"https://api.github.com/repos/sulu/SuluRouteBundle/contributors","subscribers_url":"https://api.github.com/repos/sulu/SuluRouteBundle/subscribers","subscription_url":"https://api.github.com/repos/sulu/SuluRouteBundle/subscription","commits_url":"https://api.github.com/repos/sulu/SuluRouteBundle/commits{/sha}","git_commits_url":"https://api.github.com/repos/sulu/SuluRouteBundle/git/commits{/sha}","comments_url":"https://api.github.com/repos/sulu/SuluRouteBundle/comments{/number}","issue_comment_url":"https://api.github.com/repos/sulu/SuluRouteBundle/issues/comments{/number}","contents_url":"https://api.github.com/repos/sulu/SuluRouteBundle/contents/{+path}","compare_url":"https://api.github.com/repos/sulu/SuluRouteBundle/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sulu/SuluRouteBundle/merges","archive_url":"https://api.github.com/repos/sulu/SuluRouteBundle/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sulu/SuluRouteBundle/downloads","issues_url":"https://api.github.com/repos/sulu/SuluRouteBundle/issues{/number}","pulls_url":"https://api.github.com/repos/sulu/SuluRouteBundle/pulls{/number}","milestones_url":"https://api.github.com/repos/sulu/SuluRouteBundle/milestones{/number}","notifications_url":"https://api.github.com/repos/sulu/SuluRouteBundle/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sulu/SuluRouteBundle/labels{/name}","releases_url":"https://api.github.com/repos/sulu/SuluRouteBundle/releases{/id}","deployments_url":"https://api.github.com/repos/sulu/SuluRouteBundle/deployments","created_at":"2016-04-05T08:15:14Z","updated_at":"2016-04-11T11:45:11Z","pushed_at":"2016-04-12T14:17:45Z","git_url":"git://github.com/sulu/SuluRouteBundle.git","ssh_url":"git@github.com:sulu/SuluRouteBundle.git","clone_url":"https://github.com/sulu/SuluRouteBundle.git","svn_url":"https://github.com/sulu/SuluRouteBundle","homepage":"","size":36,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":1,"forks":2,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sulu/SuluRouteBundle/pulls/4"},"html":{"href":"https://github.com/sulu/SuluRouteBundle/pull/4"},"issue":{"href":"https://api.github.com/repos/sulu/SuluRouteBundle/issues/4"},"comments":{"href":"https://api.github.com/repos/sulu/SuluRouteBundle/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/sulu/SuluRouteBundle/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/sulu/SuluRouteBundle/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sulu/SuluRouteBundle/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/sulu/SuluRouteBundle/statuses/e6df651a1a27fe44214276f658355e5a38e6907f"}}}}