当前位置: 首页>>代码示例>>PHP>>正文


PHP Twig_Node::getExpression方法代码示例

本文整理汇总了PHP中Twig_Node::getExpression方法的典型用法代码示例。如果您正苦于以下问题:PHP Twig_Node::getExpression方法的具体用法?PHP Twig_Node::getExpression怎么用?PHP Twig_Node::getExpression使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Twig_Node的用法示例。


在下文中一共展示了Twig_Node::getExpression方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: applyFilters

 protected function applyFilters(Twig_Node $node)
 {
     if (false === ($filters = $this->getCurrentFilters())) {
         return $node;
     }
     if ($node instanceof Twig_Node_Text) {
         $expression = new Twig_Node_Expression_Constant($node->getData(), $node->getLine());
     } else {
         $expression = $node->getExpression();
     }
     // filters
     if ($expression instanceof Twig_Node_Expression_Filter) {
         $expression->appendFilters($filters);
         return $node;
     } else {
         return new Twig_Node_Print(new Twig_Node_Expression_Filter($expression, $filters, $node->getLine()), $node->getLine());
     }
 }
开发者ID:te-koyama,项目名称:openpne,代码行数:18,代码来源:Filter.php

示例2: escapeNode

 protected function escapeNode(Twig_Node $node, Twig_Environment $env, $type)
 {
     if (false === $type) {
         return $node;
     }
     $expression = $node instanceof Twig_Node_Print ? $node->getExpression() : $node;
     if ($expression instanceof Twig_Node_Expression_Filter) {
         // don't escape if the primary node of the filter is not a variable
         $nodes = $expression->getNodes();
         if (!$nodes[0] instanceof Twig_Node_Expression_Name) {
             return $node;
         }
         // don't escape if there is already an "escaper" in the filter chain
         $filterMap = $env->getFilters();
         foreach ($expression->getFilters() as $filter) {
             if (isset($filterMap[$filter[0]]) && $filterMap[$filter[0]]->isEscaper()) {
                 return $node;
             }
         }
     } elseif (!$expression instanceof Twig_Node_Expression_GetAttr && !$expression instanceof Twig_Node_Expression_Name) {
         // don't escape if the node is not a variable
         return $node;
     }
     // escape
     if ($expression instanceof Twig_Node_Expression_Filter) {
         // escape all variables in filters arguments
         $filters = $expression->getFilters();
         foreach ($filters as $i => $filter) {
             foreach ($filter[1] as $j => $argument) {
                 $filters[$i][1][$j] = $this->escapeNode($argument, $env, $type);
             }
         }
         $expression->setFilters($filters);
         $expression->prependFilter($this->getEscaperFilter($type));
         return $node;
     } elseif ($node instanceof Twig_Node_Print) {
         return new Twig_Node_Print(new Twig_Node_Expression_Filter($expression, array($this->getEscaperFilter($type)), $node->getLine()), $node->getLine());
     } else {
         return new Twig_Node_Expression_Filter($node, array($this->getEscaperFilter($type)), $node->getLine());
     }
 }
开发者ID:jstanden,项目名称:devblocks,代码行数:41,代码来源:Escaper.php


注:本文中的Twig_Node::getExpression方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。