本文整理汇总了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);
}