You are here

public function ContainerBuilder::setDefinition in Service Container 7

Same name and namespace in other branches
  1. 7.2 modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/ContainerBuilder.php \Symfony\Component\DependencyInjection\ContainerBuilder::setDefinition()

Sets a service definition.

@api

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 modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/ContainerBuilder.php
Adds the service definitions.
ContainerBuilder::register in modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/ContainerBuilder.php
Registers a service definition.

File

modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/ContainerBuilder.php, line 825

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;
}