public function ContainerBuilder::setAlias in Service Container 7.2
Same name and namespace in other branches
- 7 modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/ContainerBuilder.php \Symfony\Component\DependencyInjection\ContainerBuilder::setAlias()
Sets an alias for an existing service.
@api
Parameters
string $alias The alias to create:
string|Alias $id The service to alias:
Throws
InvalidArgumentException if the id is not a string or an Alias
InvalidArgumentException if the alias is for itself
1 call to ContainerBuilder::setAlias()
- ContainerBuilder::addAliases in modules/
providers/ service_container_symfony/ lib/ Symfony/ Component/ DependencyInjection/ ContainerBuilder.php - Adds the service aliases.
File
- modules/
providers/ service_container_symfony/ lib/ Symfony/ Component/ DependencyInjection/ ContainerBuilder.php, line 677
Class
- ContainerBuilder
- ContainerBuilder is a DI container that provides an API to easily describe services.
Namespace
Symfony\Component\DependencyInjectionCode
public function setAlias($alias, $id) {
$alias = strtolower($alias);
if (is_string($id)) {
$id = new Alias($id);
}
elseif (!$id instanceof Alias) {
throw new InvalidArgumentException('$id must be a string, or an Alias object.');
}
if ($alias === (string) $id) {
throw new InvalidArgumentException(sprintf('An alias can not reference itself, got a circular reference on "%s".', $alias));
}
unset($this->definitions[$alias]);
$this->aliasDefinitions[$alias] = $id;
}