Пример #1
0
 /**
  * Renders the HTML and buffers the output
  *
  * @param INode $rootNode
  *
  * @throws \Cms\Exception
  */
 protected function prepareHtmlCache(INode $rootNode)
 {
     $websiteId = $this->getWebsiteId();
     $pageId = $this->getPageId();
     // path to
     $pageDepth = $this->getStructure()->getPageDepth($pageId);
     $pathToWebRoot = str_repeat('../', $pageDepth);
     $renderContext = $this->createRenderContext($websiteId, $pageId, $this->getStructure(), $pathToWebRoot);
     $htmlVisitor = $this->createHtmlVisitor($renderContext);
     ob_start();
     try {
         $rootNode->accept($htmlVisitor);
     } catch (\Exception $e) {
         ob_end_clean();
         throw new CmsException(2211, __METHOD__, __LINE__, array('website.id' => $websiteId, 'page.id' => $pageId, 'exception.message' => $e->getMessage(), 'exception.code' => $e->getCode(), 'exception.file' => $e->getFile(), 'exception.line' => $e->getLine()), $e);
     }
     /** @noinspection PhpUnusedLocalVariableInspection */
     $htmlCacheString = ob_get_clean();
     // use $htmlCacheString for static pages
     $this->result->setHtmlCacheValue($htmlCacheString);
 }