You are here

function drush_unused_modules_show_projects in Unused Modules 8

Same name and namespace in other branches
  1. 6 unused_modules.drush.inc \drush_unused_modules_show_projects()
  2. 7 unused_modules.drush.inc \drush_unused_modules_show_projects()

Drush callback.

Prints a table with orphaned projects.

Parameters

string $op: Either 'all' or 'disabled'.

Return value

string themed table.

1 call to drush_unused_modules_show_projects()
drush_unused_modules in ./unused_modules.drush.inc
Drush command callback.

File

./unused_modules.drush.inc, line 85
Unused Modules Drush support.

Code

function drush_unused_modules_show_projects($op = 'all') {

  /** @var \Drupal\unused_modules\UnusedModulesHelperService $helper */
  $helper = \Drupal::service('unused_modules.helper');
  $modules = $helper
    ->getModulesByProject();
  $header = [
    'Project',
    '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->projectName] = [
        $module->projectName,
        $module->projectHasEnabledModules ? t("Yes") : t("No"),
        $module->projectPath,
      ];
    }
    elseif ($op == 'disabled') {
      if (!$module->projectHasEnabledModules) {
        $rows[$module->projectName] = [
          $module->projectName,
          $module->projectHasEnabledModules ? t("Yes") : t("No"),
          $module->projectPath,
        ];
      }
    }
  }

  // Note: header is always there.
  if (count($rows) === 1) {
    drush_print("Hurray, no orphaned projects!");
  }
  else {
    drush_print_table($rows, TRUE);
  }
}