diff options
author | Phil Burton <phil@pgburton.com> | 2017-08-22 10:10:29 +0100 |
---|---|---|
committer | Phil Burton <phil@pgburton.com> | 2017-08-22 10:10:29 +0100 |
commit | 7b1e62d0cbc3519c469b2afd4da712125707de66 (patch) | |
tree | 06ee38c18849f9b0c85c2eb82bded824e2ff34e6 /src | |
parent | a4170353515c254ab7404117e7d9b3f15887214a (diff) | |
parent | 47b154758e789e75ec597d88540cdb7f4e352225 (diff) |
Merge branch 'master' of www.blatech.co.uk:FBeans/dipper
Diffstat (limited to 'src')
-rw-r--r-- | src/Filesystem/CreateFile.php | 13 | ||||
-rw-r--r-- | src/Nginx/Restart.php | 21 | ||||
-rw-r--r-- | src/Script/Command/Site/Create.php | 5 |
3 files changed, 36 insertions, 3 deletions
diff --git a/src/Filesystem/CreateFile.php b/src/Filesystem/CreateFile.php index 08ba0db..93c66a6 100644 --- a/src/Filesystem/CreateFile.php +++ b/src/Filesystem/CreateFile.php @@ -18,16 +18,22 @@ class CreateFile protected $filename; + protected $contents; + /** * Check if the file already exists * * @param string $filename * @author Phil Burton <phil@d3r.com> */ - public function __construct(string $filename) + public function __construct(string $filename, $contents = false) { $this->filename = $filename; + if ($contents) { + $this->contents = $contents; + } + if (!is_writable(dirname($filename))) { throw new \Exception('Cannot create ' . $this->thing . ' at: ' . $filename); } @@ -45,5 +51,10 @@ class CreateFile public function execute() { touch($this->filename); + + $contents = $this->contents; + if ($contents) { + file_put_contents($this->filename, $contents); + } } } diff --git a/src/Nginx/Restart.php b/src/Nginx/Restart.php new file mode 100644 index 0000000..cd150be --- /dev/null +++ b/src/Nginx/Restart.php @@ -0,0 +1,21 @@ +<?php + +namespace App\Nginx; + +/** + * Restarts nginx + * + * @author Phil Burton <phil@d3r.com> + */ +class Restart +{ + /** + * Create the new file + * + * @author Phil Burton <phil@d3r.com> + */ + public function restart() + { + + } +} diff --git a/src/Script/Command/Site/Create.php b/src/Script/Command/Site/Create.php index c7936fd..81df87e 100644 --- a/src/Script/Command/Site/Create.php +++ b/src/Script/Command/Site/Create.php @@ -52,7 +52,7 @@ class Create extends SyCommand */ protected function execute(InputInterface $input, OutputInterface $output) { - $taskCount = 6; + $taskCount = 9; $name = $input->getArgument('name'); $domain = $input->getArgument('domain'); @@ -83,7 +83,8 @@ class Create extends SyCommand ); $tasks['Creating nginx config file'] = new \App\Filesystem\CreateFile( - CONFIG_ROOT . $name . '.conf' + CONFIG_ROOT . $name . '.conf', + include_once(DIPPER_ROOT . 'nginx/stub.php') ); } catch (\Exception $e) { $output->writeln(''); |