DrupalKernel::updateModules

public DrupalKernel::updateModules(array $module_list, array $module_filenames = array())

Implements Drupal\Core\DrupalKernelInterface::updateModules().

@todo Remove obsolete $module_list parameter. Only $module_filenames is needed.

Overrides DrupalKernelInterface::updateModules

File

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

Class

DrupalKernel
The DrupalKernel class is the core of Drupal itself.

Namespace

Drupal\Core

Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
public function updateModules(array $module_list, array $module_filenames = array()) {
  $pre_existing_module_namespaces = [];
  if ($this->booted && is_array($this->moduleList)) {
    $pre_existing_module_namespaces = $this->getModuleNamespacesPsr4($this->getModuleFileNames());
  }
  $this->moduleList = $module_list;
  foreach ($module_filenames as $name => $extension) {
    $this->moduleData[$name] = $extension;
  }
 
  // If we haven't yet booted, we don't need to do anything: the new module
  // list will take effect when boot() is called. However we set a
  // flag that the container needs a rebuild, so that a potentially cached
  // container is not used. If we have already booted, then rebuild the
  // container in order to refresh the serviceProvider list and container.
  $this->containerNeedsRebuild = TRUE;
  if ($this->booted) {
    // We need to register any new namespaces to a new class loader because
    // the current class loader might have stored a negative result for a
    // class that is now available.
    // @see \Composer\Autoload\ClassLoader::findFile()
    $new_namespaces = array_diff_key(
    $this->getModuleNamespacesPsr4($this->getModuleFileNames()),
    $pre_existing_module_namespaces
    );
    if (!empty($new_namespaces)) {
      $additional_class_loader = new ClassLoader();
      $this->classLoaderAddMultiplePsr4($new_namespaces, $additional_class_loader);
      $additional_class_loader->register();
    }
 
    $this->initializeContainer();
  }
}
doc_Drupal
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.