Chris Tickner
Chris Tickner

Reputation: 2017

Symfony2 security functions in Twig? How to check the user's role?

I have Symfony 2.0.9 standard edition installed with JMSSecurityBundle. Just wondering what functions are available to me in a Twig template to deal with users?

Specifically I want check to see if a user has the role ROLE_ADMIN.

Any help?

Thanks

Upvotes: 77

Views: 60042

Answers (1)

Kris Wallsmith
Kris Wallsmith

Reputation: 8965

{% if is_granted('ROLE_ADMIN') %} ... {% endif %}

Upvotes: 257

Related Questions