Skip to content
This repository has been archived by the owner on Jul 4, 2018. It is now read-only.

Commit

Permalink
moved logic to an internal method
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Aug 3, 2015
1 parent 401674e commit b510e5a
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/Silex/ControllerCollection.php
Expand Up @@ -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());
Expand All @@ -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));
}
}

Expand Down

3 comments on commit b510e5a

@aeoris
Copy link

@aeoris aeoris commented on b510e5a Jan 7, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fabpot Why is this change? On 1.2.x there used to be a way to modify the logic behind freezing routes extending the ControllerCollection (just overriding flush would do), but now seems impossible to do, as doFlush is private and won't call the parent's doFlush. Am I missing something?

@stof
Copy link
Contributor

@stof stof commented on b510e5a Jan 7, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, this was not meant to be a supported extension point. If you need an extension point, please open an issue explaining your need

@aeoris
Copy link

@aeoris aeoris commented on b510e5a Jan 7, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @stof, I will do it asap.

Please sign in to comment.