public function CheckReferenceValidityPass::process

Processes the ContainerBuilder to validate References.

Parameters

ContainerBuilder $container:

Overrides CompilerPassInterface::process

File

drupal/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/CheckReferenceValidityPass.php, line 46

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->currentDefinition = $definition;
    $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());
  }
}