Twig_Environment::getFilters PHP Method

getFilters() public method

public getFilters ( )
    public function getFilters()
    {
        if (null === $this->filters) {
            $this->filters = array();
            foreach ($this->getExtensions() as $extension) {
                $this->filters = array_merge($this->filters, $extension->getFilters());
            }
        }

        return $this->filters;
    }

Usage Example

コード例 #1
0
 public function leaveNode(Twig_NodeInterface $node, Twig_Environment $env)
 {
     if ($node instanceof Twig_Node_Expression_Constant) {
         // constants are marked safe for all
         $this->setSafe($node, array('all'));
     } elseif ($node instanceof Twig_Node_Expression_Conditional) {
         // instersect safeness of both operands
         $safe = $this->intersectSafe($this->getSafe($node->getNode('expr2')), $this->getSafe($node->getNode('expr3')));
         $this->setSafe($node, $safe);
     } elseif ($node instanceof Twig_Node_Expression_Filter) {
         // filter expression is safe when the filter is safe
         $filterMap = $env->getFilters();
         $name = $node->getNode('filter')->getAttribute('value');
         $args = $node->getNode('arguments');
         if (isset($filterMap[$name])) {
             $this->setSafe($node, $filterMap[$name]->getSafe($args));
         } else {
             $this->setSafe($node, array());
         }
     } elseif ($node instanceof Twig_Node_Expression_Function) {
         // function expression is safe when the function is safe
         $name = $node->getNode('name')->getAttribute('name');
         $args = $node->getNode('arguments');
         $function = $env->getFunction($name);
         if (null !== $function) {
             $this->setSafe($node, $function->getSafe($args));
         } else {
             $this->setSafe($node, array());
         }
     } else {
         $this->setSafe($node, array());
     }
     return $node;
 }
All Usage Examples Of Twig_Environment::getFilters