Commit 53f39cfa authored by Fabien Potencier's avatar Fabien Potencier

fixed code as url_generator is now always available

parent 2179d540
......@@ -245,7 +245,7 @@ Core parameters
Defaults to 80.
This parameter can be used by the ``UrlGeneratorProvider``.
This parameter can be used when generating URLs.
* **request.https_port** (optional): Allows you to override the default port
for HTTPS URLs. If the current request is HTTPS, it will always use the
......@@ -253,7 +253,7 @@ Core parameters
Defaults to 443.
This parameter can be used by the ``UrlGeneratorProvider``.
This parameter can be used when generating URLs.
* **debug** (optional): Returns whether or not the application is running in
debug mode.
......
......@@ -389,9 +389,9 @@ have the value ``index``.
Named Routes
~~~~~~~~~~~~
Some providers (such as ``UrlGeneratorProvider``) can make use of named routes.
By default Silex will generate an internal route name for you but you can give
an explicit route name by calling ``bind``::
Some providers can make use of named routes. By default Silex will generate an
internal route name for you but you can give an explicit route name by calling
``bind``::
$app->get('/', function () {
// ...
......@@ -625,7 +625,7 @@ round-trip to the browser (as for a redirect), use an internal sub-request::
.. tip::
If you are using ``UrlGeneratorProvider``, you can also generate the URI::
You can also generate the URI via the built-in URL generator::
$request = Request::create($app['url_generator']->generate('hello'), 'GET');
......
......@@ -335,7 +335,7 @@ class SecurityServiceProvider implements ServiceProviderInterface, EventListener
};
$app['security.http_utils'] = function ($app) {
return new HttpUtils(isset($app['url_generator']) ? $app['url_generator'] : null, $app['request_matcher']);
return new HttpUtils($app['url_generator'], $app['request_matcher']);
};
$app['security.last_error'] = $app->protect(function (Request $request) {
......
......@@ -67,10 +67,7 @@ class TwigServiceProvider implements ServiceProviderInterface
if (class_exists('Symfony\Bridge\Twig\Extension\RoutingExtension')) {
$twig->addExtension(new HttpFoundationExtension($app['request_stack']));
if (isset($app['url_generator'])) {
$twig->addExtension(new RoutingExtension($app['url_generator']));
}
$twig->addExtension(new RoutingExtension($app['url_generator']));
if (isset($app['translator'])) {
$twig->addExtension(new TranslationExtension($app['translator']));
......
......@@ -21,16 +21,16 @@ class UrlGeneratorTraitTest extends \PHPUnit_Framework_TestCase
public function testUrl()
{
$app = new UrlGeneratorApplication();
$app['url_generator'] = $translator = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->disableOriginalConstructor()->getMock();
$translator->expects($this->once())->method('generate')->with('foo', array(), true);
$app['url_generator'] = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->disableOriginalConstructor()->getMock();
$app['url_generator']->expects($this->once())->method('generate')->with('foo', array(), true);
$app->url('foo');
}
public function testPath()
{
$app = new UrlGeneratorApplication();
$app['url_generator'] = $translator = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->disableOriginalConstructor()->getMock();
$translator->expects($this->once())->method('generate')->with('foo', array(), false);
$app['url_generator'] = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->disableOriginalConstructor()->getMock();
$app['url_generator']->expects($this->once())->method('generate')->with('foo', array(), false);
$app->path('foo');
}
}
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