vendor/lnb/shopware6-lnb-rule-condition/src/Subscriber/SalesChannelContextCreatedSubscriber.php line 28

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Lnb\Shopware6\LnbRuleCondition\Subscriber;
  4. use Lnb\Shopware6\LnbRuleCondition\Context\RequestScope;
  5. use Shopware\Core\System\SalesChannel\Event\SalesChannelContextCreatedEvent;
  6. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  7. use Symfony\Component\HttpFoundation\RequestStack;
  8. class SalesChannelContextCreatedSubscriber implements EventSubscriberInterface
  9. {
  10.     private RequestStack $requestStack;
  11.     public function __construct(RequestStack $requestStack)
  12.     {
  13.         $this->requestStack $requestStack;
  14.     }
  15.     public static function getSubscribedEvents(): array
  16.     {
  17.         return [
  18.             SalesChannelContextCreatedEvent::class => 'onSalesChannelContextCreated',
  19.         ];
  20.     }
  21.     public function onSalesChannelContextCreated(SalesChannelContextCreatedEvent $event): void
  22.     {
  23.         $event->getContext()->addExtension('lnbRequestScope', new RequestScope($this->requestStack));
  24.     }
  25. }