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.
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 {
// As this is the $refresh case, make sure that system_list() returns
// fresh data.
drupal_static_reset('system_list');
if ($bootstrap) {
$list = system_list('bootstrap');
}
else {
$list = system_list('module_enabled');
}
}
}
if ($sort) {
if (!isset($sorted_list)) {
$sorted_list = $list;
ksort($sorted_list);
}
return $sorted_list;
}
return $list;
}
?>Login or register to post comments 