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


PHP Twig_Token::getLine方法代码示例

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


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

示例1: parse

 /**
  * Parses a token and returns a node.
  *
  * @param  \Twig_Token $token A Twig_Token instance
  *
  * @return \Twig_NodeInterface A Twig_NodeInterface instance
  */
 public function parse(\Twig_Token $token)
 {
     $lineno = $token->getLine();
     $stream = $this->parser->getStream();
     $vars = new \Twig_Node_Expression_Array(array(), $lineno);
     $body = null;
     $count = $this->parser->getExpressionParser()->parseExpression();
     $domain = new \Twig_Node_Expression_Constant('messages', $lineno);
     if (!$stream->test(\Twig_Token::BLOCK_END_TYPE) && $stream->test('for')) {
         // {% transchoice count for "message" %}
         // {% transchoice count for message %}
         $stream->next();
         $body = $this->parser->getExpressionParser()->parseExpression();
     }
     if ($stream->test('with')) {
         // {% transchoice count with vars %}
         $stream->next();
         $vars = $this->parser->getExpressionParser()->parseExpression();
     }
     if ($stream->test('from')) {
         // {% transchoice count from "messages" %}
         $stream->next();
         $domain = $this->parser->getExpressionParser()->parseExpression();
     }
     if (null === $body) {
         // {% transchoice count %}message{% endtranschoice %}
         $stream->expect(\Twig_Token::BLOCK_END_TYPE);
         $body = $this->parser->subparse(array($this, 'decideTransChoiceFork'), true);
     }
     if (!$body instanceof \Twig_Node_Text && !$body instanceof \Twig_Node_Expression) {
         throw new \Twig_Error_Syntax(sprintf('A message must be a simple text (line %s)', $lineno), -1);
     }
     $stream->expect(\Twig_Token::BLOCK_END_TYPE);
     return new TransNode($body, $domain, $count, $vars, $lineno, $this->getTag());
 }
开发者ID:hellovic,项目名称:symfony,代码行数:42,代码来源:TransChoiceTokenParser.php

示例2: parse

 /**
  * {@inheritDoc}
  */
 public function parse(\Twig_Token $token)
 {
     $stream = $this->parser->getStream();
     $expressionParser = $this->parser->getExpressionParser();
     if ($stream->test(\Twig_Token::NAME_TYPE)) {
         $currentToken = $stream->getCurrent();
         $currentValue = $currentToken->getValue();
         $currentLine = $currentToken->getLine();
         // Creates expression: placeholder_name|default('placeholder_name')
         // To parse either variable value or name
         $name = new \Twig_Node_Expression_Filter_Default(new \Twig_Node_Expression_Name($currentValue, $currentLine), new \Twig_Node_Expression_Constant('default', $currentLine), new \Twig_Node(array(new \Twig_Node_Expression_Constant($currentValue, $currentLine)), array(), $currentLine), $currentLine);
         $stream->next();
     } else {
         $name = $expressionParser->parseExpression();
     }
     if ($stream->nextIf(\Twig_Token::NAME_TYPE, 'with')) {
         $variables = $expressionParser->parseExpression();
     } else {
         $variables = new \Twig_Node_Expression_Constant(array(), $token->getLine());
     }
     $stream->expect(\Twig_Token::BLOCK_END_TYPE);
     // build expression to call 'placeholder' function
     $expr = new \Twig_Node_Expression_Function('placeholder', new \Twig_Node(array('name' => $name, 'variables' => $variables)), $token->getLine());
     return new \Twig_Node_Print($expr, $token->getLine(), $this->getTag());
 }
开发者ID:Maksold,项目名称:platform,代码行数:28,代码来源:PlaceholderTokenParser.php

示例3: parse

 public function parse(Twig_Token $token)
 {
     $macro = $this->parser->getExpressionParser()->parseExpression();
     $stream = $this->parser->getStream();
     $stream->expect('import');
     $targets = array();
     do {
         $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
         $alias = $name;
         if ($stream->nextIf('as')) {
             $alias = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
         }
         $targets[$name] = $alias;
         if (!$stream->nextIf(Twig_Token::PUNCTUATION_TYPE, ',')) {
             break;
         }
     } while (true);
     $stream->expect(Twig_Token::BLOCK_END_TYPE);
     $node = new Twig_Node_Import($macro, new Twig_Node_Expression_AssignName($this->parser->getVarName(), $token->getLine()), $token->getLine(), $this->getTag());
     foreach ($targets as $name => $alias) {
         if ($this->parser->isReservedMacroName($name)) {
             throw new Twig_Error_Syntax(sprintf('"%s" cannot be an imported macro as it is a reserved keyword.', $name), $token->getLine(), $stream->getFilename());
         }
         $this->parser->addImportedSymbol('function', $alias, 'get' . $name, $node->getNode('var'));
     }
     return $node;
 }
开发者ID:idwsdta,项目名称:INIT-frame,代码行数:27,代码来源:From.php

