Sindbad~EG File Manager
<?php
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;
// TODO : Groupe this command and the parse:httpd command and use an argument like --lsws or --apache to select the config to parse
#[AsCommand(
name: 'parse:lsws-httpd',
description: 'Parse the OpenLitespeed httpd configuration and display what is returned',
hidden: false
)]
class ParseLswsHttps extends BaseCommand
{
use LockableTrait;
protected function configure(): void
{
$this
->addArgument('outputFormat', InputArgument::OPTIONAL, 'Output format desired (json, dump)', 'dump');
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
if (!$this->lock()) {
$output->writeln('The command is already running in another process.');
return 0;
}
if (!$this->lswsHttpdParser->parse($this->lswsHttpdConf)) {
$this->writeErrorAndDie($output, 'Error while parsing the OpenLitespeed httpd configuration', BaseCommand::RETURN_PARSE_ERR);
}
$data = $this->lswsHttpdParser->getData();
if (!is_array($data) || empty($data)) {
$this->writeErrorAndDie($output, 'Error while parsing the OpenLitespeed httpd configuration, 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