You are here

function system_rebuild_module_data in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/system.module \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.

34 calls to system_rebuild_module_data()
ConfigDependencyTest::testConfigEntityUninstall in core/modules/config/src/Tests/ConfigDependencyTest.php
Tests ConfigManager::uninstall() and config entity dependency management.
ConfigImportAllTest::testInstallUninstall in core/modules/config/src/Tests/ConfigImportAllTest.php
Tests that a fixed set of modules can be installed and uninstalled.
ConfigImporter::createExtensionChangelist in core/lib/Drupal/Core/Config/ConfigImporter.php
Populates the extension change list.
ConfigImportSubscriber::getModuleData in core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php
Gets module data.
ConfigImportUITest::testExtensionValidation in core/modules/config/src/Tests/ConfigImportUITest.php
Tests config importer cannot uninstall extensions which are depended on.

... See full list

7 string references to 'system_rebuild_module_data'
GetFilenameUnitTest::testDrupalGetFilename in core/modules/system/src/Tests/Bootstrap/GetFilenameUnitTest.php
Tests that drupal_get_filename() works when the file is not in database.
ModuleHandlerTest::testDependencyResolution in core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php
Tests dependency resolution.
ModuleHandlerTest::testUninstallContentDependency in core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php
Tests uninstalling a module that has content.
ModuleHandlerTest::testUninstallProfileDependency in core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php
Tests uninstalling a module that is a "dependency" of a profile.
ModuleInstaller::install in core/lib/Drupal/Core/Extension/ModuleInstaller.php
Installs a given list of modules.

... See full list

File

core/modules/system/system.module, line 1033
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;
}