1<?php 2 3/* 4 * This file is part of Twig. 5 * 6 * (c) Fabien Potencier 7 * (c) Armin Ronacher 8 * 9 * For the full copyright and license information, please view the LICENSE 10 * file that was distributed with this source code. 11 */ 12 13namespace Twig\Node\Expression; 14 15use Twig\Compiler; 16use Twig\Node\Node; 17 18class FilterExpression extends CallExpression 19{ 20 public function __construct(Node $node, ConstantExpression $filterName, Node $arguments, int $lineno, string $tag = null) 21 { 22 parent::__construct(['node' => $node, 'filter' => $filterName, 'arguments' => $arguments], [], $lineno, $tag); 23 } 24 25 public function compile(Compiler $compiler) 26 { 27 $name = $this->getNode('filter')->getAttribute('value'); 28 $filter = $compiler->getEnvironment()->getFilter($name); 29 30 $this->setAttribute('name', $name); 31 $this->setAttribute('type', 'filter'); 32 $this->setAttribute('needs_environment', $filter->needsEnvironment()); 33 $this->setAttribute('needs_context', $filter->needsContext()); 34 $this->setAttribute('arguments', $filter->getArguments()); 35 $this->setAttribute('callable', $filter->getCallable()); 36 $this->setAttribute('is_variadic', $filter->isVariadic()); 37 38 $this->compileCallable($compiler); 39 } 40} 41 42class_alias('Twig\Node\Expression\FilterExpression', 'Twig_Node_Expression_Filter'); 43