Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Twig: if is_granted('ROLE_MANAGER') check is not granted

Tags:

I want to check if a role is not granted. I have to display something only for USER but MANAGER is the hierarchy above.

To get that I am doing:

{% if is_granted('ROLE_MANAGER') %} {% else %}       my message  {% endif %} 

Which is not really nice. What can be the correct syntax for:

{% if is_NOT_granted('ROLE_MANAGER') %}  

ideas?

like image 259
Raphael_b Avatar asked Jul 09 '15 13:07

Raphael_b


Video Answer


2 Answers

Or again

{% if not is_granted('ROLE_MANAGER') %}     my message  {% endif %} 
like image 89
MouradK Avatar answered Sep 22 '22 08:09

MouradK


You can simply check as follow:

 {% if is_granted('ROLE_MANAGER') == false %}                   my message   {% endif %} 

Hope this help

like image 33
Matteo Avatar answered Sep 23 '22 08:09

Matteo