Feature/twig hooks filters (#258)

* feat: Hooks filters

* Cleanup
This commit is contained in:
Slawomir Boczek
2025-03-09 21:39:37 +01:00
committed by slawkens
parent 73a5829974
commit 99997eb57d
6 changed files with 75 additions and 19 deletions

View File

@@ -0,0 +1,28 @@
<?php
namespace MyAAC\Twig;
use Twig\Environment;
class EnvironmentBridge extends Environment
{
public function display($name, array $context = []): void
{
global $hooks;
$context['viewName'] = $name;
$context = $hooks->triggerFilter(HOOK_FILTER_TWIG_DISPLAY, $context);
parent::display($name, $context);
}
public function render($name, array $context = []): string
{
global $hooks;
$context['viewName'] = $name;
$context = $hooks->triggerFilter(HOOK_FILTER_TWIG_RENDER, $context);
return parent::render($name, $context);
}
}