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
26
26
27
27
class MyController extends AbstractController
28
28
{
29
+ #[IsGranted(new Expression('is_granted("ROLE_ADMIN") or is_granted("ROLE_MANAGER")'))]
30
+ public function show(): Response
31
+ {
32
+ // ...
33
+ }
34
+
29
35
#[IsGranted(new Expression(
30
36
'"ROLE_ADMIN" in role_names or (is_authenticated() and user.isSuperAdmin())'
31
37
))]
32
- public function index (): Response
38
+ public function edit (): Response
33
39
{
34
40
// ...
35
41
}
@@ -46,7 +52,16 @@ and ``#[IsGranted()]`` attribute also accept an
46
52
47
53
class MyController extends AbstractController
48
54
{
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
50
65
{
51
66
$this->denyAccessUnlessGranted(new Expression(
52
67
'"ROLE_ADMIN" in role_names or (is_authenticated() and user.isSuperAdmin())'
You can’t perform that action at this time.
0 commit comments