public function ResolveInvalidReferencesPass::process

Process the ContainerBuilder to resolve invalid references.

Parameters

ContainerBuilder $container:

Overrides CompilerPassInterface::process

File

drupal/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/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 $ignore) {

        // 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 $ignore) {

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