for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace eZ\Publish\Core\Search\Common\EventSubscriber;
use eZ\Publish\Core\Event\ObjectState\ObjectStateEvents;
use eZ\Publish\Core\Event\ObjectState\SetContentStateEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class ObjectStateEventSubscriber extends AbstractSearchEventSubscriber implements EventSubscriberInterface
{
public static function getSubscribedEvents(): array
return [
ObjectStateEvents::SET_CONTENT_STATE => 'onSetContentState',
];
}
public function onSetContentState(SetContentStateEvent $event)
$contentInfo = $this->persistenceHandler->contentHandler()->loadContentInfo($event->getContentInfo()->id);
$this->searchHandler->indexContent(
$this->persistenceHandler->contentHandler()->load(
$contentInfo->id,
$contentInfo->currentVersionNo
)
);
$locations = $this->persistenceHandler->locationHandler()->loadLocationsByContent($contentInfo->id);
foreach ($locations as $location) {
$this->searchHandler->indexLocation($location);