module_list

Versions
4.6
module_list($refresh = FALSE, $bootstrap = TRUE)
4.7
module_list($refresh = FALSE, $bootstrap = TRUE, $sort = FALSE)
5 – 6
module_list($refresh = FALSE, $bootstrap = TRUE, $sort = FALSE, $fixed_list = NULL)
7
module_list($refresh = FALSE, $bootstrap = FALSE, $sort = FALSE, $fixed_list = NULL)

Collect a list of all loaded modules. During the bootstrap, return only vital modules. See bootstrap.inc

Parameters

$refresh Whether to force the module list to be regenerated (such as after the administrator has changed the system settings).

$bootstrap Whether to return the reduced set of modules loaded in "bootstrap mode" for cached pages. See bootstrap.inc.

$sort By default, modules are ordered by weight and module name. Set this option to TRUE to return a module list ordered only by module name.

$fixed_list (Optional) Override the module list with the given modules. Stays until the next call with $refresh = TRUE.

Return value

An associative array whose keys and values are the names of all loaded modules.

▾ 14 functions call module_list()

bootstrap_invoke_all in includes/bootstrap.inc
Call all init or exit hooks without including all modules.
drupal_get_schema in includes/bootstrap.inc
Get the schema definition of a table, or the whole database schema.
module_disable in includes/module.inc
Disable a given set of modules.
module_enable in includes/module.inc
Enable a given list of modules.
module_exists in includes/module.inc
Determine whether a given module exists.
module_hook_info in includes/module.inc
Retrieve a list of what hooks are explicitly declared.
module_implements in includes/module.inc
Determine which modules are implementing a hook.
module_load_all in includes/module.inc
Load all the modules that have been enabled in the system table.
module_load_all_includes in includes/module.inc
Load an include file for each of the modules that have been enabled in the system table.
system_install in modules/system/system.install
Implement hook_install().
system_modules_submit in modules/system/system.admin.inc
Submit callback; handles modules form submission.
system_requirements in modules/system/system.install
Test and report Drupal installation requirements.
_drupal_maintenance_theme in includes/theme.maintenance.inc
Sets up the theming system for site installs, updates and when the site is in maintenance mode. It also applies when the database is unavailable.
_theme_process_registry in includes/theme.inc
Process a single implementation of hook_theme().

Code

includes/module.inc, line 52

<?php
function module_list($refresh = FALSE, $bootstrap = FALSE, $sort = FALSE, $fixed_list = NULL) {
  static $list = array(), $sorted_list;

  if (empty($list) || $refresh || $fixed_list) {
    $list = array();
    $sorted_list = NULL;
    if ($fixed_list) {
      foreach ($fixed_list as $name => $module) {
        drupal_get_filename('module', $name, $module['filename']);
        $list[$name] = $name;
      }
    }
    else {
      // The module name (rather than the filename) is used as the fallback
      // weighting in order to guarantee consistent behavior across different
      // Drupal installations, which might have modules installed in different
      // locations in the file system. The ordering here must also be
      // consistent with the one used in module_implements().
      if ($bootstrap) {
        $result = db_query("SELECT name, filename FROM {system} WHERE type = 'module' AND status = 1 AND bootstrap = 1 ORDER BY weight ASC, name ASC");
      }
      else {
        $result = db_query("SELECT name, filename FROM {system} WHERE type = 'module' AND status = 1 ORDER BY weight ASC, name ASC");
      }
      foreach ($result as $module) {
        if (file_exists($module->filename)) {
          // First call drupal_get_filename() to prime the static cache for
          // later lookups of the module path. Since we've already queried for
          // the filename and can pass that in as an argument, this avoids a
          // database hit for every module when drupal_get_filename() is
          // subsequently called by drupal_load().
          drupal_get_filename('module', $module->name, $module->filename);
          $list[$module->name] = $module->name;
        }
      }
    }
  }
  if ($sort) {
    if (!isset($sorted_list)) {
      $sorted_list = $list;
      ksort($sorted_list);
    }
    return $sorted_list;
  }
  return $list;
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.