W3cubDocs

/Drupal 8

function template_preprocess_system_modules_uninstall

template_preprocess_system_modules_uninstall(&$variables)

Prepares variables for module uninstall templates.

Default template: system-modules-uninstall.html.twig.

Parameters

$variables: An associative array containing:

  • 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.

Related topics

Theme system overview
Functions and templates for the user interface that themes can override.

File

core/modules/system/system.admin.inc, line 266
Admin page callbacks for the system module.

Code

function template_preprocess_system_modules_uninstall(&$variables) {
  $form = $variables['form'];
  $variables['modules'] = [];

  // 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'];

    if (!empty($module['#validation_reasons'])) {
      $module['validation_reasons'] = $module['#validation_reasons'];
      $module['reasons_count'] = count($module['validation_reasons']);
    }
    else {
      $module['reasons_count'] = 0;
    }
    if (!empty($module['#required_by'])) {
      $module['required_by'] = $module['#required_by'];
      $module['reasons_count'] = $module['reasons_count'] + 1;
    }
    $module['attributes'] = new Attribute($module['#attributes']);
    $variables['modules'][] = $module;
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!system!system.admin.inc/function/template_preprocess_system_modules_uninstall/8.1.x