custom/plugins/StripeShopwarePayment/src/Config/ShowPaymentProviderLogosInStorefrontSubscriber.php line 37

Open in your IDE?
  1. <?php
  2. /*
  3.  * Copyright (c) Pickware GmbH. All rights reserved.
  4.  * This file is part of software that is released under a proprietary license.
  5.  * You must not copy, modify, distribute, make publicly available, or execute
  6.  * its contents or parts thereof without express permission by the copyright
  7.  * holder, unless otherwise permitted by law.
  8.  */
  9. declare(strict_types=1);
  10. namespace Stripe\ShopwarePayment\Config;
  11. use Shopware\Storefront\Page\Checkout\Confirm\CheckoutConfirmPageLoadedEvent;
  12. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  13. class ShowPaymentProviderLogosInStorefrontSubscriber implements EventSubscriberInterface
  14. {
  15.     /**
  16.      * @var StripePluginConfigService
  17.      */
  18.     private $stripePluginConfigService;
  19.     public function __construct(
  20.         StripePluginConfigService $stripePluginConfigService
  21.     ) {
  22.         $this->stripePluginConfigService $stripePluginConfigService;
  23.     }
  24.     public static function getSubscribedEvents(): array
  25.     {
  26.         return [
  27.             CheckoutConfirmPageLoadedEvent::class => 'onCheckoutConfirmLoaded',
  28.         ];
  29.     }
  30.     public function onCheckoutConfirmLoaded(CheckoutConfirmPageLoadedEvent $event): void
  31.     {
  32.         $salesChannelContext $event->getSalesChannelContext();
  33.         $salesChannel $salesChannelContext->getSalesChannel();
  34.         $stripePluginConfig $this->stripePluginConfigService->getStripePluginConfigForSalesChannel(
  35.             $salesChannel->getId()
  36.         );
  37.         $showPaymentProviderLogosPageExtension = new ShowPaymentProviderLogosPageExtension();
  38.         $showPaymentProviderLogosPageExtension->assign([
  39.             'showPaymentProviderLogos' => $stripePluginConfig->shouldShowPaymentProviderLogos(),
  40.         ]);
  41.         $event->getPage()->addExtension(
  42.             ShowPaymentProviderLogosPageExtension::PAGE_EXTENSION_NAME,
  43.             $showPaymentProviderLogosPageExtension
  44.         );
  45.     }
  46. }