10000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents de0fc44 + 76d0c72 commit 1a041cbCopy full SHA for 1a041cb
book/security/authorization.rst
@@ -169,3 +169,21 @@ syntax:
169
170
If you need access to the user from a template, you need to pass it
171
explicitly.
172
+
173
+Access Control in Controllers
174
+-----------------------------
175
176
+If you want to check a user role in your controller, you use the
177
+``isGranted``method of the security context:
178
179
+.. code-block:: php
180
181
+ // DefaultController.php
182
+ public function indexAction()
183
+ {
184
+ // show different content to admin users
185
+ if($this->get('security.context')->isGranted('ADMIN')) {
186
+ // Load admin content here
187
+ }
188
+ // load other regular content here
189
0 commit comments