/** * This method is called by the launcher (index.php5) */ static function processHTTP() { ob_start(); $request = Request::parseHTTP(); $responce = new Responce($request); $pkg = Package::getPackageByName('freeform'); // Initialize session $sessionImpl = $pkg->getProperty('session.impl'); $class = new ReflectionClass($sessionImpl); $method = $class->getMethod('load'); Session::setHandler($method->invoke(null, $request)); // See if we have the server cache hit here if(!$responce->getFromCache()) { // Initialize action $action = $request->getParameter('action', $da = $pkg->getProperty('action.default')); try { $class = new ReflectionClass($action); if(!$class->isSubclassOf('Action') || $class->isAbstract()) { throw new Exception('Can not execute action ' . $class->getName()); } } catch(Exception $e) { $class = new ReflectionClass($pkg->getProperty('action.error', $da)); if($class->isSubclassOf('Action') && !$class->isAbstract()) { $responce->relocate(new Location($class->getName())); $responce->setStatusCode(Response::STATUS_ERR_ACTION); } else { throw new ConfigurationException('freeform', 'action.error, action.default', 'do not denote a valid instantiable Action subclass'); } } if(!$responce->isRelocation()) { // Initialize, secure and execute $action = $class->newInstance($request, $responce, true); Package::setEntryPackage(Package::getPackage($action)); try { self::process($action); } catch(AccessDeniedException $ade) { $responce->setStatusCode(Responce::STATUS_ERR_ACCESS); $action->onAccessDenied(); } } } // Send back the document foreach($responce->getHeaders() as $header) { header($header, false); } if($output = trim(ob_get_contents())) { error_log('Executed Action ' . $class->getName() . ' produced output: ' . $output); } ob_end_clean(); echo $responce->getBody(); }
/** * Sets the session persistence handler * * @param ISessionHandler $handler * @return void */ public function setSessionHandler(ISessionHandler $handler) { $this->session->setHandler($handler); }