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


PHP Twig_NodeInterface::getAttribute方法代碼示例

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


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

示例1: compileString

 protected function compileString(\Twig_NodeInterface $body, \Twig_Node_Expression_Array $vars)
 {
     if ($body instanceof \Twig_Node_Expression_Constant) {
         $msg = $body->getAttribute('value');
     } elseif ($body instanceof \Twig_Node_Text) {
         $msg = $body->getAttribute('data');
     } else {
         return array($body, $vars);
     }
     preg_match_all('/(?<!%)%([^%]+)%/', $msg, $matches);
     if (version_compare(\Twig_Environment::VERSION, '1.5', '>=')) {
         foreach ($matches[1] as $var) {
             $key = new \Twig_Node_Expression_Constant('%' . $var . '%', $body->getLine());
             if (!$vars->hasElement($key)) {
                 $vars->addElement(new \Twig_Node_Expression_Name($var, $body->getLine()), $key);
             }
         }
     } else {
         $current = array();
         foreach ($vars as $name => $var) {
             $current[$name] = true;
         }
         foreach ($matches[1] as $var) {
             if (!isset($current['%' . $var . '%'])) {
                 $vars->setNode('%' . $var . '%', new \Twig_Node_Expression_Name($var, $body->getLine()));
             }
         }
     }
     return array(new \Twig_Node_Expression_Constant(str_replace('%%', '%', trim($msg)), $body->getLine()), $vars);
 }
開發者ID:miguelibero,項目名稱:meinhof,代碼行數:30,代碼來源:TransNode.php

示例2: enterNode

 /**
  * Called before child nodes are visited.
  *
  * @param Twig_NodeInterface $node The node to visit
  * @param Twig_Environment   $env  The Twig environment instance
  *
  * @return Twig_NodeInterface The modified node
  */
 public function enterNode(Twig_NodeInterface $node, Twig_Environment $env)
 {
     if ($node instanceof Twig_Node_Module) {
         $this->inAModule = true;
         $this->tags = array();
         $this->filters = array();
         $this->functions = array();
         return $node;
     } elseif ($this->inAModule) {
         // look for tags
         if ($node->getNodeTag() && !isset($this->tags[$node->getNodeTag()])) {
             $this->tags[$node->getNodeTag()] = $node;
         }
         // look for filters
         if ($node instanceof Twig_Node_Expression_Filter && !isset($this->filters[$node->getNode('filter')->getAttribute('value')])) {
             $this->filters[$node->getNode('filter')->getAttribute('value')] = $node;
         }
         // look for functions
         if ($node instanceof Twig_Node_Expression_Function && !isset($this->functions[$node->getAttribute('name')])) {
             $this->functions[$node->getAttribute('name')] = $node;
         }
         // wrap print to check __toString() calls
         if ($node instanceof Twig_Node_Print) {
             return new Twig_Node_SandboxedPrint($node->getNode('expr'), $node->getLine(), $node->getNodeTag());
         }
     }
     return $node;
 }
開發者ID:TheTypoMaster,項目名稱:SPHERE-Framework,代碼行數:36,代碼來源:Sandbox.php

示例3: enterNode

 /**
  * Called before child nodes are visited.
  *
  * @param Twig_NodeInterface $node The node to visit
  * @param Twig_Environment   $env  The Twig environment instance
  *
  * @param Twig_NodeInterface The modified node
  */
 public function enterNode(Twig_NodeInterface $node, Twig_Environment $env)
 {
     if ($node instanceof Twig_Node_AutoEscape) {
         $this->statusStack[] = $node->getAttribute('value');
     } elseif ($node instanceof Twig_Node_Block) {
         $this->statusStack[] = isset($this->blocks[$node->getAttribute('name')]) ? $this->blocks[$node->getAttribute('name')] : $this->needEscaping($env);
     }
     return $node;
 }
開發者ID:bigjoevtrj,項目名稱:codeigniter-bootstrap,代碼行數:17,代碼來源:Escaper.php

