|
16 | 16 | use Symfony\Component\HttpKernel\Event\FinishRequestEvent; |
17 | 17 | use Symfony\Component\HttpKernel\Event\GetResponseEvent; |
18 | 18 | use Symfony\Component\HttpKernel\KernelEvents; |
| 19 | +use Symfony\Component\Security\Http\Firewall\AccessListener; |
19 | 20 |
|
20 | 21 | /** |
21 | 22 | * Firewall uses a FirewallMap to register security listeners for the given |
@@ -49,20 +50,31 @@ public function onKernelRequest(GetResponseEvent $event) |
49 | 50 | // register listeners for this firewall |
50 | 51 | $listeners = $this->map->getListeners($event->getRequest()); |
51 | 52 |
|
52 | | - $authenticationListeners = $listeners[0]; |
53 | | - $exceptionListener = $listeners[1]; |
54 | | - $logoutListener = isset($listeners[2]) ? $listeners[2] : null; |
| 53 | + $accessListener = null; |
| 54 | + $authenticationListeners = array(); |
55 | 55 |
|
56 | | - if (null !== $exceptionListener) { |
| 56 | + foreach ($listeners[0] as $listener) { |
| 57 | + if ($listener instanceof AccessListener) { |
| 58 | + $accessListener = $listener; |
| 59 | + } else { |
| 60 | + $authenticationListeners[] = $listener; |
| 61 | + } |
| 62 | + } |
| 63 | + |
| 64 | + if (null !== $exceptionListener = $listeners[1]) { |
57 | 65 | $this->exceptionListeners[$event->getRequest()] = $exceptionListener; |
58 | 66 | $exceptionListener->register($this->dispatcher); |
59 | 67 | } |
60 | 68 |
|
61 | | - $this->handleRequest($event, $authenticationListeners); |
| 69 | + if (null !== $logoutListener = isset($listeners[2]) ? $listeners[2] : null) { |
| 70 | + $authenticationListeners[] = $logoutListener; |
| 71 | + } |
62 | 72 |
|
63 | | - if (null !== $logoutListener) { |
64 | | - $logoutListener->handle($event); |
| 73 | + if (null !== $accessListener) { |
| 74 | + $authenticationListeners[] = $accessListener; |
65 | 75 | } |
| 76 | + |
| 77 | + $this->handleRequest($event, $authenticationListeners); |
66 | 78 | } |
67 | 79 |
|
68 | 80 | public function onKernelFinishRequest(FinishRequestEvent $event) |
|
0 commit comments