src/Core/Framework/Adapter/Cache/Script/ScriptCacheInvalidationSubscriber.php line 27

  1. <?php declare(strict_types=1);
  2. namespace Shopware\Core\Framework\Adapter\Cache\Script;
  3. use Shopware\Core\Framework\DataAbstractionLayer\Event\EntityWrittenContainerEvent;
  4. use Shopware\Core\Framework\Log\Package;
  5. use Shopware\Core\Framework\Script\Execution\ScriptExecutor;
  6. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  7. /**
  8.  * @internal
  9.  */
  10. #[Package('core')]
  11. class ScriptCacheInvalidationSubscriber implements EventSubscriberInterface
  12. {
  13.     public function __construct(private readonly ScriptExecutor $scriptExecutor)
  14.     {
  15.     }
  16.     public static function getSubscribedEvents(): array
  17.     {
  18.         return [
  19.             EntityWrittenContainerEvent::class => 'executeCacheInvalidationHook',
  20.         ];
  21.     }
  22.     public function executeCacheInvalidationHook(EntityWrittenContainerEvent $event): void
  23.     {
  24.         $this->scriptExecutor->execute(
  25.             new CacheInvalidationHook($event)
  26.         );
  27.     }
  28. }