custom/plugins/MolliePayments/src/Subscriber/ApplePayDirectSubscriber.php line 39

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 ApplePayDirectSubscriber 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.      */
  31.     public function onStorefrontRender(StorefrontRenderEvent $event) : void
  32.     {
  33.         $settings $this->settingsService->getSettings($event->getSalesChannelContext()->getSalesChannel()->getId());
  34.         $applePayDirectEnabled = (bool)$settings->isEnableApplePayDirect();
  35.         $event->setParameter('mollie_applepaydirect_enabled'$applePayDirectEnabled);
  36.         $event->setParameter('mollie_applepaydirect_restrictions'$settings->getRestrictApplePayDirect());
  37.     }
  38. }