The parameters for module_list()
have been simplified. module_list()
primarily acts as a wrapper for system_list()
, but with the ability to explicitly specify the list of modules the function would return for all subsequent calls. This is used primarily in install.php and update.php. Additionally, there was a sort parameter only used by the help module.
The new module_list()
takes only two arguments: the type of list, and a fixed list of modules. The valid types are 'bootstrap' and 'module_enabled'. Instead of using a parameter to undo the effects of using a fixed list, a separate function was introduced: module_list_reset()
.
Return a sorted list of modules:
D7
$modules = module_list(FALSE, FALSE, TRUE);
D8
$modules = module_list();
ksort($modules);
Use a fixed list, and then get the full list:
D7
$fixed_list = module_list(FALSE, FALSE, FALSE, $module_list);
$full_list = module_list(TRUE);
D8
$fixed_list = module_list(NULL, $module_list);
module_list_reset();
$modules = module_list();
Get the list of modules for bootstrap:
D7
$bootstrap = module_list(FALSE, TRUE);
D8
$bootstrap = module_list('bootstrap');
Ensure the module list is refreshed (such as after the administrator has changed the system settings):
D7
$modules = module_list(TRUE);
D8
system_list_reset();
$modules = module_list();