diff --git a/core/includes/common.inc b/core/includes/common.inc index 53e0be5c91..7420d020d5 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -1120,7 +1120,7 @@ function drupal_flush_all_caches() { PhpStorageFactory::get('twig')->deleteAll(); // Rebuild module and theme data. - $module_data = system_rebuild_module_data(); + $module_data = \Drupal::service('extension.list.module')->reset()->getList(); /** @var \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler */ $theme_handler = \Drupal::service('theme_handler'); $theme_handler->refreshInfo(); diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index b4c731da3c..06f7192973 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -1501,7 +1501,7 @@ function install_profile_modules(&$install_state) { install_core_entity_type_definitions(); $modules = \Drupal::state()->get('install_profile_modules') ?: []; - $files = system_rebuild_module_data(); + $files = \Drupal::service('extension.list.module')->reset()->getList(); \Drupal::state()->delete('install_profile_modules'); // Always install required modules first. Respect the dependencies between diff --git a/core/includes/update.inc b/core/includes/update.inc index d7fe942ebd..5c95508f43 100644 --- a/core/includes/update.inc +++ b/core/includes/update.inc @@ -43,7 +43,7 @@ function update_check_incompatibility($name, $type = 'module') { // code changes that were made in the filesystem before the update script // was initiated. $themes = \Drupal::service('theme_handler')->rebuildThemeData(); - $modules = system_rebuild_module_data(); + $modules = \Drupal::service('extension.list.module')->getList(); } if ($type == 'module' && isset($modules[$name])) { diff --git a/core/lib/Drupal/Core/Config/ConfigImporter.php b/core/lib/Drupal/Core/Config/ConfigImporter.php index b58f96358b..2857fd7b4e 100644 --- a/core/lib/Drupal/Core/Config/ConfigImporter.php +++ b/core/lib/Drupal/Core/Config/ConfigImporter.php @@ -3,6 +3,7 @@ namespace Drupal\Core\Config; use Drupal\Core\Config\Importer\MissingContentEvent; +use Drupal\Core\Extension\ModuleExtensionList; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Extension\ModuleInstallerInterface; use Drupal\Core\Extension\ThemeHandlerInterface; @@ -158,6 +159,13 @@ class ConfigImporter { */ protected $moduleInstaller; + /** + * The module extension list. + * + * @var \Drupal\Core\Extension\ModuleExtensionList + */ + protected $moduleExtensionList; + /** * Constructs a configuration import object. * @@ -180,8 +188,10 @@ class ConfigImporter { * The theme handler * @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation * The string translation service. + * @param \Drupal\Core\Extension\ModuleExtensionList $extension_list_module + * The module extension list */ - public function __construct(StorageComparerInterface $storage_comparer, EventDispatcherInterface $event_dispatcher, ConfigManagerInterface $config_manager, LockBackendInterface $lock, TypedConfigManagerInterface $typed_config, ModuleHandlerInterface $module_handler, ModuleInstallerInterface $module_installer, ThemeHandlerInterface $theme_handler, TranslationInterface $string_translation) { + public function __construct(StorageComparerInterface $storage_comparer, EventDispatcherInterface $event_dispatcher, ConfigManagerInterface $config_manager, LockBackendInterface $lock, TypedConfigManagerInterface $typed_config, ModuleHandlerInterface $module_handler, ModuleInstallerInterface $module_installer, ThemeHandlerInterface $theme_handler, TranslationInterface $string_translation, ModuleExtensionList $extension_list_module) { $this->storageComparer = $storage_comparer; $this->eventDispatcher = $event_dispatcher; $this->configManager = $config_manager; @@ -191,6 +201,7 @@ public function __construct(StorageComparerInterface $storage_comparer, EventDis $this->moduleInstaller = $module_installer; $this->themeHandler = $theme_handler; $this->stringTranslation = $string_translation; + $this->moduleExtensionList = $extension_list_module; foreach ($this->storageComparer->getAllCollectionNames() as $collection) { $this->processedConfiguration[$collection] = $this->storageComparer->getEmptyChangelist(); } @@ -369,7 +380,7 @@ protected function createExtensionChangelist() { } // Get a list of modules with dependency weights as values. - $module_data = system_rebuild_module_data(); + $module_data = $this->moduleExtensionList->getList(); // Set the actual module weights. $module_list = array_combine(array_keys($module_data), array_keys($module_data)); $module_list = array_map(function ($module) use ($module_data) { diff --git a/core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php index ea7d29fedf..fe5bdfbdfe 100644 --- a/core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php @@ -303,7 +303,7 @@ protected function getThemeData() { */ protected function getModuleData() { if (!isset($this->moduleData)) { - $this->moduleData = system_rebuild_module_data(); + $this->moduleData = \Drupal::service('extension.list.module')->getList(); } return $this->moduleData; } diff --git a/core/lib/Drupal/Core/Extension/ModuleInstaller.php b/core/lib/Drupal/Core/Extension/ModuleInstaller.php index 2cf34bd22f..c01aaa0035 100644 --- a/core/lib/Drupal/Core/Extension/ModuleInstaller.php +++ b/core/lib/Drupal/Core/Extension/ModuleInstaller.php @@ -83,7 +83,7 @@ public function install(array $module_list, $enable_dependencies = TRUE) { $extension_config = \Drupal::configFactory()->getEditable('core.extension'); if ($enable_dependencies) { // Get all module data so we can find dependencies and sort. - $module_data = system_rebuild_module_data(); + $module_data = \Drupal::service('extension.list.module')->reset()->getList(); $module_list = $module_list ? array_combine($module_list, $module_list) : []; if ($missing_modules = array_diff_key($module_list, $module_data)) { // One or more of the given modules doesn't exist. @@ -329,7 +329,7 @@ public function install(array $module_list, $enable_dependencies = TRUE) { */ public function uninstall(array $module_list, $uninstall_dependents = TRUE) { // Get all module data so we can find dependencies and sort. - $module_data = system_rebuild_module_data(); + $module_data = \Drupal::service('extension.list.module')->getList(); $module_list = $module_list ? array_combine($module_list, $module_list) : []; if (array_diff_key($module_list, $module_data)) { // One or more of the given modules doesn't exist. diff --git a/core/lib/Drupal/Core/Extension/RequiredModuleUninstallValidator.php b/core/lib/Drupal/Core/Extension/RequiredModuleUninstallValidator.php index d3fa533e93..8b90f0d161 100644 --- a/core/lib/Drupal/Core/Extension/RequiredModuleUninstallValidator.php +++ b/core/lib/Drupal/Core/Extension/RequiredModuleUninstallValidator.php @@ -44,7 +44,7 @@ public function validate($module) { * The module info, or NULL if that module does not exist. */ protected function getModuleInfoByModule($module) { - $modules = system_rebuild_module_data(); + $modules = \Drupal::service('extension.list.module')->getList(); return isset($modules[$module]->info) ? $modules[$module]->info : []; } diff --git a/core/lib/Drupal/Core/Extension/module.api.php b/core/lib/Drupal/Core/Extension/module.api.php index 45355cc3f6..e39c3411e6 100644 --- a/core/lib/Drupal/Core/Extension/module.api.php +++ b/core/lib/Drupal/Core/Extension/module.api.php @@ -131,7 +131,7 @@ function hook_module_implements_alter(&$implementations, $hook) { /** * Alter the information parsed from module and theme .info.yml files. * - * This hook is invoked in _system_rebuild_module_data() and in + * This hook is invoked in \Drupal\Core\Extension\ExtensionList::getList() and in * \Drupal\Core\Extension\ThemeHandlerInterface::rebuildThemeData(). A module * may implement this hook in order to add to or alter the data generated by * reading the .info.yml file with \Drupal\Core\Extension\InfoParser. diff --git a/core/modules/config/src/Form/ConfigSingleImportForm.php b/core/modules/config/src/Form/ConfigSingleImportForm.php index 9f9a8d9281..3db18eac16 100644 --- a/core/modules/config/src/Form/ConfigSingleImportForm.php +++ b/core/modules/config/src/Form/ConfigSingleImportForm.php @@ -12,6 +12,7 @@ use Drupal\Core\Config\StorageInterface; use Drupal\Core\Config\TypedConfigManagerInterface; use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Extension\ModuleExtensionList; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Extension\ModuleInstallerInterface; use Drupal\Core\Extension\ThemeHandlerInterface; @@ -94,6 +95,13 @@ class ConfigSingleImportForm extends ConfirmFormBase { */ protected $themeHandler; + /** + * The module extension list. + * + * @var \Drupal\Core\Extension\ModuleExtensionList + */ + protected $moduleExtensionList; + /** * The module installer. * @@ -138,8 +146,10 @@ class ConfigSingleImportForm extends ConfirmFormBase { * The module installer. * @param \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler * The theme handler. + * @param \Drupal\Core\Extension\ModuleExtensionList $extension_list_module + * The module extension list */ - public function __construct(EntityManagerInterface $entity_manager, StorageInterface $config_storage, RendererInterface $renderer, EventDispatcherInterface $event_dispatcher, ConfigManagerInterface $config_manager, LockBackendInterface $lock, TypedConfigManagerInterface $typed_config, ModuleHandlerInterface $module_handler, ModuleInstallerInterface $module_installer, ThemeHandlerInterface $theme_handler) { + public function __construct(EntityManagerInterface $entity_manager, StorageInterface $config_storage, RendererInterface $renderer, EventDispatcherInterface $event_dispatcher, ConfigManagerInterface $config_manager, LockBackendInterface $lock, TypedConfigManagerInterface $typed_config, ModuleHandlerInterface $module_handler, ModuleInstallerInterface $module_installer, ThemeHandlerInterface $theme_handler, ModuleExtensionList $extension_list_module) { $this->entityManager = $entity_manager; $this->configStorage = $config_storage; $this->renderer = $renderer; @@ -152,6 +162,7 @@ public function __construct(EntityManagerInterface $entity_manager, StorageInter $this->moduleHandler = $module_handler; $this->moduleInstaller = $module_installer; $this->themeHandler = $theme_handler; + $this->moduleExtensionList = $extension_list_module; } /** @@ -168,7 +179,8 @@ public static function create(ContainerInterface $container) { $container->get('config.typed'), $container->get('module_handler'), $container->get('module_installer'), - $container->get('theme_handler') + $container->get('theme_handler'), + $container->get('extension.list.module') ); } @@ -358,7 +370,8 @@ public function validateForm(array &$form, FormStateInterface $form_state) { $this->moduleHandler, $this->moduleInstaller, $this->themeHandler, - $this->getStringTranslation() + $this->getStringTranslation(), + $this->moduleExtensionList ); try { diff --git a/core/modules/config/src/Form/ConfigSync.php b/core/modules/config/src/Form/ConfigSync.php index 281309922a..4232b2b1d9 100644 --- a/core/modules/config/src/Form/ConfigSync.php +++ b/core/modules/config/src/Form/ConfigSync.php @@ -5,6 +5,7 @@ use Drupal\Core\Config\ConfigImporterException; use Drupal\Core\Config\ConfigImporter; use Drupal\Core\Config\TypedConfigManagerInterface; +use Drupal\Core\Extension\ModuleExtensionList; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Extension\ModuleInstallerInterface; use Drupal\Core\Extension\ThemeHandlerInterface; @@ -103,6 +104,13 @@ class ConfigSync extends FormBase { */ protected $renderer; + /** + * The module extension list. + * + * @var \Drupal\Core\Extension\ModuleExtensionList + */ + protected $moduleExtensionList; + /** * Constructs the object. * @@ -128,8 +136,10 @@ class ConfigSync extends FormBase { * The theme handler. * @param \Drupal\Core\Render\RendererInterface $renderer * The renderer. + * @param \Drupal\Core\Extension\ModuleExtensionList $extension_list_module + * The module extension list */ - public function __construct(StorageInterface $sync_storage, StorageInterface $active_storage, StorageInterface $snapshot_storage, LockBackendInterface $lock, EventDispatcherInterface $event_dispatcher, ConfigManagerInterface $config_manager, TypedConfigManagerInterface $typed_config, ModuleHandlerInterface $module_handler, ModuleInstallerInterface $module_installer, ThemeHandlerInterface $theme_handler, RendererInterface $renderer) { + public function __construct(StorageInterface $sync_storage, StorageInterface $active_storage, StorageInterface $snapshot_storage, LockBackendInterface $lock, EventDispatcherInterface $event_dispatcher, ConfigManagerInterface $config_manager, TypedConfigManagerInterface $typed_config, ModuleHandlerInterface $module_handler, ModuleInstallerInterface $module_installer, ThemeHandlerInterface $theme_handler, RendererInterface $renderer, ModuleExtensionList $extension_list_module) { $this->syncStorage = $sync_storage; $this->activeStorage = $active_storage; $this->snapshotStorage = $snapshot_storage; @@ -141,6 +151,7 @@ public function __construct(StorageInterface $sync_storage, StorageInterface $ac $this->moduleInstaller = $module_installer; $this->themeHandler = $theme_handler; $this->renderer = $renderer; + $this->moduleExtensionList = $extension_list_module; } /** @@ -158,7 +169,8 @@ public static function create(ContainerInterface $container) { $container->get('module_handler'), $container->get('module_installer'), $container->get('theme_handler'), - $container->get('renderer') + $container->get('renderer'), + $container->get('extension.list.module') ); } @@ -327,7 +339,8 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $this->moduleHandler, $this->moduleInstaller, $this->themeHandler, - $this->getStringTranslation() + $this->getStringTranslation(), + $this->moduleExtensionList ); if ($config_importer->alreadyImporting()) { drupal_set_message($this->t('Another request may be synchronizing configuration already.')); diff --git a/core/modules/config/tests/src/Functional/ConfigImportAllTest.php b/core/modules/config/tests/src/Functional/ConfigImportAllTest.php index 4823e6bf07..612b525bcc 100644 --- a/core/modules/config/tests/src/Functional/ConfigImportAllTest.php +++ b/core/modules/config/tests/src/Functional/ConfigImportAllTest.php @@ -47,7 +47,7 @@ protected function setUp() { public function testInstallUninstall() { // Get a list of modules to enable. - $all_modules = system_rebuild_module_data(); + $all_modules = $this->container->get('extension.list.module')->getList(); $all_modules = array_filter($all_modules, function ($module) { // Filter contrib, hidden, already enabled modules and modules in the // Testing package. @@ -93,8 +93,7 @@ public function testInstallUninstall() { $shortcuts = Shortcut::loadMultiple(); entity_delete_multiple('shortcut', array_keys($shortcuts)); - system_list_reset(); - $all_modules = system_rebuild_module_data(); + $all_modules = \Drupal::service('extension.list.module')->reset()->getList(); // Ensure that only core required modules and the install profile can not be uninstalled. $validation_reasons = \Drupal::service('module_installer')->validateUninstall(array_keys($all_modules)); diff --git a/core/modules/config/tests/src/Functional/ConfigImportUITest.php b/core/modules/config/tests/src/Functional/ConfigImportUITest.php index fd76990da6..a6ce280e81 100644 --- a/core/modules/config/tests/src/Functional/ConfigImportUITest.php +++ b/core/modules/config/tests/src/Functional/ConfigImportUITest.php @@ -498,7 +498,7 @@ public function testExtensionValidation() { $core = $sync->read('core.extension'); // Node depends on text. unset($core['module']['text']); - $module_data = system_rebuild_module_data(); + $module_data = $this->container->get('extension.list.module')->getList(); $this->assertTrue(isset($module_data['node']->requires['text']), 'The Node module depends on the Text module.'); // Bartik depends on classy. unset($core['theme']['classy']); diff --git a/core/modules/content_translation/tests/src/Kernel/ContentTranslationConfigImportTest.php b/core/modules/content_translation/tests/src/Kernel/ContentTranslationConfigImportTest.php index b8776a26a1..78b4de6408 100644 --- a/core/modules/content_translation/tests/src/Kernel/ContentTranslationConfigImportTest.php +++ b/core/modules/content_translation/tests/src/Kernel/ContentTranslationConfigImportTest.php @@ -51,7 +51,8 @@ protected function setUp() { $this->container->get('module_handler'), $this->container->get('module_installer'), $this->container->get('theme_handler'), - $this->container->get('string_translation') + $this->container->get('string_translation'), + $this->container->get('extension.list.module') ); } diff --git a/core/modules/field/tests/src/Kernel/FieldDefinitionIntegrityTest.php b/core/modules/field/tests/src/Kernel/FieldDefinitionIntegrityTest.php index afd468a5da..a4a0f1000f 100644 --- a/core/modules/field/tests/src/Kernel/FieldDefinitionIntegrityTest.php +++ b/core/modules/field/tests/src/Kernel/FieldDefinitionIntegrityTest.php @@ -197,7 +197,7 @@ protected function checkDisplayOption($entity_type_id, $field_id, BaseFieldDefin * and all modules required by any of these modules. */ protected function modulesWithSubdirectory($subdirectory) { - $modules = system_rebuild_module_data(); + $modules = $this->container->get('extension.list.module')->getList(); $modules = array_filter($modules, function (Extension $module) use ($subdirectory) { // Filter contrib, hidden, already enabled modules and modules in the // Testing package. diff --git a/core/modules/help/tests/src/Functional/HelpTest.php b/core/modules/help/tests/src/Functional/HelpTest.php index dff11ef173..0946ac6b29 100644 --- a/core/modules/help/tests/src/Functional/HelpTest.php +++ b/core/modules/help/tests/src/Functional/HelpTest.php @@ -152,7 +152,7 @@ protected function verifyHelp($response = 200) { */ protected function getModuleList() { $modules = []; - $module_data = system_rebuild_module_data(); + $module_data = $this->container->get('extension.list.module')->getList(); foreach (\Drupal::moduleHandler()->getImplementations('help') as $module) { $modules[$module] = $module_data[$module]->info['name']; } diff --git a/core/modules/help/tests/src/Kernel/HelpEmptyPageTest.php b/core/modules/help/tests/src/Kernel/HelpEmptyPageTest.php index 070a95451b..61e1a7cdbb 100644 --- a/core/modules/help/tests/src/Kernel/HelpEmptyPageTest.php +++ b/core/modules/help/tests/src/Kernel/HelpEmptyPageTest.php @@ -32,7 +32,7 @@ public function register(ContainerBuilder $container) { * Ensures that no URL generator is called on a page without hook_help(). */ public function testEmptyHookHelp() { - $all_modules = system_rebuild_module_data(); + $all_modules = $this->container->get('extension.list.module')->getList();; $all_modules = array_filter($all_modules, function ($module) { // Filter contrib, hidden, already enabled modules and modules in the // Testing package. diff --git a/core/modules/locale/locale.compare.inc b/core/modules/locale/locale.compare.inc index c66af14108..1c42b7ecdf 100644 --- a/core/modules/locale/locale.compare.inc +++ b/core/modules/locale/locale.compare.inc @@ -103,7 +103,7 @@ function locale_translation_project_list() { 'interface translation project', 'interface translation server pattern', ]; - $module_data = _locale_translation_prepare_project_list(system_rebuild_module_data(), 'module'); + $module_data = _locale_translation_prepare_project_list(\Drupal::service('extension.list.module')->getList(), 'module'); $theme_data = _locale_translation_prepare_project_list(\Drupal::service('theme_handler')->rebuildThemeData(), 'theme'); $project_info = new ProjectInfo(); $project_info->processInfoList($projects, $module_data, 'module', TRUE, $additional_whitelist); diff --git a/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceRestTestCoverageTest.php b/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceRestTestCoverageTest.php index d10d55c245..78ca44fa41 100644 --- a/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceRestTestCoverageTest.php +++ b/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceRestTestCoverageTest.php @@ -28,7 +28,7 @@ class EntityResourceRestTestCoverageTest extends BrowserTestBase { protected function setUp() { parent::setUp(); - $all_modules = system_rebuild_module_data(); + $all_modules = $this->container->get('extension.list.module')->getList();; $stable_core_modules = array_filter($all_modules, function ($module) { // Filter out contrib, hidden, testing, and experimental modules. We also // don't need to enable modules that are already enabled. diff --git a/core/modules/system/src/Form/ModulesListForm.php b/core/modules/system/src/Form/ModulesListForm.php index 3ff6c3d09d..195b15e152 100644 --- a/core/modules/system/src/Form/ModulesListForm.php +++ b/core/modules/system/src/Form/ModulesListForm.php @@ -143,7 +143,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { ]; // Sort all modules by their names. - $modules = system_rebuild_module_data(); + $modules = \Drupal::service('extension.list.module')->getList(); uasort($modules, 'system_sort_modules_by_info_name'); // Iterate over each of the modules. @@ -368,7 +368,7 @@ protected function buildModuleList(FormStateInterface $form_state) { 'experimental' => [], ]; - $data = system_rebuild_module_data(); + $data = \Drupal::service('extension.list.module')->getList(); foreach ($data as $name => $module) { // If the module is installed there is nothing to do. if ($this->moduleHandler->moduleExists($name)) { diff --git a/core/modules/system/src/Form/ModulesUninstallConfirmForm.php b/core/modules/system/src/Form/ModulesUninstallConfirmForm.php index f55f0d69ec..1caa8d143b 100644 --- a/core/modules/system/src/Form/ModulesUninstallConfirmForm.php +++ b/core/modules/system/src/Form/ModulesUninstallConfirmForm.php @@ -135,7 +135,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { return $this->redirect('system.modules_uninstall'); } - $data = system_rebuild_module_data(); + $data = \Drupal::service('extension.list.module')->getList(); $form['text']['#markup'] = '

' . $this->t('The following modules will be completely uninstalled from your site, and all data from these modules will be lost!') . '

'; $form['modules'] = [ '#theme' => 'item_list', diff --git a/core/modules/system/src/Form/ModulesUninstallForm.php b/core/modules/system/src/Form/ModulesUninstallForm.php index 7949067925..9fcefc3e32 100644 --- a/core/modules/system/src/Form/ModulesUninstallForm.php +++ b/core/modules/system/src/Form/ModulesUninstallForm.php @@ -79,7 +79,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { include_once DRUPAL_ROOT . '/core/includes/install.inc'; // Get a list of all available modules. - $modules = system_rebuild_module_data(); + $modules = \Drupal::service('extension.list.module')->getList(); $uninstallable = array_filter($modules, function ($module) use ($modules) { return empty($modules[$module->getName()]->info['required']) && $module->status; }); diff --git a/core/modules/system/system.install b/core/modules/system/system.install index ed05621335..a5c9a85752 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -787,7 +787,7 @@ function system_requirements($phase) { // Display an error if a newly introduced dependency in a module is not resolved. if ($phase == 'update') { $profile = drupal_get_profile(); - $files = system_rebuild_module_data(); + $files = \Drupal::service('extension.list.module')->getList(); foreach ($files as $module => $file) { // Ignore disabled modules and installation profiles. if (!$file->status || $module == $profile) { diff --git a/core/modules/system/system.module b/core/modules/system/system.module index bb82d4b19f..386d80b953 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -955,7 +955,7 @@ function system_check_directory($form_element, FormStateInterface $form_state) { * information for $name, if given. If no records are available, an empty * array is returned. * - * @see system_rebuild_module_data() + * @see \Drupal\Core\Extension\ModuleExtensionList::getList() * @see \Drupal\Core\Extension\ThemeHandlerInterface::rebuildThemeData() */ function system_get_info($type, $name = NULL) { diff --git a/core/modules/system/tests/src/Functional/Module/InstallUninstallTest.php b/core/modules/system/tests/src/Functional/Module/InstallUninstallTest.php index 4d8f30d65c..ac6685a105 100644 --- a/core/modules/system/tests/src/Functional/Module/InstallUninstallTest.php +++ b/core/modules/system/tests/src/Functional/Module/InstallUninstallTest.php @@ -33,7 +33,7 @@ public function testInstallUninstall() { $this->assertEqual($this->container->get('state')->get('system_test_preuninstall_module'), 'module_test'); $this->resetAll(); - $all_modules = system_rebuild_module_data(); + $all_modules = $this->container->get('extension.list.module')->reset()->getList(); // Test help on required modules, but do not test uninstalling. $required_modules = array_filter($all_modules, function ($module) { diff --git a/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php b/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php index a8767e92d5..30d3c3d1a1 100644 --- a/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php +++ b/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php @@ -25,14 +25,7 @@ class ModuleHandlerTest extends KernelTestBase { protected function setUp() { parent::setUp(); - // @todo ModuleInstaller calls system_rebuild_module_data which is part of - // system.module, see https://www.drupal.org/node/2208429. - include_once $this->root . '/core/modules/system/system.module'; - - // Set up the state values so we know where to find the files when running - // drupal_get_filename(). - // @todo Remove as part of https://www.drupal.org/node/2186491 - system_rebuild_module_data(); + $this->container->get('extension.list.module')->getList(); } /** @@ -259,7 +252,7 @@ public function testUninstallContentDependency() { */ public function testModuleMetaData() { // Generate the list of available modules. - $modules = system_rebuild_module_data(); + $modules = $this->container->get('extension.list.module')->getList(); // Check that the mtime field exists for the system module. $this->assertTrue(!empty($modules['system']->info['mtime']), 'The system.info.yml file modification time field is present.'); // Use 0 if mtime isn't present, to avoid an array index notice. diff --git a/core/modules/system/tests/src/Kernel/System/InfoAlterTest.php b/core/modules/system/tests/src/Kernel/System/InfoAlterTest.php index ebdac3ce0d..ee5fbf6adf 100644 --- a/core/modules/system/tests/src/Kernel/System/InfoAlterTest.php +++ b/core/modules/system/tests/src/Kernel/System/InfoAlterTest.php @@ -22,14 +22,14 @@ class InfoAlterTest extends KernelTestBase { */ public function testSystemInfoAlter() { \Drupal::state()->set('module_required_test.hook_system_info_alter', TRUE); - $info = system_rebuild_module_data(); + $info = \Drupal::service('extension.list.module')->getList(); $this->assertFalse(isset($info['node']->info['required']), 'Before the module_required_test is installed the node module is not required.'); // Enable the test module. \Drupal::service('module_installer')->install(['module_required_test'], FALSE); $this->assertTrue(\Drupal::moduleHandler()->moduleExists('module_required_test'), 'Test required module is enabled.'); - $info = system_rebuild_module_data(); + $info = \Drupal::service('extension.list.module')->getList(); $this->assertTrue($info['node']->info['required'], 'After the module_required_test is installed the node module is required.'); } diff --git a/core/modules/update/src/UpdateManager.php b/core/modules/update/src/UpdateManager.php index 07416915af..bc1c491e11 100644 --- a/core/modules/update/src/UpdateManager.php +++ b/core/modules/update/src/UpdateManager.php @@ -129,7 +129,7 @@ public function getProjects() { $this->projects = $this->projectStorage('update_project_projects'); if (empty($this->projects)) { // Still empty, so we have to rebuild. - $module_data = system_rebuild_module_data(); + $module_data = \Drupal::service('extension.list.module')->getList(); $theme_data = $this->themeHandler->rebuildThemeData(); $project_info = new ProjectInfo(); $project_info->processInfoList($this->projects, $module_data, 'module', TRUE); diff --git a/core/modules/update/tests/src/Functional/UpdateContribTest.php b/core/modules/update/tests/src/Functional/UpdateContribTest.php index 20d397cd48..343a157f55 100644 --- a/core/modules/update/tests/src/Functional/UpdateContribTest.php +++ b/core/modules/update/tests/src/Functional/UpdateContribTest.php @@ -120,7 +120,7 @@ public function testUpdateContribBasic() { * project. We need to make sure that we see the "BBB" project before the * "CCC" project, even though "CCC" includes a module that's processed first * if you sort alphabetically by module name (which is the order we see things - * inside system_rebuild_module_data() for example). + * inside \Drupal\Core\Extension\ExtensionList::getList() for example). */ public function testUpdateContribOrder() { // We want core to be version 8.0.0. diff --git a/core/modules/user/src/PermissionHandler.php b/core/modules/user/src/PermissionHandler.php index 1f07b25d95..056c435dff 100644 --- a/core/modules/user/src/PermissionHandler.php +++ b/core/modules/user/src/PermissionHandler.php @@ -229,13 +229,4 @@ protected function getModuleNames() { return $modules; } - /** - * Wraps system_rebuild_module_data() - * - * @return \Drupal\Core\Extension\Extension[] - */ - protected function systemRebuildModuleData() { - return system_rebuild_module_data(); - } - } diff --git a/core/modules/user/tests/src/Unit/PermissionHandlerTest.php b/core/modules/user/tests/src/Unit/PermissionHandlerTest.php index 2918d2f61e..94791ce74a 100644 --- a/core/modules/user/tests/src/Unit/PermissionHandlerTest.php +++ b/core/modules/user/tests/src/Unit/PermissionHandlerTest.php @@ -29,7 +29,7 @@ class PermissionHandlerTest extends UnitTestCase { /** * The tested permission handler. * - * @var \Drupal\Tests\user\Unit\TestPermissionHandler|\Drupal\user\PermissionHandler + * @var \Drupal\user\PermissionHandler */ protected $permissionHandler; @@ -142,10 +142,7 @@ public function testBuildPermissionsYaml() { $this->controllerResolver->expects($this->never()) ->method('getControllerFromDefinition'); - $this->permissionHandler = new TestPermissionHandler($this->moduleHandler, $this->stringTranslation, $this->controllerResolver); - - // Setup system_rebuild_module_data(). - $this->permissionHandler->setSystemRebuildModuleData($extensions); + $this->permissionHandler = new PermissionHandler($this->moduleHandler, $this->stringTranslation, $this->controllerResolver); $actual_permissions = $this->permissionHandler->getPermissions(); $this->assertPermissions($actual_permissions); @@ -206,7 +203,7 @@ public function testBuildPermissionsSortPerModule() { ->method('getModuleList') ->willReturn(array_flip($modules)); - $permissionHandler = new TestPermissionHandler($this->moduleHandler, $this->stringTranslation, $this->controllerResolver); + $permissionHandler = new PermissionHandler($this->moduleHandler, $this->stringTranslation, $this->controllerResolver); $actual_permissions = $permissionHandler->getPermissions(); $this->assertEquals(['access_module_a4', 'access_module_a1', 'access_module_a2', 'access_module_a3'], array_keys($actual_permissions)); @@ -287,10 +284,7 @@ public function testBuildPermissionsYamlCallback() { ->with('Drupal\\user\\Tests\\TestPermissionCallbacks::titleDescriptionRestrictAccess') ->willReturn([new TestPermissionCallbacks(), 'titleDescriptionRestrictAccess']); - $this->permissionHandler = new TestPermissionHandler($this->moduleHandler, $this->stringTranslation, $this->controllerResolver); - - // Setup system_rebuild_module_data(). - $this->permissionHandler->setSystemRebuildModuleData($extensions); + $this->permissionHandler = new PermissionHandler($this->moduleHandler, $this->stringTranslation, $this->controllerResolver); $actual_permissions = $this->permissionHandler->getPermissions(); $this->assertPermissions($actual_permissions); @@ -341,10 +335,7 @@ public function testPermissionsYamlStaticAndCallback() { ->with('Drupal\\user\\Tests\\TestPermissionCallbacks::titleDescription') ->willReturn([new TestPermissionCallbacks(), 'titleDescription']); - $this->permissionHandler = new TestPermissionHandler($this->moduleHandler, $this->stringTranslation, $this->controllerResolver); - - // Setup system_rebuild_module_data(). - $this->permissionHandler->setSystemRebuildModuleData($extensions); + $this->permissionHandler = new PermissionHandler($this->moduleHandler, $this->stringTranslation, $this->controllerResolver); $actual_permissions = $this->permissionHandler->getPermissions(); @@ -377,25 +368,6 @@ protected function assertPermissions(array $actual_permissions) { } -class TestPermissionHandler extends PermissionHandler { - - /** - * Test module data. - * - * @var array - */ - protected $systemModuleData; - - protected function systemRebuildModuleData() { - return $this->systemModuleData; - } - - public function setSystemRebuildModuleData(array $extensions) { - $this->systemModuleData = $extensions; - } - -} - class TestPermissionCallbacks { public function singleDescription() { diff --git a/core/tests/Drupal/KernelTests/Config/DefaultConfigTest.php b/core/tests/Drupal/KernelTests/Config/DefaultConfigTest.php index 39a5accae3..79da3b3d23 100644 --- a/core/tests/Drupal/KernelTests/Config/DefaultConfigTest.php +++ b/core/tests/Drupal/KernelTests/Config/DefaultConfigTest.php @@ -50,14 +50,7 @@ class DefaultConfigTest extends KernelTestBase { protected function setUp() { parent::setUp(); - // @todo ModuleInstaller calls system_rebuild_module_data which is part of - // system.module, see https://www.drupal.org/node/2208429. - include_once $this->root . '/core/modules/system/system.module'; - - // Set up the state values so we know where to find the files when running - // drupal_get_filename(). - // @todo Remove as part of https://www.drupal.org/node/2186491 - system_rebuild_module_data(); + $this->container->get('extension.list.module')->reset(); } /** diff --git a/core/tests/Drupal/KernelTests/Core/Asset/ResolvedLibraryDefinitionsFilesMatchTest.php b/core/tests/Drupal/KernelTests/Core/Asset/ResolvedLibraryDefinitionsFilesMatchTest.php index 2131a35ad0..5717c52f94 100644 --- a/core/tests/Drupal/KernelTests/Core/Asset/ResolvedLibraryDefinitionsFilesMatchTest.php +++ b/core/tests/Drupal/KernelTests/Core/Asset/ResolvedLibraryDefinitionsFilesMatchTest.php @@ -99,7 +99,7 @@ protected function setUp() { $this->container->get('theme_installer')->install($this->allThemes); // Enable all core modules. - $all_modules = system_rebuild_module_data(); + $all_modules = $this->container->get('extension.list.module')->reset()->getList(); $all_modules = array_filter($all_modules, function ($module) { // Filter contrib, hidden, already enabled modules and modules in the // Testing package. diff --git a/core/tests/Drupal/KernelTests/Core/Bootstrap/GetFilenameTest.php b/core/tests/Drupal/KernelTests/Core/Bootstrap/GetFilenameTest.php index 396facf158..4845f4fd59 100644 --- a/core/tests/Drupal/KernelTests/Core/Bootstrap/GetFilenameTest.php +++ b/core/tests/Drupal/KernelTests/Core/Bootstrap/GetFilenameTest.php @@ -30,10 +30,8 @@ public function register(ContainerBuilder $container) { * Tests that drupal_get_filename() works when the file is not in database. */ public function testDrupalGetFilename() { - // Rebuild system.module.files state data. - // @todo Remove as part of https://www.drupal.org/node/2186491 - drupal_static_reset('system_rebuild_module_data'); - system_rebuild_module_data(); + // Rebuild module list state data. + \Drupal::service('extension.list.module')->reset(); // Retrieving the location of a module. $this->assertIdentical(drupal_get_filename('module', 'system'), 'core/modules/system/system.info.yml'); diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigDependencyTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigDependencyTest.php index a9cd9f1902..453176eaca 100644 --- a/core/tests/Drupal/KernelTests/Core/Config/ConfigDependencyTest.php +++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigDependencyTest.php @@ -219,8 +219,7 @@ public function testConfigEntityUninstall() { $entity2->save(); // Perform a module rebuild so we can know where the node module is located // and uninstall it. - // @todo Remove as part of https://www.drupal.org/node/2186491 - system_rebuild_module_data(); + $this->container->get('extension.list.module')->reset(); // Test that doing a config uninstall of the node module deletes entity2 // since it is dependent on entity1 which is dependent on the node module. $config_manager->uninstall('module', 'node'); @@ -361,8 +360,7 @@ public function testConfigEntityUninstallComplex(array $entity_id_suffixes) { // Perform a module rebuild so we can know where the node module is located // and uninstall it. - // @todo Remove as part of https://www.drupal.org/node/2186491 - system_rebuild_module_data(); + $this->container->get('extension.list.module')->reset(); // Perform the uninstall. $config_manager->uninstall('module', 'node'); @@ -478,8 +476,7 @@ public function testConfigEntityUninstallThirdParty() { // Perform a module rebuild so we can know where the node module is located // and uninstall it. - // @todo Remove as part of https://www.drupal.org/node/2186491 - system_rebuild_module_data(); + $this->container->get('extension.list.module')->reset(); // Perform the uninstall. $config_manager->uninstall('module', 'node'); diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigImportRecreateTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigImportRecreateTest.php index c69f9febb4..218acfaf79 100644 --- a/core/tests/Drupal/KernelTests/Core/Config/ConfigImportRecreateTest.php +++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigImportRecreateTest.php @@ -52,7 +52,8 @@ protected function setUp() { $this->container->get('module_handler'), $this->container->get('module_installer'), $this->container->get('theme_handler'), - $this->container->get('string_translation') + $this->container->get('string_translation'), + $this->container->get('extension.list.module') ); } diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigImportRenameValidationTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigImportRenameValidationTest.php index 9c1875c85d..6de26ddd87 100644 --- a/core/tests/Drupal/KernelTests/Core/Config/ConfigImportRenameValidationTest.php +++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigImportRenameValidationTest.php @@ -57,7 +57,8 @@ protected function setUp() { $this->container->get('module_handler'), $this->container->get('module_installer'), $this->container->get('theme_handler'), - $this->container->get('string_translation') + $this->container->get('string_translation'), + $this->container->get('extension.list.module') ); } diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigImporterMissingContentTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigImporterMissingContentTest.php index 59f9cb2ed7..237697a858 100644 --- a/core/tests/Drupal/KernelTests/Core/Config/ConfigImporterMissingContentTest.php +++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigImporterMissingContentTest.php @@ -56,7 +56,8 @@ protected function setUp() { $this->container->get('module_handler'), $this->container->get('module_installer'), $this->container->get('theme_handler'), - $this->container->get('string_translation') + $this->container->get('string_translation'), + $this->container->get('extension.list.module') ); } diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php index 4024b7f9d9..327a08cd0b 100644 --- a/core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php +++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php @@ -56,7 +56,8 @@ protected function setUp() { $this->container->get('module_handler'), $this->container->get('module_installer'), $this->container->get('theme_handler'), - $this->container->get('string_translation') + $this->container->get('string_translation'), + $this->container->get('extension.list.module') ); } diff --git a/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityNullStorageTest.php b/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityNullStorageTest.php index 6da9bb3baa..6e145936a2 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityNullStorageTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityNullStorageTest.php @@ -63,7 +63,8 @@ public function testDeleteThroughImport() { $this->container->get('module_handler'), $this->container->get('module_installer'), $this->container->get('theme_handler'), - $this->container->get('string_translation') + $this->container->get('string_translation'), + $this->container->get('extension.list.module') ); // Delete the contact message in sync. diff --git a/core/tests/Drupal/KernelTests/Core/Extension/ModuleConfigureRouteTest.php b/core/tests/Drupal/KernelTests/Core/Extension/ModuleConfigureRouteTest.php index 96e469a84b..70a6517161 100644 --- a/core/tests/Drupal/KernelTests/Core/Extension/ModuleConfigureRouteTest.php +++ b/core/tests/Drupal/KernelTests/Core/Extension/ModuleConfigureRouteTest.php @@ -37,7 +37,7 @@ class ModuleConfigureRouteTest extends KernelTestBase { protected function setUp() { parent::setUp(); $this->routeProvider = \Drupal::service('router.route_provider'); - $this->moduleInfo = system_rebuild_module_data(); + $this->moduleInfo = $this->container->get('extension.list.module')->getList(); } /** diff --git a/core/tests/Drupal/KernelTests/Core/Extension/ModuleInstallerTest.php b/core/tests/Drupal/KernelTests/Core/Extension/ModuleInstallerTest.php index ff183c6f00..bc2a7646e3 100644 --- a/core/tests/Drupal/KernelTests/Core/Extension/ModuleInstallerTest.php +++ b/core/tests/Drupal/KernelTests/Core/Extension/ModuleInstallerTest.php @@ -15,15 +15,6 @@ */ class ModuleInstallerTest extends KernelTestBase { - /** - * Modules to install. - * - * The System module is required because system_rebuild_module_data() is used. - * - * @var array - */ - public static $modules = ['system']; - /** * Tests that routes are rebuilt during install and uninstall of modules. * diff --git a/core/tests/Drupal/KernelTests/Core/Theme/StableLibraryOverrideTest.php b/core/tests/Drupal/KernelTests/Core/Theme/StableLibraryOverrideTest.php index a71c3fe642..300c022373 100644 --- a/core/tests/Drupal/KernelTests/Core/Theme/StableLibraryOverrideTest.php +++ b/core/tests/Drupal/KernelTests/Core/Theme/StableLibraryOverrideTest.php @@ -60,7 +60,7 @@ protected function setUp() { $this->container->get('theme_installer')->install(['stable']); // Enable all core modules. - $all_modules = system_rebuild_module_data(); + $all_modules = $this->container->get('extension.list.module')->getList(); $all_modules = array_filter($all_modules, function ($module) { // Filter contrib, hidden, experimental, already enabled modules, and // modules in the Testing package. diff --git a/core/tests/Drupal/KernelTests/Core/Theme/StableTemplateOverrideTest.php b/core/tests/Drupal/KernelTests/Core/Theme/StableTemplateOverrideTest.php index 40d31e6dac..242528763e 100644 --- a/core/tests/Drupal/KernelTests/Core/Theme/StableTemplateOverrideTest.php +++ b/core/tests/Drupal/KernelTests/Core/Theme/StableTemplateOverrideTest.php @@ -57,11 +57,8 @@ protected function setUp() { * Installs all core modules. */ protected function installAllModules() { - // Needed for system_rebuild_module_data(). - include_once $this->root . '/core/modules/system/system.module'; - // Enable all core modules. - $all_modules = system_rebuild_module_data(); + $all_modules = $this->container->get('extension.list.module')->getList(); $all_modules = array_filter($all_modules, function ($module) { // Filter contrib, hidden, experimental, already enabled modules, and // modules in the Testing package. diff --git a/core/tests/Drupal/KernelTests/Core/Theme/ThemeInstallerTest.php b/core/tests/Drupal/KernelTests/Core/Theme/ThemeInstallerTest.php index 61f647528d..3a049db515 100644 --- a/core/tests/Drupal/KernelTests/Core/Theme/ThemeInstallerTest.php +++ b/core/tests/Drupal/KernelTests/Core/Theme/ThemeInstallerTest.php @@ -316,7 +316,7 @@ public function testThemeInfoAlter() { // Rebuild module data so we know where module_test is located. // @todo Remove as part of https://www.drupal.org/node/2186491 - system_rebuild_module_data(); + $this->container->get('extension.list.module')->reset(); $this->moduleInstaller()->install(['module_test'], FALSE); $this->assertTrue($this->moduleHandler()->moduleExists('module_test')); diff --git a/core/tests/Drupal/Tests/ConfigTestTrait.php b/core/tests/Drupal/Tests/ConfigTestTrait.php index 330ff470e2..689d2b0f69 100644 --- a/core/tests/Drupal/Tests/ConfigTestTrait.php +++ b/core/tests/Drupal/Tests/ConfigTestTrait.php @@ -34,7 +34,8 @@ protected function configImporter() { $this->container->get('module_handler'), $this->container->get('module_installer'), $this->container->get('theme_handler'), - $this->container->get('string_translation') + $this->container->get('string_translation'), + $this->container->get('extension.list.module') ); } // Always recalculate the changelist when called.