custom/plugins/AcrisShopSwitchCS/src/Subscriber/ShopSwitchCacheSubscriber.php line 30

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Acris\ShopSwitch\Subscriber;
  3. use Shopware\Core\Framework\Adapter\Cache\CacheInvalidator;
  4. use Shopware\Core\Framework\DataAbstractionLayer\Event\EntityWrittenEvent;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. class ShopSwitchCacheSubscriber implements EventSubscriberInterface
  7. {
  8.     const SWITCH_RULE_WRITTEN_EVENT 'acris_switch_rule.written';
  9.     const HEADER_CACHE_TAG 'acris-shop-switch';
  10.     const MODAL_DATA_CACHE_TAG 'acris-shop-switch-modal-data';
  11.     private CacheInvalidator $logger;
  12.     public function __construct(CacheInvalidator $logger)
  13.     {
  14.         $this->logger $logger;
  15.     }
  16.     public static function getSubscribedEvents()
  17.     {
  18.         return [
  19.             self::SWITCH_RULE_WRITTEN_EVENT => 'onSwitchRuleWrittenEvent'
  20.         ];
  21.     }
  22.     public function onSwitchRuleWrittenEvent (EntityWrittenEvent $event): void
  23.     {
  24.         $this->logger->invalidate(
  25.             [self::HEADER_CACHE_TAGself::MODAL_DATA_CACHE_TAG]
  26.         );
  27.     }
  28. }