Browse Source

adding #4

release/0.1
Björn 4 years ago
parent
commit
2f2996dc0f
2 changed files with 16 additions and 3 deletions
  1. +4
    -1
      app/Commands/NginxVhostsCommand.php
  2. +12
    -2
      app/Factories/NginxVhostFactory.php

+ 4
- 1
app/Commands/NginxVhostsCommand.php View File

@ -219,7 +219,10 @@ class NginxVhostsCommand extends Command
// add Submenu for select templates // add Submenu for select templates
->addSubMenu('add', $submenuSelectTemplate) ->addSubMenu('add', $submenuSelectTemplate)
->addLineBreak('-');
->addLineBreak('-')
->modifySelectableStyle(function (SelectableStyle $style) {
$style->setItemExtra('[ enabled ]');
});
$mainmenu->addLineBreak('-'); $mainmenu->addLineBreak('-');


+ 12
- 2
app/Factories/NginxVhostFactory.php View File

@ -10,8 +10,9 @@ use PhpSchool\CliMenu\MenuItem\MenuMenuItem;
class NginxVhostFactory class NginxVhostFactory
{ {
/** /**
* adding Vhosts behind index
* *
* @param [type] $mainmenu
* @param [type] $mainmenu
* @param [type] $vhosts * @param [type] $vhosts
* @param [type] $vhostIndex * @param [type] $vhostIndex
*/ */
@ -31,7 +32,7 @@ class NginxVhostFactory
} }
} }
// check for linebreak
// check for linebreak-object
foreach($items as $index => $item) { foreach($items as $index => $item) {
if ($index > $vhostIndex && get_class($item) === 'PhpSchool\CliMenu\MenuItem\LineBreakItem') { if ($index > $vhostIndex && get_class($item) === 'PhpSchool\CliMenu\MenuItem\LineBreakItem') {
$startIndex = $index; $startIndex = $index;
@ -57,6 +58,7 @@ class NginxVhostFactory
} }
/** /**
*
* *
* @param [type] $vhost * @param [type] $vhost
* @param [type] $mainmenu * @param [type] $mainmenu
@ -77,6 +79,7 @@ class NginxVhostFactory
$builder $builder
->setTitle('Nginx > '.$vhost['domain']) ->setTitle('Nginx > '.$vhost['domain'])
->setGoBackButtonText('Back') ->setGoBackButtonText('Back')
->addLineBreak('')
->addItem('edit', function(CliMenu $menu) use ($vhost) { ->addItem('edit', function(CliMenu $menu) use ($vhost) {
system('nano /etc/nginx/sites-available/'.$vhost['file'].' > `tty`'); system('nano /etc/nginx/sites-available/'.$vhost['file'].' > `tty`');
}) })
@ -101,6 +104,7 @@ class NginxVhostFactory
->addLineBreak('-'); ->addLineBreak('-');
$submenu = $builder->build(); $submenu = $builder->build();
$submenu->setParent($mainmenu); $submenu->setParent($mainmenu);
$submenu->setStyle($mainmenu->getStyle()); $submenu->setStyle($mainmenu->getStyle());
@ -110,6 +114,12 @@ class NginxVhostFactory
$builder->isMenuDisabled() $builder->isMenuDisabled()
); );
// show item extra if domain is enabled
$item->getStyle()->setItemExtra('[ enabled ]');
if ($vhost['enabled']) {
$item->showItemExtra();
}
return $item; return $item;
} }


Loading…
Cancel
Save