[ Index ]
 

Code source de PRADO 3.0.6

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/framework/ -> TApplication.php (sommaire)

TApplication class file

Author: Qiang Xue <qiang.xue@gmail.com>
Copyright: Copyright © 2005 PradoSoft
License: http://www.pradosoft.com/license/
Version: $Id: TApplication.php 1559 2006-12-04 03:03:21Z xue $
Poids: 1332 lignes (36 kb)
Inclus ou requis:0 fois
Référencé: 0 fois
Nécessite: 20 fichiers
 framework/Web/THttpResponse.php
 framework/interfaces.php
 framework/Web/THttpUtility.php
 framework/Exceptions/TErrorHandler.php
 framework/Collections/TMap.php
 framework/Web/THttpSession.php
 framework/IO/TTextWriter.php
 framework/Web/THttpRequest.php
 framework/Web/Javascripts/TJavaScript.php
 framework/Xml/TXmlDocument.php
 framework/TApplicationComponent.php
 framework/TModule.php
 framework/Security/TSecurityManager.php
 framework/I18N/TGlobalization.php
 framework/Web/TAssetManager.php
 framework/Security/TAuthorizationRule.php
 framework/Collections/TList.php
 framework/Web/Services/TPageService.php
 framework/Caching/TCache.php
 framework/TService.php

Définit 4 classes

TApplication:: (61 méthodes):
  __construct()
  run()
  completeRequest()
  getRequestCompleted()
  getGlobalState()
  setGlobalState()
  clearGlobalState()
  loadGlobals()
  saveGlobals()
  getID()
  setID()
  getUniqueID()
  getMode()
  setMode()
  getBasePath()
  getConfigurationFile()
  getRuntimePath()
  getService()
  setModule()
  getModule()
  getModules()
  getParameters()
  getPageService()
  setPageService()
  getRequest()
  setRequest()
  getResponse()
  setResponse()
  getSession()
  setSession()
  getErrorHandler()
  setErrorHandler()
  getSecurityManager()
  setSecurityManager()
  getAssetManager()
  setAssetManager()
  getApplicationStatePersister()
  setApplicationStatePersister()
  getCache()
  setCache()
  getUser()
  setUser()
  getGlobalization()
  setGlobalization()
  getAuthorizationRules()
  initApplication()
  onError()
  onBeginRequest()
  onAuthentication()
  onAuthenticationComplete()
  onAuthorization()
  onAuthorizationComplete()
  onLoadState()
  onLoadStateComplete()
  onPreRunService()
  runService()
  onSaveState()
  onSaveStateComplete()
  onPreFlushOutput()
  flushOutput()
  onEndRequest()

TApplicationMode:: (0 méthodes):

TApplicationConfiguration:: (7 méthodes):
  loadFromFile()
  getProperties()
  getAliases()
  getUsings()
  getModules()
  getServices()
  getParameters()

TApplicationStatePersister:: (4 méthodes):
  init()
  getStateFilePath()
  load()
  save()


Classe: TApplication  - X-Ref

TApplication class.

TApplication coordinates modules and services, and serves as a configuration
context for all Prado components.

TApplication uses a configuration file to specify the settings of
the application, the modules, the services, the parameters, and so on.

TApplication adopts a modular structure. A TApplication instance is a composition
of multiple modules. A module is an instance of class implementing
{@link IModule} interface. Each module accomplishes certain functionalities
that are shared by all Prado components in an application.
There are default modules and user-defined modules. The latter offers extreme
flexibility of extending TApplication in a plug-and-play fashion.
Modules cooperate with each other to serve a user request by following
a sequence of lifecycles predefined in TApplication.

TApplication has four modes that can be changed by setting {@link setMode Mode}
property (in the application configuration file).
- <b>Off</b> mode will prevent the application from serving user requests.
- <b>Debug</b> mode is mainly used during application development. It ensures
the cache is always up-to-date if caching is enabled. It also allows
exceptions are displayed with rich context information if they occur.
- <b>Normal</b> mode is mainly used during production stage. Exception information
will only be recorded in system error logs. The cache is ensured to be
up-to-date if it is enabled.
- <b>Performance</b> mode is similar to <b>Normal</b> mode except that it
does not ensure the cache is up-to-date.

TApplication dispatches each user request to a particular service which
finishes the actual work for the request with the aid from the application
modules.

