vendor/store.shopware.com/jlauloginascustomer/src/Subscriber/BeforeLoginSubscriber.php line 23

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Jlau\LoginAsCustomer\Subscriber;
  3. use Jlau\LoginAsCustomer\Controller\LoginAsCustomer;
  4. use Shopware\Core\Checkout\Customer\Event\CustomerBeforeLoginEvent;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. use Symfony\Component\HttpFoundation\RequestStack;
  7. class BeforeLoginSubscriber implements EventSubscriberInterface
  8. {
  9.     private RequestStack $requestStack;
  10.     public function __construct(RequestStack $requestStack)
  11.     {
  12.         $this->requestStack $requestStack;
  13.     }
  14.     public static function getSubscribedEvents()
  15.     {
  16.         return [CustomerBeforeLoginEvent::class => 'removeUserIdFromSessionBeforeLogin'];
  17.     }
  18.     public function removeUserIdFromSessionBeforeLogin(CustomerBeforeLoginEvent $event)
  19.     {
  20.         $this->requestStack->getSession()->remove(LoginAsCustomer::SESSION_NAME);
  21.     }
  22. }