private function 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 drupal/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/XmlFileLoader.php
Parses an import and adds the routes in the resource to the RouteCollection.
XmlFileLoader::parseRoute in drupal/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/XmlFileLoader.php
Parses a route and adds it to the RouteCollection.

File

drupal/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/XmlFileLoader.php, line 209

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();
  foreach ($node
    ->getElementsByTagNameNS(self::NAMESPACE_URI, '*') as $n) {
    switch ($n->localName) {
      case 'default':
        if ($n
          ->hasAttribute('xsi:nil') && 'true' == $n
          ->getAttribute('xsi:nil')) {
          $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;
      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,
  );
}