public function ContainerBuilder::setAlias in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/dependency-injection/ContainerBuilder.php \Symfony\Component\DependencyInjection\ContainerBuilder::setAlias()
Sets an alias for an existing service.
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 vendor/
symfony/ dependency-injection/ ContainerBuilder.php - Adds the service aliases.
File
- vendor/
symfony/ dependency-injection/ ContainerBuilder.php, line 627
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;
}