/** * Loads the template source and render the template. * If "layoutName" is set in a PostParseFacet callback, it will render the file with the given layout. * * @param string $actionName If set, the view of the specified action will be rendered instead. Default is the action specified in the Request object * @return string Rendered Template * @api */ public function render($actionName = NULL) { $this->baseRenderingContext->setControllerContext($this->controllerContext); $this->templateParser->setConfiguration($this->buildParserConfiguration()); $templateIdentifier = $this->getTemplateIdentifier($actionName); if ($this->templateCompiler->has($templateIdentifier)) { $parsedTemplate = $this->templateCompiler->get($templateIdentifier); } else { $parsedTemplate = $this->templateParser->parse($this->getTemplateSource($actionName)); if ($parsedTemplate->isCompilable()) { $this->templateCompiler->store($templateIdentifier, $parsedTemplate); } } if ($parsedTemplate->hasLayout()) { $layoutName = $parsedTemplate->getLayoutName($this->baseRenderingContext); $layoutIdentifier = $this->getLayoutIdentifier($layoutName); if ($this->templateCompiler->has($layoutIdentifier)) { $parsedLayout = $this->templateCompiler->get($layoutIdentifier); } else { $parsedLayout = $this->templateParser->parse($this->getLayoutSource($layoutName)); if ($parsedLayout->isCompilable()) { $this->templateCompiler->store($layoutIdentifier, $parsedLayout); } } $this->startRendering(self::RENDERING_LAYOUT, $parsedTemplate, $this->baseRenderingContext); $output = $parsedLayout->render($this->baseRenderingContext); $this->stopRendering(); } else { $this->startRendering(self::RENDERING_TEMPLATE, $parsedTemplate, $this->baseRenderingContext); $output = $parsedTemplate->render($this->baseRenderingContext); $this->stopRendering(); } return $output; }