/** * This will decide what should happen with the return value of the initialized item * * @return void * @throws Core_Main_AbstractException */ protected final function _afterInit($methodName, $value) { // If there is no value if (null === $value) { return; } // Decision tree here. There should not be many exceptions switch ($methodName) { case 'IncludePath': set_include_path($value); break; // Store registry locally // Store registry locally case 'Registry': // check interface of registry, make sure it has the right accessors (get() and set()) if (false === Core_Utility::hasInterface($value, 'Core_Interface_Registry')) { throw new Core_Main_AbstractException(sprintf('Registry does not implement %s', $registryInterface)); } $this->_registry = $value; break; default: $this->_registry->set(strtolower($methodName), $value); break; } }
/** * 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; }