function InstallerKernel::initializeContainer

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/Installer/InstallerKernel.php \Drupal\Core\Installer\InstallerKernel::initializeContainer()
  2. 10 core/lib/Drupal/Core/Installer/InstallerKernel.php \Drupal\Core\Installer\InstallerKernel::initializeContainer()
  3. 9 core/lib/Drupal/Core/Installer/InstallerKernel.php \Drupal\Core\Installer\InstallerKernel::initializeContainer()
  4. 8.9.x core/lib/Drupal/Core/Installer/InstallerKernel.php \Drupal\Core\Installer\InstallerKernel::initializeContainer()

Initializes the service container.

Return value

\Symfony\Component\DependencyInjection\ContainerInterface An initialized container object.

Overrides DrupalKernel::initializeContainer

File

core/lib/Drupal/Core/Installer/InstallerKernel.php, line 24

Class

InstallerKernel
Extend DrupalKernel to handle force some kernel behaviors.

Namespace

Drupal\Core\Installer

Code

protected function initializeContainer() {
  // Ensure the InstallerKernel's container is not dumped.
  $this->allowDumping = FALSE;
  // During installation, initializeContainer() can be called multiple times
  // without any module changes in between. Since allowDumping is FALSE, no
  // cached container exists, so the parent will always recompile.
  $extensions = $this->getExtensions();
  if (isset($this->container) && count($extensions['module'] ?? []) === count($this->compiledExtensions['module'] ?? []) && count($extensions['theme'] ?? []) === count($this->compiledExtensions['theme'] ?? []) && !array_diff_key($extensions['module'] ?? [], $this->compiledExtensions['module'] ?? []) && !array_diff_key($extensions['theme'] ?? [], $this->compiledExtensions['theme'] ?? [])) {
    $this->containerNeedsRebuild = FALSE;
    return $this->container;
  }
  else {
    $this->containerNeedsRebuild = TRUE;
    $this->compiledExtensions = $extensions;
    return parent::initializeContainer();
  }
}

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