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 1313
1414use Symfony \Component \HttpFoundation \Request ;
1515use Symfony \Component \HttpFoundation \RequestStack ;
16- use Symfony \Component \HttpFoundation \Session \Session ;
16+ use Symfony \Component \HttpFoundation \Session \SessionInterface ;
1717use Symfony \Component \Security \Core \Authentication \Token \Storage \TokenStorageInterface ;
1818use Symfony \Component \Security \Core \Authentication \Token \TokenInterface ;
1919use Symfony \Component \Security \Core \User \UserInterface ;
@@ -112,7 +112,7 @@ public function getRequest(): ?Request
112112 /**
113113 * Returns the current session.
114114 */
115- public function getSession (): ?Session
115+ public function getSession (): ?SessionInterface
116116 {
117117 if (!isset ($ this ->requestStack )) {
118118 throw new \RuntimeException ('The "app.session" variable is not available. ' );
@@ -171,6 +171,12 @@ public function getFlashes(string|array $types = null): array
171171 return [];
172172 }
173173
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+
174180 if (null === $ types || '' === $ types || [] === $ types ) {
175181 return $ session ->getFlashBag ()->all ();
176182 }
You can’t perform that action at this time.
0 commit comments