Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions ChainRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,7 @@ public function generate($name, $parameters = array(), $absolute = false)
try {
return $router->generate($name, $parameters, $absolute);
} catch (RouteNotFoundException $e) {
$hint = ($router instanceof VersatileGeneratorInterface)
? $router->getRouteDebugMessage($name, $parameters)
: "Route '$name' not found";
$hint = $this->getErrorMessage($name, $router, $parameters);
$debug[] = $hint;
if ($this->logger) {
$this->logger->info('Router '.get_class($router)." was unable to generate route. Reason: '$hint': ".$e->getMessage());
Expand All @@ -231,12 +229,28 @@ public function generate($name, $parameters = array(), $absolute = false)
$debug = array_unique($debug);
$info = implode(', ', $debug);
} else {
$info = "No route '$name' found";
$info = $this->getErrorMessage($name);
}

throw new RouteNotFoundException(sprintf('None of the chained routers were able to generate route: %s', $info));
}

private function getErrorMessage($name, $router = null, $parameters = null)
{
if ($router instanceof VersatileGeneratorInterface) {
$displayName = $router->getRouteDebugMessage($name, $parameters);
} elseif (is_object($name)) {
$displayName = method_exists($name, '__toString')
? (string) $name
: get_class($name)
;
} else {
$displayName = (string) $name;
}

return "Route '$displayName' not found";
}

/**
* {@inheritdoc}
*/
Expand Down