Getting a route is not a route path in twig symfony

I am developing an application with symfony3.
I want to get the name of the route in the branch. I did this:

 {% set current_path = path(app.request.get('_route')) %}
    {{ current_path }}

displays the url of the current page. But I want to get the name of the route is not the way.

example :
personnel_index:
    path:     /liste
    defaults: { _controller: "PersonnelBundle:Personnel:index" }
    methods:  GET

must return : personnel_index

so how can i get the route name

+4
source share
1 answer

This is because you put the path function, try to do it

{% set current_path = app.request.get('_route') %}
{{ current_path }}
+11
source

Source: https://habr.com/ru/post/1668409/


All Articles