File tree Expand file tree Collapse file tree 2 files changed +13
-6
lines changed
Filter options
Expand file tree Collapse file tree 2 files changed +13
-6
lines changed
Original file line number Diff line number Diff line change @@ -461,7 +461,7 @@ perform a 301 (permanent) redirect, modify the second argument::
461
461
462
462
.. versionadded :: 2.6
463
463
You can also directly use
464
- :method: `Symfony\\ Bundle\\ FrameworkBundle\\ Controller::redirectToRoute` `
464
+ :method: `Symfony\\ Bundle\\ FrameworkBundle\\ Controller::redirectToRoute `
465
465
and give it directly the route name like :
466
466
467
467
return $this->redirectToRoute('homepage');
@@ -646,7 +646,7 @@ in the session and then redirects. The name (``notice``) isn't significant -
646
646
it's just something you invent and reference next.
647
647
648
648
.. 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 `
650
650
method as a shortcut to ``$this->get('session')->getFlashBag()->add(...) ``.
651
651
652
652
In the template of the next action, the following code could be used to render
Original file line number Diff line number Diff line change @@ -802,9 +802,6 @@ the ``^``) would match ``/admin/foo`` but would also match URLs like ``/foo/admi
802
802
803
803
To learn about all of this, see :doc: `/cookbook/security/access_control `.
804
804
805
- .. _`book-security-securing-controller` :
806
-
807
-
808
805
Securing other Services
809
806
~~~~~~~~~~~~~~~~~~~~~~~
810
807
@@ -813,11 +810,15 @@ the one seen in the previous section. For example, suppose you have a service
813
810
(i.e. a PHP class) whose job is to send emails from one user to another.
814
811
You can restrict use of this class - no matter where it's being used from -
815
812
to users that have a specific role.
816
- >>>>>>> Minor format improvements
813
+
814
+ .. _`book-security-securing-controller` :
817
815
818
816
Securing Controllers and other Code
819
817
...................................
820
818
819
+ Securing a Controller
820
+ ~~~~~~~~~~~~~~~~~~~~~
821
+
821
822
You can easily deny access from inside a controller::
822
823
823
824
// ...
@@ -835,6 +836,12 @@ You can easily deny access from inside a controller::
835
836
The ``security.authorization_checker `` service was introduced in Symfony 2.6. Prior
836
837
to Symfony 2.6, you had to use the ``isGranted() `` method of the ``security.context `` service.
837
838
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
+
838
845
.. versionadded :: 2.5
839
846
The ``createAccessDeniedException `` method was introduced in Symfony 2.5.
840
847
You can’t perform that action at this time.
0 commit comments