|
|
@ -10,6 +10,9 @@ use App\Facades\Install; |
|
|
|
use App\Facades\NginxVhost; |
|
|
|
use App\Facades\NginxVhostFactory; |
|
|
|
use App\Facades\TerminalHelper; |
|
|
|
use App\Facades\Menus\StylesFactory; |
|
|
|
|
|
|
|
use App\Helpers\NginxTemplateHelper; |
|
|
|
|
|
|
|
use App\BladeFile; |
|
|
|
|
|
|
@ -55,43 +58,6 @@ class NginxVhostsCommand extends Command |
|
|
|
*/ |
|
|
|
protected $description = 'Create and Manage Nginx Vhosts'; |
|
|
|
|
|
|
|
/** |
|
|
|
* |
|
|
|
* @param string $prefix [description] |
|
|
|
* @return [type] [description] |
|
|
|
*/ |
|
|
|
private function getTemplates($prefix = '') |
|
|
|
{ |
|
|
|
// templates
|
|
|
|
$templates = []; |
|
|
|
|
|
|
|
// getting templates
|
|
|
|
$files = scandir(base_path().self::TEMPLATES_DIR); |
|
|
|
|
|
|
|
foreach($files as $file) { |
|
|
|
|
|
|
|
// create filepath
|
|
|
|
$filepath = base_path().self::TEMPLATES_DIR.'/'.$file; |
|
|
|
|
|
|
|
// getting info
|
|
|
|
$pathinfo = pathinfo($filepath); |
|
|
|
|
|
|
|
// if extension isset and php
|
|
|
|
if (isset($pathinfo['extension']) && $pathinfo['extension'] === 'php') { |
|
|
|
|
|
|
|
$name = str_replace('.blade.php', '', $file); |
|
|
|
|
|
|
|
$templates[] = [ |
|
|
|
'name' => $name, |
|
|
|
'file' => $file, |
|
|
|
'filepath' => $filepath |
|
|
|
]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return $templates; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* |
|
|
|
* |
|
|
@ -99,19 +65,18 @@ class NginxVhostsCommand extends Command |
|
|
|
*/ |
|
|
|
private function selectTemplate() |
|
|
|
{ |
|
|
|
// getting templates
|
|
|
|
$templates = $this->getTemplates(); |
|
|
|
|
|
|
|
// create blade
|
|
|
|
$bladeFile = new BladeFile(self::TEMPLATES_DIR); |
|
|
|
|
|
|
|
$menu = function(CliMenuBuilder $builder) use ($templates, $bladeFile) |
|
|
|
$menu = function(CliMenuBuilder $builder) |
|
|
|
{ |
|
|
|
// create blade
|
|
|
|
$bladeFile = new BladeFile(self::TEMPLATES_DIR); |
|
|
|
|
|
|
|
$builder |
|
|
|
->setTitle('Nginx > Add') |
|
|
|
->setGoBackButtonText('Back'); |
|
|
|
|
|
|
|
foreach($templates as $template) { |
|
|
|
$nginxTemplateHelper = new NginxTemplateHelper(); |
|
|
|
|
|
|
|
foreach($nginxTemplateHelper->find() as $template) { |
|
|
|
$submenuCallable = $this->createConfiguration($template, $bladeFile); |
|
|
|
$builder |
|
|
|
->addSubMenu($template['name'], $submenuCallable); |
|
|
@ -250,21 +215,18 @@ class NginxVhostsCommand extends Command |
|
|
|
$submenuSelectTemplate = $this->selectTemplate(); |
|
|
|
|
|
|
|
// create menu
|
|
|
|
$mainmenu = $this->menu('Nginx') |
|
|
|
$builder = $this->menu('Nginx') |
|
|
|
|
|
|
|
// add Submenu for select templates
|
|
|
|
->addLineBreak('-') |
|
|
|
->addSubMenu('Add', $submenuSelectTemplate); |
|
|
|
|
|
|
|
$mainmenu->addLineBreak('-'); |
|
|
|
$builder->addLineBreak('-'); |
|
|
|
|
|
|
|
// apperance
|
|
|
|
$mainmenu->setWidth($mainmenu->getTerminal()->getWidth()); |
|
|
|
$mainmenu->setBorderLeftWidth(4); |
|
|
|
$mainmenu->setBorderColour('magenta'); |
|
|
|
$mainmenu->setMargin(2); |
|
|
|
$builder = StylesFactory::setMenuStyles($builder); |
|
|
|
|
|
|
|
$mainmenu = $mainmenu->build(); |
|
|
|
$mainmenu = $builder->build(); |
|
|
|
|
|
|
|
// remove first item
|
|
|
|
$items = $mainmenu->getItems(); |
|
|
|