Langs.php in Bamboo Twig 8
File
src/TwigExtension/Langs.php
View source
<?php
namespace Drupal\bamboo_twig\TwigExtension;
use Drupal\Core\Language\LanguageManagerInterface;
class Langs extends \Twig_Extension {
private $language;
public function __construct(LanguageManagerInterface $language) {
$this->language = $language;
}
public function getFunctions() {
return [
new \Twig_SimpleFunction('get_lang', [
$this,
'getLang',
]),
];
}
public function getName() {
return 'bamboo_twig.twig.langs';
}
public function getLang() {
return $this->language
->getCurrentLanguage()
->getId();
}
}
Classes
Name |
Description |
Langs |
Provides a 'Langs' Twig Extensions. |