-
Notifications
You must be signed in to change notification settings - Fork 76
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
} | ||
|
||
/** | ||
|
@@ -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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no .. Sylius/Sylius#255 (diff) There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes ..