Symfony2 – Get action name from twig templates

This is the easyest way that I have found to get the action name from a twig template:

 
{{ app.request.attributes.get('_template').get('name') }}

…and the controller object:

 
{{ app.request.attributes.get('_template').get('controller') }}

Category: snippet, Symfony2, twig Comment »


Leave a Reply



Back to top