You are here

protected function LanguageServiceProvider::getDefaultLanguageValues in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/language/src/LanguageServiceProvider.php \Drupal\language\LanguageServiceProvider::getDefaultLanguageValues()
  2. 9 core/modules/language/src/LanguageServiceProvider.php \Drupal\language\LanguageServiceProvider::getDefaultLanguageValues()

Gets the default language values.

Return value

array|bool Returns the default language values for the language configured in system.site:default_langcode if the corresponding configuration entity exists, otherwise FALSE.

File

core/modules/language/src/LanguageServiceProvider.php, line 87

Class

LanguageServiceProvider
Overrides the language_manager service to point to language's module one.

Namespace

Drupal\language

Code

protected function getDefaultLanguageValues() {
  $config_storage = BootstrapConfigStorageFactory::get();
  $system = $config_storage
    ->read('system.site');

  // In Kernel tests it's possible this code is called before system.site
  // exists. In such cases behave as though the corresponding language
  // configuration entity does not exist.
  if ($system === FALSE) {
    return FALSE;
  }
  $default_language = $config_storage
    ->read(static::CONFIG_PREFIX . $system['default_langcode']);
  if (is_array($default_language)) {
    return $default_language;
  }
  return FALSE;
}