Commit c2421fab authored by Fabien Potencier's avatar Fabien Potencier

removed the flush call in the url generator service

parent 5f9716d8
...@@ -64,6 +64,14 @@ Moreover, if you have ``twig-bridge`` in your ``composer.json``, you will have a ...@@ -64,6 +64,14 @@ Moreover, if you have ``twig-bridge`` in your ``composer.json``, you will have a
{{ path('hello', {name: 'Fabien'}) }} {{ path('hello', {name: 'Fabien'}) }}
{{ url('hello', {name: 'Fabien'}) }} {# generates the absolute url http://example.org/hello/Fabien #} {{ url('hello', {name: 'Fabien'}) }} {# generates the absolute url http://example.org/hello/Fabien #}
.. warning::
If you try to use the ``url_generator`` service outside the handling of a
request, you must explicitly flush routes first::
$app->flush();
$url = $app['url_generator']->generate('homepage');
Traits Traits
------ ------
......
...@@ -30,8 +30,6 @@ class RoutingServiceProvider implements ServiceProviderInterface, EventListenerP ...@@ -30,8 +30,6 @@ class RoutingServiceProvider implements ServiceProviderInterface, EventListenerP
public function register(\Pimple $app) public function register(\Pimple $app)
{ {
$app['url_generator'] = $app->share(function ($app) { $app['url_generator'] = $app->share(function ($app) {
$app->flush();
return new UrlGenerator($app['routes'], $app['request_context']); return new UrlGenerator($app['routes'], $app['request_context']);
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment