Returns a list of currently active modules.
Acts as a wrapper around system_list(), returning either a list of all enabled modules, or just modules needed for bootstrap.
The returned module list is always based on system_list(). The only exception to that is when a fixed list of modules has been passed in previously, in which case system_list() is omitted and the fixed list is always returned in subsequent calls until manually reverted via module_list_reset().
string $type: The type of list to return:
array $fixed_list: (optional) An array of module names to override the list of modules. This list will persist until the next call with a new $fixed_list passed in. Primarily intended for internal use (e.g., in install.php and update.php). Use module_list_reset() to undo the $fixed_list override.
bool $reset: (optional) Whether to reset/remove the $fixed_list.
array An associative array whose keys and values are the names of the modules in the list.
function module_list($type = 'module_enabled', array $fixed_list = NULL, $reset = FALSE) {
// This static is only used for $fixed_list. It must not be a drupal_static(),
// since any call to drupal_static_reset() in unit tests would cause an
// attempt to retrieve the list of modules from the database (which does not
// exist).
static $module_list;
if ($reset) {
$module_list = NULL;
// Do nothing if no $type and no $fixed_list have been passed.
if (!isset($type) && !isset($fixed_list)) {
return;
}
}
// The list that will be be returned. Separate from $module_list in order
// to not duplicate the static cache of system_list().
$list = $module_list;
if (isset($fixed_list)) {
$module_list = array();
foreach ($fixed_list as $name => $module) {
system_register('module', $name, $module['filename']);
$module_list[$name] = $name;
}
$list = $module_list;
}
elseif (!isset($module_list)) {
$list = system_list($type);
}
return $list;
}