0

i've a problem to get role_admin or role_user in twig.

if {{ dump(app.user) }} then enter image description here

AND

if {{ dump(app.user.roles) }} then enter image description here

Then {% if is_granted('ROLE_ADMIN') %} not working So, where is the problem ?

Thanks.

Barbora
  • 921
  • 1
  • 6
  • 11
J.Lucas
  • 9
  • 2

1 Answers1

0

If you want to check if value exists (same as in_array() in PHP):

{% if 'ROLE_ADMIN' in app.user.roles %}