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

This reverts commit 574b0ebd7a.
8.0.x
Alex Pott 2015-01-22 16:50:48 +00:00
parent 574b0ebd7a
commit 9243c13a6f
4 changed files with 25 additions and 13 deletions

View File

@ -105,6 +105,15 @@ class Language implements LanguageInterface {
return $this->name;
}
/**
* {@inheritdoc}
*/
public function setName($name) {
$this->name = $name;
return $this;
}
/**
* {@inheritdoc}
*/

View File

@ -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).
*

View File

@ -397,19 +397,9 @@ class LanguageManager implements LanguageManagerInterface {
$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;
}

View File

@ -33,12 +33,15 @@ class LanguageUnitTest extends UnitTestCase {
/**
* @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());
}
/**