You are here

public function DisableLanguageManager::getFallbackLanguage in Disable language 8

Determine and return the fallback language id.

Return value

\Drupal\core\Language\LanguageInterface|null The id of the language that functions as the fallback.

File

src/DisableLanguageManager.php, line 160

Class

DisableLanguageManager
Class DisableLanguageManager.

Namespace

Drupal\disable_language

Code

public function getFallbackLanguage() {
  $redirect_language = FALSE;
  $disabledLangCodes = array_keys($this
    ->getDisabledLanguages());
  if (isset($disabledLangCodes) && in_array($this->languageManager
    ->getCurrentLanguage()
    ->getId(), $disabledLangCodes)) {

    // Get the configurable languages.
    $lang = $this
      ->getConfigurableLanguages();
    $key = $this->languageManager
      ->getCurrentLanguage()
      ->getId();
    if (array_key_exists($this->languageManager
      ->getCurrentLanguage()
      ->getId(), $lang)) {
      $redirect_language = $lang[$key]
        ->getThirdPartySetting('disable_language', 'redirect_language');
    }
  }
  return $redirect_language;
}