Skip to content

Commit 9d4c5f3

Browse files
committed
Prevent fatal error
1 parent b76d6b0 commit 9d4c5f3

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

ChainRouter.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,12 @@ public function generate($name, $parameters = array(), $absolute = false)
201201
{
202202
$debug = array();
203203

204+
if (is_object($name)) {
205+
$displayName = get_class($name);
206+
} else {
207+
$displayName = $name;
208+
}
209+
204210
foreach ($this->all() as $router) {
205211
// if $router does not implement ChainedRouterInterface and $name is not a string, continue
206212
if ($name && !$router instanceof ChainedRouterInterface) {
@@ -219,7 +225,7 @@ public function generate($name, $parameters = array(), $absolute = false)
219225
} catch (RouteNotFoundException $e) {
220226
$hint = ($router instanceof VersatileGeneratorInterface)
221227
? $router->getRouteDebugMessage($name, $parameters)
222-
: "Route '$name' not found";
228+
: "Route '$displayName' not found";
223229
$debug[] = $hint;
224230
if ($this->logger) {
225231
$this->logger->info('Router '.get_class($router)." was unable to generate route. Reason: '$hint': ".$e->getMessage());
@@ -231,7 +237,7 @@ public function generate($name, $parameters = array(), $absolute = false)
231237
$debug = array_unique($debug);
232238
$info = implode(', ', $debug);
233239
} else {
234-
$info = "No route '$name' found";
240+
$info = "No route '$displayName' found";
235241
}
236242

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

0 commit comments

Comments
 (0)