Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6fd3f93

Browse files
committed
Documenting createAccessDeniedException() method
Updating documentation to reflect the changes added insymfony/symfony#9405.
1 parent6db5f23 commit6fd3f93

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-
thrownew 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)

[8]ページ先頭

©2009-2025 Movatter.jp