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


PHP Twig_Parser::getFilename方法代码示例

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


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

示例1: 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:stler,项目名称:NMFrame,代码行数:23,代码来源:Core.php

示例2: 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

示例3: 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


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