{"action":"created","comment":{"url":"https://api.github.com/repos/backbee/BackBee/pulls/comments/55487542","id":55487542,"diff_hunk":"@@ -0,0 +1,227 @@\n+<?php\n+\n+/*\n+ * Copyright (c) 2011-2016 Lp digital system\n+ *\n+ * This file is part of BackBee.\n+ *\n+ * BackBee is free software: you can redistribute it and/or modify\n+ * it under the terms of the GNU General Public License as published by\n+ * the Free Software Foundation, either version 3 of the License, or\n+ * (at your option) any later version.\n+ *\n+ * BackBee 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 General Public License for more details.\n+ *\n+ * You should have received a copy of the GNU General Public License\n+ * along with BackBee. If not, see <http://www.gnu.org/licenses/>.\n+ *\n+ * @author Bogdan Oanes <bogdan.oanes@lp-digital.fr>\n+ */\n+\n+namespace BackBee\\Console\\Command;\n+\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\\Yaml\\Yaml;\n+\n+use BackBee\\Console\\AbstractCommand;\n+\n+/**\n+ * Create new website entries.\n+ *\n+ * @category    BackBee\n+ *\n+ * @copyright   Lp digital system\n+ * @author      Bogdan Oanes <bogdan.oanes@lp-digital.fr>\n+ */\n+class CreateWebsiteCommand extends AbstractCommand\n+{\n+\tprivate $input;\n+\tprivate $output;\n+\n+\tprivate $app;\n+\tprivate $entyMgr;\n+\n+\tprivate $siteLabel;\n+\tprivate $siteDomain;\n+\n+    /**\n+     * Configure command\n+     */\n+    protected function configure()\n+    {\n+        $this\n+            ->setName('bbapp:create_site')\n+            ->addOption('site_label', 'site_label', InputOption::VALUE_OPTIONAL, 'site label.')\n+            ->addOption('site_domain', 'site_domain', InputOption::VALUE_OPTIONAL, 'site domain.')\n+            ->setDescription('Create new website.')\n+            ->setHelp(<<<EOF\n+The <info>%command.name%</info> updates app:\n+\n+   <info>php bbapp:create</info>\n+EOF\n+            )\n+        ;\n+    }\n+\n+    /** \n+     * Execute command\n+     */\n+    protected function execute(InputInterface $input, OutputInterface $output)\n+    {\n+    \t$this\n+    \t\t->init($input, $output)\n+    \t\t->runSitesYmlProcess()\n+    \t\t->runLayoutsGenerationProcess()\n+\t\t;\n+    }        \n+\n+    /** \n+     * Init main tools\n+     */\n+    protected function init(InputInterface $input, OutputInterface $output)\n+    {\n+    \t$this->input = $input;\n+    \t$this->output = $output;\n+\n+    \t$this->app = $this->getApplication()->getApplication();\n+    \t$this->entyMgr = $this->app->getEntityManager();\n+\n+    \t$this->siteLabel = $this->input->getOption('site_label');\n+\n+\t\tif (!filter_var($this->input->getOption('site_domain'), FILTER_VALIDATE_URL)){\n+\t\t\t$this->output->writeln('<error>Invalid site domain format. Example of valid domain: http://backbee.com</error>');\n+\t\t}    \t\n+        $host = parse_url($this->input->getOption('site_domain'),PHP_URL_HOST);\n+        $port = parse_url($this->input->getOption('site_domain'), PHP_URL_PORT);\n+\n+        $this->siteDomain = $host.(empty($port) ? '' : ':'.$port);\n+\n+    \treturn $this;\n+    }\n+\n+    /** \n+     * Update sites.yml file\n+     */\n+\tprotected function runSitesYmlProcess() \n+\t{\n+\t\t$sitesConf = $this->app->getConfig()->getSitesConfig();\n+\n+\t\tif (is_array($sitesConf) && array_key_exists($this->siteLabel, $sitesConf)) {\n+\t\t\t$this->output->writeln('<info>This label already present in sites.yml</info>'); \n+\t\t\treturn $this;\n+\t\t}\n+\n+\t\tif (is_array($sitesConf) && in_array($this->siteDomain, array_column($sitesConf, 'domain'))) {\n+\t\t\t$this->output->writeln('<info>This domain already present in sites.yml</info>'); \n+\t\t\treturn $this;\n+\t\t}\n+\n+        $newSite = [\n+            \\BackBee\\Utils\\StringUtils::urlize($this->siteLabel) => [\n+                'label'  => $this->siteLabel,\n+                'domain' => $this->siteDomain,\n+            ],\n+        ];\t\t\n+\n+        $newSitesConf = (is_array($sitesConf)) ? array_merge($sitesConf, $newSite) : $newSite;\n+\n+\t\tfile_put_contents(\n+\t\t\t$this->app->getBaseDir().DIRECTORY_SEPARATOR.'repository/Config/sites.yml', \n+\t\t\tYaml::dump($newSitesConf)\n+\t\t);\n+\n+\t\treturn $this;","path":"Console/Command/CreateWebsiteCommand.php","position":138,"original_position":138,"commit_id":"01528b80ca01b1c62b937acf13c313c5b97275da","original_commit_id":"01528b80ca01b1c62b937acf13c313c5b97275da","user":{"login":"crouillon","id":7767868,"avatar_url":"https://avatars.githubusercontent.com/u/7767868?v=3","gravatar_id":"","url":"https://api.github.com/users/crouillon","html_url":"https://github.com/crouillon","followers_url":"https://api.github.com/users/crouillon/followers","following_url":"https://api.github.com/users/crouillon/following{/other_user}","gists_url":"https://api.github.com/users/crouillon/gists{/gist_id}","starred_url":"https://api.github.com/users/crouillon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crouillon/subscriptions","organizations_url":"https://api.github.com/users/crouillon/orgs","repos_url":"https://api.github.com/users/crouillon/repos","events_url":"https://api.github.com/users/crouillon/events{/privacy}","received_events_url":"https://api.github.com/users/crouillon/received_events","type":"User","site_admin":false},"body":"Format please","created_at":"2016-03-09T08:53:08Z","updated_at":"2016-03-09T08:53:08Z","html_url":"https://github.com/backbee/BackBee/pull/687#discussion_r55487542","pull_request_url":"https://api.github.com/repos/backbee/BackBee/pulls/687","_links":{"self":{"href":"https://api.github.com/repos/backbee/BackBee/pulls/comments/55487542"},"html":{"href":"https://github.com/backbee/BackBee/pull/687#discussion_r55487542"},"pull_request":{"href":"https://api.github.com/repos/backbee/BackBee/pulls/687"}}},"pull_request":{"url":"https://api.github.com/repos/backbee/BackBee/pulls/687","id":62082568,"html_url":"https://github.com/backbee/BackBee/pull/687","diff_url":"https://github.com/backbee/BackBee/pull/687.diff","patch_url":"https://github.com/backbee/BackBee/pull/687.patch","issue_url":"https://api.github.com/repos/backbee/BackBee/issues/687","number":687,"state":"open","locked":false,"title":"Reset commands","user":{"login":"oanesbogdan","id":6011217,"avatar_url":"https://avatars.githubusercontent.com/u/6011217?v=3","gravatar_id":"","url":"https://api.github.com/users/oanesbogdan","html_url":"https://github.com/oanesbogdan","followers_url":"https://api.github.com/users/oanesbogdan/followers","following_url":"https://api.github.com/users/oanesbogdan/following{/other_user}","gists_url":"https://api.github.com/users/oanesbogdan/gists{/gist_id}","starred_url":"https://api.github.com/users/oanesbogdan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oanesbogdan/subscriptions","organizations_url":"https://api.github.com/users/oanesbogdan/orgs","repos_url":"https://api.github.com/users/oanesbogdan/repos","events_url":"https://api.github.com/users/oanesbogdan/events{/privacy}","received_events_url":"https://api.github.com/users/oanesbogdan/received_events","type":"User","site_admin":false},"body":"- bbapp:update \r\n     - adjusted to accept host/port/user/password as options\r\n     - drop all tables\r\n- bbapp:create_site\r\n    - create a new website entry in site table\r\n    - creates the layouts and the root page\r\n- bbapp:create_sudoer\r\n    - creates a new sudoer\r\n- users:update_rights\r\n    - updates the user group rights\r\n    - posibility to create a new user and assign a usergroup","created_at":"2016-03-08T15:00:22Z","updated_at":"2016-03-09T08:53:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"26188c794babdf4993d284334514bca80092e374","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/backbee/BackBee/pulls/687/commits","review_comments_url":"https://api.github.com/repos/backbee/BackBee/pulls/687/comments","review_comment_url":"https://api.github.com/repos/backbee/BackBee/pulls/comments{/number}","comments_url":"https://api.github.com/repos/backbee/BackBee/issues/687/comments","statuses_url":"https://api.github.com/repos/backbee/BackBee/statuses/01528b80ca01b1c62b937acf13c313c5b97275da","head":{"label":"oanesbogdan:reset-commands","ref":"reset-commands","sha":"01528b80ca01b1c62b937acf13c313c5b97275da","user":{"login":"oanesbogdan","id":6011217,"avatar_url":"https://avatars.githubusercontent.com/u/6011217?v=3","gravatar_id":"","url":"https://api.github.com/users/oanesbogdan","html_url":"https://github.com/oanesbogdan","followers_url":"https://api.github.com/users/oanesbogdan/followers","following_url":"https://api.github.com/users/oanesbogdan/following{/other_user}","gists_url":"https://api.github.com/users/oanesbogdan/gists{/gist_id}","starred_url":"https://api.github.com/users/oanesbogdan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oanesbogdan/subscriptions","organizations_url":"https://api.github.com/users/oanesbogdan/orgs","repos_url":"https://api.github.com/users/oanesbogdan/repos","events_url":"https://api.github.com/users/oanesbogdan/events{/privacy}","received_events_url":"https://api.github.com/users/oanesbogdan/received_events","type":"User","site_admin":false},"repo":{"id":49934679,"name":"BackBee","full_name":"oanesbogdan/BackBee","owner":{"login":"oanesbogdan","id":6011217,"avatar_url":"https://avatars.githubusercontent.com/u/6011217?v=3","gravatar_id":"","url":"https://api.github.com/users/oanesbogdan","html_url":"https://github.com/oanesbogdan","followers_url":"https://api.github.com/users/oanesbogdan/followers","following_url":"https://api.github.com/users/oanesbogdan/following{/other_user}","gists_url":"https://api.github.com/users/oanesbogdan/gists{/gist_id}","starred_url":"https://api.github.com/users/oanesbogdan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oanesbogdan/subscriptions","organizations_url":"https://api.github.com/users/oanesbogdan/orgs","repos_url":"https://api.github.com/users/oanesbogdan/repos","events_url":"https://api.github.com/users/oanesbogdan/events{/privacy}","received_events_url":"https://api.github.com/users/oanesbogdan/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/oanesbogdan/BackBee","description":"the next generation CMS built on top of Symfony and Doctrine components. Give us a star to support our project :)","fork":true,"url":"https://api.github.com/repos/oanesbogdan/BackBee","forks_url":"https://api.github.com/repos/oanesbogdan/BackBee/forks","keys_url":"https://api.github.com/repos/oanesbogdan/BackBee/keys{/key_id}","collaborators_url":"https://api.github.com/repos/oanesbogdan/BackBee/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/oanesbogdan/BackBee/teams","hooks_url":"https://api.github.com/repos/oanesbogdan/BackBee/hooks","issue_events_url":"https://api.github.com/repos/oanesbogdan/BackBee/issues/events{/number}","events_url":"https://api.github.com/repos/oanesbogdan/BackBee/events","assignees_url":"https://api.github.com/repos/oanesbogdan/BackBee/assignees{/user}","branches_url":"https://api.github.com/repos/oanesbogdan/BackBee/branches{/branch}","tags_url":"https://api.github.com/repos/oanesbogdan/BackBee/tags","blobs_url":"https://api.github.com/repos/oanesbogdan/BackBee/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/oanesbogdan/BackBee/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/oanesbogdan/BackBee/git/refs{/sha}","trees_url":"https://api.github.com/repos/oanesbogdan/BackBee/git/trees{/sha}","statuses_url":"https://api.github.com/repos/oanesbogdan/BackBee/statuses/{sha}","languages_url":"https://api.github.com/repos/oanesbogdan/BackBee/languages","stargazers_url":"https://api.github.com/repos/oanesbogdan/BackBee/stargazers","contributors_url":"https://api.github.com/repos/oanesbogdan/BackBee/contributors","subscribers_url":"https://api.github.com/repos/oanesbogdan/BackBee/subscribers","subscription_url":"https://api.github.com/repos/oanesbogdan/BackBee/subscription","commits_url":"https://api.github.com/repos/oanesbogdan/BackBee/commits{/sha}","git_commits_url":"https://api.github.com/repos/oanesbogdan/BackBee/git/commits{/sha}","comments_url":"https://api.github.com/repos/oanesbogdan/BackBee/comments{/number}","issue_comment_url":"https://api.github.com/repos/oanesbogdan/BackBee/issues/comments{/number}","contents_url":"https://api.github.com/repos/oanesbogdan/BackBee/contents/{+path}","compare_url":"https://api.github.com/repos/oanesbogdan/BackBee/compare/{base}...{head}","merges_url":"https://api.github.com/repos/oanesbogdan/BackBee/merges","archive_url":"https://api.github.com/repos/oanesbogdan/BackBee/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/oanesbogdan/BackBee/downloads","issues_url":"https://api.github.com/repos/oanesbogdan/BackBee/issues{/number}","pulls_url":"https://api.github.com/repos/oanesbogdan/BackBee/pulls{/number}","milestones_url":"https://api.github.com/repos/oanesbogdan/BackBee/milestones{/number}","notifications_url":"https://api.github.com/repos/oanesbogdan/BackBee/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/oanesbogdan/BackBee/labels{/name}","releases_url":"https://api.github.com/repos/oanesbogdan/BackBee/releases{/id}","deployments_url":"https://api.github.com/repos/oanesbogdan/BackBee/deployments","created_at":"2016-01-19T07:27:31Z","updated_at":"2016-01-19T07:27:33Z","pushed_at":"2016-03-08T15:00:08Z","git_url":"git://github.com/oanesbogdan/BackBee.git","ssh_url":"git@github.com:oanesbogdan/BackBee.git","clone_url":"https://github.com/oanesbogdan/BackBee.git","svn_url":"https://github.com/oanesbogdan/BackBee","homepage":"http://www.backbee.com","size":26259,"stargazers_count":0,"watchers_count":0,"language":"PHP","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":"backbee:master","ref":"master","sha":"1eeaa145a7451f3f97edb095cf44682ad4712759","user":{"login":"backbee","id":8198689,"avatar_url":"https://avatars.githubusercontent.com/u/8198689?v=3","gravatar_id":"","url":"https://api.github.com/users/backbee","html_url":"https://github.com/backbee","followers_url":"https://api.github.com/users/backbee/followers","following_url":"https://api.github.com/users/backbee/following{/other_user}","gists_url":"https://api.github.com/users/backbee/gists{/gist_id}","starred_url":"https://api.github.com/users/backbee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/backbee/subscriptions","organizations_url":"https://api.github.com/users/backbee/orgs","repos_url":"https://api.github.com/users/backbee/repos","events_url":"https://api.github.com/users/backbee/events{/privacy}","received_events_url":"https://api.github.com/users/backbee/received_events","type":"Organization","site_admin":false},"repo":{"id":21970893,"name":"BackBee","full_name":"backbee/BackBee","owner":{"login":"backbee","id":8198689,"avatar_url":"https://avatars.githubusercontent.com/u/8198689?v=3","gravatar_id":"","url":"https://api.github.com/users/backbee","html_url":"https://github.com/backbee","followers_url":"https://api.github.com/users/backbee/followers","following_url":"https://api.github.com/users/backbee/following{/other_user}","gists_url":"https://api.github.com/users/backbee/gists{/gist_id}","starred_url":"https://api.github.com/users/backbee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/backbee/subscriptions","organizations_url":"https://api.github.com/users/backbee/orgs","repos_url":"https://api.github.com/users/backbee/repos","events_url":"https://api.github.com/users/backbee/events{/privacy}","received_events_url":"https://api.github.com/users/backbee/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/backbee/BackBee","description":"the next generation CMS built on top of Symfony and Doctrine components. Give us a star to support our project :)","fork":false,"url":"https://api.github.com/repos/backbee/BackBee","forks_url":"https://api.github.com/repos/backbee/BackBee/forks","keys_url":"https://api.github.com/repos/backbee/BackBee/keys{/key_id}","collaborators_url":"https://api.github.com/repos/backbee/BackBee/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/backbee/BackBee/teams","hooks_url":"https://api.github.com/repos/backbee/BackBee/hooks","issue_events_url":"https://api.github.com/repos/backbee/BackBee/issues/events{/number}","events_url":"https://api.github.com/repos/backbee/BackBee/events","assignees_url":"https://api.github.com/repos/backbee/BackBee/assignees{/user}","branches_url":"https://api.github.com/repos/backbee/BackBee/branches{/branch}","tags_url":"https://api.github.com/repos/backbee/BackBee/tags","blobs_url":"https://api.github.com/repos/backbee/BackBee/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/backbee/BackBee/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/backbee/BackBee/git/refs{/sha}","trees_url":"https://api.github.com/repos/backbee/BackBee/git/trees{/sha}","statuses_url":"https://api.github.com/repos/backbee/BackBee/statuses/{sha}","languages_url":"https://api.github.com/repos/backbee/BackBee/languages","stargazers_url":"https://api.github.com/repos/backbee/BackBee/stargazers","contributors_url":"https://api.github.com/repos/backbee/BackBee/contributors","subscribers_url":"https://api.github.com/repos/backbee/BackBee/subscribers","subscription_url":"https://api.github.com/repos/backbee/BackBee/subscription","commits_url":"https://api.github.com/repos/backbee/BackBee/commits{/sha}","git_commits_url":"https://api.github.com/repos/backbee/BackBee/git/commits{/sha}","comments_url":"https://api.github.com/repos/backbee/BackBee/comments{/number}","issue_comment_url":"https://api.github.com/repos/backbee/BackBee/issues/comments{/number}","contents_url":"https://api.github.com/repos/backbee/BackBee/contents/{+path}","compare_url":"https://api.github.com/repos/backbee/BackBee/compare/{base}...{head}","merges_url":"https://api.github.com/repos/backbee/BackBee/merges","archive_url":"https://api.github.com/repos/backbee/BackBee/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/backbee/BackBee/downloads","issues_url":"https://api.github.com/repos/backbee/BackBee/issues{/number}","pulls_url":"https://api.github.com/repos/backbee/BackBee/pulls{/number}","milestones_url":"https://api.github.com/repos/backbee/BackBee/milestones{/number}","notifications_url":"https://api.github.com/repos/backbee/BackBee/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/backbee/BackBee/labels{/name}","releases_url":"https://api.github.com/repos/backbee/BackBee/releases{/id}","deployments_url":"https://api.github.com/repos/backbee/BackBee/deployments","created_at":"2014-07-18T06:51:12Z","updated_at":"2016-02-29T08:51:03Z","pushed_at":"2016-03-08T15:00:23Z","git_url":"git://github.com/backbee/BackBee.git","ssh_url":"git@github.com:backbee/BackBee.git","clone_url":"https://github.com/backbee/BackBee.git","svn_url":"https://github.com/backbee/BackBee","homepage":"http://www.backbee.com","size":28136,"stargazers_count":181,"watchers_count":181,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":31,"mirror_url":null,"open_issues_count":82,"forks":31,"open_issues":82,"watchers":181,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/backbee/BackBee/pulls/687"},"html":{"href":"https://github.com/backbee/BackBee/pull/687"},"issue":{"href":"https://api.github.com/repos/backbee/BackBee/issues/687"},"comments":{"href":"https://api.github.com/repos/backbee/BackBee/issues/687/comments"},"review_comments":{"href":"https://api.github.com/repos/backbee/BackBee/pulls/687/comments"},"review_comment":{"href":"https://api.github.com/repos/backbee/BackBee/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/backbee/BackBee/pulls/687/commits"},"statuses":{"href":"https://api.github.com/repos/backbee/BackBee/statuses/01528b80ca01b1c62b937acf13c313c5b97275da"}}}}