function ThemeInstaller::uninstall
Same name and namespace in other branches
- 11.x core/lib/Drupal/Core/Extension/ThemeInstaller.php \Drupal\Core\Extension\ThemeInstaller::uninstall()
- 10 core/lib/Drupal/Core/Extension/ThemeInstaller.php \Drupal\Core\Extension\ThemeInstaller::uninstall()
- 9 core/lib/Drupal/Core/Extension/ThemeInstaller.php \Drupal\Core\Extension\ThemeInstaller::uninstall()
- 8.9.x core/lib/Drupal/Core/Extension/ThemeInstaller.php \Drupal\Core\Extension\ThemeInstaller::uninstall()
Uninstalls a given list of themes.
Uninstalling a theme removes all related configuration (like blocks) and invokes the 'themes_uninstalled' hook.
Themes are allowed to be uninstalled even when their code has been removed from the filesystem, this is because themes do not allow uninstall hooks to be defined.
Parameters
array $theme_list: The themes to uninstall.
Overrides ThemeInstallerInterface::uninstall
File
-
core/
lib/ Drupal/ Core/ Extension/ ThemeInstaller.php, line 247
Class
- ThemeInstaller
- Manages theme installation/uninstallation.
Namespace
Drupal\Core\ExtensionCode
public function uninstall(array $theme_list) {
// Validate the request without adding sub-themes: callers must list them
// explicitly, see ::getThemesToUninstall() to resolve them beforehand.
$theme_list = $this->getThemesToUninstall($theme_list, FALSE);
$extension_config = $this->configFactory
->getEditable('core.extension');
$installed_themes = $extension_config->get('theme') ?: [];
$theme_data = $this->themeExtensionList
->reset()
->getList();
$this->cssCollectionOptimizer
->deleteAll();
foreach ($theme_list as $key) {
// The value is not used; the weight is ignored for themes currently.
$extension_config->clear("theme.{$key}");
// Remove all configuration belonging to the theme.
$this->configManager
->uninstall('theme', $key);
}
$extension_config->save();
// Refresh theme info.
$this->themeHandler
->reset();
// Remove themes that were uninstalled from the list.
$register_themes = array_diff(array_keys($installed_themes), $theme_list);
// Get list of extensions for the new list of themes.
$register_themes = array_intersect_key($theme_data, array_flip($register_themes));
$this->resetSystem($register_themes);
$this->moduleHandler
->invokeAll('themes_uninstalled', [
$theme_list,
]);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.