vendor/twig/twig/src/Node/Expression/FilterExpression.php line 20

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