2022-08-20 22:17:17 +02:00
|
|
|
<?php
|
|
|
|
|
2022-11-18 18:06:46 +01:00
|
|
|
namespace Core\Objects;
|
2022-08-20 22:17:17 +02:00
|
|
|
|
2022-11-30 16:42:24 +01:00
|
|
|
use Core\Objects\DatabaseEntity\Language;
|
2022-08-20 22:17:17 +02:00
|
|
|
use Twig\Extension\AbstractExtension;
|
|
|
|
use Twig\TwigFunction;
|
|
|
|
|
|
|
|
class CustomTwigFunctions extends AbstractExtension {
|
|
|
|
public function getFunctions(): array {
|
|
|
|
return [
|
|
|
|
new TwigFunction('L', array($this, 'translate')),
|
2022-11-30 16:42:24 +01:00
|
|
|
new TwigFunction('LoadLanguageModule', array($this, 'loadLanguageModule')),
|
2022-08-20 22:17:17 +02:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function translate(string $key): string {
|
|
|
|
return L($key);
|
|
|
|
}
|
2022-11-30 16:42:24 +01:00
|
|
|
|
|
|
|
public function loadLanguageModule(string $module): void {
|
|
|
|
$language = Language::getInstance();
|
|
|
|
$language->loadModule($module);
|
|
|
|
}
|
2022-08-20 22:17:17 +02:00
|
|
|
}
|