vendor/ibexa/core/src/lib/Search/Common/EventSubscriber/ObjectStateEventSubscriber.php line 21

Open in your IDE?
  1. <?php
  2. /**
  3. * @copyright Copyright (C) Ibexa AS. All rights reserved.
  4. * @license For full copyright and license information view LICENSE file distributed with this source code.
  5. */
  6. namespace Ibexa\Core\Search\Common\EventSubscriber;
  7. use Ibexa\Contracts\Core\Repository\Events\ObjectState\SetContentStateEvent;
  8. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  9. class ObjectStateEventSubscriber extends AbstractSearchEventSubscriber implements EventSubscriberInterface
  10. {
  11. public static function getSubscribedEvents(): array
  12. {
  13. return [
  14. SetContentStateEvent::class => 'onSetContentState',
  15. ];
  16. }
  17. public function onSetContentState(SetContentStateEvent $event)
  18. {
  19. $contentInfo = $this->persistenceHandler->contentHandler()->loadContentInfo($event->getContentInfo()->id);
  20. $this->searchHandler->indexContent(
  21. $this->persistenceHandler->contentHandler()->load(
  22. $contentInfo->id,
  23. $contentInfo->currentVersionNo
  24. )
  25. );
  26. $locations = $this->persistenceHandler->locationHandler()->loadLocationsByContent($contentInfo->id);
  27. foreach ($locations as $location) {
  28. $this->searchHandler->indexLocation($location);
  29. }
  30. }
  31. }
  32. class_alias(ObjectStateEventSubscriber::class, 'eZ\Publish\Core\Search\Common\EventSubscriber\ObjectStateEventSubscriber');