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


PHP Twig_Token::typeToEnglish方法代码示例

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


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

示例1: parse

 /**
  * {@inheritDoc}
  */
 public function parse(\Twig_Token $token)
 {
     $filters = array();
     $attributes = array('output' => $this->output, 'var_name' => 'asset_url', 'vars' => array());
     $stream = $this->parser->getStream();
     while (!$stream->test(\Twig_Token::BLOCK_END_TYPE)) {
         if ($stream->test(\Twig_Token::NAME_TYPE, 'filter')) {
             $filters = array_merge($filters, array_filter(array_map('trim', explode(',', $this->parseStringValue($stream)))));
         } elseif ($stream->test(\Twig_Token::NAME_TYPE, 'output')) {
             $attributes['output'] = $this->parseStringValue($stream);
         } elseif ($stream->test(\Twig_Token::NAME_TYPE, 'debug')) {
             $attributes['debug'] = $this->parseBooleanValue($stream);
         } elseif ($stream->test(\Twig_Token::NAME_TYPE, 'combine')) {
             $attributes['combine'] = $this->parseBooleanValue($stream);
         } else {
             $token = $stream->getCurrent();
             throw new \Twig_Error_Syntax(sprintf('Unexpected token "%s" of value "%s"', \Twig_Token::typeToEnglish($token->getType(), $token->getLine()), $token->getValue()), $token->getLine());
         }
     }
     $stream->expect(\Twig_Token::BLOCK_END_TYPE);
     $body = $this->parser->subparse(array($this, 'testEndTag'), true);
     $stream->expect(\Twig_Token::BLOCK_END_TYPE);
     $lineno = $token->getLine();
     return new \Twig_Node(array($this->createAsseticNode($body, $filters, $attributes, $lineno), $this->createDebugAsseticNode($body, $filters, $attributes, $lineno)), array(), $lineno);
 }
开发者ID:Maksold,项目名称:platform,代码行数:28,代码来源:AsseticTokenParser.php

示例2: parse

 public function parse(\Twig_Token $token)
 {
     $inputs = array();
     $attrs = array('filters' => array());
     $stream = $this->parser->getStream();
     while (!$stream->test(\Twig_Token::BLOCK_END_TYPE)) {
         if ($stream->test(\Twig_Token::STRING_TYPE)) {
             $inputs[] = $stream->next()->getValue();
         } elseif ($stream->test(\Twig_Token::NAME_TYPE, 'filter')) {
             $stream->next();
             $stream->expect(\Twig_Token::OPERATOR_TYPE, '=');
             $attrs['filters'] = array_merge($attrs['filters'], array_filter(array_map('trim', explode(',', $stream->expect(\Twig_Token::STRING_TYPE)->getValue()))));
         } elseif ($stream->test(\Twig_Token::NAME_TYPE, 'output')) {
             $stream->next();
             $stream->expect(\Twig_Token::OPERATOR_TYPE, '=');
             $attributes['output'] = $stream->expect(\Twig_Token::STRING_TYPE)->getValue();
         } else {
             $token = $stream->getCurrent();
             throw new \Twig_Error_Syntax(sprintf('Unexpected token "%s" of value "%s"', \Twig_Token::typeToEnglish($token->getType(), $token->getLine()), $token->getValue()), $token->getLine());
         }
     }
     $stream->expect(\Twig_Token::BLOCK_END_TYPE);
     $content = $this->parser->subparse(array($this, 'testEndTag'), true);
     $stream->expect(\Twig_Token::BLOCK_END_TYPE);
     $this->manager->load($inputs, $attrs, $this->getTag());
     $params['assets'] = $this->manager->getAssetsPath();
     return new TlAssetsNode(array('content' => $content), $params, $token->getLine(), $this->getTag());
 }
开发者ID:electrotiti,项目名称:tlassets-bundle,代码行数:28,代码来源:TlAssetsTokenParser.php

