當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Twig_Node::hasAttribute方法代碼示例

本文整理匯總了PHP中Twig_Node::hasAttribute方法的典型用法代碼示例。如果您正苦於以下問題:PHP Twig_Node::hasAttribute方法的具體用法?PHP Twig_Node::hasAttribute怎麽用?PHP Twig_Node::hasAttribute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Twig_Node的用法示例。


在下文中一共展示了Twig_Node::hasAttribute方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: loadNode

 /**
  * Loads assets from the supplied node.
  *
  * @param \Twig_Node $node
  *
  * @return array An array of asset formulae indexed by name
  */
 private function loadNode(\Twig_Node $node)
 {
     $formulae = array();
     if ($node instanceof AsseticNode) {
         $formulae[$node->getAttribute('name')] = array($node->getAttribute('inputs'), $node->getAttribute('filters'), array('output' => $node->getAttribute('asset')->getTargetPath(), 'name' => $node->getAttribute('name'), 'debug' => $node->getAttribute('debug'), 'combine' => $node->getAttribute('combine'), 'vars' => $node->getAttribute('vars')));
     } elseif ($node instanceof \Twig_Node_Expression_Function) {
         $name = version_compare(\Twig_Environment::VERSION, '1.2.0-DEV', '<') ? $node->getNode('name')->getAttribute('name') : $node->getAttribute('name');
         if ($this->twig->getFunction($name) instanceof AsseticFilterFunction) {
             $arguments = array();
             foreach ($node->getNode('arguments') as $argument) {
                 $arguments[] = eval('return ' . $this->twig->compile($argument) . ';');
             }
             $invoker = $this->twig->getExtension('assetic')->getFilterInvoker($name);
             $inputs = isset($arguments[0]) ? (array) $arguments[0] : array();
             $filters = $invoker->getFilters();
             $options = array_replace($invoker->getOptions(), isset($arguments[1]) ? $arguments[1] : array());
             if (!isset($options['name'])) {
                 $options['name'] = $invoker->getFactory()->generateAssetName($inputs, $filters, $options);
             }
             $formulae[$options['name']] = array($inputs, $filters, $options);
         }
     }
     foreach ($node as $child) {
         if ($child instanceof \Twig_Node) {
             $formulae += $this->loadNode($child);
         }
     }
     if ($node->hasAttribute('embedded_templates')) {
         foreach ($node->getAttribute('embedded_templates') as $child) {
             $formulae += $this->loadNode($child);
         }
     }
     return $formulae;
 }
開發者ID:tahermarkos,項目名稱:Transport,代碼行數:41,代碼來源:TwigFormulaLoader.php

示例2: loadNode

 /**
  * Loads assets from the supplied node.
  *
  * @param \Twig_Node $node
  *
  * @return array An array of asset formulae indexed by name
  */
 private function loadNode(\Twig_Node $node)
 {
     $formulae = array();
     if ($node instanceof AsseticNode) {
         $formulae[$node->getAttribute('name')] = array($node->getAttribute('inputs'), $node->getAttribute('filters'), array('output' => $node->getAttribute('asset')->getTargetPath(), 'name' => $node->getAttribute('name'), 'debug' => $node->getAttribute('debug'), 'combine' => $node->getAttribute('combine'), 'vars' => $node->getAttribute('vars')));
     } elseif ($node instanceof \Twig_Node_Expression_Function) {
         $name = $node->getAttribute('name');
         if ($this->twig->getFunction($name) instanceof AsseticFilterFunction) {
             $arguments = array();
             foreach ($node->getNode('arguments') as $argument) {
                 $arguments[] = eval('return ' . $this->twig->compile($argument) . ';');
             }
             $invoker = $this->twig->getExtension('assetic')->getFilterInvoker($name);
             $inputs = isset($arguments[0]) ? (array) $arguments[0] : array();
             $filters = $invoker->getFilters();
             $options = array_replace($invoker->getOptions(), isset($arguments[1]) ? $arguments[1] : array());
             if (!isset($options['name'])) {
                 $options['name'] = $invoker->getFactory()->generateAssetName($inputs, $filters, $options);
             }
             $formulae[$options['name']] = array($inputs, $filters, $options);
         }
     }
     foreach ($node as $child) {
         if ($child instanceof \Twig_Node) {
             $formulae += $this->loadNode($child);
         }
     }
     if ($node->hasAttribute('embedded_templates')) {
         foreach ($node->getAttribute('embedded_templates') as $child) {
             $formulae += $this->loadNode($child);
         }
     }
     $formulaes = array();
     $asseticDebug = $this->app['assetic.debug'];
     foreach ($formulae as $n => $f) {
         list($inputs, $filters, $options) = $f;
         // 當沒有資源或此資源已被解開過的時候
         if (count($inputs) > 0 && strlen($n) <= 7 && ($asseticDebug == true || $options['debug'] === true || $options['combine'] === false)) {
             $path = pathinfo($options['output']);
             $counter = 1;
             foreach ($inputs as $input) {
                 $inputPath = pathinfo($input);
                 $_name = $n . '_' . md5($input);
                 $_inputs = array($input);
                 $_filters = $filters;
                 $_options = array('output' => "{$path['dirname']}/{$path['filename']}_{$inputPath['filename']}_{$counter}.{$path['extension']}", 'name' => "{$path['filename']}_{$inputPath['filename']}_{$counter}") + $options;
                 $formulaes[$_name] = array($_inputs, $_filters, $_options);
                 $counter++;
             }
         } else {
             $formulaes[$n] = $f;
         }
     }
     $formulae = $formulaes;
     return $formulae;
 }
開發者ID:wake,項目名稱:twig-assetic-integration-provider,代碼行數:63,代碼來源:TwigAsseticIntegrationFormulaLoader.php

示例3: getAttribute

 /**
  * @param \Twig_Node $node
  * @param $name
  * @return mixed|null
  */
 public function getAttribute(\Twig_Node $node, $name)
 {
     return $node->hasAttribute($name) ? $node->getAttribute($name) : null;
 }
開發者ID:selmanouni,項目名稱:blue-lines,代碼行數:9,代碼來源:TwigDataExtractor.php


注:本文中的Twig_Node::hasAttribute方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。