From f107f346df19d28d08a6e5f3fb9feda2848d748a Mon Sep 17 00:00:00 2001 From: Tomas Date: Tue, 31 May 2022 07:17:35 +0300 Subject: [PATCH] Support Symfony 6.1 --- .github/workflows/tests.yml | 2 ++ src/Command/IndexCommand.php | 4 ++-- src/Command/MeiliSearchClearCommand.php | 12 ++++++++++-- src/Command/MeiliSearchCreateCommand.php | 14 +++++++++++--- src/Command/MeiliSearchDeleteCommand.php | 12 ++++++++++-- src/Command/MeiliSearchImportCommand.php | 14 ++++++++++++-- 6 files changed, 47 insertions(+), 11 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 99cd55ad..b3cd7661 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -27,6 +27,8 @@ jobs: sf-version: '6.0.*' - php-version: '8.1' sf-version: '6.0.*' + - php-version: '8.1' + sf-version: '6.1.*' name: integration-tests (PHP ${{ matrix.php-version }}) steps: - uses: actions/checkout@v3 diff --git a/src/Command/IndexCommand.php b/src/Command/IndexCommand.php index 85bab5d7..6b6ceb9f 100644 --- a/src/Command/IndexCommand.php +++ b/src/Command/IndexCommand.php @@ -18,12 +18,12 @@ abstract class IndexCommand extends Command private string $prefix; protected SearchService $searchService; - public function __construct(SearchService $searchService, ?string $name = null) + public function __construct(SearchService $searchService) { $this->searchService = $searchService; $this->prefix = $this->searchService->getConfiguration()->get('prefix'); - parent::__construct($name); + parent::__construct(); } protected function getIndices(): Collection diff --git a/src/Command/MeiliSearchClearCommand.php b/src/Command/MeiliSearchClearCommand.php index 5e5cdd51..4f3a8be3 100644 --- a/src/Command/MeiliSearchClearCommand.php +++ b/src/Command/MeiliSearchClearCommand.php @@ -13,12 +13,20 @@ */ final class MeiliSearchClearCommand extends IndexCommand { - protected static $defaultName = 'meili:clear'; + public static function getDefaultName(): string + { + return 'meili:clear'; + } + + public static function getDefaultDescription(): string + { + return 'Clear the index documents'; + } protected function configure(): void { $this - ->setDescription('Clear the index documents') + ->setDescription(self::getDefaultDescription()) ->addOption('indices', 'i', InputOption::VALUE_OPTIONAL, 'Comma-separated list of index names'); } diff --git a/src/Command/MeiliSearchCreateCommand.php b/src/Command/MeiliSearchCreateCommand.php index 81a86edd..7023cb76 100644 --- a/src/Command/MeiliSearchCreateCommand.php +++ b/src/Command/MeiliSearchCreateCommand.php @@ -15,8 +15,6 @@ final class MeiliSearchCreateCommand extends IndexCommand { - protected static $defaultName = 'meili:create'; - private Client $searchClient; public function __construct(SearchService $searchService, Client $searchClient) @@ -26,10 +24,20 @@ public function __construct(SearchService $searchService, Client $searchClient) $this->searchClient = $searchClient; } + public static function getDefaultName(): string + { + return 'meili:create'; + } + + public static function getDefaultDescription(): string + { + return 'Create indexes'; + } + protected function configure(): void { $this - ->setDescription('Create indexes') + ->setDescription(self::getDefaultDescription()) ->addOption('indices', 'i', InputOption::VALUE_OPTIONAL, 'Comma-separated list of index names'); } diff --git a/src/Command/MeiliSearchDeleteCommand.php b/src/Command/MeiliSearchDeleteCommand.php index ebb46b43..b1a9a636 100644 --- a/src/Command/MeiliSearchDeleteCommand.php +++ b/src/Command/MeiliSearchDeleteCommand.php @@ -14,12 +14,20 @@ */ final class MeiliSearchDeleteCommand extends IndexCommand { - protected static $defaultName = 'meili:delete'; + public static function getDefaultName(): string + { + return 'meili:delete'; + } + + public static function getDefaultDescription(): string + { + return 'Delete the indexes'; + } protected function configure(): void { $this - ->setDescription('Delete the indices') + ->setDescription(self::getDefaultDescription()) ->addOption('indices', 'i', InputOption::VALUE_OPTIONAL, 'Comma-separated list of index names'); } diff --git a/src/Command/MeiliSearchImportCommand.php b/src/Command/MeiliSearchImportCommand.php index f5676a55..ab28a079 100644 --- a/src/Command/MeiliSearchImportCommand.php +++ b/src/Command/MeiliSearchImportCommand.php @@ -21,21 +21,31 @@ final class MeiliSearchImportCommand extends IndexCommand { private const DEFAULT_RESPONSE_TIMEOUT = 5000; - protected static $defaultName = 'meili:import'; protected Client $searchClient; protected ManagerRegistry $managerRegistry; public function __construct(SearchService $searchService, ManagerRegistry $managerRegistry, Client $searchClient) { parent::__construct($searchService); + $this->managerRegistry = $managerRegistry; $this->searchClient = $searchClient; } + public static function getDefaultName(): string + { + return 'meili:import'; + } + + public static function getDefaultDescription(): string + { + return 'Import given entity into search engine'; + } + protected function configure(): void { $this - ->setDescription('Import given entity into search engine') + ->setDescription(self::getDefaultDescription()) ->addOption('indices', 'i', InputOption::VALUE_OPTIONAL, 'Comma-separated list of index names') ->addOption( 'update-settings',