function gdpr_get_gdpr_module_description in General Data Protection Regulation 3.0.x
Returns a HTML markup for gdpr_modules checkpoint description.
Return value
string HTML markup string
1 call to gdpr_get_gdpr_module_description()
- gdpr_checklistapi_checklist_items in ./
gdpr.module - Callback for gdpr_checklistapi_checklist_info().
File
- ./
gdpr.module, line 263 - Module file.
Code
function gdpr_get_gdpr_module_description() {
$all_modules = gdpr_get_modules();
$renderer = Drupal::service('renderer');
$module_handler = \Drupal::service('module_handler');
$module_path = $module_handler
->getModule(basename(__FILE__, '.module'))
->getPath();
$gdpr_module_names = array_diff(scandir($module_path . '/modules'), [
'..',
'.',
]);
$gdpr_modules_list = [
'#theme' => 'item_list',
'#items' => [],
];
$module_statuses = gdpr_get_module_statuses();
$color_classes = [
-1 => 'admin-missing',
0 => 'admin-missing',
1 => 'admin-enabled',
];
foreach ($gdpr_module_names as $module_name) {
if (isset($all_modules[$module_name])) {
if (!$all_modules[$module_name]['status']) {
$status_class = $color_classes[$all_modules[$module_name]['status']];
$status = [
'#prefix' => '<span class="' . $status_class . '">',
'#suffix' => '</span>',
'#markup' => $module_statuses[$all_modules[$module_name]['status']],
];
$gdpr_modules_list['#items'][] = t('@title (@status)', [
'@title' => $all_modules[$module_name]['name'],
'@status' => $renderer
->renderPlain($status),
]);
}
}
else {
$status_class = $color_classes[-1];
$status = [
'#prefix' => '<span class="' . $status_class . '">',
'#suffix' => '</span>',
'#markup' => $module_statuses[-1],
];
$gdpr_modules_list['#items'][] = t('@title (@status)', [
'@title' => $module_name,
'@status' => $renderer
->renderPlain($status),
]);
}
}
$gdpr_modules = $renderer
->renderPlain($gdpr_modules_list);
$options = [
'absolute' => TRUE,
'fragment' => 'edit-modules-general-data-protection-regulation',
];
/** @var \Drupal\Core\Link $link */
$link = Link::createFromRoute(t('Enable them on Extend admin page'), 'system.modules_list', [], $options);
if (!empty($gdpr_modules_list['#items'])) {
$text = t("In order to have a complete overview of the site functionalities, it's recommended to enable the following features as well:");
return $text . $gdpr_modules . $link
->toString();
}
return '';
}