function DrupalKernel::updateThemes
Updates the kernel's list of themes to the new list.
The kernel needs to update its list and container to match the new list.
array<string, \Drupal\Core\Extension\Extension> $register_themes List of theme extensions, keyed by theme name.
Overrides DrupalKernelInterface::updateThemes
File
-
core/
lib/ Drupal/ Core/ DrupalKernel.php, line 900
Class
- DrupalKernel
- The DrupalKernel class is the core of Drupal itself.
Namespace
Drupal\CoreCode
public function updateThemes(array $register_themes = []) : void {
$pre_existing_theme_namespaces = [];
if ($this->booted && isset($this->themeList)) {
$pre_existing_theme_namespaces = $this->getExtensionNamespacesPsr4($this->getExtensionFileNames($this->themeList, [
$this,
'themeExtensions',
]));
}
$this->themeList = $register_themes;
foreach ($register_themes as $name => $extension) {
$this->themeExtensions[$name] = $extension;
}
// If we haven't yet booted, we don't need to do anything: the new theme
// 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->getExtensionNamespacesPsr4($this->getExtensionFileNames($this->themeList, [
$this,
'themeExtensions',
])), $pre_existing_theme_namespaces);
if (!empty($new_namespaces)) {
$additional_class_loader = new ClassLoader();
$this->classLoaderAddMultiplePsr4($new_namespaces, $additional_class_loader);
$additional_class_loader->register();
}
$this->initializeContainer();
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.