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