/** * Compiles the given template tags. * * Throws an exception in case there are unclosed tags remaining. * * @param array $templateTags The template tags to compile * @param array $textBlocks Text blocks outside of template-tags * @throws \Ableron\Core\Exception\SystemException * @return array */ private function compileTemplateTags($templateTags, $textBlocks) { // prepare return value and get number of template tags to compile $compiledTags = array(); $templateTagsCount = count($templateTags); // compile template tags, one by one for ($currentTagIndex = 0; $currentTagIndex < $templateTagsCount; $currentTagIndex++) { $this->currentLineNumber += StringUtil::getSubstringCount($textBlocks[$currentTagIndex], StringUtil::CHAR_LINE_FEED); $compiledTags[] = $this->compileTemplateTag($templateTags[$currentTagIndex]); $this->currentLineNumber += StringUtil::getSubstringCount($templateTags[$currentTagIndex], StringUtil::CHAR_LINE_FEED); } // check for unclosed tags if (!$this->compilerPluginTagStack->isEmpty()) { throw new SystemException(sprintf('Unclosed tag {%s} in template "%s" on line %s', $this->getLastCompilerPluginTagParameter('tagName'), $this->getCurrentTemplateName(), $this->getLastCompilerPluginTagParameter('lineNumber')), 0, E_USER_ERROR, __FILE__, __LINE__); } // return compiled tags return $compiledTags; }