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

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\Framework\Log\Package;
  6. use Shopware\Core\System\SalesChannel\SalesChannelDefinition;
  7. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  8. /**
  9. * @deprecated tag:v6.5.0 - reason:becomes-internal - EventSubscribers will become internal in v6.5.0
  10. */
  11. #[Package('storefront')]
  12. class CachedDomainLoaderInvalidator implements EventSubscriberInterface
  13. {
  14. private CacheInvalidator $logger;
  15. /**
  16. * @internal
  17. */
  18. public function __construct(CacheInvalidator $logger)
  19. {
  20. $this->logger = $logger;
  21. }
  22. /**
  23. * @return array<string, string|array{0: string, 1: int}|list<array{0: string, 1?: int}>>
  24. */
  25. public static function getSubscribedEvents()
  26. {
  27. return [
  28. EntityWrittenContainerEvent::class => [
  29. ['invalidate', 2000],
  30. ],
  31. ];
  32. }
  33. public function invalidate(EntityWrittenContainerEvent $event): void
  34. {
  35. if ($event->getEventByEntityName(SalesChannelDefinition::ENTITY_NAME)) {
  36. $this->logger->invalidate([CachedDomainLoader::CACHE_KEY]);
  37. }
  38. }
  39. }