public function ReplaceAliasByActualDefinitionPass::process

Process the Container to replace aliases with service definitions.

Parameters

ContainerBuilder $container:

Throws

InvalidArgumentException if the service definition does not exist

Overrides CompilerPassInterface::process

File

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

Class

ReplaceAliasByActualDefinitionPass
Replaces aliases with actual service definitions, effectively removing these aliases.

Namespace

Symfony\Component\DependencyInjection\Compiler

Code

public function process(ContainerBuilder $container) {
  $this->compiler = $container
    ->getCompiler();
  $this->formatter = $this->compiler
    ->getLoggingFormatter();
  foreach ($container
    ->getAliases() as $id => $alias) {
    $aliasId = (string) $alias;
    try {
      $definition = $container
        ->getDefinition($aliasId);
    } catch (InvalidArgumentException $e) {
      throw new InvalidArgumentException(sprintf('Unable to replace alias "%s" with "%s".', $alias, $id), null, $e);
    }
    if ($definition
      ->isPublic()) {
      continue;
    }
    $definition
      ->setPublic(true);
    $container
      ->setDefinition($id, $definition);
    $container
      ->removeDefinition($aliasId);
    $this
      ->updateReferences($container, $aliasId, $id);

    // we have to restart the process due to concurrent modification of
    // the container
    $this
      ->process($container);
    break;
  }
}