custom/static-plugins/NdStl/src/Service/LookSeoUrlPageSubscriber.php line 27

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Nd\Stl\Service;
  3. use Nd\Stl\Storefront\Framework\Seo\SeoUrlRoute\LookPageSeoUrlRoute;
  4. use Shopware\Core\Content\Seo\SeoUrlUpdater;
  5. use Shopware\Core\Framework\DataAbstractionLayer\Event\EntityDeletedEvent;
  6. use Shopware\Core\Framework\DataAbstractionLayer\Event\EntityWrittenEvent;
  7. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  8. class LookSeoUrlPageSubscriber implements EventSubscriberInterface
  9. {
  10.     private SeoUrlUpdater $seoUrlUpdater;
  11.     public function __construct(SeoUrlUpdater $seoUrlUpdater) {
  12.         $this->seoUrlUpdater $seoUrlUpdater;
  13.     }
  14.     public static function getSubscribedEvents(): array
  15.     {
  16.         return [
  17.             'look.written' => 'onEntityWritten',
  18.             'look.deleted' => 'onEntityDeleted'
  19.         ];
  20.     }
  21.     public function onEntityWritten(EntityWrittenEvent $event): void
  22.     {
  23.         $this->seoUrlUpdater->update(LookPageSeoUrlRoute::ROUTE_NAME$event->getIds());
  24.     }
  25.     public function onEntityDeleted(EntityDeletedEvent $event): void
  26.     {
  27.         $this->seoUrlUpdater->update(LookPageSeoUrlRoute::ROUTE_NAME$event->getIds());
  28.     }
  29. }