Problem/Motivation
#2226533: Changes to the Language class due to the LanguageInterface (followup) is making properties protected and was
diff --git a/core/modules/language/src/Tests/LanguageConfigurationElementTest.php b/core/modules/language/src/Tests/LanguageConfigurationElementTest.php
index 635633c..ae38d65 100644
--- a/core/modules/language/src/Tests/LanguageConfigurationElementTest.php
+++ b/core/modules/language/src/Tests/LanguageConfigurationElementTest.php
@@ -78,17 +78,17 @@ public function testDefaultLangcode() {
// Site's default.
$old_default = \Drupal::languageManager()->getDefaultLanguage();
// Ensure the language entity default value is correct.
$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.');
- $old_default->default = FALSE;
+ $old_default->setDefault(FALSE);
language_save($old_default);
$new_default = \Drupal::languageManager()->getLanguage('cc');
- $new_default->default = TRUE;
+ $new_default->setDefault(TRUE);
language_save($new_default);
language_save_default_configuration('custom_type', 'custom_bundle', array('langcode' => 'site_default', 'language_show' => TRUE));
$langcode = language_get_default_langcode('custom_type', 'custom_bundle');
but #2334763: Tidy up of LanguageInterface - removal of setters and other unnecessary methods is taking out the setDefault
Proposed resolution
Remaining tasks
User interface changes
No.
API changes
No.
Comments
Comment #1
YesCT CreditAttribution: YesCT commentedComment #2
rpayanmComment #3
martin107 CreditAttribution: martin107 commentedWe have a stale remnant from a previous reroll... or something
Can someone from the D8MI team ok the removal of the duplicate test file?
https://www.drupal.org/node/2337989
Comment #4
martin107 CreditAttribution: martin107 commented@rpayanm.. Hi
What you have done is appropriate, but may I suggest a different approach.
When I look at #2334763: Tidy up of LanguageInterface - removal of setters and other unnecessary methods I see one of the wanted API changes is
Can I outline a solution that does not used setters and getters but uses new Language() statement to specify what default values to override
Here is a code fragment that I think will work
Comment #5
martin107 CreditAttribution: martin107 commentedcore now reflects @rpayanm, solution with a minor alteration
setDefault now looks like this..
$new_default = ConfigurableLanguage::load('cc');
$new_default->set('default', TRUE);
$new_default->save();