protected function XmlFileLoader::parseImport

Parses an import and adds the routes in the resource 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:

string $file Loaded file name:

Throws

\InvalidArgumentException When the XML is invalid

1 call to XmlFileLoader::parseImport()
XmlFileLoader::parseNode in drupal/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/XmlFileLoader.php
Parses a node from a loaded XML file.

File

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

Class

XmlFileLoader
XmlFileLoader loads XML routing files.

Namespace

Symfony\Component\Routing\Loader

Code

protected function parseImport(RouteCollection $collection, \DOMElement $node, $path, $file) {
  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');
  $host = $node
    ->hasAttribute('host') ? $node
    ->getAttribute('host') : null;
  $schemes = $node
    ->hasAttribute('schemes') ? preg_split('/[\\s,\\|]++/', $node
    ->getAttribute('schemes'), -1, PREG_SPLIT_NO_EMPTY) : null;
  $methods = $node
    ->hasAttribute('methods') ? preg_split('/[\\s,\\|]++/', $node
    ->getAttribute('methods'), -1, PREG_SPLIT_NO_EMPTY) : null;
  list($defaults, $requirements, $options) = $this
    ->parseConfigs($node, $path);
  $this
    ->setCurrentDir(dirname($path));
  $subCollection = $this
    ->import($resource, '' !== $type ? $type : null, false, $file);

  /* @var $subCollection RouteCollection */
  $subCollection
    ->addPrefix($prefix);
  if (null !== $host) {
    $subCollection
      ->setHost($host);
  }
  if (null !== $schemes) {
    $subCollection
      ->setSchemes($schemes);
  }
  if (null !== $methods) {
    $subCollection
      ->setMethods($methods);
  }
  $subCollection
    ->addDefaults($defaults);
  $subCollection
    ->addRequirements($requirements);
  $subCollection
    ->addOptions($options);
  $collection
    ->addCollection($subCollection);
}