PRADO PHP Framework
Current file: /Users/knut/Sites/prado/svn/trunk/framework/TApplication.php
Legend: executed not executed dead code

  Coverage
  Classes Methods Lines
Total
25.00 %25.00%
25.00% 1 / 4
25.88 %25.88%
25.88% 22 / 85
16.40 %16.40%
16.40% 73 / 445
 
TApplication
100.00 %100.00%
100.00% 1 / 1
33.33 %33.33%
33.33% 22 / 66
24.50 %24.50%
24.50% 73 / 298
 public function __construct($basePath = 'protected', $cacheConfig = true)
100.00 %100.00%
100.00% 1 / 1
100.00 %100.00%
100.00% 8 / 8
 protected function resolvePaths($basePath)
100.00 %100.00%
100.00% 1 / 1
55.17 %55.17%
55.17% 16 / 29
 public function run()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 18
 public function completeRequest()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 2
 public function getRequestCompleted()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1
 public function getGlobalState($key, $defaultValue = NULL)
100.00 %100.00%
100.00% 1 / 1
100.00 %100.00%
100.00% 1 / 1
 public function setGlobalState($key, $value, $defaultValue = NULL)
100.00 %100.00%
100.00% 1 / 1
100.00 %100.00%
100.00% 5 / 5
 public function clearGlobalState($key)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 3
 protected function loadGlobals()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 2
 protected function saveGlobals()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 6
 public function getID()
100.00 %100.00%
100.00% 1 / 1
100.00 %100.00%
100.00% 1 / 1
 public function setID($value)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 2
 public function getUniqueID()
100.00 %100.00%
100.00% 1 / 1
100.00 %100.00%
100.00% 1 / 1
 public function getMode()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1
 public function setMode($value)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 2
 public function getBasePath()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1
 public function setBasePath($value)
100.00 %100.00%
100.00% 1 / 1
100.00 %100.00%
100.00% 2 / 2
 public function getConfigurationFile()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1
 public function setConfigurationFile($value)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 2
 public function getRuntimePath()
100.00 %100.00%
100.00% 1 / 1
100.00 %100.00%
100.00% 1 / 1
 public function setRuntimePath($value)
100.00 %100.00%
100.00% 1 / 1
100.00 %100.00%
100.00% 2 / 2
 public function getService()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1
 public function setService($value)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 2
 public function setModule($id, IModule $module)
100.00 %100.00%
100.00% 1 / 1
100.00 %100.00%
100.00% 4 / 4
 public function getModule($id)
100.00 %100.00%
100.00% 1 / 1
100.00 %100.00%
100.00% 1 / 1
 public function getModules()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1
 public function getParameters()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1
 public function getRequest()
100.00 %100.00%
100.00% 1 / 1
100.00 %100.00%
100.00% 6 / 6
 public function setRequest(THttpRequest $request)
100.00 %100.00%
100.00% 1 / 1
100.00 %100.00%
100.00% 2 / 2
 public function getResponse()
100.00 %100.00%
100.00% 1 / 1
50.00 %50.00%
50.00% 3 / 6
 public function setResponse(THttpResponse $response)
100.00 %100.00%
100.00% 1 / 1
100.00 %100.00%
100.00% 2 / 2
 public function getSession()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 6
 public function setSession(THttpSession $session)
100.00 %100.00%
100.00% 1 / 1
100.00 %100.00%
100.00% 2 / 2
 public function getErrorHandler()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 6
 public function setErrorHandler(TErrorHandler $handler)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 2
 public function getSecurityManager()
100.00 %100.00%
100.00% 1 / 1
100.00 %100.00%
100.00% 6 / 6
 public function setSecurityManager(TSecurityManager $sm)
100.00 %100.00%
100.00% 1 / 1
100.00 %100.00%
100.00% 2 / 2
 public function getAssetManager()
100.00 %100.00%
100.00% 1 / 1
50.00 %50.00%
50.00% 3 / 6
 public function setAssetManager(TAssetManager $value)
100.00 %100.00%
100.00% 1 / 1
100.00 %100.00%
100.00% 2 / 2
 public function getApplicationStatePersister()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 6
 public function setApplicationStatePersister(IStatePersister $persister)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 2
 public function getCache()
100.00 %100.00%
100.00% 1 / 1
100.00 %100.00%
100.00% 1 / 1
 public function setCache(ICache $cache)
100.00 %100.00%
100.00% 1 / 1
100.00 %100.00%
100.00% 2 / 2
 public function getUser()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1
 public function setUser(IUser $user)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 2
 public function getGlobalization($createIfNotExists = true)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 3
 public function setGlobalization(TGlobalization $glob)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 2
 public function getAuthorizationRules()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 3
 public function applyConfiguration($config, $withinService = false)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 52
 protected function initApplication()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 17
 public function startService($serviceID)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 22
 public function onError($param)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 4
 public function onBeginRequest()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 2
 public function onAuthentication()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 2
 public function onAuthenticationComplete()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 2
 public function onAuthorization()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 2
 public function onAuthorizationComplete()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 2
 public function onLoadState()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 3
 public function onLoadStateComplete()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 2
 public function onPreRunService()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 2
 public function runService()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 3
 public function onSaveState()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 3
 public function onSaveStateComplete()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 2
 public function onPreFlushOutput()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 2
 public function flushOutput()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 2
 public function onEndRequest()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 3
