File tree 2 files changed +32
-0
lines changed
Filter options
2 files changed +32
-0
lines changed
Original file line number Diff line number Diff line change @@ -174,6 +174,27 @@ Returns ``true`` if the current user has the given role.
174
174
Optionally, an object can be passed to be used by the voter. More information
175
175
can be found in :ref: `security-template `.
176
176
177
+ is_granted_for_user
178
+ ~~~~~~~~~~~~~~~~~~~
179
+
180
+ .. code-block :: twig
181
+
182
+ {{ is_granted_for_user(user, attribute, subject = null, field = null) }}
183
+
184
+ ``user ``
185
+ **type **: ``object ``
186
+ ``attribute ``
187
+ **type **: ``string ``
188
+ ``subject `` *(optional) *
189
+ **type **: ``object ``
190
+ ``field `` *(optional) *
191
+ **type **: ``string ``
192
+
193
+ Returns ``true `` if the user is authorized for the specified attribute.
194
+
195
+ Optionally, an object can be passed to be used by the voter. More information
196
+ can be found in :ref: `security-template `.
197
+
177
198
logout_path
178
199
~~~~~~~~~~~
179
200
Original file line number Diff line number Diff line change @@ -2549,6 +2549,17 @@ the built-in ``is_granted()`` helper function in any Twig template:
2549
2549
2550
2550
.. _security-isgranted :
2551
2551
2552
+ Similarly, if you want to check if a specific user has a certain role, you can use
2553
+ the built-in ``is_granted_for_user() `` helper function:
2554
+
2555
+ .. code-block :: html+twig
2556
+
2557
+ {% if is_granted_for_user(user, 'ROLE_ADMIN') %}
2558
+ <a href="...">Delete</a>
2559
+ {% endif %}
2560
+
2561
+ .. _security-isgrantedforuser :
2562
+
2552
2563
Securing other Services
2553
2564
.......................
2554
2565
You can’t perform that action at this time.
0 commit comments