You are here

private function ResolveInvalidReferencesPass::processArguments in Service Container 7.2

Same name and namespace in other branches
  1. 7 modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Compiler/ResolveInvalidReferencesPass.php \Symfony\Component\DependencyInjection\Compiler\ResolveInvalidReferencesPass::processArguments()

Processes arguments to determine invalid references.

Parameters

array $arguments An array of Reference objects:

bool $inMethodCall:

Return value

array

Throws

RuntimeException When the config is invalid

1 call to ResolveInvalidReferencesPass::processArguments()
ResolveInvalidReferencesPass::process in modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Compiler/ResolveInvalidReferencesPass.php
Process the ContainerBuilder to resolve invalid references.

File

modules/providers/service_container_symfony/lib/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;
}