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

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.     public function __construct(CacheInvalidator $logger)
  11.     {
  12.         $this->logger $logger;
  13.     }
  14.     /**
  15.      * @return array<string, string|array{0: string, 1: int}|list<array{0: string, 1?: int}>>
  16.      */
  17.     public static function getSubscribedEvents()
  18.     {
  19.         return [
  20.             EntityWrittenContainerEvent::class => [
  21.                 ['invalidate'2000],
  22.             ],
  23.         ];
  24.     }
  25.     public function invalidate(EntityWrittenContainerEvent $event): void
  26.     {
  27.         if ($event->getEventByEntityName(SalesChannelDefinition::ENTITY_NAME)) {
  28.             $this->logger->invalidate([CachedDomainLoader::CACHE_KEY]);
  29.         }
  30.     }
  31. }