function drush_unused_modules_show_modules in Unused Modules 8
Same name and namespace in other branches
- 6 unused_modules.drush.inc \drush_unused_modules_show_modules()
- 7 unused_modules.drush.inc \drush_unused_modules_show_modules()
Drush callback.
Prints a table with orphaned modules.
Parameters
string $op: Either 'all' or 'disabled'.
Return value
string themed table.
1 call to drush_unused_modules_show_modules()
- drush_unused_modules in ./
unused_modules.drush.inc - Drush command callback.
File
- ./
unused_modules.drush.inc, line 139 - Unused Modules Drush support.
Code
function drush_unused_modules_show_modules($op = 'all') {
/** @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',
];
// With Drush, the first row is the header.
$rows = [];
$rows[] = $header;
foreach ($modules as $module) {
if ($op == 'all') {
$rows[$module
->getName()] = [
$module->projectName,
$module
->getName(),
$module->moduleIsEnabled ? t("Yes") : t("No"),
$module->projectHasEnabledModules ? t("Yes") : t("No"),
$module->projectPath,
];
}
elseif ($op == 'disabled') {
if (!$module->projectHasEnabledModules) {
$rows[$module
->getName()] = [
$module->projectName,
$module
->getName(),
$module->moduleIsEnabled ? t("Yes") : t("No"),
$module->projectHasEnabledModules ? t("Yes") : t("No"),
$module->projectPath,
];
}
}
}
// Note: header is always there.
if (count($rows) === 1) {
drush_print("Hurray, no orphaned modules!");
}
else {
drush_print_table($rows, TRUE);
}
}