-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLoginSubscriber.php
More file actions
43 lines (36 loc) · 1.27 KB
/
LoginSubscriber.php
File metadata and controls
43 lines (36 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
declare(strict_types=1);
/*
* Copyright (c) Ratepay GmbH
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Ratepay\RpayPayments\Components\AdminOrders\Subscriber;
use Ratepay\RpayPayments\Components\AdminOrders\Service\SessionService;
use Shopware\Core\Checkout\Customer\Event\CustomerLogoutEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
class LoginSubscriber implements EventSubscriberInterface
{
public function __construct(
private readonly SessionService $sessionService,
private readonly RequestStack $requestStack
) {
}
public static function getSubscribedEvents(): array
{
return [
CustomerLogoutEvent::class => ['onLogout', -3000], // as late as possible to prioritize third-party modules
];
}
public function onLogout(CustomerLogoutEvent $event): void
{
$session = $this->requestStack->getMainRequest()?->getSession();
if (!$session instanceof SessionInterface) {
return;
}
$this->sessionService->destroy($session);
}
}