<?php declare(strict_types=1);
namespace Swag\EnterpriseSearch\Action;
use Shopware\Core\Framework\DataAbstractionLayer\EntityDefinition;
use Shopware\Elasticsearch\Framework\Indexing\ElasticsearchIndexer;
use Swag\EnterpriseSearch\Action\Events\ActionIndexerEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class ActionUpdater implements EventSubscriberInterface
{
/**
* @var ElasticsearchIndexer
*/
private $indexer;
/**
* @var EntityDefinition
*/
private $definition;
/**
* @internal
*/
public function __construct(ElasticsearchIndexer $indexer, EntityDefinition $definition)
{
$this->indexer = $indexer;
$this->definition = $definition;
}
/**
* @return array<string, string|array{0: string, 1: int}|list<array{0: string, 1?: int}>>
*/
public static function getSubscribedEvents()
{
return [
ActionIndexerEvent::class => 'update',
];
}
public function update(ActionIndexerEvent $event): void
{
if (method_exists($this->indexer, 'updateIds')) {
$this->indexer->updateIds($this->definition, $event->getIds());
}
}
}