vendor/store.shopware.com/molliepayments/src/Subscriber/ApplePayDirectSubscriber.php line 49

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