Class CApplication
CApplication is the base class for all application classes.
An application serves as the global context that the user request is being processed. It manages a set of application components that provide specific functionalities to the whole application.
The core application components provided by CApplication are the following:- getErrorHandler errorHandler: handles PHP errors and uncaught exceptions. This application component is dynamically loaded when needed.
- getSecurityManager securityManager: provides security-related services, such as hashing, encryption. This application component is dynamically loaded when needed.
- getStatePersister statePersister: provides global state persistence method. This application component is dynamically loaded when needed.
- getCache cache: provides caching feature. This application component is disabled by default.
- getMessages messages: provides the message source for translating application messages. This application component is dynamically loaded when needed.
- getCoreMessages coreMessages: provides the message source for translating Yii framework messages. This application component is dynamically loaded when needed.
- getUrlManager urlManager: provides URL construction as well as parsing functionality. This application component is dynamically loaded when needed.
- getRequest request: represents the current HTTP request by encapsulating the $_SERVER variable and managing cookies sent from and sent to the user. This application component is dynamically loaded when needed.
- getFormat format: provides a set of commonly used data formatting methods. This application component is dynamically loaded when needed.
- load application configuration;
- set up error handling;
- load static application components;
CApplication::onBeginRequest()
: preprocess the user request;CApplication::processRequest()
: process the user request;CApplication::onEndRequest()
: postprocess the user request;
Starting from lifecycle 3, if a PHP error or an uncaught exception occurs, the application will switch to its error handling logic and jump to step 6 afterwards.
- CComponent
- CModule
- CApplication
Indirect known subclasses
X2WebApplicationPackage: system\base
Copyright: 2008-2013 Yii Software LLC
License: http://www.yiiframework.com/license/
Author: Qiang Xue <qiang.xue@gmail.com>
Since: 1.0
Located at x2engine/framework/base/CApplication.php
abstract public
|
#
processRequest( )
Processes the request. This is the place where the actual request processing work is done. Derived classes should override this method. |
public
|
|
public
|
|
public
|
#
end( integer $status = 0, boolean $exit = true )
Terminates the application. This method replaces PHP's exit() function by
calling |
public
|
|
public
|
|
public
string
|
|
public
|
|
public
string
|
|
public
|
#
setBasePath( string $path )
Sets the root directory of the application. This method can only be invoked at the begin of the constructor. |
public
string
|
|
public
|
|
public
string
|
|
public
|
|
public
string
|
#
getLanguage( )
Returns the language that the user is using and the application should be targeted to. |
public
|
|
public
string
|
#
getTimeZone( )
Returns the time zone used by this application. This is a simple wrapper of PHP function date_default_timezone_get(). |
public
|
#
setTimeZone( string $value )
Sets the time zone used by this application. This is a simple wrapper of PHP function date_default_timezone_set(). |
public
string
|
#
findLocalizedFile( string $srcFile, string $srcLanguage = null, string $language = null )
Returns the localized version of a specified file. |
public
an
|
|
public
string
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
string
|
|
public
string
|
#
createAbsoluteUrl( string $route, array $params = array(), string $schema = '', string $ampersand = '&' )
Creates an absolute URL based on the given controller and action information. |
public
string
|
#
getBaseUrl( boolean $absolute = false )
Returns the relative URL for the application. This is a shortcut method to
|
public
string
|
|
public
|
|
public
mixed
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
#
handleError( integer $code, string $message, string $file, integer $line )
Handles PHP execution errors such as warnings, notices. |
public
|
|
public
|
|
public
|
#
displayError( integer $code, string $message, string $file, string $line )
Displays the captured PHP error. This method displays the error in HTML when there is no active error handler. |
public
|
#
displayException(
Displays the uncaught PHP exception. This method displays the exception in HTML when there is no active error handler. |
protected
|
|
protected
|
public
string
|
$name | 'My Application' |
#
the application name. Defaults to 'My Application'. |
public
string
|
$charset | 'UTF-8' |
#
the charset currently used for the application. Defaults to 'UTF-8'. |
public
string
|
$sourceLanguage | 'en_us' |
#
the language that the application is written in. This mainly refers to the language that the messages and view files are in. Defaults to 'en_us' (US English). |
public
string
|
$localeClass | 'CLocale' |
#
the class used to get locale data. Defaults to 'CLocale'. |
$behaviors,
$preload
|
public
string
|
$id |
#
The unique identifier for the application. |
public
string
|
$basePath |
#
The root directory of the application. Defaults to 'protected'. |
public
string
|
$runtimePath |
#
The directory that stores runtime files. Defaults to 'protected/runtime'. |
public
string
|
$extensionPath |
#
The directory that contains all extensions. Defaults to the 'extensions' directory under 'protected'. |
public
string
|
$language |
#
The language that the user is using and the application should be targeted to. Defaults to the sourceLanguage source language. |
public
string
|
$timeZone |
#
The time zone used by this application. |
public
|
$locale |
#
The locale instance. |
public
string
|
$localeDataPath |
#
The directory that contains the locale data. It defaults to 'framework/i18n/data'. |
public
|
$numberFormatter |
#
The locale-dependent number formatter. The current getLocale application locale will be used. |
public
|
$dateFormatter |
#
The locale-dependent date formatter. The current getLocale application locale will be used. |
public
|
$db |
#
The database connection. |
public
|
$errorHandler |
#
The error handler application component. |
public
|
$securityManager |
#
The security manager application component. |
public
|
$statePersister |
#
The state persister application component. |
public
|
$cache |
#
The cache application component. Null if the component is not enabled. |
public
|
$coreMessages |
#
The core message translations. |
public
|
$messages |
#
The application message translations. |
public
|
$request |
#
The request component. |
public
|
$urlManager |
#
The URL manager component. |
public
|
$controller |
#
The currently active controller. Null is returned in this base class. |
public
string
|
$baseUrl |
#
The relative URL for the application. |
public
string
|
$homeUrl |
#
The homepage URL. |
$aliases,
$components,
$import,
$modulePath,
$modules,
$params,
$parentModule
|