You are here

public function LangcodeTrait::getLangcode in Coder 8.2

Same name and namespace in other branches
  1. 8.3 tests/DrupalPractice/good/good.php \LangcodeTrait::getLangcode()
  2. 8.3.x tests/DrupalPractice/good/good.php \LangcodeTrait::getLangcode()

Get code of currently active language.

Return value

string Language code.

File

coder_sniffer/DrupalPractice/Test/good/good.php, line 115

Class

LangcodeTrait
A trait containing helper methods for language handling.

Code

public function getLangcode() {
  if (!isset($this->langcode)) {
    $lang = \Drupal::languageManager()
      ->getCurrentLanguage();
    $this
      ->setLangcode($lang
      ->getId());
  }
  return $this->langcode;
}