Commit b510e5a0 authored by Fabien Potencier's avatar Fabien Potencier

moved logic to an internal method

parent 401674e9
......@@ -186,16 +186,17 @@ class ControllerCollection
*
* @return RouteCollection A RouteCollection instance
*/
public function flush($prefix = '', $routes = null)
public function flush($prefix = '')
{
return $this->doFlush($prefix, new RouteCollection());
}
private function doFlush($prefix, RouteCollection $routes)
{
if ($prefix !== '') {
$prefix = '/'.trim(trim($prefix), '/');
}
if (null === $routes) {
$routes = new RouteCollection();
}
foreach ($this->controllers as $controller) {
if ($controller instanceof Controller) {
$controller->getRoute()->setPath($prefix.$controller->getRoute()->getPath());
......@@ -209,7 +210,7 @@ class ControllerCollection
$routes->add($name, $controller->getRoute());
$controller->freeze();
} else {
$routes->addCollection($controller->flush($prefix.$controller->prefix, $routes));
$routes->addCollection($controller->doFlush($prefix.$controller->prefix, $routes));
}
}
......
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