Skip to content

Commit adf6f36

Browse files
committed
revert #5271 on the 2.6 branch
1 parent 3653b67 commit adf6f36

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

best_practices/security.rst

+13-9
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,6 @@ more advanced use-case, you can always do the same security check in PHP:
221221

222222
.. code-block:: php
223223
224-
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
225-
226-
// ...
227-
228224
/**
229225
* @Route("/{id}/edit", name="admin_post_edit")
230226
*/
@@ -238,7 +234,16 @@ more advanced use-case, you can always do the same security check in PHP:
238234
}
239235
240236
if (!$post->isAuthor($this->getUser())) {
241-
throw new AccessDeniedException();
237+
$this->denyAccessUnlessGranted('edit', $post);
238+
239+
// or without the shortcut:
240+
//
241+
// use Symfony\Component\Security\Core\Exception\AccessDeniedException;
242+
// ...
243+
//
244+
// if (!$this->get('security.authorization_checker')->isGranted('edit', $post)) {
245+
// throw $this->createAccessDeniedException();
246+
// }
242247
}
243248
244249
// ...
@@ -327,10 +332,6 @@ via the even easier shortcut in a controller:
327332

328333
.. code-block:: php
329334
330-
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
331-
332-
// ...
333-
334335
/**
335336
* @Route("/{id}/edit", name="admin_post_edit")
336337
*/
@@ -342,6 +343,9 @@ via the even easier shortcut in a controller:
342343
343344
// or without the shortcut:
344345
//
346+
// use Symfony\Component\Security\Core\Exception\AccessDeniedException;
347+
// ...
348+
//
345349
// if (!$this->get('security.authorization_checker')->isGranted('edit', $post)) {
346350
// throw $this->createAccessDeniedException();
347351
// }

0 commit comments

Comments
 (0)