custom/plugins/DmagUploadCustomImage/src/Subscriber/GetPluginConfigs.php line 28

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Dmag\DmagUploadCustomImage\Subscriber;
  3. use Shopware\Core\Framework\DataAbstractionLayer\Event\EntityLoadedEvent;
  4. use Shopware\Core\Framework\Struct\ArrayEntity;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. use Shopware\Storefront\Pagelet\Header\HeaderPageletLoadedEvent;
  7. use Shopware\Core\System\SystemConfig\SystemConfigService;
  8. class GetPluginConfigs implements EventSubscriberInterface
  9. {
  10.     private SystemConfigService $systemConfigService;
  11.     public function __construct(SystemConfigService $systemConfigService)
  12.     {
  13.         $this->systemConfigService $systemConfigService;
  14.     }
  15.     public static function getSubscribedEvents(): array
  16.     {
  17.         return [
  18.             HeaderPageletLoadedEvent::class => 'onRouteRequest'
  19.         ];
  20.     }
  21.     public function onRouteRequest(HeaderPageletLoadedEvent $event): void
  22.     {
  23.         $pluginConfig $this->systemConfigService->get('DmagUploadCustomImage.config');
  24.         $page $event->getPagelet();
  25.         if($pluginConfig != null){
  26.             $page->addExtension('pluginConfig',new ArrayEntity($pluginConfig));
  27.         }
  28.     }
  29. }