Example #1
0
 /**
  * 渲染模板
  * @param string $template
  * @param boolean $withLayout
  * @return Response
  */
 function render($template = null, $withLayout = true)
 {
     // 如果没有选择render,则取当前action
     if (is_null($template)) {
         $template = $this->action;
     }
     $content = $this->application->getViewManager()->load($template, $this->layout)->render($this->viewVariables, $withLayout);
     $this->response->setContent($content);
     $this->rendered = true;
     return $this->response;
 }
Example #2
0
 /**
  * 从Application的错误模板渲染内容
  * @param Application $application
  * @param string $templateName
  * @param array $parameters
  */
 protected function renderContentFromView(Application $application, $templateName, array $parameters = [])
 {
     $viewManager = $application->getViewManager();
     $viewManager->setViewPath($application->getViewPath() . '/error/');
     return $viewManager->load($templateName)->render($parameters);
 }