custom/plugins/EnetMinOrderValue/src/Subscriber/FooterSubscriber.php line 40

Open in your IDE?
  1. <?php
  2. namespace EnetMinOrderValue\Subscriber;
  3. use EnetMinOrderValue\Struct\MinOrderValueSettingsStruct;
  4. use Shopware\Core\System\SystemConfig\SystemConfigService;
  5. use Shopware\Storefront\Page\Checkout\Confirm\CheckoutConfirmPageLoadedEvent;
  6. use Shopware\Storefront\Page\Checkout\Offcanvas\OffcanvasCartPageLoadedEvent;
  7. use Shopware\Storefront\Page\PageLoadedEvent;
  8. use Shopware\Storefront\Pagelet\Footer\FooterPageletLoadedEvent;
  9. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  10. class FooterSubscriber implements EventSubscriberInterface
  11. {
  12.     /** @var SystemConfigService $systemConfigService */
  13.     private $systemConfigService;
  14.     public function __construct(SystemConfigService $systemConfigService)
  15.     {
  16.         $this->systemConfigService $systemConfigService;
  17.     }
  18.     public static function getSubscribedEvents()
  19.     {
  20.         return [
  21.             FooterPageletLoadedEvent::class => 'onPageletLoaded',
  22.             OffcanvasCartPageLoadedEvent::class => 'onPageLoaded',
  23.             CheckoutConfirmPageLoadedEvent::class => 'onPageLoaded'
  24.         ];
  25.     }
  26.     public function onPageLoaded(PageLoadedEvent $event)
  27.     {
  28.         $event->getPage()->addExtension(
  29.             'enetMinOrderValueSettings',
  30.             $this->getSettings()
  31.         );
  32.     }
  33.     public function onPageletLoaded(FooterPageletLoadedEvent $event)
  34.     {
  35.         $event->getPagelet()->addExtension(
  36.             'enetMinOrderValueSettings',
  37.             $this->getSettings()
  38.         );
  39.     }
  40.     private function getSettings()
  41.     {
  42.         $settings $this->systemConfigService->get('EnetMinOrderValue.config');
  43.         return new MinOrderValueSettingsStruct($settings);
  44.     }
  45. }