vendor/ibexa/core/src/lib/Search/Common/EventSubscriber/TrashEventSubscriber.php line 24

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\Trash\RecoverEvent;
  8. use Ibexa\Contracts\Core\Repository\Events\Trash\TrashEvent;
  9. use Ibexa\Contracts\Core\Repository\Values\Content\TrashItem;
  10. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  11. class TrashEventSubscriber extends AbstractSearchEventSubscriber implements EventSubscriberInterface
  12. {
  13.     public static function getSubscribedEvents(): array
  14.     {
  15.         return [
  16.             RecoverEvent::class => 'onRecover',
  17.             TrashEvent::class => 'onTrash',
  18.         ];
  19.     }
  20.     public function onRecover(RecoverEvent $event)
  21.     {
  22.         $this->indexSubtree($event->getLocation()->id);
  23.     }
  24.     public function onTrash(TrashEvent $event)
  25.     {
  26.         if ($event->getTrashItem() instanceof TrashItem) {
  27.             $this->searchHandler->deleteContent(
  28.                 $event->getLocation()->contentId
  29.             );
  30.         }
  31.         $this->searchHandler->deleteLocation(
  32.             $event->getLocation()->id,
  33.             $event->getLocation()->contentId
  34.         );
  35.     }
  36. }
  37. class_alias(TrashEventSubscriber::class, 'eZ\Publish\Core\Search\Common\EventSubscriber\TrashEventSubscriber');