Skip to content
This repository was archived by the owner on Sep 16, 2021. It is now read-only.

Commit 2ecdd01

Browse files
committed
[Routing] Fixing 'Creating the Route Provider' example
Within Customizing the Dynamic Router > Using a Custom Route Provider > Creating the Route Provider > getRouteByName method: ```php /** * This method is used to generate URLs, e.g. {{ path('foobar') }}. */ public function getRouteByName($name, $params = array()) { $document = $this->findOneBy(array( 'name' => $name, )); // <---- missing RouteNotFoundException if $document is null if ($route) { // <--- undefined variable $route $route = new SymfonyRoute($route->getPattern(), array( // <---- undefined variable $route 'document' => $document, )); } return $route; } ```
1 parent 0e1f9db commit 2ecdd01

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

bundles/routing/dynamic_customize.rst

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,15 @@ following class provides a simple solution using an ODM Repository.
9191
$document = $this->findOneBy(array(
9292
'name' => $name,
9393
));
94-
95-
if ($route) {
96-
$route = new SymfonyRoute($route->getPattern(), array(
97-
'document' => $document,
98-
));
94+
95+
if (!$document) {
96+
throw new RouteNotFoundException("No route found for name '$name'");
9997
}
10098
99+
$route = new SymfonyRoute($document->getUrl(), array(
100+
'document' => $document,
101+
));
102+
101103
return $route;
102104
}
103105
}

0 commit comments

Comments
 (0)