php - Symfony 2 - How can I get current route name using bundle JMSI18nRoutingBundle -
i using jmsi18nroutingbundle on symfony 2 project translate routes.
all works have current route name (in twig or php) language switcher.
i seek : twig :
{{ app.request.attributes.get('_route') }} {{ app.request.get('_route') }}
php :
$this->container->get('request')->get('_route') $this->container->get('request')->attributes->get('_route')
but none works... (i think it's because utilize jmsi18nroutingbundle)
can help me ?
thanks in advance. (sorry english, i'm french)
it's ok, found solution :
$actual_link = preg_replace('/\/app_dev.php/', '', $_server['request_uri']); $route = $this->get('router')->match($actual_link)['_route'];
first line : "app_dev.php" has removed if in dev mode. second line : match current url routing find current route name.
php symfony2 internationalization bundle
No comments:
Post a Comment