protected function YamlFileLoader::resolveServices

Same name in this branch
  1. 8.x drupal/core/lib/Drupal/Core/DependencyInjection/YamlFileLoader.php \Drupal\Core\DependencyInjection\YamlFileLoader::resolveServices()
  2. 8.x drupal/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php \Symfony\Component\DependencyInjection\Loader\YamlFileLoader::resolveServices()

Resolves services.

Copied from \Symfony\Component\DependencyInjection\Loader\YamlFileLoader::parseDefinition().

Parameters

mixed $value: If a string, then it is either a plain string (for example a class name) or a reference to a service. If it's an array then it's a list of such strings.

Return value

string|\Symfony\Component\DependencyInjection\Reference Either the string unchanged or the Reference object.

2 calls to YamlFileLoader::resolveServices()
YamlFileLoader::load in drupal/core/lib/Drupal/Core/DependencyInjection/YamlFileLoader.php
Load a YAML file containing service definitions and kernel parameters.
YamlFileLoader::parseDefinition in drupal/core/lib/Drupal/Core/DependencyInjection/YamlFileLoader.php
Parses a definition.

File

drupal/core/lib/Drupal/Core/DependencyInjection/YamlFileLoader.php, line 227
Contains \Drupal\Core\DependencyInjection\YamlFileLoader.

Class

YamlFileLoader
YamlFileLoader loads YAML files service definitions.

Namespace

Drupal\Core\DependencyInjection

Code

protected function resolveServices($value) {
  if (is_array($value)) {
    $value = array_map(array(
      $this,
      'resolveServices',
    ), $value);
  }
  elseif (is_string($value) && 0 === strpos($value, '@')) {
    if (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;
    }
    $value = new Reference($value, $invalidBehavior, $strict);
  }
  return $value;
}