@@ -50,31 +50,38 @@ public function onKernelRequest(GetResponseEvent $event)
50
50
// register listeners for this firewall
51
51
$ listeners = $ this ->map ->getListeners ($ event ->getRequest ());
52
52
53
- $ accessListener = null ;
54
- $ authenticationListeners = array ();
55
-
56
- foreach ($ listeners [0 ] as $ listener ) {
57
- if ($ listener instanceof AccessListener) {
58
- $ accessListener = $ listener ;
59
- } else {
60
- $ authenticationListeners [] = $ listener ;
61
- }
62
- }
53
+ $ authenticationListeners = $ listeners [0 ];
54
+ $ exceptionListener = $ listeners [1 ];
55
+ $ logoutListener = isset ($ listeners [2 ]) ? $ listeners [2 ] : null ;
63
56
64
- if (null !== $ exceptionListener = $ listeners [ 1 ] ) {
57
+ if (null !== $ exceptionListener ) {
65
58
$ this ->exceptionListeners [$ event ->getRequest ()] = $ exceptionListener ;
66
59
$ exceptionListener ->register ($ this ->dispatcher );
67
60
}
68
61
69
- if (null !== $ logoutListener = isset ($ listeners [2 ]) ? $ listeners [2 ] : null ) {
70
- $ authenticationListeners [] = $ logoutListener ;
71
- }
62
+ $ authenticationListeners = function () use ($ authenticationListeners , $ logoutListener ) {
63
+ $ accessListener = null ;
72
64
73
- if (null !== $ accessListener ) {
74
- $ authenticationListeners [] = $ accessListener ;
75
- }
65
+ foreach ($ authenticationListeners as $ listener ) {
66
+ if ($ listener instanceof AccessListener) {
67
+ $ accessListener = $ listener ;
68
+
69
+ continue ;
70
+ }
71
+
72
+ yield $ listener ;
73
+ }
74
+
75
+ if (null !== $ logoutListener ) {
76
+ yield $ logoutListener ;
77
+ }
78
+
79
+ if (null !== $ accessListener ) {
80
+ yield $ accessListener ;
81
+ }
82
+ };
76
83
77
- $ this ->handleRequest ($ event , $ authenticationListeners );
84
+ $ this ->handleRequest ($ event , $ authenticationListeners() );
78
85
}
79
86
80
87
public function onKernelFinishRequest (FinishRequestEvent $ event )
0 commit comments