Not a member of Pastebin yet?
                        Sign Up,
                        it unlocks many cool features!                    
                - <?php
 - class TwigPHPExtension extends \Twig_Extension {
 - public function getName()
 - {
 - return 'php_twig_extension';
 - }
 - public function getFunctions()
 - {
 - return array(
 - new \Twig_SimpleFunction('php_*', array($this,'phpFunctions'),array('is_safe' => array('html')))
 - );
 - }
 - public function phpFunctions()
 - {
 - $arg_list = func_get_args();
 - $function = array_shift($arg_list);
 - if(is_callable($function)){
 - return call_user_func_array($function, $arg_list);
 - }
 - $errMsg = 'Called to an undefined function : <b>php_' . $function . "</b> ";
 - trigger_error($errMsg, E_USER_NOTICE);
 - return NULL;
 - }
 - }
 
Advertisement
 
                    Add Comment                
                
                        Please, Sign In to add comment