You are here

public function DrupalKernel::setContainer in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/DrupalKernel.php \Drupal\Core\DrupalKernel::setContainer()
  2. 10 core/lib/Drupal/Core/DrupalKernel.php \Drupal\Core\DrupalKernel::setContainer()

File

core/lib/Drupal/Core/DrupalKernel.php, line 528

Class

DrupalKernel
The DrupalKernel class is the core of Drupal itself.

Namespace

Drupal\Core

Code

public function setContainer(ContainerInterface $container = NULL) {
  if (isset($this->container)) {
    throw new \Exception('The container should not override an existing container.');
  }
  if ($this->booted) {
    throw new \Exception('The container cannot be set after a booted kernel.');
  }
  $this->container = $container;
  return $this;
}