Commit c0a7453a authored by catch's avatar catch

Issue #2339435 by YesCT, alexpott: Default no longer needs to be a property on...

Issue #2339435 by YesCT, alexpott: Default no longer needs to be a property on Language or ConfigurableLanguage.
parent 575a6480
...@@ -1550,12 +1550,12 @@ function install_import_translations(&$install_state) { ...@@ -1550,12 +1550,12 @@ function install_import_translations(&$install_state) {
$langcode = $install_state['parameters']['langcode']; $langcode = $install_state['parameters']['langcode'];
$language = ConfigurableLanguage::createFromLangcode($langcode); $language = ConfigurableLanguage::createFromLangcode($langcode);
$language->set('default', TRUE);
$language->save(); $language->save();
// If a non-English language was selected, remove English and import the // If a non-English language was selected, change the default language,
// translations. // remove English and import the translations.
if ($langcode != 'en') { if ($langcode != 'en') {
\Drupal::config('system.site')->set('langcode', $langcode)->save();
entity_delete_multiple('configurable_language', array('en')); entity_delete_multiple('configurable_language', array('en'));
// Set up a batch to import translations for the newly added language. // Set up a batch to import translations for the newly added language.
......
...@@ -1040,7 +1040,7 @@ protected function compileContainer() { ...@@ -1040,7 +1040,7 @@ protected function compileContainer() {
$default_language_values = Language::$defaultValues; $default_language_values = Language::$defaultValues;
if ($system = $this->getConfigStorage()->read('system.site')) { if ($system = $this->getConfigStorage()->read('system.site')) {
if ($default_language_values['id'] != $system['langcode']) { if ($default_language_values['id'] != $system['langcode']) {
$default_language_values = array('id' => $system['langcode'], 'default' => TRUE); $default_language_values = array('id' => $system['langcode']);
} }
} }
$container->setParameter('language.default_values', $default_language_values); $container->setParameter('language.default_values', $default_language_values);
......
...@@ -25,7 +25,6 @@ class Language implements LanguageInterface { ...@@ -25,7 +25,6 @@ class Language implements LanguageInterface {
'direction' => self::DIRECTION_LTR, 'direction' => self::DIRECTION_LTR,
'weight' => 0, 'weight' => 0,
'locked' => FALSE, 'locked' => FALSE,
'default' => TRUE,
); );
// Properties within the Language are set up as the default language. // Properties within the Language are set up as the default language.
...@@ -60,13 +59,6 @@ class Language implements LanguageInterface { ...@@ -60,13 +59,6 @@ class Language implements LanguageInterface {
*/ */
public $weight = 0; public $weight = 0;
/**
* Flag indicating if this is the only site default language.
*
* @var bool
*/
public $default = FALSE;
/** /**
* Locked indicates a language used by the system, not an actual language. * Locked indicates a language used by the system, not an actual language.
* *
...@@ -136,7 +128,7 @@ public function getWeight() { ...@@ -136,7 +128,7 @@ public function getWeight() {
* {@inheritdoc} * {@inheritdoc}
*/ */
public function isDefault() { public function isDefault() {
return $this->default; return static::getDefaultLangcode() == $this->getId();
} }
/** /**
...@@ -156,4 +148,15 @@ public static function sort(&$languages) { ...@@ -156,4 +148,15 @@ public static function sort(&$languages) {
}); });
} }
/**
* Gets the default langcode.
*
* @return string
* The current default langcode.
*/
protected static function getDefaultLangcode() {
$language = \Drupal::service('language.default')->get();
return $language->getId();
}
} }
...@@ -53,7 +53,6 @@ public function get() { ...@@ -53,7 +53,6 @@ public function get() {
* The default language. * The default language.
*/ */
public function set(LanguageInterface $language) { public function set(LanguageInterface $language) {
$language->default = TRUE;
$this->language = $language; $this->language = $language;
} }
......
...@@ -119,7 +119,8 @@ function testPerUserLoginFloodControl() { ...@@ -119,7 +119,8 @@ function testPerUserLoginFloodControl() {
* Tests compatibility with locale/UI translation. * Tests compatibility with locale/UI translation.
*/ */
function testLocale() { function testLocale() {
ConfigurableLanguage::create(array('id' => 'de', 'label' => 'German', 'default' => TRUE))->save(); ConfigurableLanguage::createFromLangcode('de')->save();
\Drupal::config('system.site')->set('langcode', 'de')->save();
$account = $this->drupalCreateUser(); $account = $this->drupalCreateUser();
......
...@@ -67,9 +67,7 @@ function testSiteNameTranslation() { ...@@ -67,9 +67,7 @@ function testSiteNameTranslation() {
// overrides still work. // overrides still work.
$language_manager = \Drupal::languageManager()->reset(); $language_manager = \Drupal::languageManager()->reset();
$this->assertTrue($language_manager->isMultilingual(), 'The test site is multilingual.'); $this->assertTrue($language_manager->isMultilingual(), 'The test site is multilingual.');
$language = ConfigurableLanguage::load('xx'); \Drupal::config('system.site')->set('langcode', 'xx')->save();
$language->set('default', TRUE);
$language->save();
ConfigurableLanguage::load('en')->delete(); ConfigurableLanguage::load('en')->delete();
$this->assertFalse($language_manager->isMultilingual(), 'The test site is monolingual.'); $this->assertFalse($language_manager->isMultilingual(), 'The test site is monolingual.');
......
...@@ -444,10 +444,10 @@ function language_negotiation_url_prefixes_update() { ...@@ -444,10 +444,10 @@ function language_negotiation_url_prefixes_update() {
foreach (\Drupal::languageManager()->getLanguages() as $language) { foreach (\Drupal::languageManager()->getLanguages() as $language) {
// The prefix for this language should be updated if it's not assigned yet // The prefix for this language should be updated if it's not assigned yet
// or the prefix is set to the empty string. // or the prefix is set to the empty string.
if (empty($prefixes[$language->id])) { if (empty($prefixes[$language->getId()])) {
// For the default language, set the prefix to the empty string, // For the default language, set the prefix to the empty string,
// otherwise use the langcode. // otherwise use the langcode.
$prefixes[$language->id] = !empty($language->default) ? '' : $language->id; $prefixes[$language->getId()] = $language->isDefault() ? '' : $language->id;
} }
// Otherwise we keep the configured prefix. // Otherwise we keep the configured prefix.
} }
...@@ -592,9 +592,7 @@ function language_form_system_regional_settings_alter(&$form, FormStateInterface ...@@ -592,9 +592,7 @@ function language_form_system_regional_settings_alter(&$form, FormStateInterface
* @see language_form_system_regional_settings_alter() * @see language_form_system_regional_settings_alter()
*/ */
function language_system_regional_settings_form_submit($form, FormStateInterface $form_state) { function language_system_regional_settings_form_submit($form, FormStateInterface $form_state) {
$default_language = ConfigurableLanguage::load($form_state->getValue('site_default_language')); \Drupal::config('system.site')->set('langcode', $form_state->getValue('site_default_language'))->save();
$default_language->set('default', TRUE);
$default_language->save();
} }
/** /**
......
...@@ -9,6 +9,7 @@ services: ...@@ -9,6 +9,7 @@ services:
- [initLanguageManager] - [initLanguageManager]
language.config_subscriber: language.config_subscriber:
class: Drupal\language\EventSubscriber\ConfigSubscriber class: Drupal\language\EventSubscriber\ConfigSubscriber
arguments: ['@language_manager', '@language.default']
tags: tags:
- { name: event_subscriber } - { name: event_subscriber }
language.config_factory_override: language.config_factory_override:
......
...@@ -7,12 +7,10 @@ ...@@ -7,12 +7,10 @@
namespace Drupal\language\Entity; namespace Drupal\language\Entity;
use Drupal\Core\Language\Language as LanguageObject;
use Drupal\Core\Config\Entity\ConfigEntityBase; use Drupal\Core\Config\Entity\ConfigEntityBase;
use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Language\LanguageManager; use Drupal\Core\Language\LanguageManager;
use Drupal\language\ConfigurableLanguageManager; use Drupal\language\ConfigurableLanguageManager;
use Drupal\Core\Language\Language;
use Drupal\language\ConfigurableLanguageManagerInterface; use Drupal\language\ConfigurableLanguageManagerInterface;
use Drupal\language\Exception\DeleteDefaultLanguageException; use Drupal\language\Exception\DeleteDefaultLanguageException;
use Drupal\language\ConfigurableLanguageInterface; use Drupal\language\ConfigurableLanguageInterface;
...@@ -82,21 +80,6 @@ class ConfigurableLanguage extends ConfigEntityBase implements ConfigurableLangu ...@@ -82,21 +80,6 @@ class ConfigurableLanguage extends ConfigEntityBase implements ConfigurableLangu
*/ */
public $locked = FALSE; public $locked = FALSE;
/**
* Flag to indicate if the language entity is the default site language.
*
* This property is not saved to the language entity since there can be only
* one default language. It is saved to system.site:langcode and set on the
* container using the language.default service in when the entity is saved.
* The value is set correctly when a language entity is created or loaded.
*
* @see \Drupal\language\Entity\ConfigurableLanguage::postSave()
* @see \Drupal\language\Entity\ConfigurableLanguage::isDefault()
*
* @var bool
*/
protected $default;
/** /**
* Used during saving to detect when the site becomes multilingual. * Used during saving to detect when the site becomes multilingual.
* *
...@@ -111,16 +94,10 @@ class ConfigurableLanguage extends ConfigEntityBase implements ConfigurableLangu ...@@ -111,16 +94,10 @@ class ConfigurableLanguage extends ConfigEntityBase implements ConfigurableLangu
protected $preSaveMultilingual; protected $preSaveMultilingual;
/** /**
* Checks if the language entity is the site default language. * {@inheritdoc}
*
* @return bool
* TRUE if the language entity is the site default language, FALSE if not.
*/ */
public function isDefault() { public function isDefault() {
if (!isset($this->default)) { return static::getDefaultLangcode() == $this->id();
return static::getDefaultLangcode() == $this->id();
}
return $this->default;
} }
/** /**
...@@ -144,24 +121,14 @@ public function preSave(EntityStorageInterface $storage) { ...@@ -144,24 +121,14 @@ public function preSave(EntityStorageInterface $storage) {
public function postSave(EntityStorageInterface $storage, $update = TRUE) { public function postSave(EntityStorageInterface $storage, $update = TRUE) {
parent::postSave($storage, $update); parent::postSave($storage, $update);
// Only set the default language and save it to system.site configuration if
// it needs to updated.
if ($this->isDefault() && static::getDefaultLangcode() != $this->id()) {
// Update the config. Saving the configuration fires and event that causes
// the container to be rebuilt.
\Drupal::config('system.site')->set('langcode', $this->id())->save();
\Drupal::service('language.default')->set($this->toLanguageObject());
}
$language_manager = \Drupal::languageManager(); $language_manager = \Drupal::languageManager();
$language_manager->reset(); $language_manager->reset();
if ($language_manager instanceof ConfigurableLanguageManagerInterface) { if ($language_manager instanceof ConfigurableLanguageManagerInterface) {
$language_manager->updateLockedLanguageWeights(); $language_manager->updateLockedLanguageWeights();
} }
// Update URL Prefixes for all languages after the new default language is // Update URL Prefixes for all languages after the
// propagated and the LanguageManagerInterface::getLanguages() cache is // LanguageManagerInterface::getLanguages() cache is flushed.
// flushed.
language_negotiation_url_prefixes_update(); language_negotiation_url_prefixes_update();
// If after adding this language the site will become multilingual, we need // If after adding this language the site will become multilingual, we need
...@@ -175,26 +142,6 @@ public function postSave(EntityStorageInterface $storage, $update = TRUE) { ...@@ -175,26 +142,6 @@ public function postSave(EntityStorageInterface $storage, $update = TRUE) {
} }
} }
/**
* Converts the ConfigurableLanguage entity to a Core Language value object.
*
* @todo fix return type hint after https://drupal.org/node/2246665 and
* https://drupal.org/node/2246679.
*
* @return \Drupal\Core\Language\LanguageInterface
* The language configuration entity expressed as a Language value object.
*/
protected function toLanguageObject() {
return new LanguageObject(array(
'id' => $this->id(),
'name' => $this->label(),
'direction' => $this->direction,
'weight' => $this->weight,
'locked' => $this->locked,
'default' => $this->default,
));
}
/** /**
* {@inheritdoc} * {@inheritdoc}
* *
...@@ -228,18 +175,6 @@ public static function postDelete(EntityStorageInterface $storage, array $entiti ...@@ -228,18 +175,6 @@ public static function postDelete(EntityStorageInterface $storage, array $entiti
} }
} }
/**
* {@inheritdoc}
*/
public function get($property_name) {
if ($property_name == 'default') {
return $this->isDefault();
}
else {
return parent::get($property_name);
}
}
/** /**
* Gets the default langcode. * Gets the default langcode.
* *
......
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
namespace Drupal\language\EventSubscriber; namespace Drupal\language\EventSubscriber;
use Drupal\Core\Language\LanguageDefault;
use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Core\PhpStorage\PhpStorageFactory; use Drupal\Core\PhpStorage\PhpStorageFactory;
use Drupal\Core\Config\ConfigCrudEvent; use Drupal\Core\Config\ConfigCrudEvent;
use Drupal\Core\Config\ConfigEvents; use Drupal\Core\Config\ConfigEvents;
...@@ -17,6 +19,33 @@ ...@@ -17,6 +19,33 @@
*/ */
class ConfigSubscriber implements EventSubscriberInterface { class ConfigSubscriber implements EventSubscriberInterface {
/**
* The language manager.
*
* @var \Drupal\Core\Language\LanguageManagerInterface
*/
protected $languageManager;
/**
* The default language.
*
* @var \Drupal\Core\Language\LanguageDefault
*/
protected $languageDefault;
/**
* Constructs a new class object.
*
* @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
* The language manager.
* @param \Drupal\Core\Language\LanguageDefault $language_default
* The default language.
*/
public function __construct(LanguageManagerInterface $language_manager, LanguageDefault $language_default) {
$this->languageManager = $language_manager;
$this->languageDefault = $language_default;
}
/** /**
* Causes the container to be rebuilt on the next request. * Causes the container to be rebuilt on the next request.
* *
...@@ -26,6 +55,13 @@ class ConfigSubscriber implements EventSubscriberInterface { ...@@ -26,6 +55,13 @@ class ConfigSubscriber implements EventSubscriberInterface {
public function onConfigSave(ConfigCrudEvent $event) { public function onConfigSave(ConfigCrudEvent $event) {
$saved_config = $event->getConfig(); $saved_config = $event->getConfig();
if ($saved_config->getName() == 'system.site' && $event->isChanged('langcode')) { if ($saved_config->getName() == 'system.site' && $event->isChanged('langcode')) {
$language = $this->languageManager->getLanguage($saved_config->get('langcode'));
// During an import the language might not exist yet.
if ($language) {
$this->languageDefault->set($language);
$this->languageManager->reset();
language_negotiation_url_prefixes_update();
}
// Trigger a container rebuild on the next request by deleting compiled // Trigger a container rebuild on the next request by deleting compiled
// from PHP storage. // from PHP storage.
PhpStorageFactory::get('service_container')->deleteAll(); PhpStorageFactory::get('service_container')->deleteAll();
......
...@@ -76,7 +76,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { ...@@ -76,7 +76,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
$t_args = array('%language' => $language->name, '%langcode' => $language->id); $t_args = array('%language' => $language->name, '%langcode' => $language->id);
$form['prefix'][$langcode] = array( $form['prefix'][$langcode] = array(
'#type' => 'textfield', '#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() ? $this->t('%language (%langcode) path prefix (Default language)', $t_args) : $this->t('%language (%langcode) path prefix', $t_args),
'#maxlength' => 64, '#maxlength' => 64,
'#default_value' => isset($prefixes[$langcode]) ? $prefixes[$langcode] : '', '#default_value' => isset($prefixes[$langcode]) ? $prefixes[$langcode] : '',
'#field_prefix' => $base_url . '/', '#field_prefix' => $base_url . '/',
...@@ -106,7 +106,7 @@ public function validateForm(array &$form, FormStateInterface $form_state) { ...@@ -106,7 +106,7 @@ public function validateForm(array &$form, FormStateInterface $form_state) {
$value = $form_state->getValue(array('prefix', $langcode)); $value = $form_state->getValue(array('prefix', $langcode));
if ($value === '') { 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, // Throw a form error if the prefix is blank for a non-default language,
// although it is required for selected negotiation type. // although it is required for selected negotiation type.
$form_state->setErrorByName("prefix][$langcode", $this->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.'));
...@@ -130,7 +130,7 @@ public function validateForm(array &$form, FormStateInterface $form_state) { ...@@ -130,7 +130,7 @@ public function validateForm(array &$form, FormStateInterface $form_state) {
$value = $form_state->getValue(array('domain', $langcode)); $value = $form_state->getValue(array('domain', $langcode));
if ($value === '') { 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, // Throw a form error if the domain is blank for a non-default language,
// although it is required for selected negotiation type. // although it is required for selected negotiation type.
$form_state->setErrorByName("domain][$langcode", $this->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.'));
......
...@@ -100,7 +100,7 @@ protected function getDefaultLanguageValues() { ...@@ -100,7 +100,7 @@ protected function getDefaultLanguageValues() {
$system = $config_storage->read('system.site'); $system = $config_storage->read('system.site');
$default_language = $config_storage->read(static::CONFIG_PREFIX . $system['langcode']); $default_language = $config_storage->read(static::CONFIG_PREFIX . $system['langcode']);
if (is_array($default_language)) { if (is_array($default_language)) {
return $default_language + array('default' => TRUE); return $default_language;
} }
return FALSE; return FALSE;
} }
......
...@@ -83,18 +83,16 @@ public function testDefaultLangcode() { ...@@ -83,18 +83,16 @@ public function testDefaultLangcode() {
$old_default = \Drupal::languageManager()->getDefaultLanguage(); $old_default = \Drupal::languageManager()->getDefaultLanguage();
// Ensure the language entity default value is correct. // Ensure the language entity default value is correct.
$configurable_language = entity_load('configurable_language', $old_default->getId()); $configurable_language = entity_load('configurable_language', $old_default->getId());
$this->assertTrue($configurable_language->get('default'), 'The en language entity is flagged as the default language.'); $this->assertTrue($configurable_language->isDefault(), 'The en language entity is flagged as the default language.');
$new_default = ConfigurableLanguage::load('cc'); \Drupal::config('system.site')->set('langcode', 'cc')->save();
$new_default->set('default', TRUE);
$new_default->save();
language_save_default_configuration('custom_type', 'custom_bundle', array('langcode' => 'site_default', 'language_show' => TRUE)); language_save_default_configuration('custom_type', 'custom_bundle', array('langcode' => 'site_default', 'language_show' => TRUE));
$langcode = language_get_default_langcode('custom_type', 'custom_bundle'); $langcode = language_get_default_langcode('custom_type', 'custom_bundle');
$this->assertEqual($langcode, 'cc'); $this->assertEqual($langcode, 'cc');
// Ensure the language entity default value is correct. // Ensure the language entity default value is correct.
$configurable_language = entity_load('configurable_language', $old_default->getId()); $configurable_language = entity_load('configurable_language', $old_default->getId());
$this->assertFalse($configurable_language->get('default'), 'The en language entity is not flagged as the default language.'); $this->assertFalse($configurable_language->isDefault(), 'The en language entity is not flagged as the default language.');
$configurable_language = entity_load('configurable_language', 'cc'); $configurable_language = entity_load('configurable_language', 'cc');
// Check calling the // Check calling the
// \Drupal\language\Entity\ConfigurableLanguage::isDefault() method // \Drupal\language\Entity\ConfigurableLanguage::isDefault() method
......
...@@ -42,13 +42,8 @@ function testDependencyInjectedNewLanguage() { ...@@ -42,13 +42,8 @@ function testDependencyInjectedNewLanguage() {
function testDependencyInjectedNewDefaultLanguage() { function testDependencyInjectedNewDefaultLanguage() {
$default_language = ConfigurableLanguage::load(\Drupal::languageManager()->getDefaultLanguage()->getId()); $default_language = ConfigurableLanguage::load(\Drupal::languageManager()->getDefaultLanguage()->getId());
// Change the language default object to different values. // Change the language default object to different values.
ConfigurableLanguage::create(array( ConfigurableLanguage::createFromLangcode('fr')->save();
'id' => 'fr', \Drupal::config('system.site')->set('langcode', 'fr')->save();
'label' => 'French',
'direction' => Language::DIRECTION_LTR,
'weight' => 0,
'default' => TRUE,
))->save();
// The language system creates a Language object which contains the // The language system creates a Language object which contains the
// same properties as the new default language object. // same properties as the new default language object.
...@@ -65,8 +60,8 @@ function testDependencyInjectedNewDefaultLanguage() { ...@@ -65,8 +60,8 @@ function testDependencyInjectedNewDefaultLanguage() {
} }
// Re-save the previous default language and the delete should work. // Re-save the previous default language and the delete should work.
$default_language->set('default', TRUE); \Drupal::config('system.site')->set('langcode', $default_language->getId())->save();
$default_language->save();
entity_delete_multiple('configurable_language', array('fr')); entity_delete_multiple('configurable_language', array('fr'));
$result = \Drupal::languageManager()->getCurrentLanguage(); $result = \Drupal::languageManager()->getCurrentLanguage();
$this->assertIdentical($result->id, $default_language->id); $this->assertIdentical($result->id, $default_language->id);
......
...@@ -89,9 +89,8 @@ function testUILanguageNegotiation() { ...@@ -89,9 +89,8 @@ function testUILanguageNegotiation() {
// is for some reason not found when doing translate search. This might // is for some reason not found when doing translate search. This might
// be some bug. // be some bug.
$default_language = \Drupal::languageManager()->getDefaultLanguage(); $default_language = \Drupal::languageManager()->getDefaultLanguage();
$language = ConfigurableLanguage::createFromLangcode($langcode_browser_fallback); ConfigurableLanguage::createFromLangcode($langcode_browser_fallback)->save();
$language->set('default', TRUE); \Drupal::config('system.site')->set('langcode', $langcode_browser_fallback)->save();
$language->save();
ConfigurableLanguage::createFromLangcode($langcode)->save(); ConfigurableLanguage::createFromLangcode($langcode)->save();
// We will look for this string in the admin/config screen to see if the // We will look for this string in the admin/config screen to see if the
...@@ -104,9 +103,7 @@ function testUILanguageNegotiation() { ...@@ -104,9 +103,7 @@ function testUILanguageNegotiation() {
// Now the t()'ed string is in db so switch the language back to default. // Now the t()'ed string is in db so switch the language back to default.
// This will rebuild the container so we need to rebuild the container in // This will rebuild the container so we need to rebuild the container in
// the test environment. // the test environment.
$default_language = ConfigurableLanguage::load($default_language->getId()); \Drupal::config('system.site')->set('langcode', $default_language->getId())->save();
$default_language->set('default', TRUE);
$default_language->save();
\Drupal::config('language.negotiation')->set('url.prefixes.en', '')->save(); \Drupal::config('language.negotiation')->set('url.prefixes.en', '')->save();
$this->rebuildContainer(); $this->rebuildContainer();
......
...@@ -31,9 +31,9 @@ public function setUp() { ...@@ -31,9 +31,9 @@ public function setUp() {
parent::setUp(); parent::setUp();
// Change the language default object to different values. // Change the language default object to different values.
$language = ConfigurableLanguage::createFromLangcode('fr'); ConfigurableLanguage::createFromLangcode('fr')->save();
$language->set('default', TRUE); \Drupal::config('system.site')->set('langcode', 'fr')->save();
$language->save();
$this->drupalLogin($this->root_user); $this->drupalLogin($this->root_user);
} }
......
...@@ -150,9 +150,7 @@ function testMenuLanguageRemovedEnglish() { ...@@ -150,9 +150,7 @@ function testMenuLanguageRemovedEnglish() {
// Remove English language. To do that another language has to be set as // Remove English language. To do that another language has to be set as
// default. // default.
$language = ConfigurableLanguage::load('cs'); \Drupal::config('system.site')->set('langcode', 'cs')->save();
$language->set('default', TRUE);
$language->save();
entity_delete_multiple('configurable_language', array('en')); entity_delete_multiple('configurable_language', array('en'));
// Save the menu again and check if the language is still the same. // Save the menu again and check if the language is still the same.
......
...@@ -96,9 +96,7 @@ function testFormatDate() { ...@@ -96,9 +96,7 @@ function testFormatDate() {
$this->assertIdentical(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T', 'Europe/London', 'en'), 'Monday, 26-Mar-07 01:00:00 BST', 'Test a different time zone.'); $this->assertIdentical(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T', 'Europe/London', 'en'), 'Monday, 26-Mar-07 01:00:00 BST', 'Test a different time zone.');
// Change the default language and timezone. // Change the default language and timezone.
$language = ConfigurableLanguage::load(static::LANGCODE); \Drupal::config('system.site')->set('langcode', static::LANGCODE)->save();
$language->set('default', TRUE);
$language->save();
date_default_timezone_set('America/Los_Angeles'); date_default_timezone_set('America/Los_Angeles');
$this->assertIdentical(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T', 'America/Los_Angeles', 'en'), 'Sunday, 25-Mar-07 17:00:00 PDT', 'Test a different language.'); $this->assertIdentical(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T', 'America/Los_Angeles', 'en'), 'Sunday, 25-Mar-07 17:00:00 PDT', 'Test a different language.');
......
...@@ -70,9 +70,7 @@ protected function setUp() { ...@@ -70,9 +70,7 @@ protected function setUp() {
$this->installLanguages(); $this->installLanguages();
// Assign Lolspeak (xx) to be the default language. // Assign Lolspeak (xx) to be the default language.
$language = ConfigurableLanguage::load('xx'); \Drupal::config('system.site')->set('langcode', 'xx')->save();
$language->set('default', TRUE);
$language->save();
$this->rebuildContainer(); $this->rebuildContainer();
// Check that lolspeak is the default language for the site. // Check that lolspeak is the default language for the site.
......
...@@ -95,9 +95,7 @@ function testDefaultTermLanguage() { ...@@ -95,9 +95,7 @@ function testDefaultTermLanguage() {
// Change the default language of the site and check if the default terms // Change the default language of the site and check if the default terms
// language is still correctly selected. // language is still correctly selected.
$new_default = ConfigurableLanguage::load('cc'); \Drupal::config('system.site')->set('langcode', 'cc')->save();
$new_default->set('default', TRUE);
$new_default->save();
$edit = array( $edit = array(
'default_language[langcode]' => 'site_default', 'default_language[langcode]' => 'site_default',
'default_language[language_show]' => TRUE, 'default_language[language_show]' => TRUE,
......
...@@ -56,9 +56,8 @@ public function testCreateView() { ...@@ -56,9 +56,8 @@ public function testCreateView() {
$random_description = $this->randomMachineName(); $random_description = $this->randomMachineName();
// Add a new language and mark it as default. // Add a new language and mark it as default.
$language = ConfigurableLanguage::createFromLangcode('it'); ConfigurableLanguage::createFromLangcode('it')->save();