From 2f2996dc0fcf0e4de72786896896c51f09332c5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn?= Date: Sun, 2 Aug 2020 23:57:21 +0200 Subject: [PATCH] adding #4 --- app/Commands/NginxVhostsCommand.php | 5 ++++- app/Factories/NginxVhostFactory.php | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/app/Commands/NginxVhostsCommand.php b/app/Commands/NginxVhostsCommand.php index 8049453..2359d8f 100644 --- a/app/Commands/NginxVhostsCommand.php +++ b/app/Commands/NginxVhostsCommand.php @@ -219,7 +219,10 @@ class NginxVhostsCommand extends Command // add Submenu for select templates ->addSubMenu('add', $submenuSelectTemplate) - ->addLineBreak('-'); + ->addLineBreak('-') + ->modifySelectableStyle(function (SelectableStyle $style) { + $style->setItemExtra('[ enabled ]'); + }); $mainmenu->addLineBreak('-'); diff --git a/app/Factories/NginxVhostFactory.php b/app/Factories/NginxVhostFactory.php index f3f86c3..0fecec4 100644 --- a/app/Factories/NginxVhostFactory.php +++ b/app/Factories/NginxVhostFactory.php @@ -10,8 +10,9 @@ use PhpSchool\CliMenu\MenuItem\MenuMenuItem; class NginxVhostFactory { /** + * adding Vhosts behind index * - * @param [type] $mainmenu + * @param [type] $mainmenu * @param [type] $vhosts * @param [type] $vhostIndex */ @@ -31,7 +32,7 @@ class NginxVhostFactory } } - // check for linebreak + // check for linebreak-object foreach($items as $index => $item) { if ($index > $vhostIndex && get_class($item) === 'PhpSchool\CliMenu\MenuItem\LineBreakItem') { $startIndex = $index; @@ -57,6 +58,7 @@ class NginxVhostFactory } /** + * * * @param [type] $vhost * @param [type] $mainmenu @@ -77,6 +79,7 @@ class NginxVhostFactory $builder ->setTitle('Nginx > '.$vhost['domain']) ->setGoBackButtonText('Back') + ->addLineBreak('') ->addItem('edit', function(CliMenu $menu) use ($vhost) { system('nano /etc/nginx/sites-available/'.$vhost['file'].' > `tty`'); }) @@ -101,6 +104,7 @@ class NginxVhostFactory ->addLineBreak('-'); $submenu = $builder->build(); + $submenu->setParent($mainmenu); $submenu->setStyle($mainmenu->getStyle()); @@ -110,6 +114,12 @@ class NginxVhostFactory $builder->isMenuDisabled() ); + // show item extra if domain is enabled + $item->getStyle()->setItemExtra('[ enabled ]'); + if ($vhost['enabled']) { + $item->showItemExtra(); + } + return $item; }