Hi community,
I am trying to define my own function but it lags at the very beginning. In my services.php I have my service "view" where I add the engine "Volt" and the custom function but in the view I try to call this function {{ tata("df") }} and there comes the exception.
$di->set('view', function() use ($config) {
$view = new \Phalcon\Mvc\View();
$view->setViewsDir($config->application->viewsDir);
$view->registerEngines(array(
// '.volt' => "voltService"
'.volt' => function ($view, $di) use ($config) {
$volt = new Phalcon\Mvc\View\Engine\Volt($view, $di);
$volt->setOptions(array(
'compiledPath' => $config->application->cacheDir,
'compiledSeparator' => '_'
));
// This does not work either
// $compiler= $volt->getCompiler();
// $compiler->addFunction("eike", function($str) {
// return "xdebug_var_dump($str)";
// });
$volt->getCompiler()->addFunction(
'tata',
function ($key) {
return "xdebug_var_dump({$key})";
}
);
return $volt;
}
));
return $view;
}, true);
greetings Eike