You are here

public function AutoAliasServicePass::process in Zircon Profile 8

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

You can modify the container here before it is dumped to PHP code.

Parameters

ContainerBuilder $container:

Overrides CompilerPassInterface::process

File

vendor/symfony/dependency-injection/Compiler/AutoAliasServicePass.php, line 26

Class

AutoAliasServicePass
Sets a service to be an alias of another one, given a format pattern.

Namespace

Symfony\Component\DependencyInjection\Compiler

Code

public function process(ContainerBuilder $container) {
  foreach ($container
    ->findTaggedServiceIds('auto_alias') as $serviceId => $tags) {
    foreach ($tags as $tag) {
      if (!isset($tag['format'])) {
        throw new InvalidArgumentException(sprintf('Missing tag information "format" on auto_alias service "%s".', $serviceId));
      }
      $aliasId = $container
        ->getParameterBag()
        ->resolveValue($tag['format']);
      if ($container
        ->hasDefinition($aliasId) || $container
        ->hasAlias($aliasId)) {
        $container
          ->setAlias($serviceId, new Alias($aliasId));
      }
    }
  }
}