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

Appearance settings

Commit 46377b2

Browse filesBrowse files
committed
feature #3486 Documenting createAccessDeniedException() method (klaussilveira)
This PR was merged into the master branch. Discussion ---------- Documenting createAccessDeniedException() method Updating documentation to reflect the changes added in symfony/symfony#9405. | Q | A | ------------- | --- | Doc fix? | no | New docs? | yes (symfony/symfony#9405) | Applies to | 2.5+ | Fixed tickets | Commits ------- da6002d Wrapping line b1b9090 Adding versionadded detail 53f156c Updating references to match doc format 6fd3f93 Documenting createAccessDeniedException() method
2 parents 6058408 + da6002d commit 46377b2
Copy full SHA for 46377b2

File tree

Expand file treeCollapse file tree

1 file changed

+8
-2
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+8
-2
lines changed

‎book/security.rst

Copy file name to clipboardExpand all lines: book/security.rst
+8-2Lines 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-
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+
.. 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.