diff options
-rw-r--r-- | demos/quickstart/protected/pages/Fundamentals/applifecycles.gif | bin | 34714 -> 31200 bytes | |||
-rw-r--r-- | demos/quickstart/protected/pages/Fundamentals/applifecycles.vsd | bin | 216576 -> 220672 bytes | |||
-rw-r--r-- | framework/Log/TLogRouter.php | 2 | ||||
-rw-r--r-- | framework/TApplication.php | 35 | ||||
-rw-r--r-- | framework/Web/THttpResponse.php | 3 |
5 files changed, 18 insertions, 22 deletions
diff --git a/demos/quickstart/protected/pages/Fundamentals/applifecycles.gif b/demos/quickstart/protected/pages/Fundamentals/applifecycles.gif Binary files differindex e4fc306c..d5300aa6 100644 --- a/demos/quickstart/protected/pages/Fundamentals/applifecycles.gif +++ b/demos/quickstart/protected/pages/Fundamentals/applifecycles.gif diff --git a/demos/quickstart/protected/pages/Fundamentals/applifecycles.vsd b/demos/quickstart/protected/pages/Fundamentals/applifecycles.vsd Binary files differindex 0f0e2bab..56f6602d 100644 --- a/demos/quickstart/protected/pages/Fundamentals/applifecycles.vsd +++ b/demos/quickstart/protected/pages/Fundamentals/applifecycles.vsd diff --git a/framework/Log/TLogRouter.php b/framework/Log/TLogRouter.php index 06877f0f..5326b598 100644 --- a/framework/Log/TLogRouter.php +++ b/framework/Log/TLogRouter.php @@ -68,7 +68,7 @@ class TLogRouter extends TModule throw new TConfigurationException('logrouter_configfile_invalid',$this->_configFile);
}
$this->loadConfig($config);
- $this->getApplication()->attachEventHandler('OnExitApplication',array($this,'collectLogs'));
+ $this->getApplication()->attachEventHandler('OnEndRequest',array($this,'collectLogs'));
}
/**
diff --git a/framework/TApplication.php b/framework/TApplication.php index b85e3dcc..1a982488 100644 --- a/framework/TApplication.php +++ b/framework/TApplication.php @@ -87,7 +87,6 @@ require_once(PRADO_DIR.'/Web/Services/TPageService.php'); * - onPreFlushOutput : this event happens right before the application flushes output to client side. * - flushOutput : the application flushes output to client side. * - onEndRequest : this is the last stage a request is being completed - * - onExitApplication : this is the last stage before application instance is destructed * - [destruct] : destruction of the application instance * Modules and services can attach their methods to one or several of the above * events and do appropriate processing when the events are raised. By this way, @@ -154,8 +153,7 @@ class TApplication extends TComponent 'onSaveState', 'onSaveStateComplete', 'onPreFlushOutput', - 'flushOutput', - 'onEndRequest' + 'flushOutput' ); /** @@ -333,20 +331,19 @@ class TApplication extends TComponent { if($this->_mode===self::STATE_OFF) throw new THttpException(503,'application_service_unavailable'); + if($this->_requestCompleted) + break; $method=self::$_steps[$this->_step]; - Prado::trace("Executing $method",'System.TApplication'); + Prado::trace("Executing $method()",'System.TApplication'); $this->$method(); - if($this->_requestCompleted && $this->_step<$n-1) - $this->_step=$n-1; - else - $this->_step++; + $this->_step++; } } catch(Exception $e) { $this->onError($e); } - $this->onExitApplication(); + $this->onEndRequest(); } /** @@ -360,6 +357,14 @@ class TApplication extends TComponent } /** + * @return boolean whether the current request is processed. + */ + public function getRequestCompleted() + { + return $this->_requestCompleted; + } + + /** * Returns a global value. * * A global value is one that is persistent across users sessions and requests. @@ -831,8 +836,8 @@ class TApplication extends TComponent public function onError($param) { Prado::log($param->getMessage(),TLogger::ERROR,'System.TApplication'); - $this->getErrorHandler()->handleError($this,$param); $this->raiseEvent('OnError',$this,$param); + $this->getErrorHandler()->handleError($this,$param); } /** @@ -964,16 +969,6 @@ class TApplication extends TComponent { $this->raiseEvent('OnEndRequest',$this,null); } - - /** - * Raises OnExitApplication event. - * This method is invoked when the application instance is being destructed. - * Do not raise exceptions within this method or in the event handler. - */ - public function onExitApplication() - { - $this->raiseEvent('OnExitApplication',$this,null); - } } diff --git a/framework/Web/THttpResponse.php b/framework/Web/THttpResponse.php index d64a82af..a8c3777a 100644 --- a/framework/Web/THttpResponse.php +++ b/framework/Web/THttpResponse.php @@ -265,7 +265,8 @@ class THttpResponse extends TModule implements ITextWriter */
public function redirect($url)
{
- $this->getApplication()->onExitApplication();
+ if(!$this->getApplication()->getRequestCompleted())
+ $this->getApplication()->onEndRequest();
header('Location:'.$url);
exit();
}
|