Should be possible to define some php functions in configuration to use them in twig. This can be done by the magic function __call.