function ContainerBuilder::set

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php \Drupal\Core\DependencyInjection\ContainerBuilder::set()
  2. 10 core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php \Drupal\Core\DependencyInjection\ContainerBuilder::set()
  3. 11.x core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php \Drupal\Core\DependencyInjection\ContainerBuilder::set()

Overrides Symfony\Component\DependencyInjection\ContainerBuilder::set().

Drupal's container builder can be used at runtime after compilation, so we override Symfony's ContainerBuilder's restriction on setting services in a frozen builder.

@todo Restrict this to synthetic services only. Ideally, the upstream ContainerBuilder class should be fixed to allow setting synthetic services in a frozen builder.

File

core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php, line 43

Class

ContainerBuilder
Drupal's dependency injection container builder.

Namespace

Drupal\Core\DependencyInjection

Code

public function set($id, $service) {
    SymfonyContainer::set($id, $service);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.