Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get route controllers/action within rendered subcomponent in symfony3

Tags:

symfony

In my base.html.twig I render a component:

{% block header %}
    {{ render(controller("AppBundle:Application\\Header:header")) }}
{% endblock %}

Is there a way to get the current route action/controller? i.e. the current url in the browser?

When I do var_dump($request->get('_route'));die; it results in null

like image 498
strangeQuirks Avatar asked Mar 10 '23 20:03

strangeQuirks


1 Answers

If you want get the actual route, in your controller you can get the master request like this:

$this->container->get('request_stack')->getMasterRequest()->get('_route');
like image 168
panche14 Avatar answered May 26 '23 06:05

panche14