function ModuleRequiredByThemesUninstallValidator::validateConfigImport

Same name in this branch
  1. 9 core/lib/Drupal/Core/ProxyClass/Extension/ModuleRequiredByThemesUninstallValidator.php \Drupal\Core\ProxyClass\Extension\ModuleRequiredByThemesUninstallValidator::validateConfigImport()
Same name in other branches
  1. 10 core/lib/Drupal/Core/ProxyClass/Extension/ModuleRequiredByThemesUninstallValidator.php \Drupal\Core\ProxyClass\Extension\ModuleRequiredByThemesUninstallValidator::validateConfigImport()
  2. 10 core/lib/Drupal/Core/Extension/ModuleRequiredByThemesUninstallValidator.php \Drupal\Core\Extension\ModuleRequiredByThemesUninstallValidator::validateConfigImport()
  3. 11.x core/lib/Drupal/Core/ProxyClass/Extension/ModuleRequiredByThemesUninstallValidator.php \Drupal\Core\ProxyClass\Extension\ModuleRequiredByThemesUninstallValidator::validateConfigImport()
  4. 11.x core/lib/Drupal/Core/Extension/ModuleRequiredByThemesUninstallValidator.php \Drupal\Core\Extension\ModuleRequiredByThemesUninstallValidator::validateConfigImport()

Overrides ConfigImportModuleUninstallValidatorInterface::validateConfigImport

File

core/lib/Drupal/Core/Extension/ModuleRequiredByThemesUninstallValidator.php, line 68

Class

ModuleRequiredByThemesUninstallValidator
Ensures modules cannot be uninstalled if enabled themes depend on them.

Namespace

Drupal\Core\Extension

Code

public function validateConfigImport(string $module, StorageInterface $source_storage) : array {
    $reasons = [];
    $themes_depending_on_module = $this->getThemesDependingOnModule($module);
    if (!empty($themes_depending_on_module)) {
        $installed_themes_after_import = $source_storage->read('core.extension')['theme'];
        $themes_depending_on_module_still_installed = array_intersect_key($themes_depending_on_module, $installed_themes_after_import);
        // Ensure that any dependent themes will be uninstalled by the module.
        if (!empty($themes_depending_on_module_still_installed)) {
            $reasons[] = $this->formatPlural(count($themes_depending_on_module_still_installed), 'Required by the theme: @theme_names', 'Required by the themes: @theme_names', [
                '@theme_names' => implode(', ', $themes_depending_on_module_still_installed),
            ]);
        }
    }
    return $reasons;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.