diff --git a/core/authorize.php b/core/authorize.php index e880d34..114dcd3 100644 --- a/core/authorize.php +++ b/core/authorize.php @@ -80,9 +80,9 @@ function authorize_access_allowed() { // 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('extension_handler')->setModuleList($module_list); -drupal_container()->get('extension_handler')->loadModule('system'); -drupal_container()->get('extension_handler')->loadModule('user'); +drupal_container()->get('module_handler')->setModuleList($module_list); +drupal_container()->get('module_handler')->load('system'); +drupal_container()->get('module_handler')->load('user'); // Initialize the language system. drupal_language_initialize(); diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index d6c963c..bee7b9d 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -5,8 +5,8 @@ use Drupal\Core\DrupalKernel; use Drupal\Core\Database\Database; use Drupal\Core\DependencyInjection\ContainerBuilder; -use Drupal\Core\ExtensionHandler; -use Drupal\Core\ExtensionHandlerMinimal; +use Drupal\Core\ModuleHandler; +use Drupal\Core\InstallModuleHandler; use Symfony\Component\ClassLoader\UniversalClassLoader; use Symfony\Component\ClassLoader\ApcUniversalClassLoader; use Symfony\Component\DependencyInjection\Container; @@ -891,7 +891,7 @@ function drupal_get_filename($type, $name, $filename = NULL) { else { if ($type == 'module') { if (empty($files[$type])) { - $files[$type] = drupal_container()->get('extension_handler')->getModuleList(); + $files[$type] = drupal_container()->get('module_handler')->getModuleList(); } if (isset($files[$type][$name])) { return $files[$type][$name]; @@ -1142,9 +1142,9 @@ function drupal_page_is_cacheable($allow_caching = NULL) { * @see bootstrap_hooks() */ function bootstrap_invoke_all($hook) { - $extension_handler = drupal_container()->get('extension_handler'); - foreach ($extension_handler->getBootstrapModules() as $module) { - $extension_handler->loadModule($module); + $module_handler = drupal_container()->get('module_handler'); + foreach ($module_handler->getBootstrapModules() as $module) { + $module_handler->load($module); module_invoke($module, $hook); } } @@ -1163,8 +1163,8 @@ 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('extension_handler')->moduleExists($name)) { - return drupal_container()->get('extension_handler')->loadModule($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 @@ -2437,7 +2437,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('extension_handler')->loadBootstrapModules(); + drupal_container()->get('module_handler')->loadBootstrapModules(); } /** @@ -2493,40 +2493,40 @@ function drupal_container(Container $new_container = NULL) { /** * Determines which modules are implementing a hook. * - * @see ExtensionHandler::moduleImplements(). + * @see ModuleHandler::getImplementations(). */ function module_implements($hook) { - return drupal_container()->get('extension_handler')->moduleImplements($hook); + return drupal_container()->get('module_handler')->getImplementations($hook); } /** * Invokes a hook in all enabled modules that implement it. * - * @see ExtensionHandler::moduleInvokeAll(). + * @see ModuleHandler::invokeAll(). */ function module_invoke_all($hook) { $args = func_get_args(); // Remove $hook from the arguments. unset($args[0]); - return drupal_container()->get('extension_handler')->moduleInvokeAll($hook, $args); + return drupal_container()->get('module_handler')->invokeAll($hook, $args); } /** * Passes alterable variables to specific hook_TYPE_alter() implementations. * - * @see ExtensionHandler::alter(). + * @see ModuleHandler::alter(). */ function drupal_alter($type, &$data, &$context1 = NULL, &$context2 = NULL) { - return drupal_container()->get('extension_handler')->alter($type, $data, $context1, $context2); + return drupal_container()->get('module_handler')->alter($type, $data, $context1, $context2); } /** * Determines whether a given module exists. * - * @see ExtensionHandler::moduleExists(). + * @see ModuleHandler::moduleExists(). */ function module_exists($module) { - return drupal_container()->get('extension_handler')->moduleExists($module); + return drupal_container()->get('module_handler')->moduleExists($module); } /** diff --git a/core/includes/common.inc b/core/includes/common.inc index 58f8cb4..48f1fd4 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -4774,7 +4774,7 @@ function _drupal_bootstrap_code() { require_once DRUPAL_ROOT . '/core/includes/entity.inc'; // Load all enabled modules - drupal_container()->get('extension_handler')->loadAllModules(); + drupal_container()->get('module_handler')->loadAll(); // Make sure all stream wrappers are registered. file_get_stream_wrappers(); @@ -6373,7 +6373,7 @@ function drupal_flush_all_caches() { // Ensure that all modules that are currently supposed to be enabled are // actually loaded. - drupal_container()->get('extension_handler')->loadAllModules(); + drupal_container()->get('module_handler')->loadAll(); // Update the list of bootstrap modules. // Allows developers to get new hook_boot() implementations registered without @@ -6450,7 +6450,7 @@ function debug($data, $label = NULL, $print_r = FALSE) { * Checks whether a version is compatible with a given dependency. * * @param $v - * A parsed dependency structure e.g. from ExtensionHandler::parseDependency(). + * A parsed dependency structure e.g. from ModuleHandler::parseDependency(). * @param $current_version * The version to check against (like 4.2). * @@ -6458,7 +6458,7 @@ function debug($data, $label = NULL, $print_r = FALSE) { * NULL if compatible, otherwise the original dependency version string that * caused the incompatibility. * - * @see ExtensionHandler::parseDependency() + * @see ModuleHandler::parseDependency() */ function drupal_check_incompatibility($v, $current_version) { if (!empty($v['versions'])) { diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index 279b43e..dd27421 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -332,7 +332,7 @@ function install_begin_request(&$install_state) { ->addArgument(new Reference('event_dispatcher')); // Register an extension handler for managing enabled modules. $container - ->register('extension_handler', 'Drupal\Core\ExtensionHandlerMinimal'); + ->register('module_handler', 'Drupal\Core\InstallModuleHandler'); drupal_container($container); } @@ -342,8 +342,8 @@ function install_begin_request(&$install_state) { require_once DRUPAL_ROOT . '/core/includes/ajax.inc'; // Override the module list with a minimal set of modules. - drupal_container()->get('extension_handler')->setModuleList(array('system' => 'core/modules/system/system.module')); - drupal_container()->get('extension_handler')->loadModule('system'); + drupal_container()->get('module_handler')->setModuleList(array('system' => 'core/modules/system/system.module')); + drupal_container()->get('module_handler')->load('system'); // Load the cache infrastructure using a "fake" cache implementation that // does not attempt to write to the database. We need this during the initial @@ -1501,7 +1501,7 @@ function install_load_profile(&$install_state) { function install_bootstrap_full(&$install_state) { // Clear the statically cached extension handler. This will allow all freshly // installed modules to be loaded. - drupal_static_reset('drupal_extension_handler'); + drupal_static_reset('drupal_module_handler'); // Instantiate the kernel. $kernel = new DrupalKernel('prod', FALSE, drupal_classloader(), FALSE); diff --git a/core/includes/install.inc b/core/includes/install.inc index a87dda6..6439565 100644 --- a/core/includes/install.inc +++ b/core/includes/install.inc @@ -425,8 +425,8 @@ function drupal_install_system() { ->save(); // Clear out module list and hook implementation statics. - drupal_static_reset('drupal_extension_handler'); - drupal_container()->get('extension_handler')->setModuleList(array('system' => $system_path . '/system.module')); + drupal_static_reset('drupal_module_handler'); + drupal_container()->get('module_handler')->setModuleList(array('system' => $system_path . '/system.module')); config_install_default_config('module', 'system'); module_invoke('system', 'install'); diff --git a/core/includes/module.inc b/core/includes/module.inc index 03680d7..df56084 100644 --- a/core/includes/module.inc +++ b/core/includes/module.inc @@ -283,9 +283,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'); - $extension_handler = drupal_container()->get('extension_handler'); + $module_handler = drupal_container()->get('module_handler'); foreach ($module_list as $module) { - $module_filenames = $extension_handler->getModuleList(); + $module_filenames = $module_handler->getModuleList(); // Only process modules that are not already enabled. $enabled = isset($module_filenames[$module]); if (!$enabled) { @@ -311,18 +311,18 @@ function module_enable($module_list, $enable_dependencies = TRUE) { } // Refresh the module list in the extension handler. - $extension_handler->setModuleList($module_filenames); + $module_handler->setModuleList($module_filenames); // Load the module's code. - $extension_handler->loadModule($module); + $module_handler->load($module); module_load_install($module); // Refresh the module list to include it. - $extension_handler->moduleImplementsReset(); + $module_handler->resetImplementations(); _system_update_bootstrap_status(); - // Update the kernel to include the new module + // Update the kernel to include the new module. // @todo The if statement is here because install_begin_request() creates // a container without a kernel. It probably shouldn't. if ($kernel = drupal_container()->get('kernel', ContainerInterface::NULL_ON_INVALID_REFERENCE)) { @@ -436,9 +436,9 @@ function module_disable($module_list, $disable_dependents = TRUE) { $module_config = config('system.module'); $disabled_config = config('system.module.disabled'); - $extension_handler = drupal_container()->get('extension_handler'); + $module_handler = drupal_container()->get('module_handler'); foreach ($module_list as $module) { - $enabled = $extension_handler->getModuleList(); + $enabled = $module_handler->getModuleList(); if (isset($enabled[$module])) { module_load_install($module); module_invoke($module, 'disable'); @@ -449,7 +449,7 @@ function module_disable($module_list, $disable_dependents = TRUE) { ->clear("enabled.$module") ->save(); unset($enabled[$module]); - $extension_handler->setModuleList($enabled); + $module_handler->setModuleList($enabled); $invoke_modules[] = $module; watchdog('system', '%module module disabled.', array('%module' => $module), WATCHDOG_INFO); } @@ -461,7 +461,7 @@ function module_disable($module_list, $disable_dependents = TRUE) { // the todo in system_list_reset(). system_list_reset(); // Refresh the module list to exclude the disabled modules. - drupal_container()->get('extension_handler')->moduleImplementsReset(); + drupal_container()->get('module_handler')->resetImplementations(); entity_info_cache_clear(); // Invoke hook_modules_disabled before disabling modules, // so we can still call module hooks to get information. @@ -595,7 +595,7 @@ function module_hook($module, $hook) { } // If the hook implementation does not exist, check whether it may live in an // optional include file registered via hook_hook_info(). - $hook_info = drupal_container()->get('extension_handler')->moduleHookInfo(); + $hook_info = drupal_container()->get('module_handler')->getHookInfo(); if (isset($hook_info[$hook]['group'])) { module_load_include('inc', $module, $module . '.' . $hook_info[$hook]['group']); if (function_exists($function)) { @@ -664,8 +664,8 @@ function drupal_required_modules() { function module_set_weight($module, $weight) { // Update the module weight in the config file that contains it. $module_config = config('system.module'); - $extension_handler = drupal_container()->get('extension_handler'); - $enabled_modules = $extension_handler->getModuleList(); + $module_handler = drupal_container()->get('module_handler'); + $enabled_modules = $module_handler->getModuleList(); if ($module_config->get("enabled.$module") !== NULL) { $module_config ->set("enabled.$module", $weight) @@ -677,7 +677,7 @@ function module_set_weight($module, $weight) { $sorted_with_filenames[$m] = $enabled_modules[$m]; } // Refresh the module list in the extension handler. - $extension_handler->setModuleList($sorted_with_filenames); + $module_handler->setModuleList($sorted_with_filenames); return; } $disabled_config = config('system.module.disabled'); diff --git a/core/includes/schema.inc b/core/includes/schema.inc index e24bb80..eb023fc 100644 --- a/core/includes/schema.inc +++ b/core/includes/schema.inc @@ -85,7 +85,7 @@ function drupal_get_complete_schema($rebuild = FALSE) { // that it contains the complete list of modules before we go on to call // module_load_all_includes(). system_list_reset(); - drupal_container()->get('extension_handler')->loadModuleIncludes('install'); + drupal_container()->get('module_handler')->loadAllIncludes('install'); } require_once DRUPAL_ROOT . '/core/includes/common.inc'; @@ -130,7 +130,7 @@ function drupal_get_schema_versions($module) { $updates = &drupal_static(__FUNCTION__, NULL); if (!isset($updates[$module])) { $updates = array(); - foreach (drupal_container()->get('extension_handler')->getModuleList() as $loaded_module => $filename) { + foreach (drupal_container()->get('module_handler')->getModuleList() as $loaded_module => $filename) { $updates[$loaded_module] = array(); } diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 42fcd84..6378327 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -367,14 +367,14 @@ function _theme_load_registry($theme, $base_theme = NULL, $theme_engine = NULL, $registry = _theme_build_registry($theme, $base_theme, $theme_engine); // Only persist this registry if all modules are loaded. This assures a // complete set of theme hooks. - if (drupal_container()->get('extension_handler')->allModulesLoaded()) { + if (drupal_container()->get('module_handler')->isLoaded()) { _theme_save_registry($theme, $registry); } } return $registry; } else { - return new ThemeRegistry('theme_registry:runtime:' . $theme->name, 'cache', array('theme_registry' => TRUE), drupal_container()->get('extension_handler')->allModulesLoaded()); + return new ThemeRegistry('theme_registry:runtime:' . $theme->name, 'cache', array('theme_registry' => TRUE), drupal_container()->get('module_handler')->isLoaded()); } } @@ -545,7 +545,7 @@ function _theme_process_registry(&$cache, $name, $type, $theme, $path) { // Add all modules so they can intervene with their own variable // processors. This allows them to provide variable processors even // if they are not the owner of the current hook. - $prefixes = array_merge($prefixes, array_keys(drupal_container()->get('extension_handler')->getModuleList())); + $prefixes = array_merge($prefixes, array_keys(drupal_container()->get('module_handler')->getModuleList())); } elseif ($type == 'theme_engine' || $type == 'base_theme_engine') { // Theme engines get an extra set that come before the normally @@ -640,7 +640,7 @@ function _theme_build_registry($theme, $base_theme, $theme_engine) { _theme_process_registry($cache, $module, 'module', $module, drupal_get_path('module', $module)); } // Only cache this registry if all modules are loaded. - if (drupal_container()->get('extension_handler')->allModulesLoaded()) { + if (drupal_container()->get('module_handler')->isLoaded()) { cache()->set("theme_registry:build:modules", $cache, CacheBackendInterface::CACHE_PERMANENT, array('theme_registry' => TRUE)); } } @@ -955,7 +955,7 @@ function theme($hook, $variables = array()) { // If called before all modules are loaded, we do not necessarily have a full // theme registry to work with, and therefore cannot process the theme // request properly. See also _theme_load_registry(). - if (!drupal_container()->get('extension_handler')->allModulesLoaded() && !defined('MAINTENANCE_MODE')) { + if (!drupal_container()->get('module_handler')->isLoaded() && !defined('MAINTENANCE_MODE')) { throw new Exception(t('theme() may not be called until all modules are loaded.')); } diff --git a/core/includes/theme.maintenance.inc b/core/includes/theme.maintenance.inc index e1d6c70..d9999b6 100644 --- a/core/includes/theme.maintenance.inc +++ b/core/includes/theme.maintenance.inc @@ -56,8 +56,8 @@ function _drupal_maintenance_theme() { // Ensure that system.module is loaded. if (!function_exists('_system_rebuild_theme_data')) { $module_list['system']['filename'] = 'core/modules/system/system.module'; - drupal_container()->get('extension_handler')->setModuleList($module_list); - drupal_container()->get('extension_handler')->loadModule('system'); + drupal_container()->get('module_handler')->setModuleList($module_list); + drupal_container()->get('module_handler')->load('system'); } $themes = list_themes(); diff --git a/core/includes/update.inc b/core/includes/update.inc index 8405b34..fdd2e34 100644 --- a/core/includes/update.inc +++ b/core/includes/update.inc @@ -9,7 +9,7 @@ */ use Drupal\Component\Graph\Graph; -use Drupal\Core\ExtensionHandler; +use Drupal\Core\ModuleHandler; use Drupal\Core\Config\FileStorage; use Drupal\Core\Config\ConfigException; use Drupal\Component\Uuid\Uuid; @@ -126,10 +126,10 @@ function update_prepare_d8_bootstrap() { include_once DRUPAL_ROOT . '/core/includes/module.inc'; include_once DRUPAL_ROOT . '/core/includes/cache.inc'; - $extension_handler = drupal_container()->get('extension_handler'); - $extension_handler->setModuleList(array('system' => 'core/modules/system/system.module')); + $module_handler = drupal_container()->get('module_handler'); + $module_handler->setModuleList(array('system' => 'core/modules/system/system.module')); - $extension_handler->loadModule('system'); + $module_handler->load('system'); // Ensure the configuration directories exist and are writable, or create // them. If the directories have not been specified in settings.php and // created manually already, and either directory cannot be created by the @@ -243,7 +243,7 @@ function update_prepare_d8_bootstrap() { // Populate a fixed module list (again, why did it get lost?) to avoid // errors due to the drupal_alter() in _system_rebuild_module_data(). $module_list['system'] = 'core/modules/system/system.module'; - drupal_container()->get('extension_handler')->setModuleList($module_list); + drupal_container()->get('module_handler')->setModuleList($module_list); $module_data = _system_rebuild_module_data(); // Migrate each extension into configuration, varying by the extension's @@ -274,7 +274,7 @@ function update_prepare_d8_bootstrap() { $sorted_with_filenames[$m] = drupal_get_filename('module', $m); } - drupal_container()->get('extension_handler')->setModuleList($sorted_with_filenames); + drupal_container()->get('module_handler')->setModuleList($sorted_with_filenames); $disabled_modules->save(); $theme_config->save(); $disabled_themes->save(); diff --git a/core/lib/Drupal/Core/CoreBundle.php b/core/lib/Drupal/Core/CoreBundle.php index 7433de3..5498374 100644 --- a/core/lib/Drupal/Core/CoreBundle.php +++ b/core/lib/Drupal/Core/CoreBundle.php @@ -73,6 +73,12 @@ public function build(ContainerBuilder $container) { ->register('keyvalue.database', 'Drupal\Core\KeyValueStore\KeyValueDatabaseFactory') ->addArgument(new Reference('database')); + // Register the state k/v store as a service. + $container->register('state', 'Drupal\Core\KeyValueStore\KeyValueStoreInterface') + ->setFactoryService(new Reference('keyvalue')) + ->setFactoryMethod('get') + ->addArgument('state'); + $container->register('path.alias_manager', 'Drupal\Core\Path\AliasManager') ->addArgument(new Reference('database')) ->addArgument(new Reference('keyvalue')); @@ -111,11 +117,11 @@ public function build(ContainerBuilder $container) { ->setFactoryMethod('get') ->addArgument('bootstrap'); - // The ExtensionHandler manages enabled modules and provides the ability to + // The ModuleHandler manages enabled modules and provides the ability to // invoke hooks in all enabled modules. - $container->register('extension_handler', 'Drupal\Core\ExtensionHandler') + $container->register('module_handler', 'Drupal\Core\ModuleHandler') ->addArgument('%container.modules%') - ->addArgument(new Reference('keyvalue')) + ->addArgument(new Reference('state')) ->addArgument(new Reference('cache.bootstrap')); $container->register('resolver', 'Drupal\Core\ControllerResolver') @@ -150,7 +156,7 @@ public function build(ContainerBuilder $container) { ->addArgument(new Reference('router.dumper')) ->addArgument(new Reference('lock')) ->addArgument(new Reference('event_dispatcher')) - ->addArgument(new Reference('extension_handler')); + ->addArgument(new Reference('module_handler')); $container->register('matcher', 'Drupal\Core\Routing\ChainMatcher'); $container->register('legacy_url_matcher', 'Drupal\Core\LegacyUrlMatcher') @@ -232,7 +238,7 @@ public function build(ContainerBuilder $container) { ->setScope('request') ->addTag('event_subscriber'); $container->register('request_close_subscriber', 'Drupal\Core\EventSubscriber\RequestCloseSubscriber') - ->addArgument(new Reference('extension_handler')) + ->addArgument(new Reference('module_handler')) ->addTag('event_subscriber'); $container->register('config_global_override_subscriber', 'Drupal\Core\EventSubscriber\ConfigGlobalOverrideSubscriber') ->addTag('event_subscriber'); diff --git a/core/lib/Drupal/Core/EventSubscriber/RequestCloseSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/RequestCloseSubscriber.php index 04250ab..0e9ee9b 100644 --- a/core/lib/Drupal/Core/EventSubscriber/RequestCloseSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/RequestCloseSubscriber.php @@ -7,7 +7,7 @@ namespace Drupal\Core\EventSubscriber; -use Drupal\Core\ExtensionHandlerInterface; +use Drupal\Core\ModuleHandlerInterface; use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\HttpKernel\Event\PostResponseEvent; use Symfony\Component\EventDispatcher\EventSubscriberInterface; @@ -18,15 +18,15 @@ class RequestCloseSubscriber implements EventSubscriberInterface { /** - * @var ExtensionHandlerInterface + * @var ModuleHandlerInterface */ - protected $extensionHandler; + protected $ModuleHandler; /** * Constructor. */ - function __construct(ExtensionHandlerInterface $extension_handler) { - $this->extensionHandler = $extension_handler; + function __construct(ModuleHandlerInterface $module_handler) { + $this->ModuleHandler = $module_handler; } /** @@ -48,7 +48,7 @@ public function onTerminate(PostResponseEvent $event) { // since these do not need to be optimized as tightly, and not doing so // keeps the cache entry smaller. if ($request_method == 'GET' || $request_method == 'HEAD') { - $this->extensionHandler->writeModuleImplementationsCache(); + $this->ModuleHandler->writeImplementationsCache(); } system_run_automated_cron(); } diff --git a/core/lib/Drupal/Core/ExtensionHandlerMinimal.php b/core/lib/Drupal/Core/InstallModuleHandler.php similarity index 82% rename from core/lib/Drupal/Core/ExtensionHandlerMinimal.php rename to core/lib/Drupal/Core/InstallModuleHandler.php index f62ae23..732f4f9 100644 --- a/core/lib/Drupal/Core/ExtensionHandlerMinimal.php +++ b/core/lib/Drupal/Core/InstallModuleHandler.php @@ -2,33 +2,33 @@ /** * @file - * Definition of Drupal\Core\ExtensionHandlerMinimal. + * Contains Drupal\Core\InstallModuleHandler. */ namespace Drupal\Core; -use Drupal\Core\ExtensionHandler; +use Drupal\Core\ModuleHandler; use Symfony\Component\ClassLoader\UniversalClassLoader; /** - * Class representing an ExtensionHandler that tests can use. + * Module handler used by the installer. * - * Overrides all methods in the ExtensionHandler class that attempt to talk to - * a database. + * Overrides all methods in the ModuleHandler class that attempt to talk to + * the state k/v store or a cache. */ -class ExtensionHandlerMinimal extends ExtensionHandler { +class InstallModuleHandler extends ModuleHandler { /** - * Overrides Drupal\Core\ExtensionHandler::construct(). + * Overrides Drupal\Core\ModuleHandler::construct(). */ public function __construct(array $module_list = array()) { $this->moduleList = $module_list; } /** - * Overrides Drupal\Core\ExtensionHandler::moduleImplements(). + * Overrides Drupal\Core\ModuleHandler::getImplementations(). */ - public function moduleImplements($hook) { + public function getImplementations($hook) { // Fetch implementations from cache. if (empty($this->implementations)) { $this->implementations = array(); @@ -37,7 +37,7 @@ public function moduleImplements($hook) { // The hook is not cached, so ensure that whether or not it has // implementations, that the cache is updated at the end of the request. $this->implementations['#write_cache'] = TRUE; - $hook_info = $this->moduleHookInfo(); + $hook_info = $this->getHookInfo(); $this->implementations[$hook] = array(); foreach ($this->moduleList as $module => $filename) { $include_file = isset($hook_info[$hook]['group']) && module_load_include('inc', $module, $module . '.' . $hook_info[$hook]['group']); @@ -78,9 +78,9 @@ public function moduleImplements($hook) { } /** - * Overrides Drupal\Core\ExtensionHandler::moduleImplementsReset(). + * Overrides Drupal\Core\ModuleHandler::resetImplementations(). */ - public function moduleImplementsReset() { + public function resetImplementations() { // We maintain a persistent cache of hook implementations in addition to the // static cache to avoid looping through every module and every hook on each // request. Benchmarks show that the benefit of this caching outweighs the @@ -97,9 +97,9 @@ public function moduleImplementsReset() { } /** - * Overrides Drupal\Core\ExtensionHandler::moduleHookInfo(). + * Overrides Drupal\Core\ModuleHandler::getHookInfo(). */ - public function moduleHookInfo() { + public function getHookInfo() { // When this function is indirectly invoked from bootstrap_invoke_all() prior // to all modules being loaded, we do not want to cache an incomplete // hook_hook_info() result, so instead return an empty array. This requires @@ -111,7 +111,7 @@ public function moduleHookInfo() { if (!isset($this->hookInfo)) { $this->hookInfo = array(); - // We can't use $this->moduleInvokeAll() here or it would cause an infinite + // We can't use $this->invokeAll() here or it would cause an infinite // loop. foreach ($this->moduleList as $module => $filename) { $function = $module . '_hook_info'; @@ -134,8 +134,8 @@ public function moduleHookInfo() { } /** - * Overrides Drupal\Core\ExtensionHandler::moduleImplementsWriteCache(). + * Overrides Drupal\Core\ModuleHandler::getImplementationsWriteCache(). */ - public function writeModuleImplementationsCache() { + public function writeImplementationsCache() { } } diff --git a/core/lib/Drupal/Core/ExtensionHandler.php b/core/lib/Drupal/Core/ModuleHandler.php similarity index 83% rename from core/lib/Drupal/Core/ExtensionHandler.php rename to core/lib/Drupal/Core/ModuleHandler.php index 674b65d..aa83c02 100644 --- a/core/lib/Drupal/Core/ExtensionHandler.php +++ b/core/lib/Drupal/Core/ModuleHandler.php @@ -2,17 +2,20 @@ /** * @file - * Definition of Drupal\Core\ExtensionHandler. + * Contains Drupal\Core\ModuleHandler. */ namespace Drupal\Core; use Drupal\Component\Graph\Graph; use Drupal\Core\Cache\CacheBackendInterface; -use Drupal\Core\KeyValueStore\KeyValueFactory; -use Drupal\Core\ExtensionHandlerInterface; +use Drupal\Core\KeyValueStore\KeyValueStoreInterface; +use Drupal\Core\ModuleHandlerInterface; -class ExtensionHandler implements ExtensionHandlerInterface { +/** + * Class that manages enabled modules in a Drupal installation. + */ +class ModuleHandler implements ModuleHandlerInterface { /** * State key/value store. @@ -64,18 +67,18 @@ class ExtensionHandler implements ExtensionHandlerInterface { protected $alterFunctions; /** - * Constructor. + * Constructs a ModuleHandler object. */ - public function __construct(array $module_list, KeyValueFactory $key_value, CacheBackendInterface $bootstrapCache) { + public function __construct(array $module_list, KeyValueStoreInterface $state, CacheBackendInterface $bootstrap_cache) { $this->moduleList = $module_list; - $this->state = $key_value->get('state'); - $this->bootstrapCache = $bootstrapCache; + $this->state = $state; + $this->bootstrapCache = $bootstrap_cache; } /** - * Implements Drupal\Core\ExtensionHandlerInterface::loadModule(). + * Implements \Drupal\Core\ModuleHandlerInterface::load(). */ - public function loadModule($name) { + public function load($name) { if (isset($this->loadedFiles[$name])) { return TRUE; } @@ -90,59 +93,59 @@ public function loadModule($name) { } /** - * Implements Drupal\Core\ExtensionHandlerInterface::loadAllModules(). + * Implements \Drupal\Core\ModuleHandlerInterface::loadAll(). */ - public function loadAllModules() { + public function loadAll() { if (!$this->loaded) { foreach ($this->moduleList as $module => $filename) { - $this->loadModule($module); + $this->load($module); } $this->loaded = TRUE; } } /** - * Implements Drupal\Core\ExtensionHandlerInterface::reloadModules(). + * Implements \Drupal\Core\ModuleHandlerInterface::reload(). */ - public function reloadModules() { + public function reload() { $this->loaded = FALSE; - $this->loadAllModules(); + $this->loadAll(); } /** - * Implements Drupal\Core\ExtensionHandlerInterface::loadBootstrapModules(). + * Implements \Drupal\Core\ModuleHandlerInterface::loadBootstrapModules(). */ public function loadBootstrapModules() { if (!$this->loaded) { foreach ($this->getBootstrapModules() as $module) { - $this->loadModule($module); + $this->load($module); } } } /** - * Implements Drupal\Core\ExtensionHandlerInterface::allModulesLoaded(). + * Implements \Drupal\Core\ModuleHandlerInterface::isLoaded(). */ - public function allModulesLoaded() { + public function isLoaded() { return $this->loaded; } /** - * Implements Drupal\Core\ExtensionHandlerInterface::getModuelList(). + * Implements \Drupal\Core\ModuleHandlerInterface::getModuelList(). */ public function getModuleList() { return $this->moduleList; } /** - * Implements Drupal\Core\ExtensionHandlerInterface::setModuleList(). + * Implements \Drupal\Core\ModuleHandlerInterface::setModuleList(). */ public function setModuleList(array $module_list = array()) { $this->moduleList = $module_list; } /** - * Implements Drupal\Core\ExtensionHandlerInterface::getBootstrapModules(). + * Implements \Drupal\Core\ModuleHandlerInterface::getBootstrapModules(). */ public function getBootstrapModules() { if (isset($this->bootstrapModules)) { @@ -161,7 +164,7 @@ public function getBootstrapModules() { } /** - * Implements Drupal\Core\ExtensionHandlerInterface::buildModuleDependencies(). + * Implements \Drupal\Core\ModuleHandlerInterface::buildModuleDependencies(). */ public function buildModuleDependencies($files) { foreach ($files as $filename => $file) { @@ -184,26 +187,25 @@ public function buildModuleDependencies($files) { } /** - * Implements Drupal\Core\ExtensionHandlerInterface::moduleExists(). + * Implements \Drupal\Core\ModuleHandlerInterface::moduleExists(). */ public function moduleExists($module) { return isset($this->moduleList[$module]); } /** - * Implements Drupal\Core\ExtensionHandlerInterface::loadModuleIncludes(). + * Implements \Drupal\Core\ModuleHandlerInterface::loadAllIncludes(). */ - public function loadModuleIncludes($type, $name = NULL) { + public function loadAllIncludes($type, $name = NULL) { foreach ($this->moduleList as $module => $filename) { module_load_include($type, $module, $name); } } - /** - * Implements Drupal\Core\ExtensionHandlerInterface::moduleImplements(). + * Implements \Drupal\Core\ModuleHandlerInterface::getImplementations(). */ - public function moduleImplements($hook) { + public function getImplementations($hook) { // Fetch implementations from cache. if (empty($this->implementations)) { $implementations = $this->bootstrapCache->get('module_implements'); @@ -219,7 +221,7 @@ public function moduleImplements($hook) { // The hook is not cached, so ensure that whether or not it has // implementations, that the cache is updated at the end of the request. $this->implementations['#write_cache'] = TRUE; - $hook_info = $this->moduleHookInfo(); + $hook_info = $this->getHookInfo(); $this->implementations[$hook] = array(); foreach ($this->moduleList as $module => $filename) { $include_file = isset($hook_info[$hook]['group']) && module_load_include('inc', $module, $module . '.' . $hook_info[$hook]['group']); @@ -259,19 +261,9 @@ public function moduleImplements($hook) { } /** - * Implements Drupal\Core\ExtensionHandlerInterface::getModuleHookImplementations(). - */ - public function getModuleHookImplementations() { - if (empty($this->implementations)) { - return array(); - } - return $this->implementations; - } - - /** - * Implements Drupal\Core\ExtensionHandlerInterface::moduleImplementsReset(). + * Implements \Drupal\Core\ModuleHandlerInterface::resetImplementations(). */ - public function moduleImplementsReset() { + public function resetImplementations() { // We maintain a persistent cache of hook implementations in addition to the // static cache to avoid looping through every module and every hook on each // request. Benchmarks show that the benefit of this caching outweighs the @@ -290,9 +282,9 @@ public function moduleImplementsReset() { } /** - * Implements Drupal\Core\ExtensionHandlerInterface::moduleHookInfo(). + * Implements \Drupal\Core\ModuleHandlerInterface::getHookInfo(). */ - public function moduleHookInfo() { + public function getHookInfo() { // When this function is indirectly invoked from bootstrap_invoke_all() prior // to all modules being loaded, we do not want to cache an incomplete // hook_hookInfo() result, so instead return an empty array. This requires @@ -306,7 +298,7 @@ public function moduleHookInfo() { $cache = $this->bootstrapCache->get('hook_info'); if ($cache === FALSE) { // Rebuild the cache and save it. - // We can't use $this->moduleInvokeAll() here or it would cause an infinite + // We can't use $this->invokeAll() here or it would cause an infinite // loop. foreach ($this->moduleList as $module => $filename) { $function = $module . '_hook_info'; @@ -336,9 +328,9 @@ public function moduleHookInfo() { } /** - * Implements Drupal\Core\ExtensionHandlerInterface::moduleImplementsWriteCache(). + * Implements \Drupal\Core\ModuleHandlerInterface::getImplementationsWriteCache(). */ - public function writeModuleImplementationsCache() { + public function writeImplementationsCache() { if (isset($this->implementations['#write_cache'])) { unset($this->implementations['#write_cache']); $this->bootstrapCache->set('module_implements', $this->implementations); @@ -346,11 +338,11 @@ public function writeModuleImplementationsCache() { } /** - * Implements Drupal\Core\ExtensionHandlerInterface::moduleInvokeAll(). + * Implements \Drupal\Core\ModuleHandlerInterface::invokeAll(). */ - public function moduleInvokeAll($hook, $args) { + public function invokeAll($hook, $args) { $return = array(); - foreach ($this->moduleImplements($hook) as $module) { + foreach ($this->getImplementations($hook) as $module) { $function = $module . '_' . $hook; if (function_exists($function)) { $result = call_user_func_array($function, $args); @@ -367,7 +359,7 @@ public function moduleInvokeAll($hook, $args) { } /** - * Implements Drupal\Core\ExtensionHandlerInterface::alter(). + * Implements \Drupal\Core\ModuleHandlerInterface::alter(). */ public function alter($type, &$data, &$context1 = NULL, &$context2 = NULL) { // Most of the time, $type is passed as a string, so for performance, @@ -395,10 +387,10 @@ public function alter($type, &$data, &$context1 = NULL, &$context2 = NULL) { if (!isset($this->alterFunctions[$cid])) { $this->alterFunctions[$cid] = array(); $hook = $type . '_alter'; - $modules = $this->moduleImplements($hook); + $modules = $this->getImplementations($hook); if (!isset($extra_types)) { // For the more common case of a single hook, we do not need to call - // function_exists(), since $this->moduleImplements() returns only modules with + // function_exists(), since $this->getImplementations() returns only modules with // implementations. foreach ($modules as $module) { $this->alterFunctions[$cid][] = $module . '_' . $hook; @@ -409,19 +401,19 @@ public function alter($type, &$data, &$context1 = NULL, &$context2 = NULL) { // implements at least one of them. $extra_modules = array(); foreach ($extra_types as $extra_type) { - $extra_modules = array_merge($extra_modules, $this->moduleImplements($extra_type . '_alter')); + $extra_modules = array_merge($extra_modules, $this->getImplementations($extra_type . '_alter')); } // If any modules implement one of the extra hooks that do not implement // the primary hook, we need to add them to the $modules array in their - // appropriate order. $this->moduleImplements() can only return ordered + // appropriate order. $this->getImplementations() can only return ordered // implementations of a single hook. To get the ordered implementations - // of multiple hooks, we mimic the $this->moduleImplements() logic of first + // of multiple hooks, we mimic the $this->getImplementations() logic of first // ordering by $this->getModuleList(), and then calling // $this->alter('module_implements'). if (array_diff($extra_modules, $modules)) { // Merge the arrays and order by getModuleList(). $modules = array_intersect(array_keys($this->moduleList), array_merge($modules, $extra_modules)); - // Since $this->moduleImplements() already took care of loading the necessary + // Since $this->getImplementations() already took care of loading the necessary // include files, we can safely pass FALSE for the array values. $implementations = array_fill_keys($modules, FALSE); // Let modules adjust the order solely based on the primary hook. This diff --git a/core/lib/Drupal/Core/ExtensionHandlerInterface.php b/core/lib/Drupal/Core/ModuleHandlerInterface.php similarity index 87% rename from core/lib/Drupal/Core/ExtensionHandlerInterface.php rename to core/lib/Drupal/Core/ModuleHandlerInterface.php index 1ff835b..6f49f35 100644 --- a/core/lib/Drupal/Core/ExtensionHandlerInterface.php +++ b/core/lib/Drupal/Core/ModuleHandlerInterface.php @@ -2,12 +2,19 @@ /** * @file - * Contains Drupal\Core\ExtensionHandlerInterface. + * Contains Drupal\Core\ModuleHandlerInterface. */ namespace Drupal\Core; -interface ExtensionHandlerInterface { +/** + * Interface for classes that manage a set of enabled modules. + * + * Classes implementing this interface work with a fixed list of modules and are + * responsible for loading module files and maintaining information about module + * dependencies and hook implementations. + */ +interface ModuleHandlerInterface { /** * Includes a file with the provided type and name. @@ -20,12 +27,12 @@ * @return * TRUE if the item is loaded or has already been loaded. */ - public function loadModule($name); + public function load($name); /** * Loads all the modules that have been enabled. */ - public function loadAllModules(); + public function loadAll(); /** * Loads all bootstrap modules. @@ -39,12 +46,12 @@ public function loadBootstrapModules(); * A Boolean indicating whether all modules have been loaded. This means all * modules; the load status of bootstrap modules cannot be checked. */ - public function allModulesLoaded(); + public function isLoaded(); /** * Reloads all enabled modules. */ - public function reloadModules(); + public function reload(); /** * Returns a list of currently active modules. @@ -89,7 +96,7 @@ public function moduleExists($module); /** * Loads an include file for each module enabled. */ - public function loadModuleIncludes($type, $name = NULL); + public function loadAllIncludes($type, $name = NULL); /** * Determines which modules are implementing a hook. @@ -100,19 +107,13 @@ public function loadModuleIncludes($type, $name = NULL); * @return * An array with the names of the modules which are implementing this hook. * - * @see module_implements_write_cache() */ - public function moduleImplements($hook); + public function getImplementations($hook); /** * Regenerates the stored list of hook implementations. */ - public function moduleImplementsReset(); - - /** - * Returns the hook implementation cache. - */ - public function getModuleHookImplementations(); + public function resetImplementations(); /** * Retrieves a list of hooks that are declared through hook_hook_info(). @@ -124,14 +125,14 @@ public function getModuleHookImplementations(); * * @see hook_hook_info() */ - public function moduleHookInfo(); + public function getHookInfo(); /** * Writes the hook implementation cache. * - * @see $this->moduleImplements() + * @see $this->getImplementations() */ - public function writeModuleImplementationsCache(); + public function writeImplementationsCache(); /** * Invokes a hook in all enabled modules that implement it. @@ -145,7 +146,7 @@ public function writeModuleImplementationsCache(); * An array of return values of the hook implementations. If modules return * arrays from their implementations, those are merged into one array. */ - public function moduleInvokeAll($hook, $args); + public function invokeAll($hook, $args); /** * Passes alterable variables to specific hook_TYPE_alter() implementations. diff --git a/core/lib/Drupal/Core/Routing/RouteBuilder.php b/core/lib/Drupal/Core/Routing/RouteBuilder.php index e74c4c6..f6ec656 100644 --- a/core/lib/Drupal/Core/Routing/RouteBuilder.php +++ b/core/lib/Drupal/Core/Routing/RouteBuilder.php @@ -13,7 +13,7 @@ use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Routing\Route; -use Drupal\Core\ExtensionHandlerInterface; +use Drupal\Core\ModuleHandlerInterface; use Drupal\Core\Lock\LockBackendInterface; /** @@ -48,9 +48,9 @@ class RouteBuilder { /** * The extension handler for retieving the list of enabled modules. * - * @var \Drupal\Core\ExtensionHandlerInterface + * @var \Drupal\Core\ModuleHandlerInterface */ - protected $extensionHandler; + protected $ModuleHandler; /** * Construcs the RouteBuilder using the passed MatcherDumperInterface. @@ -62,11 +62,11 @@ class RouteBuilder { * @param \Symfony\Component\EventDispatcherEventDispatcherInterface * The event dispatcher to notify of routes. */ - public function __construct(MatcherDumperInterface $dumper, LockBackendInterface $lock, EventDispatcherInterface $dispatcher, ExtensionHandlerInterface $extension_handler) { + public function __construct(MatcherDumperInterface $dumper, LockBackendInterface $lock, EventDispatcherInterface $dispatcher, ModuleHandlerInterface $module_handler) { $this->dumper = $dumper; $this->lock = $lock; $this->dispatcher = $dispatcher; - $this->extensionHandler = $extension_handler; + $this->ModuleHandler = $module_handler; } /** @@ -85,7 +85,7 @@ public function rebuild() { // We need to manually call each module so that we can know which module // a given item came from. - foreach ($this->extensionHandler->getModuleList() as $module => $filename) { + foreach ($this->ModuleHandler->getModuleList() as $module => $filename) { $collection = new RouteCollection(); $routing_file = DRUPAL_ROOT . '/' . dirname($filename) . '/' . $module . '.routing.yml'; if (file_exists($routing_file)) { diff --git a/core/modules/breakpoint/breakpoint.install b/core/modules/breakpoint/breakpoint.install index 9fd1054..cba7b1b 100644 --- a/core/modules/breakpoint/breakpoint.install +++ b/core/modules/breakpoint/breakpoint.install @@ -18,5 +18,5 @@ function breakpoint_enable() { _breakpoint_theme_enabled(array_keys($themes)); // Import breakpoints from modules. - _breakpoint_modules_enabled(array_keys(drupal_container()->get('extension_handler')->getModuleList())); + _breakpoint_modules_enabled(array_keys(drupal_container()->get('module_handler')->getModuleList())); } diff --git a/core/modules/field/field.module b/core/modules/field/field.module index 7d16a84..662c866 100644 --- a/core/modules/field/field.module +++ b/core/modules/field/field.module @@ -504,7 +504,7 @@ function field_modules_disabled($modules) { function field_sync_field_status() { // Refresh the 'active' and 'storage_active' columns according to the current // set of enabled modules. - $modules = array_keys(drupal_container()->get('extension_handler')->getModuleList()); + $modules = array_keys(drupal_container()->get('module_handler')->getModuleList()); foreach ($modules as $module_name) { field_associate_fields($module_name); } diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageNegotiationInfoTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageNegotiationInfoTest.php index 795d4d5..38096db 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageNegotiationInfoTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageNegotiationInfoTest.php @@ -139,7 +139,7 @@ protected function languageNegotiationUpdate($op = 'enable') { $function = "module_{$op}"; $function($modules); // Reset hook implementation cache. - drupal_container()->get('extension_handler')->moduleImplementsReset(); + drupal_container()->get('module_handler')->resetImplementations(); } drupal_static_reset('language_types_info'); diff --git a/core/modules/layout/lib/Drupal/layout/Plugin/Derivative/Layout.php b/core/modules/layout/lib/Drupal/layout/Plugin/Derivative/Layout.php index c5de29e..1efbc10 100644 --- a/core/modules/layout/lib/Drupal/layout/Plugin/Derivative/Layout.php +++ b/core/modules/layout/lib/Drupal/layout/Plugin/Derivative/Layout.php @@ -10,7 +10,7 @@ use DirectoryIterator; use Drupal\Component\Plugin\Derivative\DerivativeInterface; use Drupal\Core\Config\FileStorage; -use Drupal\Core\ExtensionHandlerInterface; +use Drupal\Core\ModuleHandlerInterface; /** * Layout plugin derivative definition. @@ -61,7 +61,7 @@ public function getDerivativeDefinitions(array $base_plugin_definition) { // Add all modules as possible layout providers. // @todo Change this class so that it gets the extension handler injected // into it. - foreach (drupal_container()->get('extension_handler')->getModuleList() as $module => $filename) { + foreach (drupal_container()->get('module_handler')->getModuleList() as $module => $filename) { $available_layout_providers[$module] = array( 'type' => 'module', 'provider' => $module, diff --git a/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php index 96856ec..222e6a2 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php @@ -213,17 +213,17 @@ protected function installSchema($module, $table) { */ protected function enableModules(array $modules, $install = TRUE) { // Explicitly set the list of modules in the extension handler. - $enabled = $this->container->get('extension_handler')->getModuleList(); + $enabled = $this->container->get('module_handler')->getModuleList(); foreach ($modules as $module) { $enabled[$module] = drupal_get_filename('module', $module); // Call module_enable() to enable (install) the new module. if ($install) { module_enable(array($module), FALSE); } - $this->container->get('extension_handler')->setModuleList($enabled); + $this->container->get('module_handler')->setModuleList($enabled); } - $this->container->get('extension_handler')->moduleImplementsReset(); - $this->container->get('extension_handler')->reloadModules(); + $this->container->get('module_handler')->resetImplementations(); + $this->container->get('module_handler')->reload(); } } diff --git a/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php b/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php index fe25549..75c016e 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php @@ -39,7 +39,7 @@ function testSetUp() { // Verify that specified $modules have been loaded. $this->assertTrue(function_exists('entity_test_permission'), "$module.module was loaded."); // Verify that there is a fixed module list. - $this->assertIdentical(array_keys(drupal_container()->get('extension_handler')->getModuleList()), array($module)); + $this->assertIdentical(array_keys(drupal_container()->get('module_handler')->getModuleList()), array($module)); $this->assertIdentical(module_implements('permission'), array($module)); // Verify that no modules have been installed. @@ -54,7 +54,7 @@ function testEnableModulesLoad() { // Verify that the module does not exist yet. $this->assertFalse(module_exists($module), "$module module not found."); - $list = array_keys(drupal_container()->get('extension_handler')->getModuleList()); + $list = array_keys(drupal_container()->get('module_handler')->getModuleList()); $this->assertFalse(in_array($module, $list), "$module module not found in the extension handler's module list."); $list = module_implements('permission'); $this->assertFalse(in_array($module, $list), "{$module}_permission() in module_implements() not found."); @@ -64,7 +64,7 @@ function testEnableModulesLoad() { // Verify that the module exists. $this->assertTrue(module_exists($module), "$module module found."); - $list = array_keys(drupal_container()->get('extension_handler')->getModuleList()); + $list = array_keys(drupal_container()->get('module_handler')->getModuleList()); $this->assertTrue(in_array($module, $list), "$module module found in the extension handler's module list."); $list = module_implements('permission'); $this->assertTrue(in_array($module, $list), "{$module}_permission() in module_implements() found."); @@ -83,7 +83,7 @@ function testEnableModulesInstall() { // Verify that the module does not exist yet. $this->assertFalse(module_exists($module), "$module module not found."); - $list = array_keys(drupal_container()->get('extension_handler')->getModuleList()); + $list = array_keys(drupal_container()->get('module_handler')->getModuleList()); $this->assertFalse(in_array($module, $list), "$module module not found in the extension handler's module list."); $list = module_implements('permission'); $this->assertFalse(in_array($module, $list), "{$module}_permission() in module_implements() not found."); @@ -97,7 +97,7 @@ function testEnableModulesInstall() { // Verify that the enabled module exists. $this->assertTrue(module_exists($module), "$module module found."); - $list = array_keys(drupal_container()->get('extension_handler')->getModuleList()); + $list = array_keys(drupal_container()->get('module_handler')->getModuleList()); $this->assertTrue(in_array($module, $list), "$module module found in the extension handler's module list."); $list = module_implements('permission'); $this->assertTrue(in_array($module, $list), "{$module}_permission() in module_implements() found."); diff --git a/core/modules/system/lib/Drupal/system/Tests/Module/EnableDisableTest.php b/core/modules/system/lib/Drupal/system/Tests/Module/EnableDisableTest.php index ae829db..4a32d97 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Module/EnableDisableTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Module/EnableDisableTest.php @@ -43,7 +43,7 @@ function testEnableDisable() { // Remove already enabled modules (via installation profile). // @todo Remove this after removing all dependencies from Testing profile. - foreach ($this->container->get('extension_handler')->getModuleList() as $dependency => $filename) { + foreach ($this->container->get('module_handler')->getModuleList() as $dependency => $filename) { // Exclude required modules. Only installation profile "suggestions" can // be disabled and uninstalled. if (isset($modules[$dependency])) { diff --git a/core/modules/system/lib/Drupal/system/Tests/Module/ModuleApiTest.php b/core/modules/system/lib/Drupal/system/Tests/Module/ModuleApiTest.php index 8787f9b..5ea5306 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Module/ModuleApiTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Module/ModuleApiTest.php @@ -61,7 +61,7 @@ function testModuleList() { 'system' => 'core/modules/system/system.module', 'menu' => 'core/modules/menu/menu.module', ); - $this->container->get('extension_handler')->setModuleList($fixed_list); + $this->container->get('module_handler')->setModuleList($fixed_list); $new_module_list = array_combine(array_keys($fixed_list), array_keys($fixed_list)); $this->assertModuleList($new_module_list, t('When using a fixed list')); @@ -75,7 +75,7 @@ function testModuleList() { */ protected function assertModuleList(Array $expected_values, $condition) { $expected_values = array_values(array_unique($expected_values)); - $enabled_modules = array_keys($this->container->get('extension_handler')->getModuleList()); + $enabled_modules = array_keys($this->container->get('module_handler')->getModuleList()); $enabled_modules = sort($enabled_modules); $this->assertEqual($expected_values, $enabled_modules, format_string('@condition: extension handler returns correct results', array('@condition' => $condition))); } @@ -83,7 +83,7 @@ protected function assertModuleList(Array $expected_values, $condition) { /** * Test module_implements() caching. */ - function testModuleImplements() { + function testgetImplementations() { // Clear the cache. cache('bootstrap')->delete('module_implements'); $this->assertFalse(cache('bootstrap')->get('module_implements'), 'The module implements cache is empty.'); @@ -101,13 +101,11 @@ function testModuleImplements() { // already loaded when the cache is rebuilt. // For that activate the module_test which provides the file to load. module_enable(array('module_test')); - $extension_handler = drupal_container()->get('extension_handler'); - $extension_handler->loadAllModules(); + $module_handler = drupal_container()->get('module_handler'); + $module_handler->loadAll(); module_load_include('inc', 'module_test', 'module_test.file'); - $modules = $extension_handler->moduleImplements('test_hook'); + $modules = $module_handler->getImplementations('test_hook'); $this->assertTrue(in_array('module_test', $modules), 'Hook found.'); - $module_implementations = $extension_handler->getModuleHookImplementations(); - $this->assertEqual($module_implementations['test_hook']['module_test'], 'file', 'Include file detected.'); } /** @@ -123,7 +121,7 @@ function testModuleInvoke() { /** * Test that module_invoke_all() can load a hook defined in hook_hook_info(). */ - function testModuleInvokeAll() { + function testinvokeAll() { module_enable(array('module_test'), FALSE); $this->resetAll(); $this->drupalGet('module-test/hook-dynamic-loading-invoke-all'); @@ -133,10 +131,10 @@ function testModuleInvokeAll() { /** * Test that a menu item load function can invoke hooks defined in hook_hook_info(). * - * We test this separately from testModuleInvokeAll(), because menu item load + * We test this separately from testinvokeAll(), because menu item load * functions execute early in the request handling. */ - function testModuleInvokeAllDuringLoadFunction() { + function testinvokeAllDuringLoadFunction() { module_enable(array('module_test'), FALSE); $this->resetAll(); $this->drupalGet('module-test/hook-dynamic-loading-invoke-all-during-load/module_test'); diff --git a/core/modules/system/lib/Drupal/system/Tests/Module/ModuleTestBase.php b/core/modules/system/lib/Drupal/system/Tests/Module/ModuleTestBase.php index 49a29cf..a45a616 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Module/ModuleTestBase.php +++ b/core/modules/system/lib/Drupal/system/Tests/Module/ModuleTestBase.php @@ -151,7 +151,7 @@ function assertModules(array $modules, $enabled) { else { $message = 'Module "@module" is not enabled.'; } - $this->assertEqual($this->container->get('extension_handler')->moduleExists($module), $enabled, format_string($message, array('@module' => $module))); + $this->assertEqual($this->container->get('module_handler')->moduleExists($module), $enabled, format_string($message, array('@module' => $module))); } } diff --git a/core/modules/system/lib/Drupal/system/Tests/Theme/RegistryTest.php b/core/modules/system/lib/Drupal/system/Tests/Theme/RegistryTest.php index 1b683bb..5ab43ca 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Theme/RegistryTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Theme/RegistryTest.php @@ -40,7 +40,7 @@ function testRaceCondition() { // Directly instantiate the theme registry, this will cause a base cache // entry to be written in __construct(). - $registry = new ThemeRegistry($cid, 'cache', array('theme_registry' => TRUE), $this->container->get('extension_handler')->allModulesLoaded()); + $registry = new ThemeRegistry($cid, 'cache', array('theme_registry' => TRUE), $this->container->get('module_handler')->isLoaded()); $this->assertTrue(cache()->get($cid), 'Cache entry was created.'); diff --git a/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTest.php b/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTest.php index 1430f4d..6e9b383 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTest.php @@ -179,7 +179,7 @@ function testRegistryRebuild() { // container and ensure the extension handler is loaded, otherwise theme() // throws an exception. $this->rebuildContainer(); - $this->container->get('extension_handler')->loadAllModules(); + $this->container->get('module_handler')->loadAll(); $this->assertIdentical(theme('theme_test_foo', array('foo' => 'b')), '', 'The theme registry does not contain theme_test_foo, because the module is disabled.'); module_enable(array('theme_test'), FALSE); @@ -187,7 +187,7 @@ function testRegistryRebuild() { // container and ensure the extension handler is loaded, otherwise theme() // throws an exception. $this->rebuildContainer(); - $this->container->get('extension_handler')->loadAllModules(); + $this->container->get('module_handler')->loadAll(); $this->assertIdentical(theme('theme_test_foo', array('foo' => 'c')), 'c', 'The theme registry contains theme_test_foo again after re-enabling the module.'); } diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/BareMinimalUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/BareMinimalUpgradePathTest.php index 2be9d12..499acf2 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/BareMinimalUpgradePathTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/BareMinimalUpgradePathTest.php @@ -82,7 +82,7 @@ public function testBasicMinimalUpgrade() { $this->assertFalse($result, 'No {menu_links} entry exists for user/autocomplete'); // Verify that all required modules are enabled. - $enabled = $this->container->get('extension_handler')->getModuleList(); + $enabled = $this->container->get('module_handler')->getModuleList(); $required = array_filter(system_rebuild_module_data(), function ($data) { return !empty($data->info['required']); }); diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/ModulesDisabledUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/ModulesDisabledUpgradePathTest.php index 7034c01..2e3c725 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/ModulesDisabledUpgradePathTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/ModulesDisabledUpgradePathTest.php @@ -37,7 +37,7 @@ public function testDisabledUpgrade() { $this->assertTrue($this->performUpgrade(), 'The upgrade was completed successfully.'); // Get enabled modules. - $enabled = drupal_container()->get('extension_handler')->getModuleList(); + $enabled = drupal_container()->get('module_handler')->getModuleList(); // Get all available modules. $available = system_rebuild_module_data(); // Filter out hidden test modules. diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/UpgradePathTestBase.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/UpgradePathTestBase.php index 09f2b50..41432c6 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/UpgradePathTestBase.php +++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/UpgradePathTestBase.php @@ -265,8 +265,8 @@ protected function performUpgrade($register_errors = TRUE) { // Reload module list for modules that are enabled in the test database // but not on the test client. - drupal_container()->get('extension_handler')->moduleImplementsReset(); - drupal_container()->get('extension_handler')->reloadModules(); + drupal_container()->get('module_handler')->resetImplementations(); + drupal_container()->get('module_handler')->reload(); // Rebuild the container and all caches. $this->rebuildContainer(); diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc index 21b1366..37a2bf2 100644 --- a/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -1204,7 +1204,7 @@ function system_modules_submit($form, &$form_state) { // Gets list of modules prior to install process, unsets $form_state['storage'] // so we don't get redirected back to the confirmation form. - $pre_install_list = drupal_container()->get('extension_handler')->getModuleList(); + $pre_install_list = drupal_container()->get('module_handler')->getModuleList(); unset($form_state['storage']); // Reverse the 'enable' list, to order dependencies before dependents. @@ -1216,7 +1216,7 @@ function system_modules_submit($form, &$form_state) { // Gets module list after install process, flushes caches and displays a // message if there are changes. - $post_install_list = drupal_container()->get('extension_handler')->getModuleList(); + $post_install_list = drupal_container()->get('module_handler')->getModuleList(); if ($pre_install_list != $post_install_list) { drupal_flush_all_caches(); drupal_set_message(t('The configuration options have been saved.')); diff --git a/core/modules/system/system.install b/core/modules/system/system.install index 01baa71..e3f1539 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -400,7 +400,7 @@ function system_requirements($phase) { ); // Check installed modules. - foreach (drupal_container()->get('extension_handler')->getModuleList() as $module => $filename) { + foreach (drupal_container()->get('module_handler')->getModuleList() as $module => $filename) { $updates = drupal_get_schema_versions($module); if ($updates !== FALSE) { $default = drupal_get_installed_schema_version($module); diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 1e4573d..fd1b606 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -2752,7 +2752,7 @@ function system_get_info($type, $name = NULL) { $info = array(); if ($type == 'module') { $data = system_rebuild_module_data(); - foreach (drupal_container()->get('extension_handler')->getModuleList() as $module => $filename) { + foreach (drupal_container()->get('module_handler')->getModuleList() as $module => $filename) { $info[$module] = $data[$module]->info; } } @@ -2895,7 +2895,7 @@ function system_rebuild_module_data() { $record->schema_version = SCHEMA_UNINSTALLED; $files[$module] = $record->filename; } - $modules = drupal_container()->get('extension_handler')->buildModuleDependencies($modules); + $modules = drupal_container()->get('module_handler')->buildModuleDependencies($modules); $modules_cache = $modules; // Store filenames to allow system_list() and drupal_get_filename() to diff --git a/core/modules/update/lib/Drupal/update/Tests/UpdateUploadTest.php b/core/modules/update/lib/Drupal/update/Tests/UpdateUploadTest.php index d3bcdb8..f785151 100644 --- a/core/modules/update/lib/Drupal/update/Tests/UpdateUploadTest.php +++ b/core/modules/update/lib/Drupal/update/Tests/UpdateUploadTest.php @@ -36,7 +36,7 @@ public function setUp() { /** * Tests upload and extraction of a module. */ - public function testUploadModule() { + public function testUpload() { // Images are not valid archives, so get one and try to install it. We // need an extra variable to store the result of drupalGetTestFiles() // since reset() takes an argument by reference and passing in a constant diff --git a/core/scripts/dump-database-d6.sh b/core/scripts/dump-database-d6.sh index 18453e6..106568d 100644 --- a/core/scripts/dump-database-d6.sh +++ b/core/scripts/dump-database-d6.sh @@ -44,7 +44,7 @@ ENDOFHEADER; -foreach (drupal_container()->get('extension_handler')->getModuleList() as $module => $filename) { +foreach (drupal_container()->get('module_handler')->getModuleList() as $module => $filename) { $output .= " * - $module\n"; } $output .= " */\n\n"; diff --git a/core/scripts/dump-database-d7.sh b/core/scripts/dump-database-d7.sh index 8489520..3b8597d 100644 --- a/core/scripts/dump-database-d7.sh +++ b/core/scripts/dump-database-d7.sh @@ -45,7 +45,7 @@ ENDOFHEADER; -foreach (drupal_container()->get('extension_handler')->getModuleList() as $module => $filename) { +foreach (drupal_container()->get('module_handler')->getModuleList() as $module => $filename) { $output .= " * - $module\n"; } $output .= " */\n\n"; diff --git a/core/update.php b/core/update.php index 0b5570c..69f058a 100644 --- a/core/update.php +++ b/core/update.php @@ -436,13 +436,13 @@ function update_check_requirements($skip_warnings = FALSE) { // Load module basics. include_once DRUPAL_ROOT . '/core/includes/module.inc'; $module_list['system'] = 'core/modules/system/system.module'; - $extension_handler = drupal_container()->get('extension_handler'); - $extension_handler->setModuleList($module_list); - $extension_handler->loadModule('system'); + $module_handler = drupal_container()->get('module_handler'); + $module_handler->setModuleList($module_list); + $module_handler->load('system'); // Reset the module implementations cache so that any new hook implementations // in updated code are picked up. - $extension_handler->moduleImplementsReset(); + $module_handler->resetImplementations(); // Set up $language, since the installer components require it. drupal_language_initialize();