/** * Handling process: * dispatch: onParseUrl }-> caught Exception * dispatch: onAccessCheck |-> dispatch: onException * dispatch: onRequestStart | * dispatch: onSendResponse }---> caught SiteRedirectException * dispatch: onResponseSent | |-> redirect * cleanup <-------------------/-/ * * At any point in the process, a thrown exception will cause 'onException' * to be dispatched, if that generates no output, then the exception is * simply printed in a minimal html document. After the onException, normal cleanup is done * * @return void * @see parseUrl */ public final function handle() { $args = array_slice(func_get_args(), 1); try { ob_start(); $this->parseUrl(Params::server('REQUEST_URI')); $this->log->info(sprintf('==> Framework v%s: New Request from %s - %s <==', Loader::$FrameworkVersion, Params::server('REMOTE_ADDR'), $this->requestUrl)); $this->dispatchCallback('onAccessCheck', $this); $this->dispatchCallback('onRequestStart', $this); $this->dispatchCallback('onSendResponse', $this); $this->dispatchCallback('onResponseSent', $this); ob_end_flush(); } catch (SiteRedirectException $r) { ob_end_clean(); header("Location: {$r->url}"); } $this->cleanup(); }
/** * contructor; generic initializations * do your initializations onInitialize() */ public final function __construct($actionId = null) { $this->title = get_class($this); $this->onInitialize(); $this->onRegisterActions(); if (!isset($actionId)) { $actionId = Params::request(self::$ActionKey, null); } if (!isset($actionId)) { throw new RuntimeException("need an action"); } $this->action = $this->getAction($actionId); if (!$this->action) { throw new RuntimeException("Unknown action {$actionId}"); } $this->stage = Params::request(self::$StageKey, Stage::VIEW); if (Params::server('HTTPS') != 'on' && $this->action->requiresSSL) { // TODO implement secure checking } }