diff --git a/src/Joomlatools/Console/Command/Vhost/Create.php b/src/Joomlatools/Console/Command/Vhost/Create.php index c1990b91..3013e66a 100644 --- a/src/Joomlatools/Console/Command/Vhost/Create.php +++ b/src/Joomlatools/Console/Command/Vhost/Create.php @@ -91,9 +91,6 @@ protected function execute(InputInterface $input, OutputInterface $output) throw new \RuntimeException(sprintf('Site not found: %s', $this->site)); } - $port = $input->getOption('http-port'); - $path = realpath(__DIR__.'/../../../../../bin/.files/'); - $tmp = '/tmp/vhost.tmp'; $variables = $this->_getVariables($input); @@ -107,7 +104,8 @@ protected function execute(InputInterface $input, OutputInterface $output) `sudo tee /etc/apache2/sites-available/1-$site.conf < $tmp`; `sudo a2ensite 1-$site.conf`; - `sudo /etc/init.d/apache2 restart > /dev/null 2>&1`; + + $restart[] = 'apache'; @unlink($tmp); } @@ -130,10 +128,18 @@ protected function execute(InputInterface $input, OutputInterface $output) `sudo tee /etc/nginx/sites-available/1-$site.conf < $tmp`; `sudo ln -fs /etc/nginx/sites-available/1-$site.conf /etc/nginx/sites-enabled/1-$site.conf`; - `sudo /etc/init.d/nginx restart > /dev/null 2>&1`; + + $restart[] = 'nginx'; @unlink($tmp); } + + if (Util::isJoomlatoolsBox() && $restart) + { + $arguments = implode(' ', $restart); + + `box server:restart $arguments`; + } } protected function _getVariables(InputInterface $input) diff --git a/src/Joomlatools/Console/Command/Vhost/Remove.php b/src/Joomlatools/Console/Command/Vhost/Remove.php index dd22679f..2d71bcd7 100644 --- a/src/Joomlatools/Console/Command/Vhost/Remove.php +++ b/src/Joomlatools/Console/Command/Vhost/Remove.php @@ -7,10 +7,10 @@ namespace Joomlatools\Console\Command\Vhost; +use Joomlatools\Console\Joomla\Util; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; class Remove extends Command @@ -32,14 +32,16 @@ protected function configure() protected function execute(InputInterface $input, OutputInterface $output) { - $site = $input->getArgument('site'); - $file = '/etc/apache2/sites-available/1-' . $site . '.conf'; + $site = $input->getArgument('site'); + $restart = []; + $file = '/etc/apache2/sites-available/1-' . $site . '.conf'; if (is_file($file)) { `sudo a2dissite 1-$site.conf`; `sudo rm $file`; - `sudo /etc/init.d/apache2 restart > /dev/null 2>&1`; + + $restart[] = 'apache'; } $file = '/etc/nginx/sites-available/1-' . $site . '.conf'; @@ -48,7 +50,15 @@ protected function execute(InputInterface $input, OutputInterface $output) { `sudo rm -f $file`; `sudo rm -f /etc/nginx/sites-enabled/1-$site.conf`; - `sudo /etc/init.d/nginx restart > /dev/null 2>&1`; + + $restart[] = 'nginx'; + } + + if (Util::isJoomlatoolsBox() && $restart) + { + $arguments = implode(' ', $restart); + + `box server:restart $arguments`; } } } \ No newline at end of file