custom/plugins/SasBlogModule/src/Content/Blog/BlogSeoUrlListener.php line 25

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Sas\BlogModule\Content\Blog;
  3. use Shopware\Core\Content\Seo\SeoUrlUpdater;
  4. use Shopware\Core\Framework\DataAbstractionLayer\Event\EntityWrittenEvent;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. class BlogSeoUrlListener implements EventSubscriberInterface
  7. {
  8.     private SeoUrlUpdater $seoUrlUpdater;
  9.     public function __construct(SeoUrlUpdater $seoUrlUpdater)
  10.     {
  11.         $this->seoUrlUpdater $seoUrlUpdater;
  12.     }
  13.     public static function getSubscribedEvents(): array
  14.     {
  15.         return [
  16.             'sas_blog_entries.written' => 'onBlogUpdated',
  17.         ];
  18.     }
  19.     public function onBlogUpdated(EntityWrittenEvent $event): void
  20.     {
  21.         $this->seoUrlUpdater->update(BlogSeoUrlRoute::ROUTE_NAME$event->getIds());
  22.     }
  23. }