Loads an XML file.
@api
string $file An XML file path:
string $type The resource type:
RouteCollection A RouteCollection instance
\InvalidArgumentException When a tag can't be parsed
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;
}