Exemplo n.º 1
0
 public function __construct(IfwPsn_Vendor_Twig_NodeInterface $node, IfwPsn_Vendor_Twig_Node_Expression_Constant $filterName, IfwPsn_Vendor_Twig_NodeInterface $arguments, $lineno, $tag = null)
 {
     $default = new IfwPsn_Vendor_Twig_Node_Expression_Filter($node, new IfwPsn_Vendor_Twig_Node_Expression_Constant('default', $node->getLine()), $arguments, $node->getLine());
     if ('default' === $filterName->getAttribute('value') && ($node instanceof IfwPsn_Vendor_Twig_Node_Expression_Name || $node instanceof IfwPsn_Vendor_Twig_Node_Expression_GetAttr)) {
         $test = new IfwPsn_Vendor_Twig_Node_Expression_Test_Defined(clone $node, 'defined', new IfwPsn_Vendor_Twig_Node(), $node->getLine());
         $false = count($arguments) ? $arguments->getNode(0) : new IfwPsn_Vendor_Twig_Node_Expression_Constant('', $node->getLine());
         $node = new IfwPsn_Vendor_Twig_Node_Expression_Conditional($test, $default, $false, $node->getLine());
     } else {
         $node = $default;
     }
     parent::__construct($node, $filterName, $arguments, $lineno, $tag);
 }
Exemplo n.º 2
0
 protected function preEscapeFilterNode(IfwPsn_Vendor_Twig_Node_Expression_Filter $filter, IfwPsn_Vendor_Twig_Environment $env)
 {
     $name = $filter->getNode('filter')->getAttribute('value');
     $type = $env->getFilter($name)->getPreEscape();
     if (null === $type) {
         return $filter;
     }
     $node = $filter->getNode('node');
     if ($this->isSafeFor($type, $node, $env)) {
         return $filter;
     }
     $filter->setNode('node', $this->getEscaperFilter($type, $node));
     return $filter;
 }