TApplication maintains a lifecycle with the following stages:
- [construct] : construction of the application instance
- [initApplication] : load application configuration and instantiate modules and the requested service
- onBeginRequest : this event happens right after application initialization
- onAuthentication : this event happens when authentication is needed for the current request
- onAuthenticationComplete : this event happens right after the authentication is done for the current request
- onAuthorization : this event happens when authorization is needed for the current request
- onAuthorizationComplete : this event happens right after the authorization is done for the current request
- onLoadState : this event happens when application state needs to be loaded
- onLoadStateComplete : this event happens right after the application state is loaded
- onPreRunService : this event happens right before the requested service is to run
- runService : the requested service runs
- onSaveState : this event happens when application needs to save its state
- onSaveStateComplete : this event happens right after the application saves its state
- 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
- [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,
the application is able to coordinate the activities of modules and services
in the above order. To terminate an application before the whole lifecycle
completes, call {@link completeRequest}.

Examples:
- Create and run a Prado application:
<code>
$application=new TApplication($configFile);
$application->run();
</code>

__construct($basePath='protected',$cacheConfig=true)   X-Ref
Constructor.
Sets application base path and initializes the application singleton.
Application base path refers to the root directory storing application
data and code not directly accessible by Web users.
By default, the base path is assumed to be the <b>protected</b>
directory under the directory containing the current running script.

param: string application base path or configuration file path.
param: boolean whether to cache application configuration. Defaults to true.

run()   X-Ref
Executes the lifecycles of the application.
This is the main entry function that leads to the running of the whole
Prado application.


completeRequest()   X-Ref
Completes current request processing.
This method can be used to exit the application lifecycles after finishing
the current cycle.


getRequestCompleted()   X-Ref

return: boolean whether the current request is processed.

getGlobalState($key,$defaultValue=null)   X-Ref
Returns a global value.

A global value is one that is persistent across users sessions and requests.
param: string the name of the value to be returned
param: mixed the default value. If $key is not found, $defaultValue will be returned
return: mixed the global value corresponding to $key

setGlobalState($key,$value,$defaultValue=null)   X-Ref
Sets a global value.

A global value is one that is persistent across users sessions and requests.
Make sure that the value is serializable and unserializable.
param: string the name of the value to be set
param: mixed the global value to be set
param: mixed the default value. If $key is not found, $defaultValue will be returned

clearGlobalState($key)   X-Ref
Clears a global value.

The value cleared will no longer be available in this request and the following requests.
param: string the name of the value to be cleared

loadGlobals()   X-Ref
Loads global values from persistent storage.
This method is invoked when {@link onLoadState OnLoadState} event is raised.
After this method, values that are stored in previous requests become
available to the current request via {@link getGlobalState}.


saveGlobals()   X-Ref
Saves global values into persistent storage.
This method is invoked when {@link onSaveState OnSaveState} event is raised.


getID()   X-Ref

return: string application ID

setID($value)   X-Ref

param: string application ID

getUniqueID()   X-Ref

return: string an ID that uniquely identifies this Prado application from the others

getMode()   X-Ref

return: TApplicationMode application mode. Defaults to TApplicationMode::Debug.

setMode($value)   X-Ref

param: TApplicationMode application mode

getBasePath()   X-Ref

return: string configuration path

getConfigurationFile()   X-Ref

return: string configuration file path

getRuntimePath()   X-Ref
Gets the directory storing application-level persistent data.

return: string application state path

getService()   X-Ref

return: IService the currently requested service

setModule($id,IModule $module)   X-Ref
Adds a module to application.
Note, this method does not do module initialization.

param: string ID of the module
param: IModule module object

getModule($id)   X-Ref

return: IModule the module with the specified ID, null if not found

getModules()   X-Ref

return: array list of loaded application modules, indexed by module IDs

getParameters()   X-Ref
Returns the list of application parameters.
Since the parameters are returned as a {@link TMap} object, you may use
the returned result to access, add or remove individual parameters.

return: TMap the list of application parameters

getPageService()   X-Ref

return: TPageService page service

setPageService(TPageService $service)   X-Ref
Registers the page service instance.
This method should only be used by framework developers.

param: TPageService page service

getRequest()   X-Ref

return: THttpRequest the request module

setRequest(THttpRequest $request)   X-Ref

param: THttpRequest the request module

getResponse()   X-Ref

return: THttpResponse the response module

setResponse(THttpResponse $response)   X-Ref

param: THttpRequest the request module

getSession()   X-Ref

return: THttpSession the session module, null if session module is not installed

setSession(THttpSession $session)   X-Ref

param: THttpSession the session module

getErrorHandler()   X-Ref

return: TErrorHandler the error hanlder module

setErrorHandler(TErrorHandler $handler)   X-Ref

param: TErrorHandler the error hanlder module

getSecurityManager()   X-Ref

return: TSecurityManager the security manager module

setSecurityManager(TSecurityManager $sm)   X-Ref

param: TSecurityManager the security manager module

getAssetManager()   X-Ref

return: TAssetManager asset manager

setAssetManager(TAssetManager $value)   X-Ref

param: TAssetManager asset manager

getApplicationStatePersister()   X-Ref

return: IStatePersister application state persister

setApplicationStatePersister(IStatePersister $persister)   X-Ref

param: IStatePersister  application state persister

getCache()   X-Ref

return: ICache the cache module, null if cache module is not installed

setCache(ICache $cache)   X-Ref

param: ICache the cache module

getUser()   X-Ref

return: IUser the application user

setUser(IUser $user)   X-Ref

param: IUser the application user

getGlobalization($createIfNotExists=true)   X-Ref

param: boolean whether to create globalization if it does not exist
return: TGlobalization globalization module

setGlobalization(TGlobalization $glob)   X-Ref

param: TGlobalization globalization module

getAuthorizationRules()   X-Ref

return: TAuthorizationRuleCollection list of authorization rules for the current request

initApplication()   X-Ref
Loads configuration and initializes application.
Configuration file will be read and parsed (if a valid cached version exists,
it will be used instead). Then, modules are created and initialized;
Afterwards, the requested service is created and initialized.

param: string configuration file path (absolute or relative to current executing script)
param: string cache file path, empty if no present or needed

onError($param)   X-Ref
Raises OnError event.
This method is invoked when an exception is raised during the lifecycles
of the application.

param: mixed event parameter

onBeginRequest()   X-Ref
Raises OnBeginRequest event.
At the time when this method is invoked, application modules are loaded
and initialized, user request is resolved and the corresponding service
is loaded and initialized. The application is about to start processing
the user request.


onAuthentication()   X-Ref
Raises OnAuthentication event.
This method is invoked when the user request needs to be authenticated.


onAuthenticationComplete()   X-Ref
Raises OnAuthenticationComplete event.
This method is invoked right after the user request is authenticated.


onAuthorization()   X-Ref
Raises OnAuthorization event.
This method is invoked when the user request needs to be authorized.


onAuthorizationComplete()   X-Ref
Raises OnAuthorizationComplete event.
This method is invoked right after the user request is authorized.


onLoadState()   X-Ref
Raises OnLoadState event.
This method is invoked when the application needs to load state (probably stored in session).


onLoadStateComplete()   X-Ref
Raises OnLoadStateComplete event.
This method is invoked right after the application state has been loaded.


onPreRunService()   X-Ref
Raises OnPreRunService event.
This method is invoked right before the service is to be run.


runService()   X-Ref
Runs the requested service.


onSaveState()   X-Ref
Raises OnSaveState event.
This method is invoked when the application needs to save state (probably stored in session).


onSaveStateComplete()   X-Ref
Raises OnSaveStateComplete event.
This method is invoked right after the application state has been saved.


onPreFlushOutput()   X-Ref
Raises OnPreFlushOutput event.
This method is invoked right before the application flushes output to client.


flushOutput()   X-Ref
Flushes output to client side.


onEndRequest()   X-Ref
Raises OnEndRequest event.
This method is invoked when the application completes the processing of the request.


Classe: TApplicationMode  - X-Ref

TApplicationMode class.
TApplicationMode defines the possible mode that an application can be set at by
setting {@link TApplication::setMode Mode}.
In particular, the following modes are defined
- Off: the application is not running. Any request to the application will obtain an error.
- Debug: the application is running in debug mode.
- Debug: the application is running in normal production mode.
- Performance: the application is running in performance mode.

Classe: TApplicationConfiguration  - X-Ref

TApplicationConfiguration class.

This class is used internally by TApplication to parse and represent application configuration.

loadFromFile($fname)   X-Ref
Parses the application configuration file.

param: string configuration file name

getProperties()   X-Ref

return: array list of application initial property values, indexed by property names

getAliases()   X-Ref

return: array list of path aliases, indexed by alias names

getUsings()   X-Ref

return: array list of namespaces to be used

getModules()   X-Ref

return: array list of module configurations

getServices()   X-Ref

return: array list of service configurations

getParameters()   X-Ref

return: array list of parameters

Classe: TApplicationStatePersister  - X-Ref

TApplicationStatePersister class.
TApplicationStatePersister provides a file-based persistent storage
for application state. Application state, when serialized, is stored
in a file named 'global.cache' under the 'runtime' directory of the application.
Cache will be exploited if it is enabled.

init($config)   X-Ref
Initializes module.

param: TXmlElement module configuration (may be null)

getStateFilePath()   X-Ref

return: string the file path storing the application state

load()   X-Ref
Loads application state from persistent storage.

return: mixed application state

save($state)   X-Ref
Saves application state in persistent storage.

param: mixed application state



Généré le : Sun Feb 25 21:07:04 2007 par Balluche grâce à PHPXref 0.7