From 86278cd6c09ecb6f61b3e260c98d342734041a4c Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Tue, 13 Jan 2015 14:24:52 +0100 Subject: [PATCH 1/4] [Routing] remove deprecated features from routing --- .../Component/Routing/Annotation/Route.php | 20 ----- .../Routing/Generator/UrlGenerator.php | 4 - .../Routing/Loader/AnnotationClassLoader.php | 3 - .../Routing/Loader/XmlFileLoader.php | 11 --- .../Routing/Loader/YamlFileLoader.php | 13 +--- .../Loader/schema/routing/routing-1.0.xsd | 1 - src/Symfony/Component/Routing/Route.php | 75 +------------------ .../Routing/Tests/Annotation/RouteTest.php | 8 -- .../Tests/Fixtures/legacy_validpattern.xml | 16 ---- .../Tests/Fixtures/legacy_validpattern.yml | 8 -- .../Tests/Loader/XmlFileLoaderTest.php | 19 ----- .../Tests/Loader/YamlFileLoaderTest.php | 19 ----- .../Component/Routing/Tests/RouteTest.php | 42 ----------- 13 files changed, 3 insertions(+), 236 deletions(-) delete mode 100644 src/Symfony/Component/Routing/Tests/Fixtures/legacy_validpattern.xml delete mode 100644 src/Symfony/Component/Routing/Tests/Fixtures/legacy_validpattern.yml diff --git a/src/Symfony/Component/Routing/Annotation/Route.php b/src/Symfony/Component/Routing/Annotation/Route.php index af2158250c770..a0e3294c32ddb 100644 --- a/src/Symfony/Component/Routing/Annotation/Route.php +++ b/src/Symfony/Component/Routing/Annotation/Route.php @@ -54,26 +54,6 @@ public function __construct(array $data) } } - /** - * @deprecated since version 2.2, to be removed in 3.0. Use setPath instead. - */ - public function setPattern($pattern) - { - trigger_error('The '.__METHOD__.' method is deprecated since version 2.2 and will be removed in 3.0. Use the setPath() method instead and use the "path" option instead of the "pattern" option in the route definition.', E_USER_DEPRECATED); - - $this->path = $pattern; - } - - /** - * @deprecated since version 2.2, to be removed in 3.0. Use getPath instead. - */ - public function getPattern() - { - trigger_error('The '.__METHOD__.' method is deprecated since version 2.2 and will be removed in 3.0. Use the getPath() method instead and use the "path" option instead of the "pattern" option in the route definition.', E_USER_DEPRECATED); - - return $this->path; - } - public function setPath($path) { $this->path = $path; diff --git a/src/Symfony/Component/Routing/Generator/UrlGenerator.php b/src/Symfony/Component/Routing/Generator/UrlGenerator.php index 0deb666fb4abe..86a5a948ad071 100644 --- a/src/Symfony/Component/Routing/Generator/UrlGenerator.php +++ b/src/Symfony/Component/Routing/Generator/UrlGenerator.php @@ -219,10 +219,6 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa $referenceType = self::ABSOLUTE_URL; $scheme = current($requiredSchemes); } - } elseif (isset($requirements['_scheme']) && ($req = strtolower($requirements['_scheme'])) && $scheme !== $req) { - // We do this for BC; to be removed if _scheme is not supported anymore - $referenceType = self::ABSOLUTE_URL; - $scheme = $req; } if ($hostTokens) { diff --git a/src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php b/src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php index 92abf3648ace1..fb1475715222f 100644 --- a/src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php +++ b/src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php @@ -220,11 +220,8 @@ protected function getGlobals(\ReflectionClass $class) ); if ($annot = $this->reader->getClassAnnotation($class, $this->routeAnnotationClass)) { - // for BC reasons if (null !== $annot->getPath()) { $globals['path'] = $annot->getPath(); - } elseif (null !== $annot->getPattern()) { - $globals['path'] = $annot->getPattern(); } if (null !== $annot->getRequirements()) { diff --git a/src/Symfony/Component/Routing/Loader/XmlFileLoader.php b/src/Symfony/Component/Routing/Loader/XmlFileLoader.php index 7d2e12fe3414c..9519299841236 100644 --- a/src/Symfony/Component/Routing/Loader/XmlFileLoader.php +++ b/src/Symfony/Component/Routing/Loader/XmlFileLoader.php @@ -117,17 +117,6 @@ protected function parseRoute(RouteCollection $collection, \DOMElement $node, $p throw new \InvalidArgumentException(sprintf('The element in file "%s" must have an "id" and a "path" attribute.', $path)); } - if ($node->hasAttribute('pattern')) { - if ($node->hasAttribute('path')) { - throw new \InvalidArgumentException(sprintf('The element in file "%s" cannot define both a "path" and a "pattern" attribute. Use only "path".', $path)); - } - - trigger_error('The "pattern" is deprecated since version 2.2 and will be removed in 3.0. Use the "path" option in the route definition instead.', E_USER_DEPRECATED); - - $node->setAttribute('path', $node->getAttribute('pattern')); - $node->removeAttribute('pattern'); - } - $schemes = preg_split('/[\s,\|]++/', $node->getAttribute('schemes'), -1, PREG_SPLIT_NO_EMPTY); $methods = preg_split('/[\s,\|]++/', $node->getAttribute('methods'), -1, PREG_SPLIT_NO_EMPTY); diff --git a/src/Symfony/Component/Routing/Loader/YamlFileLoader.php b/src/Symfony/Component/Routing/Loader/YamlFileLoader.php index 63d3cd6439ff5..963aa701b8792 100644 --- a/src/Symfony/Component/Routing/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/Routing/Loader/YamlFileLoader.php @@ -28,7 +28,7 @@ class YamlFileLoader extends FileLoader { private static $availableKeys = array( - 'resource', 'type', 'prefix', 'pattern', 'path', 'host', 'schemes', 'methods', 'defaults', 'requirements', 'options', 'condition', + 'resource', 'type', 'prefix', 'path', 'host', 'schemes', 'methods', 'defaults', 'requirements', 'options', 'condition', ); private $yamlParser; @@ -76,17 +76,6 @@ public function load($file, $type = null) } foreach ($config as $name => $config) { - if (isset($config['pattern'])) { - if (isset($config['path'])) { - throw new \InvalidArgumentException(sprintf('The file "%s" cannot define both a "path" and a "pattern" attribute. Use only "path".', $path)); - } - - trigger_error('The "pattern" is deprecated since version 2.2 and will be removed in 3.0. Use the "path" option in the route definition instead.', E_USER_DEPRECATED); - - $config['path'] = $config['pattern']; - unset($config['pattern']); - } - $this->validate($config, $name, $path); if (isset($config['resource'])) { diff --git a/src/Symfony/Component/Routing/Loader/schema/routing/routing-1.0.xsd b/src/Symfony/Component/Routing/Loader/schema/routing/routing-1.0.xsd index d40aa422122a2..19b400540eb78 100644 --- a/src/Symfony/Component/Routing/Loader/schema/routing/routing-1.0.xsd +++ b/src/Symfony/Component/Routing/Loader/schema/routing/routing-1.0.xsd @@ -38,7 +38,6 @@ - diff --git a/src/Symfony/Component/Routing/Route.php b/src/Symfony/Component/Routing/Route.php index a7b6ad1fd4733..b9d1b30c95188 100644 --- a/src/Symfony/Component/Routing/Route.php +++ b/src/Symfony/Component/Routing/Route.php @@ -91,14 +91,8 @@ public function __construct($path, array $defaults = array(), array $requirement $this->setRequirements($requirements); $this->setOptions($options); $this->setHost($host); - // The conditions make sure that an initial empty $schemes/$methods does not override the corresponding requirement. - // They can be removed when the BC layer is removed. - if ($schemes) { - $this->setSchemes($schemes); - } - if ($methods) { - $this->setMethods($methods); - } + $this->setSchemes($schemes); + $this->setMethods($methods); $this->setCondition($condition); } @@ -142,38 +136,6 @@ public function unserialize($serialized) } } - /** - * Returns the pattern for the path. - * - * @return string The pattern - * - * @deprecated since version 2.2, to be removed in 3.0. Use getPath instead. - */ - public function getPattern() - { - trigger_error('The '.__METHOD__.' method is deprecated since version 2.2 and will be removed in 3.0. Use the getPath() method instead.', E_USER_DEPRECATED); - - return $this->path; - } - - /** - * Sets the pattern for the path. - * - * This method implements a fluent interface. - * - * @param string $pattern The path pattern - * - * @return Route The current Route instance - * - * @deprecated since version 2.2, to be removed in 3.0. Use setPath instead. - */ - public function setPattern($pattern) - { - trigger_error('The '.__METHOD__.' method is deprecated since version 2.2 and will be removed in 3.0. Use the setPath() method instead.', E_USER_DEPRECATED); - - return $this->setPath($pattern); - } - /** * Returns the pattern for the path. * @@ -254,14 +216,6 @@ public function getSchemes() public function setSchemes($schemes) { $this->schemes = array_map('strtolower', (array) $schemes); - - // this is to keep BC and will be removed in a future version - if ($this->schemes) { - $this->requirements['_scheme'] = implode('|', $this->schemes); - } else { - unset($this->requirements['_scheme']); - } - $this->compiled = null; return $this; @@ -303,14 +257,6 @@ public function getMethods() public function setMethods($methods) { $this->methods = array_map('strtoupper', (array) $methods); - - // this is to keep BC and will be removed in a future version - if ($this->methods) { - $this->requirements['_method'] = implode('|', $this->methods); - } else { - unset($this->requirements['_method']); - } - $this->compiled = null; return $this; @@ -548,12 +494,6 @@ public function addRequirements(array $requirements) */ public function getRequirement($key) { - if ('_scheme' === $key) { - trigger_error('The "_scheme" requirement is deprecated since version 2.2 and will be removed in 3.0. Use getSchemes() instead.', E_USER_DEPRECATED); - } elseif ('_method' === $key) { - trigger_error('The "_method" requirement is deprecated since version 2.2 and will be removed in 3.0. Use getMethods() instead.', E_USER_DEPRECATED); - } - return isset($this->requirements[$key]) ? $this->requirements[$key] : null; } @@ -653,17 +593,6 @@ private function sanitizeRequirement($key, $regex) throw new \InvalidArgumentException(sprintf('Routing requirement for "%s" cannot be empty.', $key)); } - // 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); - - $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); - - $this->setMethods(explode('|', $regex)); - } - return $regex; } } diff --git a/src/Symfony/Component/Routing/Tests/Annotation/RouteTest.php b/src/Symfony/Component/Routing/Tests/Annotation/RouteTest.php index 921edf63d0746..7a3665eebe71f 100644 --- a/src/Symfony/Component/Routing/Tests/Annotation/RouteTest.php +++ b/src/Symfony/Component/Routing/Tests/Annotation/RouteTest.php @@ -46,12 +46,4 @@ public function getValidParameters() array('condition', 'context.getMethod() == "GET"', 'getCondition'), ); } - - public function testLegacyGetPattern() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - - $route = new Route(array('value' => '/Blog')); - $this->assertEquals($route->getPattern(), '/Blog'); - } } diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/legacy_validpattern.xml b/src/Symfony/Component/Routing/Tests/Fixtures/legacy_validpattern.xml deleted file mode 100644 index a01ebca23ae09..0000000000000 --- a/src/Symfony/Component/Routing/Tests/Fixtures/legacy_validpattern.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - MyBundle:Blog:show - - GET|POST|put|OpTiOnS - hTTps - \w+ - - context.getMethod() == "GET" - - diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/legacy_validpattern.yml b/src/Symfony/Component/Routing/Tests/Fixtures/legacy_validpattern.yml deleted file mode 100644 index ada65f0568da1..0000000000000 --- a/src/Symfony/Component/Routing/Tests/Fixtures/legacy_validpattern.yml +++ /dev/null @@ -1,8 +0,0 @@ -blog_show_legacy: - pattern: /blog/{slug} - defaults: { _controller: "MyBundle:Blog:show" } - host: "{locale}.example.com" - requirements: { '_method': 'GET|POST|put|OpTiOnS', _scheme: https, 'locale': '\w+' } - condition: 'context.getMethod() == "GET"' - options: - compiler_class: RouteCompiler diff --git a/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php index 1b552d6d66aa3..048d3ae904c9b 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php @@ -45,25 +45,6 @@ public function testLoadWithRoute() $this->assertEquals('context.getMethod() == "GET"', $route->getCondition()); } - public function testLegacyRouteDefinitionLoading() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - - $loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures'))); - $routeCollection = $loader->load('legacy_validpattern.xml'); - $route = $routeCollection->get('blog_show_legacy'); - - $this->assertInstanceOf('Symfony\Component\Routing\Route', $route); - $this->assertSame('/blog/{slug}', $route->getPath()); - $this->assertSame('{locale}.example.com', $route->getHost()); - $this->assertSame('MyBundle:Blog:show', $route->getDefault('_controller')); - $this->assertSame('\w+', $route->getRequirement('locale')); - $this->assertSame('RouteCompiler', $route->getOption('compiler_class')); - $this->assertEquals(array('GET', 'POST', 'PUT', 'OPTIONS'), $route->getMethods()); - $this->assertEquals(array('https'), $route->getSchemes()); - $this->assertEquals('context.getMethod() == "GET"', $route->getCondition()); - } - public function testLoadWithNamespacePrefix() { $loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures'))); diff --git a/src/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php index c3365e7ee54eb..ed99d87b0954a 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php @@ -79,25 +79,6 @@ public function testLoadWithRoute() $this->assertEquals('context.getMethod() == "GET"', $route->getCondition()); } - public function testLegacyRouteDefinitionLoading() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - - $loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures'))); - $routeCollection = $loader->load('legacy_validpattern.yml'); - $route = $routeCollection->get('blog_show_legacy'); - - $this->assertInstanceOf('Symfony\Component\Routing\Route', $route); - $this->assertSame('/blog/{slug}', $route->getPath()); - $this->assertSame('{locale}.example.com', $route->getHost()); - $this->assertSame('MyBundle:Blog:show', $route->getDefault('_controller')); - $this->assertSame('\w+', $route->getRequirement('locale')); - $this->assertSame('RouteCompiler', $route->getOption('compiler_class')); - $this->assertEquals(array('GET', 'POST', 'PUT', 'OPTIONS'), $route->getMethods()); - $this->assertEquals(array('https'), $route->getSchemes()); - $this->assertEquals('context.getMethod() == "GET"', $route->getCondition()); - } - public function testLoadWithResource() { $loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures'))); diff --git a/src/Symfony/Component/Routing/Tests/RouteTest.php b/src/Symfony/Component/Routing/Tests/RouteTest.php index b2a90e995125e..adc15a61d51d4 100644 --- a/src/Symfony/Component/Routing/Tests/RouteTest.php +++ b/src/Symfony/Component/Routing/Tests/RouteTest.php @@ -164,23 +164,6 @@ public function testScheme() $this->assertTrue($route->hasScheme('httpS')); } - public function testLegacySchemeRequirement() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - - $route = new Route('/'); - $route->setRequirement('_scheme', 'http|https'); - $this->assertEquals('http|https', $route->getRequirement('_scheme')); - $this->assertEquals(array('http', 'https'), $route->getSchemes()); - $this->assertTrue($route->hasScheme('https')); - $this->assertTrue($route->hasScheme('http')); - $this->assertFalse($route->hasScheme('ftp')); - $route->setSchemes(array('hTTp')); - $this->assertEquals('http', $route->getRequirement('_scheme')); - $route->setSchemes(array()); - $this->assertNull($route->getRequirement('_scheme')); - } - public function testMethod() { $route = new Route('/'); @@ -191,20 +174,6 @@ public function testMethod() $this->assertEquals(array('GET', 'POST'), $route->getMethods(), '->setMethods() accepts an array of methods and uppercases them'); } - public function testLegacyMethodRequirement() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - - $route = new Route('/'); - $route->setRequirement('_method', 'GET|POST'); - $this->assertEquals('GET|POST', $route->getRequirement('_method')); - $this->assertEquals(array('GET', 'POST'), $route->getMethods()); - $route->setMethods(array('gEt')); - $this->assertEquals('GET', $route->getRequirement('_method')); - $route->setMethods(array()); - $this->assertNull($route->getRequirement('_method')); - } - public function testCondition() { $route = new Route('/'); @@ -222,17 +191,6 @@ public function testCompile() $this->assertNotSame($compiled, $route->compile(), '->compile() recompiles if the route was modified'); } - public function testLegacyPattern() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - - $route = new Route('/{foo}'); - $this->assertEquals('/{foo}', $route->getPattern()); - - $route->setPattern('/bar'); - $this->assertEquals('/bar', $route->getPattern()); - } - public function testSerialize() { $route = new Route('/prefix/{foo}', array('foo' => 'default'), array('foo' => '\d+')); From 4ca9ab38e9eb74a9d48853db29e31b63203ae938 Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Tue, 13 Jan 2015 14:32:07 +0100 Subject: [PATCH 2/4] [FrameworkBundle] remove deprecated routing features --- .../FrameworkBundle/Console/Descriptor/JsonDescriptor.php | 5 +---- .../Console/Descriptor/MarkdownDescriptor.php | 5 +---- .../FrameworkBundle/Console/Descriptor/TextDescriptor.php | 5 +---- .../FrameworkBundle/Console/Descriptor/XmlDescriptor.php | 6 ++---- src/Symfony/Bundle/FrameworkBundle/Routing/Router.php | 4 ---- 5 files changed, 5 insertions(+), 20 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php index 8548b211375be..014fa06228c13 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php @@ -180,9 +180,6 @@ private function writeData(array $data, array $options) */ protected function getRouteData(Route $route) { - $requirements = $route->getRequirements(); - unset($requirements['_scheme'], $requirements['_method']); - return array( 'path' => $route->getPath(), 'pathRegex' => $route->compile()->getRegex(), @@ -192,7 +189,7 @@ protected function getRouteData(Route $route) 'method' => $route->getMethods() ? implode('|', $route->getMethods()) : 'ANY', 'class' => get_class($route), 'defaults' => $route->getDefaults(), - 'requirements' => $requirements ?: 'NO CUSTOM', + 'requirements' => $route->getRequirements() ?: 'NO CUSTOM', 'options' => $route->getOptions(), ); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php index a3ebd7f1e57c3..4921d2ba5b5b0 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php @@ -49,9 +49,6 @@ protected function describeRouteCollection(RouteCollection $routes, array $optio */ protected function describeRoute(Route $route, array $options = array()) { - $requirements = $route->getRequirements(); - unset($requirements['_scheme'], $requirements['_method']); - $output = '- Path: '.$route->getPath() ."\n".'- Path Regex: '.$route->compile()->getRegex() ."\n".'- Host: '.('' !== $route->getHost() ? $route->getHost() : 'ANY') @@ -60,7 +57,7 @@ protected function describeRoute(Route $route, array $options = array()) ."\n".'- Method: '.($route->getMethods() ? implode('|', $route->getMethods()) : 'ANY') ."\n".'- Class: '.get_class($route) ."\n".'- Defaults: '.$this->formatRouterConfig($route->getDefaults()) - ."\n".'- Requirements: '.($requirements ? $this->formatRouterConfig($requirements) : 'NO CUSTOM') + ."\n".'- Requirements: '.($route->getRequirements() ? $this->formatRouterConfig($route->getRequirements()) : 'NO CUSTOM') ."\n".'- Options: '.$this->formatRouterConfig($route->getOptions()); $this->write(isset($options['name']) diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php index 85dbb2b8b8a0f..9dd9200f65117 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php @@ -70,9 +70,6 @@ protected function describeRouteCollection(RouteCollection $routes, array $optio */ protected function describeRoute(Route $route, array $options = array()) { - $requirements = $route->getRequirements(); - unset($requirements['_scheme'], $requirements['_method']); - // fixme: values were originally written as raw $description = array( 'Path '.$route->getPath(), @@ -83,7 +80,7 @@ protected function describeRoute(Route $route, array $options = array()) 'Method '.($route->getMethods() ? implode('|', $route->getMethods()) : 'ANY'), 'Class '.get_class($route), 'Defaults '.$this->formatRouterConfig($route->getDefaults()), - 'Requirements '.($requirements ? $this->formatRouterConfig($requirements) : 'NO CUSTOM'), + 'Requirements '.($route->getRequirements() ? $this->formatRouterConfig($route->getRequirements()) : 'NO CUSTOM'), 'Options '.$this->formatRouterConfig($route->getOptions()), ); diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php index c37a9009fcff5..fe0c357e11974 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php @@ -196,11 +196,9 @@ private function getRouteDocument(Route $route, $name = null) } } - $requirements = $route->getRequirements(); - unset($requirements['_scheme'], $requirements['_method']); - if (count($requirements)) { + if (count($route->getRequirements())) { $routeXML->appendChild($requirementsXML = $dom->createElement('requirements')); - foreach ($requirements as $attribute => $pattern) { + foreach ($route->getRequirements() as $attribute => $pattern) { $requirementsXML->appendChild($requirementXML = $dom->createElement('requirement')); $requirementXML->setAttribute('key', $attribute); $requirementXML->appendChild(new \DOMText($pattern)); diff --git a/src/Symfony/Bundle/FrameworkBundle/Routing/Router.php b/src/Symfony/Bundle/FrameworkBundle/Routing/Router.php index 46882cdc4fcfc..b5bc751662a01 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Routing/Router.php +++ b/src/Symfony/Bundle/FrameworkBundle/Routing/Router.php @@ -92,10 +92,6 @@ private function resolveParameters(RouteCollection $collection) } 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)); } From 82d54fac8c12f4462c3c648d9fbb22e35cc6ccfe Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Fri, 16 Jan 2015 09:31:31 +0100 Subject: [PATCH 3/4] [FramworkBundle] our tests now expect symfony 3.0 behavior for routing --- src/Symfony/Bundle/FrameworkBundle/composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/composer.json b/src/Symfony/Bundle/FrameworkBundle/composer.json index 0c8bddcb0d7b4..7ce20486d4718 100644 --- a/src/Symfony/Bundle/FrameworkBundle/composer.json +++ b/src/Symfony/Bundle/FrameworkBundle/composer.json @@ -23,7 +23,7 @@ "symfony/http-foundation": "~2.7|~3.0", "symfony/http-kernel": "~2.7|~3.0", "symfony/filesystem": "~2.7|~3.0", - "symfony/routing": "~2.7|~3.0", + "symfony/routing": "~3.0", "symfony/security-core": "~2.7|~3.0", "symfony/security-csrf": "~2.7|~3.0", "symfony/stopwatch": "~2.7|~3.0", From f939fea5438983bc296c0b8da705ffe3aabd2c0a Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Sat, 31 Jan 2015 21:19:47 +0100 Subject: [PATCH 4/4] [Routing] make path required again in the xsd pattern was previously also required, see https://github.com/symfony/symfony/commit/508299400d7fe6f6222a32d5e527d988bb307dcb#diff-4 --- src/Symfony/Component/Routing/Loader/XmlFileLoader.php | 2 +- .../Component/Routing/Loader/schema/routing/routing-1.0.xsd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Routing/Loader/XmlFileLoader.php b/src/Symfony/Component/Routing/Loader/XmlFileLoader.php index 9519299841236..1fb04dd2bc888 100644 --- a/src/Symfony/Component/Routing/Loader/XmlFileLoader.php +++ b/src/Symfony/Component/Routing/Loader/XmlFileLoader.php @@ -113,7 +113,7 @@ public function supports($resource, $type = null) */ protected function parseRoute(RouteCollection $collection, \DOMElement $node, $path) { - if ('' === ($id = $node->getAttribute('id')) || (!$node->hasAttribute('pattern') && !$node->hasAttribute('path'))) { + if ('' === ($id = $node->getAttribute('id')) || !$node->hasAttribute('path')) { throw new \InvalidArgumentException(sprintf('The element in file "%s" must have an "id" and a "path" attribute.', $path)); } diff --git a/src/Symfony/Component/Routing/Loader/schema/routing/routing-1.0.xsd b/src/Symfony/Component/Routing/Loader/schema/routing/routing-1.0.xsd index 19b400540eb78..8090c784c1604 100644 --- a/src/Symfony/Component/Routing/Loader/schema/routing/routing-1.0.xsd +++ b/src/Symfony/Component/Routing/Loader/schema/routing/routing-1.0.xsd @@ -37,7 +37,7 @@ - +