class Langs in Bamboo Twig 8
Provides a 'Langs' Twig Extensions.
Hierarchy
- class \Drupal\bamboo_twig\TwigExtension\Langs extends \Drupal\bamboo_twig\TwigExtension\Twig_Extension
Expanded class hierarchy of Langs
1 string reference to 'Langs'
1 service uses Langs
File
- src/
TwigExtension/ Langs.php, line 11
Namespace
Drupal\bamboo_twig\TwigExtensionView source
class Langs extends \Twig_Extension {
/**
* Language manager service.
*
* @var Drupal\Core\Language\LanguageManagerInterface
*/
private $language;
/**
* TwigExtension constructor.
*/
public function __construct(LanguageManagerInterface $language) {
$this->language = $language;
}
/**
* List of all Twig functions.
*/
public function getFunctions() {
return [
new \Twig_SimpleFunction('get_lang', [
$this,
'getLang',
]),
];
}
/**
* Unique identifier for this Twig extension.
*/
public function getName() {
return 'bamboo_twig.twig.langs';
}
/**
* Retrieve the current language.
*/
public function getLang() {
return $this->language
->getCurrentLanguage()
->getId();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Langs:: |
private | property | Language manager service. | |
Langs:: |
public | function | List of all Twig functions. | |
Langs:: |
public | function | Retrieve the current language. | |
Langs:: |
public | function | Unique identifier for this Twig extension. | |
Langs:: |
public | function | TwigExtension constructor. |