From 401674e935811686c5f6d5366a169d76acb612bd Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 3 Aug 2015 15:02:06 +0200 Subject: [PATCH] simplified previous merge --- src/Silex/ControllerCollection.php | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/src/Silex/ControllerCollection.php b/src/Silex/ControllerCollection.php index 4ec61134a..4582fedcf 100644 --- a/src/Silex/ControllerCollection.php +++ b/src/Silex/ControllerCollection.php @@ -42,7 +42,6 @@ class ControllerCollection protected $defaultRoute; protected $defaultController; protected $prefix; - protected $routes; public function __construct(Route $defaultRoute) { @@ -52,16 +51,6 @@ public function __construct(Route $defaultRoute) }; } - /** - * 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 @@ public function shareRoutes(RouteCollection $routes) */ 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 @@ public function __call($method, $arguments) * * @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 @@ public function flush($prefix = '') $routes->add($name, $controller->getRoute()); $controller->freeze(); } else { - $routes->addCollection($controller->flush($prefix.$controller->prefix)); + $routes->addCollection($controller->flush($prefix.$controller->prefix, $routes)); } }