You are here

function _get_module_list in General Data Protection Regulation 8

Same name and namespace in other branches
  1. 8.2 gdpr.module \_get_module_list()
  2. 7 gdpr.module \_get_module_list()

Returns a HTML markup for data_collecting modules checkpoint description.

Parameters

string $type: Type of modules to search for.

Return value

string HTML markup string

1 call to _get_module_list()
gdpr_checklistapi_checklist_items in ./gdpr.module
Callback for gdpr_checklistapi_checklist_info().

File

./gdpr.module, line 352
Module file.

Code

function _get_module_list($type) {
  $c_modules = _get_module_list_by_type($type);
  $renderer = \Drupal::service('renderer');
  $modules_list = [
    '#theme' => 'item_list',
    '#items' => [],
  ];
  $module_statuses = _get_module_statuses();
  $all_modules = _get_modules();
  $color_classes = [
    -1 => 'admin-enabled',
    0 => 'admin-enabled',
    1 => 'admin-missing',
  ];
  foreach ($c_modules as $c_module) {
    if (isset($all_modules[$c_module])) {
      $status_class = $color_classes[$all_modules[$c_module]['status']];
      $status = [
        '#prefix' => '<span class="' . $status_class . '">',
        '#suffix' => '</span>',
        '#markup' => $module_statuses[$all_modules[$c_module]['status']],
      ];
      $modules_list['#items'][] = t('@title (@status)', [
        '@title' => $all_modules[$c_module]['name'],
        '@status' => $renderer
          ->renderPlain($status),
      ]);
    }
  }
  return $renderer
    ->renderPlain($modules_list);
}