Answer the question
In order to leave comments, you need to log in
Why doesn't the twig extension work correctly?
function views($name, $array = []) {
$twig = new \Twig_Environment(new \Twig_Loader_Filesystem(__DIR__ . '/../app/resources/views'), [
'cache' => __DIR__ . '/../storage/cache/views'
]);
$twig->addFunction(new Twig_SimpleTest('Lang', function ($key) {
return \Lang::Get($key);
}));
return $twig->render($name, $array);
}
Answer the question
In order to leave comments, you need to log in
$twig->addFunction(new Twig_SimpleTest(...));
The error says - you need to create an object that implements the Twig_FunctionInterface interface or a Twig_SimpleFunction object. And you passed an object of the Twig_SimpleTest() class.
Maybe you have a syntax error? Twig_SimpleTest -> Twig_SimpleFunction
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question