File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff 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())'
You can’t perform that action at this time.
0 commit comments