Skip to content

Commit d20225e

Browse files
committed
filter routes with the id prefix before doing lookups
1 parent 0c78372 commit d20225e

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

Doctrine/Phpcr/RouteProvider.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,11 @@ protected function getCandidates($url)
120120
public function getRouteByName($name, $parameters = array())
121121
{
122122
// $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+
}
124126

125-
if (!$route) {
127+
if (empty($route)) {
126128
throw new RouteNotFoundException(sprintf('No route found for path "%s"', $name));
127129
}
128130

@@ -138,7 +140,18 @@ public function getRouteByName($name, $parameters = array())
138140
*/
139141
public function getRoutesByNames($names, $parameters = array())
140142
{
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);
142155
foreach ($collection as $key => $document) {
143156
if (!$document instanceof SymfonyRoute) {
144157
// we follow the logic of DocumentManager::findMany and do not throw an exception

0 commit comments

Comments
 (0)