/** * Dispatch and start output buffer * * @return void */ public function dispatch() { // start output buffer Core_Utility::startBuffer(); $this->_runActionController(); // Send buffer to output print Core_Utility::collectBuffer(); }
/** * This will output the array or object as JSON object * * @param Mixed $mixed An array */ public function setResponse($mixed) { // Check parameter if (false === is_object($mixed) && false === is_array($mixed)) { throw new Core_HTTP_Helper_Response_JsonException(sprintf('Supplied paramter is %s, but should be either an object or an array.', gettype($mixed))); } // Set headers for JSON response $this->_responseObject->setHeaders(array('Content-type' => 'application/json', 'Expires' => 'Mon, 26 Jul 1997 05:00:00 GMT', 'Pragma' => 'no-cache', 'Cache-Control' => 'no-cache')); // Stop output buffer Core_Utility::collectBuffer(); // Output JSON encoded string print json_encode($mixed); // Stop script exit; }