{"action":"created","comment":{"url":"https://api.github.com/repos/seventag/seventag/pulls/comments/44050408","id":44050408,"diff_hunk":"@@ -0,0 +1,143 @@\n+<?php\n+/**\n+ * Copyright (C) 2015 Digimedia Sp. z o.o. d/b/a Clearcode\n+ *\n+ * This program is free software: you can redistribute it and/or modify it under\n+ * the terms of the GNU Affero General Public License as published by the Free\n+ * Software Foundation, either version 3 of the License, or (at your option) any\n+ * later version.\n+ *\n+ * This program is distributed in the hope that it will be useful,\n+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\n+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n+ * GNU Affero General Public License for more details.\n+ *\n+ * You should have received a copy of the GNU Affero General Public License\n+ * along with this program. If not, see <http://www.gnu.org/licenses/>.\n+ */\n+\n+namespace SevenTag\\Api\\AppBundle\\Command;\n+\n+use Doctrine\\Common\\Collections\\ArrayCollection;\n+use SevenTag\\Api\\ContainerBundle\\ContainerLibrary\\ContainerLibraryEvent;\n+use SevenTag\\Api\\ContainerBundle\\ContainerLibrary\\Events;\n+use SevenTag\\Api\\ContainerBundle\\Entity\\ContainerRepository;\n+use Symfony\\Bundle\\FrameworkBundle\\Command\\ContainerAwareCommand;\n+use Symfony\\Component\\Console\\Helper\\DialogHelper;\n+use Symfony\\Component\\Console\\Helper\\ProgressBar;\n+use Symfony\\Component\\Console\\Input\\InputInterface;\n+use Symfony\\Component\\Console\\Input\\InputOption;\n+use Symfony\\Component\\Console\\Output\\OutputInterface;\n+use Symfony\\Component\\EventDispatcher\\EventDispatcherInterface;\n+\n+class RepublishContainerCommand extends ContainerAwareCommand\n+{\n+    /**\n+     * @var ContainerRepository\n+     */\n+    private $containerRepository;\n+\n+    /**\n+     * @var EventDispatcherInterface\n+     */\n+    private $eventDispatcher;\n+\n+    /**\n+     * @param ContainerRepository $containerRepository\n+     * @param EventDispatcherInterface $eventDispatcher\n+     */\n+    public function __construct(ContainerRepository $containerRepository, EventDispatcherInterface $eventDispatcher)\n+    {\n+        $this->containerRepository = $containerRepository;\n+        $this->eventDispatcher = $eventDispatcher;\n+\n+        parent::__construct(null);\n+    }\n+\n+    protected function configure()\n+    {\n+        $this\n+            ->setName('seventag:republish')\n+            ->setDescription('Republish containers or specified container')\n+            ->addOption('containerId', 'c', InputOption::VALUE_OPTIONAL, 'If set, republished will be only this container.', null);\n+    }\n+\n+    /**\n+     * @param InputInterface $input\n+     * @param OutputInterface $output\n+     * @return int|null|void\n+     */\n+    protected function execute(InputInterface $input, OutputInterface $output)\n+    {\n+        $containerId = $input->getOption('containerId');\n+\n+        if ($containerId) {\n+            $containers = $this->getSingleContainerToProcess($containerId);\n+        } else {\n+            $containers = $this->getAllPublishedContainersToProcess();\n+        }\n+\n+        if (null === $containers) {\n+            $output->writeln('<error>Nothing to republish.</error>');\n+\n+            return;\n+        }\n+\n+        /** @var DialogHelper $dialog */\n+        $dialog = $this->getHelper('dialog');\n+        if (!$dialog->askConfirmation($output, sprintf('<question>%d containers will be republished. Are you sure?', $containers->count(), false))) {\n+            return;\n+        }\n+\n+        $progress = new ProgressBar($output, $containers->count());\n+\n+        foreach ($containers as $container) {\n+            $this->eventDispatcher->dispatch(Events::CONTAINER_REPUBLISHED, new ContainerLibraryEvent($container));\n+\n+            $progress->advance();\n+        }\n+\n+        $progress->finish();\n+\n+        $output->writeln('');\n+        $output->writeln('<info>Republish completed.</info>');\n+    }\n+\n+    /**\n+     * @param $containerId\n+     * @return ArrayCollection|null\n+     */","path":"src/SevenTag/Api/AppBundle/Command/RepublishContainerCommand.php","position":109,"original_position":109,"commit_id":"dba13276bd88f61637ba32bb71f71fd623e282f6","original_commit_id":"dba13276bd88f61637ba32bb71f71fd623e282f6","user":{"login":"zientalak","id":1021504,"avatar_url":"https://avatars.githubusercontent.com/u/1021504?v=3","gravatar_id":"","url":"https://api.github.com/users/zientalak","html_url":"https://github.com/zientalak","followers_url":"https://api.github.com/users/zientalak/followers","following_url":"https://api.github.com/users/zientalak/following{/other_user}","gists_url":"https://api.github.com/users/zientalak/gists{/gist_id}","starred_url":"https://api.github.com/users/zientalak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zientalak/subscriptions","organizations_url":"https://api.github.com/users/zientalak/orgs","repos_url":"https://api.github.com/users/zientalak/repos","events_url":"https://api.github.com/users/zientalak/events{/privacy}","received_events_url":"https://api.github.com/users/zientalak/received_events","type":"User","site_admin":false},"body":"You don't need return nul in this placel. You can return ArrayCollection with empty collection data and then instead checking null in line 80 just make sure that collection is not empty:\r\n\r\n```\r\nif($containers->isEmpty() {}\r\n```","created_at":"2015-11-05T18:40:55Z","updated_at":"2015-11-05T18:40:55Z","html_url":"https://github.com/seventag/seventag/pull/216#discussion_r44050408","pull_request_url":"https://api.github.com/repos/seventag/seventag/pulls/216","_links":{"self":{"href":"https://api.github.com/repos/seventag/seventag/pulls/comments/44050408"},"html":{"href":"https://github.com/seventag/seventag/pull/216#discussion_r44050408"},"pull_request":{"href":"https://api.github.com/repos/seventag/seventag/pulls/216"}}},"pull_request":{"url":"https://api.github.com/repos/seventag/seventag/pulls/216","id":49843019,"html_url":"https://github.com/seventag/seventag/pull/216","diff_url":"https://github.com/seventag/seventag/pull/216.diff","patch_url":"https://github.com/seventag/seventag/pull/216.patch","issue_url":"https://api.github.com/repos/seventag/seventag/issues/216","number":216,"state":"open","locked":false,"title":"TM-965 create republish command","user":{"login":"kallosz","id":157952,"avatar_url":"https://avatars.githubusercontent.com/u/157952?v=3","gravatar_id":"","url":"https://api.github.com/users/kallosz","html_url":"https://github.com/kallosz","followers_url":"https://api.github.com/users/kallosz/followers","following_url":"https://api.github.com/users/kallosz/following{/other_user}","gists_url":"https://api.github.com/users/kallosz/gists{/gist_id}","starred_url":"https://api.github.com/users/kallosz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kallosz/subscriptions","organizations_url":"https://api.github.com/users/kallosz/orgs","repos_url":"https://api.github.com/users/kallosz/repos","events_url":"https://api.github.com/users/kallosz/events{/privacy}","received_events_url":"https://api.github.com/users/kallosz/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-11-05T16:04:03Z","updated_at":"2015-11-05T18:40:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"eaeec469e585792c2f1c4e9dfb9397336135c564","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/seventag/seventag/pulls/216/commits","review_comments_url":"https://api.github.com/repos/seventag/seventag/pulls/216/comments","review_comment_url":"https://api.github.com/repos/seventag/seventag/pulls/comments{/number}","comments_url":"https://api.github.com/repos/seventag/seventag/issues/216/comments","statuses_url":"https://api.github.com/repos/seventag/seventag/statuses/dba13276bd88f61637ba32bb71f71fd623e282f6","head":{"label":"seventag:feature/TM-965-republish-command","ref":"feature/TM-965-republish-command","sha":"dba13276bd88f61637ba32bb71f71fd623e282f6","user":{"login":"seventag","id":11617285,"avatar_url":"https://avatars.githubusercontent.com/u/11617285?v=3","gravatar_id":"","url":"https://api.github.com/users/seventag","html_url":"https://github.com/seventag","followers_url":"https://api.github.com/users/seventag/followers","following_url":"https://api.github.com/users/seventag/following{/other_user}","gists_url":"https://api.github.com/users/seventag/gists{/gist_id}","starred_url":"https://api.github.com/users/seventag/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seventag/subscriptions","organizations_url":"https://api.github.com/users/seventag/orgs","repos_url":"https://api.github.com/users/seventag/repos","events_url":"https://api.github.com/users/seventag/events{/privacy}","received_events_url":"https://api.github.com/users/seventag/received_events","type":"Organization","site_admin":false},"repo":{"id":32939880,"name":"seventag","full_name":"seventag/seventag","owner":{"login":"seventag","id":11617285,"avatar_url":"https://avatars.githubusercontent.com/u/11617285?v=3","gravatar_id":"","url":"https://api.github.com/users/seventag","html_url":"https://github.com/seventag","followers_url":"https://api.github.com/users/seventag/followers","following_url":"https://api.github.com/users/seventag/following{/other_user}","gists_url":"https://api.github.com/users/seventag/gists{/gist_id}","starred_url":"https://api.github.com/users/seventag/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seventag/subscriptions","organizations_url":"https://api.github.com/users/seventag/orgs","repos_url":"https://api.github.com/users/seventag/repos","events_url":"https://api.github.com/users/seventag/events{/privacy}","received_events_url":"https://api.github.com/users/seventag/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/seventag/seventag","description":"","fork":false,"url":"https://api.github.com/repos/seventag/seventag","forks_url":"https://api.github.com/repos/seventag/seventag/forks","keys_url":"https://api.github.com/repos/seventag/seventag/keys{/key_id}","collaborators_url":"https://api.github.com/repos/seventag/seventag/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/seventag/seventag/teams","hooks_url":"https://api.github.com/repos/seventag/seventag/hooks","issue_events_url":"https://api.github.com/repos/seventag/seventag/issues/events{/number}","events_url":"https://api.github.com/repos/seventag/seventag/events","assignees_url":"https://api.github.com/repos/seventag/seventag/assignees{/user}","branches_url":"https://api.github.com/repos/seventag/seventag/branches{/branch}","tags_url":"https://api.github.com/repos/seventag/seventag/tags","blobs_url":"https://api.github.com/repos/seventag/seventag/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/seventag/seventag/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/seventag/seventag/git/refs{/sha}","trees_url":"https://api.github.com/repos/seventag/seventag/git/trees{/sha}","statuses_url":"https://api.github.com/repos/seventag/seventag/statuses/{sha}","languages_url":"https://api.github.com/repos/seventag/seventag/languages","stargazers_url":"https://api.github.com/repos/seventag/seventag/stargazers","contributors_url":"https://api.github.com/repos/seventag/seventag/contributors","subscribers_url":"https://api.github.com/repos/seventag/seventag/subscribers","subscription_url":"https://api.github.com/repos/seventag/seventag/subscription","commits_url":"https://api.github.com/repos/seventag/seventag/commits{/sha}","git_commits_url":"https://api.github.com/repos/seventag/seventag/git/commits{/sha}","comments_url":"https://api.github.com/repos/seventag/seventag/comments{/number}","issue_comment_url":"https://api.github.com/repos/seventag/seventag/issues/comments{/number}","contents_url":"https://api.github.com/repos/seventag/seventag/contents/{+path}","compare_url":"https://api.github.com/repos/seventag/seventag/compare/{base}...{head}","merges_url":"https://api.github.com/repos/seventag/seventag/merges","archive_url":"https://api.github.com/repos/seventag/seventag/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/seventag/seventag/downloads","issues_url":"https://api.github.com/repos/seventag/seventag/issues{/number}","pulls_url":"https://api.github.com/repos/seventag/seventag/pulls{/number}","milestones_url":"https://api.github.com/repos/seventag/seventag/milestones{/number}","notifications_url":"https://api.github.com/repos/seventag/seventag/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/seventag/seventag/labels{/name}","releases_url":"https://api.github.com/repos/seventag/seventag/releases{/id}","created_at":"2015-03-26T16:46:33Z","updated_at":"2015-11-04T15:52:16Z","pushed_at":"2015-11-05T16:10:45Z","git_url":"git://github.com/seventag/seventag.git","ssh_url":"git@github.com:seventag/seventag.git","clone_url":"https://github.com/seventag/seventag.git","svn_url":"https://github.com/seventag/seventag","homepage":null,"size":6092,"stargazers_count":9,"watchers_count":9,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":29,"forks":2,"open_issues":29,"watchers":9,"default_branch":"develop"}},"base":{"label":"seventag:feature/TM-923-auto-republish-container","ref":"feature/TM-923-auto-republish-container","sha":"b1c2e6fefc216e1e877d9dc0c8ed7ba6b51a9cb3","user":{"login":"seventag","id":11617285,"avatar_url":"https://avatars.githubusercontent.com/u/11617285?v=3","gravatar_id":"","url":"https://api.github.com/users/seventag","html_url":"https://github.com/seventag","followers_url":"https://api.github.com/users/seventag/followers","following_url":"https://api.github.com/users/seventag/following{/other_user}","gists_url":"https://api.github.com/users/seventag/gists{/gist_id}","starred_url":"https://api.github.com/users/seventag/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seventag/subscriptions","organizations_url":"https://api.github.com/users/seventag/orgs","repos_url":"https://api.github.com/users/seventag/repos","events_url":"https://api.github.com/users/seventag/events{/privacy}","received_events_url":"https://api.github.com/users/seventag/received_events","type":"Organization","site_admin":false},"repo":{"id":32939880,"name":"seventag","full_name":"seventag/seventag","owner":{"login":"seventag","id":11617285,"avatar_url":"https://avatars.githubusercontent.com/u/11617285?v=3","gravatar_id":"","url":"https://api.github.com/users/seventag","html_url":"https://github.com/seventag","followers_url":"https://api.github.com/users/seventag/followers","following_url":"https://api.github.com/users/seventag/following{/other_user}","gists_url":"https://api.github.com/users/seventag/gists{/gist_id}","starred_url":"https://api.github.com/users/seventag/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seventag/subscriptions","organizations_url":"https://api.github.com/users/seventag/orgs","repos_url":"https://api.github.com/users/seventag/repos","events_url":"https://api.github.com/users/seventag/events{/privacy}","received_events_url":"https://api.github.com/users/seventag/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/seventag/seventag","description":"","fork":false,"url":"https://api.github.com/repos/seventag/seventag","forks_url":"https://api.github.com/repos/seventag/seventag/forks","keys_url":"https://api.github.com/repos/seventag/seventag/keys{/key_id}","collaborators_url":"https://api.github.com/repos/seventag/seventag/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/seventag/seventag/teams","hooks_url":"https://api.github.com/repos/seventag/seventag/hooks","issue_events_url":"https://api.github.com/repos/seventag/seventag/issues/events{/number}","events_url":"https://api.github.com/repos/seventag/seventag/events","assignees_url":"https://api.github.com/repos/seventag/seventag/assignees{/user}","branches_url":"https://api.github.com/repos/seventag/seventag/branches{/branch}","tags_url":"https://api.github.com/repos/seventag/seventag/tags","blobs_url":"https://api.github.com/repos/seventag/seventag/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/seventag/seventag/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/seventag/seventag/git/refs{/sha}","trees_url":"https://api.github.com/repos/seventag/seventag/git/trees{/sha}","statuses_url":"https://api.github.com/repos/seventag/seventag/statuses/{sha}","languages_url":"https://api.github.com/repos/seventag/seventag/languages","stargazers_url":"https://api.github.com/repos/seventag/seventag/stargazers","contributors_url":"https://api.github.com/repos/seventag/seventag/contributors","subscribers_url":"https://api.github.com/repos/seventag/seventag/subscribers","subscription_url":"https://api.github.com/repos/seventag/seventag/subscription","commits_url":"https://api.github.com/repos/seventag/seventag/commits{/sha}","git_commits_url":"https://api.github.com/repos/seventag/seventag/git/commits{/sha}","comments_url":"https://api.github.com/repos/seventag/seventag/comments{/number}","issue_comment_url":"https://api.github.com/repos/seventag/seventag/issues/comments{/number}","contents_url":"https://api.github.com/repos/seventag/seventag/contents/{+path}","compare_url":"https://api.github.com/repos/seventag/seventag/compare/{base}...{head}","merges_url":"https://api.github.com/repos/seventag/seventag/merges","archive_url":"https://api.github.com/repos/seventag/seventag/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/seventag/seventag/downloads","issues_url":"https://api.github.com/repos/seventag/seventag/issues{/number}","pulls_url":"https://api.github.com/repos/seventag/seventag/pulls{/number}","milestones_url":"https://api.github.com/repos/seventag/seventag/milestones{/number}","notifications_url":"https://api.github.com/repos/seventag/seventag/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/seventag/seventag/labels{/name}","releases_url":"https://api.github.com/repos/seventag/seventag/releases{/id}","created_at":"2015-03-26T16:46:33Z","updated_at":"2015-11-04T15:52:16Z","pushed_at":"2015-11-05T16:10:45Z","git_url":"git://github.com/seventag/seventag.git","ssh_url":"git@github.com:seventag/seventag.git","clone_url":"https://github.com/seventag/seventag.git","svn_url":"https://github.com/seventag/seventag","homepage":null,"size":6092,"stargazers_count":9,"watchers_count":9,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":29,"forks":2,"open_issues":29,"watchers":9,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/seventag/seventag/pulls/216"},"html":{"href":"https://github.com/seventag/seventag/pull/216"},"issue":{"href":"https://api.github.com/repos/seventag/seventag/issues/216"},"comments":{"href":"https://api.github.com/repos/seventag/seventag/issues/216/comments"},"review_comments":{"href":"https://api.github.com/repos/seventag/seventag/pulls/216/comments"},"review_comment":{"href":"https://api.github.com/repos/seventag/seventag/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/seventag/seventag/pulls/216/commits"},"statuses":{"href":"https://api.github.com/repos/seventag/seventag/statuses/dba13276bd88f61637ba32bb71f71fd623e282f6"}}}}