public function ReplaceAliasByActualDefinitionPass::process in Service Container 7
Same name and namespace in other branches
- 7.2 modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/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
- modules/
providers/ service_container_symfony/ lib/ Symfony/ Component/ DependencyInjection/ Compiler/ ReplaceAliasByActualDefinitionPass.php, line 37
Class
- ReplaceAliasByActualDefinitionPass
- Replaces aliases with actual service definitions, effectively removing these aliases.
Namespace
Symfony\Component\DependencyInjection\CompilerCode
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;
}
}