Commit 48727b4d authored by Fabien Potencier's avatar Fabien Potencier

cascade route configuration for embedded route collection

parent cfb6ed09
...@@ -171,10 +171,8 @@ class ControllerCollection ...@@ -171,10 +171,8 @@ class ControllerCollection
call_user_func_array(array($this->defaultRoute, $method), $arguments); call_user_func_array(array($this->defaultRoute, $method), $arguments);
foreach ($this->controllers as $controller) { foreach ($this->controllers as $controller) {
if ($controller instanceof Controller) {
call_user_func_array(array($controller, $method), $arguments); call_user_func_array(array($controller, $method), $arguments);
} }
}
return $this; return $this;
} }
......
...@@ -176,6 +176,24 @@ class ControllerCollectionTest extends \PHPUnit_Framework_TestCase ...@@ -176,6 +176,24 @@ class ControllerCollectionTest extends \PHPUnit_Framework_TestCase
$controller = new ControllerCollection($route); $controller = new ControllerCollection($route);
$controller->bar(); $controller->bar();
} }
public function testNestedCollectionRouteCallbacks()
{
$cl1 = new ControllerCollection(new MyRoute1());
$cl2 = new ControllerCollection(new MyRoute1());
$c1 = $cl2->match('/c1', function () {});
$cl1->mount('/foo', $cl2);
$c2 = $cl2->match('/c2', function () {});
$cl1->before('before');
$c3 = $cl2->match('/c3', function () {});
$cl1->flush();
$this->assertEquals(array('before'), $c1->getRoute()->getOption('_before_middlewares'));
$this->assertEquals(array('before'), $c2->getRoute()->getOption('_before_middlewares'));
$this->assertEquals(array('before'), $c3->getRoute()->getOption('_before_middlewares'));
}
} }
class MyRoute1 extends Route class MyRoute1 extends Route
......
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