Commit be83ed2b authored by webchick's avatar webchick
Browse files

Issue #2166915 by ianthomas_uk, sun | plach: Remove uses of deprecated...

Issue #2166915 by ianthomas_uk, sun | plach: Remove uses of deprecated language functions in tests and procedural code.
parent 7a91c2e8
......@@ -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;
......
......@@ -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);
}
......
......@@ -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',
......
......@@ -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();
......
......@@ -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();
......
......@@ -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);
......
......@@ -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' => '',
);
......
......@@ -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' => '',
);
......
......@@ -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.
......
......@@ -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))));
......
......@@ -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');
......
......@@ -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
......
......@@ -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');
......
......@@ -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);
}
/**
......
......@@ -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);
......
......@@ -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());
......
......@@ -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.
......
......@@ -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);
......
......@@ -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();
......
......@@ -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',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment