diff options
Diffstat (limited to 'src/View.php')
-rw-r--r-- | src/View.php | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/View.php b/src/View.php index 7862b12..1c29a67 100644 --- a/src/View.php +++ b/src/View.php @@ -9,11 +9,14 @@ use Twig\TwigFilter; class View { - private static Environment $twig; + public static Environment $twig; public static function init(): void { - $loader = new FilesystemLoader(dirname(__DIR__) . '/views'); + $loader = new FilesystemLoader( + dirname(__DIR__) . '/views/' . + (isset($_ENV['GEMINI']) ? 'gemini' : 'http') + ); self::$twig = new Environment($loader, [ 'debug' => $_ENV['APP_ENV'] === 'development', ]); @@ -24,8 +27,11 @@ class View self::$twig->addFilter(new TwigFilter('buildTime', function ($buildTime) { return @sprintf('%02d:%02d:%02d', $buildTime / 3600, ($buildTime / 60) % 60, $buildTime % 60); })); + } - self::$twig->addGlobal('session', $_SESSION); + public static function addGlobal(string $name, mixed $value): void + { + self::$twig->addGlobal($name, $value); } /** |