platform/src/Storefront/Framework/Routing/CachedDomainLoaderInvalidator.php line 28

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.     public static function getSubscribedEvents()
  15.     {
  16.         return [
  17.             EntityWrittenContainerEvent::class => [
  18.                 ['invalidate'2000],
  19.             ],
  20.         ];
  21.     }
  22.     public function invalidate(EntityWrittenContainerEvent $event): void
  23.     {
  24.         if ($event->getEventByEntityName(SalesChannelDefinition::ENTITY_NAME)) {
  25.             $this->logger->invalidate([CachedDomainLoader::CACHE_KEY]);
  26.         }
  27.     }
  28. }