-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Added shortcut methods for controllers #4109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
ccc6384
3b03455
675877d
0366a0c
8b23729
4a54c5f
cded08b
6db9c11
0758d62
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -451,6 +451,10 @@ perform a 301 (permanent) redirect, modify the second argument:: | |
|
||
return new RedirectResponse($this->generateUrl('homepage')); | ||
|
||
You can also directly use ``redirectToRoute()`` and give it directly the route name like : | ||
|
||
return $this->redirectToRoute('homepage'); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that we should replace all
|
||
.. index:: | ||
single: Controller; Forwarding | ||
|
||
|
@@ -720,6 +724,10 @@ After processing the request, the controller sets a ``notice`` flash message | |
and then redirects. The name (``notice``) isn't significant - it's just what | ||
you're using to identify the type of the message. | ||
|
||
.. tip:: | ||
|
||
You can use the ``addFlash(...)`` method as a shortcut to ``$this->get('session')->getFlashBag()->add(...)``. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here and you should split lines after the first word that crosses the 72nd character |
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same thing here - we should replace all the old code with the new |
||
In the template of the next action, the following code could be used to render | ||
the ``notice`` message: | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1124,6 +1124,11 @@ Thanks to the SensioFrameworkExtraBundle, you can also secure your controller us | |
For more information, see the | ||
:doc:`FrameworkExtraBundle documentation </bundles/SensioFrameworkExtraBundle/annotations/security>`. | ||
|
||
.. tip:: | ||
|
||
You can use directly `$this->isGranted($role)` instead of `$this->get('security.context')->isGranted($role)` to check if | ||
a role is granted and `denyAccessUnlessGranted` to throw an exception if the access is not granted (like in the example above). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And same here, let's use the shortcut methods everywhere |
||
Securing other Services | ||
~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can link directly to the API docs (instead of
redirectToRoute()
):