custom/plugins/CkoShopware6/src/Subscriber/CheckoutSettingsGenericPageSubscriber.php line 27

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Cko\Shopware6\Subscriber;
  3. use Cko\Shopware6\Factory\SettingsFactory;
  4. use Shopware\Storefront\Page\GenericPageLoadedEvent;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. class CheckoutSettingsGenericPageSubscriber implements EventSubscriberInterface
  7. {
  8.     public const GENERIC_PAGE_EXTENSION 'checkoutCom';
  9.     private SettingsFactory $settingFactory;
  10.     public function __construct(SettingsFactory $settingFactory)
  11.     {
  12.         $this->settingFactory $settingFactory;
  13.     }
  14.     public static function getSubscribedEvents(): array
  15.     {
  16.         return [
  17.             GenericPageLoadedEvent::class => 'onGenericPageLoaded',
  18.         ];
  19.     }
  20.     public function onGenericPageLoaded(GenericPageLoadedEvent $event): void
  21.     {
  22.         $publicConfigStruct $this->settingFactory->getPublicConfig(
  23.             $event->getSalesChannelContext()->getSalesChannel()->getId()
  24.         );
  25.         $event->getPage()->addExtension(self::GENERIC_PAGE_EXTENSION$publicConfigStruct);
  26.     }
  27. }