From 4ade0f01a0c0dd4c27eea7b3587d495e50679ca9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Nadaud?= Date: Tue, 24 Jan 2023 15:40:47 +0100 Subject: [PATCH] fix(command): add attributes support --- src/Command/CreateCommand.php | 6 ++++-- src/Command/ImportCommand.php | 7 ++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Command/CreateCommand.php b/src/Command/CreateCommand.php index 5bc2b30..7886a75 100644 --- a/src/Command/CreateCommand.php +++ b/src/Command/CreateCommand.php @@ -5,13 +5,16 @@ namespace ACSEO\TypesenseBundle\Command; use ACSEO\TypesenseBundle\Manager\CollectionManager; +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: 'typesense:create', +)] class CreateCommand extends Command { - protected static $defaultName = 'typesense:create'; private $collectionManager; public function __construct(CollectionManager $collectionManager) @@ -23,7 +26,6 @@ public function __construct(CollectionManager $collectionManager) protected function configure() { $this - ->setName(self::$defaultName) ->setDescription('Create Typsenses indexes') ; diff --git a/src/Command/ImportCommand.php b/src/Command/ImportCommand.php index 539ba37..f1233df 100644 --- a/src/Command/ImportCommand.php +++ b/src/Command/ImportCommand.php @@ -8,16 +8,18 @@ use ACSEO\TypesenseBundle\Manager\DocumentManager; use ACSEO\TypesenseBundle\Transformer\DoctrineToTypesenseTransformer; use Doctrine\ORM\EntityManagerInterface; +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; use Symfony\Component\Console\Style\SymfonyStyle; +#[AsCommand( + name: 'typesense:import', +)] class ImportCommand extends Command { - protected static $defaultName = 'typesense:import'; - private $em; private $collectionManager; private $documentManager; @@ -45,7 +47,6 @@ public function __construct( protected function configure() { $this - ->setName(self::$defaultName) ->setDescription('Import collections from Database') ->addOption('action', null, InputOption::VALUE_OPTIONAL, 'Action modes for typesense import ("create", "upsert" or "update")', 'upsert') ;