From b510e5a0758b6029be89f08f37cabf4d1cef3dbf Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 3 Aug 2015 15:13:36 +0200 Subject: [PATCH] moved logic to an internal method --- src/Silex/ControllerCollection.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Silex/ControllerCollection.php b/src/Silex/ControllerCollection.php index 4582fedcf..7c57d92aa 100644 --- a/src/Silex/ControllerCollection.php +++ b/src/Silex/ControllerCollection.php @@ -186,16 +186,17 @@ public function __call($method, $arguments) * * @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 @@ public function flush($prefix = '', $routes = null) $routes->add($name, $controller->getRoute()); $controller->freeze(); } else { - $routes->addCollection($controller->flush($prefix.$controller->prefix, $routes)); + $routes->addCollection($controller->doFlush($prefix.$controller->prefix, $routes)); } }