From 6fd3f93201ec093d20b12f13f035373ac5a0bec0 Mon Sep 17 00:00:00 2001 From: Klaus Silveira Date: Fri, 17 Jan 2014 10:51:53 -0200 Subject: [PATCH] Documenting createAccessDeniedException() method Updating documentation to reflect the changes added in https://github.com/symfony/symfony/pull/9405. --- book/security.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/book/security.rst b/book/security.rst index fa9958dca1e..f9a8e97e887 100644 --- a/book/security.rst +++ b/book/security.rst @@ -1072,12 +1072,11 @@ fine-grained enough in certain cases. When necessary, you can easily force authorization from inside a controller:: // ... - use Symfony\Component\Security\Core\Exception\AccessDeniedException; public function helloAction($name) { if (false === $this->get('security.context')->isGranted('ROLE_ADMIN')) { - throw new AccessDeniedException(); + throw $this->createAccessDeniedException('Unable to access this page!'); } // ... @@ -1085,6 +1084,9 @@ authorization from inside a controller:: .. _book-security-securing-controller-annotations: +The ``createAccessDeniedException()`` method creates a special ``AccessDeniedException`` +object, which ultimately triggers a 403 HTTP response inside Symfony. + Thanks to the SensioFrameworkExtraBundle, you can also secure your controller using annotations:: // ...