protected function XmlFileLoader::parseNode

Parses a node from a loaded XML file.

Parameters

RouteCollection $collection the collection to associate with the node:

DOMElement $node the node to parse:

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

string $file:

1 call to XmlFileLoader::parseNode()
XmlFileLoader::load in drupal/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/XmlFileLoader.php
Loads an XML file.

File

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

Class

XmlFileLoader
XmlFileLoader loads XML routing files.

Namespace

Symfony\Component\Routing\Loader

Code

protected function parseNode(RouteCollection $collection, \DOMElement $node, $path, $file) {
  switch ($node->tagName) {
    case 'route':
      $this
        ->parseRoute($collection, $node, $path);
      break;
    case 'import':
      $resource = (string) $node
        ->getAttribute('resource');
      $type = (string) $node
        ->getAttribute('type');
      $prefix = (string) $node
        ->getAttribute('prefix');
      $defaults = array();
      $requirements = array();
      $options = array();
      foreach ($node->childNodes as $n) {
        if (!$n instanceof \DOMElement) {
          continue;
        }
        switch ($n->tagName) {
          case 'default':
            $defaults[(string) $n
              ->getAttribute('key')] = trim((string) $n->nodeValue);
            break;
          case 'requirement':
            $requirements[(string) $n
              ->getAttribute('key')] = trim((string) $n->nodeValue);
            break;
          case 'option':
            $options[(string) $n
              ->getAttribute('key')] = trim((string) $n->nodeValue);
            break;
          default:
            throw new \InvalidArgumentException(sprintf('Unable to parse tag "%s"', $n->tagName));
        }
      }
      $this
        ->setCurrentDir(dirname($path));
      $collection
        ->addCollection($this
        ->import($resource, '' !== $type ? $type : null, false, $file), $prefix, $defaults, $requirements, $options);
      break;
    default:
      throw new \InvalidArgumentException(sprintf('Unable to parse tag "%s"', $node->tagName));
  }
}