Commit 401674e9 authored by Fabien Potencier's avatar Fabien Potencier

simplified previous merge

parent 091240ea
......@@ -42,7 +42,6 @@ class ControllerCollection
protected $defaultRoute;
protected $defaultController;
protected $prefix;
protected $routes;
public function __construct(Route $defaultRoute)
{
......@@ -52,16 +51,6 @@ class ControllerCollection
};
}
/**
* Use existing route collection to resolve conflicting autogenerated route names among mounted routes
*
* @param RouteCollection $routes
*/
public function shareRoutes(RouteCollection $routes)
{
$this->routes = $routes;
}
/**
* Mounts controllers under the given route prefix.
*
......@@ -70,10 +59,6 @@ class ControllerCollection
*/
public function mount($prefix, ControllerCollection $controllers)
{
if (!($this->routes instanceof RouteCollection)) {
$this->routes = new RouteCollection();
}
$controllers->shareRoutes($this->routes);
$controllers->prefix = $prefix;
$this->controllers[] = $controllers;
......@@ -201,13 +186,15 @@ class ControllerCollection
*
* @return RouteCollection A RouteCollection instance
*/
public function flush($prefix = '')
public function flush($prefix = '', $routes = null)
{
if ($prefix !== '') {
$prefix = '/'.trim(trim($prefix), '/');
}
$routes = $this->routes ?: new RouteCollection();
if (null === $routes) {
$routes = new RouteCollection();
}
foreach ($this->controllers as $controller) {
if ($controller instanceof Controller) {
......@@ -222,7 +209,7 @@ class ControllerCollection
$routes->add($name, $controller->getRoute());
$controller->freeze();
} else {
$routes->addCollection($controller->flush($prefix.$controller->prefix));
$routes->addCollection($controller->flush($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