public function ModuleRequiredByThemesUninstallValidator::validate in Drupal 9
Same name in this branch
- 9 core/lib/Drupal/Core/Extension/ModuleRequiredByThemesUninstallValidator.php \Drupal\Core\Extension\ModuleRequiredByThemesUninstallValidator::validate()
- 9 core/lib/Drupal/Core/ProxyClass/Extension/ModuleRequiredByThemesUninstallValidator.php \Drupal\Core\ProxyClass\Extension\ModuleRequiredByThemesUninstallValidator::validate()
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Extension/ModuleRequiredByThemesUninstallValidator.php \Drupal\Core\Extension\ModuleRequiredByThemesUninstallValidator::validate()
Determines the reasons a module can not be uninstalled.
Parameters
string $module: A module name.
Return value
string[] An array of reasons the module can not be uninstalled, empty if it can. Each reason should not end with any punctuation since multiple reasons can be displayed together.
Overrides ModuleUninstallValidatorInterface::validate
See also
template_preprocess_system_modules_uninstall()
File
- core/
lib/ Drupal/ Core/ Extension/ ModuleRequiredByThemesUninstallValidator.php, line 48
Class
- ModuleRequiredByThemesUninstallValidator
- Ensures modules cannot be uninstalled if enabled themes depend on them.
Namespace
Drupal\Core\ExtensionCode
public function validate($module) {
$reasons = [];
$themes_depending_on_module = $this
->getThemesDependingOnModule($module);
if (!empty($themes_depending_on_module)) {
$module_name = $this->moduleExtensionList
->get($module)->info['name'];
$theme_names = implode(', ', $themes_depending_on_module);
$reasons[] = $this
->formatPlural(count($themes_depending_on_module), 'Required by the theme: @theme_names', 'Required by the themes: @theme_names', [
'@module_name' => $module_name,
'@theme_names' => $theme_names,
]);
}
return $reasons;
}