public function XmlFileLoader::load

Same name in this branch

Loads an XML file.

@api

Parameters

string $file An XML file path:

string $type The resource type:

Return value

RouteCollection A RouteCollection instance

Throws

\InvalidArgumentException When a tag can't be parsed

File

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

Class

XmlFileLoader
XmlFileLoader loads XML routing files.

Namespace

Symfony\Component\Routing\Loader

Code

public function load($file, $type = null) {
  $path = $this->locator
    ->locate($file);
  $xml = $this
    ->loadFile($path);
  $collection = new RouteCollection();
  $collection
    ->addResource(new FileResource($path));

  // process routes and imports
  foreach ($xml->documentElement->childNodes as $node) {
    if (!$node instanceof \DOMElement) {
      continue;
    }
    $this
      ->parseNode($collection, $node, $path, $file);
  }
  return $collection;
}