本文整理匯總了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());
}
示例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';
}
示例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;
}