diff --cc core/includes/form.inc index 838a156,8cef7b0..0000000 --- a/core/includes/form.inc +++ b/core/includes/form.inc diff --cc core/lib/Drupal/Core/Entity/EntityManager.php index 26eac4e,83a0284..0000000 --- a/core/lib/Drupal/Core/Entity/EntityManager.php +++ b/core/lib/Drupal/Core/Entity/EntityManager.php @@@ -832,8 -839,7 +832,8 @@@ class EntityManager extends DefaultPlug protected function getAllDisplayModesByEntityType($display_type) { if (!isset($this->displayModeInfo[$display_type])) { $key = 'entity_' . $display_type . '_info'; + $entity_type_id = 'entity_' . $display_type; - $langcode = $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_INTERFACE)->id; + $langcode = $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_INTERFACE)->getId(); if ($cache = $this->cacheBackend->get("$key:$langcode")) { $this->displayModeInfo[$display_type] = $cache->data; } diff --cc core/lib/Drupal/Core/Language/LanguageManager.php index d86789e,fe2cc58..0000000 --- a/core/lib/Drupal/Core/Language/LanguageManager.php +++ b/core/lib/Drupal/Core/Language/LanguageManager.php @@@ -145,10 -120,8 +145,10 @@@ class LanguageManager implements Langua // Add the site's default language if flagged as allowed value. if ($flags & LanguageInterface::STATE_SITE_DEFAULT) { $default = isset($default) ? $default : $this->getDefaultLanguage(); - // Rename the default language. - $default->setName($this->t("Site's default language (@lang_name)", array('@lang_name' => $default->getName()))); + // Rename the default language. But we do not want to do this globally, + // if we're acting on a global object, so clone the object first. + $default = clone $default; - $default->name = $this->t("Site's default language (@lang_name)", array('@lang_name' => $default->name)); ++ $default->name = $this->t("Site's default language (@lang_name)", array('@lang_name' => $default->getName())); $filtered_languages['site_default'] = $default; } diff --cc core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php index 22bcaaf,a5eb69a..0000000 --- a/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php +++ b/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php @@@ -325,7 -325,7 +325,7 @@@ class ConfigTranslationUiTest extends W // Test that delete links work and operations perform properly. foreach ($this->langcodes as $langcode) { - $replacements = array('%label' => t('!label !entity_type', array('!label' => $label, '!entity_type' => Unicode::strtolower(t('Contact form')))), '@language' => language_load($langcode)->name); - $replacements = array('%label' => t('!label !entity_type', array('!label' => $label, '!entity_type' => Unicode::strtolower(t('Contact category')))), '@language' => language_load($langcode)->getName()); ++ $replacements = array('%label' => t('!label !entity_type', array('!label' => $label, '!entity_type' => Unicode::strtolower(t('Contact form')))), '@language' => language_load($langcode)->getName()); $this->drupalGet("$translation_base_url/$langcode/delete"); $this->assertRaw(t('Are you sure you want to delete the @language translation of %label?', $replacements)); diff --cc core/modules/contact/src/Tests/ContactSitewideTest.php index 436b2bf,e16cc87..0000000 --- a/core/modules/contact/src/Tests/ContactSitewideTest.php +++ b/core/modules/contact/src/Tests/ContactSitewideTest.php @@@ -107,26 -107,26 +107,26 @@@ class ContactSitewideTest extends WebTe $recipients = array('simpletest@example.com', 'simpletest2@example.com', 'simpletest3@example.com'); $max_length = EntityTypeInterface::BUNDLE_MAX_LENGTH; $max_length_exceeded = $max_length + 1; - $this->addCategory($id = drupal_strtolower($this->randomMachineName($max_length_exceeded)), $label = $this->randomMachineName($max_length_exceeded), implode(',', array($recipients[0])), '', TRUE); + $this->addContactForm($id = drupal_strtolower($this->randomMachineName($max_length_exceeded)), $label = $this->randomMachineName($max_length_exceeded), implode(',', array($recipients[0])), '', TRUE); $this->assertText(format_string('Machine-readable name cannot be longer than !max characters but is currently !exceeded characters long.', array('!max' => $max_length, '!exceeded' => $max_length_exceeded))); - $this->addCategory($id = drupal_strtolower($this->randomMachineName($max_length)), $label = $this->randomMachineName($max_length), implode(',', array($recipients[0])), '', TRUE); - $this->assertRaw(t('Category %label has been added.', array('%label' => $label))); + $this->addContactForm($id = drupal_strtolower($this->randomMachineName($max_length)), $label = $this->randomMachineName($max_length), implode(',', array($recipients[0])), '', TRUE); + $this->assertRaw(t('Contact form %label has been added.', array('%label' => $label))); - // Create first valid category. - $this->addCategory($id = drupal_strtolower($this->randomMachineName(16)), $label = $this->randomMachineName(16), implode(',', array($recipients[0])), '', TRUE); - $this->assertRaw(t('Category %label has been added.', array('%label' => $label))); + // Create first valid form. + $this->addContactForm($id = drupal_strtolower($this->randomMachineName(16)), $label = $this->randomMachineName(16), implode(',', array($recipients[0])), '', TRUE); + $this->assertRaw(t('Contact form %label has been added.', array('%label' => $label))); - // Check that the category was created in site default language. - $langcode = \Drupal::config('contact.category.' . $id)->get('langcode'); + // Check that the form was created in site default language. + $langcode = \Drupal::config('contact.form.' . $id)->get('langcode'); - $default_langcode = \Drupal::languageManager()->getDefaultLanguage()->id; + $default_langcode = \Drupal::languageManager()->getDefaultLanguage()->getId(); $this->assertEqual($langcode, $default_langcode); - // Make sure the newly created category is included in the list of categories. - $this->assertNoUniqueText($label, 'New category included in categories list.'); + // Make sure the newly created form is included in the list of forms. + $this->assertNoUniqueText($label, 'New form included in forms list.'); - // Test update contact form category. - $this->updateCategory($id, $label = $this->randomMachineName(16), $recipients_str = implode(',', array($recipients[0], $recipients[1])), $reply = $this->randomMachineName(30), FALSE); - $config = \Drupal::config('contact.category.' . $id)->get(); + // Test update contact form. + $this->updateContactForm($id, $label = $this->randomMachineName(16), $recipients_str = implode(',', array($recipients[0], $recipients[1])), $reply = $this->randomMachineName(30), FALSE); + $config = \Drupal::config('contact.form.' . $id)->get(); $this->assertEqual($config['label'], $label); $this->assertEqual($config['recipients'], array($recipients[0], $recipients[1])); $this->assertEqual($config['reply'], $reply); diff --cc core/modules/content_translation/src/Access/ContentTranslationManageAccessCheck.php index 5f12452,c6a4afa..0000000 --- a/core/modules/content_translation/src/Access/ContentTranslationManageAccessCheck.php +++ b/core/modules/content_translation/src/Access/ContentTranslationManageAccessCheck.php diff --cc core/modules/content_translation/src/ContentTranslationHandler.php index 60eb6f3,0af6d08..0000000 --- a/core/modules/content_translation/src/ContentTranslationHandler.php +++ b/core/modules/content_translation/src/ContentTranslationHandler.php @@@ -84,9 -84,9 +84,9 @@@ class ContentTranslationHandler impleme * {@inheritdoc} */ public function entityFormAlter(array &$form, FormStateInterface $form_state, EntityInterface $entity) { - $form_controller = content_translation_form_controller($form_state); - $form_langcode = $form_controller->getFormLangcode($form_state); + $form_object = $form_state->getFormObject(); + $form_langcode = $form_object->getFormLangcode($form_state); - $entity_langcode = $entity->getUntranslated()->language()->id; + $entity_langcode = $entity->getUntranslated()->language()->getId(); $source_langcode = $this->getSourceLangcode($form_state); $new_translation = !empty($source_langcode); @@@ -443,10 -439,10 +443,10 @@@ $form_state->setRedirect('content_translation.translation_add_' . $entity_type_id, array( $entity_type_id => $entity->id(), 'source' => $source, - 'target' => $form_controller->getFormLangcode($form_state), + 'target' => $form_object->getFormLangcode($form_state), )); $languages = language_list(); - drupal_set_message(t('Source language set to: %language', array('%language' => $languages[$source]->name))); + drupal_set_message(t('Source language set to: %language', array('%language' => $languages[$source]->getName()))); } /** diff --cc core/modules/field/src/Plugin/views/field/Field.php index 0bd93b2,c2a6a79..0000000 --- a/core/modules/field/src/Plugin/views/field/Field.php +++ b/core/modules/field/src/Plugin/views/field/Field.php diff --cc core/modules/language/src/Form/NegotiationUrlForm.php index e2e241e,7ed9979..0000000 --- a/core/modules/language/src/Form/NegotiationUrlForm.php +++ b/core/modules/language/src/Form/NegotiationUrlForm.php @@@ -73,17 -73,17 +73,17 @@@ class NegotiationUrlForm extends Config $prefixes = language_negotiation_url_prefixes(); $domains = language_negotiation_url_domains(); foreach ($languages as $langcode => $language) { - $t_args = array('%language' => $language->name, '%langcode' => $language->id); + $t_args = array('%language' => $language->getName(), '%langcode' => $language->getId()); $form['prefix'][$langcode] = array( '#type' => 'textfield', - '#title' => $language->default ? $this->t('%language (%langcode) path prefix (Default language)', $t_args) : $this->t('%language (%langcode) path prefix', $t_args), - '#title' => $language->isDefault() ? t('%language (%langcode) path prefix (Default language)', $t_args) : t('%language (%langcode) path prefix', $t_args), ++ '#title' => $language->isDefault() ? $this->t('%language (%langcode) path prefix (Default language)', $t_args) : $this->t('%language (%langcode) path prefix', $t_args), '#maxlength' => 64, '#default_value' => isset($prefixes[$langcode]) ? $prefixes[$langcode] : '', '#field_prefix' => $base_url . '/', ); $form['domain'][$langcode] = array( '#type' => 'textfield', - '#title' => $this->t('%language (%langcode) domain', array('%language' => $language->name, '%langcode' => $language->id)), - '#title' => t('%language (%langcode) domain', array('%language' => $language->getName(), '%langcode' => $language->getId())), ++ '#title' => $this->t('%language (%langcode) domain', array('%language' => $language->getName(), '%langcode' => $language->getId())), '#maxlength' => 128, '#default_value' => isset($domains[$langcode]) ? $domains[$langcode] : '', ); @@@ -106,10 -106,10 +106,10 @@@ $value = $form_state->getValue(array('prefix', $langcode)); if ($value === '') { - if (!$language->default && $form_state->getValue('language_negotiation_url_part') == LanguageNegotiationUrl::CONFIG_PATH_PREFIX) { + if (!$language->isDefault() && $form_state->getValue('language_negotiation_url_part') == LanguageNegotiationUrl::CONFIG_PATH_PREFIX) { // Throw a form error if the prefix is blank for a non-default language, // although it is required for selected negotiation type. - $form_state->setErrorByName("prefix][$langcode", t('The prefix may only be left blank for the default language.')); + $form_state->setErrorByName("prefix][$langcode", $this->t('The prefix may only be left blank for the default language.')); } } elseif (strpos($value, '/') !== FALSE) { @@@ -120,7 -120,7 +120,7 @@@ elseif (isset($count[$value]) && $count[$value] > 1) { // Throw a form error if there are two languages with the same // domain/prefix. - $form_state->setErrorByName("prefix][$langcode", $this->t('The prefix for %language, %value, is not unique.', array('%language' => $language->name, '%value' => $value))); - $form_state->setErrorByName("prefix][$langcode", t('The prefix for %language, %value, is not unique.', array('%language' => $language->getName(), '%value' => $value))); ++ $form_state->setErrorByName("prefix][$langcode", $this->t('The prefix for %language, %value, is not unique.', array('%language' => $language->getName(), '%value' => $value))); } } @@@ -130,16 -130,16 +130,16 @@@ $value = $form_state->getValue(array('domain', $langcode)); if ($value === '') { - if (!$language->default && $form_state->getValue('language_negotiation_url_part') == LanguageNegotiationUrl::CONFIG_DOMAIN) { + if (!$language->isDefault() && $form_state->getValue('language_negotiation_url_part') == LanguageNegotiationUrl::CONFIG_DOMAIN) { // Throw a form error if the domain is blank for a non-default language, // although it is required for selected negotiation type. - $form_state->setErrorByName("domain][$langcode", t('The domain may only be left blank for the default language.')); + $form_state->setErrorByName("domain][$langcode", $this->t('The domain may only be left blank for the default language.')); } } elseif (isset($count[$value]) && $count[$value] > 1) { // Throw a form error if there are two languages with the same // domain/domain. - $form_state->setErrorByName("domain][$langcode", $this->t('The domain for %language, %value, is not unique.', array('%language' => $language->name, '%value' => $value))); - $form_state->setErrorByName("domain][$langcode", t('The domain for %language, %value, is not unique.', array('%language' => $language->getName(), '%value' => $value))); ++ $form_state->setErrorByName("domain][$langcode", $this->t('The domain for %language, %value, is not unique.', array('%language' => $language->getName(), '%value' => $value))); } } diff --cc core/modules/migrate_drupal/src/Tests/d6/MigrateAggregatorFeedTest.php index 66bc81f,c444c99..0000000 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateAggregatorFeedTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateAggregatorFeedTest.php @@@ -42,7 -43,7 +42,7 @@@ class MigrateAggregatorFeedTest extend $feed = entity_load('aggregator_feed', 5); $this->assertNotNull($feed->uuid()); $this->assertEqual($feed->title->value, 'Know Your Meme'); - $this->assertEqual($feed->language()->id, 'en'); - $this->assertEqual($feed->language()->getId(), LanguageInterface::LANGCODE_NOT_SPECIFIED); ++ $this->assertEqual($feed->language()->getId(), 'en'); $this->assertEqual($feed->url->value, 'http://knowyourmeme.com/newsfeed.rss'); $this->assertEqual($feed->refresh->value, 900); $this->assertEqual($feed->checked->value, 1387659487); diff --cc core/modules/migrate_drupal/src/Tests/d6/MigrateAggregatorItemTest.php index b2c200a,6e7ca97..0000000 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateAggregatorItemTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateAggregatorItemTest.php @@@ -67,7 -67,7 +67,7 @@@ class MigrateAggregatorItemTest extend $this->assertEqual($item->getDescription(), "

