|
|
@ -112,7 +112,7 @@ class NginxVhostsCommand extends Command |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* create Configuration, add for each template a submenu |
|
|
|
* create Configuration, add for each template a submenu |
|
|
|
* |
|
|
|
* |
|
|
|
* @param array $template |
|
|
@ -121,7 +121,9 @@ class NginxVhostsCommand extends Command |
|
|
|
*/ |
|
|
|
private function createConfiguration($template, $blade) |
|
|
|
{ |
|
|
|
$menu = function(CliMenuBuilder $builder) use ($template, $blade) |
|
|
|
$self = $this; |
|
|
|
|
|
|
|
$menu = function(CliMenuBuilder $builder) use ($template, $blade, $self) |
|
|
|
{ |
|
|
|
$configuration = [ |
|
|
|
'domain' => '', |
|
|
@ -172,9 +174,15 @@ class NginxVhostsCommand extends Command |
|
|
|
->addMenuItem($checkboxSSL) |
|
|
|
->addMenuItem($checkboxRedirect) |
|
|
|
->addLineBreak('-') |
|
|
|
->addItem('save', function() use (&$configuration, $template, $blade) { |
|
|
|
->addItem('save', function(CliMenu $menu) use (&$configuration, $template, $blade, $self) { |
|
|
|
$content = $blade->render($template['name'], $configuration); |
|
|
|
file_put_contents('/etc/nginx/sites-available/'.$configuration['domain'].'.conf', $content); |
|
|
|
|
|
|
|
$parent = $menu->getParent(); |
|
|
|
$menu->closeThis(); |
|
|
|
|
|
|
|
$mainmenu = $parent->getParent(); |
|
|
|
$mainmenu->open(); |
|
|
|
}) |
|
|
|
->addLineBreak('-'); |
|
|
|
}; |
|
|
@ -182,6 +190,13 @@ class NginxVhostsCommand extends Command |
|
|
|
return $menu; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* |
|
|
|
* |
|
|
|
* |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* create submenu for vhost |
|
|
|
* |
|
|
@ -192,7 +207,7 @@ class NginxVhostsCommand extends Command |
|
|
|
*/ |
|
|
|
private function vhost($vhost) |
|
|
|
{ |
|
|
|
$menu = function(CliMenuBuilder $builder) use ($vhost) |
|
|
|
$currentMenu = function(CliMenuBuilder $builder) use ($vhost) |
|
|
|
{ |
|
|
|
$checkbox = new CheckboxItem('enabled', function(CliMenu $menu) use ($vhost) { |
|
|
|
|
|
|
@ -234,6 +249,14 @@ class NginxVhostsCommand extends Command |
|
|
|
} else { |
|
|
|
unlink('/etc/nginx/sites-available/'.$vhost['file']); |
|
|
|
$menu->confirm($vhost['domain'].' is deleted!')->display('OK!'); |
|
|
|
|
|
|
|
// get
|
|
|
|
$parent = $menu->getParent(); |
|
|
|
$menu->closeThis(); |
|
|
|
|
|
|
|
// remove current vhost from mainmenu
|
|
|
|
$parent->removeItem($parent->getSelectedItem()); |
|
|
|
$parent->open(); |
|
|
|
} |
|
|
|
}) |
|
|
|
->addLineBreak('-') |
|
|
@ -241,6 +264,24 @@ class NginxVhostsCommand extends Command |
|
|
|
->addLineBreak('-'); |
|
|
|
}; |
|
|
|
|
|
|
|
return $currentMenu; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* |
|
|
|
* |
|
|
|
*/ |
|
|
|
protected function updateVhosts($menu) |
|
|
|
{ |
|
|
|
// getting vhosts
|
|
|
|
$vhosts = NginxVhost::find(); |
|
|
|
|
|
|
|
// add submenu for each vhost
|
|
|
|
foreach($vhosts as $vhost) { |
|
|
|
$submenuEditVhost = $this->vhost($vhost); |
|
|
|
$menu->addSubMenu($vhost['domain'], $submenuEditVhost); |
|
|
|
} |
|
|
|
|
|
|
|
return $menu; |
|
|
|
} |
|
|
|
|
|
|
@ -260,14 +301,7 @@ class NginxVhostsCommand extends Command |
|
|
|
->addSubMenu('add', $submenuSelectTemplate) |
|
|
|
->addLineBreak('-'); |
|
|
|
|
|
|
|
// getting vhosts
|
|
|
|
$vhosts = NginxVhost::find(); |
|
|
|
|
|
|
|
// add submenu for each vhost
|
|
|
|
foreach($vhosts as $vhost) { |
|
|
|
$submenuEditVhost = $this->vhost($vhost); |
|
|
|
$main->addSubMenu($vhost['domain'], $submenuEditVhost); |
|
|
|
} |
|
|
|
$main = $this->updateVhosts($main); |
|
|
|
|
|
|
|
$main->addLineBreak('-'); |
|
|
|
$main->open(); |
|
|
|