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


PHP ezcTemplateCursor::length方法代码示例

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


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

示例1: handleSuccessfulResult

 /**
  * Performs checking on the parse result.
  *
  * The method will check if there are more text after the current cursor
  * location and if so appends a new ezcTextElement object containing the
  * text.
  *
  * It also checks if the $lastBlock contains the current program parser, if it
  * does not it means the nesting in the current source code is incorrect.
  *
  * @param ezcTemplateCursor $lastCursor
  * @param ezcTemplateCursor $cursor
  *
  * @throws ezcTemplateParserException if blocks are incorrectly nested.
  *
  * @return void
  */
 protected function handleSuccessfulResult(ezcTemplateCursor $lastCursor, ezcTemplateCursor $cursor)
 {
     if ($lastCursor->length($cursor) > 0) {
         $textElement = new ezcTemplateTextBlockTstNode($this->parser->source, clone $lastCursor, clone $cursor);
         $this->handleElements(array($textElement));
     }
     if ($this->lastBlock === null) {
         throw new ezcTemplateInternalException("lastBlock is null, should have been a parser element object.");
     }
     if (!$this->lastBlock instanceof ezcTemplateProgramTstNode) {
         $parents = array();
         // Calculate level of the last block, this used to indent the last block
         $level = 0;
         $block = $this->lastBlock;
         while ($block->parentBlock !== null && !$block->parentBlock instanceof ezcTemplateProgramTstNode) {
             if ($block === $block->parentBlock) {
                 throw new ezcTemplateInternalException("Infinite recursion found in parser element " . get_class($block));
             }
             ++$level;
             $block = $block->parentBlock;
         }
         $block = $this->lastBlock;
         // Go trough all parents until the root is reached
         while ($block->parentBlock !== null && !$block->parentBlock instanceof ezcTemplateProgramTstNode) {
             if ($block === $block->parentBlock) {
                 throw new ezcTemplateInternalException("Infinite recursion found in parser element " . get_class($block));
             }
             $block = $block->parentBlock;
             --$level;
             $parents[] = str_repeat("  ", $level) . "{" . $block->name . "} @ {$block->startCursor->line}:{$block->startCursor->column}:";
         }
         $parents = array_reverse($parents);
         $treeText = "The current nesting structure:\n" . join("\n", $parents);
         throw new ezcTemplateParserException($this->parser->source, $this->startCursor, $this->currentCursor, "Incorrect nesting in code, close block {/" . $this->lastBlock->name . "} expected.");
     }
     // Get rid of whitespace for the block line of the program element
     $this->parser->trimBlockLine($this->program);
 }
开发者ID:zetacomponents,项目名称:template,代码行数:55,代码来源:program.php


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