示例4: enterNode

 /**
  * Called before child nodes are visited.
  *
  * @param Twig_NodeInterface $node The node to visit
  * @param Twig_Environment   $env  The Twig environment instance
  *
  * @return Twig_NodeInterface The modified node
  */
 public function enterNode(Twig_NodeInterface $node, Twig_Environment $env)
 {
     if ($node instanceof Twig_Node_Module) {
         if ($env->hasExtension('escaper') && ($defaultStrategy = $env->getExtension('escaper')->getDefaultStrategy($node->getAttribute('filename')))) {
             $this->defaultStrategy = $defaultStrategy;
         }
     } elseif ($node instanceof Twig_Node_AutoEscape) {
         $this->statusStack[] = $node->getAttribute('value');
     } elseif ($node instanceof Twig_Node_Block) {
         $this->statusStack[] = isset($this->blocks[$node->getAttribute('name')]) ? $this->blocks[$node->getAttribute('name')] : $this->needEscaping($env);
     }
     return $node;
 }
開發者ID:Zyko0,項目名稱:Baikal,代碼行數:21,代碼來源:Escaper.php

示例5: leaveNode

 /**
  * {@inheritdoc}
  */
 public function leaveNode(Twig_NodeInterface $node, Twig_Environment $env)
 {
     if ($node instanceof Twig_Node_Module) {
         $varName = $this->getVarName();
         $node->setNode('display_start', new Twig_Node(array(new Twig_Profiler_Node_EnterProfile($this->extensionName, Twig_Profiler_Profile::TEMPLATE, $node->getAttribute('filename'), $varName), $node->getNode('display_start'))));
         $node->setNode('display_end', new Twig_Node(array(new Twig_Profiler_Node_LeaveProfile($varName), $node->getNode('display_end'))));
     } elseif ($node instanceof Twig_Node_Block) {
         $varName = $this->getVarName();
         $node->setNode('body', new Twig_Node_Body(array(new Twig_Profiler_Node_EnterProfile($this->extensionName, Twig_Profiler_Profile::BLOCK, $node->getAttribute('name'), $varName), $node->getNode('body'), new Twig_Profiler_Node_LeaveProfile($varName))));
     } elseif ($node instanceof Twig_Node_Macro) {
         $varName = $this->getVarName();
         $node->setNode('body', new Twig_Node_Body(array(new Twig_Profiler_Node_EnterProfile($this->extensionName, Twig_Profiler_Profile::MACRO, $node->getAttribute('name'), $varName), $node->getNode('body'), new Twig_Profiler_Node_LeaveProfile($varName))));
     }
     return $node;
 }
開發者ID:neteasy-work,項目名稱:hkgbf_crm,代碼行數:18,代碼來源:Profiler.php

示例6: enterNode

 /**
  * {@inheritdoc}
  */
 public function enterNode(\Twig_NodeInterface $node, \Twig_Environment $env)
 {
     if ($node instanceof \Twig_Node_Expression_Function && 'constant' === $node->getAttribute('name') && 1 === $node->count() && null !== ($resolved = $this->resolve($node))) {
         return $this->resolve($node);
     }
     return $node;
 }
開發者ID:silentroach,項目名稱:twig-const-resolver,代碼行數:10,代碼來源:NodeVisitor.php

示例7: enterNode

 /**
  * {@inheritdoc}
  */
 public function enterNode(Twig_NodeInterface $node, Twig_Environment $env)
 {
     if ($node instanceof Twig_Node_Expression_Name) {
         print $node->getAttribute('name') . "\n";
     }
     return $node;
 }
開發者ID:hmmbug,項目名稱:unbindery,代碼行數:10,代碼來源:VariableAnalyzer.php

