Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3bcb186

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

File tree

Expand file treeCollapse file tree

1 file changed

+11
-2
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+11
-2
lines changed

‎book/controller.rst

Copy file name to clipboardExpand all lines: book/controller.rst
+11-2Lines 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.