You are here

protected function LanguageConfigurationTest::getHighestConfigurableLanguageWeight in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/language/tests/src/Functional/LanguageConfigurationTest.php \Drupal\Tests\language\Functional\LanguageConfigurationTest::getHighestConfigurableLanguageWeight()
  2. 10 core/modules/language/tests/src/Functional/LanguageConfigurationTest.php \Drupal\Tests\language\Functional\LanguageConfigurationTest::getHighestConfigurableLanguageWeight()

Helper to get maximum weight of configurable (unlocked) languages.

Return value

int Maximum weight of configurable languages.

2 calls to LanguageConfigurationTest::getHighestConfigurableLanguageWeight()
LanguageConfigurationTest::checkConfigurableLanguageWeight in core/modules/language/tests/src/Functional/LanguageConfigurationTest.php
Validates system languages are ordered after configurable languages.
LanguageConfigurationTest::testLanguageConfigurationWeight in core/modules/language/tests/src/Functional/LanguageConfigurationTest.php
Functional tests for setting system language weight on adding, editing and deleting languages.

File

core/modules/language/tests/src/Functional/LanguageConfigurationTest.php, line 214

Class

LanguageConfigurationTest
Adds and configures languages to check negotiation changes.

Namespace

Drupal\Tests\language\Functional

Code

protected function getHighestConfigurableLanguageWeight() {
  $max_weight = 0;
  $storage = $this->container
    ->get('entity_type.manager')
    ->getStorage('configurable_language');
  $storage
    ->resetCache();

  /* @var $languages \Drupal\Core\Language\LanguageInterface[] */
  $languages = $storage
    ->loadMultiple();
  foreach ($languages as $language) {
    if (!$language
      ->isLocked()) {
      $max_weight = max($max_weight, $language
        ->getWeight());
    }
  }
  return $max_weight;
}