示例8: compile

 /**
  * Compiles a node.
  *
  * @param Twig_NodeInterface $node        The node to compile
  * @param int                $indentation The current indentation
  *
  * @return Twig_Compiler The current compiler instance
  */
 public function compile(Twig_NodeInterface $node, $indentation = 0)
 {
     $this->lastLine = null;
     $this->source = '';
     $this->debugInfo = array();
     $this->sourceOffset = 0;
     // source code starts at 1 (as we then increment it when we encounter new lines)
     $this->sourceLine = 1;
     $this->indentation = $indentation;
     if ($node instanceof Twig_Node_Module) {
         $node->setFilename($node->getAttribute('filename'));
         // to be removed in 2.0
         $this->filename = $node->getAttribute('filename');
     }
     $node->compile($this);
     return $this;
 }
開發者ID:indigo423,項目名稱:blog.no42.org,代碼行數:25,代碼來源:Compiler.php

示例9: leaveNode

 /**
  * Called after child nodes are visited.
  *
  * @param Twig_NodeInterface $node The node to visit
  * @param Twig_Environment   $env  The Twig environment instance
  *
  * @param Twig_NodeInterface The modified node
  */
 public function leaveNode(Twig_NodeInterface $node, Twig_Environment $env)
 {
     if ($node instanceof Twig_Node_AutoEscape || $node instanceof Twig_Node_Block) {
         array_pop($this->statusStack);
     } elseif ($node instanceof Twig_Node_BlockReference) {
         $this->blocks[$node->getAttribute('name')] = $this->needEscaping($env);
     }
     return $node;
 }
開發者ID:kuzmichus,項目名稱:schoolreg,代碼行數:17,代碼來源:Escaper.php

示例10: compileString

 protected function compileString(\Twig_NodeInterface $body, \Twig_Node_Expression_Array $vars)
 {
     if ($body instanceof \Twig_Node_Expression_Constant) {
         $msg = $body->getAttribute('value');
     } elseif ($body instanceof \Twig_Node_Text) {
         $msg = $body->getAttribute('data');
     } else {
         return array($body, $vars);
     }
     preg_match_all('/(?<!%)%([^%]+)%/', $msg, $matches);
     foreach ($matches[1] as $var) {
         $key = new \Twig_Node_Expression_Constant('%' . $var . '%', $body->getLine());
         if (!$vars->hasElement($key)) {
             $vars->addElement(new \Twig_Node_Expression_Name($var, $body->getLine()), $key);
         }
     }
     return array(new \Twig_Node_Expression_Constant(str_replace('%%', '%', trim($msg)), $body->getLine()), $vars);
 }
開發者ID:TuxCoffeeCorner,項目名稱:tcc,代碼行數:18,代碼來源:TransNode.php

示例11: leaveNode

 public function leaveNode(\Twig_NodeInterface $node, \Twig_Environment $env)
 {
     if ($node instanceof TwigJsNode) {
         if ($node->hasAttribute('name')) {
             $this->moduleNode->setAttribute('twig_js_name', $node->getAttribute('name'));
         }
         return false;
     }
     return $node;
 }
開發者ID:raphydev,項目名稱:onep,代碼行數:10,代碼來源:TwigJsNodeVisitor.php

示例12: compileString

 protected function compileString(\Twig_NodeInterface $body, \Twig_Node_Expression_Array $vars)
 {
     if ($body instanceof \Twig_Node_Expression_Constant) {
         $msg = $body->getAttribute('value');
     } elseif ($body instanceof \Twig_Node_Text) {
         $msg = $body->getAttribute('data');
     } else {
         return array($body, $vars);
     }
     $current = array();
     foreach ($vars as $name => $var) {
         $current[$name] = true;
     }
     preg_match_all('/\\%([^\\%]+)\\%/', $msg, $matches);
     foreach ($matches[1] as $var) {
         if (!isset($current['%' . $var . '%'])) {
             $vars->setNode('%' . $var . '%', new \Twig_Node_Expression_Name($var, $body->getLine()));
         }
     }
     return array(new \Twig_Node_Expression_Constant(trim($msg), $body->getLine()), $vars);
 }
