function YamlFileLoader::resolveServices

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/DependencyInjection/YamlFileLoader.php \Drupal\Core\DependencyInjection\YamlFileLoader::resolveServices()
  2. 10 core/lib/Drupal/Core/DependencyInjection/YamlFileLoader.php \Drupal\Core\DependencyInjection\YamlFileLoader::resolveServices()
  3. 11.x core/lib/Drupal/Core/DependencyInjection/YamlFileLoader.php \Drupal\Core\DependencyInjection\YamlFileLoader::resolveServices()

Resolves services.

Parameters

string|array $value:

Return value

array|string|Reference

2 calls to YamlFileLoader::resolveServices()
YamlFileLoader::load in core/lib/Drupal/Core/DependencyInjection/YamlFileLoader.php
Loads a Yaml file.
YamlFileLoader::parseDefinition in core/lib/Drupal/Core/DependencyInjection/YamlFileLoader.php
Parses a definition.

File

core/lib/Drupal/Core/DependencyInjection/YamlFileLoader.php, line 466

Class

YamlFileLoader
YamlFileLoader loads YAML files service definitions.

Namespace

Drupal\Core\DependencyInjection

Code

private function resolveServices($value) {
    if (is_array($value)) {
        $value = array_map(array(
            $this,
            'resolveServices',
        ), $value);
    }
    elseif (is_string($value) && 0 === strpos($value, '@=')) {
        // Not supported.
        
        //return new Expression(substr($value, 2));
        throw new InvalidArgumentException(sprintf("'%s' is an Expression, but expressions are not supported.", $value));
    }
    elseif (is_string($value) && 0 === strpos($value, '@')) {
        if (0 === strpos($value, '@@')) {
            $value = substr($value, 1);
            $invalidBehavior = null;
        }
        elseif (0 === strpos($value, '@?')) {
            $value = substr($value, 2);
            $invalidBehavior = ContainerInterface::IGNORE_ON_INVALID_REFERENCE;
        }
        else {
            $value = substr($value, 1);
            $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE;
        }
        if ('=' === substr($value, -1)) {
            $value = substr($value, 0, -1);
            $strict = false;
        }
        else {
            $strict = true;
        }
        if (null !== $invalidBehavior) {
            $value = new Reference($value, $invalidBehavior, $strict);
        }
    }
    return $value;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.