Commit 9243c13a authored by alexpott's avatar alexpott

Revert "Issue #2407125 by Cogax: LanguageInterface should not support setName"

This reverts commit 574b0ebd.
parent 574b0ebd
...@@ -105,6 +105,15 @@ public function getName() { ...@@ -105,6 +105,15 @@ public function getName() {
return $this->name; return $this->name;
} }
/**
* {@inheritdoc}
*/
public function setName($name) {
$this->name = $name;
return $this;
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
......
...@@ -109,6 +109,16 @@ interface LanguageInterface { ...@@ -109,6 +109,16 @@ interface LanguageInterface {
*/ */
public function getName(); 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). * Gets the ID (language code).
* *
......
...@@ -397,19 +397,9 @@ protected function filterLanguages(array $languages, $flags = LanguageInterface: ...@@ -397,19 +397,9 @@ protected function filterLanguages(array $languages, $flags = LanguageInterface:
$filtered_languages = array(); $filtered_languages = array();
// Add the site's default language if requested. // Add the site's default language if requested.
if ($flags & LanguageInterface::STATE_SITE_DEFAULT) { if ($flags & LanguageInterface::STATE_SITE_DEFAULT) {
// Setup a language to have the defaults, but with overridden name.
// Setup a language to have the defaults with data appropriate of the $default = $this->getDefaultLanguage();
// default language only for runtime. $default->setName($this->t("Site's default language (@lang_name)", array('@lang_name' => $default->getName())));
$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; $filtered_languages[LanguageInterface::LANGCODE_SITE_DEFAULT] = $default;
} }
......
...@@ -33,12 +33,15 @@ public function testConstruct() { ...@@ -33,12 +33,15 @@ public function testConstruct() {
/** /**
* @covers ::getName * @covers ::getName
* @covers ::setName
*/ */
public function testGetName() { public function testGetName() {
$name = $this->randomMachineName(); $name = $this->randomMachineName();
$language_code = $this->randomMachineName(2); $language_code = $this->randomMachineName(2);
$language = new Language(array('id' => $language_code, 'name' => $name)); $language = new Language(array('id' => $language_code, 'name' => $name));
$this->assertSame($name, $language->getName()); $this->assertSame($name, $language->getName());
$new_name = $this->randomMachineName();
$this->assertSame($new_name, $language->setName($new_name)->getName());
} }
/** /**
......
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