Skip to content

Commit 58f4a00

Browse files
committed
Use denyAccessUnlessGranted shortcut
1 parent 8ded86a commit 58f4a00

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

best_practices/security.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,9 +327,13 @@ via the even easier shortcut in a controller:
327327
{
328328
$post = // query for the post ...
329329
330-
if (!$this->get('security.authorization_checker')->isGranted('edit', $post)) {
331-
throw $this->createAccessDeniedException();
332-
}
330+
$this->denyAccessUnlessGranted('edit', $post);
331+
332+
// or without the shortcut:
333+
//
334+
// if (!$this->get('security.authorization_checker')->isGranted('edit', $post)) {
335+
// throw $this->createAccessDeniedException();
336+
// }
333337
}
334338
335339
Learn More

0 commit comments

Comments
 (0)