From 1c98327de3fb998e07c618415f6b7ca3d1553bf4 Mon Sep 17 00:00:00 2001 From: Vladimir Tomashevskiy Date: Sun, 8 Feb 2026 15:43:48 +0000 Subject: [PATCH] Add csrf_token and csrf_hash Twig functions - Add csrf_token() function to return CSRF token name - Add csrf_hash() function to return CSRF hash value --- app/Libraries/Twig/TwigGlobalsExtension.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/Libraries/Twig/TwigGlobalsExtension.php b/app/Libraries/Twig/TwigGlobalsExtension.php index fdc77f2..4bf45a5 100644 --- a/app/Libraries/Twig/TwigGlobalsExtension.php +++ b/app/Libraries/Twig/TwigGlobalsExtension.php @@ -52,6 +52,8 @@ class TwigGlobalsExtension extends AbstractExtension new TwigFunction('is_module_active', [$this, 'isModuleActive'], ['is_safe' => ['html']]), new TwigFunction('is_module_available', [$this, 'isModuleAvailable'], ['is_safe' => ['html']]), new TwigFunction('csrf_meta', [$this, 'csrf_meta'], ['is_safe' => ['html']]), + new TwigFunction('csrf_token', [$this, 'csrf_token'], ['is_safe' => ['html']]), + new TwigFunction('csrf_hash', [$this, 'csrf_hash'], ['is_safe' => ['html']]), ]; } @@ -59,6 +61,16 @@ class TwigGlobalsExtension extends AbstractExtension { return csrf_meta(); } + + public function csrf_token(): string + { + return csrf_token(); + } + + public function csrf_hash(): string + { + return csrf_hash(); + } // ======================================== // Access Functions для Twig // ========================================