What's new with Drupal 8?

"); $this->assertEqual($item->getLink(), 'https://groups.drupal.org/node/395218'); $this->assertEqual($item->getPostedTime(), 1389297196); - $this->assertEqual($item->language()->id, 'en'); - $this->assertEqual($item->language()->getId(), LanguageInterface::LANGCODE_NOT_SPECIFIED); ++ $this->assertEqual($item->language()->getId(), 'en'); $this->assertEqual($item->getGuid(), '395218 at https://groups.drupal.org'); } diff --cc core/modules/migrate_drupal/src/Tests/d6/MigrateBlockContentTest.php index 0835650,67cf734..0000000 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateBlockContentTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateBlockContentTest.php @@@ -51,7 -51,7 +51,7 @@@ class MigrateBlockContentTest extends M $this->assertEqual('My block 1', $block->label()); $this->assertEqual(1, $block->getRevisionId()); $this->assertTrue(REQUEST_TIME <= $block->getChangedTime() && $block->getChangedTime() <= time()); - $this->assertEqual('en', $block->language()->id); - $this->assertEqual(LanguageInterface::LANGCODE_NOT_SPECIFIED, $block->language()->getId()); ++ $this->assertEqual('en', $block->language()->getId()); $this->assertEqual('

My first custom block body

