custom/plugins/SwagHoggi/src/Service/DynamicSeoUrlPageSubscriber.php line 30

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace SwagHoggi\Service;
  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 SwagHoggi\Storefront\Framework\Seo\SeoUrlRoute\HoggiConfiguratorPageSeoUrlRoute;
  8. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  9. class DynamicSeoUrlPageSubscriber implements EventSubscriberInterface
  10. {
  11.     private SeoUrlUpdater $seoUrlUpdater;
  12.     public function __construct(SeoUrlUpdater $seoUrlUpdater) {
  13.         $this->seoUrlUpdater $seoUrlUpdater;
  14.     }
  15.     public static function getSubscribedEvents(): array
  16.     {
  17.         return [
  18.             'hoggi_configurator.written' => 'onEntityWritten',
  19.             'swag_example.deleted' => 'onEntityDeleted'
  20.         ];
  21.     }
  22.     public function onEntityWritten(EntityWrittenEvent $event): void
  23.     {
  24.         $this->seoUrlUpdater->update(HoggiConfiguratorPageSeoUrlRoute::ROUTE_NAME$event->getIds());
  25.     }
  26.     public function onEntityDeleted(EntityDeletedEvent $event): void
  27.     {
  28.         $this->seoUrlUpdater->update(HoggiConfiguratorPageSeoUrlRoute::ROUTE_NAME$event->getIds());
  29.     }
  30. }