Skip to content

Commit 6fd3f93

Browse files
committed
Documenting createAccessDeniedException() method
Updating documentation to reflect the changes added in symfony/symfony#9405.
1 parent 6db5f23 commit 6fd3f93

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

book/security.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,19 +1072,21 @@ fine-grained enough in certain cases. When necessary, you can easily force
10721072
authorization from inside a controller::
10731073

10741074
// ...
1075-
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
10761075

10771076
public function helloAction($name)
10781077
{
10791078
if (false === $this->get('security.context')->isGranted('ROLE_ADMIN')) {
1080-
throw new AccessDeniedException();
1079+
throw $this->createAccessDeniedException('Unable to access this page!');
10811080
}
10821081

10831082
// ...
10841083
}
10851084

10861085
.. _book-security-securing-controller-annotations:
10871086

1087+
The ``createAccessDeniedException()`` method creates a special ``AccessDeniedException``
1088+
object, which ultimately triggers a 403 HTTP response inside Symfony.
1089+
10881090
Thanks to the SensioFrameworkExtraBundle, you can also secure your controller using annotations::
10891091

10901092
// ...

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy