Skip to content

Commit 7ae62e8

Browse files
Cydonia7wouterj
authored andcommitted
Minor improvements
1 parent 4611ce9 commit 7ae62e8

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

book/controller.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ perform a 301 (permanent) redirect, modify the second argument::
461461

462462
.. versionadded:: 2.6
463463
You can also directly use
464-
:method:`Symfony\\Bundle\\FrameworkBundle\\Controller::redirectToRoute``
464+
:method:`Symfony\\Bundle\\FrameworkBundle\\Controller::redirectToRoute`
465465
and give it directly the route name like :
466466

467467
return $this->redirectToRoute('homepage');
@@ -646,7 +646,7 @@ in the session and then redirects. The name (``notice``) isn't significant -
646646
it's just something you invent and reference next.
647647

648648
.. versionadded:: 2.6
649-
You can use the :method:`Symfony\\Bundle\\FrameworkBundle\\Controller::addFlash``
649+
You can use the :method:`Symfony\\Bundle\\FrameworkBundle\\Controller::addFlash`
650650
method as a shortcut to ``$this->get('session')->getFlashBag()->add(...)``.
651651

652652
In the template of the next action, the following code could be used to render

book/security.rst

+11-4
Original file line numberDiff line numberDiff line change
@@ -802,9 +802,6 @@ the ``^``) would match ``/admin/foo`` but would also match URLs like ``/foo/admi
802802

803803
To learn about all of this, see :doc:`/cookbook/security/access_control`.
804804

805-
.. _`book-security-securing-controller`:
806-
807-
808805
Securing other Services
809806
~~~~~~~~~~~~~~~~~~~~~~~
810807

@@ -813,11 +810,15 @@ the one seen in the previous section. For example, suppose you have a service
813810
(i.e. a PHP class) whose job is to send emails from one user to another.
814811
You can restrict use of this class - no matter where it's being used from -
815812
to users that have a specific role.
816-
>>>>>>> Minor format improvements
813+
814+
.. _`book-security-securing-controller`:
817815

818816
Securing Controllers and other Code
819817
...................................
820818

819+
Securing a Controller
820+
~~~~~~~~~~~~~~~~~~~~~
821+
821822
You can easily deny access from inside a controller::
822823

823824
// ...
@@ -835,6 +836,12 @@ You can easily deny access from inside a controller::
835836
The ``security.authorization_checker`` service was introduced in Symfony 2.6. Prior
836837
to Symfony 2.6, you had to use the ``isGranted()`` method of the ``security.context`` service.
837838

839+
.. versionadded:: 2.6
840+
You can use directly :method:`Symfony\\Bundle\\FrameworkBundle\\Controller::isGranted`
841+
instead of `$this->get('security.context')->isGranted($role)` to check if
842+
a role is granted and :method:`Symfony\\Bundle\\FrameworkBundle\\Controller::denyAccessUnlessGranted`
843+
to throw an exception if the access is not granted (like in the example above).
844+
838845
.. versionadded:: 2.5
839846
The ``createAccessDeniedException`` method was introduced in Symfony 2.5.
840847

0 commit comments

Comments
 (0)