@@ -29,7 +29,10 @@ class LogoutUrlGenerator
29
29
private $ router ;
30
30
private $ tokenStorage ;
31
31
private $ listeners = [];
32
- private $ currentFirewall ;
32
+ /** @var string|null */
33
+ private $ currentFirewallName ;
34
+ /** @var string|null */
35
+ private $ currentFirewallContext ;
33
36
34
37
public function __construct (RequestStack $ requestStack = null , UrlGeneratorInterface $ router = null , TokenStorageInterface $ tokenStorage = null )
35
38
{
@@ -74,7 +77,8 @@ public function getLogoutUrl(string $key = null)
74
77
75
78
public function setCurrentFirewall (?string $ key , string $ context = null )
76
79
{
77
- $ this ->currentFirewall = [$ key , $ context ];
80
+ $ this ->currentFirewallName = $ key ;
81
+ $ this ->currentFirewallContext = $ context ;
78
82
}
79
83
80
84
/**
@@ -130,7 +134,7 @@ private function getListener(?string $key): array
130
134
if (null !== $ this ->tokenStorage ) {
131
135
$ token = $ this ->tokenStorage ->getToken ();
132
136
133
- // @deprecated since 5.4
137
+ // @deprecated since Symfony 5.4
134
138
if ($ token instanceof AnonymousToken) {
135
139
throw new \InvalidArgumentException ('Unable to generate a logout url for an anonymous token. ' );
136
140
}
@@ -151,14 +155,12 @@ private function getListener(?string $key): array
151
155
}
152
156
153
157
// Fetch from injected current firewall information, if possible
154
- [$ key , $ context ] = $ this ->currentFirewall ;
155
-
156
- if (isset ($ this ->listeners [$ key ])) {
157
- return $ this ->listeners [$ key ];
158
+ if (isset ($ this ->listeners [$ this ->currentFirewallName ])) {
159
+ return $ this ->listeners [$ this ->currentFirewallName ];
158
160
}
159
161
160
162
foreach ($ this ->listeners as $ listener ) {
161
- if (isset ($ listener [4 ]) && $ context === $ listener [4 ]) {
163
+ if (isset ($ listener [4 ]) && $ this -> currentFirewallContext === $ listener [4 ]) {
162
164
return $ listener ;
163
165
}
164
166
}
0 commit comments