You are here

public function ContainerBuilder::setDefinition in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/dependency-injection/ContainerBuilder.php \Symfony\Component\DependencyInjection\ContainerBuilder::setDefinition()

Sets a service definition.

Parameters

string $id The service identifier:

Definition $definition A Definition instance:

Return value

Definition the service definition

Throws

BadMethodCallException When this ContainerBuilder is frozen

2 calls to ContainerBuilder::setDefinition()
ContainerBuilder::addDefinitions in vendor/symfony/dependency-injection/ContainerBuilder.php
Adds the service definitions.
ContainerBuilder::register in vendor/symfony/dependency-injection/ContainerBuilder.php
Registers a service definition.

File

vendor/symfony/dependency-injection/ContainerBuilder.php, line 757

Class

ContainerBuilder
ContainerBuilder is a DI container that provides an API to easily describe services.

Namespace

Symfony\Component\DependencyInjection

Code

public function setDefinition($id, Definition $definition) {
  if ($this
    ->isFrozen()) {
    throw new BadMethodCallException('Adding definition to a frozen container is not allowed');
  }
  $id = strtolower($id);
  unset($this->aliasDefinitions[$id]);
  return $this->definitions[$id] = $definition;
}