public function UnusedModulesController::renderModulesTable in Unused Modules 8
Returns a table with orphaned modules.
Parameters
string $filter: Either 'all' or 'disabled'.
Return value
array Table render array.
1 string reference to 'UnusedModulesController::renderModulesTable'
File
- src/
UnusedModulesController.php, line 75
Class
- UnusedModulesController
- Page callbacks.
Namespace
Drupal\unused_modulesCode
public function renderModulesTable($filter) {
/** @var \Drupal\unused_modules\UnusedModulesHelperService $helper */
$helper = \Drupal::service('unused_modules.helper');
$modules = $helper
->getModulesByProject();
$header = [
'Project',
'Module',
'Module enabled',
'Project has Enabled Modules',
'Project Path',
];
$rows = [];
foreach ($modules as $module) {
if ($filter === 'all') {
$rows[$module
->getName()] = [
$module->projectName,
$module
->getName(),
$module->moduleIsEnabled ? $this
->t("Yes") : $this
->t("No"),
$module->projectHasEnabledModules ? $this
->t("Yes") : $this
->t("No"),
$module->projectPath,
];
}
elseif ($filter === 'disabled') {
if (!$module->projectHasEnabledModules) {
$rows[$module
->getName()] = [
$module->projectName,
$module
->getName(),
$module->moduleIsEnabled ? $this
->t("Yes") : $this
->t("No"),
$module->projectHasEnabledModules ? $this
->t("Yes") : $this
->t("No"),
$module->projectPath,
];
}
}
}
if (!$rows) {
return [
'#type' => 'markup',
'#markup' => $this
->t("Hurray, no orphaned modules!"),
];
}
return [
'#type' => 'table',
'#header' => $header,
'#rows' => $rows,
];
}