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


PHP Twig_NodeInterface::getIterator方法代码示例

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


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

示例1: enterNode

 /**
  * Defined by Twig_NodeVisitorInterface
  *
  * Extracts messages from calls to the translate function.
  */
 public function enterNode(\Twig_NodeInterface $node, \Twig_Environment $env)
 {
     if ($node instanceof \Skeleton\I18n\Template\Twig\Extension\Node\Trans\Tigron) {
         if ($node->getNodeTag() == 'trans') {
             $this->extracted[] = $node->getNode('body')->getAttribute('value');
         }
     } elseif ($node instanceof \Twig_Node_Print) {
         $n = $node->getNode('expr');
         while ($n instanceof \Twig_Node_Expression_Filter) {
             $filter = null;
             if ($n->hasNode('filter')) {
                 $filter = $n->getNode('filter')->getAttribute('value');
             }
             $n = $n->getNode('node');
             if ($n instanceof \Twig_Node_Expression_Constant and $filter == 'trans') {
                 $this->extracted[] = $n->getAttribute('value');
             }
         }
     } elseif ($node instanceof \Twig_Node_Expression_Array) {
         $data = $node->getIterator();
         foreach ($data as $row) {
             if ($row instanceof \Twig_Node_Expression_Filter) {
                 if ($row->hasNode('filter') and $row->getNode('filter')->getAttribute('value') == 'trans') {
                     $this->extracted[] = $row->getNode('node')->getAttribute('value');
                 }
             }
         }
     }
     return $node;
 }
开发者ID:tigron,项目名称:skeleton-i18n,代码行数:35,代码来源:Twig.php

示例2: getDependencies

 /**
  * Parses module dependencies from Twig AST.
  *
  * @param JsCompiler          $compiler
  * @param \Twig_NodeInterface $node
  *
  * @return array of dependencies
  */
 private function getDependencies(JsCompiler $compiler, \Twig_NodeInterface $node)
 {
     $dependencies = ['files' => [], 'functions' => []];
     $stack = iterator_to_array($node->getIterator());
     while (count($stack)) {
         $subNode = array_shift($stack);
         if (!$subNode instanceof \Twig_Node) {
             continue;
         }
         if ($subNode instanceof \Twig_Node_Include || $subNode instanceof \Twig_Node_Import) {
             $expr = $subNode->getNode('expr');
             $env = $compiler->getEnvironment();
             $path = $expr->getAttribute('value');
             $source = $env->getLoader()->getSource($path);
             $module = $env->parse($env->tokenize($source, $path));
             $name = $compiler->getFunctionName($module);
             array_push($dependencies['files'], $name . 'Template');
             array_push($dependencies['functions'], $name);
         } elseif ($subNode->count()) {
             $stack = array_merge(iterator_to_array($subNode->getIterator()), $stack);
         }
     }
     return $dependencies;
 }
开发者ID:redco,项目名称:twigjs-compiler,代码行数:32,代码来源:RequireModuleCompiler.php


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