File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -120,9 +120,11 @@ protected function getCandidates($url)
120
120
public function getRouteByName ($ name , $ parameters = array ())
121
121
{
122
122
// $name is the route document path
123
- $ route = $ this ->getObjectManager ()->find ($ this ->className , $ name );
123
+ if ($ this ->idPrefix && 0 === strpos ($ name , $ this ->idPrefix )) {
124
+ $ route = $ this ->getObjectManager ()->find ($ this ->className , $ name );
125
+ }
124
126
125
- if (! $ route ) {
127
+ if (empty ( $ route) ) {
126
128
throw new RouteNotFoundException (sprintf ('No route found for path "%s" ' , $ name ));
127
129
}
128
130
@@ -138,7 +140,18 @@ public function getRouteByName($name, $parameters = array())
138
140
*/
139
141
public function getRoutesByNames ($ names , $ parameters = array ())
140
142
{
141
- $ collection = $ this ->getObjectManager ()->findMany ($ this ->className , $ names );
143
+ if ($ this ->idPrefix ) {
144
+ $ routes = array ();
145
+ foreach ($ names as $ name ) {
146
+ if (0 === strpos ($ name , $ this ->idPrefix )) {
147
+ $ routes [] = $ name ;
148
+ }
149
+ }
150
+ } else {
151
+ $ routes = $ names ;
152
+ }
153
+
154
+ $ collection = $ this ->getObjectManager ()->findMany ($ this ->className , $ routes );
142
155
foreach ($ collection as $ key => $ document ) {
143
156
if (!$ document instanceof SymfonyRoute) {
144
157
// we follow the logic of DocumentManager::findMany and do not throw an exception
You can’t perform that action at this time.
0 commit comments