protected function XmlFileLoader::parseRoute in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/symfony/routing/Loader/XmlFileLoader.php \Symfony\Component\Routing\Loader\XmlFileLoader::parseRoute()
Parses a route and adds it to the RouteCollection.
Parameters
RouteCollection $collection RouteCollection instance:
\DOMElement $node Element to parse that represents a Route:
string $path Full path of the XML file being processed:
Throws
\InvalidArgumentException When the XML is invalid
1 call to XmlFileLoader::parseRoute()
- XmlFileLoader::parseNode in vendor/
symfony/ routing/ Loader/ XmlFileLoader.php - Parses a node from a loaded XML file.
File
- vendor/
symfony/ routing/ Loader/ XmlFileLoader.php, line 108
Class
- XmlFileLoader
- XmlFileLoader loads XML routing files.
Namespace
Symfony\Component\Routing\LoaderCode
protected function parseRoute(RouteCollection $collection, \DOMElement $node, $path) {
if ('' === ($id = $node
->getAttribute('id')) || !$node
->hasAttribute('pattern') && !$node
->hasAttribute('path')) {
throw new \InvalidArgumentException(sprintf('The <route> 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 <route> element in file "%s" cannot define both a "path" and a "pattern" attribute. Use only "path".', $path));
}
@trigger_error(sprintf('The "pattern" option in file "%s" is deprecated since version 2.2 and will be removed in 3.0. Use the "path" option in the route definition instead.', $path), 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);
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);
}