0

如何从另一个函数过滤另一个过滤器中调用一个函数?例如

public function getFilters()
     {

         return array (
             'test' => new \ Twig_Filter_Method ($this, 'test'),
             'test1' => new \ Twig_Filter_Method ($this, 'test1', array('is_safe' => array('html')))
         );
     }


public function test($test)
{
    return;
}


public function test1($test)
{
    // how to test call?
}

谢谢和对不起我的英语

4

1 回答 1

0

From twig template you can do that like this:

{{ 'Some string'|test|test1('argument')}}

Inside twig extension class you can call test function like regular php object function:

public function test1($test)
{
    // your code
    $testResult = $this->test($test);
}
于 2013-08-07T13:51:18.940 回答