vendor/ibexa/elasticsearch/src/bundle/Event/Subscriber/LocationEventSubscriber.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. declare(strict_types=1);
  7. namespace Ibexa\Bundle\Elasticsearch\Event\Subscriber;
  8. use Ibexa\Contracts\Core\Repository\Events\Location\BeforeSwapLocationEvent;
  9. use Ibexa\Core\Search\Common\EventSubscriber\AbstractSearchEventSubscriber;
  10. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  11. final class LocationEventSubscriber extends AbstractSearchEventSubscriber implements EventSubscriberInterface
  12. {
  13.     public static function getSubscribedEvents(): array
  14.     {
  15.         return [
  16.             BeforeSwapLocationEvent::class => 'onBeforeSwapLocation',
  17.         ];
  18.     }
  19.     public function onBeforeSwapLocation(BeforeSwapLocationEvent $event): void
  20.     {
  21.         $location1 $event->getLocation1();
  22.         $location2 $event->getLocation2();
  23.         $this->searchHandler->deleteLocation(
  24.             $location1->id,
  25.             $location1->contentId
  26.         );
  27.         $this->searchHandler->deleteLocation(
  28.             $location2->id,
  29.             $location2->contentId
  30.         );
  31.     }
  32. }