You are here

public function ResolveInvalidReferencesPass::process in Service Container 7

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

Process the ContainerBuilder to resolve invalid references.

Parameters

ContainerBuilder $container:

Overrides CompilerPassInterface::process

File

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