From 9af0ff2fb2fbf64e2d084d8d82350a8bdef120f7 Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Mon, 12 Jan 2015 19:11:00 +0100 Subject: [PATCH] [FrameworkBundle] fix routing container param resolving to not access deprecated requirements while maintaining BC --- .../Bundle/FrameworkBundle/Routing/Router.php | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Routing/Router.php b/src/Symfony/Bundle/FrameworkBundle/Routing/Router.php index cee502d404..46882cdc4f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Routing/Router.php +++ b/src/Symfony/Bundle/FrameworkBundle/Routing/Router.php @@ -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); } }