Procedural module/hook system functions have been replaced with a dedicated class/service.
Within other classes/services and also tests, you should exclusively use the new 'module_handler'
service; e.g., like this:
Drupal 7 |
Drupal 8 |
module_load_all($bootstrap = FALSE)
module_load_all($bootstrap = TRUE)
module_load_all($bootstrap = NULL)
module_load_all($bootstrap, $reset = TRUE)
|
\Drupal::moduleHandler()->loadAll()
\Drupal::moduleHandler()->loadBootstrapModules()
\Drupal::moduleHandler()->isLoaded()
—
|
module_list($type = 'module_enabled')
module_list($type = 'bootstrap')
module_list($type, $fixed_list = array(...))
module_list($type, $fixed_list, $reset = TRUE)
|
\Drupal::moduleHandler()->getModuleList()
\Drupal::moduleHandler()->getBootstrapModules()
\Drupal::moduleHandler()->setModuleList()
—
|
module_list_reset()
|
—
|
system_list('module_enabled')
system_list('bootstrap')
|
\Drupal::moduleHandler()->getModuleList()
\Drupal::moduleHandler()->getBootstrapModules()
|
system_list_reset()
|
—
In tests:
$this->rebuildContainer()
|
_module_build_dependencies($files)
|
\Drupal::moduleHandler()->buildModuleDependencies($files)
|
module_exists($module)
|
\Drupal::moduleHandler()->moduleExists($module)
|
module_load_all_includes($type, $name = NULL)
|
\Drupal::moduleHandler()->loadAllIncludes($type, $name = NULL)
|
module_hook($module, $hook)
|
\Drupal::moduleHandler()->implementsHook($module, $hook)
|
module_implements($hook)
|
\Drupal::moduleHandler()->getImplementations($hook)
|
module_implements_reset()
|
\Drupal::moduleHandler()->resetImplementations()
|
module_hook_info()
|
—
|
module_invoke($module, $hook[, $arg1])
|
\Drupal::moduleHandler()->invoke($module, $hook, $args = array())
|
module_invoke_all($hook)
|
\Drupal::moduleHandler()->invokeAll($hook, $args = array())
|
drupal_alter($type, &$data, &$context1 = NULL, &$context2 = NULL)
|
\Drupal::moduleHandler()->alter($type, &$data, &$context1 = NULL, &$context2 = NULL)
|
module_install($module_list, $enable_dependencies)
module_enable($module_list, $enable_dependencies)
|
\Drupal::service('module_installer')->install($module_list, $enable_dependencies)
|
module_uninstall($module_list, $uninstall_dependents)
|
\Drupal::service('module_installer')->uninstall($module_list, $uninstall_dependents)
|
A few procedural functions still exist as wrappers, but are marked as @deprecated and are scheduled for removal.