diff --git a/core/lib/Drupal/Core/Extension/ModuleUninstallValidatorInterface.php b/core/lib/Drupal/Core/Extension/ModuleUninstallValidatorInterface.php index 7fcfebe..63599bb 100644 --- a/core/lib/Drupal/Core/Extension/ModuleUninstallValidatorInterface.php +++ b/core/lib/Drupal/Core/Extension/ModuleUninstallValidatorInterface.php @@ -41,7 +41,7 @@ * Each reason should not end with any punctuation since multiple reasons * can be displayed together. * - * @see theme_system_modules_uninstall() + * @see template_preprocess_system_modules_uninstall() */ public function validate($module); } diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc index efa1f5c..5b391e7 100644 --- a/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -248,83 +248,50 @@ function template_preprocess_system_modules_details(&$variables) { } /** - * Returns HTML for a table of currently disabled modules. + * Prepares variables for module uninstall templates. + * + * Default template: system-modules-uninstall.html.twig. * * @param $variables * An associative array containing: - * - form: A render element representing the form. + * - form: A render element representing the form. Child elements of the form + * are individual modules. Each module is an associative array containing + * the following elements: + * - #module_name: The name of the module as a string. + * - name: The name of the module in a renderable array. + * - description: A description of the module. + * - #required_by: (optional) A list of modules that require the module. + * - #validation_reasons: (optional) Additional reasons why the module + * cannot be uninstalled. + * - #attributes: A list of attributes for the module wrapper. * * @ingroup themeable */ -function theme_system_modules_uninstall($variables) { +function template_preprocess_system_modules_uninstall(&$variables) { $form = $variables['form']; + $variables['modules'] = []; - // No theming for the confirm form. - if (isset($form['confirm'])) { - return drupal_render($form); - } - - // Table headers. - $header = array(t('Uninstall'), - t('Name'), - t('Description'), - ); + // Iterate through all the modules, which are children of this element. + foreach (Element::children($form['modules']) as $key) { + $module = $form['modules'][$key]; + $module['module_name'] = $module['#module_name']; + $module['checkbox'] = $form['uninstall'][$key]; + $module['checkbox_id'] = $form['uninstall'][$key]['#id']; - // Display table. - $rows = array(); - foreach (Element::children($form['modules']) as $module) { - $disabled_header = ''; - $disabled_reasons = ''; - // Add the modules requiring the module in question as a validation reason. - if (!empty($form['modules'][$module]['#required_by'])) { - $form['modules'][$module]['#validation_reasons'][] = \Drupal::translation()->translate('Required by: @modules', array('@modules' => implode(', ',$form['modules'][$module]['#required_by']))); + if (!empty($module['#validation_reasons'])) { + $module['validation_reasons'] = $module['#validation_reasons']; + $module['reasons_count'] = count($module['validation_reasons']); } - if (!empty($form['modules'][$module]['#validation_reasons'])) { - $disabled_reasons = [ - '#theme' => 'item_list', - '#items' => $form['modules'][$module]['#validation_reasons'], - ]; - $disabled_reasons = drupal_render($disabled_reasons); - $disabled_header = \Drupal::translation()->formatPlural(count($form['modules'][$module]['#validation_reasons']), - 'The following reason prevents @module from being uninstalled:', - 'The following reasons prevents @module from being uninstalled:', - array('@module' => $form['modules'][$module]['#module_name'])); + else { + $module['reasons_count'] = 0; } - $rows[] = array( - array('data' => drupal_render($form['uninstall'][$module]), 'align' => 'center'), - array( - 'data' => array( - '#type' => 'inline_template', - '#template' => '', - '#context' => array('module_id' => $form['uninstall'][$module]['#id'], 'module_name' => drupal_render($form['modules'][$module]['name'])), - ) - ), - array( - 'data' => array( - '#type' => 'inline_template', - '#template' => '{{ module_description }}{% if disabled_header is not empty %}
{{ 'Uninstall'|t }} | +{{ 'Name'|t }} | +{{ 'Description'|t }} | +
---|---|---|
+ {{- module.checkbox -}} + | ++ + | +
+ {{ module.description }}
+ {% if module.reasons_count > 0 %}
+
+ {%- trans -%}
+ The following reason prevents {{ module.module_name }} from being uninstalled:
+ {%- plural module.reasons_count -%}
+ The following reasons prevent {{ module.module_name }} from being uninstalled:
+ {%- endtrans %}
+
+ {% endif %}
+
+
+
|
+