private function ResolveInvalidReferencesPass::processArguments

Processes arguments to determine invalid references.

Parameters

array $arguments An array of Reference objects:

Boolean $inMethodCall:

Return value

array

Throws

RuntimeException When the config is invalid

1 call to ResolveInvalidReferencesPass::processArguments()
ResolveInvalidReferencesPass::process in drupal/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/ResolveInvalidReferencesPass.php
Process the ContainerBuilder to resolve invalid references.

File

drupal/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/ResolveInvalidReferencesPass.php, line 79

Class

ResolveInvalidReferencesPass
Emulates the invalid behavior if the reference is not found within the container.

Namespace

Symfony\Component\DependencyInjection\Compiler

Code

private function processArguments(array $arguments, $inMethodCall = false) {
  foreach ($arguments as $k => $argument) {
    if (is_array($argument)) {
      $arguments[$k] = $this
        ->processArguments($argument, $inMethodCall);
    }
    elseif ($argument instanceof Reference) {
      $id = (string) $argument;
      $invalidBehavior = $argument
        ->getInvalidBehavior();
      $exists = $this->container
        ->has($id);

      // resolve invalid behavior
      if (!$exists && ContainerInterface::NULL_ON_INVALID_REFERENCE === $invalidBehavior) {
        $arguments[$k] = null;
      }
      elseif (!$exists && ContainerInterface::IGNORE_ON_INVALID_REFERENCE === $invalidBehavior) {
        if ($inMethodCall) {
          throw new RuntimeException('Method shouldn\'t be called.');
        }
        $arguments[$k] = null;
      }
    }
  }
  return $arguments;
}