<?php
							 | 
						|
								
							 | 
						|
								namespace App\Commands;
							 | 
						|
								
							 | 
						|
								use Illuminate\Console\Scheduling\Schedule;
							 | 
						|
								use LaravelZero\Framework\Commands\Command;
							 | 
						|
								use Illuminate\Support\Facades\File;
							 | 
						|
								
							 | 
						|
								use App\Facades\Install;
							 | 
						|
								use App\Facades\NginxVhost;
							 | 
						|
								use App\Facades\NginxVhostFactory;
							 | 
						|
								use App\Facades\Menus\StylesFactory;
							 | 
						|
								
							 | 
						|
								use App\Helpers\NginxTemplateHelper;
							 | 
						|
								use App\Menus\Nginx\TemplateMenuFactory;
							 | 
						|
								
							 | 
						|
								/**
							 | 
						|
								 *  Add and Edit Configurations of Vhosts from Nginx
							 | 
						|
								 *
							 | 
						|
								 *  Using php-school/cli-menu
							 | 
						|
								 *
							 | 
						|
								 *  @author Björn Hase, Tentakelfabrik
							 | 
						|
								 *  @license http://opensource.org/licenses/MIT The MIT License
							 | 
						|
								 *  @link https://gitea.tentakelfabrik.de/Tentakelfabrik/mcp
							 | 
						|
								 *
							 | 
						|
								 */
							 | 
						|
								class NginxVhostsCommand extends Command
							 | 
						|
								{
							 | 
						|
								    // index for vhosts
							 | 
						|
								    // @TODO move this in a global class
							 | 
						|
								    const VHOST_INDEX = 0;
							 | 
						|
								
							 | 
						|
								    /**
							 | 
						|
								     * The signature of the command.
							 | 
						|
								     *
							 | 
						|
								     * @var string
							 | 
						|
								     */
							 | 
						|
								    protected $signature = 'nginx:vhosts';
							 | 
						|
								
							 | 
						|
								    /**
							 | 
						|
								     * The description of the command.
							 | 
						|
								     *
							 | 
						|
								     * @var string
							 | 
						|
								     */
							 | 
						|
								    protected $description = 'Create and Manage Nginx Vhosts';
							 | 
						|
								
							 | 
						|
								    /**
							 | 
						|
								     *  let it rain
							 | 
						|
								     *
							 | 
						|
								     *
							 | 
						|
								     */
							 | 
						|
								    public function handle()
							 | 
						|
								    {
							 | 
						|
								        $nginxTemplateHelper = new TemplateMenuFactory();
							 | 
						|
								
							 | 
						|
								        // create menu
							 | 
						|
								        $builder = $this->menu('Nginx')
							 | 
						|
								
							 | 
						|
								            // add Submenu for select templates
							 | 
						|
								            ->addLineBreak('-')
							 | 
						|
								            ->addSubMenu('Add', $nginxTemplateHelper->addSelectTemplateItem());
							 | 
						|
								
							 | 
						|
								        $builder->addLineBreak('-');
							 | 
						|
								
							 | 
						|
								        // apperance
							 | 
						|
								        $builder = StylesFactory::setMenuStyles($builder);
							 | 
						|
								
							 | 
						|
								        $mainmenu = $builder->build();
							 | 
						|
								
							 | 
						|
								        // remove first item
							 | 
						|
								        $items = $mainmenu->getItems();
							 | 
						|
								        unset($items[0]);
							 | 
						|
								        $mainmenu->setItems($items);
							 | 
						|
								
							 | 
						|
								        // adding current vhosts
							 | 
						|
								        $mainmenu = NginxVhostFactory::addVhosts($mainmenu, NginxVhost::find(), self::VHOST_INDEX);
							 | 
						|
								        $mainmenu->open();
							 | 
						|
								    }
							 | 
						|
								}
							 |