You are here

public function CheckReferenceValidityPass::process in Zircon Profile 8

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

Processes the ContainerBuilder to validate References.

Parameters

ContainerBuilder $container:

Overrides CompilerPassInterface::process

File

vendor/symfony/dependency-injection/Compiler/CheckReferenceValidityPass.php, line 45

Class

CheckReferenceValidityPass
Checks the validity of references.

Namespace

Symfony\Component\DependencyInjection\Compiler

Code

public function process(ContainerBuilder $container) {
  $this->container = $container;
  $children = $this->container
    ->getScopeChildren();
  $ancestors = array();
  $scopes = $this->container
    ->getScopes();
  foreach ($scopes as $name => $parent) {
    $ancestors[$name] = array(
      $parent,
    );
    while (isset($scopes[$parent])) {
      $ancestors[$name][] = $parent = $scopes[$parent];
    }
  }
  foreach ($container
    ->getDefinitions() as $id => $definition) {
    if ($definition
      ->isSynthetic() || $definition
      ->isAbstract()) {
      continue;
    }
    $this->currentId = $id;
    $this->currentScope = $scope = $definition
      ->getScope();
    if (ContainerInterface::SCOPE_CONTAINER === $scope) {
      $this->currentScopeChildren = array_keys($scopes);
      $this->currentScopeAncestors = array();
    }
    elseif (ContainerInterface::SCOPE_PROTOTYPE !== $scope) {
      $this->currentScopeChildren = isset($children[$scope]) ? $children[$scope] : array();
      $this->currentScopeAncestors = isset($ancestors[$scope]) ? $ancestors[$scope] : array();
    }
    $this
      ->validateReferences($definition
      ->getArguments());
    $this
      ->validateReferences($definition
      ->getMethodCalls());
    $this
      ->validateReferences($definition
      ->getProperties());
  }
}