[FrameworkBundle] fix routing container param resolving to not access deprecated requirements while maintaining BC

This commit is contained in:
Tobias Schultze 2015-01-12 19:11:00 +01:00
parent bd91867225
commit 9af0ff2fb2
1 changed files with 20 additions and 2 deletions

View File

@ -77,8 +77,10 @@ class Router extends BaseRouter implements WarmableInterface
* Replaces placeholders with service container parameter values in:
* - the route defaults,
* - the route requirements,
* - the route pattern.
* - the route host.
* - the route path,
* - the route host,
* - the route schemes,
* - the route methods.
*
* @param RouteCollection $collection
*/
@ -90,11 +92,27 @@ class Router extends BaseRouter implements WarmableInterface
}
foreach ($route->getRequirements() as $name => $value) {
if ('_scheme' === $name || '_method' === $name) {
continue; // ignore deprecated requirements to not trigger deprecation warnings
}
$route->setRequirement($name, $this->resolve($value));
}
$route->setPath($this->resolve($route->getPath()));
$route->setHost($this->resolve($route->getHost()));
$schemes = array();
foreach ($route->getSchemes() as $scheme) {
$schemes = array_merge($schemes, explode('|', $this->resolve($scheme)));
}
$route->setSchemes($schemes);
$methods = array();
foreach ($route->getMethods() as $method) {
$methods = array_merge($methods, explode('|', $this->resolve($method)));
}
$route->setMethods($methods);
}
}