public function addFilter($name, $filter = null)
    {
        if (!$name instanceof Twig_SimpleFilter && !($filter instanceof Twig_SimpleFilter || $filter instanceof Twig_FilterInterface)) {
            throw new LogicException('A filter must be an instance of Twig_FilterInterface or Twig_SimpleFilter');
        }

        if ($name instanceof Twig_SimpleFilter) {
            $filter = $name;
            $name = $filter->getName();
        }

        if ($this->extensionInitialized) {
            throw new LogicException(sprintf('Unable to add filter "%s" as extensions have already been initialized.', $name));
        }

        $this->staging->addFilter($name, $filter);
    }
public function addFilter($name, $filter = null)
    {
        if (!$name instanceof Twig_SimpleFilter && !($filter instanceof Twig_SimpleFilter || $filter instanceof Twig_FilterInterface)) {
            throw new LogicException('A filter must be an instance of Twig_FilterInterface or Twig_SimpleFilter');
        }

        if ($name instanceof Twig_SimpleFilter) {
            $filter = $name;
            $name = $filter->getName();
        }

        if ($this->extensionInitialized) {
            throw new LogicException(sprintf('Unable to add filter "%s" as extensions have already been initialized.', $name));
        }

        $this->staging->addFilter($name, $filter);
    }
public function addFilter ( $ name , $ filter = null ) { if ( ! $ name instanceof Twig_SimpleFilter && ! ( $ filter instanceof Twig_SimpleFilter || $ filter instanceof Twig_FilterInterface ) ) { throw new LogicException ( 'A filter must be an instance of Twig_FilterInterface or Twig_SimpleFilter' ) ; } if ( $ name instanceof Twig_SimpleFilter ) { $ filter = $ name ; $ name = $ filter -> getName ( ) ; } if ( $ this -> extensionInitialized ) { throw new LogicException ( sprintf ( 'Unable to add filter "%s" as extensions have already been initialized.' , $ name ) ) ; } $ this -> staging -> addFilter ( $ name , $ filter ) ; }
Registers a Filter.

@param string|Twig_SimpleFilter               $name   The filter name or a Twig_SimpleFilter instance
@param Twig_FilterInterface|Twig_SimpleFilter $filter A Twig_FilterInterface instance or a Twig_SimpleFilter instance
Registers a Filter .