custom/plugins/IronHoliday/src/Subscriber/PluginSettingsSubscriber.php line 61

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace IronHoliday\Subscriber;
  3. use IronHoliday\Holiday\HolidayDataService;
  4. use Shopware\Storefront\Page\Checkout\Confirm\CheckoutConfirmPageLoadedEvent;
  5. use Shopware\Storefront\Page\Product\ProductPageLoadedEvent;
  6. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  7. /**
  8.  * Class PluginSettingsSubscriber
  9.  *
  10.  * @package IronHoliday\Subscriber
  11.  */
  12. class PluginSettingsSubscriber implements EventSubscriberInterface
  13. {
  14.     const HOLIDAY_DATA_EXTENSION_ID 'ironHolidayData';
  15.     /**
  16.      * @var HolidayDataService
  17.      */
  18.     private $holidayDataService;
  19.     /**
  20.      * PluginSettingsSubscriber constructor.
  21.      *
  22.      * @param HolidayDataService $holidayDataService
  23.      */
  24.     public function __construct(
  25.         HolidayDataService $holidayDataService
  26.     )
  27.     {
  28.         $this->holidayDataService $holidayDataService;
  29.     }
  30.     /*
  31.      * @inherit
  32.      */
  33.     public static function getSubscribedEvents(): array
  34.     {
  35.         return [
  36.             ProductPageLoadedEvent::class => 'onProductPageLoaded',
  37.             CheckoutConfirmPageLoadedEvent::class => 'onCheckoutConfirmPageLoaded',
  38.         ];
  39.     }
  40.     /**
  41.      * @param CheckoutConfirmPageLoadedEvent $event
  42.      * @throws \Exception
  43.      */
  44.     public function onCheckoutConfirmPageLoaded(CheckoutConfirmPageLoadedEvent $event)
  45.     {
  46.         $page $event->getPage();
  47.         $page->addExtensions([self::HOLIDAY_DATA_EXTENSION_ID => $this->holidayDataService->getHolidayData()]);
  48.     }
  49.     /**
  50.      * @param ProductPageLoadedEvent $event
  51.      * @throws \Exception
  52.      */
  53.     public function onProductPageLoaded(ProductPageLoadedEvent $event)
  54.     {
  55.         $page $event->getPage();
  56.         $page->addExtensions([self::HOLIDAY_DATA_EXTENSION_ID => $this->holidayDataService->getHolidayData()]);
  57.     }
  58. }