summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorxue <>2006-02-08 22:33:11 +0000
committerxue <>2006-02-08 22:33:11 +0000
commit682d48577ae6e0118a11e5e6134fdbbb6048456d (patch)
treef1210e77e88ff2dc4e565f78fdf0227ee5c80ebb /framework
parentb4103f28384d4ce9b5dc8e8a1abfda378eb42db0 (diff)
Updated application lifecycle and related tutorial description.
Diffstat (limited to 'framework')
-rw-r--r--framework/Log/TLogRouter.php2
-rw-r--r--framework/TApplication.php35
-rw-r--r--framework/Web/THttpResponse.php3
3 files changed, 18 insertions, 22 deletions
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();
}