@@ -66,7 +66,7 @@ Take the following ``access_control`` entries as an example:
66
66
# for custom matching needs, use a request matcher service
67
67
- { roles: ROLE_USER, request_matcher: App\Security\RequestMatcher\MyRequestMatcher }
68
68
69
- # require ROLE_ADMIN for 'admin' route. You can use the shortcut "route: xxx", instead of "attributes": ["_route": "xxx"].
69
+ # require ROLE_ADMIN for 'admin' route. You can use the shortcut "route: " xxx", instead of "attributes": ["_route": "xxx"]
70
70
- { attributes: {'_route': 'admin'}, roles: ROLE_ADMIN }
71
71
- { route: 'admin', roles: ROLE_ADMIN }
72
72
@@ -103,6 +103,12 @@ Take the following ``access_control`` entries as an example:
103
103
104
104
<!-- for custom matching needs, use a request matcher service -->
105
105
<rule role =" ROLE_USER" request-matcher =" App\Security\RequestMatcher\MyRequestMatcher" />
106
+
107
+ <!-- require ROLE_ADMIN for 'admin' route. You can use the shortcut route="xxx" -->
108
+ <rule role =" ROLE_ADMIN" >
109
+ <attribute key =" _route" >admin</attribute >
110
+ </rule >
111
+ <rule route =" admin" role =" ROLE_ADMIN" />
106
112
</config >
107
113
</srv : container >
108
114
@@ -154,6 +160,17 @@ Take the following ``access_control`` entries as an example:
154
160
->roles(['ROLE_USER'])
155
161
->requestMatcher('App\Security\RequestMatcher\MyRequestMatcher')
156
162
;
163
+
164
+ // require ROLE_ADMIN for 'admin' route. You can use the shortcut route('xxx') mehtod,
165
+ // instead of attributes(['_route' => 'xxx']) method
166
+ $security->accessControl()
167
+ ->roles(['ROLE_ADMIN'])
168
+ ->attributes(['_route' => 'admin'])
169
+ ;
170
+ $security->accessControl()
171
+ ->roles(['ROLE_ADMIN'])
172
+ ->route('admin')
173
+ ;
157
174
};
158
175
159
176
For each incoming request, Symfony will decide which ``access_control ``
0 commit comments