public function render($view = null, $layout = null)
{
$builder = $this->viewBuilder();
if (!$builder->templatePath()) {
$builder->templatePath($this->_viewPath());
}
if (!empty($this->request->params['bare'])) {
$builder->autoLayout(false);
}
$builder->className($this->viewClass);
$this->autoRender = false;
$event = $this->dispatchEvent('Controller.beforeRender');
if ($event->result instanceof Response) {
return $event->result;
}
if ($event->isStopped()) {
return $this->response;
}
if ($builder->template() === null && isset($this->request->params['action'])) {
$builder->template($this->request->params['action']);
}
$this->View = $this->createView();
$this->response->body($this->View->render($view, $layout));
return $this->response;
}