custom/plugins/MolliePayments/src/Subscriber/StorefrontBuildSubscriber.php line 40

Open in your IDE?
  1. <?php
  2. namespace Kiener\MolliePayments\Subscriber;
  3. use Kiener\MolliePayments\Service\SettingsService;
  4. use Shopware\Storefront\Event\StorefrontRenderEvent;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. class StorefrontBuildSubscriber implements EventSubscriberInterface
  7. {
  8.     /**
  9.      * @var SettingsService
  10.      */
  11.     private $settingsService;
  12.     /**
  13.      * @param SettingsService $settingsService
  14.      */
  15.     public function __construct(SettingsService $settingsService)
  16.     {
  17.         $this->settingsService $settingsService;
  18.     }
  19.     /**
  20.      * @inheritDoc
  21.      */
  22.     public static function getSubscribedEvents()
  23.     {
  24.         return [
  25.             StorefrontRenderEvent::class => 'onStorefrontRender',
  26.         ];
  27.     }
  28.     /**
  29.      * @param StorefrontRenderEvent $event
  30.      * @throws \Exception
  31.      * @return void
  32.      */
  33.     public function onStorefrontRender(StorefrontRenderEvent $event): void
  34.     {
  35.         $settings $this->settingsService->getSettings($event->getSalesChannelContext()->getSalesChannel()->getId());
  36.         $useJsValue = (int)$settings->isUseShopwareJavascript();
  37.         $event->setParameter('mollie_javascript_use_shopware'$useJsValue);
  38.     }
  39. }