Commit c52c5f9a authored by alexpott's avatar alexpott

Issue #2304403 by martin107, YesCT, Désiré: Convert language:weight into a protected property.

parent 6ef8ba79
......@@ -733,7 +733,7 @@ function update_language_list($flags = LanguageInterface::STATE_CONFIGURABLE) {
// No language module, so use the default language only.
$languages = array($default->id => $default);
// Add the special languages, they will be filtered later if needed.
$languages += \Drupal::languageManager()->getDefaultLockedLanguages($default->weight);
$languages += \Drupal::languageManager()->getDefaultLockedLanguages($default->getWeight());
}
}
......
......@@ -57,7 +57,7 @@ class Language implements LanguageInterface {
*
* @var int
*/
public $weight = 0;
protected $weight = 0;
/**
* Locked indicates a language used by the system, not an actual language.
......
......@@ -135,7 +135,7 @@ public function getLanguages($flags = LanguageInterface::STATE_CONFIGURABLE) {
$default = $this->getDefaultLanguage();
$this->languages = array($default->id => $default);
// Add the special languages, they will be filtered later if needed.
$this->languages += $this->getDefaultLockedLanguages($default->weight);
$this->languages += $this->getDefaultLockedLanguages($default->getWeight());
}
// Filter the full list of languages based on the value of the $all flag. By
......
......@@ -298,7 +298,7 @@ public function getLanguages($flags = LanguageInterface::STATE_CONFIGURABLE) {
$data['default'] = ($langcode == $default->id);
$data['name'] = $data['label'];
$this->languages[$langcode] = new Language($data);
$weight = max(array($weight, $this->languages[$langcode]->weight));
$weight = max(array($weight, $this->languages[$langcode]->getWeight()));
}
// Add locked languages, they will be filtered later if needed.
......@@ -337,8 +337,8 @@ public function updateLockedLanguageWeights() {
// Get maximum weight to update the system languages to keep them on bottom.
foreach ($this->getLanguages(LanguageInterface::STATE_CONFIGURABLE) as $language) {
if (!$language->isLocked() && $language->weight > $max_weight) {
$max_weight = $language->weight;
if (!$language->isLocked() && $language->getWeight() > $max_weight) {
$max_weight = $language->getWeight();
}
}
......
......@@ -71,7 +71,7 @@ class ConfigurableLanguage extends ConfigEntityBase implements ConfigurableLangu
*
* @var integer
*/
public $weight = 0;
protected $weight = 0;
/**
* Locked languages cannot be edited.
......
......@@ -157,7 +157,7 @@ protected function checkConfigurableLanguageWeight($state = 'by default') {
$replacements = array('@event' => $state);
foreach (\Drupal::languageManager()->getLanguages(LanguageInterface::STATE_LOCKED) as $locked_language) {
$replacements['%language'] = $locked_language->name;
$this->assertTrue($locked_language->weight > $max_configurable_language_weight, format_string('System language %language has higher weight than configurable languages @event', $replacements));
$this->assertTrue($locked_language->getWeight() > $max_configurable_language_weight, format_string('System language %language has higher weight than configurable languages @event', $replacements));
}
}
......@@ -170,10 +170,11 @@ protected function checkConfigurableLanguageWeight($state = 'by default') {
protected function getHighestConfigurableLanguageWeight(){
$max_weight = 0;
/* @var $languages \Drupal\Core\Language\LanguageInterface[] */
$languages = entity_load_multiple('configurable_language', NULL, TRUE);
foreach ($languages as $language) {
if (!$language->isLocked() && $language->weight > $max_weight) {
$max_weight = $language->weight;
if (!$language->isLocked() && $language->getWeight() > $max_weight) {
$max_weight = $language->getWeight();
}
}
......
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