custom/plugins/MolliePayments/src/Subscriber/TestModeNotificationSubscriber.php line 43

Open in your IDE?
  1. <?php
  2. namespace Kiener\MolliePayments\Subscriber;
  3. use Kiener\MolliePayments\Service\SettingsService;
  4. use Kiener\MolliePayments\Storefront\Struct\TestModePageExtensionStruct;
  5. use Shopware\Storefront\Page\Account\Order\AccountEditOrderPageLoadedEvent;
  6. use Shopware\Storefront\Page\Account\Overview\AccountOverviewPageLoadedEvent;
  7. use Shopware\Storefront\Page\Account\PaymentMethod\AccountPaymentMethodPageLoadedEvent;
  8. use Shopware\Storefront\Page\Checkout\Confirm\CheckoutConfirmPageLoadedEvent;
  9. use Shopware\Storefront\Page\Checkout\Finish\CheckoutFinishPageLoadedEvent;
  10. use Shopware\Storefront\Page\PageLoadedEvent;
  11. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  12. class TestModeNotificationSubscriber implements EventSubscriberInterface
  13. {
  14.     /** @var SettingsService */
  15.     private $settingsService;
  16.     public static function getSubscribedEvents()
  17.     {
  18.         return [
  19.             AccountOverviewPageLoadedEvent::class => 'addTestModeInformationToPages',
  20.             AccountPaymentMethodPageLoadedEvent::class => 'addTestModeInformationToPages',
  21.             AccountEditOrderPageLoadedEvent::class => 'addTestModeInformationToPages',
  22.             CheckoutConfirmPageLoadedEvent::class => 'addTestModeInformationToPages',
  23.             CheckoutFinishPageLoadedEvent::class => 'addTestModeInformationToPages'
  24.         ];
  25.     }
  26.     /**
  27.      * Creates a new instance of PaymentMethodSubscriber.
  28.      *
  29.      * @param SettingsService $settingsService
  30.      */
  31.     public function __construct(
  32.         SettingsService $settingsService
  33.     )
  34.     {
  35.         $this->settingsService $settingsService;
  36.     }
  37.     public function addTestModeInformationToPages(PageLoadedEvent $event): void
  38.     {
  39.         $settings $this->settingsService->getSettings($event->getSalesChannelContext()->getSalesChannel()->getId());
  40.         $event->getPage()->addExtension('MollieTestModePageExtension', new TestModePageExtensionStruct($settings->isTestMode()));
  41.     }
  42. }