Skip to content

Commit 3be2287

Browse files
author
Iltar van der Berg
committed
Added an example for the flashbag
1 parent b3a0744 commit 3be2287

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

controller.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,18 @@ Stored attributes remain in the session for the remainder of that user's session
376376
Every ``SessionInterface`` implementation is supported. If you have your
377377
own implementation, type-hint this in the arguments instead.
378378

379+
As a developer, you might prefer not to extend the ``Controller``. To use the
380+
flash message functionality, you can request the flash bag from the
381+
:class:`Symfony\\Component\\HttpFoundation\\Session\\Session`::
382+
383+
use Symfony\Component\HttpFoundation\Session\Session;
384+
385+
public function indexAction(Session $session)
386+
{
387+
// getFlashBag is not available in the SessionInterface and requires the Session
388+
$flashBag = $session->getFlashBag();
389+
}
390+
379391
.. index::
380392
single: Session; Flash messages
381393

0 commit comments

Comments
 (0)