vendor/store.shopware.com/netinexteasycoupon/src/Subscriber/PageSubscriber.php line 29

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace NetInventors\NetiNextEasyCoupon\Subscriber;
  4. use NetInventors\NetiNextEasyCoupon\Service\ConditionService\ConditionErrorService;
  5. use NetInventors\NetiNextEasyCoupon\Struct\ConditionErrorStruct;
  6. use Shopware\Storefront\Page\GenericPageLoadedEvent;
  7. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  8. class PageSubscriber implements EventSubscriberInterface
  9. {
  10.     private ConditionErrorService $conditionErrorService;
  11.     public function __construct(
  12.         ConditionErrorService $conditionErrorService
  13.     ) {
  14.         $this->conditionErrorService $conditionErrorService;
  15.     }
  16.     public static function getSubscribedEvents(): array
  17.     {
  18.         return [
  19.             GenericPageLoadedEvent::class => 'onGenericPageLoaded',
  20.         ];
  21.     }
  22.     public function onGenericPageLoaded(GenericPageLoadedEvent $event): void
  23.     {
  24.         $conditionErrorStruct ConditionErrorStruct::fromError($this->conditionErrorService->get());
  25.         $event->getPage()->addExtension('netiEcConditionError'$conditionErrorStruct);
  26.     }
  27. }