示例3: parse

 /**
  * {@inheritDoc}
  */
 public function parse(\Twig_Token $token)
 {
     $inputs = $this->assets;
     $filters = [];
     $attributes = ['output' => $this->output, 'var_name' => 'asset_url', 'vars' => []];
     $stream = $this->parser->getStream();
     while (!$stream->test(\Twig_Token::BLOCK_END_TYPE)) {
         if ($stream->test(\Twig_Token::NAME_TYPE, 'filter')) {
             $filters = array_merge($filters, array_filter(array_map('trim', explode(',', $this->parseValue($stream, false)))));
         } elseif ($stream->test(\Twig_Token::NAME_TYPE, 'output')) {
             $attributes['output'] = $this->parseValue($stream, false);
         } elseif ($stream->test(\Twig_Token::NAME_TYPE, 'debug')) {
             $attributes['debug'] = $this->parseValue($stream);
         } elseif ($stream->test(\Twig_Token::NAME_TYPE, 'combine')) {
             $attributes['combine'] = $this->parseValue($stream);
         } else {
             $token = $stream->getCurrent();
             throw new \Twig_Error_Syntax(sprintf('Unexpected token "%s" of value "%s"', \Twig_Token::typeToEnglish($token->getType(), $token->getLine()), $token->getValue()), $token->getLine());
         }
     }
     $stream->expect(\Twig_Token::BLOCK_END_TYPE);
     $body = $this->parser->subparse([$this, 'testEndTag'], true);
     $stream->expect(\Twig_Token::BLOCK_END_TYPE);
     $nameUnCompress = $this->factory->generateAssetName($inputs['compress'][0], $filters, $attributes);
     $nameCompress = substr(sha1(serialize($inputs['uncompress'][0]) . 'oro_assets'), 0, 7);
     return new OroAsseticNode(['compress' => $this->factory->createAsset($inputs['compress'][0], $filters, $attributes + ['name' => $nameCompress, 'debug' => false]), 'un_compress' => $this->factory->createAsset($inputs['uncompress'][0], [], $attributes + ['name' => $nameUnCompress, 'debug' => true])], ['un_compress' => $nameUnCompress, 'compress' => $nameCompress], $filters, $inputs, $body, $attributes, $token->getLine(), $this->getTag());
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:30,代码来源:AsseticTokenParser.php

示例4: parse

 public function parse(\Twig_Token $token)
 {
     $name = null;
     $stream = $this->parser->getStream();
     while (!$stream->test(\Twig_Token::BLOCK_END_TYPE)) {
         if ($stream->test(\Twig_Token::STRING_TYPE)) {
             $name = $stream->next()->getValue();
             if (!$this->manager->has($name)) {
                 throw new FeatureToggleNotFoundException('The feature "%s" does not exist.', $name);
             } else {
                 $feature = $this->manager->get($name);
             }
         } else {
             $token = $stream->getCurrent();
             throw new \Twig_Error_Syntax(sprintf('Unexpected token "%s" of value %s".', \Twig_Token::typeToEnglish($token->getType(), $token->getLine()), $token->getValue()), $token->getLine());
         }
     }
     $stream->expect(\Twig_Token::BLOCK_END_TYPE);
     // Store the body of the feature.
     $body = $this->parser->subparse(array($this, 'decideFeatureEnd'), true);
     $stream->expect(\Twig_Token::BLOCK_END_TYPE);
     if ($feature->isEnabled()) {
         return $body;
     }
     return;
 }
开发者ID:vladab,项目名称:featuretogglebundle,代码行数:26,代码来源:FeatureToggleTokenParser.php

示例5: parse

 /**
  * {@inheritdoc}
  */
 public function parse(Twig_Token $token)
 {
     $dirs = [];
     $name = null;
     $output = null;
     $stream = $this->parser->getStream();
     while (!$stream->test(\Twig_Token::BLOCK_END_TYPE)) {
         if ($stream->test(\Twig_Token::STRING_TYPE)) {
             // 'web/css', 'web/js'
             $dirs[] = $stream->next()->getValue();
         } elseif ($stream->test(\Twig_Token::NAME_TYPE, 'pattern')) {
             // patern='\.js$'
             $stream->next();
             $stream->expect(\Twig_Token::OPERATOR_TYPE, '=');
             $pattern = $stream->next()->getValue();
         } else {
             $token = $stream->getCurrent();
             throw new \Twig_Error_Syntax(sprintf('Unexpected token "%s" of value "%s"', \Twig_Token::typeToEnglish($token->getType()), $token->getValue()), $token->getLine(), $stream->getFilename());
         }
     }
     $stream->expect(\Twig_Token::BLOCK_END_TYPE);
     $body = $this->parser->subparse([$this, 'testEndTag'], true);
     $stream->expect(\Twig_Token::BLOCK_END_TYPE);
     $matches = $this->matchPatterns($this->baseDir, $dirs, $pattern);
     return new GlobNode($matches, ['body' => $body], [], $token->getLine(), $this->getTag());
 }
开发者ID:Briareos,项目名称:Undine,代码行数:29,代码来源:Glob.php

示例6: typeToEnglish

 public static function typeToEnglish($type, $line = -1)
 {
     switch ($type) {
         case self::COMMENT:
             return 'comment';
         default:
             return parent::typeToEnglish($type, $line);
     }
 }
开发者ID:KacerCZ,项目名称:Twig-extensions,代码行数:9,代码来源:Token.php

示例7: expect

 /**
  * Tests a token and returns it or throws a syntax error.
  *
  * @return Twig_Token
  */
 public function expect($type, $value = null, $message = null)
 {
     $token = $this->tokens[$this->current];
     if (!$token->test($type, $value)) {
         throw new Twig_Error_Syntax(sprintf('%sUnexpected token "%s" of value "%s" ("%s" expected%s)', $message ? $message . '. ' : '', Twig_Token::typeToEnglish($token->getType()), $token->getValue(), Twig_Token::typeToEnglish($type), $value ? sprintf(' with value "%s"', $value) : ''), $token->getLine());
     }
     $this->next();
     return $token;
 }
开发者ID:jackbravo,项目名称:symfony-sandbox,代码行数:14,代码来源:TokenStream.php

示例8: parse

 public function parse(\Twig_Token $token)
 {
     $files = array();
     $stream = $this->parser->getStream();
     // parse string values until the tag end
     while (!$stream->test(\Twig_Token::BLOCK_END_TYPE)) {
         if ($stream->test(\Twig_Token::STRING_TYPE)) {
             // 'bundle/file', 'bundle/file2'
             $files[] = $stream->next()->getValue();
         } else {
             $token = $stream->getCurrent();
             throw new \Twig_Error_Syntax(sprintf('Unexpected token "%s" of value "%s"', \Twig_Token::typeToEnglish($token->getType(), $token->getLine()), $token->getValue()), $token->getLine());
         }
     }
     $stream->expect(\Twig_Token::BLOCK_END_TYPE);
     return new RequireJsNode($this->manifest, $this->config, $files, $token->getLine(), $this->getTag());
 }
开发者ID:99designs,项目名称:silex-assets,代码行数:17,代码来源:RequireJsTokenParser.php

示例9: parse

 public function parse(\Twig_Token $token)
 {
     $node = new TwigJsNode(array(), array(), $token->getLine(), $this->getTag());
     $stream = $this->parser->getStream();
     while (!$stream->test(\Twig_Token::BLOCK_END_TYPE)) {
         if ($stream->test(\Twig_Token::NAME_TYPE, 'name')) {
             $stream->next();
             $stream->expect(\Twig_Token::OPERATOR_TYPE, '=');
             $node->setAttribute('name', $stream->expect(\Twig_Token::STRING_TYPE)->getValue());
             continue;
         }
         $token = $stream->getCurrent();
         throw new \Twig_Error_Syntax(sprintf('Unexpected token "%s" of value "%s"', \Twig_Token::typeToEnglish($token->getType(), $token->getLine()), $token->getValue()), $token->getLine());
     }
     $stream->expect(\Twig_Token::BLOCK_END_TYPE);
     return $node;
 }
开发者ID:raphydev,项目名称:onep,代码行数:17,代码来源:TwigJsTokenParser.php

示例10: parse

 public function parse(\Twig_Token $token)
 {
     $files = array();
     $stream = $this->parser->getStream();
     // parse string values until the tag end
     while (!$stream->test(\Twig_Token::BLOCK_END_TYPE)) {
         if ($stream->test(\Twig_Token::STRING_TYPE)) {
             // 'css/myfile.css', 'css/llamas.css'
             $files[] = $stream->next()->getValue();
         } else {
             $token = $stream->getCurrent();
             throw new \Twig_Error_Syntax(sprintf('Unexpected token "%s" of value "%s"', \Twig_Token::typeToEnglish($token->getType(), $token->getLine()), $token->getValue()), $token->getLine());
         }
     }
     $stream->expect(\Twig_Token::BLOCK_END_TYPE);
     $body = $this->parser->subparse(array($this, 'testEndTag'), true);
     $stream->expect(\Twig_Token::BLOCK_END_TYPE);
     return $this->createNode($body, $this->getTag(), $token->getLine(), $files);
 }
开发者ID:99designs,项目名称:silex-assets,代码行数:19,代码来源:AssetTokenParser.php

示例11: parse

 public function parse(Token $token)
 {
     $inputs = array();
     $stream = $this->parser->getStream();
     while (!$stream->test(Token::BLOCK_END_TYPE)) {
         if ($stream->test(Token::STRING_TYPE)) {
             $inputs[] = $stream->next()->getValue();
         } else {
             $token = $stream->getCurrent();
             throw new \Twig_Error_Syntax(sprintf('Unexpected token "%s" of value "%s"', Token::typeToEnglish($token->getType()), $token->getValue()), $token->getLine(), $stream->getFilename());
         }
     }
     $stream->expect(Token::BLOCK_END_TYPE);
     $endTag = 'end_' . $this->getTag();
     $body = $this->parser->subparse(function (Token $token) use($endTag) {
         return $token->test(array($endTag));
     }, true);
     $stream->expect(Token::BLOCK_END_TYPE);
     $nodes = array();
     foreach ($inputs as $input) {
         $nodes[] = $this->createNodeForInput($input, $body, $token->getLine());
     }
     return new \Twig_Node($nodes);
 }
开发者ID:mariusbalcytis,项目名称:webpack-bundle,代码行数:24,代码来源:WebpackTokenParser.php

示例12: parse

 public function parse(\Twig_Token $token)
 {
     $inputs = array();
     $filters = array();
     $name = null;
     $attributes = array('output' => $this->output, 'var_name' => 'asset_url', 'vars' => array());
     $stream = $this->parser->getStream();
     while (!$stream->test(\Twig_Token::BLOCK_END_TYPE)) {
         if ($stream->test(\Twig_Token::STRING_TYPE)) {
             // '@jquery', 'js/src/core/*', 'js/src/extra.js'
             $inputs[] = $stream->next()->getValue();
         } elseif ($stream->test(\Twig_Token::NAME_TYPE, 'filter')) {
             // filter='yui_js'
             $stream->next();
             $stream->expect(\Twig_Token::OPERATOR_TYPE, '=');
             $filters = array_merge($filters, array_filter(array_map('trim', explode(',', $stream->expect(\Twig_Token::STRING_TYPE)->getValue()))));
         } elseif ($stream->test(\Twig_Token::NAME_TYPE, 'output')) {
             // output='js/packed/*.js' OR output='js/core.js'
             $stream->next();
             $stream->expect(\Twig_Token::OPERATOR_TYPE, '=');
             $attributes['output'] = $stream->expect(\Twig_Token::STRING_TYPE)->getValue();
         } elseif ($stream->test(\Twig_Token::NAME_TYPE, 'name')) {
             // name='core_js'
             $stream->next();
             $stream->expect(\Twig_Token::OPERATOR_TYPE, '=');
             $name = $stream->expect(\Twig_Token::STRING_TYPE)->getValue();
         } elseif ($stream->test(\Twig_Token::NAME_TYPE, 'as')) {
             // as='the_url'
             $stream->next();
             $stream->expect(\Twig_Token::OPERATOR_TYPE, '=');
             $attributes['var_name'] = $stream->expect(\Twig_Token::STRING_TYPE)->getValue();
         } elseif ($stream->test(\Twig_Token::NAME_TYPE, 'debug')) {
             // debug=true
             $stream->next();
             $stream->expect(\Twig_Token::OPERATOR_TYPE, '=');
             $attributes['debug'] = 'true' == $stream->expect(\Twig_Token::NAME_TYPE, array('true', 'false'))->getValue();
         } elseif ($stream->test(\Twig_Token::NAME_TYPE, 'combine')) {
             // combine=true
             $stream->next();
             $stream->expect(\Twig_Token::OPERATOR_TYPE, '=');
             $attributes['combine'] = 'true' == $stream->expect(\Twig_Token::NAME_TYPE, array('true', 'false'))->getValue();
         } elseif ($stream->test(\Twig_Token::NAME_TYPE, 'vars')) {
             // vars=['locale','browser']
             $stream->next();
             $stream->expect(\Twig_Token::OPERATOR_TYPE, '=');
             $stream->expect(\Twig_Token::PUNCTUATION_TYPE, '[');
             while ($stream->test(\Twig_Token::STRING_TYPE)) {
                 $attributes['vars'][] = $stream->expect(\Twig_Token::STRING_TYPE)->getValue();
                 if (!$stream->test(\Twig_Token::PUNCTUATION_TYPE, ',')) {
                     break;
                 }
                 $stream->next();
             }
             $stream->expect(\Twig_Token::PUNCTUATION_TYPE, ']');
         } elseif ($stream->test(\Twig_Token::NAME_TYPE, $this->extensions)) {
             // an arbitrary configured attribute
             $key = $stream->next()->getValue();
             $stream->expect(\Twig_Token::OPERATOR_TYPE, '=');
             $attributes[$key] = $stream->expect(\Twig_Token::STRING_TYPE)->getValue();
         } else {
             $token = $stream->getCurrent();
             throw new \Twig_Error_Syntax(sprintf('Unexpected token "%s" of value "%s"', \Twig_Token::typeToEnglish($token->getType()), $token->getValue()), $token->getLine(), $stream->getFilename());
         }
     }
     $stream->expect(\Twig_Token::BLOCK_END_TYPE);
     $body = $this->parser->subparse(array($this, 'testEndTag'), true);
     $stream->expect(\Twig_Token::BLOCK_END_TYPE);
     if ($this->single && 1 < count($inputs)) {
         $inputs = array_slice($inputs, -1);
     }
     if (!$name) {
         $name = $this->factory->generateAssetName($inputs, $filters, $attributes);
     }
     $asset = $this->factory->createAsset($inputs, $filters, $attributes + array('name' => $name));
     return $this->createBodyNode($asset, $body, $inputs, $filters, $name, $attributes, $token->getLine(), $this->getTag());
 }
开发者ID:betes-curieuses-design,项目名称:ElieJosiePhotographie,代码行数:76,代码来源:AsseticTokenParser.php

示例13: expect

 private function expect($filename, \Twig_Token $token, $type, $value = null)
 {
     if ($token->getType() !== $type) {
         throw new \RuntimeException(sprintf('Parse error in %s at line %d. Expected %s%s, got %s.', $filename, $token->getLine(), \Twig_Token::typeToEnglish($type), $value !== null ? ' "' . $value . '"' : '', \Twig_Token::typeToEnglish($token->getType())));
     }
 }
开发者ID:studionone,项目名称:webpack-bundle,代码行数:6,代码来源:TwigParser.php

示例14: parseHashExpression

 public function parseHashExpression()
 {
     $stream = $this->parser->getStream();
     $stream->expect(Twig_Token::PUNCTUATION_TYPE, '{', 'A hash element was expected');
     $elements = array();
     while (!$stream->test(Twig_Token::PUNCTUATION_TYPE, '}')) {
         if (!empty($elements)) {
             $stream->expect(Twig_Token::PUNCTUATION_TYPE, ',', 'A hash value must be followed by a comma');
             // trailing ,?
             if ($stream->test(Twig_Token::PUNCTUATION_TYPE, '}')) {
                 break;
             }
         }
         if (!$stream->test(Twig_Token::STRING_TYPE) && !$stream->test(Twig_Token::NUMBER_TYPE)) {
             $current = $stream->getCurrent();
             throw new Twig_Error_Syntax(sprintf('A hash key must be a quoted string or a number (unexpected token "%s" of value "%s"', Twig_Token::typeToEnglish($current->getType(), $current->getLine()), $current->getValue()), $current->getLine());
         }
         $key = $stream->next()->getValue();
         $stream->expect(Twig_Token::PUNCTUATION_TYPE, ':', 'A hash key must be followed by a colon (:)');
         $elements[$key] = $this->parseExpression();
     }
     $stream->expect(Twig_Token::PUNCTUATION_TYPE, '}', 'An opened hash is not properly closed');
     return new Twig_Node_Expression_Array($elements, $stream->getCurrent()->getLine());
 }
开发者ID:vebnz,项目名称:lifelitup,代码行数:24,代码来源:ExpressionParser.php

示例15: parseStringAttribute

 /**
  * Parses a string attribute token, saving it as either the title, link URL, or link text
  *
  * @param \Twig_Token $token The token to parse
  * @param \Twig_TokenStream $stream The token stream being traversed
  * @return void
  */
 protected function parseStringAttribute(\Twig_Token $token, \Twig_TokenStream $stream)
 {
     if (!$token->test(\Twig_Token::STRING_TYPE)) {
         throw new RuntimeException(sprintf("Expected string token but received '%s' instead", \Twig_Token::typeToEnglish($token->getType())), $stream->getCurrent()->getLine(), $stream->getFilename());
     }
     // If any of these values has already been set, then set the next
     // property with this string. The string order that must be followed
     // in the codeblock tag is: title, url, link text
     if (empty($this->attributes['title'])) {
         $this->attributes['title'] = $token->getValue();
     } elseif (empty($this->attributes['linkUrl'])) {
         $this->attributes['linkUrl'] = $token->getValue();
     } elseif (empty($this->attributes['linkText'])) {
         $this->attributes['linkText'] = $token->getValue();
     }
 }
开发者ID:ramsey,项目名称:twig-codeblock,代码行数:23,代码来源:CodeBlockParser.php


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