You are here

public function ResolveInvalidReferencesPass::process in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/dependency-injection/Compiler/ResolveInvalidReferencesPass.php \Symfony\Component\DependencyInjection\Compiler\ResolveInvalidReferencesPass::process()

Process the ContainerBuilder to resolve invalid references.

Parameters

ContainerBuilder $container:

Overrides CompilerPassInterface::process

File

vendor/symfony/dependency-injection/Compiler/ResolveInvalidReferencesPass.php, line 34

Class

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

Namespace

Symfony\Component\DependencyInjection\Compiler

Code

public function process(ContainerBuilder $container) {
  $this->container = $container;
  foreach ($container
    ->getDefinitions() as $definition) {
    if ($definition
      ->isSynthetic() || $definition
      ->isAbstract()) {
      continue;
    }
    $definition
      ->setArguments($this
      ->processArguments($definition
      ->getArguments()));
    $calls = array();
    foreach ($definition
      ->getMethodCalls() as $call) {
      try {
        $calls[] = array(
          $call[0],
          $this
            ->processArguments($call[1], true),
        );
      } catch (RuntimeException $e) {

        // this call is simply removed
      }
    }
    $definition
      ->setMethodCalls($calls);
    $properties = array();
    foreach ($definition
      ->getProperties() as $name => $value) {
      try {
        $value = $this
          ->processArguments(array(
          $value,
        ), true);
        $properties[$name] = reset($value);
      } catch (RuntimeException $e) {

        // ignore property
      }
    }
    $definition
      ->setProperties($properties);
  }
}