-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Added shortcut methods for controllers #4109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
ccc6384
3b03455
675877d
0366a0c
8b23729
4a54c5f
cded08b
6db9c11
0758d62
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -252,21 +252,23 @@ user to be logged in to access this URL: | |
Securing a Controller | ||
~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
Protecting your application based on URL patterns is easy, but may not be | ||
fine-grained enough in certain cases. When necessary, you can easily force | ||
authorization from inside a controller:: | ||
|
||
.. versionadded:: 2.6 | ||
The ``denyAccessUnlessGranted()`` method was introduced in Symfony 2.6. Previously (and | ||
still now), you could check access directly and throw the ``AccessDeniedException`` as shown | ||
in the example below). | ||
|
||
Protecting your application based on URL patterns is easy, but may not be | ||
fine-grained enough in certain cases. When necessary, you can easily force | ||
authorization from inside a controller:: | ||
|
||
// ... | ||
|
||
public function helloAction($name) | ||
{ | ||
$this->denyAccessUnlessGranted('ROLE_ADMIN', null, 'Unable to access this page!'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same thing - I'd like to show the "old" way (which would now use the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And we need a versionadded note above this: .. versionadded:: 2.6
The ``denyAccessUnlessGranted()`` method was introduced in Symfony 2.6. Previously (and
still now), you could check access directly and throw the ``AccessDeniedException`` as shown
in the example below). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we should add a brief explanation of the weird There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's right. |
||
|
||
// The second parameter is used to specify on what object the role is tested. | ||
// | ||
// Old way : | ||
// if (false === $this->get('security.authorization_checker')->isGranted( 8000 9;ROLE_ADMIN')) { | ||
// throw $this->createAccessDeniedException('Unable to access this page!'); | ||
|
@@ -322,7 +324,6 @@ to users that have a specific role. | |
array('path' => '^/admin', 'role' => 'ROLE_ADMIN'), | ||
), | ||
)); | ||
>>>>>>> master | ||
|
||
.. note:: | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would move it above the paragraph (right below the "Securing a Controller" headline).