開發者ID:nickaggarwal,項目名稱:sample-symfony2,代碼行數:21,代碼來源:TransNode.php

示例13: leaveNode

 public function leaveNode(\Twig_NodeInterface $node, \Twig_Environment $env)
 {
     if ($node instanceof \Twig_Node_Module) {
         $this->currentModule = null;
     } elseif ($node instanceof \Twig_Node_Expression_Function) {
         $name = $node->getAttribute('name');
         if ('render_documents' == $name) {
             $this->currentRenderDocuments = null;
         }
     }
     return $node;
 }
開發者ID:carew,項目名稱:carew,代碼行數:12,代碼來源:Paginator.php

示例14: compileString

 protected function compileString(\Twig_NodeInterface $body, \Twig_Node_Expression_Array $vars, $ignoreStrictCheck = false)
 {
     if ($body instanceof \Twig_Node_Expression_Constant) {
         $msg = $body->getAttribute('value');
     } elseif ($body instanceof \Twig_Node_Text) {
         $msg = $body->getAttribute('data');
     } else {
         return array($body, $vars);
     }
     preg_match_all('/(?<!%)%([^%]+)%/', $msg, $matches);
     foreach ($matches[1] as $var) {
         $key = new \Twig_Node_Expression_Constant('%' . $var . '%', $body->getLine());
         if (!$vars->hasElement($key)) {
             if ('count' === $var && null !== $this->getNode('count')) {
                 $vars->addElement($this->getNode('count'), $key);
             } else {
                 $varExpr = new \Twig_Node_Expression_Name($var, $body->getLine());
                 $varExpr->setAttribute('ignore_strict_check', $ignoreStrictCheck);
                 $vars->addElement($varExpr, $key);
             }
         }
     }
     return array(new \Twig_Node_Expression_Constant(str_replace('%%', '%', trim($msg)), $body->getLine()), $vars);
 }
開發者ID:neteasy-work,項目名稱:hkgbf_crm,代碼行數:24,代碼來源:TransNode.php

示例15: enterNode

 public function enterNode(\Twig_NodeInterface $node, \Twig_Environment $env)
 {
     $this->stack[] = $node;
     if ($node instanceof \Twig_Node_Expression_Function) {
         $name = $node->getAttribute('name');
         if (in_array($name, $this->methodNames)) {
             $args = $node->getNode('arguments');
             switch ($name) {
                 case '_n':
                 case '_fn':
                     $id = $args->getNode(0)->getAttribute('value') . '|' . $args->getNode(1)->getAttribute('value');
                     break;
                 default:
                 case '__f':
                 case '__':
                     $id = $args->getNode(0)->getAttribute('value');
                     break;
             }
             // obtain translation domain from composer file
             $composerPath = str_replace($this->file->getRelativePathname(), '', $this->file->getPathname());
             if (isset(self::$domainCache[$composerPath])) {
                 $domain = self::$domainCache[$composerPath];
             } else {
                 $scanner = new Scanner();
                 $scanner->scan(array($composerPath), 1);
                 $metaData = $scanner->getModulesMetaData(true);
                 $domains = array_keys($metaData);
                 if (isset($domains[0])) {
                     $domain = strtolower($domains[0]);
                     // cache result of file lookup
                     self::$domainCache[$composerPath] = $domain;
                 } else {
                     $domain = 'messages';
                 }
             }
             $domainNode = array_search($name, $this->methodNames);
             $domain = $args->hasNode($domainNode) ? $args->getNode($domainNode)->getAttribute('value') : $domain;
             $message = new Message($id, $domain);
             $message->addSource(new FileSource((string) $this->file, $node->getLine()));
             $this->catalogue->add($message);
         }
     }
     return $node;
 }
開發者ID:rmaiwald,項目名稱:core,代碼行數:44,代碼來源:ZikulaTwigFileExtractor.php


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