Commit 322dbb5d authored by Jared Kazimir's avatar Jared Kazimir Committed by Fabien Potencier

updated route_factory service to use Pimple 2 factory method

parent fc8bbb62
...@@ -78,9 +78,9 @@ class Application extends \Pimple implements HttpKernelInterface, TerminableInte ...@@ -78,9 +78,9 @@ class Application extends \Pimple implements HttpKernelInterface, TerminableInte
}); });
$this['route_class'] = 'Silex\\Route'; $this['route_class'] = 'Silex\\Route';
$this['route_factory'] = function () use ($app) { $this['route_factory'] = $this->factory(function () use ($app) {
return new $app['route_class'](); return new $app['route_class']();
}; });
$this['exception_handler'] = function () use ($app) { $this['exception_handler'] = function () use ($app) {
return new ExceptionHandler($app['debug']); return new ExceptionHandler($app['debug']);
......
...@@ -497,6 +497,18 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase ...@@ -497,6 +497,18 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
$response = $app->handle(Request::create('/foo')); $response = $app->handle(Request::create('/foo'));
$this->assertEquals(301, $response->getStatusCode()); $this->assertEquals(301, $response->getStatusCode());
} }
public function testBeforeFilterOnMountedControllerGroupIsolatedToGroup()
{
$app = new Application();
$app->match('/', function() { return new Response('ok'); });
$mounted = $app['controllers_factory'];
$mounted->before(function() { return new Response('not ok'); });
$app->mount('/group', $mounted);
$response = $app->handle(Request::create('/'));
$this->assertEquals('ok', $response->getContent());
}
} }
class FooController class FooController
......
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