I need to know how can I get a filter from another filter, I have the next code. Maybe I have to use Twig_Enviroment, but I don't how.
The Idea is:
- The filter A converts a number in words. This is done.
The filter B should use filter A to convert a currency value to words.
class CurrencyToWordsExtension extends \Twig_Extension { public function getFilters() { return array( new \Twig_SimpleFilter('currencyToWords', array($this, 'currencyToWordsFilter')) ); }
function currencyToWordsFilter($number) { // $toWords = $env->getFilter('toWords'); $number = number_format((float)$number, 2); $pesos = floor($number); $centavos = ($number - $pesos) * 100; return $pesos .' con '. $centavos; } public function getName() { return 'currencyToWords'; }
}