ensure id, pattern and resource are specified
the yaml loader also requires the pattern to be given, so the xml loader should do the same
This commit is contained in:
parent
8361b5a58b
commit
b20d6a7960
@ -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 <route> 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 <import> 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;
|
||||
|
@ -36,7 +36,7 @@
|
||||
<xsd:group ref="configs" minOccurs="0" maxOccurs="unbounded" />
|
||||
|
||||
<xsd:attribute name="id" type="xsd:string" use="required" />
|
||||
<xsd:attribute name="pattern" type="xsd:string" default="/" />
|
||||
<xsd:attribute name="pattern" type="xsd:string" use="required" />
|
||||
<xsd:attribute name="hostname-pattern" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
|
||||
|
Reference in New Issue
Block a user