If you want to add a new function, you can do it in your bootstrap file. Mine looks like this:
$DI->set('view',function() use($Config){
$View = new \Phalcon\Mvc\View();
$View->setViewsDir($Config->dirs->views);
$View->registerEngines(['.phtml'=> function($View,$DI) use ($Config){
$Volt = new \Phalcon\Mvc\View\Engine\Volt($View,$DI);
$Volt->setOptions([ 'compiledPath' => $Config->dirs->views_compile,
'compileAlways' => $Config->views_always_compile,
'compiledSeparator' => '::'
]);
$Compiler = $Volt->getCompiler();
$Compiler->addFunction('strtotime','strtotime');
$Compiler->addFunction('number_format','number_format');
$Compiler->addFunction('trim','trim');
$Compiler->addFilter('e_char',function($resolvedArgs,$exprArgs){
return 'htmlspecialchars('.$resolvedArgs.')';
});
return $Volt;
}]);
return $View;
});
I haven't tried it, but you may be able to use a closure as the second argument to addFunction() instead of a string.