vendor/shopware/storefront/Framework/Routing/CachedDomainLoaderInvalidator.php line 34

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Shopware\Storefront\Framework\Routing;
  3. use Shopware\Core\Framework\Adapter\Cache\CacheInvalidator;
  4. use Shopware\Core\Framework\DataAbstractionLayer\Event\EntityWrittenContainerEvent;
  5. use Shopware\Core\System\SalesChannel\SalesChannelDefinition;
  6. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  7. class CachedDomainLoaderInvalidator implements EventSubscriberInterface
  8. {
  9.     private CacheInvalidator $logger;
  10.     /**
  11.      * @internal
  12.      */
  13.     public function __construct(CacheInvalidator $logger)
  14.     {
  15.         $this->logger $logger;
  16.     }
  17.     /**
  18.      * @return array<string, string|array{0: string, 1: int}|list<array{0: string, 1?: int}>>
  19.      */
  20.     public static function getSubscribedEvents()
  21.     {
  22.         return [
  23.             EntityWrittenContainerEvent::class => [
  24.                 ['invalidate'2000],
  25.             ],
  26.         ];
  27.     }
  28.     public function invalidate(EntityWrittenContainerEvent $event): void
  29.     {
  30.         if ($event->getEventByEntityName(SalesChannelDefinition::ENTITY_NAME)) {
  31.             $this->logger->invalidate([CachedDomainLoader::CACHE_KEY]);
  32.         }
  33.     }
  34. }