class AutoAliasServicePass in Service Container 7.2
Same name and namespace in other branches
- 7 modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Compiler/AutoAliasServicePass.php \Symfony\Component\DependencyInjection\Compiler\AutoAliasServicePass
Sets a service to be an alias of another one, given a format pattern.
Hierarchy
- class \Symfony\Component\DependencyInjection\Compiler\AutoAliasServicePass implements CompilerPassInterface
Expanded class hierarchy of AutoAliasServicePass
1 file declares its use of AutoAliasServicePass
- AutoAliasServicePassTest.php in modules/
providers/ service_container_symfony/ lib/ Symfony/ Component/ DependencyInjection/ Tests/ Compiler/ AutoAliasServicePassTest.php
File
- modules/
providers/ service_container_symfony/ lib/ Symfony/ Component/ DependencyInjection/ Compiler/ AutoAliasServicePass.php, line 21
Namespace
Symfony\Component\DependencyInjection\CompilerView source
class AutoAliasServicePass implements CompilerPassInterface {
/**
* {@inheritdoc}
*/
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));
}
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AutoAliasServicePass:: |
public | function |
You can modify the container here before it is dumped to PHP code. Overrides CompilerPassInterface:: |