Sindbad~EG File Manager

Current Path : /proc/self/root/proc/self/root/opt/nginxhttpd_/src/Command/
Upload File :
Current File : //proc/self/root/proc/self/root/opt/nginxhttpd_/src/Command/ParseHttpd.php

<?php
/**
 * Created by PhpStorm.
 * User: user
 * Date: 15/01/20
 * Time: 15:49
 */

namespace App\Command;


use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Command\LockableTrait;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

#[AsCommand(
    name: 'parse:httpd',
    description: 'Parse the httpd.conf and display what is returned',
    hidden: false
)]
class ParseHttpd extends BaseCommand
{
    use LockableTrait;

    protected function configure(){
        $this
            ->setHelp("This command will generate the all the Nginx Vhosts")
            ->addArgument('outputFormat', InputArgument::OPTIONAL, "Output format desired (json, dump)", "dump");
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        if (!$this->lock()) {
            $output->writeln('The command is already running in another process.');
            return 0;
        }
        // Parse the httpd.conf
        if (!$this->apacheHttpdParser->parse($this->apacheHttpdConf)) {
            $this->writeErrorAndDie($output, "Error while parsing the httpd.conf", BaseCommand::RETURN_PARSE_ERR);
        }

        $data = $this->apacheHttpdParser->getData();
        if ($data === false || !is_array($data) || empty($data)) {
            $this->writeErrorAndDie($output, "Error while parsing the httpd.conf, unexpected return", BaseCommand::RETURN_PARSE_ERR);
        }

        if($input->getArgument('outputFormat') === 'dump'){
            dump($data);
        } else {
            echo json_encode($data);
        }

        return Command::SUCCESS;
    }
}

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists