system_rebuild_module_data

system_rebuild_module_data()

Rebuild, save, and return data about all currently available modules.

Return value

\Drupal\Core\Extension\Extension[] Array of all available modules and their data.

File

core/modules/system/system.module, line 1066
Configuration system that lets administrators modify the workings of the site.

Code

function system_rebuild_module_data() {
  $modules_cache = &drupal_static(__FUNCTION__);
  // Only rebuild once per request. $modules and $modules_cache cannot be
  // combined into one variable, because the $modules_cache variable is reset by
  // reference from system_list_reset() during the rebuild.
  if (!isset($modules_cache)) {
    $modules = _system_rebuild_module_data();
    $files = array();
    ksort($modules);
    // Add status, weight, and schema version.
    $installed_modules = \Drupal::config('core.extension')->get('module') ? : array();
    foreach ($modules as $name => $module) {
      $module->weight = isset($installed_modules[$name]) ? $installed_modules[$name] : 0;
      $module->status = (int) isset($installed_modules[$name]);
      $module->schema_version = SCHEMA_UNINSTALLED;
      $files[$name] = $module->getPathname();
    }
    $modules = \Drupal::moduleHandler()->buildModuleDependencies($modules);
    $modules_cache = $modules;

    // Store filenames to allow drupal_get_filename() to retrieve them without
    // having to rebuild or scan the filesystem.
    \Drupal::state()->set('system.module.files', $files);
    // Clear the module info cache.
    \Drupal::cache()->delete('system.module.info');
    drupal_static_reset('system_get_info');
  }
  return $modules_cache;
}
doc_Drupal
2016-10-29 09:45:57
Comments
Leave a Comment

Please login to continue.