You are here

public function CheckReferenceValidityPass::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/CheckReferenceValidityPass.php \Symfony\Component\DependencyInjection\Compiler\CheckReferenceValidityPass::process()

Processes the ContainerBuilder to validate References.

Parameters

ContainerBuilder $container:

Overrides CompilerPassInterface::process

File

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