You are here

protected function LanguageConfigurationTest::getHighestConfigurableLanguageWeight in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/language/tests/src/Functional/LanguageConfigurationTest.php \Drupal\Tests\language\Functional\LanguageConfigurationTest::getHighestConfigurableLanguageWeight()
  2. 9 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.

File

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

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