', $block->body->value); $this->assertEqual('full_html', $block->body->format); @@@ -59,7 -59,7 +59,7 @@@ $this->assertEqual('My block 2', $block->label()); $this->assertEqual(2, $block->getRevisionId()); $this->assertTrue(REQUEST_TIME <= $block->getChangedTime() && $block->getChangedTime() <= time()); - $this->assertEqual('en', $block->language()->id); - $this->assertEqual(LanguageInterface::LANGCODE_NOT_SPECIFIED, $block->language()->getId()); ++ $this->assertEqual('en', $block->language()->getId()); $this->assertEqual('

My second custom block body

', $block->body->value); $this->assertEqual('full_html', $block->body->format); } diff --cc core/modules/migrate_drupal/src/Tests/d6/MigrateCommentTest.php index 77980cd,38faa8a..0000000 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateCommentTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateCommentTest.php @@@ -81,7 -81,7 +81,7 @@@ class MigrateCommentTest extends Migrat $this->assertEqual(0, $comment->pid->target_id); $this->assertEqual(1, $comment->getCommentedEntityId()); $this->assertEqual('node', $comment->getCommentedEntityTypeId()); - $this->assertEqual('en', $comment->language()->id); - $this->assertEqual(LanguageInterface::LANGCODE_NOT_SPECIFIED, $comment->language()->getId()); ++ $this->assertEqual('en', $comment->language()->getId()); $this->assertEqual('comment_no_subject', $comment->getTypeId()); $comment = entity_load('comment', 2); diff --cc core/modules/node/src/Controller/NodeController.php index 3382c0b,c96da1f..0000000 --- a/core/modules/node/src/Controller/NodeController.php +++ b/core/modules/node/src/Controller/NodeController.php diff --cc core/modules/system/src/Tests/Entity/EntityTranslationTest.php index 1cb7c82,d487198..0000000 --- a/core/modules/system/src/Tests/Entity/EntityTranslationTest.php +++ b/core/modules/system/src/Tests/Entity/EntityTranslationTest.php @@@ -38,12 -38,6 +38,12 @@@ class EntityTranslationTest extends Ent 'name' => 'test', 'user_id' => $this->container->get('current_user')->id(), )); - $this->assertEqual($entity->language()->getId(), $this->languageManager->getDefaultLanguage()->id, format_string('%entity_type: Entity created with API has default language.', array('%entity_type' => $entity_type))); ++ $this->assertEqual($entity->language()->getId(), $this->languageManager->getDefaultLanguage()->getId(), format_string('%entity_type: Entity created with API has default language.', array('%entity_type' => $entity_type))); + $entity = entity_create($entity_type, array( + 'name' => 'test', + 'user_id' => \Drupal::currentUser()->id(), + 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, + )); $this->assertEqual($entity->language()->getId(), LanguageInterface::LANGCODE_NOT_SPECIFIED, format_string('%entity_type: Entity language not specified.', array('%entity_type' => $entity_type))); $this->assertFalse($entity->getTranslationLanguages(FALSE), format_string('%entity_type: No translations are available', array('%entity_type' => $entity_type))); @@@ -149,10 -143,10 +149,10 @@@ // Create a language neutral entity and check that properties are stored // as language neutral. - $entity = entity_create($entity_type, array('name' => $name, 'user_id' => $uid)); + $entity = entity_create($entity_type, array('name' => $name, 'user_id' => $uid, 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED)); $entity->save(); $entity = entity_load($entity_type, $entity->id()); - $default_langcode = $entity->language()->id; + $default_langcode = $entity->language()->getId(); $this->assertEqual($default_langcode, LanguageInterface::LANGCODE_NOT_SPECIFIED, format_string('%entity_type: Entity created as language neutral.', array('%entity_type' => $entity_type))); $field = $entity->getTranslation(LanguageInterface::LANGCODE_DEFAULT)->get('name'); $this->assertEqual($name, $field->value, format_string('%entity_type: The entity name has been correctly stored as language neutral.', array('%entity_type' => $entity_type))); diff --cc core/modules/views/src/Plugin/views/cache/CachePluginBase.php index c8f9429,507ad95..0000000 --- a/core/modules/views/src/Plugin/views/cache/CachePluginBase.php +++ b/core/modules/views/src/Plugin/views/cache/CachePluginBase.php @@@ -327,8 -327,8 +327,8 @@@ abstract class CachePluginBase extends 'result' => $this->view->result, 'roles' => $user->getRoles(), 'super-user' => $user->id() == 1, // special caching for super user. - 'theme' => $GLOBALS['theme'], + 'theme' => \Drupal::theme()->getActiveTheme()->getName(), - 'langcode' => \Drupal::languageManager()->getCurrentLanguage()->id, + 'langcode' => \Drupal::languageManager()->getCurrentLanguage()->getId(), 'base_url' => $GLOBALS['base_url'], ); diff --cc core/modules/views/views.api.php index c7e5133,35ee3eb..0000000 --- a/core/modules/views/views.api.php +++ b/core/modules/views/views.api.php @@@ -577,8 -557,8 +577,8 @@@ function hook_views_query_substitutions return array( '***CURRENT_VERSION***' => \Drupal::VERSION, '***CURRENT_TIME***' => REQUEST_TIME, - '***LANGUAGE_language_content***' => \Drupal::languageManager()->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)->id, - '***LANGUAGE_site_default***' => \Drupal::languageManager()->getDefaultLanguage()->id, - '***CURRENT_LANGUAGE***' => \Drupal::languageManager()->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)->getId(), - '***DEFAULT_LANGUAGE***' => \Drupal::languageManager()->getDefaultLanguage()->getId(), ++ '***LANGUAGE_language_content***' => \Drupal::languageManager()->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)->getId(), ++ '***LANGUAGE_site_default***' => \Drupal::languageManager()->getDefaultLanguage()->getId(), ); } diff --cc core/modules/views/views.module index 5a30bf0,d1fd49f..0000000 --- a/core/modules/views/views.module +++ b/core/modules/views/views.module diff --cc core/modules/views/views.views_execution.inc index 91dead5,1c4f5bc..0000000 --- a/core/modules/views/views.views_execution.inc +++ b/core/modules/views/views.views_execution.inc diff --git a/core/modules/content_translation/src/Controller/ContentTranslationController.php b/core/modules/content_translation/src/Controller/ContentTranslationController.php index 5f2c460..78e30d5 100644 --- a/core/modules/content_translation/src/Controller/ContentTranslationController.php +++ b/core/modules/content_translation/src/Controller/ContentTranslationController.php @@ -75,7 +75,7 @@ public function overview(Request $request, $entity_type_id = NULL) { $show_source_column = !empty($additional_source_langcodes); foreach ($languages as $language) { - $language_name = $language->name; + $language_name = $language->getName(); $langcode = $language->getId(); $add_url = new Url( @@ -161,7 +161,7 @@ public function overview(Request $request, $entity_type_id = NULL) { $source_name = $this->t('n/a'); } else { - $source_name = isset($languages[$source]) ? $languages[$source]->name : $this->t('n/a'); + $source_name = isset($languages[$source]) ? $languages[$source]->getName() : $this->t('n/a'); if ($handler->getTranslationAccess($entity, 'delete')) { $links['delete'] = array( 'title' => $this->t('Delete'), diff --git a/core/modules/views/src/Plugin/views/PluginBase.php b/core/modules/views/src/Plugin/views/PluginBase.php index b66578b..f93943e 100644 --- a/core/modules/views/src/Plugin/views/PluginBase.php +++ b/core/modules/views/src/Plugin/views/PluginBase.php @@ -516,14 +516,14 @@ public static function queryLanguageSubstitutions() { $manager = \Drupal::languageManager(); // Handle default language. - $default = $manager->getDefaultLanguage()->id; + $default = $manager->getDefaultLanguage()->getId(); $changes['***LANGUAGE_site_default***'] = $default; // Handle negotiated languages. $types = $manager->getDefinedLanguageTypesInfo(); foreach ($types as $id => $type) { if (isset($type['name'])) { - $changes['***LANGUAGE_' . $id . '***'] = $manager->getCurrentLanguage($id)->id; + $changes['***LANGUAGE_' . $id . '***'] = $manager->getCurrentLanguage($id)->getId(); } }