You are here

private function SpiController::getModules in Acquia Connector 8

Same name and namespace in other branches
  1. 8.2 src/Controller/SpiController.php \Drupal\acquia_connector\Controller\SpiController::getModules()
  2. 3.x src/Controller/SpiController.php \Drupal\acquia_connector\Controller\SpiController::getModules()

Gather information about modules on the site.

Return value

array An associative array keyed by filename of associative arrays with information on the modules.

1 call to SpiController::getModules()
SpiController::get in src/Controller/SpiController.php
Gather site profile information about this site.

File

src/Controller/SpiController.php, line 930

Class

SpiController
SPI Controller class.

Namespace

Drupal\acquia_connector\Controller

Code

private function getModules() {
  $modules = \Drupal::service('extension.list.module')
    ->reset()
    ->getList();
  uasort($modules, 'system_sort_modules_by_info_name');
  $result = [];
  $keys_to_send = [
    'name',
    'version',
    'package',
    'core',
    'project',
  ];
  foreach ($modules as $module) {
    $info = [];
    $info['status'] = $module->status;
    foreach ($keys_to_send as $key) {
      $info[$key] = isset($module->info[$key]) ? $module->info[$key] : '';
    }
    $info['filename'] = $module
      ->getPathname();
    if (empty($info['project']) && $module->origin == 'core') {
      $info['project'] = 'drupal';
    }
    $result[] = $info;
  }
  return $result;
}