function 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
File
- 
              core/lib/ Drupal/ Core/ Extension/ ModuleRequiredByThemesUninstallValidator.php, line 49 
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;
}Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
