You are here

public function UserSession::getPreferredAdminLangcode in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Session/UserSession.php \Drupal\Core\Session\UserSession::getPreferredAdminLangcode()
  2. 9 core/lib/Drupal/Core/Session/UserSession.php \Drupal\Core\Session\UserSession::getPreferredAdminLangcode()

File

core/lib/Drupal/Core/Session/UserSession.php, line 144

Class

UserSession
An implementation of the user account interface for the global user.

Namespace

Drupal\Core\Session

Code

public function getPreferredAdminLangcode($fallback_to_default = TRUE) {
  $language_list = \Drupal::languageManager()
    ->getLanguages();
  if (!empty($this->preferred_admin_langcode) && isset($language_list[$this->preferred_admin_langcode])) {
    return $language_list[$this->preferred_admin_langcode]
      ->getId();
  }
  else {
    return $fallback_to_default ? \Drupal::languageManager()
      ->getDefaultLanguage()
      ->getId() : '';
  }
}