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() {
return $this->name;
}
/**
* {@inheritdoc}
*/
public function setName($name) {
$this->name = $name;
return $this;
}
/**
* {@inheritdoc}
*/
......
......@@ -109,6 +109,16 @@ 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,19 +397,9 @@ 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 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(),
)
);
// 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())));
$filtered_languages[LanguageInterface::LANGCODE_SITE_DEFAULT] = $default;
}
......
......@@ -33,12 +33,15 @@ 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());
}
/**
......
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