Skip to content

implemented getRoutesByNames(), removed bogus try/catch #187

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 7, 2013
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
36 changes: 18 additions & 18 deletions Doctrine/Orm/RouteProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,16 @@ public function getRouteByName($name, $parameters = array())
*/
public function getRoutesByNames($names, $parameters = array())
{
return array();
$routes = array();
foreach ($names as $name) {
try {
$routes[] = $this->getRouteByName($name, $parameters);
} catch (RouteNotFoundException $e) {
// not found
}
}

return $routes;
Copy link
Member

Choose a reason for hiding this comment

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

you did that on the orm provider on purpose, right? its a cheap implementation and could be optimized, but better than nothing.

Copy link
Member Author

Choose a reason for hiding this comment

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

yes ..

}

/**
Expand All @@ -93,25 +102,16 @@ public function getRouteCollectionForRequest(Request $request)
return $collection;
}

try {
$routes = $this->getRoutesRepository()->findByStaticPrefix($candidates, array('position' => 'ASC'));

foreach ($routes as $key => $route) {
if (preg_match('/.+\.([a-z]+)$/i', $url, $matches)) {
if ($route->getDefault('_format') === $matches[1]) {
continue;
}

$route->setDefault('_format', $matches[1]);
$routes = $this->getRoutesRepository()->findByStaticPrefix($candidates, array('position' => 'ASC'));
foreach ($routes as $key => $route) {
if (preg_match('/.+\.([a-z]+)$/i', $url, $matches)) {
if ($route->getDefault('_format') === $matches[1]) {
continue;
}
$collection->add($key, $route);

$route->setDefault('_format', $matches[1]);
}
} catch (RepositoryException $e) {
// TODO: this is not an orm exception
// https://github.com/symfony-cmf/RoutingBundle/issues/142
// also check if there are valid reasons for the orm manager to
// throw an exception or if we should just not catch it to not hide
// a severe problem.
$collection->add($key, $route);
Copy link
Member

Choose a reason for hiding this comment

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

this would fix #142 - do we lose anything here or can we never get exceptions except when the db is down?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

great. i added a note to the issue that we fix #142 with this

}

return $collection;
Expand Down