custom/plugins/SwagB2bPlatform/SwagB2bPlatform/Subscriber/LoginHeaderSender.php line 31

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.     const HEADER_NAME 'b2b-no-login';
  10.     /**
  11.      * @var AuthenticationService
  12.      */
  13.     private $authenticationService;
  14.     public function __construct(AuthenticationService $authenticationService)
  15.     {
  16.         $this->authenticationService $authenticationService;
  17.     }
  18.     public static function getSubscribedEvents(): array
  19.     {
  20.         return [
  21.             KernelEvents::RESPONSE => 'addLoginHeader',
  22.         ];
  23.     }
  24.     public function addLoginHeader(ResponseEvent $event): void
  25.     {
  26.         $response $event->getResponse();
  27.         if (!$this->authenticationService->isB2b()) {
  28.             $response->headers->set(static::HEADER_NAMEtrue);
  29.         }
  30.     }
  31. }