You are here

private static function UnusedModulesHelperService::getEnabledModules in Unused Modules 8

Returns an array of enabled modules.

1 call to UnusedModulesHelperService::getEnabledModules()
UnusedModulesHelperService::getModulesByProject in src/UnusedModulesHelperService.php
Returns an array with all available modules.

File

src/UnusedModulesHelperService.php, line 70

Class

UnusedModulesHelperService
Common Unused Modules functionality.

Namespace

Drupal\unused_modules

Code

private static function getEnabledModules() {

  // Get all modules available.
  $available_modules = self::getAvailableModules();

  // Get all enabled modules.
  $moduleHandler = \Drupal::moduleHandler();
  $enabled_modules = array_map('self::decorateExtension', $moduleHandler
    ->getModuleList());

  // Return only enabled.
  $return = [];
  foreach ($enabled_modules as $enabled_module => $extension) {

    // Some enabled_modules are actually not available. This is the case for
    // installation profiles like 'minimal'.
    if (isset($available_modules[$enabled_module])) {
      $return[$enabled_module] = $available_modules[$enabled_module];
    }
  }
  return $return;
}