Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/Symfony/Bridge/Twig/AppVariable.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\User\UserInterface;
Expand Down Expand Up @@ -93,7 +93,7 @@ public function getRequest(): ?Request
/**
* Returns the current session.
*/
public function getSession(): ?Session
public function getSession(): ?SessionInterface
{
if (!isset($this->requestStack)) {
throw new \RuntimeException('The "app.session" variable is not available.');
Expand Down Expand Up @@ -143,6 +143,12 @@ public function getFlashes(string|array $types = null): array
return [];
}

// In 7.0 (when symfony/http-foundation: 6.4 is required) this can be updated to
// check if the session is an instance of FlashBagAwareSessionInterface
if (!method_exists($session, 'getFlashBag')) {
return [];
}

if (null === $types || '' === $types || [] === $types) {
return $session->getFlashBag()->all();
}
Expand Down