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

Breadcrumb

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

function YamlFileLoader::load

Same name in this branch
  1. 11.1.x vendor/symfony/routing/Loader/YamlFileLoader.php \Symfony\Component\Routing\Loader\YamlFileLoader::load()
  2. 11.1.x core/lib/Drupal/Core/DependencyInjection/YamlFileLoader.php \Drupal\Core\DependencyInjection\YamlFileLoader::load()

File

vendor/symfony/dependency-injection/Loader/YamlFileLoader.php, line 119

Class

YamlFileLoader
YamlFileLoader loads YAML files service definitions.

Namespace

Symfony\Component\DependencyInjection\Loader

Code

public function load(mixed $resource, ?string $type = null) : mixed {
    $path = $this->locator
        ->locate($resource);
    $content = $this->loadFile($path);
    $this->container
        ->fileExists($path);
    // empty file
    if (null === $content) {
        return null;
    }
    ++$this->importing;
    try {
        $this->loadContent($content, $path);
        // per-env configuration
        if ($this->env && isset($content['when@' . $this->env])) {
            if (!\is_array($content['when@' . $this->env])) {
                throw new InvalidArgumentException(\sprintf('The "when@%s" key should contain an array in "%s". Check your YAML syntax.', $this->env, $path));
            }
            $env = $this->env;
            $this->env = null;
            try {
                $this->loadContent($content['when@' . $env], $path);
            } finally {
                $this->env = $env;
            }
        }
    } finally {
        --$this->importing;
    }
    $this->loadExtensionConfigs();
    return null;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal