Commit 2e6c6d71 authored by catch's avatar catch

Issue #2045931 by Sam152, joelpittet, LinL, Sutharsan, adsw12: Replace all...

Issue #2045931 by Sam152, joelpittet, LinL, Sutharsan, adsw12: Replace all module_exists() deprecated function calls.
parent 9c4ed905
......@@ -1706,7 +1706,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);
......@@ -1717,7 +1717,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';
......
......@@ -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'),
......
......@@ -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();
......
......@@ -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();
}
......
......@@ -111,7 +111,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 {
......
......@@ -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;
......
......@@ -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";
......
......@@ -171,7 +171,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
......@@ -194,7 +194,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();
}
}
......@@ -227,7 +227,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();
}
}
......
......@@ -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();
......
......@@ -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');
......
......@@ -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'),
......
......@@ -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);
......
......@@ -35,7 +35,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');
......
......@@ -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.');
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment