public function run(Zend_Controller_Response_Abstract $response = null) { if ($response === null) { $response = new Zend_Controller_Response_Http(); } $this->response = $response; $action = $this->getCurrentAction(); $this->request->setActionName($action); ob_start(); $this->actionRun($action); if ($this->response->isRedirect() && $this->completeRequest->isXmlHttpRequest()) { $url = null; foreach ($response->getHeaders() as $header) { if ($header['name'] == 'Location') { $url = $header['value']; } } $code = $response->getHttpResponseCode(); // change request to ajax response $response->clearAllHeaders(); $response->clearBody(); $response->setHttpResponseCode(200); $response->setHeader("Content-type", "application/json; charset=utf8"); $response->setBody(Am_Controller::getJson(array('ngrid-redirect' => $url, 'status' => $code))); //throw new Am_Exception_Redirect($url); } else { $this->response->appendBody(ob_get_clean()); } unset($this->response); return $response; }
/** * Try to get response body from cache storage with predefined processors * * @param Zend_Controller_Response_Abstract $response * @return bool */ public function processRequest(Zend_Controller_Response_Abstract $response) { if (empty($this->_requestProcessors)) { return false; } $content = false; foreach ($this->_requestProcessors as $processor) { $processor = $this->_getProcessor($processor); if ($processor) { $content = $processor->extractContent($content); } } if ($content) { $response->appendBody($content); return true; } return false; }
/** * Add footer text * * @param Zend_Controller_Response_Abstract $response */ protected function addFooter($response) { $footer = <<<EOF \t\t\t</div><br /> \t\t</div> \t</body> </html> EOF; $response->appendBody($footer); }