You are here

public function YamlFileLoader::load in Zircon Profile 8.0

Same name in this branch
  1. 8.0 vendor/symfony/routing/Loader/YamlFileLoader.php \Symfony\Component\Routing\Loader\YamlFileLoader::load()
  2. 8.0 vendor/symfony/translation/Loader/YamlFileLoader.php \Symfony\Component\Translation\Loader\YamlFileLoader::load()
  3. 8.0 vendor/symfony/dependency-injection/Loader/YamlFileLoader.php \Symfony\Component\DependencyInjection\Loader\YamlFileLoader::load()
  4. 8.0 core/lib/Drupal/Core/DependencyInjection/YamlFileLoader.php \Drupal\Core\DependencyInjection\YamlFileLoader::load()
Same name and namespace in other branches
  1. 8 vendor/symfony/dependency-injection/Loader/YamlFileLoader.php \Symfony\Component\DependencyInjection\Loader\YamlFileLoader::load()

File

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

Class

YamlFileLoader
YamlFileLoader loads YAML files service definitions.

Namespace

Symfony\Component\DependencyInjection\Loader

Code

public function load($resource, $type = null) {
  $path = $this->locator
    ->locate($resource);
  $content = $this
    ->loadFile($path);
  $this->container
    ->addResource(new FileResource($path));

  // empty file
  if (null === $content) {
    return;
  }

  // imports
  $this
    ->parseImports($content, $path);

  // parameters
  if (isset($content['parameters'])) {
    if (!is_array($content['parameters'])) {
      throw new InvalidArgumentException(sprintf('The "parameters" key should contain an array in %s. Check your YAML syntax.', $resource));
    }
    foreach ($content['parameters'] as $key => $value) {
      $this->container
        ->setParameter($key, $this
        ->resolveServices($value));
    }
  }

  // extensions
  $this
    ->loadFromExtensions($content);

  // services
  $this
    ->parseDefinitions($content, $resource);
}