custom/plugins/SwagEnterpriseSearchPlatform/src/Action/ActionUpdater.php line 41

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Swag\EnterpriseSearch\Action;
  3. use Shopware\Core\Framework\DataAbstractionLayer\EntityDefinition;
  4. use Shopware\Elasticsearch\Framework\Indexing\ElasticsearchIndexer;
  5. use Swag\EnterpriseSearch\Action\Events\ActionIndexerEvent;
  6. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  7. class ActionUpdater implements EventSubscriberInterface
  8. {
  9.     /**
  10.      * @var ElasticsearchIndexer
  11.      */
  12.     private $indexer;
  13.     /**
  14.      * @var EntityDefinition
  15.      */
  16.     private $definition;
  17.     /**
  18.      * @internal
  19.      */
  20.     public function __construct(ElasticsearchIndexer $indexerEntityDefinition $definition)
  21.     {
  22.         $this->indexer $indexer;
  23.         $this->definition $definition;
  24.     }
  25.     /**
  26.      * @return array<string, string|array{0: string, 1: int}|list<array{0: string, 1?: int}>>
  27.      */
  28.     public static function getSubscribedEvents()
  29.     {
  30.         return [
  31.             ActionIndexerEvent::class => 'update',
  32.         ];
  33.     }
  34.     public function update(ActionIndexerEvent $event): void
  35.     {
  36.         if (method_exists($this->indexer'updateIds')) {
  37.             $this->indexer->updateIds($this->definition$event->getIds());
  38.         }
  39.     }
  40. }