示例4: parse

 /**
  * Parses a token and returns a node.
  *
  * @param Twig_Token $token A Twig_Token instance
  *
  * @return Twig_NodeInterface A Twig_NodeInterface instance
  */
 public function parse(\Twig_Token $token)
 {
     $lineno = $token->getLine();
     $stream = $this->parser->getStream();
     $test_name = $stream->expect(\Twig_Token::NAME_TYPE)->getValue();
     $stream->expect(\Twig_Token::BLOCK_END_TYPE);
     $test_name = preg_replace("/[^a-zA-Z0-9]+/", "", $test_name);
     $variants = [];
     // Find the first variant name, and discard content before it.
     $this->parser->subparse(array($this, 'decideIfVariant'));
     // Parse the available variants
     $end = false;
     while (!$end) {
         switch ($stream->next()->getValue()) {
             case 'variant':
                 $name = $stream->expect(\Twig_Token::NAME_TYPE)->getValue();
                 $stream->expect(\Twig_Token::BLOCK_END_TYPE);
                 $body = $this->parser->subparse(array($this, 'decideIfVariant'));
                 $name = preg_replace("/[^a-zA-Z0-9]+/", "", $name);
                 $variants[$name] = $body;
                 break;
             case 'endab':
                 $end = true;
                 break;
             default:
                 throw new \Twig_Error_Syntax(sprintf('ab block started on line %d was not closed.)', $lineno), $stream->getCurrent()->getLine(), $stream->getFilename());
         }
     }
     if (count($variants) < 1) {
         throw new \Twig_Error_Syntax(sprintf('ab block started on line %d had no variants.)', $lineno), $stream->getCurrent()->getLine(), $stream->getFilename());
     }
     $stream->expect(\Twig_Token::BLOCK_END_TYPE);
     return new Node($test_name, $variants, $token->getLine(), $this->getTag());
 }
开发者ID:enyosolutions,项目名称:AutoAB,代码行数:41,代码来源:Parser.php

示例5: parse

 /**
  * Parses a token and returns a node.
  *
  * @param Twig_Token $token A Twig_Token instance
  *
  * @return Twig_NodeInterface A Twig_NodeInterface instance
  */
 public function parse(Twig_Token $token)
 {
     $macro = $this->parser->getExpressionParser()->parseExpression();
     $stream = $this->parser->getStream();
     $stream->expect('import');
     $targets = array();
     do {
         $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
         $alias = $name;
         if ($stream->test('as')) {
             $stream->next();
             $alias = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
         }
         $targets[$name] = $alias;
         if (!$stream->test(Twig_Token::PUNCTUATION_TYPE, ',')) {
             break;
         }
         $stream->next();
     } while (true);
     $stream->expect(Twig_Token::BLOCK_END_TYPE);
     $node = new Twig_Node_Import($macro, new Twig_Node_Expression_AssignName($this->parser->getVarName(), $token->getLine()), $token->getLine(), $this->getTag());
     foreach ($targets as $name => $alias) {
         $this->parser->addImportedFunction($alias, $name, $node->getNode('var'));
     }
     return $node;
 }
开发者ID:kuslahne,项目名称:rapid-slim-php-blog-application,代码行数:33,代码来源:From.php

示例6: parse

 /**
  * Parses a token and returns a node.
  *
  * @param Twig_Token $token A Twig_Token instance
  *
  * @return Twig_NodeInterface A Twig_NodeInterface instance
  */
 public function parse(Twig_Token $token)
 {
     $macro = $this->parser->getExpressionParser()->parseExpression();
     $this->parser->getStream()->expect('as');
     $var = new Twig_Node_Expression_AssignName($this->parser->getStream()->expect(Twig_Token::NAME_TYPE)->getValue(), $token->getLine());
     $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
     return new Twig_Node_Import($macro, $var, $token->getLine(), $this->getTag());
 }
开发者ID:BGCX067,项目名称:fajr-svn-to-git,代码行数:15,代码来源:Import.php

示例7: parse

 public function parse(Twig_Token $token)
 {
     if (!count($this->parser->getBlockStack())) {
         throw new Twig_SyntaxError('Calling "parent" outside a block is forbidden', $token->getLine());
     }
     $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
     return new Twig_Node_Parent($this->parser->peekBlockStack(), $token->getLine(), $this->getTag());
 }
开发者ID:skoop,项目名称:MediTerra,代码行数:8,代码来源:Parent.php

示例8: parse

 public function parse(Twig_Token $token)
 {
     $helper = $token->getValue();
     $args = $this->parser->getExpressionParser()->parseArguments();
     $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
     $expr = new Zwig_Node_Expression_ViewHelper($helper, $args, $token->getLine(), $this->getTag());
     return new Zwig_Node_Stmt($expr, array(), $token->getLine(), $this->getTag());
 }
开发者ID:BGCX262,项目名称:zwig-svn-to-git,代码行数:8,代码来源:ViewHelper.php

示例9: parse

 /**
  * Parse tag.
  *
  * @param Twig_Token $token
  * @return Twig_Node
  */
 public function parse(Twig_Token $token)
 {
     $name = $this->parser->getExpressionParser()->parseExpression();
     if (!$name instanceof Twig_Node_Expression_Constant) {
         throw new Twig_Error_Syntax('The name in a "placeholder" statement must be a string.', $token->getLine());
     }
     $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
     return new Curry_Twig_Node_Placeholder($name->getAttribute('value'), $token->getLine(), $this->getTag());
 }
