diff --git a/src/Command/BaseGenerateBundleCommand.php b/src/Command/BaseGenerateBundleCommand.php index 287591f..d4ffa51 100644 --- a/src/Command/BaseGenerateBundleCommand.php +++ b/src/Command/BaseGenerateBundleCommand.php @@ -17,6 +17,8 @@ use Pimcore\Bundle\BundleGeneratorBundle\Generator\BundleGenerator; use Pimcore\Bundle\BundleGeneratorBundle\Model\Bundle; +use Symfony\Component\Console\Attribute\AsCommand; +use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; @@ -29,16 +31,18 @@ * * The following class is copied from \Sensio\Bundle\BundleGeneratorBundle\Command\GenerateBundleCommand */ +#[AsCommand( + name: 'generate:bundle', + description: 'Generates a bundle', +)] class BaseGenerateBundleCommand extends BaseGeneratorCommand { /** * @see Command */ - protected function configure() + protected function configure(): void { $this - ->setName('generate:bundle') - ->setDescription('Generates a bundle') ->setDefinition([ new InputOption('namespace', '', InputOption::VALUE_REQUIRED, 'The namespace of the bundle to create'), new InputOption('dir', '', InputOption::VALUE_REQUIRED, 'The directory where to create the bundle', 'bundles/'), @@ -77,7 +81,7 @@ protected function configure() * * @return int */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $questionHelper = $this->getQuestionHelper(); @@ -112,7 +116,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $questionHelper->writeGeneratorSummary($output, $errors); - return 0; + return Command::SUCCESS; } protected function interact(InputInterface $input, OutputInterface $output) diff --git a/src/Command/GenerateBundleCommand.php b/src/Command/GenerateBundleCommand.php index f0ab5b6..1236818 100644 --- a/src/Command/GenerateBundleCommand.php +++ b/src/Command/GenerateBundleCommand.php @@ -19,21 +19,25 @@ use Pimcore\Bundle\BundleGeneratorBundle\Generator\BundleGenerator; use Pimcore\Bundle\BundleGeneratorBundle\Model\Bundle; +use Symfony\Component\Console\Attribute\AsCommand; +use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +#[AsCommand( + name: 'pimcore:generate:bundle', + description: 'Generates a Pimcore bundle', +)] class GenerateBundleCommand extends BaseGenerateBundleCommand { /** * @inheritDoc */ - protected function configure() + protected function configure(): void { parent::configure(); $this - ->setName('pimcore:generate:bundle') - ->setDescription('Generates a Pimcore bundle') ->setHelp( <<%command.name% command helps you generates new Pimcore bundles. If you need to create a normal Symfony @@ -61,7 +65,7 @@ protected function configure() /** * @inheritDoc */ - protected function initialize(InputInterface $input, OutputInterface $output) + protected function initialize(InputInterface $input, OutputInterface $output): void { $input->setOption('format', 'annotation'); @@ -76,7 +80,7 @@ protected function initialize(InputInterface $input, OutputInterface $output) * * @return int */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $questionHelper = $this->getQuestionHelper(); @@ -106,7 +110,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $questionHelper->writeGeneratorSummary($output, $errors); - return 0; + return Command::SUCCESS; } protected function checkBundleSearchDirectory(Bundle $bundle)