I render my header.twig from the base.twig file via the render function. So in my base.twig there is the following code to trigger header controller:
{{ render(controller('MyBundle:Global:header')) }}
That controller renders the header.twig. In this twig file there the the following code link for changing the language:
<a href="{{ path(app.request.get('_route'), app.request.get('_route_params')|merge({'_locale' : app.request.locale })) }}"><img src="{{ asset('flags/'~app.request.locale~'.png', 'img') }}" /></a>
The objects form app.request.get('_route') and app.request.get('_route_params') both return null.
app.request.get('_route')
If I run the same code link directly in the base.twig the request returns the correct objects. Looks like because the header.twig has it own controller the request are not working. Is it possible to request the route and parametsr of the active url in a other way?
app.request.get('_route_params', {})so that if there are no_route_paramsit will default to an emty object. - qooplmao