custom/plugins/memoPostcodePlugin/src/Subscribers/FrontendSubscriber.php line 27

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Memo\PostcodenlPlugin\Subscribers;
  3. use Shopware\Core\System\SystemConfig\SystemConfigService;
  4. use Shopware\Storefront\Event\StorefrontRenderEvent;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. class FrontendSubscriber implements EventSubscriberInterface
  7. {
  8.     private $configService;
  9.     public function __construct(
  10.         SystemConfigService $configService
  11.     )
  12.     {
  13.         $this->configService $configService;
  14.     }
  15.     public static function getSubscribedEvents()
  16.     {
  17.         return [
  18.             StorefrontRenderEvent::class => "onStorefrontRender",
  19.         ];
  20.     }
  21.     public function onStorefrontRender(StorefrontRenderEvent $event)
  22.     {
  23.         $config $this->configService->get('memoPostcodePlugin.config') ?? [];
  24.         $config array_intersect_key($configarray_diff_key($configarray_flip(['apiKey''apiSecret'])));
  25.         $event->setParameter('postcode_config', (object)$config);
  26.     }
  27. }