public function getFunctions() {
return array(
'foo' => new Twig_Function_Method($this, 'bar');
);
}
public function bar($baz) {
return $this->foo . $baz;
}
Look at all the different classes that extend Twig_Function
for all the different ways to specify template functions.
For the newer Twig_SimpleFunction
, it seems you can pass any kind of callable
as the second argument to the constructor:
new Twig_SimpleFunction('foo', array($this, 'bar'))