vendor/store.shopware.com/cbaxmodulmanufacturers/src/Subscriber/BackendSubscriber.php line 30

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Cbax\ModulManufacturers\Subscriber;
  3. use Shopware\Core\System\SystemConfig\Event\SystemConfigChangedEvent;
  4. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  5. use Shopware\Core\Framework\Context;
  6. use Cbax\ModulManufacturers\Components\ManufacturersHelper;
  7. class BackendSubscriber implements EventSubscriberInterface
  8. {
  9.     /**
  10.      * @var ManufacturersHelper
  11.      */
  12.     private $helperComponent;
  13.     public function __construct(ManufacturersHelper $helperComponent)
  14.     {
  15.         $this->helperComponent $helperComponent;
  16.     }
  17.     public static function getSubscribedEvents(): array
  18.     {
  19.         return [
  20.             SystemConfigChangedEvent::class => 'onSystemConfigChanged'
  21.         ];
  22.     }
  23.     //wenn Produktanzahl aus DB statt live Berechnung, runProductCount() ausführen, damit Daten immer vorhanden
  24.     public function onSystemConfigChanged(SystemConfigChangedEvent $event)
  25.     {
  26.         if ($event->getKey() === 'CbaxModulManufacturers.config.productCount' && $event->getValue() === 'notLive') {
  27.             $context Context::createDefaultContext();
  28.             $this->helperComponent->runProductCount($context);
  29.         }
  30.     }
  31. }