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

Commit46377b2

Browse files
committed
feature#3486 Documenting createAccessDeniedException() method (klaussilveira)
This PR was merged into the master branch.Discussion----------Documenting createAccessDeniedException() methodUpdating documentation to reflect the changes added insymfony/symfony#9405.| Q | A| ------------- | ---| Doc fix? | no| New docs? | yes (symfony/symfony#9405)| Applies to | 2.5+| Fixed tickets |Commits-------da6002d Wrapping lineb1b9090 Adding versionadded detail53f156c Updating references to match doc format6fd3f93 Documenting createAccessDeniedException() method
2 parents6058408 +da6002d commit46377b2

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

‎book/security.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,19 +1072,25 @@ 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+
..versionadded::2.5
1088+
The ``createAccessDeniedException`` method was introduced in Symfony 2.5.
1089+
1090+
The:method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller::createAccessDeniedException()`
1091+
method creates a special:class:`Symfony\\Component\\Security\\Core\Exception\\AccessDeniedException`
1092+
object, which ultimately triggers a 403 HTTP response inside Symfony.
1093+
10881094
Thanks to the SensioFrameworkExtraBundle, you can also secure your controller using annotations::
10891095

10901096
// ...

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp