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


PHP Twig_Parser::getEnvironment方法代码示例

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


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

示例1: parseTestExpression

 public function parseTestExpression(Twig_Parser $parser, $node)
 {
     $stream = $parser->getStream();
     $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
     $arguments = null;
     if ($stream->test(Twig_Token::PUNCTUATION_TYPE, '(')) {
         $arguments = $parser->getExpressionParser()->parseArguments();
     }
     $class = $this->getTestNodeClass($parser->getEnvironment(), $name);
     return new $class($node, $name, $arguments, $parser->getCurrentToken()->getLine());
 }
开发者ID:carlesgutierrez,项目名称:libreobjet.org,代码行数:11,代码来源:Core.php

示例2: __construct

 public function __construct(Twig_Parser $parser, Twig_Environment $env = null)
 {
     $this->parser = $parser;
     if ($env instanceof Twig_Environment) {
         $this->env = $env;
         $this->unaryOperators = $env->getUnaryOperators();
         $this->binaryOperators = $env->getBinaryOperators();
     } else {
         @trigger_error('Passing the operators as constructor arguments to ' . __METHOD__ . ' is deprecated since version 1.27. Pass the environment instead.', E_USER_DEPRECATED);
         $this->env = $parser->getEnvironment();
         $this->unaryOperators = func_get_arg(1);
         $this->binaryOperators = func_get_arg(2);
     }
 }
开发者ID:bigbitecreative,项目名称:wordpress-git-content,代码行数:14,代码来源:ExpressionParser.php

示例3: parseInline

 private function parseInline(\Twig_TokenStream $stream, $lineno)
 {
     $stream->expect(\Twig_Token::BLOCK_END_TYPE);
     $this->parser->subparse(function ($token) {
         return $token->test(['end' . $this->getTag()]);
     }, true);
     $stream->expect(\Twig_Token::BLOCK_END_TYPE);
     $file = $this->parser->getEnvironment()->getLoader()->getCacheKey($stream->getFilename());
     if (!isset($this->inline_blocks[$file])) {
         $this->inline_blocks[$file] = 0;
     }
     $file_name = md5($file . $this->inline_blocks[$file]) . ".js";
     $assets = $this->extension->webpackAsset('cache.' . $file_name);
     $this->inline_blocks[$file]++;
     return new WebpackInlineNode(['js_file' => $assets['js'], 'css_file' => $assets['css']], $lineno, $this->getTag());
 }
开发者ID:studionone,项目名称:webpack-bundle,代码行数:16,代码来源:WebpackTokenParser.php

示例4: getTestNodeClass

 protected function getTestNodeClass(Twig_Parser $parser, $name)
 {
     $env = $parser->getEnvironment();
     $testMap = $env->getTests();
     if ($testMap[$name] instanceof Twig_SimpleTest) {
         return $testMap[$name]->getNodeClass();
     }
     return $testMap[$name] instanceof Twig_Test_Node ? $testMap[$name]->getClass() : 'Twig_Node_Expression_Test';
 }
开发者ID:stler,项目名称:NMFrame,代码行数:9,代码来源:Core.php

示例5: getTestNodeClass

 protected function getTestNodeClass(Twig_Parser $parser, $name, $line)
 {
     $env = $parser->getEnvironment();
     $testMap = $env->getTests();
     $testName = null;
     if (isset($testMap[$name])) {
         $testName = $name;
     } elseif ($parser->getStream()->test(Twig_Token::NAME_TYPE)) {
         // try 2-words tests
         $name = $name . ' ' . $parser->getCurrentToken()->getValue();
         if (isset($testMap[$name])) {
             $parser->getStream()->next();
             $testName = $name;
         }
     }
     if (null === $testName) {
         $message = sprintf('The test "%s" does not exist', $name);
         if ($alternatives = $env->computeAlternatives($name, array_keys($env->getTests()))) {
             $message = sprintf('%s. Did you mean "%s"', $message, implode('", "', $alternatives));
         }
         throw new Twig_Error_Syntax($message, $line, $parser->getFilename());
     }
     if ($testMap[$name] instanceof Twig_SimpleTest) {
         return $testMap[$name]->getNodeClass();
     }
     return $testMap[$name] instanceof Twig_Test_Node ? $testMap[$name]->getClass() : 'Twig_Node_Expression_Test';
 }
开发者ID:TiGR,项目名称:Twig,代码行数:27,代码来源:Core.php

示例6: getTest

 protected function getTest(Twig_Parser $parser, $line)
 {
     $stream = $parser->getStream();
     $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
     $env = $parser->getEnvironment();
     if ($test = $env->getTest($name)) {
         return array($name, $test);
     }
     if ($stream->test(Twig_Token::NAME_TYPE)) {
         // try 2-words tests
         $name = $name . ' ' . $parser->getCurrentToken()->getValue();
         if ($test = $env->getTest($name)) {
             $parser->getStream()->next();
             return array($name, $test);
         }
     }
     $e = new Twig_Error_Syntax(sprintf('Unknown "%s" test.', $name), $line, $parser->getFilename());
     $e->addSuggestions($name, array_keys($env->getTests()));
     throw $e;
 }
开发者ID:hoque92,项目名称:hoquezilla,代码行数:20,代码来源:Core.php

示例7: getTestName

 protected function getTestName(Twig_Parser $parser, $line)
 {
     $stream = $parser->getStream();
     $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
     $env = $parser->getEnvironment();
     $testMap = $env->getTests();
     if (isset($testMap[$name])) {
         return $name;
     }
     if ($stream->test(Twig_Token::NAME_TYPE)) {
         // try 2-words tests
         $name = $name . ' ' . $parser->getCurrentToken()->getValue();
         if (isset($testMap[$name])) {
             $parser->getStream()->next();
             return $name;
         }
     }
     $message = sprintf('The test "%s" does not exist', $name);
     if ($alternatives = $env->computeAlternatives($name, array_keys($testMap))) {
         $message = sprintf('%s. Did you mean "%s"', $message, implode('", "', $alternatives));
     }
     throw new Twig_Error_Syntax($message, $line, $parser->getFilename());
 }
开发者ID:JohnnyEstilles,项目名称:Twig,代码行数:23,代码来源:Core.php


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