From 5d0729f07a08ee6f3ec771483ec8e81c8d348798 Mon Sep 17 00:00:00 2001 From: webchick <webchick@24967.no-reply.drupal.org> Date: Wed, 26 Feb 2014 11:16:54 -0800 Subject: [PATCH] Issue #2070369 by herom, bdgreen, Mac_Weber, InternetDevels, sidharthap, JeroenT: Remove all calls to deprecated function language(). --- core/includes/common.inc | 2 +- core/includes/entity.inc | 4 ++-- core/includes/form.inc | 2 +- core/includes/menu.inc | 6 +++--- core/includes/theme.inc | 4 ++-- core/lib/Drupal.php | 2 +- core/lib/Drupal/Core/Datetime/DrupalDateTime.php | 2 +- core/lib/Drupal/Core/Routing/UrlGeneratorInterface.php | 8 ++++---- core/lib/Drupal/Core/Url.php | 4 ++-- core/lib/Drupal/Core/Validation/DrupalTranslator.php | 2 +- .../block/lib/Drupal/block/BlockAccessController.php | 2 +- core/modules/book/book.module | 2 +- core/modules/book/lib/Drupal/book/BookManager.php | 4 ++-- core/modules/ckeditor/ckeditor.admin.inc | 2 +- .../Drupal/comment/Tests/CommentTokenReplaceTest.php | 2 +- .../lib/Drupal/contact/MessageFormController.php | 2 +- .../content_translation/content_translation.module | 6 +++--- .../content_translation/content_translation.pages.inc | 4 ++-- .../Access/ContentTranslationManageAccessCheck.php | 4 ++-- .../lib/Drupal/file/Tests/FileTokenReplaceTest.php | 2 +- core/modules/language/language.module | 2 +- .../Tests/LanguageConfigurationElementTest.php | 2 +- .../language/tests/language_test/language_test.module | 4 ++-- core/modules/locale/locale.module | 10 +++++----- core/modules/node/node.module | 4 ++-- core/modules/search/search.pages.inc | 2 +- .../simpletest/lib/Drupal/simpletest/TestBase.php | 2 +- .../statistics/Tests/StatisticsTokenReplaceTest.php | 2 +- core/modules/system/language.api.php | 4 ++-- .../lib/Drupal/system/Tests/Common/FormatDateTest.php | 2 +- .../system/lib/Drupal/system/Tests/Mail/MailTest.php | 6 +++--- core/modules/system/system.api.php | 4 ++-- core/modules/system/system.module | 2 +- .../plugin_test/Plugin/CachedMockBlockManager.php | 2 +- core/modules/system/theme.api.php | 2 +- .../lib/Drupal/taxonomy/Tests/TokenReplaceTest.php | 2 +- .../user/lib/Drupal/user/AccountFormController.php | 2 +- .../lib/Drupal/user/Tests/UserTokenReplaceTest.php | 2 +- .../views/Plugin/views/cache/CachePluginBase.php | 4 ++-- core/modules/views/views.api.php | 2 +- core/modules/views/views.theme.inc | 2 +- core/modules/views/views.views_execution.inc | 2 +- 42 files changed, 66 insertions(+), 66 deletions(-) diff --git a/core/includes/common.inc b/core/includes/common.inc index 1f2b74bea037..7415803b5409 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -768,7 +768,7 @@ function filter_xss_bad_protocol($string) { * Arbitrary elements may be added using the $args associative array. */ function format_rss_channel($title, $link, $description, $items, $langcode = NULL, $args = array()) { - $langcode = $langcode ? $langcode : language(Language::TYPE_CONTENT)->id; + $langcode = $langcode ? $langcode : \Drupal::languageManager()->getCurrentLanguage(Language::TYPE_CONTENT)->id; $output = "<channel>\n"; $output .= ' <title>' . String::checkPlain($title) . "</title>\n"; diff --git a/core/includes/entity.inc b/core/includes/entity.inc index 0ade970ba5f5..39701ef14637 100644 --- a/core/includes/entity.inc +++ b/core/includes/entity.inc @@ -93,7 +93,7 @@ function entity_invoke_bundle_hook($hook, $entity_type, $bundle, $bundle_new = N function entity_get_form_modes($entity_type = NULL) { $form_modes = &drupal_static(__FUNCTION__); if (!$form_modes) { - $langcode = language(Language::TYPE_INTERFACE)->id; + $langcode = \Drupal::languageManager()->getCurrentLanguage()->id; if ($cache = \Drupal::cache()->get("entity_form_mode_info:$langcode")) { $form_modes = $cache->data; } @@ -131,7 +131,7 @@ function entity_get_form_modes($entity_type = NULL) { function entity_get_view_modes($entity_type = NULL) { $view_modes = &drupal_static(__FUNCTION__); if (!$view_modes) { - $langcode = language(Language::TYPE_INTERFACE)->id; + $langcode = \Drupal::languageManager()->getCurrentLanguage()->id; if ($cache = \Drupal::cache()->get("entity_view_mode_info:$langcode")) { $view_modes = $cache->data; } diff --git a/core/includes/form.inc b/core/includes/form.inc index 454a01670bfb..15c6634d8fbd 100644 --- a/core/includes/form.inc +++ b/core/includes/form.inc @@ -1898,7 +1898,7 @@ function form_validate_table($element, &$form_state) { */ function form_process_machine_name($element, &$form_state) { // We need to pass the langcode to the client. - $language = language(Language::TYPE_INTERFACE); + $language = \Drupal::languageManager()->getCurrentLanguage(); // Apply default form element properties. $element += array( diff --git a/core/includes/menu.inc b/core/includes/menu.inc index 495fb4722b88..053239e58411 100644 --- a/core/includes/menu.inc +++ b/core/includes/menu.inc @@ -1009,7 +1009,7 @@ function menu_tree_output($tree) { */ function menu_tree_all_data($menu_name, $link = NULL, $max_depth = NULL) { $tree = &drupal_static(__FUNCTION__, array()); - $language_interface = language(Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); // Use $mlid as a flag for whether the data being loaded is for the whole tree. $mlid = isset($link['mlid']) ? $link['mlid'] : 0; @@ -1120,7 +1120,7 @@ function menu_tree_get_path($menu_name) { function menu_tree_page_data($menu_name, $max_depth = NULL, $only_active_trail = FALSE) { $tree = &drupal_static(__FUNCTION__, array()); - $language_interface = language(Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); // Check if the active trail has been overridden for this menu tree. $active_path = menu_tree_get_path($menu_name); @@ -1278,7 +1278,7 @@ function menu_build_tree($menu_name, array $parameters = array()) { function _menu_build_tree($menu_name, array $parameters = array()) { // Static cache of already built menu trees. $trees = &drupal_static(__FUNCTION__, array()); - $language_interface = language(Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); // Build the cache id; sort parents to prevent duplicate storage and remove // default parameter values. diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 2e7d41e4e649..dad6f65bd625 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -2191,7 +2191,7 @@ function template_preprocess_html(&$variables) { * @see drupal_render_page() */ function template_preprocess_page(&$variables) { - $language_interface = language(Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); $site_config = \Drupal::config('system.site'); // Move some variables to the top level for themer convenience and template cleanliness. @@ -2365,7 +2365,7 @@ function theme_get_suggestions($args, $base, $delimiter = '__') { * @see system_page_build() */ function template_preprocess_maintenance_page(&$variables) { - $language_interface = language(Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); // Initializes attributes which are specific to the html element. $variables['html_attributes'] = new Attribute; diff --git a/core/lib/Drupal.php b/core/lib/Drupal.php index 1ea2bc13ad9b..db285d9b2393 100644 --- a/core/lib/Drupal.php +++ b/core/lib/Drupal.php @@ -455,7 +455,7 @@ public static function urlGenerator() { * displayed outside the site, such as in an RSS feed. * - 'language': An optional language object used to look up the alias * for the URL. If $options['language'] is omitted, the language will be - * obtained from language(Language::TYPE_URL). + * obtained from \Drupal::languageManager()->getCurrentLanguage(Language::TYPE_URL). * - 'https': Whether this URL should point to a secure location. If not * defined, the current scheme is used, so the user stays on HTTP or HTTPS * respectively. if mixed mode sessions are permitted, TRUE enforces HTTPS diff --git a/core/lib/Drupal/Core/Datetime/DrupalDateTime.php b/core/lib/Drupal/Core/Datetime/DrupalDateTime.php index 08bdded821da..2d4be4614daf 100644 --- a/core/lib/Drupal/Core/Datetime/DrupalDateTime.php +++ b/core/lib/Drupal/Core/Datetime/DrupalDateTime.php @@ -53,7 +53,7 @@ class DrupalDateTime extends DateTimePlus { public function __construct($time = 'now', $timezone = NULL, $settings = array()) { // We can set the langcode and country using Drupal values. if (!isset($settings['langcode'])) { - $settings['langcode'] = language(Language::TYPE_INTERFACE)->id; + $settings['langcode'] = \Drupal::languageManager()->getCurrentLanguage()->id; } if (!isset($settings['country'])) { diff --git a/core/lib/Drupal/Core/Routing/UrlGeneratorInterface.php b/core/lib/Drupal/Core/Routing/UrlGeneratorInterface.php index 5c42a8189d22..9903fe336c98 100644 --- a/core/lib/Drupal/Core/Routing/UrlGeneratorInterface.php +++ b/core/lib/Drupal/Core/Routing/UrlGeneratorInterface.php @@ -13,7 +13,7 @@ /** * Defines an interface for generating a url from a route or system path. * - * Provides additional methods and options not present in the base interface. + * Provides additional methods and options not present in the base interface. */ interface UrlGeneratorInterface extends VersatileGeneratorInterface { @@ -55,7 +55,7 @@ interface UrlGeneratorInterface extends VersatileGeneratorInterface { * - 'language': An optional language object. If the path being linked to is * internal to the site, $options['language'] is used to look up the alias * for the URL. If $options['language'] is omitted, the language will be - * obtained from language(Language::TYPE_URL). + * obtained from \Drupal::languageManager()->getCurrentLanguage(Language::TYPE_URL). * - 'https': Whether this URL should point to a secure location. If not * defined, the current scheme is used, so the user stays on HTTP or HTTPS * respectively. TRUE enforces HTTPS and FALSE enforces HTTP, but HTTPS can @@ -121,8 +121,8 @@ public function getPathFromRoute($name, $parameters = array()); * absolute link (beginning with http:). Useful for links that will be * displayed outside the site, such as in an RSS feed. * - 'language': An optional language object used to look up the alias - * for the URL. If $options['language'] is omitted, the language will be - * obtained from language(Language::TYPE_URL). + * for the URL. If $options['language'] is omitted, it defaults to the + * current language for the language type Language::TYPE_URL. * - 'https': Whether this URL should point to a secure location. If not * defined, the current scheme is used, so the user stays on HTTP or HTTPS * respectively. if mixed mode sessions are permitted, TRUE enforces HTTPS diff --git a/core/lib/Drupal/Core/Url.php b/core/lib/Drupal/Core/Url.php index 23dbeaf03ead..33f91fc94baf 100644 --- a/core/lib/Drupal/Core/Url.php +++ b/core/lib/Drupal/Core/Url.php @@ -82,8 +82,8 @@ class Url extends DependencySerialization { * absolute link (beginning with http:). Useful for links that will be * displayed outside the site, such as in an RSS feed. * - 'language': An optional language object used to look up the alias - * for the URL. If $options['language'] is omitted, the language will be - * obtained from language(Language::TYPE_URL). + * for the URL. If $options['language'] is omitted, it defaults to the + * current language for the language type Language::TYPE_URL. * - 'https': Whether this URL should point to a secure location. If not * defined, the current scheme is used, so the user stays on HTTP or HTTPS * respectively. if mixed mode sessions are permitted, TRUE enforces HTTPS diff --git a/core/lib/Drupal/Core/Validation/DrupalTranslator.php b/core/lib/Drupal/Core/Validation/DrupalTranslator.php index df14d942db00..5b4d99dc4b29 100644 --- a/core/lib/Drupal/Core/Validation/DrupalTranslator.php +++ b/core/lib/Drupal/Core/Validation/DrupalTranslator.php @@ -56,7 +56,7 @@ public function setLocale($locale) { * Implements \Symfony\Component\Translation\TranslatorInterface::getLocale(). */ public function getLocale() { - return $this->locale ? $this->locale : language(Language::TYPE_INTERFACE)->id; + return $this->locale ? $this->locale : \Drupal::languageManager()->getCurrentLanguage()->id; } /** diff --git a/core/modules/block/lib/Drupal/block/BlockAccessController.php b/core/modules/block/lib/Drupal/block/BlockAccessController.php index 9469ffcb4a05..4f5182b0d471 100644 --- a/core/modules/block/lib/Drupal/block/BlockAccessController.php +++ b/core/modules/block/lib/Drupal/block/BlockAccessController.php @@ -117,7 +117,7 @@ protected function checkAccess(EntityInterface $entity, $operation, $langcode, A // Language visibility settings. if (!empty($visibility['language']['langcodes']) && array_filter($visibility['language']['langcodes'])) { - if (empty($visibility['language']['langcodes'][language($visibility['language']['language_type'])->id])) { + if (empty($visibility['language']['langcodes'][\Drupal::languageManager()->getCurrentLanguage($visibility['language']['language_type'])->id])) { return FALSE; } } diff --git a/core/modules/book/book.module b/core/modules/book/book.module index b7a8cc776d2f..b20123412c58 100644 --- a/core/modules/book/book.module +++ b/core/modules/book/book.module @@ -713,7 +713,7 @@ function template_preprocess_book_navigation(&$variables) { */ function template_preprocess_book_export_html(&$variables) { global $base_url; - $language_interface = language(Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); $variables['title'] = String::checkPlain($variables['title']); $variables['base_url'] = $base_url; diff --git a/core/modules/book/lib/Drupal/book/BookManager.php b/core/modules/book/lib/Drupal/book/BookManager.php index 8f3162c1f6d4..8edd4d70da41 100644 --- a/core/modules/book/lib/Drupal/book/BookManager.php +++ b/core/modules/book/lib/Drupal/book/BookManager.php @@ -552,7 +552,7 @@ public function deleteBook($nid) { */ public function bookTreeAllData($menu_name, $link = NULL, $max_depth = NULL) { $tree = &drupal_static('menu_tree_all_data', array()); - $language_interface = language(Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); // Use $mlid as a flag for whether the data being loaded is for the whole tree. $mlid = isset($link['mlid']) ? $link['mlid'] : 0; @@ -721,7 +721,7 @@ protected function menu_build_tree($menu_name, array $parameters = array()) { protected function _menu_build_tree($menu_name, array $parameters = array()) { // Static cache of already built menu trees. $trees = &drupal_static('menu_build_tree', array()); - $language_interface = language(Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); // Build the cache id; sort parents to prevent duplicate storage and remove // default parameter values. diff --git a/core/modules/ckeditor/ckeditor.admin.inc b/core/modules/ckeditor/ckeditor.admin.inc index d8ef45f8f538..7d763c75ed85 100644 --- a/core/modules/ckeditor/ckeditor.admin.inc +++ b/core/modules/ckeditor/ckeditor.admin.inc @@ -20,7 +20,7 @@ */ function template_preprocess_ckeditor_settings_toolbar(&$variables) { // Simplify the language direction information for toolbar buttons. - $language_interface = language(Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); $language_direction = $language_interface->direction ? 'rtl' : 'ltr'; // Create lists of active and disabled buttons. diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentTokenReplaceTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentTokenReplaceTest.php index 081775fd6217..bd300fc83877 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentTokenReplaceTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentTokenReplaceTest.php @@ -26,7 +26,7 @@ public static function getInfo() { */ function testCommentTokenReplacement() { $token_service = \Drupal::token(); - $language_interface = language(Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); $url_options = array( 'absolute' => TRUE, 'language' => $language_interface, diff --git a/core/modules/contact/lib/Drupal/contact/MessageFormController.php b/core/modules/contact/lib/Drupal/contact/MessageFormController.php index f8f57cf506de..067865444634 100644 --- a/core/modules/contact/lib/Drupal/contact/MessageFormController.php +++ b/core/modules/contact/lib/Drupal/contact/MessageFormController.php @@ -141,7 +141,7 @@ public function preview(array $form, array &$form_state) { public function save(array $form, array &$form_state) { global $user; - $language_interface = language(Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); $message = $this->entity; $sender = clone user_load($user->id()); diff --git a/core/modules/content_translation/content_translation.module b/core/modules/content_translation/content_translation.module index d425866e86d4..8c65f1e9f37c 100644 --- a/core/modules/content_translation/content_translation.module +++ b/core/modules/content_translation/content_translation.module @@ -372,7 +372,7 @@ function content_translation_view_access(EntityInterface $entity, $langcode, Acc */ function content_translation_add_access(EntityInterface $entity, Language $source = NULL, Language $target = NULL) { $source = !empty($source) ? $source : $entity->language(); - $target = !empty($target) ? $target : language(Language::TYPE_CONTENT); + $target = !empty($target) ? $target : \Drupal::languageManager()->getCurrentLanguage(Language::TYPE_CONTENT); $translations = $entity->getTranslationLanguages(); $languages = language_list(); return $source->id != $target->id && isset($languages[$source->id]) && isset($languages[$target->id]) && !isset($translations[$target->id]) && content_translation_access($entity, 'create'); @@ -388,7 +388,7 @@ function content_translation_add_access(EntityInterface $entity, Language $sourc * content language. */ function content_translation_edit_access(EntityInterface $entity, Language $language = NULL) { - $language = !empty($language) ? $language : language(Language::TYPE_CONTENT); + $language = !empty($language) ? $language : \Drupal::languageManager()->getCurrentLanguage(Language::TYPE_CONTENT); $translations = $entity->getTranslationLanguages(); $languages = language_list(); return isset($languages[$language->id]) && $language->id != $entity->getUntranslated()->language()->id && isset($translations[$language->id]) && content_translation_access($entity, 'update'); @@ -404,7 +404,7 @@ function content_translation_edit_access(EntityInterface $entity, Language $lang * content language. */ function content_translation_delete_access(EntityInterface $entity, Language $language = NULL) { - $language = !empty($language) ? $language : language(Language::TYPE_CONTENT); + $language = !empty($language) ? $language : \Drupal::languageManager()->getCurrentLanguage(Language::TYPE_CONTENT); $translations = $entity->getTranslationLanguages(); $languages = language_list(); return isset($languages[$language->id]) && $language->id != $entity->getUntranslated()->language()->id && isset($translations[$language->id]) && content_translation_access($entity, 'delete'); diff --git a/core/modules/content_translation/content_translation.pages.inc b/core/modules/content_translation/content_translation.pages.inc index 0b6a4dc62479..bed50a047202 100644 --- a/core/modules/content_translation/content_translation.pages.inc +++ b/core/modules/content_translation/content_translation.pages.inc @@ -184,7 +184,7 @@ function _content_translation_get_switch_links($path) { */ function content_translation_add_page(EntityInterface $entity, Language $source = NULL, Language $target = NULL) { $source = !empty($source) ? $source : $entity->language(); - $target = !empty($target) ? $target : language(Language::TYPE_CONTENT); + $target = !empty($target) ? $target : \Drupal::languageManager()->getCurrentLanguage(Language::TYPE_CONTENT); // @todo Exploit the upcoming hook_entity_prepare() when available. content_translation_prepare_translation($entity, $source, $target); $form_state['langcode'] = $target->id; @@ -210,7 +210,7 @@ function content_translation_add_page(EntityInterface $entity, Language $source * Use \Drupal\content_translation\Controller\ContentTranslationController::edit(). */ function content_translation_edit_page(EntityInterface $entity, Language $language = NULL) { - $language = !empty($language) ? $language : language(Language::TYPE_CONTENT); + $language = !empty($language) ? $language : \Drupal::languageManager()->getCurrentLanguage(Language::TYPE_CONTENT); $form_state['langcode'] = $language->id; $form_state['content_translation']['translation_form'] = TRUE; return \Drupal::service('entity.form_builder')->getForm($entity, 'default', $form_state); diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Access/ContentTranslationManageAccessCheck.php b/core/modules/content_translation/lib/Drupal/content_translation/Access/ContentTranslationManageAccessCheck.php index be3fe8553f85..f1c3ea5ea054 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/Access/ContentTranslationManageAccessCheck.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Access/ContentTranslationManageAccessCheck.php @@ -56,7 +56,7 @@ public function access(Route $route, Request $request, AccountInterface $account $source = language_load($request->attributes->get('source')); $target = language_load($request->attributes->get('target')); $source = !empty($source) ? $source : $entity->language(); - $target = !empty($target) ? $target : language(Language::TYPE_CONTENT); + $target = !empty($target) ? $target : \Drupal::languageManager()->getCurrentLanguage(Language::TYPE_CONTENT); return ($source->id != $target->id && isset($languages[$source->id]) && isset($languages[$target->id]) @@ -67,7 +67,7 @@ public function access(Route $route, Request $request, AccountInterface $account case 'update': case 'delete': $language = language_load($request->attributes->get('language')); - $language = !empty($language) ? $language : language(Language::TYPE_CONTENT); + $language = !empty($language) ? $language : \Drupal::languageManager()->getCurrentLanguage(Language::TYPE_CONTENT); return isset($languages[$language->id]) && $language->id != $entity->getUntranslated()->language()->id && isset($translations[$language->id]) diff --git a/core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php b/core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php index 03aedcb0433a..35bb593947c0 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php @@ -26,7 +26,7 @@ public static function getInfo() { */ function testFileTokenReplacement() { $token_service = \Drupal::token(); - $language_interface = language(Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); // Create file field. $type_name = 'article'; diff --git a/core/modules/language/language.module b/core/modules/language/language.module index 9d2305825bc0..f196969a8794 100644 --- a/core/modules/language/language.module +++ b/core/modules/language/language.module @@ -402,7 +402,7 @@ function language_get_default_langcode($entity_type, $bundle) { } $default_value = NULL; - $language_interface = language(Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); switch ($configuration['langcode']) { case 'site_default': $default_value = language_default()->id; diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationElementTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationElementTest.php index 5b413f87cd13..adab4caeee1b 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationElementTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationElementTest.php @@ -83,7 +83,7 @@ public function testDefaultLangcode() { // Current interface. language_save_default_configuration('custom_type', 'custom_bundle', array('langcode' => 'current_interface', 'language_show' => TRUE)); $langcode = language_get_default_langcode('custom_type', 'custom_bundle'); - $language_interface = language(Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); $this->assertEqual($langcode, $language_interface->id); // Site's default. diff --git a/core/modules/language/tests/language_test/language_test.module b/core/modules/language/tests/language_test/language_test.module index 38171374a7c2..42f2b0f65402 100644 --- a/core/modules/language/tests/language_test/language_test.module +++ b/core/modules/language/tests/language_test/language_test.module @@ -13,8 +13,8 @@ */ function language_test_page_build() { language_test_store_language_negotiation(); - if (isset(language(Language::TYPE_INTERFACE)->id) && isset(language(Language::TYPE_INTERFACE)->method_id)) { - drupal_set_message(t('Language negotiation method: @name', array('@name' => language(Language::TYPE_INTERFACE)->method_id))); + if (isset(\Drupal::languageManager()->getCurrentLanguage()->id) && isset(\Drupal::languageManager()->getCurrentLanguage()->method_id)) { + drupal_set_message(t('Language negotiation method: @name', array('@name' => \Drupal::languageManager()->getCurrentLanguage()->method_id))); } } diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module index 105f44ec0cbd..7c3f5706c190 100644 --- a/core/modules/locale/locale.module +++ b/core/modules/locale/locale.module @@ -315,7 +315,7 @@ function locale_translatable_language_list() { * plural formula. */ function locale_get_plural($count, $langcode = NULL) { - $language_interface = language(Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); // Used to locally cache the plural formulas for all languages. $plural_formulas = &drupal_static(__FUNCTION__, array()); @@ -583,7 +583,7 @@ function locale_js_alter(&$javascript) { * applicable. */ function locale_js_translate(array $files = array()) { - $language_interface = language(Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); $dir = 'public://' . \Drupal::config('locale.settings')->get('javascript.directory'); $parsed = \Drupal::state()->get('system.javascript_parsed') ?: array(); @@ -644,7 +644,7 @@ function locale_library_alter(array &$library, $module, $name) { // the behavior executes early. JS_LIBRARY is the default. $library['dependencies'][] = array('locale', 'drupal.locale.datepicker'); - $language_interface = language(Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); $settings['jquery']['ui']['datepicker'] = array( 'isRTL' => $language_interface->direction == Language::DIRECTION_RTL, 'firstDay' => \Drupal::config('system.date')->get('first_day'), @@ -820,7 +820,7 @@ function locale_system_file_system_settings_submit(&$form, $form_state) { */ function locale_preprocess_node(&$variables) { if ($variables['node']->language()->id != Language::LANGCODE_NOT_SPECIFIED) { - $language_interface = language(Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); $node_language = $variables['node']->language(); if ($node_language->id != $language_interface->id) { @@ -1270,7 +1270,7 @@ function _locale_invalidate_js($langcode = NULL) { function _locale_rebuild_js($langcode = NULL) { $config = \Drupal::config('locale.settings'); if (!isset($langcode)) { - $language = language(Language::TYPE_INTERFACE); + $language = \Drupal::languageManager()->getCurrentLanguage(); } else { // Get information about the locale. diff --git a/core/modules/node/node.module b/core/modules/node/node.module index bb851a5b60ce..fb29b392825d 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -336,7 +336,7 @@ function node_type_get_types() { * An array of node type labels, keyed by the node type name. */ function node_type_get_names() { - $cid = 'node_type:names:' . language(Language::TYPE_INTERFACE)->id; + $cid = 'node_type:names:' . \Drupal::languageManager()->getCurrentLanguage()->id; if ($cache = \Drupal::cache()->get($cid)) { return $cache->data; } @@ -1147,7 +1147,7 @@ function node_block_access($block) { */ function node_feed($nids = FALSE, $channel = array()) { global $base_url; - $language_content = language(Language::TYPE_CONTENT); + $language_content = \Drupal::languageManager()->getCurrentLanguage(Language::TYPE_CONTENT); $rss_config = \Drupal::config('system.rss'); if ($nids === FALSE) { diff --git a/core/modules/search/search.pages.inc b/core/modules/search/search.pages.inc index ec718554edad..34b235c650d7 100644 --- a/core/modules/search/search.pages.inc +++ b/core/modules/search/search.pages.inc @@ -31,7 +31,7 @@ function search_theme_suggestions_search_result(array $variables) { * - content_attributes: HTML attributes for the content. */ function template_preprocess_search_result(&$variables) { - $language_interface = language(Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); $result = $variables['result']; $variables['url'] = check_url($result['link']); diff --git a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php index cf162fd3baf2..e1bcc90234f1 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php @@ -973,7 +973,7 @@ private function prepareEnvironment() { // Create the database prefix for this test. $this->prepareDatabasePrefix(); - $language_interface = language(Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); // When running the test runner within a test, back up the original database // prefix. diff --git a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsTokenReplaceTest.php b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsTokenReplaceTest.php index f8fa0fe10016..712c5ab21a47 100644 --- a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsTokenReplaceTest.php +++ b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsTokenReplaceTest.php @@ -25,7 +25,7 @@ public static function getInfo() { * Creates a node, then tests the statistics tokens generated from it. */ function testStatisticsTokenReplacement() { - $language_interface = language(Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); // Create user and node. $user = $this->drupalCreateUser(array('create page content')); diff --git a/core/modules/system/language.api.php b/core/modules/system/language.api.php index 8684406741ef..ed6de6c50330 100644 --- a/core/modules/system/language.api.php +++ b/core/modules/system/language.api.php @@ -25,7 +25,7 @@ * The current path. */ function hook_language_switch_links_alter(array &$links, $type, $path) { - $language_interface = language(\Drupal\Core\Language\Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); if ($type == \Drupal\Core\Language\Language::TYPE_CONTENT && isset($links[$language_interface->id])) { foreach ($links[$language_interface->id] as $link) { @@ -69,7 +69,7 @@ function hook_language_switch_links_alter(array &$links, $type, $path) { * Here is a code snippet to transliterate some text: * @code * // Use the current default interface language. - * $langcode = language(\Drupal\Core\Language\Language::TYPE_INTERFACE)->id; + * $langcode = \Drupal::languageManager()->getCurrentLanguage()->id; * // Instantiate the transliteration class. * $trans = \Drupal::transliteration(); * // Use this to transliterate some text. diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php index 4511346494a4..c9ac3bd22c71 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php @@ -96,7 +96,7 @@ function testAdminDefinedFormatDate() { function testFormatDate() { global $user; - $language_interface = language(Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); $timestamp = strtotime('2007-03-26T00:00:00+00:00'); $this->assertIdentical(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T', 'America/Los_Angeles', 'en'), 'Sunday, 25-Mar-07 17:00:00 PDT', 'Test all parameters.'); diff --git a/core/modules/system/lib/Drupal/system/Tests/Mail/MailTest.php b/core/modules/system/lib/Drupal/system/Tests/Mail/MailTest.php index 927b7b1e2384..025c190db00c 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Mail/MailTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Mail/MailTest.php @@ -50,7 +50,7 @@ function setUp() { * Assert that the pluggable mail system is functional. */ public function testPluggableFramework() { - $language_interface = language(Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); // Use MailTestCase for sending a message. drupal_mail('simpletest', 'mail_test', 'testing@example.com', $language_interface->id); @@ -65,7 +65,7 @@ public function testPluggableFramework() { * @see simpletest_mail_alter() */ public function testCancelMessage() { - $language_interface = language(Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); // Reset the class variable holding a copy of the last sent message. self::$sent_message = NULL; @@ -81,7 +81,7 @@ public function testCancelMessage() { * Checks the From: and Reply-to: headers. */ public function testFromAndReplyToHeader() { - global $language; + $language = \Drupal::languageManager()->getCurrentLanguage(); // Reset the class variable holding a copy of the last sent message. self::$sent_message = NULL; diff --git a/core/modules/system/system.api.php b/core/modules/system/system.api.php index cd5919c4a36d..19ea5b1b75e2 100644 --- a/core/modules/system/system.api.php +++ b/core/modules/system/system.api.php @@ -348,7 +348,7 @@ function hook_library_alter(array &$library, $extension, $name) { // hook_library_info_alter() already. $library['dependencies'][] = array('locale', 'drupal.locale.datepicker'); - $language_interface = language(Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); $settings['jquery']['ui']['datepicker'] = array( 'isRTL' => $language_interface->direction == Language::DIRECTION_RTL, 'firstDay' => \Drupal::config('system.date')->get('first_day'), @@ -1388,7 +1388,7 @@ function hook_template_preprocess_default_variables_alter(&$variables) { */ function hook_watchdog(array $log_entry) { global $base_url; - $language_interface = language(\Drupal\Core\Language\Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); $severity_list = array( WATCHDOG_EMERGENCY => t('Emergency'), diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 2580688af3ff..ef3749110d3a 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -1334,7 +1334,7 @@ function system_page_build(&$page) { array( 'path' => current_path(), 'front' => drupal_is_front_page(), - 'language' => language(\Drupal\Core\Language\Language::TYPE_URL)->id, + 'language' => \Drupal::languageManager()->getCurrentLanguage(\Drupal\Core\Language\Language::TYPE_URL)->id, 'query' => \Drupal::service('request')->query->all(), ) ); diff --git a/core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/Plugin/CachedMockBlockManager.php b/core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/Plugin/CachedMockBlockManager.php index 9928a5707141..29634e2294b7 100644 --- a/core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/Plugin/CachedMockBlockManager.php +++ b/core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/Plugin/CachedMockBlockManager.php @@ -25,6 +25,6 @@ public function __construct() { // The CacheDecorator allows us to cache these plugin definitions for // quicker retrieval. In this case we are generating a cache key by // language. - $this->discovery = new CacheDecorator($this->discovery, 'mock_block:' . language(Language::TYPE_INTERFACE)->id, 'cache', 1542646800, array('plugin_test')); + $this->discovery = new CacheDecorator($this->discovery, 'mock_block:' . \Drupal::languageManager()->getCurrentLanguage()->id, 'cache', 1542646800, array('plugin_test')); } } diff --git a/core/modules/system/theme.api.php b/core/modules/system/theme.api.php index a5d617de822a..931707b9e16e 100644 --- a/core/modules/system/theme.api.php +++ b/core/modules/system/theme.api.php @@ -258,7 +258,7 @@ function hook_theme_suggestions_HOOK(array $variables) { */ function hook_theme_suggestions_alter(array &$suggestions, array $variables, $hook) { // Add an interface-language specific suggestion to all theme hooks. - $suggestions[] = $hook . '__' . \Drupal::languageManager()->getLanguage()->id; + $suggestions[] = $hook . '__' . \Drupal::languageManager()->getCurrentLanguage()->id; } /** diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TokenReplaceTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TokenReplaceTest.php index e22b97efc12a..eac5f8496b9e 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TokenReplaceTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TokenReplaceTest.php @@ -66,7 +66,7 @@ function setUp() { */ function testTaxonomyTokenReplacement() { $token_service = \Drupal::token(); - $language_interface = language(Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); // Create two taxonomy terms. $term1 = $this->createTerm($this->vocabulary); diff --git a/core/modules/user/lib/Drupal/user/AccountFormController.php b/core/modules/user/lib/Drupal/user/AccountFormController.php index 964c6642ae02..915e71f3cbd3 100644 --- a/core/modules/user/lib/Drupal/user/AccountFormController.php +++ b/core/modules/user/lib/Drupal/user/AccountFormController.php @@ -72,7 +72,7 @@ public function form(array $form, array &$form_state) { $user = $this->currentUser(); $config = \Drupal::config('user.settings'); - $language_interface = language(Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); $register = $account->isAnonymous(); $admin = $user->hasPermission('administer users'); diff --git a/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php b/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php index cc706baef813..d16b4e2e070d 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php @@ -43,7 +43,7 @@ public function setUp() { */ function testUserTokenReplacement() { $token_service = \Drupal::token(); - $language_interface = language(Language::TYPE_INTERFACE); + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); $url_options = array( 'absolute' => TRUE, 'language' => $language_interface, diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/cache/CachePluginBase.php b/core/modules/views/lib/Drupal/views/Plugin/views/cache/CachePluginBase.php index cfad8fe41e79..665b7a512709 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/cache/CachePluginBase.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/cache/CachePluginBase.php @@ -285,7 +285,7 @@ public function generateResultsKey() { 'build_info' => $build_info, 'roles' => $user->getRoles(), 'super-user' => $user->id() == 1, // special caching for super user. - 'langcode' => language(Language::TYPE_INTERFACE)->id, + 'langcode' => \Drupal::languageManager()->getCurrentLanguage()->id, 'base_url' => $GLOBALS['base_url'], ); $request = \Drupal::request(); @@ -315,7 +315,7 @@ public function generateOutputKey() { 'roles' => $user->getRoles(), 'super-user' => $user->id() == 1, // special caching for super user. 'theme' => $GLOBALS['theme'], - 'langcode' => language(Language::TYPE_INTERFACE)->id, + 'langcode' => \Drupal::languageManager()->getCurrentLanguage()->id, 'base_url' => $GLOBALS['base_url'], ); diff --git a/core/modules/views/views.api.php b/core/modules/views/views.api.php index d48f78957bc6..faacf8a69b8d 100644 --- a/core/modules/views/views.api.php +++ b/core/modules/views/views.api.php @@ -341,7 +341,7 @@ function hook_views_query_substitutions(ViewExecutable $view) { return array( '***CURRENT_VERSION***' => \Drupal::VERSION, '***CURRENT_TIME***' => REQUEST_TIME, - '***CURRENT_LANGUAGE***' => language(\Drupal\Core\Language\Language::TYPE_CONTENT)->id, + '***CURRENT_LANGUAGE***' => \Drupal::languageManager()->getCurrentLanguage(\Drupal\Core\Language\Language::TYPE_CONTENT)->id, '***DEFAULT_LANGUAGE***' => language_default()->id, ); } diff --git a/core/modules/views/views.theme.inc b/core/modules/views/views.theme.inc index 400fcf20cd68..8a55f4bdbbc7 100644 --- a/core/modules/views/views.theme.inc +++ b/core/modules/views/views.theme.inc @@ -1017,7 +1017,7 @@ function template_preprocess_views_view_rss(&$variables) { $variables['link'] = check_url(url($path, $url_options)); } - $variables['langcode'] = String::checkPlain(language(Language::TYPE_INTERFACE)->id); + $variables['langcode'] = String::checkPlain(\Drupal::languageManager()->getCurrentLanguage()->id); $variables['namespaces'] = new Attribute($style->namespaces); $variables['items'] = $items; $variables['channel_elements'] = format_xml_elements($style->channel_elements); diff --git a/core/modules/views/views.views_execution.inc b/core/modules/views/views.views_execution.inc index e730bbb6e470..18039befd346 100644 --- a/core/modules/views/views.views_execution.inc +++ b/core/modules/views/views.views_execution.inc @@ -17,7 +17,7 @@ function views_views_query_substitutions(ViewExecutable $view) { return array( '***CURRENT_VERSION***' => \Drupal::VERSION, '***CURRENT_TIME***' => REQUEST_TIME, - '***CURRENT_LANGUAGE***' => language(Language::TYPE_CONTENT)->id, + '***CURRENT_LANGUAGE***' => \Drupal::languageManager()->getCurrentLanguage(Language::TYPE_CONTENT)->id, '***DEFAULT_LANGUAGE***' => language_default()->id, ); } -- GitLab