vendor/store.shopware.com/acrispromotioncs/src/Subscriber/ClearCache.php line 31

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Acris\Promotion\Subscriber;
  4. use Shopware\Core\Framework\Adapter\Cache\CacheInvalidator;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. class ClearCache implements EventSubscriberInterface
  7. {
  8.     private const PRODUCT_CACHE_TAG 'config.core.listing.hideCloseoutProductsWhenOutOfStock';
  9.     /**
  10.      * @var CacheInvalidator
  11.      */
  12.     private $cacheInvalidator;
  13.     public function __construct(CacheInvalidator $cacheInvalidator)
  14.     {
  15.         $this->cacheInvalidator $cacheInvalidator;
  16.     }
  17.     public static function getSubscribedEvents(): array
  18.     {
  19.         return [
  20.             'promotion.written' => 'clearCache',
  21.             'promotion_discount.written' => 'clearCache'
  22.         ];
  23.     }
  24.     public function clearCache()
  25.     {
  26.         $this->cacheInvalidator->invalidate([self::PRODUCT_CACHE_TAG]);
  27.     }
  28. }