diff --git a/src/Symfony/Component/Routing/Annotation/Route.php b/src/Symfony/Component/Routing/Annotation/Route.php index 8bbc17be20..d5bfea5768 100644 --- a/src/Symfony/Component/Routing/Annotation/Route.php +++ b/src/Symfony/Component/Routing/Annotation/Route.php @@ -106,6 +106,22 @@ class Route public function setRequirements($requirements) { + if (isset($requirements['_method'])) { + if (0 === count($this->methods)) { + $this->methods = explode('|', $requirements['_method']); + } + + @trigger_error('The "_method" requirement is deprecated since version 2.2 and will be removed in 3.0. Use the "methods" option instead.', E_USER_DEPRECATED); + } + + if (isset($requirements['_scheme'])) { + if (0 === count($this->schemes)) { + $this->schemes = explode('|', $requirements['_scheme']); + } + + @trigger_error('The "_scheme" requirement is deprecated since version 2.2 and will be removed in 3.0. Use the "schemes" option instead.', E_USER_DEPRECATED); + } + $this->requirements = $requirements; } diff --git a/src/Symfony/Component/Routing/Loader/XmlFileLoader.php b/src/Symfony/Component/Routing/Loader/XmlFileLoader.php index a18dbb9741..e8c7f6b148 100644 --- a/src/Symfony/Component/Routing/Loader/XmlFileLoader.php +++ b/src/Symfony/Component/Routing/Loader/XmlFileLoader.php @@ -133,6 +133,24 @@ class XmlFileLoader extends FileLoader list($defaults, $requirements, $options, $condition) = $this->parseConfigs($node, $path); + if (isset($requirements['_method'])) { + if (0 === count($methods)) { + $methods = explode('|', $requirements['_method']); + } + + unset($requirements['_method']); + @trigger_error(sprintf('The "_method" requirement of route "%s" in file "%s" is deprecated since version 2.2 and will be removed in 3.0. Use the "methods" attribute instead.', $id, $path), E_USER_DEPRECATED); + } + + if (isset($requirements['_scheme'])) { + if (0 === count($schemes)) { + $schemes = explode('|', $requirements['_scheme']); + } + + unset($requirements['_scheme']); + @trigger_error(sprintf('The "_scheme" requirement of route "%s" in file "%s" is deprecated since version 2.2 and will be removed in 3.0. Use the "schemes" attribute instead.', $id, $path), E_USER_DEPRECATED); + } + $route = new Route($node->getAttribute('path'), $defaults, $requirements, $options, $node->getAttribute('host'), $schemes, $methods, $condition); $collection->add($id, $route); } diff --git a/src/Symfony/Component/Routing/Loader/YamlFileLoader.php b/src/Symfony/Component/Routing/Loader/YamlFileLoader.php index 7d850e7c8e..d30da91d2a 100644 --- a/src/Symfony/Component/Routing/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/Routing/Loader/YamlFileLoader.php @@ -127,6 +127,24 @@ class YamlFileLoader extends FileLoader $methods = isset($config['methods']) ? $config['methods'] : array(); $condition = isset($config['condition']) ? $config['condition'] : null; + if (isset($requirements['_method'])) { + if (0 === count($methods)) { + $methods = explode('|', $requirements['_method']); + } + + unset($requirements['_method']); + @trigger_error(sprintf('The "_method" requirement of route "%s" in file "%s" is deprecated since version 2.2 and will be removed in 3.0. Use the "methods" option instead.', $name, $path), E_USER_DEPRECATED); + } + + if (isset($requirements['_scheme'])) { + if (0 === count($schemes)) { + $schemes = explode('|', $requirements['_scheme']); + } + + unset($requirements['_scheme']); + @trigger_error(sprintf('The "_scheme" requirement of route "%s" in file "%s" is deprecated since version 2.2 and will be removed in 3.0. Use the "schemes" option instead.', $name, $path), E_USER_DEPRECATED); + } + $route = new Route($config['path'], $defaults, $requirements, $options, $host, $schemes, $methods, $condition); $collection->add($name, $route); diff --git a/src/Symfony/Component/Routing/Route.php b/src/Symfony/Component/Routing/Route.php index d0b3a2dbed..19a48f13bd 100644 --- a/src/Symfony/Component/Routing/Route.php +++ b/src/Symfony/Component/Routing/Route.php @@ -655,11 +655,11 @@ class Route implements \Serializable // this is to keep BC and will be removed in a future version if ('_scheme' === $key) { - @trigger_error('The "_scheme" requirement is deprecated since version 2.2 and will be removed in 3.0. Use the setSchemes() method instead or the "schemes" option in the route definition.', E_USER_DEPRECATED); + @trigger_error('The "_scheme" requirement is deprecated since version 2.2 and will be removed in 3.0. Use the setSchemes() method instead.', E_USER_DEPRECATED); $this->setSchemes(explode('|', $regex)); } elseif ('_method' === $key) { - @trigger_error('The "_method" requirement is deprecated since version 2.2 and will be removed in 3.0. Use the setMethods() method instead or the "methods" option in the route definition.', E_USER_DEPRECATED); + @trigger_error('The "_method" requirement is deprecated since version 2.2 and will be removed in 3.0. Use the setMethods() method instead.', E_USER_DEPRECATED); $this->setMethods(explode('|', $regex)); }