vendor/shopware/elasticsearch/Admin/Subscriber/RefreshIndexSubscriber.php line 31

  1. <?php declare(strict_types=1);
  2. namespace Shopware\Elasticsearch\Admin\Subscriber;
  3. use Shopware\Core\Framework\DataAbstractionLayer\Event\RefreshIndexEvent;
  4. use Shopware\Core\Framework\Log\Package;
  5. use Shopware\Elasticsearch\Admin\AdminIndexingBehavior;
  6. use Shopware\Elasticsearch\Admin\AdminSearchRegistry;
  7. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  8. /**
  9.  * @internal
  10.  */
  11. #[Package('system-settings')]
  12. final class RefreshIndexSubscriber implements EventSubscriberInterface
  13. {
  14.     public function __construct(private readonly AdminSearchRegistry $registry)
  15.     {
  16.     }
  17.     /**
  18.      * @return array<string, string|array{0: string, 1: int}|list<array{0: string, 1?: int}>>
  19.      */
  20.     public static function getSubscribedEvents(): array
  21.     {
  22.         return [
  23.             RefreshIndexEvent::class => 'handled',
  24.         ];
  25.     }
  26.     public function handled(RefreshIndexEvent $event): void
  27.     {
  28.         $this->registry->iterate(
  29.             new AdminIndexingBehavior(
  30.                 $event->getNoQueue(),
  31.                 $event->getSkipEntities(),
  32.                 $event->getOnlyEntities()
  33.             )
  34.         );
  35.     }
  36. }