diff --git a/config/services.php b/config/services.php index a024fa37..ea70c7ea 100644 --- a/config/services.php +++ b/config/services.php @@ -84,7 +84,7 @@ '$stopwatch' => service('stenope.build.stopwatch'), '$registeredTypes' => 'The known content types, defined by the extension', ]) - ->tag('console.command', ['command' => DebugCommand::getDefaultName()]) + ->tag('console.command', ['command' => 'debug:stenope:content']) // Expression Language ->set(ExpressionLanguage::class)->args([ @@ -96,7 +96,7 @@ '$builder' => service(Builder::class), '$stopwatch' => service('stenope.build.stopwatch'), ]) - ->tag('console.command', ['command' => BuildCommand::getDefaultName()]) + ->tag('console.command', ['command' => 'stenope:build']) ->set(Builder::class)->args([ '$router' => service('router'), diff --git a/src/Command/BuildCommand.php b/src/Command/BuildCommand.php index f2e30f6d..9d936bad 100644 --- a/src/Command/BuildCommand.php +++ b/src/Command/BuildCommand.php @@ -9,7 +9,6 @@ namespace Stenope\Bundle\Command; use Stenope\Bundle\Builder; -use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Helper\ProgressBar; use Symfony\Component\Console\Input\InputArgument; @@ -20,13 +19,10 @@ use Symfony\Component\Console\Terminal; use Symfony\Component\Stopwatch\Stopwatch; -#[AsCommand('stenope:build')] class BuildCommand extends Command { use StopwatchHelperTrait; - protected static $defaultName = 'stenope:build'; - private Builder $builder; private Stopwatch $stopwatch; @@ -44,6 +40,7 @@ public function __construct(Builder $builder, Stopwatch $stopwatch) protected function configure(): void { $this + ->setName('stenope:build') ->setDescription('Build static website') ->addArgument( 'buildDir', diff --git a/src/Command/DebugCommand.php b/src/Command/DebugCommand.php index dc1cb6e1..68927b35 100644 --- a/src/Command/DebugCommand.php +++ b/src/Command/DebugCommand.php @@ -14,7 +14,6 @@ use Stenope\Bundle\ExpressionLanguage\Expression; use Stenope\Bundle\TableOfContent\Headline; use Stenope\Bundle\TableOfContent\TableOfContent; -use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Helper\Dumper; use Symfony\Component\Console\Input\InputArgument; @@ -27,13 +26,10 @@ use Symfony\Component\VarDumper\Cloner\Stub; use Symfony\Component\VarDumper\Cloner\VarCloner; -#[AsCommand('debug:stenope:content')] class DebugCommand extends Command { use StopwatchHelperTrait; - protected static $defaultName = 'debug:stenope:content'; - private ContentManagerInterface $manager; private Stopwatch $stopwatch; private array $registeredTypes; @@ -53,6 +49,7 @@ public function __construct(ContentManagerInterface $manager, Stopwatch $stopwat protected function configure(): void { $this + ->setName('debug:stenope:content') ->setDescription('Debug Stenope managed contents') ->addArgument('class', InputArgument::REQUIRED, 'Content FQCN') ->addArgument('id', InputArgument::OPTIONAL, 'Content identifier') diff --git a/tests/Integration/Command/DebugCommandTest.php b/tests/Integration/Command/DebugCommandTest.php index 85f5c56d..2d8e5d4b 100644 --- a/tests/Integration/Command/DebugCommandTest.php +++ b/tests/Integration/Command/DebugCommandTest.php @@ -28,7 +28,7 @@ public function testList(string $class, string $expected, array $filters = [], a $kernel = static::createKernel(); $application = new Application($kernel); - $command = $application->find(DebugCommand::getDefaultName()); + $command = $application->find('debug:stenope:content'); $tester = new CommandTester($command); $tester->execute([ 'class' => $class, @@ -153,7 +153,7 @@ public function testShow(): void $kernel = static::createKernel(); $application = new Application($kernel); - $command = $application->find(DebugCommand::getDefaultName()); + $command = $application->find('debug:stenope:content'); $tester = new CommandTester($command); $tester->execute([ 'class' => Author::class, @@ -194,7 +194,7 @@ public function testUnavailableExpressionLanguageHint(): void $kernel = static::createKernel(); $application = new Application($kernel); - $command = $application->find(DebugCommand::getDefaultName()); + $command = $application->find('debug:stenope:content'); $tester = new CommandTester($command); try {