custom/plugins/CogiGlossary/src/Core/SeoUrlUpdateListener.php line 47

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace CogiGlossary\Core;
  3. use CogiGlossary\Glossary\GlossaryIndexerEvent;
  4. use Doctrine\DBAL\Connection;
  5. use Shopware\Core\Content\Seo\SeoUrlUpdater;
  6. use Shopware\Core\Framework\DataAbstractionLayer\Event\EntityWrittenContainerEvent;
  7. use Shopware\Core\Framework\DataAbstractionLayer\Event\EntityWrittenEvent;
  8. use Shopware\Core\Framework\DataAbstractionLayer\Indexing\EntityIndexerRegistry;
  9. use Shopware\Core\Framework\Uuid\Uuid;
  10. use Shopware\Core\System\SalesChannel\SalesChannelDefinition;
  11. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  12. use Unirest\Exception;
  13. class SeoUrlUpdateListener implements EventSubscriberInterface
  14. {
  15.     /**
  16.      * @var SeoUrlUpdater
  17.      */
  18.     private $seoUrlUpdater;
  19.     /**
  20.      * @var Connection
  21.      */
  22.     private $connection;
  23.     /**
  24.      * @var EntityIndexerRegistry
  25.      */
  26.     private $indexerRegistry;
  27.     public function __construct(SeoUrlUpdater $seoUrlUpdaterConnection $connectionEntityIndexerRegistry $indexerRegistry)
  28.     {
  29.         $this->seoUrlUpdater $seoUrlUpdater;
  30.         $this->connection $connection;
  31.         $this->indexerRegistry $indexerRegistry;
  32.     }
  33.     public static function getSubscribedEvents()
  34.     {
  35.         return [
  36.             GlossaryIndexerEvent::class => 'updateGlossaryUrls'
  37.         ];
  38.     }
  39.     public function updateGlossaryUrls(GlossaryIndexerEvent $event): void
  40.     {
  41.         $ids $event->getIds();
  42.         $this->seoUrlUpdater->update(GlossaryCharSeoUrlRoute::ROUTE_NAME$ids);
  43.         $this->seoUrlUpdater->update(GlossaryEntrySeoUrlRoute::ROUTE_NAME$ids);
  44.     }
  45. }