diff --git a/core/includes/menu.inc b/core/includes/menu.inc index d54fe06..1adc677 100644 --- a/core/includes/menu.inc +++ b/core/includes/menu.inc @@ -1805,7 +1805,7 @@ function menu_list_system_menus() { */ function menu_main_menu() { $config = \Drupal::config('menu.settings'); - $menu_enabled = module_exists('menu'); + $menu_enabled = \Drupal::moduleHandler()->moduleExists('menu'); // When menu module is not enabled, we need a hardcoded default value. $main_links_source = $menu_enabled ? $config->get('main_links') : 'main'; return menu_navigation_links($main_links_source); @@ -1816,7 +1816,7 @@ function menu_main_menu() { */ function menu_secondary_menu() { $config = \Drupal::config('menu.settings'); - $menu_enabled = module_exists('menu'); + $menu_enabled = \Drupal::moduleHandler()->moduleExists('menu'); // When menu module is not enabled, we need a hardcoded default value. $main_links_source = $menu_enabled ? $config->get('main_links') : 'main'; $secondary_links_source = $menu_enabled ? $config->get('secondary_links') : 'account'; diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeFormController.php b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeFormController.php index 15cd8f8..7273790 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeFormController.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeFormController.php @@ -53,7 +53,7 @@ public function form(array $form, array &$form_state) { '#description' => t('Create a new revision by default for this block type.') ); - if (module_exists('content_translation')) { + if ($this->moduleHandler->moduleExists('content_translation')) { $form['language'] = array( '#type' => 'details', '#title' => t('Language settings'), diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockTest.php index af49957..8e045cf 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockTest.php @@ -251,7 +251,7 @@ function moveBlockToRegion(array $block, $region) { */ function testBlockRehash() { \Drupal::moduleHandler()->install(array('block_test')); - $this->assertTrue(module_exists('block_test'), 'Test block module enabled.'); + $this->assertTrue(\Drupal::moduleHandler()->moduleExists('block_test'), 'Test block module enabled.'); // Clear the block cache to load the block_test module's block definitions. $this->container->get('plugin.manager.block')->clearCachedDefinitions(); diff --git a/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTestFormController.php b/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTestFormController.php index 514311b..5390419 100644 --- a/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTestFormController.php +++ b/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTestFormController.php @@ -47,7 +47,7 @@ public function form(array $form, array &$form_state) { '#default_value' => $entity->get('style'), '#access' => FALSE, ); - if (module_exists('image')) { + if ($this->moduleHandler->moduleExists('image')) { $form['style']['#access'] = TRUE; $form['style']['#options'] = image_style_options(); } diff --git a/core/modules/hal/lib/Drupal/hal/Normalizer/EntityNormalizer.php b/core/modules/hal/lib/Drupal/hal/Normalizer/EntityNormalizer.php index a3aa448..0bedf76 100644 --- a/core/modules/hal/lib/Drupal/hal/Normalizer/EntityNormalizer.php +++ b/core/modules/hal/lib/Drupal/hal/Normalizer/EntityNormalizer.php @@ -92,7 +92,7 @@ public function denormalize($data, $class, $format = NULL, array $context = arra if (isset($data['langcode'])) { $langcode = $data['langcode'][0]['value']; } - elseif (module_exists('language')) { + elseif (\Drupal::moduleHandler()->moduleExists('language')) { $langcode = language_get_default_langcode($typed_data_ids['entity_type'], $typed_data_ids['bundle']); } else { diff --git a/core/modules/history/lib/Drupal/history/Plugin/views/field/HistoryUserTimestamp.php b/core/modules/history/lib/Drupal/history/Plugin/views/field/HistoryUserTimestamp.php index 8b0f502..fb0ea06 100644 --- a/core/modules/history/lib/Drupal/history/Plugin/views/field/HistoryUserTimestamp.php +++ b/core/modules/history/lib/Drupal/history/Plugin/views/field/HistoryUserTimestamp.php @@ -40,7 +40,7 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o if (\Drupal::currentUser()->isAuthenticated()) { $this->additional_fields['created'] = array('table' => 'node_field_data', 'field' => 'created'); $this->additional_fields['changed'] = array('table' => 'node_field_data', 'field' => 'changed'); - if (module_exists('comment') && !empty($this->options['comments'])) { + if (\Drupal::moduleHandler()->moduleExists('comment') && !empty($this->options['comments'])) { $this->additional_fields['last_comment'] = array('table' => 'comment_entity_statistics', 'field' => 'last_comment_timestamp'); } } @@ -56,7 +56,7 @@ protected function defineOptions() { public function buildOptionsForm(&$form, &$form_state) { parent::buildOptionsForm($form, $form_state); - if (module_exists('comment')) { + if (\Drupal::moduleHandler()->moduleExists('comment')) { $form['comments'] = array( '#type' => 'checkbox', '#title' => t('Check for new comments as well'), @@ -85,7 +85,7 @@ public function render(ResultRow $values) { $last_read = $this->getValue($values); $changed = $this->getValue($values, 'changed'); - $last_comment = module_exists('comment') && !empty($this->options['comments']) ? $this->getValue($values, 'last_comment') : 0; + $last_comment = \Drupal::moduleHandler()->moduleExists('comment') && !empty($this->options['comments']) ? $this->getValue($values, 'last_comment') : 0; if (!$last_read && $changed > HISTORY_READ_LIMIT) { $mark = MARK_NEW; diff --git a/core/modules/history/lib/Drupal/history/Plugin/views/filter/HistoryUserTimestamp.php b/core/modules/history/lib/Drupal/history/Plugin/views/filter/HistoryUserTimestamp.php index 6b6b0db..ffd9a6f 100644 --- a/core/modules/history/lib/Drupal/history/Plugin/views/filter/HistoryUserTimestamp.php +++ b/core/modules/history/lib/Drupal/history/Plugin/views/filter/HistoryUserTimestamp.php @@ -80,7 +80,7 @@ public function query() { $clause = ''; $clause2 = ''; - if (module_exists('comment')) { + if (\Drupal::moduleHandler()->moduleExists('comment')) { $ces = $this->query->ensureTable('comment_entity_statistics', $this->relationship); $clause = ("OR $ces.last_comment_timestamp > (***CURRENT_TIME*** - $limit)"); $clause2 = "OR $field < $ces.last_comment_timestamp"; diff --git a/core/modules/menu/menu.module b/core/modules/menu/menu.module index 1ffddee..ee05ead 100644 --- a/core/modules/menu/menu.module +++ b/core/modules/menu/menu.module @@ -155,7 +155,7 @@ function menu_load($menu_name) { function menu_menu_insert(Menu $menu) { menu_cache_clear_all(); // Invalidate the block cache to update menu-based derivatives. - if (module_exists('block')) { + if (\Drupal::moduleHandler()->moduleExists('block')) { \Drupal::service('plugin.manager.block')->clearCachedDefinitions(); } // Make sure the menu is present in the active menus variable so that its @@ -178,7 +178,7 @@ function menu_menu_insert(Menu $menu) { function menu_menu_update(Menu $menu) { menu_cache_clear_all(); // Invalidate the block cache to update menu-based derivatives. - if (module_exists('block')) { + if (\Drupal::moduleHandler()->moduleExists('block')) { \Drupal::service('plugin.manager.block')->clearCachedDefinitions(); } } @@ -211,7 +211,7 @@ function menu_menu_delete(Menu $menu) { menu_cache_clear_all(); // Invalidate the block cache to update menu-based derivatives. - if (module_exists('block')) { + if (\Drupal::moduleHandler()->moduleExists('block')) { \Drupal::service('plugin.manager.block')->clearCachedDefinitions(); } } diff --git a/core/modules/rest/lib/Drupal/rest/Plugin/rest/resource/DBLogResource.php b/core/modules/rest/lib/Drupal/rest/Plugin/rest/resource/DBLogResource.php index 8b7cb99..bd05a5a 100644 --- a/core/modules/rest/lib/Drupal/rest/Plugin/rest/resource/DBLogResource.php +++ b/core/modules/rest/lib/Drupal/rest/Plugin/rest/resource/DBLogResource.php @@ -27,7 +27,7 @@ class DBLogResource extends ResourceBase { */ public function routes() { // Only expose routes if the dblog module is enabled. - if (module_exists('dblog')) { + if (\Drupal::moduleHandler()->moduleExists('dblog')) { return parent::routes(); } return new RouteCollection(); diff --git a/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php b/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php index 715325a..953b38e 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php @@ -53,7 +53,7 @@ function testEnableModulesLoad() { $module = 'field_test'; // Verify that the module does not exist yet. - $this->assertFalse(module_exists($module), "$module module not found."); + $this->assertFalse(\Drupal::moduleHandler()->moduleExists($module), "$module module not found."); $list = array_keys(\Drupal::moduleHandler()->getModuleList()); $this->assertFalse(in_array($module, $list), "$module module not found in the extension handler's module list."); $list = \Drupal::moduleHandler()->getImplementations('permission'); @@ -63,7 +63,7 @@ function testEnableModulesLoad() { $this->enableModules(array($module)); // Verify that the module exists. - $this->assertTrue(module_exists($module), "$module module found."); + $this->assertTrue(\Drupal::moduleHandler()->moduleExists($module), "$module module found."); $list = array_keys(\Drupal::moduleHandler()->getModuleList()); $this->assertTrue(in_array($module, $list), "$module module found in the extension handler's module list."); $list = \Drupal::moduleHandler()->getImplementations('permission'); @@ -78,7 +78,7 @@ function testEnableModulesInstall() { $table = 'node'; // Verify that the module does not exist yet. - $this->assertFalse(module_exists($module), "$module module not found."); + $this->assertFalse(\Drupal::moduleHandler()->moduleExists($module), "$module module not found."); $list = array_keys(\Drupal::moduleHandler()->getModuleList()); $this->assertFalse(in_array($module, $list), "$module module not found in the extension handler's module list."); $list = \Drupal::moduleHandler()->getImplementations('permission'); @@ -92,7 +92,7 @@ function testEnableModulesInstall() { \Drupal::moduleHandler()->install(array($module)); // Verify that the enabled module exists. - $this->assertTrue(module_exists($module), "$module module found."); + $this->assertTrue(\Drupal::moduleHandler()->moduleExists($module), "$module module found."); $list = array_keys(\Drupal::moduleHandler()->getModuleList()); $this->assertTrue(in_array($module, $list), "$module module found in the extension handler's module list."); $list = \Drupal::moduleHandler()->getImplementations('permission'); diff --git a/core/modules/syslog/syslog.module b/core/modules/syslog/syslog.module index 287cfaf..a93ee93 100644 --- a/core/modules/syslog/syslog.module +++ b/core/modules/syslog/syslog.module @@ -30,7 +30,7 @@ function syslog_help($path, $arg) { */ function syslog_form_system_logging_settings_alter(&$form, &$form_state) { $config = \Drupal::config('syslog.settings'); - $help = module_exists('help') ? ' ' . l(t('More information'), 'admin/help/syslog') . '.' : NULL; + $help = \Drupal::moduleHandler()->moduleExists('help') ? ' ' . l(t('More information'), 'admin/help/syslog') . '.' : NULL; $form['syslog_identity'] = array( '#type' => 'textfield', '#title' => t('Syslog identity'), 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 0d184b6..68dae37 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Module/ModuleApiTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Module/ModuleApiTest.php @@ -144,10 +144,10 @@ function testDependencyResolution() { // are not already enabled. (If they were, the tests below would not work // correctly.) \Drupal::moduleHandler()->install(array('module_test'), FALSE); - $this->assertTrue(module_exists('module_test'), 'Test module is enabled.'); - $this->assertFalse(module_exists('forum'), 'Forum module is disabled.'); - $this->assertFalse(module_exists('ban'), 'Ban module is disabled.'); - $this->assertFalse(module_exists('xmlrpc'), 'XML-RPC module is disabled.'); + $this->assertTrue(\Drupal::moduleHandler()->moduleExists('module_test'), 'Test module is enabled.'); + $this->assertFalse(\Drupal::moduleHandler()->moduleExists('forum'), 'Forum module is disabled.'); + $this->assertFalse(\Drupal::moduleHandler()->moduleExists('ban'), 'Ban module is disabled.'); + $this->assertFalse(\Drupal::moduleHandler()->moduleExists('xmlrpc'), 'XML-RPC module is disabled.'); // First, create a fake missing dependency. Forum depends on ban, which // depends on a made-up module, foo. Nothing should be installed. @@ -155,7 +155,7 @@ function testDependencyResolution() { drupal_static_reset('system_rebuild_module_data'); $result = \Drupal::moduleHandler()->install(array('forum')); $this->assertFalse($result, '\Drupal\Core\Extension\ModuleHandler::install() returns FALSE if dependencies are missing.'); - $this->assertFalse(module_exists('forum'), '\Drupal\Core\Extension\ModuleHandler::install() aborts if dependencies are missing.'); + $this->assertFalse(\Drupal::moduleHandler()->moduleExists('forum'), '\Drupal\Core\Extension\ModuleHandler::install() aborts if dependencies are missing.'); // Now, fix the missing dependency. Forum module depends on ban, but ban // depends on the XML-RPC module. @@ -165,9 +165,9 @@ function testDependencyResolution() { $result = \Drupal::moduleHandler()->install(array('forum')); $this->assertTrue($result, '\Drupal\Core\Extension\ModuleHandler::install() returns the correct value.'); // Verify that the fake dependency chain was installed. - $this->assertTrue(module_exists('ban') && module_exists('xmlrpc'), 'Dependency chain was installed.'); + $this->assertTrue(\Drupal::moduleHandler()->moduleExists('ban') && \Drupal::moduleHandler()->moduleExists('xmlrpc'), 'Dependency chain was installed.'); // Verify that the original module was installed. - $this->assertTrue(module_exists('forum'), 'Module installation with unlisted dependencies succeeded.'); + $this->assertTrue(\Drupal::moduleHandler()->moduleExists('forum'), 'Module installation with unlisted dependencies succeeded.'); // Finally, verify that the modules were enabled in the correct order. $module_order = \Drupal::state()->get('module_test.install_order') ?: array(); $this->assertEqual($module_order, array('xmlrpc', 'ban', 'forum'), 'Modules were enabled in the correct order.'); @@ -201,9 +201,9 @@ function testDependencyResolution() { $result = \Drupal::moduleHandler()->install(array('forum')); $this->assertTrue($result, '\Drupal\Core\Extension\ModuleHandler::install() returns the correct value.'); // Verify that the fake dependency chain was installed. - $this->assertTrue(module_exists('ban') && module_exists('xmlrpc'), 'Dependency chain was installed.'); + $this->assertTrue(\Drupal::moduleHandler()->moduleExists('ban') && \Drupal::moduleHandler()->moduleExists('xmlrpc'), 'Dependency chain was installed.'); // Verify that the original module was installed. - $this->assertTrue(module_exists('forum'), 'Module installation with version dependencies succeeded.'); + $this->assertTrue(\Drupal::moduleHandler()->moduleExists('forum'), 'Module installation with version dependencies succeeded.'); // Finally, verify that the modules were enabled in the correct order. $enable_order = \Drupal::state()->get('module_test.install_order') ?: array(); $xmlrpc_position = array_search('xmlrpc', $enable_order); diff --git a/core/modules/system/lib/Drupal/system/Tests/System/InfoAlterTest.php b/core/modules/system/lib/Drupal/system/Tests/System/InfoAlterTest.php index c739dd9..2dbbccf 100644 --- a/core/modules/system/lib/Drupal/system/Tests/System/InfoAlterTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/System/InfoAlterTest.php @@ -32,7 +32,7 @@ function testSystemInfoAlter() { // Enable seven and the test module. theme_enable(array('seven')); \Drupal::moduleHandler()->install(array('module_test'), FALSE); - $this->assertTrue(module_exists('module_test'), 'Test module is enabled.'); + $this->assertTrue(\Drupal::moduleHandler()->moduleExists('module_test'), 'Test module is enabled.'); // Verify that the rebuilt and altered theme info is returned. $info = system_get_info('theme', 'seven'); diff --git a/core/modules/system/lib/Drupal/system/Tests/System/MainContentFallbackTest.php b/core/modules/system/lib/Drupal/system/Tests/System/MainContentFallbackTest.php index 4d59aa7..69b1bd3 100644 --- a/core/modules/system/lib/Drupal/system/Tests/System/MainContentFallbackTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/System/MainContentFallbackTest.php @@ -58,7 +58,7 @@ function testMainContentFallback() { $this->drupalPostForm(NULL, NULL, t('Uninstall')); $this->assertText(t('The selected modules have been uninstalled.'), 'Modules status has been updated.'); $this->rebuildContainer(); - $this->assertFalse(module_exists('block'), 'Block module uninstall.'); + $this->assertFalse(\Drupal::moduleHandler()->moduleExists('block'), 'Block module uninstall.'); // At this point, no region is filled and fallback should be triggered. $this->drupalGet('admin/config/system/site-information'); @@ -92,6 +92,6 @@ function testMainContentFallback() { $this->drupalPostForm('admin/modules', $edit, t('Save configuration')); $this->assertText(t('The configuration options have been saved.'), 'Modules status has been updated.'); $this->rebuildContainer(); - $this->assertTrue(module_exists('block'), 'Block module re-enabled.'); + $this->assertTrue(\Drupal::moduleHandler()->moduleExists('block'), 'Block module re-enabled.'); } }