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

Breadcrumb

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

function YamlFileLoader::parseImports

1 call to YamlFileLoader::parseImports()
YamlFileLoader::loadContent in vendor/symfony/dependency-injection/Loader/YamlFileLoader.php

File

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

Class

YamlFileLoader
YamlFileLoader loads YAML files service definitions.

Namespace

Symfony\Component\DependencyInjection\Loader

Code

private function parseImports(array $content, string $file) : void {
    if (!isset($content['imports'])) {
        return;
    }
    if (!\is_array($content['imports'])) {
        throw new InvalidArgumentException(\sprintf('The "imports" key should contain an array in "%s". Check your YAML syntax.', $file));
    }
    $defaultDirectory = \dirname($file);
    foreach ($content['imports'] as $import) {
        if (!\is_array($import)) {
            $import = [
                'resource' => $import,
            ];
        }
        if (!isset($import['resource'])) {
            throw new InvalidArgumentException(\sprintf('An import should provide a resource in "%s". Check your YAML syntax.', $file));
        }
        $this->setCurrentDir($defaultDirectory);
        $this->import($import['resource'], $import['type'] ?? null, $import['ignore_errors'] ?? false, $file);
    }
}

API Navigation

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