當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。