Skip to content

Commit 3082ce5

Browse files
committed
Merge pull request #187 from symfony-cmf/orm_route_provider
implemented getRoutesByNames(), removed bogus try/catch
2 parents 0c78372 + 1e7e6f9 commit 3082ce5

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

Doctrine/Orm/RouteProvider.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,16 @@ public function getRouteByName($name, $parameters = array())
7575
*/
7676
public function getRoutesByNames($names, $parameters = array())
7777
{
78-
return array();
78+
$routes = array();
79+
foreach ($names as $name) {
80+
try {
81+
$routes[] = $this->getRouteByName($name, $parameters);
82+
} catch (RouteNotFoundException $e) {
83+
// not found
84+
}
85+
}
86+
87+
return $routes;
7988
}
8089

8190
/**
@@ -93,25 +102,16 @@ public function getRouteCollectionForRequest(Request $request)
93102
return $collection;
94103
}
95104

96-
try {
97-
$routes = $this->getRoutesRepository()->findByStaticPrefix($candidates, array('position' => 'ASC'));
98-
99-
foreach ($routes as $key => $route) {
100-
if (preg_match('/.+\.([a-z]+)$/i', $url, $matches)) {
101-
if ($route->getDefault('_format') === $matches[1]) {
102-
continue;
103-
}
104-
105-
$route->setDefault('_format', $matches[1]);
105+
$routes = $this->getRoutesRepository()->findByStaticPrefix($candidates, array('position' => 'ASC'));
106+
foreach ($routes as $key => $route) {
107+
if (preg_match('/.+\.([a-z]+)$/i', $url, $matches)) {
108+
if ($route->getDefault('_format') === $matches[1]) {
109+
continue;
106110
}
107-
$collection->add($key, $route);
111+
112+
$route->setDefault('_format', $matches[1]);
108113
}
109-
} catch (RepositoryException $e) {
110-
// TODO: this is not an orm exception
111-
// https://github.com/symfony-cmf/RoutingBundle/issues/142
112-
// also check if there are valid reasons for the orm manager to
113-
// throw an exception or if we should just not catch it to not hide
114-
// a severe problem.
114+
$collection->add($key, $route);
115115
}
116116

117117
return $collection;

0 commit comments

Comments
 (0)