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