You are here

private function XmlFileLoader::parseConfigs in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/routing/Loader/XmlFileLoader.php \Symfony\Component\Routing\Loader\XmlFileLoader::parseConfigs()

Parses the config elements (default, requirement, option).

Parameters

\DOMElement $node Element to parse that contains the configs:

string $path Full path of the XML file being processed:

Return value

array An array with the defaults as first item, requirements as second and options as third.

Throws

\InvalidArgumentException When the XML is invalid

2 calls to XmlFileLoader::parseConfigs()
XmlFileLoader::parseImport in vendor/symfony/routing/Loader/XmlFileLoader.php
Parses an import and adds the routes in the resource to the RouteCollection.
XmlFileLoader::parseRoute in vendor/symfony/routing/Loader/XmlFileLoader.php
Parses a route and adds it to the RouteCollection.

File

vendor/symfony/routing/Loader/XmlFileLoader.php, line 226

Class

XmlFileLoader
XmlFileLoader loads XML routing files.

Namespace

Symfony\Component\Routing\Loader

Code

private function parseConfigs(\DOMElement $node, $path) {
  $defaults = array();
  $requirements = array();
  $options = array();
  $condition = null;
  foreach ($node
    ->getElementsByTagNameNS(self::NAMESPACE_URI, '*') as $n) {
    switch ($n->localName) {
      case 'default':
        if ($this
          ->isElementValueNull($n)) {
          $defaults[$n
            ->getAttribute('key')] = null;
        }
        else {
          $defaults[$n
            ->getAttribute('key')] = trim($n->textContent);
        }
        break;
      case 'requirement':
        $requirements[$n
          ->getAttribute('key')] = trim($n->textContent);
        break;
      case 'option':
        $options[$n
          ->getAttribute('key')] = trim($n->textContent);
        break;
      case 'condition':
        $condition = trim($n->textContent);
        break;
      default:
        throw new \InvalidArgumentException(sprintf('Unknown tag "%s" used in file "%s". Expected "default", "requirement" or "option".', $n->localName, $path));
    }
  }
  return array(
    $defaults,
    $requirements,
    $options,
    $condition,
  );
}