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

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.     /**
  9.      * @var SeoUrlUpdater
  10.      */
  11.     private $seoUrlUpdater;
  12.     public function __construct(SeoUrlUpdater $seoUrlUpdater)
  13.     {
  14.         $this->seoUrlUpdater $seoUrlUpdater;
  15.     }
  16.     public static function getSubscribedEvents(): array
  17.     {
  18.         return [
  19.             'sas_blog_entries.written' => 'onBlogUpdated',
  20.         ];
  21.     }
  22.     public function onBlogUpdated(EntityWrittenEvent $event): void
  23.     {
  24.         $this->seoUrlUpdater->update(BlogSeoUrlRoute::ROUTE_NAME$event->getIds());
  25.     }
  26. }