Thanks for this first of all. But I am getting this error when calling the method to add a custom function:
Message: Argument 2 passed to Twig::register_function() must implement interface Twig_FunctionInterface, none given,
And I was calling something like this $this->twig->register_function('test', $template);