{$var} = $controller->{$var}; } $this->response->type('json'); } } /** * Render a JSON view. * * Uses the special 'serialize' parameter to convert a set of * view variables into a JSON response. Makes generating simple * JSON responses very easy. You can omit the 'serialize' parameter, * and use a normal view + layout as well. * * @param string $view The view being rendered. * @param string $layout The layout being rendered. * @return string The rendered view. */ public function render($view = null, $layout = null) { if ($view !== false && $viewFileName = $this->_getViewFileName($view)) { $this->_render($viewFileName); } $data = isset($this->viewVars['serialize']) ? $this->viewVars['serialize'] : null; return $this->output = json_encode($data); } }