pass twig environment to twig filter filter

This commit is contained in:
Benjamin Dalsass
2022-08-01 10:33:45 +02:00
parent 8188d76f63
commit ca5bbc596e

View File

@@ -143,13 +143,13 @@ class Extension
// @since 2.7.7 3.0.2 3.1.0 N°4867 "Twig content not allowed" error when use the extkey widget search icon in the user portal
// Overwrite native twig filter: disable use of 'system' filter
$aFilters[] = new TwigFilter('filter', function ($array, $arrow) {
$aFilters[] = new TwigFilter('filter', function (Environment $oTwigEnv, $array, $arrow) {
if ($arrow == 'system') {
return json_encode($array);
}
return twig_array_filter($array, $arrow);
});
return twig_array_filter($oTwigEnv, $array, $arrow);
}, ['needs_environment' => true]);
return $aFilters;
}