vendor/store.shopware.com/swagb2bplatform/SwagB2bPlatform/Subscriber/LoginHeaderSender.php line 28

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace SwagB2bPlatform\Subscriber;
  3. use Shopware\B2B\StoreFrontAuthentication\Framework\AuthenticationService;
  4. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  5. use Symfony\Component\HttpKernel\Event\ResponseEvent;
  6. use Symfony\Component\HttpKernel\KernelEvents;
  7. class LoginHeaderSender implements EventSubscriberInterface
  8. {
  9.     public const HEADER_NAME 'b2b-no-login';
  10.     private AuthenticationService $authenticationService;
  11.     public function __construct(AuthenticationService $authenticationService)
  12.     {
  13.         $this->authenticationService $authenticationService;
  14.     }
  15.     public static function getSubscribedEvents(): array
  16.     {
  17.         return [
  18.             KernelEvents::RESPONSE => 'addLoginHeader',
  19.         ];
  20.     }
  21.     public function addLoginHeader(ResponseEvent $event): void
  22.     {
  23.         $response $event->getResponse();
  24.         if (!$this->authenticationService->isB2b()) {
  25.             $response->headers->set(static::HEADER_NAMEtrue);
  26.         }
  27.     }
  28. }