Commit 2cf9e49e authored by catch's avatar catch

Revert "Issue #1331486 by katbailey, chx, sun, beejeebus, amateescu: Move...

Revert "Issue #1331486 by katbailey, chx, sun, beejeebus, amateescu: Move module_invoke_*() and friends to an Extensions class. Broke core tests after commit."

This reverts commit c80c3e18.
parent 0d74f5bf
......@@ -78,11 +78,11 @@ function authorize_access_allowed() {
// We have to enable the user and system modules, even to check access and
// display errors via the maintenance theme.
$module_list['system'] = 'core/modules/system/system.module';
$module_list['user'] = 'core/modules/user/user.module';
drupal_container()->get('module_handler')->setModuleList($module_list);
drupal_container()->get('module_handler')->load('system');
drupal_container()->get('module_handler')->load('user');
$module_list['system']['filename'] = 'core/modules/system/system.module';
$module_list['user']['filename'] = 'core/modules/user/user.module';
module_list(NULL, $module_list);
drupal_load('module', 'system');
drupal_load('module', 'user');
// Initialize the language system.
drupal_language_initialize();
......
......@@ -888,14 +888,6 @@ function drupal_get_filename($type, $name, $filename = NULL) {
// nothing
}
else {
if ($type == 'module') {
if (empty($files[$type])) {
$files[$type] = drupal_container()->get('module_handler')->getModuleList();
}
if (isset($files[$type][$name])) {
return $files[$type][$name];
}
}
// Verify that we have an keyvalue service before using it. This is required
// because this function is called during installation.
// @todo Inject database connection into KeyValueStore\DatabaseStorage.
......@@ -1141,9 +1133,8 @@ function drupal_page_is_cacheable($allow_caching = NULL) {
* @see bootstrap_hooks()
*/
function bootstrap_invoke_all($hook) {
$module_handler = drupal_container()->get('module_handler');
foreach ($module_handler->getBootstrapModules() as $module) {
$module_handler->load($module);
foreach (module_list('bootstrap') as $module) {
drupal_load('module', $module);
module_invoke($module, $hook);
}
}
......@@ -1162,10 +1153,6 @@ function bootstrap_invoke_all($hook) {
* TRUE if the item is loaded or has already been loaded.
*/
function drupal_load($type, $name) {
if ($type == 'module' && drupal_container()->get('module_handler')->moduleExists($name)) {
return drupal_container()->get('module_handler')->load($name);
}
// Once a file is included this can't be reversed during a request so do not
// use drupal_static() here.
static $files = array();
......@@ -2436,7 +2423,7 @@ function _drupal_bootstrap_variables() {
$conf = variable_initialize(isset($conf) ? $conf : array());
// Load bootstrap modules.
require_once DRUPAL_ROOT . '/core/includes/module.inc';
drupal_container()->get('module_handler')->loadBootstrapModules();
module_load_all(TRUE);
}
/**
......@@ -2489,82 +2476,6 @@ function drupal_container(ContainerInterface $new_container = NULL) {
return $container;
}
/**
* Returns the list of enabled modules.
*
* @deprecated as of Drupal 8.0. Use
* drupal_container()->get('module_handler')->getModuleList().
*
* @see \Drupal\Core\Extension\ModuleHandler::getModuleList()
*/
function module_list() {
$modules = array_keys(drupal_container()->get('module_handler')->getModuleList());
return array_combine($modules, $modules);
}
/**
* Determines which modules are implementing a hook.
*
* @deprecated as of Drupal 8.0. Use
* drupal_container()->get('module_handler')->getImplementations($hook).
*
* @see \Drupal\Core\Extension\ModuleHandler::getImplementations()
*/
function module_implements($hook) {
return drupal_container()->get('module_handler')->getImplementations($hook);
}
/**
* Invokes a hook in all enabled modules that implement it.
*
* @deprecated as of Drupal 8.0. Use
* drupal_container()->get('module_handler')->invokeAll($hook).
*
* @see \Drupal\Core\Extension\ModuleHandler::invokeAll()
*/
function module_invoke_all($hook) {
$args = func_get_args();
// Remove $hook from the arguments.
array_shift($args);
return drupal_container()->get('module_handler')->invokeAll($hook, $args);
}
/**
* Passes alterable variables to specific hook_TYPE_alter() implementations.
*
* @deprecated as of Drupal 8.0. Use
* drupal_container()->get('module_handler')->alter($hook).
*
* @see \Drupal\Core\Extension\ModuleHandler::alter()
*/
function drupal_alter($type, &$data, &$context1 = NULL, &$context2 = NULL) {
return drupal_container()->get('module_handler')->alter($type, $data, $context1, $context2);
}
/**
* Determines whether a given module exists.
*
* @deprecated as of Drupal 8.0. Use
* drupal_container()->get('module_handler')->moduleExists($hook).
*
* @see \Drupal\Core\Extension\ModuleHandler::moduleExists()
*/
function module_exists($module) {
return drupal_container()->get('module_handler')->moduleExists($module);
}
/**
* Determines whether a module implements a hook.
*
* @deprecated as of Drupal 8.0. Use
* drupal_container()->get('module_handler')->implementsHook($module, $hook).
*
* @see \Drupal\Core\Extension\ModuleHandler::implementsHook()
*/
function module_hook($module, $hook) {
return drupal_container()->get('module_handler')->implementsHook($module, $hook);
}
/**
* Returns the state storage service.
*
......
......@@ -4839,7 +4839,7 @@ function _drupal_bootstrap_code() {
require_once DRUPAL_ROOT . '/core/includes/entity.inc';
// Load all enabled modules
drupal_container()->get('module_handler')->loadAll();
module_load_all();
// Make sure all stream wrappers are registered.
file_get_stream_wrappers();
......@@ -6438,7 +6438,7 @@ function drupal_flush_all_caches() {
// Ensure that all modules that are currently supposed to be enabled are
// actually loaded.
drupal_container()->get('module_handler')->loadAll();
module_load_all();
// Update the list of bootstrap modules.
// Allows developers to get new hook_boot() implementations registered without
......@@ -6511,11 +6511,69 @@ function debug($data, $label = NULL, $print_r = FALSE) {
trigger_error(trim($label ? "$label: $string" : $string));
}
/**
* Parses a dependency for comparison by drupal_check_incompatibility().
*
* @param $dependency
* A dependency string, for example 'foo (>=8.x-4.5-beta5, 3.x)'.
*
* @return
* An associative array with three keys:
* - 'name' includes the name of the thing to depend on (e.g. 'foo').
* - 'original_version' contains the original version string (which can be
* used in the UI for reporting incompatibilities).
* - 'versions' is a list of associative arrays, each containing the keys
* 'op' and 'version'. 'op' can be one of: '=', '==', '!=', '<>', '<',
* '<=', '>', or '>='. 'version' is one piece like '4.5-beta3'.
* Callers should pass this structure to drupal_check_incompatibility().
*
* @see drupal_check_incompatibility()
*/
function drupal_parse_dependency($dependency) {
// We use named subpatterns and support every op that version_compare
// supports. Also, op is optional and defaults to equals.
$p_op = '(?P<operation>!=|==|=|<|<=|>|>=|<>)?';
// Core version is always optional: 8.x-2.x and 2.x is treated the same.
$p_core = '(?:' . preg_quote(DRUPAL_CORE_COMPATIBILITY) . '-)?';
$p_major = '(?P<major>\d+)';
// By setting the minor version to x, branches can be matched.
$p_minor = '(?P<minor>(?:\d+|x)(?:-[A-Za-z]+\d+)?)';
$value = array();
$parts = explode('(', $dependency, 2);
$value['name'] = trim($parts[0]);
if (isset($parts[1])) {
$value['original_version'] = ' (' . $parts[1];
foreach (explode(',', $parts[1]) as $version) {
if (preg_match("/^\s*$p_op\s*$p_core$p_major\.$p_minor/", $version, $matches)) {
$op = !empty($matches['operation']) ? $matches['operation'] : '=';
if ($matches['minor'] == 'x') {
// Drupal considers "2.x" to mean any version that begins with
// "2" (e.g. 2.0, 2.9 are all "2.x"). PHP's version_compare(),
// on the other hand, treats "x" as a string; so to
// version_compare(), "2.x" is considered less than 2.0. This
// means that >=2.x and <2.x are handled by version_compare()
// as we need, but > and <= are not.
if ($op == '>' || $op == '<=') {
$matches['major']++;
}
// Equivalence can be checked by adding two restrictions.
if ($op == '=' || $op == '==') {
$value['versions'][] = array('op' => '<', 'version' => ($matches['major'] + 1) . '.x');
$op = '>=';
}
}
$value['versions'][] = array('op' => $op, 'version' => $matches['major'] . '.' . $matches['minor']);
}
}
}
return $value;
}
/**
* Checks whether a version is compatible with a given dependency.
*
* @param $v
* A parsed dependency structure e.g. from ModuleHandler::parseDependency().
* The parsed dependency structure from drupal_parse_dependency().
* @param $current_version
* The version to check against (like 4.2).
*
......@@ -6523,7 +6581,7 @@ function debug($data, $label = NULL, $print_r = FALSE) {
* NULL if compatible, otherwise the original dependency version string that
* caused the incompatibility.
*
* @see \Drupal\Core\Extension\ModuleHandler::parseDependency()
* @see drupal_parse_dependency()
*/
function drupal_check_incompatibility($v, $current_version) {
if (!empty($v['versions'])) {
......
......@@ -338,7 +338,6 @@ function install_begin_request(&$install_state) {
$container->register('config.factory', 'Drupal\Core\Config\ConfigFactory')
->addArgument(new Reference('config.storage'))
->addArgument(new Reference('event_dispatcher'));
// The install process cannot use the database lock backend since the database
// is not fully up, so we use a null backend implementation during the
// installation process. This will also speed up the installation process.
......@@ -347,10 +346,6 @@ function install_begin_request(&$install_state) {
// (as opposed to the cache backend) so we can afford having a null
// implementation here.
$container->register('lock', 'Drupal\Core\Lock\NullLockBackend');
// Register a module handler for managing enabled modules.
$container
->register('module_handler', 'Drupal\Core\Extension\ModuleHandler');
drupal_container($container);
}
......@@ -358,13 +353,10 @@ function install_begin_request(&$install_state) {
drupal_language_initialize();
require_once DRUPAL_ROOT . '/core/includes/ajax.inc';
$module_handler = drupal_container()->get('module_handler');
if (!$module_handler->moduleExists('system')) {
// Override the module list with a minimal set of modules.
$module_handler->setModuleList(array('system' => 'core/modules/system/system.module'));
}
$module_handler->load('system');
// Override the module list with a minimal set of modules.
$module_list['system']['filename'] = 'core/modules/system/system.module';
module_list(NULL, $module_list);
drupal_load('module', 'system');
require_once DRUPAL_ROOT . '/core/includes/cache.inc';
$conf['cache_classes'] = array('cache' => 'Drupal\Core\Cache\MemoryBackend');
......@@ -1578,7 +1570,9 @@ function install_bootstrap_full(&$install_state) {
// cache backend will be used again.
unset($GLOBALS['conf']['cache_classes']['cache']);
drupal_static_reset('cache');
// Clear the module list that was overriden earlier in the process.
// This will allow all freshly installed modules to be loaded.
module_list_reset();
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
}
......
......@@ -424,10 +424,15 @@ function drupal_install_system() {
->set('enabled.system', 0)
->save();
// Update the module list to include it.
drupal_container()->get('module_handler')->setModuleList(array('system' => $system_path . '/system.module'));
drupal_container()->get('module_handler')->resetImplementations();
// Clear out module list and hook implementation statics.
system_list_reset();
module_list_reset();
module_implements_reset();
// To ensure that the system module can be found by the plugin system, warm
// the module list cache.
// @todo Remove this in http://drupal.org/node/1798732.
module_list();
config_install_default_config('module', 'system');
module_invoke('system', 'install');
......
......@@ -9,6 +9,114 @@
use Drupal\Component\Utility\NestedArray;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Loads all enabled modules.
*
* @param bool $bootstrap
* Whether to load only the reduced set of modules loaded in "bootstrap mode"
* for cached pages. See bootstrap.inc. Pass NULL to only check the current
* status without loading of modules.
* @param bool $reset
* (optional) Internal use only. Whether to reset the internal statically
* cached flag of whether modules have been loaded. If TRUE, all modules are
* (re)loaded in the same call. Used by the testing framework to override and
* persist a limited module list for the duration of a unit test (in which no
* module system exists).
*
* @return bool
* A Boolean indicating whether all modules have been loaded. This means all
* modules; the load status of bootstrap modules cannot be checked.
*/
function module_load_all($bootstrap = FALSE, $reset = FALSE) {
static $has_run = FALSE;
if ($reset) {
$has_run = FALSE;
}
// Unless $boostrap is NULL, load the requested set of modules.
if (isset($bootstrap) && !$has_run) {
$type = $bootstrap ? 'bootstrap' : 'module_enabled';
foreach (module_list($type) as $module) {
drupal_load('module', $module);
}
// $has_run will be TRUE if $bootstrap is FALSE.
$has_run = !$bootstrap;
}
return $has_run;
}
/**
* 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().
*
* @param string $type
* The type of list to return:
* - module_enabled: All enabled modules.
* - bootstrap: All enabled modules required for bootstrap.
* @param 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.
* @param bool $reset
* (optional) Whether to reset/remove the $fixed_list.
*
* @return array
* An associative array whose keys and values are the names of the modules in
* the list.
*
* @see module_list_reset()
*/
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;
}
/**
* Reverts an enforced fixed list of module_list().
*
* Subsequent calls to module_list() will no longer use a fixed list.
*/
function module_list_reset() {
module_list(NULL, NULL, TRUE);
}
/**
* Builds a list of bootstrap modules and enabled modules and themes.
*
......@@ -24,6 +132,7 @@
* For $type 'theme', the array values are objects representing the
* respective database row, with the 'info' property already unserialized.
*
* @see module_list()
* @see list_themes()
*
* @todo There are too many layers/levels of caching involved for system_list()
......@@ -33,74 +142,121 @@
*/
function system_list($type) {
$lists = &drupal_static(__FUNCTION__);
if ($cached = cache('bootstrap')->get('system_list')) {
$lists = $cached->data;
// For bootstrap modules, attempt to fetch the list from cache if possible.
// if not fetch only the required information to fire bootstrap hooks
// in case we are going to serve the page from cache.
if ($type == 'bootstrap') {
if (isset($lists['bootstrap'])) {
return $lists['bootstrap'];
}
if ($cached = cache('bootstrap')->get('bootstrap_modules')) {
$bootstrap_list = $cached->data;
}
else {
$bootstrap_list = state()->get('system.module.bootstrap') ?: array();
cache('bootstrap')->set('bootstrap_modules', $bootstrap_list);
}
// To avoid a separate database lookup for the filepath, prime the
// drupal_get_filename() static cache for bootstrap modules only.
// The rest is stored separately to keep the bootstrap module cache small.
foreach ($bootstrap_list as $name => $filename) {
system_register('module', $name, $filename);
}
// We only return the module names here since module_list() doesn't need
// the filename itself.
$lists['bootstrap'] = array_keys($bootstrap_list);
}
else {
$lists = array(
'theme' => array(),
'filepaths' => array(),
);
// Build a list of themes.
$enabled_themes = (array) config('system.theme')->get('enabled');
// @todo Themes include all themes, including disabled/uninstalled. This
// system.theme.data state will go away entirely as soon as themes have
// a proper installation status.
// @see http://drupal.org/node/1067408
$theme_data = state()->get('system.theme.data');
if (empty($theme_data)) {
// @todo: system_list() may be called from _drupal_bootstrap_code(), in
// which case system.module is not loaded yet.
// Prevent a filesystem scan in drupal_load() and include it directly.
// @see http://drupal.org/node/1067408
require_once DRUPAL_ROOT . '/core/modules/system/system.module';
$theme_data = system_rebuild_theme_data();
}
foreach ($theme_data as $name => $theme) {
$theme->status = (int) isset($enabled_themes[$name]);
$lists['theme'][$name] = $theme;
// Build a list of filenames so drupal_get_filename can use it.
if (isset($enabled_themes[$name])) {
// Otherwise build the list for enabled modules and themes.
elseif (!isset($lists['module_enabled'])) {
if ($cached = cache('bootstrap')->get('system_list')) {
$lists = $cached->data;
}
else {
$lists = array(
'module_enabled' => array(),
'theme' => array(),
'filepaths' => array(),
);
// 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().
$enabled_modules = (array) config('system.module')->get('enabled');
$module_files = state()->get('system.module.files');
foreach ($enabled_modules as $name => $weight) {
// Build a list of all enabled modules.
$lists['module_enabled'][$name] = $name;
// Build a list of filenames so drupal_get_filename can use it.
$lists['filepaths'][] = array(
'type' => 'theme',
'type' => 'module',
'name' => $name,
'filepath' => $theme->filename,
'filepath' => $module_files[$name],
);
}
}
// @todo Move into list_themes(). Read info for a particular requested
// theme from state instead.
foreach ($lists['theme'] as $key => $theme) {
if (!empty($theme->info['base theme'])) {
// Make a list of the theme's base themes.
require_once DRUPAL_ROOT . '/core/includes/theme.inc';
$lists['theme'][$key]->base_themes = drupal_find_base_themes($lists['theme'], $key);
// Don't proceed if there was a problem with the root base theme.
if (!current($lists['theme'][$key]->base_themes)) {
continue;
}
// Determine the root base theme.
$base_key = key($lists['theme'][$key]->base_themes);
// Add to the list of sub-themes for each of the theme's base themes.
foreach (array_keys($lists['theme'][$key]->base_themes) as $base_theme) {
$lists['theme'][$base_theme]->sub_themes[$key] = $lists['theme'][$key]->info['name'];
// Build a list of themes.
$enabled_themes = (array) config('system.theme')->get('enabled');
// @todo Themes include all themes, including disabled/uninstalled. This
// system.theme.data state will go away entirely as soon as themes have
// a proper installation status.
// @see http://drupal.org/node/1067408
$theme_data = state()->get('system.theme.data');
if (empty($theme_data)) {
// @todo: system_list() may be called from _drupal_bootstrap_code() and
// module_load_all(), in which case system.module is not loaded yet.
// Prevent a filesystem scan in drupal_load() and include it directly.
// @see http://drupal.org/node/1067408
require_once DRUPAL_ROOT . '/core/modules/system/system.module';
$theme_data = system_rebuild_theme_data();
}
foreach ($theme_data as $name => $theme) {
$theme->status = (int) isset($enabled_themes[$name]);
$lists['theme'][$name] = $theme;
// Build a list of filenames so drupal_get_filename can use it.
if (isset($enabled_themes[$name])) {
$lists['filepaths'][] = array(
'type' => 'theme',
'name' => $name,
'filepath' => $theme->filename,
);
}
// Add the base theme's theme engine info.
$lists['theme'][$key]->info['engine'] = $lists['theme'][$base_key]->info['engine'];
}
else {
// A plain theme is its own base theme.
$base_key = $key;
// @todo Move into list_themes(). Read info for a particular requested
// theme from state instead.
foreach ($lists['theme'] as $key => $theme) {
if (!empty($theme->info['base theme'])) {
// Make a list of the theme's base themes.
require_once DRUPAL_ROOT . '/core/includes/theme.inc';
$lists['theme'][$key]->base_themes = drupal_find_base_themes($lists['theme'], $key);
// Don't proceed if there was a problem with the root base theme.
if (!current($lists['theme'][$key]->base_themes)) {
continue;
}
// Determine the root base theme.
$base_key = key($lists['theme'][$key]->base_themes);
// Add to the list of sub-themes for each of the theme's base themes.
foreach (array_keys($lists['theme'][$key]->base_themes) as $base_theme) {
$lists['theme'][$base_theme]->sub_themes[$key] = $lists['theme'][$key]->info['name'];
}
// Add the base theme's theme engine info.
$lists['theme'][$key]->info['engine'] = $lists['theme'][$base_key]->info['engine'];
}
else {
// A plain theme is its own base theme.
$base_key = $key;
}
// Set the theme engine prefix.
$lists['theme'][$key]->prefix = ($lists['theme'][$key]->info['engine'] == 'theme') ? $base_key : $lists['theme'][$key]->info['engine'];
}
// Set the theme engine prefix.
$lists['theme'][$key]->prefix = ($lists['theme'][$key]->info['engine'] == 'theme') ? $base_key : $lists['theme'][$key]->info['engine'];
cache('bootstrap')->set('system_list', $lists);
}
// To avoid a separate database lookup for the filepath, prime the
// drupal_get_filename() static cache with all enabled modules and themes.
foreach ($lists['filepaths'] as $item) {
system_register($item['type'], $item['name'], $item['filepath']);
}
cache('bootstrap')->set('system_list', $lists);
}
// To avoid a separate database lookup for the filepath, prime the
// drupal_get_filename() static cache with all enabled modules and themes.
foreach ($lists['filepaths'] as $item) {
system_register($item['type'], $item['name'], $item['filepath']);
}
return $lists[$type];
......@@ -113,7 +269,7 @@ function system_list_reset() {
drupal_static_reset('system_list');
drupal_static_reset('system_rebuild_module_data');
drupal_static_reset('list_themes');
cache('bootstrap')->delete('system_list');
cache('bootstrap')->deleteMultiple(array('bootstrap_modules', 'system_list'));
cache()->delete('system_info');
// Remove last known theme data state.
// This causes system_list() to call system_rebuild_theme_data() on its next
......@@ -141,6 +297,53 @@ function system_register($type, $name, $uri) {
drupal_classloader_register($name, dirname($uri));
}
/**
* Determines which modules require and are required by each module.
*
* @param $files
* The array of filesystem objects used to rebuild the cache.
*
* @return
* The same array with the new keys for each module:
* - requires: An array with the keys being the modules that this module
* requires.
* - required_by: An array with the keys being the modules that will not work
* without this module.
*/
function _module_build_dependencies($files) {
foreach ($files as $filename => $file) {
$graph[$file->name]['edges'] = array();
if (isset($file->info['dependencies']) && is_array($file->info['dependencies'])) {
foreach ($file->info['dependencies'] as $dependency) {
$dependency_data = drupal_parse_dependency($dependency);
$graph[$file->name]['edges'][$dependency_data['name']] = $dependency_data;
}
}
}
$graph_object = new Graph($graph);
$graph = $graph_object->searchAndSort();
foreach ($graph as $module => $data) {
$files[$module]->required_by = isset($data['reverse_paths']) ? $data['reverse_paths'] : array();
$files[$module]->requires = isset($data['paths']) ? $data['paths'] : array();
$files[$module]->sort = $data['weight'];
}
return $files;
}
/**
* Determines whether a given module exists.
*
* @param $module
* The name of the module (without the .module extension).
*
* @return
* TRUE if the module is both installed and enabled.
*/
function module_exists($module) {
$list = module_list();
return isset($list[$module]);
}
/**
* Loads a module's installation hooks.
*
......@@ -183,11 +386,6 @@ function module_load_install($module) {
*
* @return
* The name of the included file, if successful; FALSE otherwise.
*
* @todo The module_handler service has a loadInclude() method which performs
* this same task but only for enabled modules. Figure out a way to move this
* functionality entirely into the module_handler while keeping the ability to
* load the files of disabled modules.
*/
function module_load_include($type, $module, $name = NULL) {
if (!isset($name)) {
......@@ -204,6 +402,15 @@ function module_load_include($type, $module, $name = NULL) {
return FALSE;
}
/**
* Loads an include file for each enabled module.
*/
function module_load_all_includes($type, $name = NULL) {
$modules = module_list();
foreach ($modules as $module) {
module_load_include($type, $module, $name);
}
}
/**
* Enables or installs a given list of modules.
......@@ -287,12 +494,9 @@ function module_enable($module_list, $enable_dependencies = TRUE) {
$schema_store = drupal_container()->get('keyvalue')->get('system.schema');
$module_config = config('system.module');
$disabled_config = config('system.module.disabled');
$module_handler = drupal_container()->get('module_handler');
$module_filenames = drupal_container()->getParameter('container.modules');
foreach ($module_list as $module) {
// Only process modules that are not already enabled.
// A module is only enabled if it is configured as enabled. Custom or
// overridden module handlers might contain the module already, which means