From 19519392c9e43c4b0fabafe91037d6467a39c4a8 Mon Sep 17 00:00:00 2001 From: Maxime Huran Date: Wed, 16 Aug 2023 17:15:08 +0200 Subject: [PATCH] Display index prefix on reindex console --- src/Index/Indexer.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/Index/Indexer.php b/src/Index/Indexer.php index aa1f296..ed74094 100644 --- a/src/Index/Indexer.php +++ b/src/Index/Indexer.php @@ -19,6 +19,7 @@ use Jane\Component\AutoMapper\AutoMapperInterface; use JoliCode\Elastically\Indexer as ElasticallyIndexer; use MonsieurBiz\SyliusSearchPlugin\Model\Documentable\DocumentableInterface; +use MonsieurBiz\SyliusSearchPlugin\Model\Documentable\PrefixedDocumentableInterface; use MonsieurBiz\SyliusSearchPlugin\Search\ClientFactory; use Sylius\Component\Channel\Repository\ChannelRepositoryInterface; use Sylius\Component\Core\Model\ChannelInterface; @@ -64,7 +65,9 @@ public function indexAll(?OutputInterface $output = null): void $output = $output ?? new NullOutput(); /** @var DocumentableInterface $documentable */ foreach ($this->documentableRegistry->all() as $documentable) { - $output->writeln(sprintf('Indexing %s', $documentable->getIndexCode())); + $documentable instanceof PrefixedDocumentableInterface ? + $output->writeln(sprintf('Indexing %s (Prefix: %s)', $documentable->getIndexCode(), $documentable->getPrefix())) + : $output->writeln(sprintf('Indexing %s', $documentable->getIndexCode())); $this->indexDocumentable($output, $documentable); } } @@ -160,10 +163,16 @@ private function indexDocumentable(OutputInterface $output, DocumentableInterfac { if (null === $locale && $documentable->isTranslatable()) { foreach ($this->getLocales() as $localeCode) { - $output->writeln( - sprintf('Indexing %s for locale %s', $documentable->getIndexCode(), $localeCode), - OutputInterface::VERBOSITY_VERBOSE - ); + $documentable instanceof PrefixedDocumentableInterface ? + $output->writeln( + sprintf('Indexing %s for locale %s (Prefix: %s)', $documentable->getIndexCode(), $localeCode, $documentable->getPrefix()), + OutputInterface::VERBOSITY_VERBOSE + ) + : $output->writeln( + sprintf('Indexing %s for locale %s', $documentable->getIndexCode(), $localeCode), + OutputInterface::VERBOSITY_VERBOSE + ); + $this->indexDocumentable($output, $documentable, $localeCode); }