You are here

function drush_modules_weight_mw_list in Modules weight 8

Same name and namespace in other branches
  1. 8.2 modules_weight.drush.inc \drush_modules_weight_mw_list()
  2. 7 modules_weight.drush.inc \drush_modules_weight_mw_list()

Callback for the mw-list command.

File

./modules_weight.drush.inc, line 232
Drush commands related to the Modules weight module.

Code

function drush_modules_weight_mw_list() {
  $result = [];

  // Getting the --force option.
  $force = (bool) drush_get_option('force');

  // If we don't force we need to check the configuration variable to know if we
  // should show or not the core modules.
  $show_core_modules = $force ?: \Drupal::service('config.factory')
    ->get('modules_weight.settings')
    ->get('show_system_modules');

  // Getting the module list.
  $modules = \Drupal::service('modules_weight')
    ->getModulesList($show_core_modules);

  // Iterate over each of the modules.
  foreach ($modules as $filename => $module) {

    // The rows info.
    $row = [];

    // Module name.
    $row['name'] = $module['name'];

    // Module machine name.
    $row['machine_name'] = $filename;

    // Module weight.
    $row['weight'] = $module['weight'];

    // Module package.
    $row['package'] = $module['package'];
    $result[] = $row;
  }
  return $result;
}