diff --git a/core/includes/update.inc b/core/includes/update.inc index 0bca24470f84b7df9d7785efb459554830c2a7b1..9aa35bfd6df7934963dd99e5e68aad45fb9c4229 100644 --- a/core/includes/update.inc +++ b/core/includes/update.inc @@ -821,7 +821,7 @@ function update_language_list($flags = Language::STATE_CONFIGURABLE) { $languages = array(); // Fill in master language list based on current configuration. - $default = language_default(); + $default = \Drupal::languageManager()->getDefaultLanguage(); if (\Drupal::languageManager()->isMultilingual() || \Drupal::moduleHandler()->moduleExists('language')) { // Use language module configuration if available. We can not use // entity_load_multiple() because this breaks during updates. @@ -858,7 +858,7 @@ function update_language_list($flags = Language::STATE_CONFIGURABLE) { // Add the site's default language if flagged as allowed value. if ($flags & Language::STATE_SITE_DEFAULT) { - $default = isset($default) ? $default : language_default(); + $default = isset($default) ? $default : \Drupal::languageManager()->getDefaultLanguage(); // Rename the default language. $default->name = t("Site's default language (@lang_name)", array('@lang_name' => $default->name)); $filtered_languages['site_default'] = $default; diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTypeTest.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTypeTest.php index 6c4a6817cf253cad382e56f6ce230f1f3be0a232..739f234256036c631c4fead819043c7b70c5f5a1 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTypeTest.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTypeTest.php @@ -66,7 +66,7 @@ public function testCustomBlockTypeCreation() { $this->assertTrue($block_type, 'The new block type has been created.'); // Check that the block type was created in site default language. - $default_langcode = language_default()->id; + $default_langcode = \Drupal::languageManager()->getDefaultLanguage()->id; $this->assertEqual($block_type->langcode, $default_langcode); } diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php index 79c572ea60139652e6867afea36305e14bd17850..55ad332e164741bf376e2c4ae5fbf2309137907a 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php @@ -93,7 +93,7 @@ protected function createTests() { 'id' => 'test_block', 'weight' => NULL, 'status' => TRUE, - 'langcode' => language_default()->id, + 'langcode' => \Drupal::languageManager()->getDefaultLanguage()->id, 'dependencies' => array('module' => array('block_test'), 'theme' => array('stark')), 'theme' => 'stark', 'region' => '-1', diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentLanguageTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentLanguageTest.php index 56444a9f5bbb1540234921b5c4f593b61d97e7b4..139bf736e3e6823ec4f6b79f58ef2648a1ab274d 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentLanguageTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentLanguageTest.php @@ -91,7 +91,7 @@ function testCommentLanguage() { // is the user language preference. This way we can ensure that node // language and interface language do not influence comment language, as // only content language has to. - foreach (language_list() as $node_langcode => $node_language) { + foreach ($this->container->get('language_manager')->getLanguages() as $node_langcode => $node_language) { // Create "Article" content. $title = $this->randomName(); $edit = array( @@ -104,7 +104,7 @@ function testCommentLanguage() { $node = $this->drupalGetNodeByTitle($title); $prefixes = language_negotiation_url_prefixes(); - foreach (language_list() as $langcode => $language) { + foreach ($this->container->get('language_manager')->getLanguages() as $langcode => $language) { // Post a comment with content language $langcode. $prefix = empty($prefixes[$langcode]) ? '' : $prefixes[$langcode] . '/'; $comment_values[$node_langcode][$langcode] = $this->randomName(); diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentTranslationUITest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentTranslationUITest.php index ce52ee2bc4ead46308aaf6bdb5e5e14afc1e2809..5e5b4de702645d15cc2ee86ccc167c3a702bddbd 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentTranslationUITest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentTranslationUITest.php @@ -132,7 +132,7 @@ protected function assertPublishedStatus() { $entity = entity_load($this->entityTypeId, $this->entityId); $user = $this->drupalCreateUser(array('access comments')); $this->drupalLogin($user); - $languages = language_list(); + $languages = $this->container->get('language_manager')->getLanguages(); // Check that simple users cannot see unpublished field translations. $path = $entity->getSystemPath(); diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityTest.php index 51bbf331f50eb4ff80bebac5a0876c939373f528..a2e1975521665ad00dbd436b31ba6a80005e81d9 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityTest.php @@ -39,7 +39,7 @@ public static function getInfo() { * Tests CRUD operations. */ function testCRUD() { - $default_langcode = language_default()->id; + $default_langcode = \Drupal::languageManager()->getDefaultLanguage()->id; // Verify default properties on a newly created empty entity. $empty = entity_create('config_test'); $this->assertIdentical($empty->id, NULL); diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php index 51f91825b82d137da190d01338a07f365653177a..4a38a4df3eba33bae8df31c9d3a9dec5d71e4cd6 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php @@ -58,7 +58,7 @@ function testImport() { 'test_dependencies' => array(), 'status' => TRUE, 'uuid' => '30df59bd-7b03-4cf7-bb35-d42fc49f0651', - 'langcode' => language_default()->id, + 'langcode' => \Drupal::languageManager()->getDefaultLanguage()->id, 'dependencies' => array(), 'protected_property' => '', ); diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigImporterTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigImporterTest.php index b01ddabd696c6ae94ecadd12f19683a9f2d6d5e7..8e99296012aceaa1016878d8bc6b637ba0d2ebae 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigImporterTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigImporterTest.php @@ -169,7 +169,7 @@ function testNew() { 'test_dependencies' => array(), 'status' => TRUE, 'uuid' => '30df59bd-7b03-4cf7-bb35-d42fc49f0651', - 'langcode' => language_default()->id, + 'langcode' => \Drupal::languageManager()->getDefaultLanguage()->id, 'dependencies' => array(), 'protected_property' => '', ); diff --git a/core/modules/contact/lib/Drupal/contact/Tests/ContactSitewideTest.php b/core/modules/contact/lib/Drupal/contact/Tests/ContactSitewideTest.php index 126fc757e09bb74cecd814c555c7b6c1c79f1e2c..744216637acd2c2a610186abe482713127156e44 100644 --- a/core/modules/contact/lib/Drupal/contact/Tests/ContactSitewideTest.php +++ b/core/modules/contact/lib/Drupal/contact/Tests/ContactSitewideTest.php @@ -115,7 +115,7 @@ function testSiteWideContact() { // Check that the category was created in site default language. $langcode = \Drupal::config('contact.category.' . $id)->get('langcode'); - $default_langcode = language_default()->id; + $default_langcode = \Drupal::languageManager()->getDefaultLanguage()->id; $this->assertEqual($langcode, $default_langcode); // Make sure the newly created category is included in the list of categories. diff --git a/core/modules/content_translation/content_translation.admin.inc b/core/modules/content_translation/content_translation.admin.inc index 96b8d3c02e29197dc38dc06925eb81452d67ba8a..d7017a90e3eac6c092fdb39b18c11b90f7f15690 100644 --- a/core/modules/content_translation/content_translation.admin.inc +++ b/core/modules/content_translation/content_translation.admin.inc @@ -277,7 +277,7 @@ function content_translation_form_language_content_settings_validate(array $form $values = $bundle_settings['settings']['language']; if (empty($values['language_show']) && \Drupal::languageManager()->isLanguageLocked($values['langcode'])) { - foreach (language_list(Language::STATE_LOCKED) as $language) { + foreach (\Drupal::languageManager()->getLanguages(Language::STATE_LOCKED) as $language) { $locked_languages[] = $language->name; } form_set_error($name, $form_state, t('Translation is not supported if language is always one of: @locked_languages', array('@locked_languages' => implode(', ', $locked_languages)))); diff --git a/core/modules/content_translation/content_translation.install b/core/modules/content_translation/content_translation.install index e474d693d8eb597f4bddc254e047f9d5aa465d48..2d4963e1dde041d2836891b698890985b690f217 100644 --- a/core/modules/content_translation/content_translation.install +++ b/core/modules/content_translation/content_translation.install @@ -94,7 +94,7 @@ function content_translation_install() { */ function content_translation_enable() { // Translation works when at least two languages are enabled. - if (count(language_list()) < 2) { + if (count(\Drupal::languageManager()->getLanguages()) < 2) { $t_args = array('!language_url' => url('admin/config/regional/language')); $message = t('Be sure to <a href="!language_url">enable at least two languages</a> to translate content.', $t_args); drupal_set_message($message, 'warning'); diff --git a/core/modules/content_translation/content_translation.module b/core/modules/content_translation/content_translation.module index dc405b90ecc1a69457ad283e008420e4dce7f546..634338c21ae303a0d060ce23285e240400e252e6 100644 --- a/core/modules/content_translation/content_translation.module +++ b/core/modules/content_translation/content_translation.module @@ -287,7 +287,7 @@ function content_translation_add_access(EntityInterface $entity, Language $sourc $source = !empty($source) ? $source : $entity->language(); $target = !empty($target) ? $target : \Drupal::languageManager()->getCurrentLanguage(Language::TYPE_CONTENT); $translations = $entity->getTranslationLanguages(); - $languages = language_list(); + $languages = \Drupal::languageManager()->getLanguages(); return $source->id != $target->id && isset($languages[$source->id]) && isset($languages[$target->id]) && !isset($translations[$target->id]) && content_translation_access($entity, 'create'); } @@ -303,7 +303,7 @@ function content_translation_add_access(EntityInterface $entity, Language $sourc function content_translation_edit_access(EntityInterface $entity, Language $language = NULL) { $language = !empty($language) ? $language : \Drupal::languageManager()->getCurrentLanguage(Language::TYPE_CONTENT); $translations = $entity->getTranslationLanguages(); - $languages = language_list(); + $languages = \Drupal::languageManager()->getLanguages(); return isset($languages[$language->id]) && $language->id != $entity->getUntranslated()->language()->id && isset($translations[$language->id]) && content_translation_access($entity, 'update'); } @@ -319,7 +319,7 @@ function content_translation_edit_access(EntityInterface $entity, Language $lang function content_translation_delete_access(EntityInterface $entity, Language $language = NULL) { $language = !empty($language) ? $language : \Drupal::languageManager()->getCurrentLanguage(Language::TYPE_CONTENT); $translations = $entity->getTranslationLanguages(); - $languages = language_list(); + $languages = \Drupal::languageManager()->getLanguages(); return isset($languages[$language->id]) && $language->id != $entity->getUntranslated()->language()->id && isset($translations[$language->id]) && content_translation_access($entity, 'delete'); } @@ -859,7 +859,7 @@ function content_translation_language_configuration_element_validate($element, a $key = $form_state['content_translation']['key']; $values = $form_state['values'][$key]; if (!$values['language_show'] && $values['content_translation'] && \Drupal::languageManager()->isLanguageLocked($values['langcode'])) { - foreach (language_list(Language::STATE_LOCKED) as $language) { + foreach (\Drupal::languageManager()->getLanguages(Language::STATE_LOCKED) as $language) { $locked_languages[] = $language->name; } // @todo Set the correct form element name as soon as the element parents diff --git a/core/modules/content_translation/content_translation.pages.inc b/core/modules/content_translation/content_translation.pages.inc index 44c82d09b39b2d2606f3f318a74eb664a8a6160a..16864bf4baa917a4378923932311a673922b6ea7 100644 --- a/core/modules/content_translation/content_translation.pages.inc +++ b/core/modules/content_translation/content_translation.pages.inc @@ -20,7 +20,7 @@ */ function content_translation_overview(EntityInterface $entity) { $controller = content_translation_controller($entity->getEntityTypeId()); - $languages = language_list(); + $languages = \Drupal::languageManager()->getLanguages(); $original = $entity->getUntranslated()->language()->id; $translations = $entity->getTranslationLanguages(); $administrator = \Drupal::currentUser()->hasPermission('administer languages'); diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationTestBase.php b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationTestBase.php index 250b10a4cdbafc98f1be9e9d17cebcef0c56ae1e..54c5d6972368b5a547c2109c684045497a69e191 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationTestBase.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationTestBase.php @@ -103,7 +103,7 @@ protected function setupLanguages() { foreach ($this->langcodes as $langcode) { language_save(new Language(array('id' => $langcode))); } - array_unshift($this->langcodes, language_default()->id); + array_unshift($this->langcodes, \Drupal::languageManager()->getDefaultLanguage()->id); } /** diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationWorkflowsTest.php b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationWorkflowsTest.php index 861aec91dafccd722634f3c6d9da4a1ff0ad6891..43e5d774716703e3aca6f95c9adba139f2b0247f 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationWorkflowsTest.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationWorkflowsTest.php @@ -119,7 +119,7 @@ function testWorkflows() { */ protected function assertWorkflows(UserInterface $user, $expected_status) { $default_langcode = $this->langcodes[0]; - $languages = language_list(); + $languages = $this->container->get('language_manager')->getLanguages(); $args = array('@user_label' => $user->getUsername()); $this->drupalLogin($user); diff --git a/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php b/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php index 02630bb91aa5467c5d643cec48553fc06f9b67a5..89af9c936a53cebd864f2423db0853a4ddf2749c 100644 --- a/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php @@ -126,7 +126,7 @@ function testTranslatableFieldSaveLoad() { field_test_entity_info_translatable($entity_type_id, TRUE); $entity = entity_create($entity_type_id, array('type' => $this->instance->bundle)); $field_translations = array(); - $available_langcodes = array_keys(language_list()); + $available_langcodes = array_keys($this->container->get('language_manager')->getLanguages()); $entity->langcode->value = reset($available_langcodes); foreach ($available_langcodes as $langcode) { $field_translations[$langcode] = $this->_generateTestFieldValues($this->field->getCardinality()); diff --git a/core/modules/field/lib/Drupal/field/Tests/TranslationWebTest.php b/core/modules/field/lib/Drupal/field/Tests/TranslationWebTest.php index d8d9f9c8efc4597836caf46eccae286252a91627..ba00c740b1795fd60c507f52b1180e3b18050369 100644 --- a/core/modules/field/lib/Drupal/field/Tests/TranslationWebTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/TranslationWebTest.php @@ -103,7 +103,7 @@ function testFieldFormTranslationRevisions() { // Prepare the field translations. field_test_entity_info_translatable($this->entity_type, TRUE); $entity = entity_create($this->entity_type); - $available_langcodes = array_flip(array_keys(language_list())); + $available_langcodes = array_flip(array_keys($this->container->get('language_manager')->getLanguages())); $field_name = $this->field->getName(); // Store the field translations. diff --git a/core/modules/filter/lib/Drupal/filter/Tests/FilterCrudTest.php b/core/modules/filter/lib/Drupal/filter/Tests/FilterCrudTest.php index a6456918fd1e6e36190ec8813407f7da2c5f1051..041f309d1c67a233c524340faf71448b05afd304 100644 --- a/core/modules/filter/lib/Drupal/filter/Tests/FilterCrudTest.php +++ b/core/modules/filter/lib/Drupal/filter/Tests/FilterCrudTest.php @@ -84,7 +84,7 @@ function testTextFormatCrud() { */ function verifyTextFormat($format) { $t_args = array('%format' => $format->name); - $default_langcode = language_default()->id; + $default_langcode = \Drupal::languageManager()->getDefaultLanguage()->id; // Verify the loaded filter has all properties. $filter_format = entity_load('filter_format', $format->format); diff --git a/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php b/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php index 35a4bd1e1f3da2a1a4ec08eb7042cd9dead0f269..637392925554bd42f2f1b90672dbc8e6b013c032 100644 --- a/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php +++ b/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php @@ -300,7 +300,7 @@ private function doAdminTests($user) { 'name' => 'Tags', 'description' => $description, 'vid' => 'tags', - 'langcode' => language_default()->id, + 'langcode' => \Drupal::languageManager()->getDefaultLanguage()->id, 'help' => $help, )); $vocabulary->save(); diff --git a/core/modules/forum/lib/Drupal/forum/Tests/ForumUninstallTest.php b/core/modules/forum/lib/Drupal/forum/Tests/ForumUninstallTest.php index c9bbcff71141a5d686effbf20b10f1613762fe8f..1e4e9bd384e99c6eff383a7561140e32f6063196 100644 --- a/core/modules/forum/lib/Drupal/forum/Tests/ForumUninstallTest.php +++ b/core/modules/forum/lib/Drupal/forum/Tests/ForumUninstallTest.php @@ -42,7 +42,7 @@ function testForumUninstallWithField() { // Create a taxonomy term. $term = entity_create('taxonomy_term', array( 'name' => t('A term'), - 'langcode' => language_default()->id, + 'langcode' => \Drupal::languageManager()->getDefaultLanguage()->id, 'description' => '', 'parent' => array(0), 'vid' => 'forums', diff --git a/core/modules/language/language.admin.inc b/core/modules/language/language.admin.inc index c7dbb8dc2682d14cc3a08eae2fcc8ed455885ed4..5a34319926c28ea9b0564a907e37560a563abd1b 100644 --- a/core/modules/language/language.admin.inc +++ b/core/modules/language/language.admin.inc @@ -12,7 +12,7 @@ * Prepare a language code list for unused predefined languages. */ function language_admin_predefined_list() { - $languages = language_list(); + $languages = \Drupal::languageManager()->getLanguages(); $predefined = LanguageManager::getStandardLanguageList(); foreach ($predefined as $key => $value) { if (isset($languages[$key])) { diff --git a/core/modules/language/language.module b/core/modules/language/language.module index 41a8a6f24d76d206c73540cda4e0ad7b83fd1dfb..e70b2b9163a66f50f22aa0bd53c24cea66c00e9c 100644 --- a/core/modules/language/language.module +++ b/core/modules/language/language.module @@ -161,7 +161,7 @@ function language_process_language_select($element) { // set the options. if (!isset($element['#options'])) { $element['#options'] = array(); - foreach (language_list($element['#languages']) as $langcode => $language) { + foreach (\Drupal::languageManager()->getLanguages($element['#languages']) as $langcode => $language) { $element['#options'][$langcode] = $language->locked ? t('- @name -', array('@name' => $language->name)) : $language->name; } } @@ -203,12 +203,12 @@ function language_element_info() { */ function language_configuration_element_default_options() { $language_options = array( - 'site_default' => t("Site's default language (!language)", array('!language' => language_default()->name)), + 'site_default' => t("Site's default language (!language)", array('!language' => \Drupal::languageManager()->getDefaultLanguage()->name)), 'current_interface' => t('Current interface language'), 'authors_default' => t("Author's preferred language"), ); - $languages = language_list(Language::STATE_ALL); + $languages = \Drupal::languageManager()->getLanguages(Language::STATE_ALL); foreach ($languages as $langcode => $language) { $language_options[$langcode] = $language->locked ? t('- @name -', array('@name' => $language->name)) : $language->name; } @@ -383,7 +383,7 @@ function language_get_default_langcode($entity_type, $bundle) { $language_interface = \Drupal::languageManager()->getCurrentLanguage(); switch ($configuration['langcode']) { case 'site_default': - $default_value = language_default()->id; + $default_value = \Drupal::languageManager()->getDefaultLanguage()->id; break; case 'current_interface': @@ -457,7 +457,8 @@ function language_save($language) { } // Update URL Prefixes for all languages after the new default language is - // propagated and the language_list() cache is flushed. + // propagated and the LanguageManagerInterface::getLanguages() cache is + // flushed. language_negotiation_url_prefixes_update(); // If after adding this language the site will become multilingual, we need to @@ -479,7 +480,7 @@ function language_save($language) { * TRUE if language is successfully deleted. Otherwise FALSE. */ function language_delete($langcode) { - $languages = language_list(Language::STATE_ALL); + $languages = \Drupal::languageManager()->getLanguages(Language::STATE_ALL); if (isset($languages[$langcode]) && !$languages[$langcode]->locked) { $language = $languages[$langcode]; @@ -551,7 +552,7 @@ function language_negotiation_url_prefixes() { */ function language_negotiation_url_prefixes_update() { $prefixes = language_negotiation_url_prefixes(); - foreach (language_list() as $language) { + foreach (\Drupal::languageManager()->getLanguages() as $language) { // The prefix for this language should be updated if it's not assigned yet // or the prefix is set to the empty string. if (empty($prefixes[$language->id])) { @@ -679,8 +680,8 @@ function language_set_browser_drupal_langcode_mappings($mappings) { * @see language_system_regional_settings_form_submit() */ function language_form_system_regional_settings_alter(&$form, &$form_state) { - $languages = language_list(); - $default = language_default(); + $languages = \Drupal::languageManager()->getLanguages(); + $default = \Drupal::languageManager()->getDefaultLanguage(); foreach ($languages as $key => $language) { $language_options[$key] = $language->name; } @@ -702,7 +703,7 @@ function language_form_system_regional_settings_alter(&$form, &$form_state) { * @see language_form_system_regional_settings_alter() */ function language_system_regional_settings_form_submit($form, &$form_state) { - $languages = language_list(); + $languages = \Drupal::languageManager()->getLanguages(); $language = $languages[$form_state['values']['site_default_language']]; $language->default = TRUE; language_save($language); diff --git a/core/modules/language/lib/Drupal/language/Tests/Condition/LanguageConditionTest.php b/core/modules/language/lib/Drupal/language/Tests/Condition/LanguageConditionTest.php index a9cec74fd98619b61bcfa428f6ad21558575c4c2..fb8bfffca72aa43d59987304a790e1d611bd0262 100644 --- a/core/modules/language/lib/Drupal/language/Tests/Condition/LanguageConditionTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/Condition/LanguageConditionTest.php @@ -51,7 +51,7 @@ protected function setUp() { $this->installConfig(array('language')); // Setup English. - language_save(language_default()); + language_save(\Drupal::languageManager()->getDefaultLanguage()); // Setup Italian. $language = new Language(array( @@ -70,7 +70,7 @@ protected function setUp() { public function testConditions() { // Grab the language condition and configure it to check the content // language. - $language = language_load('en'); + $language = \Drupal::languageManager()->getLanguage('en'); $condition = $this->manager->createInstance('language') ->setConfig('langcodes', array('en' => 'en', 'it' => 'it')) ->setContextValue('language', $language); @@ -91,7 +91,7 @@ public function testConditions() { $this->assertEqual($condition->summary(), 'The language is not Italian.'); // Change the default language to Italian. - $language = language_load('it'); + $language = \Drupal::languageManager()->getLanguage('it'); $condition = $this->manager->createInstance('language') ->setConfig('langcodes', array('en' => 'en', 'it' => 'it')) diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationElementTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationElementTest.php index adab4caeee1b8c2a969d3bf8496da082385c5386..0a507f20cf373d325f4f2ea44e852fcee8558cf8 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationElementTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationElementTest.php @@ -87,10 +87,10 @@ public function testDefaultLangcode() { $this->assertEqual($langcode, $language_interface->id); // Site's default. - $old_default = language_default(); + $old_default = \Drupal::languageManager()->getDefaultLanguage(); $old_default->default = FALSE; language_save($old_default); - $new_default = language_load('cc'); + $new_default = \Drupal::languageManager()->getLanguage('cc'); $new_default->default = TRUE; language_save($new_default); language_save_default_configuration('custom_type', 'custom_bundle', array('langcode' => 'site_default', 'language_show' => TRUE)); diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageDependencyInjectionTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageDependencyInjectionTest.php index f7342100ecd80e7beb2b037fd10d5661d846fa53..067c477c7bf15e439761ce4f2b8b797f43e16cea 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageDependencyInjectionTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageDependencyInjectionTest.php @@ -47,7 +47,7 @@ function testDependencyInjectedNewLanguage() { * @see \Drupal\Core\Language\Language */ function testDependencyInjectedNewDefaultLanguage() { - $default_language = language_default(); + $default_language = \Drupal::languageManager()->getDefaultLanguage(); // Change the language default object to different values. $new_language_default = new Language(array( 'id' => 'fr', diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageListModuleInstallTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageListModuleInstallTest.php index d4192b6221facb5d7f2c73d4baedd8be244ff1cd..17e433e4347aef1a968cffb1f1525dd78f64a87c 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageListModuleInstallTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageListModuleInstallTest.php @@ -41,7 +41,7 @@ function testModuleInstallLanguageList() { $edit['modules[Multilingual][language][enable]'] = 'language'; $this->drupalPostForm('admin/modules', $edit, t('Save configuration')); - $this->assertEqual(\Drupal::state()->get('language_test.language_count_preinstall', 0), 1, 'Using language_list() returns 1 language during Language installation.'); + $this->assertEqual(\Drupal::state()->get('language_test.language_count_preinstall', 0), 1, 'Using LanguageManager::getLanguages() returns 1 language during Language installation.'); // Get updated module list by rebuilding container. $this->rebuildContainer(); diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageListTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageListTest.php index a475c04cae7314138a3d2fb61b11c3b4c6b79213..273850b5a4ab1188593d67a49677d4609cfe56a1 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageListTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageListTest.php @@ -118,12 +118,12 @@ function testLanguageList() { $this->assertResponse(404, 'Language no longer found.'); // Make sure the "language_count" state has been updated correctly. $this->container->get('language_manager')->reset(); - $languages = language_list(); + $languages = $this->container->get('language_manager')->getLanguages(); // Delete French. $this->drupalPostForm('admin/config/regional/language/delete/fr', array(), t('Delete')); // Get the count of languages. $this->container->get('language_manager')->reset(); - $languages = language_list(); + $languages = $this->container->get('language_manager')->getLanguages(); // We need raw here because %language and %langcode will add HTML. $t_args = array('%language' => 'French', '%langcode' => 'fr'); $this->assertRaw(t('The %language (%langcode) language has been removed.', $t_args), 'Disabled language has been removed.'); @@ -179,13 +179,13 @@ function testLanguageStates() { $expected_all_languages = array('l4' => 'l4', 'l3' => 'l3', 'l2' => 'l2', 'l1' => 'l1', 'en' => 'en', 'und' => 'und', 'zxx' => 'zxx'); $expected_conf_languages = array('l3' => 'l3', 'l1' => 'l1', 'en' => 'en'); - $locked_languages = language_list(Language::STATE_LOCKED); + $locked_languages = $this->container->get('language_manager')->getLanguages(Language::STATE_LOCKED); $this->assertEqual(array_diff_key($expected_locked_languages, $locked_languages), array(), 'Locked languages loaded correctly.'); - $all_languages = language_list(Language::STATE_ALL); + $all_languages = $this->container->get('language_manager')->getLanguages(Language::STATE_ALL); $this->assertEqual(array_diff_key($expected_all_languages, $all_languages), array(), 'All languages loaded correctly.'); - $conf_languages = language_list(); + $conf_languages = $this->container->get('language_manager')->getLanguages(); $this->assertEqual(array_diff_key($expected_conf_languages, $conf_languages), array(), 'Configurable languages loaded correctly.'); } } diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguagePathMonolingualTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguagePathMonolingualTest.php index 863a41d43d39c06d25b4bdcb8528ebbbeee65031..73e5b854ccbc4ee54d2fa40dc457b0438906bc30 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguagePathMonolingualTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguagePathMonolingualTest.php @@ -57,7 +57,7 @@ function setUp() { // Verify that French is the only language. $this->container->get('language_manager')->reset(); $this->assertFalse(\Drupal::languageManager()->isMultilingual(), 'Site is mono-lingual'); - $this->assertEqual(language_default()->id, 'fr', 'French is the default language'); + $this->assertEqual(\Drupal::languageManager()->getDefaultLanguage()->id, 'fr', 'French is the default language'); // Set language detection to URL. $edit = array('language_interface[enabled][language-url]' => TRUE); diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php index 89832f3cf69d79488c537a9ed4c865fdf81be9cd..169bfcf0a209c1d074c11884773fd5f3c2827342 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php @@ -98,7 +98,7 @@ function testUILanguageNegotiation() { // into database when seen by t(). Without doing this, our target string // is for some reason not found when doing translate search. This might // be some bug. - $default_language = language_default(); + $default_language = \Drupal::languageManager()->getDefaultLanguage(); $language = new Language(array( 'id' => $langcode_browser_fallback, 'default' => TRUE, @@ -364,7 +364,7 @@ function testUrlLanguageFallback() { 'id' => $langcode_browser_fallback, )); language_save($language); - $languages = language_list(); + $languages = $this->container->get('language_manager')->getLanguages(); // Enable the path prefix for the default language: this way any unprefixed // URL must have a valid fallback value. @@ -416,7 +416,7 @@ function testLanguageDomain() { 'id' => $langcode, )); language_save($language); - $languages = language_list(); + $languages = $this->container->get('language_manager')->getLanguages(); // Enable browser and URL language detection. $edit = array( diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageUrlRewritingTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageUrlRewritingTest.php index 09cb3631de514fb894f0451f4808ced3c4bd77ad..39ad3f813834b05871b62d2e48f3b1de12dbef5d 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageUrlRewritingTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageUrlRewritingTest.php @@ -54,7 +54,7 @@ function setUp() { */ function testUrlRewritingEdgeCases() { // Check URL rewriting with a non-installed language. - $non_existing = language_default(); + $non_existing = \Drupal::languageManager()->getDefaultLanguage(); $non_existing->id = $this->randomName(); $this->checkUrl($non_existing, 'Path language is ignored if language is not installed.', 'URL language negotiation does not work with non-installed languages'); @@ -129,7 +129,7 @@ function testDomainNameNegotiationPort() { $request = $this->prepareRequestForGenerator(TRUE, array('HTTP_HOST' => $server['HTTP_HOST'] . ':88')); // Create an absolute French link. - $language = language_load('fr'); + $language = \Drupal::languageManager()->getLanguage('fr'); $url = url('', array( 'absolute' => TRUE, 'language' => $language, diff --git a/core/modules/language/tests/language_test/language_test.module b/core/modules/language/tests/language_test/language_test.module index 42f2b0f65402f3737ebc22e997cbe53888b4dc7b..e1fd47e45af46ed3c290675e537fc932377cf631 100644 --- a/core/modules/language/tests/language_test/language_test.module +++ b/core/modules/language/tests/language_test/language_test.module @@ -98,5 +98,5 @@ function language_test_language_fallback_candidates_test_alter(array &$candidate * Implements hook_module_preinstall(). */ function language_test_module_preinstall() { - \Drupal::state()->set('language_test.language_count_preinstall', count(language_list())); + \Drupal::state()->set('language_test.language_count_preinstall', count(\Drupal::languageManager()->getLanguages())); } diff --git a/core/modules/language/tests/language_test/lib/Drupal/language_test/Controller/LanguageTestController.php b/core/modules/language/tests/language_test/lib/Drupal/language_test/Controller/LanguageTestController.php index 781af064359ab1683d14bb1f1fb012821eee0d72..dd6aff83dcf982caa2845642760fa1d4e7785b98 100644 --- a/core/modules/language/tests/language_test/lib/Drupal/language_test/Controller/LanguageTestController.php +++ b/core/modules/language/tests/language_test/lib/Drupal/language_test/Controller/LanguageTestController.php @@ -8,6 +8,7 @@ namespace Drupal\language_test\Controller; use Drupal\Core\DependencyInjection\ContainerInjectionInterface; +use Drupal\Core\Language\LanguageManager; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\HttpKernelInterface; @@ -24,21 +25,29 @@ class LanguageTestController implements ContainerInjectionInterface { */ protected $httpKernel; + /** + * The language manager service. + * + * @var \Drupal\Core\Language\LanguageManager + */ + protected $languageManager; + /** * Constructs a new LanguageTestController object. * * @param \Symfony\Component\HttpKernel\HttpKernelInterface $httpKernel * An HTTP kernel. */ - public function __construct(HttpKernelInterface $httpKernel) { + public function __construct(HttpKernelInterface $httpKernel, LanguageManager $language_manager) { $this->httpKernel = $httpKernel; + $this->languageManager = $language_manager; } /** * {@inheritdoc} */ public static function create(ContainerInterface $container) { - return new static($container->get('http_kernel')); + return new static($container->get('http_kernel'), $container->get('language_manager')); } /** @@ -48,7 +57,7 @@ public static function create(ContainerInterface $container) { */ public function typeLinkActiveClass() { // We assume that 'en' and 'fr' have been configured. - $languages = language_list(); + $languages = $this->languageManager->getLanguages(); return array( 'no_language' => array( '#type' => 'link', diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleStringTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleStringTest.php index 59993f03b2de822b58aae464f64573a236824ce0..865023e2f1d75dfc6796bd12ad61ca2e5670e3b1 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleStringTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleStringTest.php @@ -195,7 +195,7 @@ function buildSourceString($values = array()) { */ function createAllTranslations($source, $values = array()) { $list = array(); - foreach (language_list() as $language) { + foreach ($this->container->get('language_manager')->getLanguages() as $language) { $list[$language->id] = $this->createTranslation($source, $language->id, $values); } return $list; diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateBase.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateBase.php index 2e29d98f51f685967dce39ecd0c4d2fb6764fde8..6554886b9c4bc0720b8187a3b5dec039a7bb658c 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateBase.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateBase.php @@ -81,7 +81,7 @@ protected function addLanguage($langcode) { $edit = array('predefined_langcode' => $langcode); $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language')); $this->container->get('language_manager')->reset(); - $this->assertTrue(language_load($langcode), String::format('Language %langcode added.', array('%langcode' => $langcode))); + $this->assertTrue(\Drupal::languageManager()->getLanguage($langcode), String::format('Language %langcode added.', array('%langcode' => $langcode))); } /** diff --git a/core/modules/locale/locale.bulk.inc b/core/modules/locale/locale.bulk.inc index 5f72ad89726cd9fee17a3c2af8e19554c9a98936..4f061643c3d9cacde8625c8b03ef6d726ef2eaca 100644 --- a/core/modules/locale/locale.bulk.inc +++ b/core/modules/locale/locale.bulk.inc @@ -20,7 +20,7 @@ */ function locale_translate_import_form($form, &$form_state) { Drupal::languageManager()->reset(); - $languages = language_list(); + $languages = \Drupal::languageManager()->getLanguages(); // Initialize a language list to the ones available, including English if we // are to translate Drupal to English as well. @@ -118,7 +118,7 @@ function locale_translate_import_form_submit($form, &$form_state) { if ($file = file_save_upload('file', $form_state, $form['file']['#upload_validators'], 'translations://', 0)) { // Add language, if not yet supported. - $language = language_load($form_state['values']['langcode']); + $language = \Drupal::languageManager()->getLanguage($form_state['values']['langcode']); if (empty($language)) { $language = new Language(array( 'id' => $form_state['values']['langcode'] @@ -182,7 +182,7 @@ function locale_translate_batch_import_files($options, $force = FALSE) { else { // If langcode was not provided, make sure to only import files for the // languages we have enabled. - $langcodes = array_keys(language_list()); + $langcodes = array_keys(\Drupal::languageManager()->getLanguages()); } $files = locale_translate_get_interface_translation_files(array(), $langcodes); diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module index 79bf982d4d889b4b42d243ac7497b0c526cfed8a..e6d9a6f0923f9d6a6a928d907c79bab67e63ae4a 100644 --- a/core/modules/locale/locale.module +++ b/core/modules/locale/locale.module @@ -269,7 +269,7 @@ function locale_language_entity_delete(LanguageEntity $language) { * unless it is marked as translatable. */ function locale_translatable_language_list() { - $languages = language_list(); + $languages = \Drupal::languageManager()->getLanguages(); if (!locale_translate_english()) { unset($languages['en']); } @@ -1252,7 +1252,7 @@ function _locale_rebuild_js($langcode = NULL) { } else { // Get information about the locale. - $languages = language_list(); + $languages = \Drupal::languageManager()->getLanguages(); $language = $languages[$langcode]; } diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php b/core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php index afc0c570710f89f55222cb4c2601f49e9c9ae5e2..40129081f6e1a91dbeef3f2508050e03c36976db 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php @@ -114,7 +114,7 @@ protected function getFormSubmitAction(EntityInterface $entity, $langcode) { protected function doTestPublishedStatus() { $entity = entity_load($this->entityTypeId, $this->entityId, TRUE); $path = $entity->getSystemPath('edit-form'); - $languages = language_list(); + $languages = $this->container->get('language_manager')->getLanguages(); $actions = array( t('Save and keep published'), @@ -145,7 +145,7 @@ protected function doTestPublishedStatus() { protected function doTestAuthoringInfo() { $entity = entity_load($this->entityTypeId, $this->entityId, TRUE); $path = $entity->getSystemPath('edit-form'); - $languages = language_list(); + $languages = $this->container->get('language_manager')->getLanguages(); $values = array(); // Post different base field information for each translation. @@ -331,7 +331,7 @@ function testTranslationRendering() { * The translation values to be found. */ protected function doTestTranslations($path, array $values) { - $languages = language_list(); + $languages = $this->container->get('language_manager')->getLanguages(); foreach ($this->langcodes as $langcode) { $this->drupalGet($path, array('language' => $languages[$langcode])); $this->assertText($values[$langcode]['title'][0]['value'], format_string('The %langcode node translation is correctly displayed.', array('%langcode' => $langcode))); diff --git a/core/modules/node/node.tokens.inc b/core/modules/node/node.tokens.inc index dbf668c7eab94b092416bdfbbc229013fabe117c..e06da3f79537bf795344af73aed8e9d49176193b 100644 --- a/core/modules/node/node.tokens.inc +++ b/core/modules/node/node.tokens.inc @@ -90,7 +90,7 @@ function node_tokens($type, $tokens, array $data = array(), array $options = arr $url_options = array('absolute' => TRUE); if (isset($options['langcode'])) { - $url_options['language'] = language_load($options['langcode']); + $url_options['language'] = \Drupal::languageManager()->getLanguage($options['langcode']); $langcode = $options['langcode']; } else { diff --git a/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php b/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php index 683bac0ff85eba495dc03bd89765f837ced2c03d..a2fcbb7273263b893efce83d7dedabf62536c694 100644 --- a/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php +++ b/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php @@ -107,7 +107,7 @@ function testAliasTranslation() { // Languages are cached on many levels, and we need to clear those caches. $this->container->get('language_manager')->reset(); $this->rebuildContainer(); - $languages = language_list(); + $languages = $this->container->get('language_manager')->getLanguages(); // Ensure the node was created. $english_node = node_load($english_node->id(), TRUE); @@ -121,7 +121,7 @@ function testAliasTranslation() { // Confirm that the alias is returned by url(). Languages are cached on // many levels, and we need to clear those caches. $this->container->get('language_manager')->reset(); - $languages = language_list(); + $languages = $this->container->get('language_manager')->getLanguages(); $url = $this->container->get('url_generator')->generateFromPath('node/' . $french_node->id(), array('language' => $languages['fr'])); $this->assertTrue(strpos($url, $edit['path[alias]']), 'URL contains the path alias.'); diff --git a/core/modules/path/path.admin.inc b/core/modules/path/path.admin.inc index 76bc1dc74ac871e2224381bdbf498f5549406f09..d26d236fe9b51b760f9271ab626972697267b6b8 100644 --- a/core/modules/path/path.admin.inc +++ b/core/modules/path/path.admin.inc @@ -161,7 +161,7 @@ function path_admin_form($form, &$form_state, $path = array('source' => '', 'ali // A hidden value unless language.module is enabled. if (\Drupal::moduleHandler()->moduleExists('language')) { - $languages = language_list(); + $languages = \Drupal::languageManager()->getLanguages(); foreach ($languages as $langcode => $language) { $language_options[$langcode] = $language->name; } diff --git a/core/modules/system/entity.api.php b/core/modules/system/entity.api.php index 315d55da3d713f2cdc0dd4bb85a475b6f7fa426f..f5b5af2dfec4975765f1e5a6e1148fae33f63642 100644 --- a/core/modules/system/entity.api.php +++ b/core/modules/system/entity.api.php @@ -356,7 +356,7 @@ function hook_entity_translation_insert(\Drupal\Core\Entity\EntityInterface $tra * The original entity object. */ function hook_entity_translation_delete(\Drupal\Core\Entity\EntityInterface $translation) { - $languages = language_list(); + $languages = \Drupal::languageManager()->getLanguages(); $variables = array( '@language' => $languages[$langcode]->name, '@label' => $entity->label(), diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php index 61c8c87cc1bd4a654b20b6b2fda993bdaf2c2e27..4a054311a2144cd0398519a1bca7928fbf785c97 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php @@ -190,18 +190,18 @@ protected function assertReadWrite($entity_type) { // Access the language field. $this->assertEqual(Language::LANGCODE_NOT_SPECIFIED, $entity->langcode->value, format_string('%entity_type: Language code can be read.', array('%entity_type' => $entity_type))); - $this->assertEqual(language_load(Language::LANGCODE_NOT_SPECIFIED), $entity->langcode->language, format_string('%entity_type: Language object can be read.', array('%entity_type' => $entity_type))); + $this->assertEqual(\Drupal::languageManager()->getLanguage(Language::LANGCODE_NOT_SPECIFIED), $entity->langcode->language, format_string('%entity_type: Language object can be read.', array('%entity_type' => $entity_type))); // Change the language by code. - $entity->langcode->value = language_default()->id; - $this->assertEqual(language_default()->id, $entity->langcode->value, format_string('%entity_type: Language code can be read.', array('%entity_type' => $entity_type))); - $this->assertEqual(language_default(), $entity->langcode->language, format_string('%entity_type: Language object can be read.', array('%entity_type' => $entity_type))); + $entity->langcode->value = \Drupal::languageManager()->getDefaultLanguage()->id; + $this->assertEqual(\Drupal::languageManager()->getDefaultLanguage()->id, $entity->langcode->value, format_string('%entity_type: Language code can be read.', array('%entity_type' => $entity_type))); + $this->assertEqual(\Drupal::languageManager()->getDefaultLanguage(), $entity->langcode->language, format_string('%entity_type: Language object can be read.', array('%entity_type' => $entity_type))); // Revert language by code then try setting it by language object. $entity->langcode->value = Language::LANGCODE_NOT_SPECIFIED; - $entity->langcode->language = language_default(); - $this->assertEqual(language_default()->id, $entity->langcode->value, format_string('%entity_type: Language code can be read.', array('%entity_type' => $entity_type))); - $this->assertEqual(language_default(), $entity->langcode->language, format_string('%entity_type: Language object can be read.', array('%entity_type' => $entity_type))); + $entity->langcode->language = \Drupal::languageManager()->getDefaultLanguage(); + $this->assertEqual(\Drupal::languageManager()->getDefaultLanguage()->id, $entity->langcode->value, format_string('%entity_type: Language code can be read.', array('%entity_type' => $entity_type))); + $this->assertEqual(\Drupal::languageManager()->getDefaultLanguage(), $entity->langcode->language, format_string('%entity_type: Language object can be read.', array('%entity_type' => $entity_type))); // Access the text field and test updating. $this->assertEqual($entity->field_test_text->value, $this->entity_field_text, format_string('%entity_type: Text field can be read.', array('%entity_type' => $entity_type))); @@ -329,7 +329,7 @@ protected function assertSave($entity_type) { $this->assertEqual(1, $entity->id->value, format_string('%entity_type: ID value can be read.', array('%entity_type' => $entity_type))); $this->assertTrue(is_string($entity->uuid->value), format_string('%entity_type: UUID value can be read.', array('%entity_type' => $entity_type))); $this->assertEqual(Language::LANGCODE_NOT_SPECIFIED, $entity->langcode->value, format_string('%entity_type: Language code can be read.', array('%entity_type' => $entity_type))); - $this->assertEqual(language_load(Language::LANGCODE_NOT_SPECIFIED), $entity->langcode->language, format_string('%entity_type: Language object can be read.', array('%entity_type' => $entity_type))); + $this->assertEqual(\Drupal::languageManager()->getLanguage(Language::LANGCODE_NOT_SPECIFIED), $entity->langcode->language, format_string('%entity_type: Language object can be read.', array('%entity_type' => $entity_type))); $this->assertEqual($this->entity_user->id(), $entity->user_id->target_id, format_string('%entity_type: User id can be read.', array('%entity_type' => $entity_type))); $this->assertEqual($this->entity_user->getUsername(), $entity->user_id->entity->name->value, format_string('%entity_type: User name can be read.', array('%entity_type' => $entity_type))); $this->assertEqual($this->entity_field_text, $entity->field_test_text->value, format_string('%entity_type: Text field can be read.', array('%entity_type' => $entity_type))); diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php index 7b72ee5af248fd3170b8b103e9d3b5d7b15c0878..58ad4c379d197d1fbdde89b2cf1fad6174e6bf62 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php @@ -72,7 +72,7 @@ protected function _testEntityLanguageMethods($entity_type) { $default_langcode = $this->langcodes[0]; $entity->langcode->value = $default_langcode; $entity->{$this->field_name} = array(); - $this->assertEqual($entity->language(), language_load($this->langcodes[0]), format_string('%entity_type: Entity language retrieved.', array('%entity_type' => $entity_type))); + $this->assertEqual($entity->language(), \Drupal::languageManager()->getLanguage($this->langcodes[0]), format_string('%entity_type: Entity language retrieved.', array('%entity_type' => $entity_type))); $this->assertFalse($entity->getTranslationLanguages(FALSE), format_string('%entity_type: No translations are available', array('%entity_type' => $entity_type))); // Set the value in default language. @@ -93,7 +93,7 @@ protected function _testEntityLanguageMethods($entity_type) { $this->assertEqual($field->value, 'default value', 'Untranslated value stays.'); $this->assertEqual($field->getLangcode(), $default_langcode, 'Untranslated value has the expected langcode.'); - $translations[$this->langcodes[1]] = language_load($this->langcodes[1]); + $translations[$this->langcodes[1]] = \Drupal::languageManager()->getLanguage($this->langcodes[1]); $this->assertEqual($entity->getTranslationLanguages(FALSE), $translations, 'Translations retrieved.'); // Try to get a not available translation. diff --git a/core/modules/system/lib/Drupal/system/Tests/Form/LanguageSelectElementTest.php b/core/modules/system/lib/Drupal/system/Tests/Form/LanguageSelectElementTest.php index 0acd6b2bf00b442e4478ff205c07a83cb97d35a3..021419a7603ef7b02a8d0b0d0af91a89ec448327 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Form/LanguageSelectElementTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Form/LanguageSelectElementTest.php @@ -59,7 +59,7 @@ function testLanguageSelectElementOptions() { foreach ($ids as $id => $flags) { $this->assertField($id, format_string('The @id field was found on the page.', array('@id' => $id))); $options = array(); - foreach (language_list($flags) as $langcode => $language) { + foreach ($this->container->get('language_manager')->getLanguages($flags) as $langcode => $language) { $options[$langcode] = $language->locked ? t('- @name -', array('@name' => $language->name)) : $language->name; } $this->_testLanguageSelectElementOptions($id, $options); diff --git a/core/modules/system/lib/Drupal/system/Tests/Theme/TwigTransTest.php b/core/modules/system/lib/Drupal/system/Tests/Theme/TwigTransTest.php index 0aa1f1f9bf80e3226e8eebd6c6db86861a8015bf..47d4557bf7c69f7028a4c68ae427ae354979311e 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Theme/TwigTransTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Theme/TwigTransTest.php @@ -86,14 +86,14 @@ protected function setUp() { $this->rebuildContainer(); // Check that lolspeak is the default language for the site. - $this->assertEqual(language_default()->id, 'xx', 'Lolspeak is the default language'); + $this->assertEqual(\Drupal::languageManager()->getDefaultLanguage()->id, 'xx', 'Lolspeak is the default language'); } /** * Test Twig "trans" tags. */ public function testTwigTransTags() { - $this->drupalGet('twig-theme-test/trans', array('language' => language_load('xx'))); + $this->drupalGet('twig-theme-test/trans', array('language' => \Drupal::languageManager()->getLanguage('xx'))); $this->assertText( 'OH HAI SUNZ', @@ -182,7 +182,7 @@ public function testTwigTransDebug() { $this->writeSettings($settings); // Get page for assertion testing. - $this->drupalGet('twig-theme-test/trans', array('language' => language_load('xx'))); + $this->drupalGet('twig-theme-test/trans', array('language' => \Drupal::languageManager()->getLanguage('xx'))); // Ensure debug output is printed. $this->checkForDebugMarkup(TRUE); diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermLanguageTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermLanguageTest.php index 8287b99d356c74b2f1ecf2b2497f2b65dbe46b46..256a0a054701a4ccbdc76497dbca3a08fdc4a415 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermLanguageTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermLanguageTest.php @@ -102,10 +102,10 @@ function testDefaultTermLanguage() { // Change the default language of the site and check if the default terms // language is still correctly selected. - $old_default = language_default(); + $old_default = \Drupal::languageManager()->getDefaultLanguage(); $old_default->default = FALSE; language_save($old_default); - $new_default = language_load('cc'); + $new_default = \Drupal::languageManager()->getLanguage('cc'); $new_default->default = TRUE; language_save($new_default); $edit = array( diff --git a/core/modules/update/update.fetch.inc b/core/modules/update/update.fetch.inc index 55ef13dcc8aafd4eb52ab5c0058cca3ca06d0293..d4568012c75fa618ce72cb6eb30608bab675e4d5 100644 --- a/core/modules/update/update.fetch.inc +++ b/core/modules/update/update.fetch.inc @@ -110,7 +110,7 @@ function _update_cron_notify() { if (!empty($params)) { $notify_list = $update_config->get('notification.emails'); if (!empty($notify_list)) { - $default_langcode = language_default()->id; + $default_langcode = \Drupal::languageManager()->getDefaultLanguage()->id; foreach ($notify_list as $target) { if ($target_user = user_load_by_mail($target)) { $target_langcode = $target_user->getPreferredLangcode(); diff --git a/core/modules/update/update.module b/core/modules/update/update.module index 6297ff40742ac5ecd551e9d7ecc046ef2829eee2..db3b8931144311a79db05f61fd36533c4d8bb67c 100644 --- a/core/modules/update/update.module +++ b/core/modules/update/update.module @@ -426,7 +426,7 @@ function update_fetch_data_finished($success, $results) { */ function update_mail($key, &$message, $params) { $langcode = $message['langcode']; - $language = language_load($langcode); + $language = \Drupal::languageManager()->getLanguage($langcode); $message['subject'] .= t('New release(s) available for !site_name', array('!site_name' => \Drupal::config('system.site')->get('name')), array('langcode' => $langcode)); foreach ($params as $msg_type => $msg_reason) { $message['body'][] = _update_message_text($msg_type, $msg_reason, FALSE, $langcode); @@ -517,7 +517,7 @@ function _update_message_text($msg_type, $msg_reason, $report_link = FALSE, $lan break; } if (!empty($langcode)) { - $language = language_load($langcode); + $language = \Drupal::languageManager()->getLanguage($langcode); } else { $language = NULL; diff --git a/core/modules/user/lib/Drupal/user/Tests/UserInstallTest.php b/core/modules/user/lib/Drupal/user/Tests/UserInstallTest.php index 3c86a305fb4b9e279cf1fc5592b98a9642ad23f3..4e54ff85bdc386cbf437075356c10db09a78f34b 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserInstallTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserInstallTest.php @@ -51,8 +51,8 @@ public function testUserInstall() { $this->assertFalse(empty($anon->uuid), 'Anon user has a UUID'); $this->assertFalse(empty($admin->uuid), 'Admin user has a UUID'); - $this->assertEqual($anon->langcode, language_default()->id, 'Anon user language is the default.'); - $this->assertEqual($admin->langcode, language_default()->id, 'Admin user language is the default.'); + $this->assertEqual($anon->langcode, \Drupal::languageManager()->getDefaultLanguage()->id, 'Anon user language is the default.'); + $this->assertEqual($admin->langcode, \Drupal::languageManager()->getDefaultLanguage()->id, 'Admin user language is the default.'); $this->assertEqual($admin->status, 1, 'Admin user is active.'); $this->assertEqual($anon->status, 0, 'Anon user is blocked.'); diff --git a/core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php b/core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php index ee84db2b4c0433d13005ccb2d56724d88ace8de3..15e75bf6e260779ca75c9b900fba4fa31ec94dea 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php @@ -186,8 +186,8 @@ function testRegistrationDefaultValues() { $this->assertTrue(($new_user->getCreatedTime() > REQUEST_TIME - 20 ), 'Correct creation time.'); $this->assertEqual($new_user->isActive(), $config_user_settings->get('register') == USER_REGISTER_VISITORS ? 1 : 0, 'Correct status field.'); $this->assertEqual($new_user->getTimezone(), $config_system_date->get('timezone.default'), 'Correct time zone field.'); - $this->assertEqual($new_user->langcode->value, language_default()->id, 'Correct language field.'); - $this->assertEqual($new_user->preferred_langcode->value, language_default()->id, 'Correct preferred language field.'); + $this->assertEqual($new_user->langcode->value, \Drupal::languageManager()->getDefaultLanguage()->id, 'Correct language field.'); + $this->assertEqual($new_user->preferred_langcode->value, \Drupal::languageManager()->getDefaultLanguage()->id, 'Correct preferred language field.'); $this->assertEqual($new_user->init->value, $mail, 'Correct init field.'); } diff --git a/core/modules/user/lib/Drupal/user/Tests/UserRoleAdminTest.php b/core/modules/user/lib/Drupal/user/Tests/UserRoleAdminTest.php index 2658b1a94fe21343d0cf0125a8cf6df1d9b16fb2..5052571545f3c7bbf8924334c793c56bebdfcfbf 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserRoleAdminTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserRoleAdminTest.php @@ -32,7 +32,7 @@ function setUp() { */ function testRoleAdministration() { $this->drupalLogin($this->admin_user); - $default_langcode = language_default()->id; + $default_langcode = \Drupal::languageManager()->getDefaultLanguage()->id; // Test presence of tab. $this->drupalGet('admin/people/permissions'); $tabs = $this->xpath('//ul[@class=:classes and //a[contains(., :text)]]', array( diff --git a/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php b/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php index 991ac35e7e10d26be26ec0be80ec99e15370c2d6..c9be29ca19bfc03238a8d2d6eead8d3e16b8c190 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php @@ -105,14 +105,14 @@ function testUserTokenReplacement() { // Generate tokens with the user's preferred language. $account->preferred_langcode = 'de'; $account->save(); - $link = url('user', array('language' => language_load($account->getPreferredLangcode()), 'absolute' => TRUE)); + $link = url('user', array('language' => \Drupal::languageManager()->getLanguage($account->getPreferredLangcode()), 'absolute' => TRUE)); foreach ($tests as $input => $expected) { $output = $token_service->replace($input, array('user' => $account), array('callback' => 'user_mail_tokens', 'sanitize' => FALSE, 'clear' => TRUE)); $this->assertTrue(strpos($output, $link) === 0, "Generated URL is in the user's preferred language."); } // Generate tokens with one specific language. - $link = url('user', array('language' => language_load('de'), 'absolute' => TRUE)); + $link = url('user', array('language' => \Drupal::languageManager()->getLanguage('de'), 'absolute' => TRUE)); foreach ($tests as $input => $expected) { foreach (array($user1, $user2) as $account) { $output = $token_service->replace($input, array('user' => $account), array('langcode' => 'de', 'callback' => 'user_mail_tokens', 'sanitize' => FALSE, 'clear' => TRUE)); diff --git a/core/modules/user/user.install b/core/modules/user/user.install index c21e2959b13e0a3b667791385e6f38cfe86ca222..97515a251fce1e1a7040f3450a919622f5f4c014 100644 --- a/core/modules/user/user.install +++ b/core/modules/user/user.install @@ -227,7 +227,7 @@ function user_install() { 'uuid' => \Drupal::service('uuid')->generate(), 'name' => '', 'mail' => '', - 'langcode' => language_default()->id, + 'langcode' => \Drupal::languageManager()->getDefaultLanguage()->id, )) ->execute(); @@ -241,7 +241,7 @@ function user_install() { 'mail' => 'placeholder-for-uid-1', 'created' => REQUEST_TIME, 'status' => 1, - 'langcode' => language_default()->id, + 'langcode' => \Drupal::languageManager()->getDefaultLanguage()->id, )) ->execute(); } diff --git a/core/modules/user/user.module b/core/modules/user/user.module index 0ed9aa1d37ec323569ad06dd75a0dbafed2f6fee..9d3514d0e798b2e7d320bf3a73c32aeb5310dc6a 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -812,7 +812,7 @@ function user_user_logout($account) { function user_pass_reset_url($account, $options = array()) { $timestamp = REQUEST_TIME; $langcode = isset($options['langcode']) ? $options['langcode'] : $account->getPreferredLangcode(); - $url_options = array('absolute' => TRUE, 'language' => language_load($langcode)); + $url_options = array('absolute' => TRUE, 'language' => \Drupal::languageManager()->getLanguage($langcode)); return url("user/reset/" . $account->id() . "/$timestamp/" . user_pass_rehash($account->getPassword(), $timestamp, $account->getLastLoginTime()), $url_options); } @@ -840,7 +840,7 @@ function user_pass_reset_url($account, $options = array()) { function user_cancel_url($account, $options = array()) { $timestamp = REQUEST_TIME; $langcode = isset($options['langcode']) ? $options['langcode'] : $account->getPreferredLangcode(); - $url_options = array('absolute' => TRUE, 'language' => language_load($langcode)); + $url_options = array('absolute' => TRUE, 'language' => \Drupal::languageManager()->getLanguage($langcode)); return url("user/" . $account->id() . "/cancel/confirm/$timestamp/" . user_pass_rehash($account->getPassword(), $timestamp, $account->getLastLoginTime()), $url_options); } @@ -1124,7 +1124,7 @@ function user_mail($key, &$message, $params) { $langcode = $message['langcode']; $variables = array('user' => $params['account']); - $language = language_load($params['account']->getPreferredLangcode()); + $language = \Drupal::languageManager()->getLanguage($params['account']->getPreferredLangcode()); $original_language = $language_manager->getConfigOverrideLanguage(); $language_manager->setConfigOverrideLanguage($language); $mail_config = \Drupal::config('user.mail'); @@ -1472,7 +1472,7 @@ function _user_mail_notify($op, $account, $langcode = NULL) { if ($op == 'register_pending_approval') { // If a user registered requiring admin approval, notify the admin, too. // We use the site default language for this. - drupal_mail('user', 'register_pending_approval_admin', $site_mail, language_default()->id, $params); + drupal_mail('user', 'register_pending_approval_admin', $site_mail, \Drupal::languageManager()->getDefaultLanguage()->id, $params); } } return empty($mail) ? NULL : $mail['result']; diff --git a/core/modules/user/user.tokens.inc b/core/modules/user/user.tokens.inc index e3c22f2b2b177940981221c6a4e7f176643c4ba3..80c8bbdcca5f33e9390fe0f53b61cbee9964cf55 100644 --- a/core/modules/user/user.tokens.inc +++ b/core/modules/user/user.tokens.inc @@ -66,7 +66,7 @@ function user_tokens($type, $tokens, array $data = array(), array $options = arr $token_service = \Drupal::token(); $url_options = array('absolute' => TRUE); if (isset($options['langcode'])) { - $url_options['language'] = language_load($options['langcode']); + $url_options['language'] = \Drupal::languageManager()->getLanguage($options['langcode']); $langcode = $options['langcode']; } else { diff --git a/core/modules/views/views.api.php b/core/modules/views/views.api.php index f2d2a1e31ac597e85f4e2a9da33c9b29f864ea26..f1551e233c3abc0e40d4d5a1a67870e9ab7fd761 100644 --- a/core/modules/views/views.api.php +++ b/core/modules/views/views.api.php @@ -342,7 +342,7 @@ function hook_views_query_substitutions(ViewExecutable $view) { '***CURRENT_VERSION***' => \Drupal::VERSION, '***CURRENT_TIME***' => REQUEST_TIME, '***CURRENT_LANGUAGE***' => \Drupal::languageManager()->getCurrentLanguage(\Drupal\Core\Language\Language::TYPE_CONTENT)->id, - '***DEFAULT_LANGUAGE***' => language_default()->id, + '***DEFAULT_LANGUAGE***' => \Drupal::languageManager()->getDefaultLanguage()->id, ); } diff --git a/core/modules/views/views.module b/core/modules/views/views.module index 5c2c166af2438de6e4be386dde14b70ea738d52a..806ba9de0a6516ca1abed8ee625bb5b28516c6bd 100644 --- a/core/modules/views/views.module +++ b/core/modules/views/views.module @@ -497,7 +497,8 @@ function views_add_contextual_links(&$render_element, $location, ViewExecutable /** * Prepares a list of language names. * - * This is a wrapper around language_list to return a plain key value array. + * This is a wrapper around \Drupal::languageManager()->getLanguages() to return + * a plain key value array. * * @param string $field * The field of the language object which should be used as the value of the @@ -513,7 +514,7 @@ function views_add_contextual_links(&$render_element, $location, ViewExecutable * @see locale_language_list() */ function views_language_list($field = 'name', $flags = Language::STATE_ALL) { - $languages = language_list($flags); + $languages = \Drupal::languageManager()->getLanguages($flags); $list = array(); foreach ($languages as $language) { $list[$language->id] = ($field == 'name') ? t($language->name) : $language->$field; diff --git a/core/modules/views/views.views_execution.inc b/core/modules/views/views.views_execution.inc index 18039befd34604a6d21d063211a5c97881853001..d1c040fa7a336f3f541a006bfb046f252f0bbd4b 100644 --- a/core/modules/views/views.views_execution.inc +++ b/core/modules/views/views.views_execution.inc @@ -18,6 +18,6 @@ function views_views_query_substitutions(ViewExecutable $view) { '***CURRENT_VERSION***' => \Drupal::VERSION, '***CURRENT_TIME***' => REQUEST_TIME, '***CURRENT_LANGUAGE***' => \Drupal::languageManager()->getCurrentLanguage(Language::TYPE_CONTENT)->id, - '***DEFAULT_LANGUAGE***' => language_default()->id, + '***DEFAULT_LANGUAGE***' => \Drupal::languageManager()->getDefaultLanguage()->id, ); }