Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
14.29% |
1 / 7 |
|
33.33% |
1 / 3 |
CRAP | |
0.00% |
0 / 1 |
LogoutSubscriber | |
14.29% |
1 / 7 |
|
33.33% |
1 / 3 |
14.08 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getSubscribedEvents | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
onLogout | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | |
3 | namespace App\EventSubscriber; |
4 | |
5 | use Symfony\Component\EventDispatcher\EventSubscriberInterface; |
6 | use Symfony\Component\HttpFoundation\RedirectResponse; |
7 | use Symfony\Component\Security\Http\Event\LogoutEvent; |
8 | |
9 | class LogoutSubscriber implements EventSubscriberInterface |
10 | { |
11 | public function __construct() |
12 | { |
13 | } |
14 | |
15 | public static function getSubscribedEvents(): array |
16 | { |
17 | return [LogoutEvent::class => 'onLogout']; |
18 | } |
19 | |
20 | public function onLogout(LogoutEvent $event): void |
21 | { |
22 | $session = $event->getRequest()->getSession(); |
23 | if ($session->has('ssoLogoutUrl')) { |
24 | $response = new RedirectResponse($session->get('ssoLogoutUrl')); |
25 | $event->setResponse($response); |
26 | } |
27 | $session->clear(); |
28 | } |
29 | } |