diff --git a/core/includes/update.inc b/core/includes/update.inc index 0bca244..9aa35bf 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 82cb852..7f6ca8e 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 e63fb2b..c7dff39 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 56444a9..139bf73 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 ce52ee2..5e5b4de 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 19ebaff..8ec6146 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityTest.php @@ -36,7 +36,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 51f9182..4a38a4d 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 b01ddab..8e99296 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 126fc75..7442166 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 8ea5d1c..cfa8cc2 100644 --- a/core/modules/content_translation/content_translation.admin.inc +++ b/core/modules/content_translation/content_translation.admin.inc @@ -276,7 +276,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 e474d69..2d4963e 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 enable at least two languages 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 95cd875..1d5f5c2 100644 --- a/core/modules/content_translation/content_translation.module +++ b/core/modules/content_translation/content_translation.module @@ -316,7 +316,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'); } @@ -332,7 +332,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'); } @@ -348,7 +348,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'); } @@ -890,7 +890,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 ac36ff7..4a783bd 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 09afe8c..9a34bd4 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 861aec9..43e5d77 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 02630bb..89af9c9 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 d8d9f9c..ba00c74 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 8320336..203124d 100644 --- a/core/modules/filter/lib/Drupal/filter/Tests/FilterCrudTest.php +++ b/core/modules/filter/lib/Drupal/filter/Tests/FilterCrudTest.php @@ -83,7 +83,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 d7f8dd0..688bee6 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 c9bbcff..1e4e9bd 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 b506136..c44684d 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 c616837..c97957e 100644 --- a/core/modules/language/language.module +++ b/core/modules/language/language.module @@ -183,7 +183,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; } } @@ -225,12 +225,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; } @@ -405,7 +405,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': @@ -484,7 +484,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 @@ -506,7 +507,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]; @@ -580,7 +581,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])) { @@ -708,8 +709,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; } @@ -731,7 +732,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 a9cec74..fb8bfff 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 adab4ca..0a507f2 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 f734210..067c477 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 d4192b6..17e433e 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 a475c04..273850b 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 863a41d..73e5b85 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 89832f3..169bfcf 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 09cb363..39ad3f8 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 42f2b0f..e1fd47e 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 781af06..dd6aff8 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; @@ -25,20 +26,28 @@ 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 59993f0..865023e 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 2e29d98..6554886 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 5f72ad8..4f06164 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 68a4d1d..333fedf 100644 --- a/core/modules/locale/locale.module +++ b/core/modules/locale/locale.module @@ -292,7 +292,7 @@ function locale_language_delete($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']); } @@ -1275,7 +1275,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 7ed9f14..4b56eb7 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php @@ -112,7 +112,7 @@ protected function getFormSubmitAction(EntityInterface $entity) { 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( array(t('Save and publish'), t('Save and keep published')), @@ -144,7 +144,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 authoring information for each translation. @@ -272,7 +272,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 dbf668c..e06da3f 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 0653743..cc47e2d 100644 --- a/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php +++ b/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php @@ -106,7 +106,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); @@ -120,7 +120,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 d22fe66..fa5d705 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 c6cb1d9..08b6b72 100644 --- a/core/modules/system/entity.api.php +++ b/core/modules/system/entity.api.php @@ -355,7 +355,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 5dcfd38..23201e0 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))); @@ -333,7 +333,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 d3b5842..f683d30 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 0acd6b2..021419a 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 0aa1f1f..47d4557 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 c74efbe..4774068 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 55ef13d..d456801 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 2097a76..859d6b1 100644 --- a/core/modules/update/update.module +++ b/core/modules/update/update.module @@ -441,7 +441,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); @@ -532,7 +532,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 3c86a30..4e54ff8 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 7aae5e5..673568f 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 2658b1a..5052571 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 991ac35..c9be29c 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 c21e295..97515a2 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 6330fcb..90c7690 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -861,7 +861,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); } @@ -889,7 +889,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); } @@ -1173,7 +1173,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'); @@ -1521,7 +1521,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 e3c22f2..80c8bbd 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 f2d2a1e..f1551e2 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 922a8d9..be6edbb 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 18039be..d1c040f 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, ); }