@@ -75,7 +75,16 @@ public function getRouteByName($name, $parameters = array())
75
75
*/
76
76
public function getRoutesByNames ($ names , $ parameters = array ())
77
77
{
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 ;
79
88
}
80
89
81
90
/**
@@ -93,25 +102,16 @@ public function getRouteCollectionForRequest(Request $request)
93
102
return $ collection ;
94
103
}
95
104
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 ;
106
110
}
107
- $ collection ->add ($ key , $ route );
111
+
112
+ $ route ->setDefault ('_format ' , $ matches [1 ]);
108
113
}
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 );
115
115
}
116
116
117
117
return $ collection ;
0 commit comments