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

Breadcrumb

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

function YamlFileLoader::parseDefinitions

Same name in this branch
  1. 11.1.x core/lib/Drupal/Core/DependencyInjection/YamlFileLoader.php \Drupal\Core\DependencyInjection\YamlFileLoader::parseDefinitions()
1 call to YamlFileLoader::parseDefinitions()
YamlFileLoader::loadContent in vendor/symfony/dependency-injection/Loader/YamlFileLoader.php

File

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

Class

YamlFileLoader
YamlFileLoader loads YAML files service definitions.

Namespace

Symfony\Component\DependencyInjection\Loader

Code

private function parseDefinitions(array $content, string $file, bool $trackBindings = true) : void {
    if (!isset($content['services'])) {
        return;
    }
    if (!\is_array($content['services'])) {
        throw new InvalidArgumentException(\sprintf('The "services" key should contain an array in "%s". Check your YAML syntax.', $file));
    }
    if (\array_key_exists('_instanceof', $content['services'])) {
        $instanceof = $content['services']['_instanceof'];
        unset($content['services']['_instanceof']);
        if (!\is_array($instanceof)) {
            throw new InvalidArgumentException(\sprintf('Service "_instanceof" key must be an array, "%s" given in "%s".', get_debug_type($instanceof), $file));
        }
        $this->instanceof = [];
        $this->isLoadingInstanceof = true;
        foreach ($instanceof as $id => $service) {
            if (!$service || !\is_array($service)) {
                throw new InvalidArgumentException(\sprintf('Type definition "%s" must be a non-empty array within "_instanceof" in "%s". Check your YAML syntax.', $id, $file));
            }
            if (\is_string($service) && str_starts_with($service, '@')) {
                throw new InvalidArgumentException(\sprintf('Type definition "%s" cannot be an alias within "_instanceof" in "%s". Check your YAML syntax.', $id, $file));
            }
            $this->parseDefinition($id, $service, $file, [], false, $trackBindings);
        }
    }
    $this->isLoadingInstanceof = false;
    $defaults = $this->parseDefaults($content, $file);
    foreach ($content['services'] as $id => $service) {
        $this->parseDefinition($id, $service, $file, $defaults, false, $trackBindings);
    }
}

API Navigation

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