2013-08-07 81 views
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? 
} 

感謝和抱歉,我的英語

回答

0

從樹枝模板可以是這樣做的:

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

裏面樹枝擴展類,你可以調用test功能像普通PHP對象功能:

public function test1($test) 
{ 
    // your code 
    $testResult = $this->test($test); 
}