Sets an alias for an existing service.
@api
string $alias The alias to create:
string|Alias $id The service to alias:
InvalidArgumentException if the id is not a string or an Alias
InvalidArgumentException if the alias is for itself
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 === strtolower($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;
}