Skip to content

Instantly share code, notes, and snippets.

@vudaltsov
Last active December 22, 2023 11:10
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vudaltsov/22c9498e891669d36bbbd366cc3705ef to your computer and use it in GitHub Desktop.
Save vudaltsov/22c9498e891669d36bbbd366cc3705ef to your computer and use it in GitHub Desktop.
<?php
declare(strict_types=1);
namespace App\Console;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
abstract class ConsoleCommand extends Command
{
public function __construct()
{
parent::__construct();
}
abstract public static function name(): string;
final public static function getDefaultName(): string
{
return 'app:'.static::name();
}
final public function execute(InputInterface $input, OutputInterface $output): int
{
return $this->doExecute($input, new SymfonyStyle($input, $output));
}
abstract protected function doExecute(InputInterface $input, SymfonyStyle $io): int;
final protected function interact(InputInterface $input, OutputInterface $output): void
{
$this->doInteract($input, new SymfonyStyle($input, $output));
}
protected function doInteract(InputInterface $input, SymfonyStyle $io): void
{
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment