Skip to content
Snippets Groups Projects
Commit 574b0ebd authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2407125 by Cogax: LanguageInterface should not support setName

parent 7e57c75d
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -105,15 +105,6 @@ public function getName() {
return $this->name;
}
/**
* {@inheritdoc}
*/
public function setName($name) {
$this->name = $name;
return $this;
}
/**
* {@inheritdoc}
*/
......
......@@ -109,16 +109,6 @@ interface LanguageInterface {
*/
public function getName();
/**
* Sets the name of the language.
*
* @param string $name
* The human-readable English name of the language.
*
* @return $this
*/
public function setName($name);
/**
* Gets the ID (language code).
*
......
......@@ -397,9 +397,19 @@ protected function filterLanguages(array $languages, $flags = LanguageInterface:
$filtered_languages = array();
// Add the site's default language if requested.
if ($flags & LanguageInterface::STATE_SITE_DEFAULT) {
// Setup a language to have the defaults, but with overridden name.
$default = $this->getDefaultLanguage();
$default->setName($this->t("Site's default language (@lang_name)", array('@lang_name' => $default->getName())));
// Setup a language to have the defaults with data appropriate of the
// default language only for runtime.
$defaultLanguage = $this->getDefaultLanguage();
$default = new Language(
array(
'id' => $defaultLanguage->getId(),
'name' => $this->t("Site's default language (@lang_name)",
array('@lang_name' => $defaultLanguage->getName())),
'direction' => $defaultLanguage->getDirection(),
'weight' => $defaultLanguage->getWeight(),
)
);
$filtered_languages[LanguageInterface::LANGCODE_SITE_DEFAULT] = $default;
}
......
......@@ -33,15 +33,12 @@ public function testConstruct() {
/**
* @covers ::getName
* @covers ::setName
*/
public function testGetName() {
$name = $this->randomMachineName();
$language_code = $this->randomMachineName(2);
$language = new Language(array('id' => $language_code, 'name' => $name));
$this->assertSame($name, $language->getName());
$new_name = $this->randomMachineName();
$this->assertSame($new_name, $language->setName($new_name)->getName());
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment