From 903b671e7d6cc1c289be5dc7f356a9e5fb98dbf7 Mon Sep 17 00:00:00 2001 From: Fbenas Date: Fri, 25 Aug 2017 01:47:18 +0100 Subject: Add config and config loader and remove requirement of trailing slashes in config values --- src/Script/Command/Site/Create.php | 42 ++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 11 deletions(-) (limited to 'src/Script') diff --git a/src/Script/Command/Site/Create.php b/src/Script/Command/Site/Create.php index 81df87e..e300ef7 100644 --- a/src/Script/Command/Site/Create.php +++ b/src/Script/Command/Site/Create.php @@ -58,10 +58,10 @@ class Create extends SyCommand $domain = $input->getArgument('domain'); $output->writeln( - 'Creating new site with domain: ' - . $input->getArgument('domain') - . ' and name: ' + 'Creating new site with name: ' . $input->getArgument('name') + . ' and domain: ' + . $input->getArgument('domain') ); // Set-up progress bar @@ -79,12 +79,12 @@ class Create extends SyCommand try { $tasks['Creating site directory'] = new \App\Filesystem\CreateDirectory( - SITES_ROOT . $name + $this->getFullSitesPath($name) ); $tasks['Creating nginx config file'] = new \App\Filesystem\CreateFile( CONFIG_ROOT . $name . '.conf', - include_once(DIPPER_ROOT . 'nginx/stub.php') + include_once(DIPPER_ROOT . '/nginx/stub.php') ); } catch (\Exception $e) { $output->writeln(''); @@ -104,35 +104,35 @@ class Create extends SyCommand $this->runTask( new \App\Filesystem\CreateDirectory( - SITES_ROOT . $name . '/logs' + $this->getFullSitesPath($name) . '/logs' ), 'Creating logs directory' ); $this->runTask( new \App\Filesystem\CreateFile( - SITES_ROOT . $name . '/logs/' . $name . '.access_log' + $this->getFullSitesPath($name) . '/logs/' . $name . '.access_log' ), 'Creating access log file' ); $this->runTask( new \App\Filesystem\CreateFile( - SITES_ROOT . $name . '/logs/' . $name . '.errors_log' + $this->getFullSitesPath($name) . '/logs/' . $name . '.errors_log' ), 'Creating error log file' ); $this->runTask( new \App\Filesystem\CreateDirectory( - SITES_ROOT . $name . '/web' + $this->getFullSitesPath($name) . '/web' ), 'Creating web folder' ); $this->runTask( new \App\Filesystem\CreateFile( - SITES_ROOT . $name . '/web/index.php' + $this->getFullSitesPath($name) . '/web/index.php' ), 'Creating directory index.php' ); @@ -159,7 +159,27 @@ class Create extends SyCommand $output->writeln('Complete'); } - public function runTask($task, $message) + /** + * Return the full path of a given file + * + * @author Phil Burton + * @param string $path + * @return string + */ + protected function getFullSitesPath($path) + { + return SITES_ROOT . "/" . $path; + } + + /** + * Run a task + * + * @author Phil Burton + * @param mixed $task + * @param string $message + * @return string + */ + protected function runTask($task, $message) { $this->progressBar->advance(); $this->progressBar->setMessage($message); -- cgit v1.2.3