diff options
author | xue <> | 2005-11-16 22:32:52 +0000 |
---|---|---|
committer | xue <> | 2005-11-16 22:32:52 +0000 |
commit | 6c1b05deafd9940da5d473800032558df90b118e (patch) | |
tree | 3435de08a595fab3ca71ed41f3a88cc9ab6e2995 /framework/TApplication.php | |
parent | 65acec4f65ddefcb3e9f9762d958be0539f3f71a (diff) |
Key modules are now using registered to application rather than using reserved module names.
Diffstat (limited to 'framework/TApplication.php')
-rw-r--r-- | framework/TApplication.php | 114 |
1 files changed, 84 insertions, 30 deletions
diff --git a/framework/TApplication.php b/framework/TApplication.php index f1a7d316..441de82e 100644 --- a/framework/TApplication.php +++ b/framework/TApplication.php @@ -72,16 +72,6 @@ class TApplication extends TComponent implements IApplication 'PostSaveState',
'EndRequest'
);
- /**
- * @var array list of types that the named modules must be of
- */
- private static $_moduleTypes=array(
- 'request'=>'THttpRequest',
- 'response'=>'THttpResponse',
- 'session'=>'THttpSession',
- 'cache'=>'ICache',
- 'error'=>'IErrorHandler'
- );
/**
* @var string application ID
@@ -124,9 +114,33 @@ class TApplication extends TComponent implements IApplication */
private $_userType='System.Security.TUser';
/**
- * @var IUser user instance
+ * @var TErrorHandler error handler module
+ */
+ private $_errorHandler=null;
+ /**
+ * @var THttpRequest request module
+ */
+ private $_request=null;
+ /**
+ * @var THttpResponse response module
+ */
+ private $_response=null;
+ /**
+ * @var THttpSession session module, could be null
+ */
+ private $_session=null;
+ /**
+ * @var ICache cache module, could be null
+ */
+ private $_cache=null;
+ /**
+ * @var IUser user instance, could be null
*/
private $_user=null;
+ /**
+ * @var TAuthorizationRuleCollection collection of authorization rules
+ */
+ private $_authRules=null;
/**
* Constructor.
@@ -264,51 +278,83 @@ class TApplication extends TComponent implements IApplication }
/**
- * @return THttpRequest the request object
+ * @return THttpRequest the request module
*/
public function getRequest()
{
- return isset($this->_modules['request'])?$this->_modules['request']:null;
+ return $this->_request;
}
/**
- * @return THttpResponse the response object
+ * @param THttpRequest the request module
+ */
+ public function setRequest(THttpRequest $request)
+ {
+ $this->_request=$request;
+ }
+
+ /**
+ * @return THttpResponse the response module
*/
public function getResponse()
{
- return isset($this->_modules['response'])?$this->_modules['response']:null;
+ return $this->_response;
+ }
+
+ /**
+ * @param THttpRequest the request module
+ */
+ public function setResponse(THttpResponse $response)
+ {
+ $this->_response=$response;
+ }
+
+ /**
+ * @return TErrorHandler the error hanlder module
+ */
+ public function getErrorHandler()
+ {
+ return $this->_errorHandler;
+ }
+
+ /**
+ * @param TErrorHandler the error hanlder module
+ */
+ public function setErrorHandler(TErrorHandler $handler)
+ {
+ $this->_errorHandler=$handler;
}
/**
- * @return THttpSession the session object
+ * @return THttpSession the session module, null if session module is not installed
*/
public function getSession()
{
- return isset($this->_modules['session'])?$this->_modules['session']:null;
+ return $this->_session;
}
/**
- * @return ICache the cache object, null if not exists
+ * @param THttpSession the session module
*/
- public function getCache()
+ public function setSession(THttpSession $session)
{
- return isset($this->_modules['cache'])?$this->_modules['cache']:null;
+ $this->_session=$session;
}
/**
- * @return IErrorHandler the error hanlder module
+ * @return ICache the cache module, null if cache module is not installed
*/
- public function getErrorHandler()
+ public function getCache()
{
- return isset($this->_modules['error'])?$this->_modules['error']:null;
+ return $this->_cache;
}
/**
- * @return IRoleProvider provider for user auth management
+ * @param ICache the cache module
*/
- public function getAuthManager()
+ public function setCache(ICache $cache)
{
- return isset($this->_modules['auth'])?$this->_modules['auth']:null;
+ $this->_cache=$cache;
}
/**
@@ -328,6 +374,16 @@ class TApplication extends TComponent implements IApplication }
/**
+ * @return TAuthorizationRuleCollection list of authorization rules that may be applied
+ */
+ public function getAuthorizationRules()
+ {
+ if($this->_authRules===null)
+ $this->_authRules=new TAuthorizationRuleCollection;
+ return $this->_authRules;
+ }
+
+ /**
* Loads configuration and initializes application.
* Configuration file will be read and parsed (if a valid cache version exists,
* it will be used instead). Then, modules are created and initialized;
@@ -395,8 +451,6 @@ class TApplication extends TComponent implements IApplication if(isset($this->_modules[$id]))
throw new TConfigurationException('application_module_redefined',$id);
$module=Prado::createComponent($moduleConfig[0]);
- if(isset(self::$_moduleTypes[$id]) && !($module instanceof self::$_moduleTypes[$id]))
- throw new TConfigurationException('application_module_invalid',$id,self::$_moduleTypes[$id]);
$this->_modules[$id]=$module;
foreach($moduleConfig[1] as $name=>$value)
$module->setSubProperty($name,$value);
@@ -597,9 +651,9 @@ class TApplicationConfiguration extends TComponent * @var array list of module configurations
*/
private $_modules=array(
+ 'error'=>array('TErrorHandler',array(),null),
'request'=>array('THttpRequest',array(),null),
- 'response'=>array('THttpResponse',array(),null),
- 'error'=>array('TErrorHandler',array(),null)
+ 'response'=>array('THttpResponse',array(),null)
);
/**
* @var array list of service configurations
|