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
This commit is contained in:
Vladimir Tomashevskiy 2026-02-08 15:43:48 +00:00
parent f6aebd8b66
commit 1c98327de3
1 changed files with 12 additions and 0 deletions

View File

@ -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
// ========================================