Last active
December 22, 2023 11:10
-
-
Save vudaltsov/22c9498e891669d36bbbd366cc3705ef to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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