You are here

private function UnusedModulesCommands::showModules in Unused Modules 8

Drush callback.

Prints a table with orphaned modules.

Parameters

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

Return value

\Consolidation\OutputFormatters\StructuredData\RowsOfFields Rows with unused module information.

1 call to UnusedModulesCommands::showModules()
UnusedModulesCommands::modules in src/Commands/UnusedModulesCommands.php
Show unused modules or projects.

File

src/Commands/UnusedModulesCommands.php, line 153

Class

UnusedModulesCommands
A Drush commandfile.

Namespace

Drupal\unused_modules\Commands

Code

private function showModules($op = 'all') {
  $modules = $this->unusedModulesHelper
    ->getModulesByProject();
  $rows = [];
  foreach ($modules as $module) {
    if ($op == 'all') {
      $rows[$module
        ->getName()] = [
        'project' => $module->projectName,
        'module' => $module
          ->getName(),
        'enabled' => $module->moduleIsEnabled ? dt("Yes") : dt("No"),
        'has_modules' => $module->projectHasEnabledModules ? dt("Yes") : dt("No"),
        'path' => $module->projectPath,
      ];
    }
    elseif ($op == 'disabled') {
      if (!$module->projectHasEnabledModules) {
        $rows[$module
          ->getName()] = [
          'project' => $module->projectName,
          'module' => $module
            ->getName(),
          'enabled' => $module->moduleIsEnabled ? dt("Yes") : dt("No"),
          'has_modules' => $module->projectHasEnabledModules ? dt("Yes") : dt("No"),
          'path' => $module->projectPath,
        ];
      }
    }
  }
  if (!count($rows)) {
    $this
      ->output()
      ->writeln("Hurray, no orphaned modules!");
    return NULL;
  }
  return new RowsOfFields($rows);
}