TApplicationMode
0.00 %0.00%
0.00% 0 / 1
100.00 %100.00%
100.00% 0 / 0
100.00 %100.00%
100.00% 0 / 0
TApplicationConfiguration
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 15
0.00 %0.00%
0.00% 0 / 126
 public function loadFromFile($fname)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 4
 public function getIsEmpty()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1
 public function loadFromXml($dom, $configPath)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 26
 protected function loadPathsXml($pathsNode, $configPath)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 29
 protected function loadModulesXml($modulesNode, $configPath)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 17
 protected function loadServicesXml($servicesNode, $configPath)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 15
 protected function loadParametersXml($parametersNode, $configPath)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 18
 protected function loadExternalXml($includeNode, $configPath)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 9
 public function getProperties()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1
 public function getAliases()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1
 public function getUsings()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1
 public function getModules()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1
 public function getServices()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1
 public function getParameters()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1
 public function getExternalConfigurations()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1
TApplicationStatePersister
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 4
0.00 %0.00%
0.00% 0 / 21
 public function init($config)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 2
 protected function getStateFilePath()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1
 public function load()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 5
 public function save($state)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 13


       1                 : <?php                                                                                                                
       2                 : /**                                                                                                                  
       3                 :  * TApplication class file                                                                                           
       4                 :  *                                                                                                                   
       5                 :  * @author Qiang Xue <qiang.xue@gmail.com>                                                                           
       6                 :  * @link http://www.pradosoft.com/                                                                                   
       7                 :  * @copyright Copyright &copy; 2005 PradoSoft                                                                        
       8                 :  * @license http://www.pradosoft.com/license/                                                                        
       9                 :  * @version $Id: TApplication.php 2244 2007-09-26 13:15:56Z xue $                                                    
      10                 :  * @package System                                                                                                   
      11                 :  */                                                                                                                  
      12                 :                                                                                                                      
      13                 : /**                                                                                                                  
      14                 :  * Includes core interfaces essential for TApplication class                                                         
      15                 :  */                                                                                                                  
      16                 : require_once(PRADO_DIR.'/interfaces.php');                                                                           
      17                 :                                                                                                                      
      18                 : /**                                                                                                                  
      19                 :  * Includes core classes essential for TApplication class                                                            
      20                 :  */                                                                                                                  
      21                 : Prado::using('System.TApplicationComponent');                                                                        
      22                 : Prado::using('System.TModule');                                                                                      
      23                 : Prado::using('System.TService');                                                                                     
      24                 : Prado::using('System.Exceptions.TErrorHandler');                                                                     
      25                 : Prado::using('System.Caching.TCache');                                                                               
      26                 : Prado::using('System.IO.TTextWriter');                                                                               
      27                 : Prado::using('System.Collections.TList');                                                                            
      28                 : Prado::using('System.Collections.TMap');                                                                             
      29                 : Prado::using('System.Collections.TStack');                                                                           
      30                 : Prado::using('System.Xml.TXmlDocument');                                                                             
      31                 : Prado::using('System.Security.TAuthorizationRule');                                                                  
      32                 : Prado::using('System.Security.TSecurityManager');                                                                    
      33                 : Prado::using('System.Web.THttpUtility');                                                                             
      34                 : Prado::using('System.Web.Javascripts.TJavaScript');                                                                  
      35                 : Prado::using('System.Web.THttpRequest');                                                                             
      36                 : Prado::using('System.Web.THttpResponse');                                                                            
      37                 : Prado::using('System.Web.THttpSession');                                                                             
      38                 : Prado::using('System.Web.Services.TPageService');                                                                    
      39                 : Prado::using('System.Web.TAssetManager');                                                                            
      40                 : Prado::using('System.I18N.TGlobalization');                                                                          
      41                 :                                                                                                                      
      42                 : /**                                                                                                                  
      43                 :  * TApplication class.                                                                                               
      44                 :  *                                                                                                                   
      45                 :  * TApplication coordinates modules and services, and serves as a configuration                                      
      46                 :  * context for all Prado components.                                                                                 
      47                 :  *                                                                                                                   
      48                 :  * TApplication uses a configuration file to specify the settings of                                                 
      49                 :  * the application, the modules, the services, the parameters, and so on.                                            
      50                 :  *                                                                                                                   
      51                 :  * TApplication adopts a modular structure. A TApplication instance is a composition                                 
      52                 :  * of multiple modules. A module is an instance of class implementing                                                
      53                 :  * {@link IModule} interface. Each module accomplishes certain functionalities                                       
      54                 :  * that are shared by all Prado components in an application.                                                        
      55                 :  * There are default modules and user-defined modules. The latter offers extreme                                     
      56                 :  * flexibility of extending TApplication in a plug-and-play fashion.                                                 
      57                 :  * Modules cooperate with each other to serve a user request by following                                            
      58                 :  * a sequence of lifecycles predefined in TApplication.                                                              
      59                 :  *                                                                                                                   
      60                 :  * TApplication has four modes that can be changed by setting {@link setMode Mode}                                   
      61                 :  * property (in the application configuration file).                                                                 
      62                 :  * - <b>Off</b> mode will prevent the application from serving user requests.                                        
      63                 :  * - <b>Debug</b> mode is mainly used during application development. It ensures                                     
      64                 :  *   the cache is always up-to-date if caching is enabled. It also allows                                            
      65                 :  *   exceptions are displayed with rich context information if they occur.                                           
      66                 :  * - <b>Normal</b> mode is mainly used during production stage. Exception information                                
      67                 :  *   will only be recorded in system error logs. The cache is ensured to be                                          
      68                 :  *   up-to-date if it is enabled.                                                                                    
      69                 :  * - <b>Performance</b> mode is similar to <b>Normal</b> mode except that it                                         
      70                 :  *   does not ensure the cache is up-to-date.                                                                        
      71                 :  *                                                                                                                   
      72                 :  * TApplication dispatches each user request to a particular service which                                           
      73                 :  * finishes the actual work for the request with the aid from the application                                        
      74                 :  * modules.                                                                                                          
      75                 :  *                                                                                                                   
      76                 :  * TApplication maintains a lifecycle with the following stages:                                                     
      77                 :  * - [construct] : construction of the application instance                                                          
      78                 :  * - [initApplication] : load application configuration and instantiate modules and the requested service            
      79                 :  * - onBeginRequest : this event happens right after application initialization                                      
      80                 :  * - onAuthentication : this event happens when authentication is needed for the current request                     
      81                 :  * - onAuthenticationComplete : this event happens right after the authentication is done for the current request    
      82                 :  * - onAuthorization : this event happens when authorization is needed for the current request                       
      83                 :  * - onAuthorizationComplete : this event happens right after the authorization is done for the current request      
      84                 :  * - onLoadState : this event happens when application state needs to be loaded                                      
      85                 :  * - onLoadStateComplete : this event happens right after the application state is loaded                            
      86                 :  * - onPreRunService : this event happens right before the requested service is to run                               
      87                 :  * - runService : the requested service runs                                                                         
      88                 :  * - onSaveState : this event happens when application needs to save its state                                       
      89                 :  * - onSaveStateComplete : this event happens right after the application saves its state                            
      90                 :  * - onPreFlushOutput : this event happens right before the application flushes output to client side.               
      91                 :  * - flushOutput : the application flushes output to client side.                                                    
      92                 :  * - onEndRequest : this is the last stage a request is being completed                                              
      93                 :  * - [destruct] : destruction of the application instance                                                            
      94                 :  * Modules and services can attach their methods to one or several of the above                                      
      95                 :  * events and do appropriate processing when the events are raised. By this way,                                     
      96                 :  * the application is able to coordinate the activities of modules and services                                      
      97                 :  * in the above order. To terminate an application before the whole lifecycle                                        
      98                 :  * completes, call {@link completeRequest}.                                                                          
      99                 :  *                                                                                                                   
     100                 :  * Examples:                                                                                                         
     101                 :  * - Create and run a Prado application:                                                                             
     102                 :  * <code>                                                                                                            
     103                 :  * $application=new TApplication($configFile);                                                                       
     104                 :  * $application->run();                                                                                              
     105                 :  * </code>                                                                                                           
     106                 :  *                                                                                                                   
     107                 :  * @author Qiang Xue <qiang.xue@gmail.com>                                                                           
     108                 :  * @version $Id: TApplication.php 2244 2007-09-26 13:15:56Z xue $                                                    
     109                 :  * @package System                                                                                                   
     110                 :  * @since 3.0                                                                                                        
     111                 :  */                                                                                                                  
     112                 : class TApplication extends TComponent                                                                                
     113                 : {                                                                                                                    
     114                 : 	/**                                                                                                                 
     115                 : 	 * possible application mode.                                                                                       
     116                 : 	 * @deprecated deprecated since version 3.0.4 (use TApplicationMode constants instead)                              
     117                 : 	 */                                                                                                                 
     118                 : 	const STATE_OFF='Off';                                                                                              
     119                 : 	const STATE_DEBUG='Debug';                                                                                          
     120                 : 	const STATE_NORMAL='Normal';                                                                                        
     121                 : 	const STATE_PERFORMANCE='Performance';                                                                              
     122                 :                                                                                                                      
     123                 : 	/**                                                                                                                 
     124                 : 	 * Page service ID                                                                                                  
     125                 : 	 */                                                                                                                 
     126                 : 	const PAGE_SERVICE_ID='page';                                                                                       
     127                 : 	/**                                                                                                                 
     128                 : 	 * Application configuration file name                                                                              
     129                 : 	 */                                                                                                                 
     130                 : 	const CONFIG_FILE='application.xml';                                                                                
     131                 : 	/**                                                                                                                 
     132                 : 	 * File extension for external config files                                                                         
     133                 : 	 */