当前位置: 首页>>代码示例>>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;未经允许,请勿转载。