You are here

public function CurrentLangcode::getValue in More Global Variables 8

Method that implement generating value of global variable.

Return value

mixed Return value of declared variable.

Overrides GlobalVariableInterface::getValue

File

src/Plugin/GlobalVariable/CurrentLangcode.php, line 21

Class

CurrentLangcode
Class CurrentLangcode.

Namespace

Drupal\mgv\Plugin\GlobalVariable

Code

public function getValue() {

  // Print the current langcode. This could be useful if you want to do a
  // "Back to Search" type feature, but need to ensure you keep the current
  // selected language e.g. "/fr/node/123" and "/ga/node/123".
  return \Drupal::languageManager()
    ->getCurrentLanguage()
    ->getId();
}