custom/static-plugins/NdFashion/src/Service/ManufacturerSeoUrlPageSubscriber.php line 27

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Nd\Fashion\Service;
  3. use Shopware\Core\Content\Seo\SeoUrlUpdater;
  4. use Shopware\Core\Framework\DataAbstractionLayer\Event\EntityDeletedEvent;
  5. use Shopware\Core\Framework\DataAbstractionLayer\Event\EntityWrittenEvent;
  6. use Nd\Fashion\Storefront\Framework\Seo\SeoUrlRoute\ManufacturerPageSeoUrlRoute;
  7. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  8. class ManufacturerSeoUrlPageSubscriber 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.             'product_manufacturer.written' => 'onEntityWritten',
  18.             'product_manufacturer.deleted' => 'onEntityDeleted'
  19.         ];
  20.     }
  21.     public function onEntityWritten(EntityWrittenEvent $event): void
  22.     {
  23.         $this->seoUrlUpdater->update(ManufacturerPageSeoUrlRoute::ROUTE_NAME$event->getIds());
  24.     }
  25.     public function onEntityDeleted(EntityDeletedEvent $event): void
  26.     {
  27.         $this->seoUrlUpdater->update(ManufacturerPageSeoUrlRoute::ROUTE_NAME$event->getIds());
  28.     }
  29. }