Skip to content

Commit 6c97e93

Browse files
committed
Merge branch '6.2' into 6.3
* 6.2: Update expressions.rst
2 parents f9e972d + de2fc32 commit 6c97e93

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

security/expressions.rst

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,16 @@ and ``#[IsGranted()]`` attribute also accept an
2626
2727
class MyController extends AbstractController
2828
{
29+
#[IsGranted(new Expression('is_granted("ROLE_ADMIN") or is_granted("ROLE_MANAGER")'))]
30+
public function show(): Response
31+
{
32+
// ...
33+
}
34+
2935
#[IsGranted(new Expression(
3036
'"ROLE_ADMIN" in role_names or (is_authenticated() and user.isSuperAdmin())'
3137
))]
32-
public function index(): Response
38+
public function edit(): Response
3339
{
3440
// ...
3541
}
@@ -46,7 +52,16 @@ and ``#[IsGranted()]`` attribute also accept an
4652
4753
class MyController extends AbstractController
4854
{
49-
public function index(): Response
55+
public function show(): Response
56+
{
57+
$this->denyAccessUnlessGranted(new Expression(
58+
'is_granted("ROLE_ADMIN") or is_granted("ROLE_MANAGER")'
59+
));
60+
61+
// ...
62+
}
63+
64+
public function edit(): Response
5065
{
5166
$this->denyAccessUnlessGranted(new Expression(
5267
'"ROLE_ADMIN" in role_names or (is_authenticated() and user.isSuperAdmin())'

0 commit comments

Comments
 (0)