File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change 13
13
14
14
use Symfony \Component \HttpFoundation \Request ;
15
15
use Symfony \Component \HttpFoundation \RequestStack ;
16
- use Symfony \Component \HttpFoundation \Session \Session ;
16
+ use Symfony \Component \HttpFoundation \Session \SessionInterface ;
17
17
use Symfony \Component \Security \Core \Authentication \Token \Storage \TokenStorageInterface ;
18
18
use Symfony \Component \Security \Core \Authentication \Token \TokenInterface ;
19
19
use Symfony \Component \Security \Core \User \UserInterface ;
@@ -112,7 +112,7 @@ public function getRequest(): ?Request
112
112
/**
113
113
* Returns the current session.
114
114
*/
115
- public function getSession (): ?Session
115
+ public function getSession (): ?SessionInterface
116
116
{
117
117
if (!isset ($ this ->requestStack )) {
118
118
throw new \RuntimeException ('The "app.session" variable is not available. ' );
@@ -171,6 +171,12 @@ public function getFlashes(string|array $types = null): array
171
171
return [];
172
172
}
173
173
174
+ // In 7.0 (when symfony/http-foundation: 6.4 is required) this can be updated to
175
+ // check if the session is an instance of FlashBagAwareSessionInterface
176
+ if (!method_exists ($ session , 'getFlashBag ' )) {
177
+ return [];
178
+ }
179
+
174
180
if (null === $ types || '' === $ types || [] === $ types ) {
175
181
return $ session ->getFlashBag ()->all ();
176
182
}
You can’t perform that action at this time.
0 commit comments