custom/plugins/NenoCategoryH1/src/Subscriber/SystemConfigChangedSubscriber.php line 33

Open in your IDE?
  1. <?php
  2. namespace Neno\CategoryH1\Subscriber;
  3. use Shopware\Core\Framework\Adapter\Cache\CacheClearer;
  4. use Shopware\Core\System\SystemConfig\Event\SystemConfigChangedEvent;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. class SystemConfigChangedSubscriber implements EventSubscriberInterface {
  7.     private CacheClearer $cacheClearer;
  8.     public function __construct
  9.     (
  10.         CacheClearer $cacheClearer
  11.     ) {
  12.         $this->cacheClearer $cacheClearer;
  13.     }
  14.     static string $PLUGIN_NAME 'NenoCategoryH1';
  15.     public static function getSubscribedEvents(): array
  16.     {
  17.         return [
  18.             SystemConfigChangedEvent::class => 'onConfigChanged'
  19.         ];
  20.     }
  21.     private function shouldHandle(string $key): bool {
  22.         return self::$PLUGIN_NAME '.config.zzzNenoCacheClear' === $key;
  23.     }
  24.     public function onConfigChanged(SystemConfigChangedEvent $event):void {
  25.         if ($this->shouldHandle($event->getKey())) {
  26.             $this->cacheClearer->clear();
  27.         }
  28.     }
  29. }