diff --git a/src/Symfony/Component/Routing/Loader/XmlFileLoader.php b/src/Symfony/Component/Routing/Loader/XmlFileLoader.php index 109b883d3b..30fc1dac6a 100644 --- a/src/Symfony/Component/Routing/Loader/XmlFileLoader.php +++ b/src/Symfony/Component/Routing/Loader/XmlFileLoader.php @@ -112,11 +112,14 @@ class XmlFileLoader extends FileLoader */ protected function parseRoute(RouteCollection $collection, \DOMElement $node, $path) { + if ('' === ($id = $node->getAttribute('id')) || !$node->hasAttribute('pattern')) { + throw new \InvalidArgumentException(sprintf('The element in file "%s" must have an "id" and a "pattern" attribute.', $path)); + } + list($defaults, $requirements, $options) = $this->parseConfigs($node, $path); $route = new Route($node->getAttribute('pattern'), $defaults, $requirements, $options, $node->getAttribute('hostname-pattern')); - - $collection->add($node->getAttribute('id'), $route); + $collection->add($id, $route); } /** @@ -131,7 +134,10 @@ class XmlFileLoader extends FileLoader */ protected function parseImport(RouteCollection $collection, \DOMElement $node, $path, $file) { - $resource = $node->getAttribute('resource'); + if ('' === $resource = $node->getAttribute('resource')) { + throw new \InvalidArgumentException(sprintf('The element in file "%s" must have a "resource" attribute.', $path)); + } + $type = $node->getAttribute('type'); $prefix = $node->getAttribute('prefix'); $hostnamePattern = $node->hasAttribute('hostname-pattern') ? $node->getAttribute('hostname-pattern') : null; 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 c9bd3d6a6d..3143b3ac72 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 @@ -36,7 +36,7 @@ - +