You are here

public function ReplaceAliasByActualDefinitionPass::process in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/dependency-injection/Compiler/ReplaceAliasByActualDefinitionPass.php \Symfony\Component\DependencyInjection\Compiler\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

vendor/symfony/dependency-injection/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;
  }
}