function ModuleInstaller::updateKernel

Same name in other branches
  1. 9 core/lib/Drupal/Core/Extension/ModuleInstaller.php \Drupal\Core\Extension\ModuleInstaller::updateKernel()
  2. 8.9.x core/lib/Drupal/Core/Extension/ModuleInstaller.php \Drupal\Core\Extension\ModuleInstaller::updateKernel()
  3. 11.x core/lib/Drupal/Core/Extension/ModuleInstaller.php \Drupal\Core\Extension\ModuleInstaller::updateKernel()

Updates the kernel module list.

Parameters

\Drupal\Core\Extension\Extension[] $module_filenames: The list of installed modules.

2 calls to ModuleInstaller::updateKernel()
ModuleInstaller::install in core/lib/Drupal/Core/Extension/ModuleInstaller.php
ModuleInstaller::uninstall in core/lib/Drupal/Core/Extension/ModuleInstaller.php

File

core/lib/Drupal/Core/Extension/ModuleInstaller.php, line 615

Class

ModuleInstaller
Default implementation of the module installer.

Namespace

Drupal\Core\Extension

Code

protected function updateKernel($module_filenames) {
    // Save current state of config installer, so it can be restored after the
    // container is rebuilt.
    
    /** @var \Drupal\Core\Config\ConfigInstallerInterface $config_installer */
    $config_installer = $this->kernel
        ->getContainer()
        ->get('config.installer');
    $sync_status = $config_installer->isSyncing();
    $source_storage = $config_installer->getSourceStorage();
    // This reboots the kernel to register the module's bundle and its services
    // in the service container. The $module_filenames argument is taken over as
    // %container.modules% parameter, which is passed to a fresh ModuleHandler
    // instance upon first retrieval.
    $this->kernel
        ->updateModules($module_filenames, $module_filenames);
    // After rebuilding the container we need to update the injected
    // dependencies.
    $container = $this->kernel
        ->getContainer();
    $this->moduleHandler = $container->get('module_handler');
    $this->connection = $container->get('database');
    $this->updateRegistry = $container->get('update.update_hook_registry');
    // Restore state of config installer.
    if ($sync_status) {
        $container->get('config.installer')
            ->setSyncing(TRUE)
            ->setSourceStorage($source_storage);
    }
}

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