/** * Load all filters provided by the current extension into the TwigRenderizer * * @param TwigRenderizer $renderizer Twig renderizer */ public function load(TwigRenderizer $renderizer) { $filters = $this->extension->getFilters(); foreach ($filters as $filter) { $name = $filter->getName(); $callable = $filter->getCallable(); $options = array('needs_environment' => $filter->needsEnvironment()); $renderizer->addTwigFilter($name, $callable, $options); } }
public function getFilters() { return array('sm_absolutize' => new \Twig_Filter_Method($this, 'getAbsoluteUrl'), 'sm_format_date' => new \Twig_Filter_Method($this, 'getFormattedDate')); return parent::getFilters(); }