2020-02-06 02:35:13 +00:00
|
|
|
<?php
|
2020-10-14 22:19:31 +00:00
|
|
|
|
2021-07-19 05:53:45 +00:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2020-02-06 02:35:13 +00:00
|
|
|
namespace App\Console\Command;
|
|
|
|
|
|
|
|
use App\Console\Application;
|
|
|
|
use Symfony\Component\Console\Input\ArrayInput;
|
|
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
|
|
|
|
|
|
abstract class CommandAbstract
|
|
|
|
{
|
2020-06-29 03:55:44 +00:00
|
|
|
protected Application $application;
|
2020-02-06 02:35:13 +00:00
|
|
|
|
|
|
|
public function __construct(Application $application)
|
|
|
|
{
|
|
|
|
$this->application = $application;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getApplication(): Application
|
|
|
|
{
|
|
|
|
return $this->application;
|
|
|
|
}
|
|
|
|
|
2021-07-19 05:53:45 +00:00
|
|
|
protected function runCommand(OutputInterface $output, string $command_name, array $command_args = []): void
|
2020-02-06 02:35:13 +00:00
|
|
|
{
|
|
|
|
$command = $this->getApplication()->find($command_name);
|
|
|
|
|
|
|
|
$input = new ArrayInput(['command' => $command_name] + $command_args);
|
|
|
|
$input->setInteractive(false);
|
|
|
|
|
|
|
|
$command->run($input, $output);
|
|
|
|
}
|
|
|
|
}
|