开发者ID:varvanin,项目名称:currycms,代码行数:15,代码来源:Placeholder.php

示例10: parse

 /**
  * @param \Twig_Token $token consumed token by the lexer.
  *
  * @return \Twig_Node
  * @throws \Twig_Error_Syntax
  */
 public function parse(\Twig_Token $token)
 {
     $stream = $this->parser->getStream();
     $field = $stream->expect(\Twig_Token::NAME_TYPE)->getValue();
     $stream->expect(\Twig_Token::BLOCK_END_TYPE);
     if (FormState::$current === null) {
         throw new \Twig_Error_Syntax(sprintf('Cannot render form field [%s] outside a form element', $field), $token->getLine(), $this->parser->getFilename());
     }
     return new FormFieldNode(FormState::$current, $field, $token->getLine(), $this->getTag());
 }
开发者ID:forkcms,项目名称:forkcms,代码行数:16,代码来源:FormFieldTokenParser.php

示例11: parse

 public function parse(Twig_Token $token)
 {
     if (!$this->parser->isMainScope()) {
         throw new Twig_Error_Syntax('Cannot extend from a block.', $token->getLine(), $this->parser->getFilename());
     }
     if (null !== $this->parser->getParent()) {
         throw new Twig_Error_Syntax('Multiple extends tags are forbidden.', $token->getLine(), $this->parser->getFilename());
     }
     $this->parser->setParent($this->parser->getExpressionParser()->parseExpression());
     $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
 }
开发者ID:idwsdta,项目名称:INIT-frame,代码行数:11,代码来源:Extends.php

示例12: parse

 /**
  * Parses a token and returns a node.
  *
  * @param Twig_Token $token A Twig_Token instance
  *
  * @return Twig_NodeInterface A Twig_NodeInterface instance
  */
 public function parse(Twig_Token $token)
 {
     if (!count($this->parser->getBlockStack())) {
         throw new Twig_Error_Syntax('Calling "parent" outside a block is forbidden', $token->getLine());
     }
     $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
     if (!$this->parser->getParent()) {
         throw new Twig_Error_Syntax('Calling "parent" on a template that does not extend another one is forbidden', $token->getLine());
     }
     return new Twig_Node_Parent($this->parser->peekBlockStack(), $token->getLine(), $this->getTag());
 }
开发者ID:baowzh,项目名称:renfangbaosong,代码行数:18,代码来源:Parent.php

示例13: parse

 /**
  * Parses a token and returns a node.
  *
  * @param \Twig_Token $token A \Twig_Token instance
  *
  * @return \Twig_NodeInterface A \Twig_NodeInterface instance
  */
 public function parse(\Twig_Token $token)
 {
     if (null !== $this->parser->getParent()) {
         throw new \Twig_Error_Syntax('Multiple extends tags are forbidden', $token->getLine());
     }
     $tpl = $this->container->getParameter($this->parser->getCurrentToken()->getValue());
     $this->parser->getExpressionParser()->parseExpression();
     $this->parser->setParent(new \Twig_Node_Expression_Constant($tpl, $token->getLine()));
     $this->parser->getStream()->expect(\Twig_Token::BLOCK_END_TYPE);
     return null;
 }
开发者ID:Azmonkh,项目名称:AdmingeneratorUserBundle,代码行数:18,代码来源:ExtendsMyConfiguredLayoutTokenParser.php

示例14: parse

 /**
  * {@inheritdoc}
  */
 public function parse(\Twig_Token $token)
 {
     $stream = $this->parser->getStream();
     $stream->getCurrent()->test('string');
     $assetName = $stream->getCurrent()->getValue();
     $stream->expect(\Twig_Token::STRING_TYPE);
     $assetStore = $stream->next()->getValue();
     $stream->expect(\Twig_Token::BLOCK_END_TYPE);
     $asset = $this->extractAssetPath($assetName, $assetStore);
     /* @noinspection PhpParamsInspection */
     return new \Twig_Node_Print(new \Twig_Node_Expression_Constant($asset, $token->getLine()), $token->getLine(), $this->getTag());
 }
开发者ID:Briareos,项目名称:Undine,代码行数:15,代码来源:Asset.php

示例15: parse

 /**
  * @param \Twig_Token $token
  *
  * @return \Twig_Node
  * @throws \Twig_Error_Syntax
  */
 public function parse(\Twig_Token $token)
 {
     $stream = $this->parser->getStream();
     $form = $stream->expect(\Twig_Token::NAME_TYPE)->getValue();
     $stream->expect(\Twig_Token::BLOCK_END_TYPE);
     if (FormState::$current !== null) {
         throw new \Twig_Error_Syntax(sprintf('form [%s] not closed while opening form [%s]', FormState::$current, $form), $token->getLine(), $stream->getFilename());
     } else {
         FormState::$current = $form;
     }
     return new FormNode($form, $token->getLine(), $this->getTag());
 }
开发者ID:forkcms,项目名称:forkcms,代码行数:18,代码来源:FormTokenParser.php


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