vendor/store.shopware.com/molliepayments/src/Subscriber/TestModeNotificationSubscriber.php line 42

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.         $this->settingsService $settingsService;
  35.     }
  36.     public function addTestModeInformationToPages(PageLoadedEvent $event): void
  37.     {
  38.         $settings $this->settingsService->getSettings($event->getSalesChannelContext()->getSalesChannel()->getId());
  39.         $event->getPage()->addExtension('MollieTestModePageExtension', new TestModePageExtensionStruct($settings->isTestMode()));
  40.     }
  41. }