8000 Added shortcut methods for controllers · symfony/symfony-docs@3bcb186 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3bcb186

Browse files
Cydonia7wouterj
authored andcommitted
Added shortcut methods for controllers
1 parent 9caab86 commit 3bcb186

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

book/controller.rst

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,10 @@ perform a 301 (permanent) redirect, modify the second argument::
459459

460460
return new RedirectResponse($this->generateUrl('homepage'));
461461

462+
You can also directly use ``redirectToRoute()`` and give it directly the route name like :
463+
464+
return $this->redirectToRoute('homepage');
465+
462466
.. index::
463467
single: Controller; Rendering templates
464468

@@ -638,8 +642,13 @@ After processing the request, the controller sets a ``notice`` flash message
638642
in the session and then redirects. The name (``notice``) isn't significant -
639643
it's just something you invent and reference next.
640644

641-
In the template of the next page (or even better, in your base layout template),
642-
the following code will render the ``notice`` message:
645+
.. tip::
646+
647+
You can use the ``addFlash()`` method as a shortcut to
648+
``$this->get('session')->getFlashBag()->add()``.
649+
650+
In the template of the next action, the following code could be used to render
651+
the ``notice`` message:
643652

644653
.. configuration-block::
645654

0 commit comments

Comments
 (0)
0