Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. XmlFileLoader.php

function XmlFileLoader::load

Same name in this branch
  1. 11.1.x vendor/symfony/routing/Loader/XmlFileLoader.php \Symfony\Component\Routing\Loader\XmlFileLoader::load()

File

vendor/symfony/dependency-injection/Loader/XmlFileLoader.php, line 44

Class

XmlFileLoader
XmlFileLoader loads XML files service definitions.

Namespace

Symfony\Component\DependencyInjection\Loader

Code

public function load(mixed $resource, ?string $type = null) : mixed {
    $path = $this->locator
        ->locate($resource);
    $xml = $this->parseFileToDOM($path);
    $this->container
        ->fileExists($path);
    $this->loadXml($xml, $path);
    if ($this->env) {
        $xpath = new \DOMXPath($xml);
        $xpath->registerNamespace('container', self::NS);
        foreach ($xpath->query(\sprintf('//container:when[@env="%s"]', $this->env)) ?: [] as $root) {
            $env = $this->env;
            $this->env = null;
            try {
                $this->loadXml($xml, $path, $root);
            } finally {
                $this->env = $env;
            }
        }
    }
    return null;
}
RSS feed
Powered by Drupal