CWebApplication

CDbHttpSession

Yii Framework v1.1.10 类参考

CWebApplication

system.web
继承 class CWebApplication » CApplication » CModule » CComponent
源自 1.0
版本 $Id: CWebApplication.php 3515 2011-12-28 12:29:24Z mdomba $
源码 framework/web/CWebApplication.php
CWebApplication extends CApplication by providing functionalities specific to Web requests.

CWebApplication manages the controllers in MVC pattern, and provides the following additional core application components:
  • urlManager: provides URL parsing and constructing functionality;
  • request: encapsulates the Web request information;
  • session: provides the session-related functionalities;
  • assetManager: manages the publishing of private asset files.
  • user: represents the user session information.
  • themeManager: manages themes.
  • authManager: manages role-based access control (RBAC).
  • clientScript: manages client scripts (javascripts and CSS).
  • widgetFactory: creates widgets and supports widget skinning.


User requests are resolved as controller-action pairs and additional parameters. CWebApplication creates the requested controller instance and let it to handle the actual user request. If the user does not specify controller ID, it will assume defaultController is requested (which defaults to 'site').

Controller class files must reside under the directory controllerPath (defaults to 'protected/controllers'). The file name and the class name must be the same as the controller ID with the first letter in upper case and appended with 'Controller'. For example, the controller 'article' is defined by the class 'ArticleController' which is in the file 'protected/controllers/ArticleController.php'.

公共属性

隐藏继承属性

属性类型描述定义在
assetManager CAssetManager the asset manager component CWebApplication
authManager IAuthManager the authorization manager component CWebApplication
basePath string 返回应用程序的根目录。 CApplication
baseUrl string 返回应用程序的相对URL。 CApplication
behaviors array the behaviors that should be attached to the module. CModule
cache CCache 返回缓存组件。 CApplication
catchAllRequest array the configuration specifying a controller which should handle all user requests. CWebApplication
charset string 应用程序当前使用的字符集。默认为‘UTF-8’。 CApplication
clientScript CClientScript Returns the client script manager. CWebApplication
components array 返回应用组件。 CModule
controller CController the currently active controller CWebApplication
controllerMap array mapping from controller ID to controller configurations. CWebApplication
controllerPath string the directory that contains the controller classes. CWebApplication
coreMessages CPhpMessageSource 返回核心信息翻译组件。 CApplication
dateFormatter CDateFormatter 返回本地化的日期格式。 CApplication
db CDbConnection 返回数据库连接组件。 CApplication
defaultController string the route of the default controller, action or module. CWebApplication
errorHandler CErrorHandler 返回错误处理组件。 CApplication
extensionPath string 返回第三方扩展根目录。 CApplication
homeUrl string 主页URL CApplication
id string 返回应用程序的唯一标识符。 CApplication
language string 返回用户正在使用的应用程序语言。 CApplication
layout mixed the application-wide layout. CWebApplication
layoutPath string the root directory of layout files. CWebApplication
locale CLocale 返回本地(环境)实例。 CApplication
localeDataPath string 返回包含本地化的数据目录。 CApplication
messages CMessageSource 返回应用程序信息翻译组件。 CApplication
modulePath string 返回包含应用程序模块的目录。 CModule
modules array 返回应用程序当前已经安装的模块。 CModule
name string 应用程序名字。默认为‘My Application’。 CApplication
numberFormatter CNumberFormatter 本地化数字格式。 将使用当前application locale CApplication
params CAttributeCollection 返回用户定义的参数。 CModule
parentModule CModule 返回父模块。 CModule
preload array the IDs of the application components that should be preloaded. CModule
request CHttpRequest 返回请求组件。 CApplication
runtimePath string 返回存储运行时文件目录。 CApplication
securityManager CSecurityManager 返回安全管理器组件。 CApplication
session CHttpSession the session component CWebApplication
sourceLanguage string 应用程序使用语言. CApplication
statePersister CStatePersister 返回持久状态组件。 CApplication
systemViewPath string the root directory of system view files. CWebApplication
theme CTheme the theme used currently. CWebApplication
themeManager CThemeManager the theme manager. CWebApplication
timeZone string 返回应用程序所使用的时区。 CApplication
urlManager CUrlManager 返回URL管理器组件。 CApplication
user CWebUser the user session information CWebApplication
viewPath string the root directory of view files. CWebApplication
viewRenderer IViewRenderer Returns the view renderer. CWebApplication
widgetFactory IWidgetFactory Returns the widget factory. CWebApplication

公共方法

隐藏继承方法

方法描述定义在
__call() 如果类中没有调的方法名,则调用这个方法。 CComponent
__construct() 构造器。 CApplication
__get() getter魔术方法。 CModule
__isset() 检查一个属性值是否为null。 CModule
__set() 设置一个组件的属性值。 CComponent
__unset() 设置一个组件的属性为null。 CComponent
afterControllerAction() The post-filter for controller actions. CWebApplication
asa() 返回这个名字的行为对象。 CComponent
attachBehavior() 附加一个行为到组件。 CComponent
attachBehaviors() 附加一个行为列表到组件。 CComponent
attachEventHandler() 为事件附加一个事件处理程序。 CComponent
beforeControllerAction() The pre-filter for controller actions. CWebApplication
canGetProperty() 确定属性是否可读。 CComponent
canSetProperty() 确定属性是否可写。 CComponent
clearGlobalState() 清空一个全局值。 CApplication
configure() 为模块指定配置。 CModule
createAbsoluteUrl() 创建一个基于给定控制器和动作(信息)绝对的URL。 CApplication
createController() Creates a controller instance based on a route. CWebApplication
createUrl() 创建一个基于给定控制器和动作(信息)相对的URL。 CApplication
detachBehavior() 从组件中分离一个行为。 CComponent
detachBehaviors() 从组件中分离所有行为。 CComponent
detachEventHandler() 分离一个存在的事件处理程序。 CComponent
disableBehavior() 禁用一个附加行为。 CComponent
disableBehaviors() 禁用组件附加的所有行为。 CComponent
displayError() 显示捕获的PHP错误。 CApplication
displayException() 显示未捕获的PHP异常。 CApplication
enableBehavior() 启用一个附加行为。 CComponent
enableBehaviors() 启用组件附加的所有行为。 CComponent
end() 终止应用程序。 CApplication
evaluateExpression() 计算一个PHP表达式,或根据组件上下文执行回调。 CComponent
findLocalizedFile() 返回指定文件的本地化版本。 CApplication
findModule() Do not call this method. This method is used internally to search for a module by its ID. CWebApplication
getAssetManager() 返回the asset manager component CWebApplication
getAuthManager() 返回the authorization manager component CWebApplication
getBasePath() 返回应用程序的根目录。 CApplication
getBaseUrl() 返回应用程序的相对URL。 CApplication
getCache() 返回缓存组件。 CApplication
getClientScript() Returns the client script manager. CWebApplication
getComponent() Retrieves the named application component. CModule
getComponents() 返回应用组件。 CModule
getController() 返回the currently active controller CWebApplication
getControllerPath() 返回the directory that contains the controller classes. Defaults to 'protected/controllers'. CWebApplication
getCoreMessages() 返回核心信息翻译组件。 CApplication
getDateFormatter() 返回本地化的日期格式。 CApplication
getDb() 返回数据库连接组件。 CApplication
getErrorHandler() 返回错误处理组件。 CApplication
getEventHandlers() 返回一个事件的附加处理程序列表。 CComponent
getExtensionPath() 返回第三方扩展根目录。 CApplication
getGlobalState() 返回一个全局值 CApplication
getHomeUrl() 返回主页URL CApplication
getId() 返回应用程序的唯一标识符。 CApplication
getLanguage() 返回用户正在使用的应用程序语言。 CApplication
getLayoutPath() 返回the root directory of layout files. Defaults to 'protected/views/layouts'. CWebApplication
getLocale() 返回本地(环境)实例。 CApplication
getLocaleDataPath() 返回包含本地化的数据目录。 CApplication
getMessages() 返回应用程序信息翻译组件。 CApplication
getModule() 检索指定的应用模块。 CModule
getModulePath() 返回包含应用程序模块的目录。 CModule
getModules() 返回应用程序当前已经安装的模块。 CModule
getNumberFormatter() 返回本地化数字格式。 将使用当前application locale CApplication
getParams() 返回用户定义的参数。 CModule
getParentModule() 返回父模块。 CModule
getRequest() 返回请求组件。 CApplication
getRuntimePath() 返回存储运行时文件目录。 CApplication
getSecurityManager() 返回安全管理器组件。 CApplication
getSession() 返回the session component CWebApplication
getStatePersister() 返回持久状态组件。 CApplication
getSystemViewPath() 返回the root directory of system view files. Defaults to 'protected/views/system'. CWebApplication
getTheme() 返回the theme used currently. Null if no theme is being used. CWebApplication
getThemeManager() 返回the theme manager. CWebApplication
getTimeZone() 返回应用程序所使用的时区。 CApplication
getUrlManager() 返回URL管理器组件。 CApplication
getUser() 返回the user session information CWebApplication
getViewPath() 返回the root directory of view files. Defaults to 'protected/views'. CWebApplication
getViewRenderer() Returns the view renderer. CWebApplication
getWidgetFactory() Returns the widget factory. CWebApplication
handleError() 处理PHP异常错误,如警告,通知。 CApplication
handleException() 处理未捕获的PHP异常。 CApplication
hasComponent() 检查是否存在指定组件。 CModule
hasEvent() 确定一个事件是否定义。 CComponent
hasEventHandler() 检查事件是否有附加的处理程序。 CComponent
hasModule() 检查是否已经安装了指定模块。 CModule
hasProperty() 确定属性是否被定义。 CComponent
loadGlobalState() 从持久存储加载全局状态数据。 CApplication
onBeginRequest() 应用程序处理请求之前发起。 CApplication
onEndRequest() 应用程序处理请求之后发起。 CApplication
onError() 当一个PHP异常错误发生时发起。 CApplication
onException() 当一个未捕获的PHP异常发生时发起。 CApplication
processRequest() Processes the current request. CWebApplication
raiseEvent() 发起一个事件。 CComponent
run() 运行应用程序。 CApplication
runController() Creates the controller and performs the specified action. CWebApplication
saveGlobalState() 保存全局状态数据到持久存储。 CApplication
setAliases() 定义根目录的别名。 CModule
setBasePath() 设置应用程序根目录。 CApplication
setComponent() 添加一个组件到模块中 CModule
setComponents() 设置应用组件。 CModule
setController() 设置the currently active controller CWebApplication
setControllerPath() 设置the directory that contains the controller classes. CWebApplication
setExtensionPath() 设置第三方扩展目录。 CApplication
setGlobalState() 设置一个全局值。 CApplication
setHomeUrl() 设置设置主页URL CApplication
setId() 设置应用程序唯一的标识符。 CApplication
setImport() 设置在模块中使用的路径别名。 CModule
setLanguage() 指定应用程序语言。 CApplication
setLayoutPath() 设置the root directory of layout files. CWebApplication
setLocaleDataPath() 设置包含本地化数据的目录。 CApplication
setModulePath() 设置包含应用程序模块的目录。 CModule
setModules() 配置模块的子模块。 CModule
setParams() 设置用户定义的参数。 CModule
setRuntimePath() 设置存储运行时文件目录。 CApplication
setSystemViewPath() 设置the root directory of system view files. CWebApplication
setTheme() 设置the theme name CWebApplication
setTimeZone() 设置应用程序所使用的时区。 CApplication
setViewPath() 设置the root directory of view files. CWebApplication

受保护方法

隐藏继承方法

方法描述定义在
init() Initializes the application. CWebApplication
initSystemHandlers() 初始化类自动加载器和错误处理。 CApplication
parseActionParams() Parses a path info into an action ID and GET variables. CWebApplication
preinit() 模块预初始化。 CModule
preloadComponents() 加载静态应用组件。 CModule
registerCoreComponents() Registers the core application components. CWebApplication

事件

隐藏继承事件

事件描述定义在
onBeginRequest 应用程序处理请求之前发起。 CApplication
onEndRequest 应用程序处理请求之后发起。 CApplication
onException 当一个未捕获的PHP异常发生时发起。 CApplication
onError 当一个PHP异常错误发生时发起。 CApplication

属性详细

assetManager 属性 只读

the asset manager component

authManager 属性 只读

the authorization manager component

catchAllRequest 属性
public array $catchAllRequest;

the configuration specifying a controller which should handle all user requests. This is mainly used when the application is in maintenance mode and we should use a controller to handle all incoming requests. The configuration specifies the controller route (the first element) and GET parameters (the rest name-value pairs). For example,

array(
    'offline/notice',
    'param1'=>'value1',
    'param2'=>'value2',
)
Defaults to null, meaning catch-all is not effective.

clientScript 属性 只读

Returns the client script manager.

controller 属性
public CController getController()
public void setController(CController $value)

the currently active controller

controllerMap 属性
public array $controllerMap;

mapping from controller ID to controller configurations. Each name-value pair specifies the configuration for a single controller. A controller configuration can be either a string or an array. If the former, the string should be the class name or class path alias of the controller. If the latter, the array must contain a 'class' element which specifies the controller's class name or class path alias. The rest name-value pairs in the array are used to initialize the corresponding controller properties. For example,

array(
  'post'=>array(
     'class'=>'path.to.PostController',
     'pageTitle'=>'something new',
  ),
  'user'=>'path.to.UserController',,
)


Note, when processing an incoming request, the controller map will first be checked to see if the request can be handled by one of the controllers in the map. If not, a controller will be searched for under the default controller path.

controllerPath 属性
public string getControllerPath()
public void setControllerPath(string $value)

the directory that contains the controller classes. Defaults to 'protected/controllers'.

defaultController 属性
public string $defaultController;

the route of the default controller, action or module. Defaults to 'site'.

layout 属性
public mixed $layout;

the application-wide layout. Defaults to 'main' (relative to layoutPath). If this is false, then no layout will be used.

layoutPath 属性
public string getLayoutPath()
public void setLayoutPath(string $path)

the root directory of layout files. Defaults to 'protected/views/layouts'.

session 属性 只读

the session component

systemViewPath 属性
public string getSystemViewPath()
public void setSystemViewPath(string $path)

the root directory of system view files. Defaults to 'protected/views/system'.

theme 属性
public CTheme getTheme()
public void setTheme(string $value)

the theme used currently. Null if no theme is being used.

themeManager 属性 只读

the theme manager.

user 属性 只读
public CWebUser getUser()

the user session information

viewPath 属性
public string getViewPath()
public void setViewPath(string $path)

the root directory of view files. Defaults to 'protected/views'.

viewRenderer 属性 只读

Returns the view renderer. If this component is registered and enabled, the default view rendering logic defined in CBaseController will be replaced by this renderer.

widgetFactory 属性 只读 (可用自 v1.1)

Returns the widget factory.

方法详细

afterControllerAction() 方法
public void afterControllerAction(CController $controller, CAction $action)
$controller CController the controller
$action CAction the action
源码: framework/web/CWebApplication.php#504 (显示)
public function afterControllerAction($controller,$action)
{
}

The post-filter for controller actions. This method is invoked after the currently requested controller action and all its filters are executed. You may override this method with logic that needs to be done after all controller actions.

beforeControllerAction() 方法
public boolean beforeControllerAction(CController $controller, CAction $action)
$controller CController the controller
$action CAction the action
{return} boolean whether the action should be executed.
源码: framework/web/CWebApplication.php#491 (显示)
public function beforeControllerAction($controller,$action)
{
    return 
true;
}

The pre-filter for controller actions. This method is invoked before the currently requested controller action and all its filters are executed. You may override this method with logic that needs to be done before all controller actions.

createController() 方法
public array createController(string $route, CWebModule $owner=NULL)
$route string the route of the request.
$owner CWebModule the module that the new controller will belong to. Defaults to null, meaning the application instance is the owner.
{return} array the controller instance and the action ID. Null if the controller class does not exist or the route is invalid.
源码: framework/web/CWebApplication.php#304 (显示)
public function createController($route,$owner=null)
{
    if(
$owner===null)
        
$owner=$this;
    if((
$route=trim($route,'/'))==='')
        
$route=$owner->defaultController;
    
$caseSensitive=$this->getUrlManager()->caseSensitive;

    
$route.='/';
    while((
$pos=strpos($route,'/'))!==false)
    {
        
$id=substr($route,0,$pos);
        if(!
preg_match('/^\w+$/',$id))
            return 
null;
        if(!
$caseSensitive)
            
$id=strtolower($id);
        
$route=(string)substr($route,$pos+1);
        if(!isset(
$basePath))  // first segment
        
{
            if(isset(
$owner->controllerMap[$id]))
            {
                return array(
                    
Yii::createComponent($owner->controllerMap[$id],$id,$owner===$this?null:$owner),
                    
$this->parseActionParams($route),
                );
            }

            if((
$module=$owner->getModule($id))!==null)
                return 
$this->createController($route,$module);

            
$basePath=$owner->getControllerPath();
            
$controllerID='';
        }
        else
            
$controllerID.='/';
        
$className=ucfirst($id).'Controller';
        
$classFile=$basePath.DIRECTORY_SEPARATOR.$className.'.php';
        if(
is_file($classFile))
        {
            if(!
class_exists($className,false))
                require(
$classFile);
            if(
class_exists($className,false) && is_subclass_of($className,'CController'))
            {
                
$id[0]=strtolower($id[0]);
                return array(
                    new 
$className($controllerID.$id,$owner===$this?null:$owner),
                    
$this->parseActionParams($route),
                );
            }
            return 
null;
        }
        
$controllerID.=$id;
        
$basePath.=DIRECTORY_SEPARATOR.$id;
    }
}

Creates a controller instance based on a route. The route should contain the controller ID and the action ID. It may also contain additional GET variables. All these must be concatenated together with slashes.

This method will attempt to create a controller in the following order:

  1. If the first segment is found in controllerMap, the corresponding controller configuration will be used to create the controller;
  2. If the first segment is found to be a module ID, the corresponding module will be used to create the controller;
  3. Otherwise, it will search under the controllerPath to create the corresponding controller. For example, if the route is "admin/user/create", then the controller will be created using the class file "protected/controllers/admin/UserController.php".

findModule() 方法
public CWebModule findModule(string $id)
$id string module ID
{return} CWebModule the module that has the specified ID. Null if no module is found.
源码: framework/web/CWebApplication.php#513 (显示)
public function findModule($id)
{
    if((
$controller=$this->getController())!==null && ($module=$controller->getModule())!==null)
    {
        do
        {
            if((
$m=$module->getModule($id))!==null)
                return 
$m;
        } while((
$module=$module->getParentModule())!==null);
    }
    if((
$m=$this->getModule($id))!==null)
        return 
$m;
}

Do not call this method. This method is used internally to search for a module by its ID.

getAssetManager() 方法
public CAssetManager getAssetManager()
{return} CAssetManager the asset manager component
源码: framework/web/CWebApplication.php#185 (显示)
public function getAssetManager()
{
    return 
$this->getComponent('assetManager');
}

getAuthManager() 方法
public IAuthManager getAuthManager()
{return} IAuthManager the authorization manager component
源码: framework/web/CWebApplication.php#177 (显示)
public function getAuthManager()
{
    return 
$this->getComponent('authManager');
}

getClientScript() 方法
public CClientScript getClientScript()
{return} CClientScript the client script manager
源码: framework/web/CWebApplication.php#222 (显示)
public function getClientScript()
{
    return 
$this->getComponent('clientScript');
}

Returns the client script manager.

getController() 方法
public CController getController()
{return} CController the currently active controller
源码: framework/web/CWebApplication.php#381 (显示)
public function getController()
{
    return 
$this->_controller;
}

getControllerPath() 方法
public string getControllerPath()
{return} string the directory that contains the controller classes. Defaults to 'protected/controllers'.
源码: framework/web/CWebApplication.php#397 (显示)
public function getControllerPath()
{
    if(
$this->_controllerPath!==null)
        return 
$this->_controllerPath;
    else
        return 
$this->_controllerPath=$this->getBasePath().DIRECTORY_SEPARATOR.'controllers';
}

getLayoutPath() 方法
public string getLayoutPath()
{return} string the root directory of layout files. Defaults to 'protected/views/layouts'.
源码: framework/web/CWebApplication.php#463 (显示)
public function getLayoutPath()
{
    if(
$this->_layoutPath!==null)
        return 
$this->_layoutPath;
    else
        return 
$this->_layoutPath=$this->getViewPath().DIRECTORY_SEPARATOR.'layouts';
}

getSession() 方法
public CHttpSession getSession()
{return} CHttpSession the session component
源码: framework/web/CWebApplication.php#193 (显示)
public function getSession()
{
    return 
$this->getComponent('session');
}

getSystemViewPath() 方法
public string getSystemViewPath()
{return} string the root directory of system view files. Defaults to 'protected/views/system'.
源码: framework/web/CWebApplication.php#441 (显示)
public function getSystemViewPath()
{
    if(
$this->_systemViewPath!==null)
        return 
$this->_systemViewPath;
    else
        return 
$this->_systemViewPath=$this->getViewPath().DIRECTORY_SEPARATOR.'system';
}

getTheme() 方法
public CTheme getTheme()
{return} CTheme the theme used currently. Null if no theme is being used.
源码: framework/web/CWebApplication.php#248 (显示)
public function getTheme()
{
    if(
is_string($this->_theme))
        
$this->_theme=$this->getThemeManager()->getTheme($this->_theme);
    return 
$this->_theme;
}

getThemeManager() 方法
public CThemeManager getThemeManager()
{return} CThemeManager the theme manager.
源码: framework/web/CWebApplication.php#240 (显示)
public function getThemeManager()
{
    return 
$this->getComponent('themeManager');
}

getUser() 方法
public CWebUser getUser()
{return} CWebUser the user session information
源码: framework/web/CWebApplication.php#201 (显示)
public function getUser()
{
    return 
$this->getComponent('user');
}

getViewPath() 方法
public string getViewPath()
{return} string the root directory of view files. Defaults to 'protected/views'.
源码: framework/web/CWebApplication.php#419 (显示)
public function getViewPath()
{
    if(
$this->_viewPath!==null)
        return 
$this->_viewPath;
    else
        return 
$this->_viewPath=$this->getBasePath().DIRECTORY_SEPARATOR.'views';
}

getViewRenderer() 方法
public IViewRenderer getViewRenderer()
{return} IViewRenderer the view renderer.
源码: framework/web/CWebApplication.php#213 (显示)
public function getViewRenderer()
{
    return 
$this->getComponent('viewRenderer');
}

Returns the view renderer. If this component is registered and enabled, the default view rendering logic defined in CBaseController will be replaced by this renderer.

getWidgetFactory() 方法 (可用自 v1.1)
public IWidgetFactory getWidgetFactory()
{return} IWidgetFactory the widget factory
源码: framework/web/CWebApplication.php#232 (显示)
public function getWidgetFactory()
{
    return 
$this->getComponent('widgetFactory');
}

Returns the widget factory.

init() 方法
protected void init()
源码: framework/web/CWebApplication.php#531 (显示)
protected function init()
{
    
parent::init();
    
// preload 'request' so that it has chance to respond to onBeginRequest event.
    
$this->getRequest();
}

Initializes the application. This method overrides the parent implementation by preloading the 'request' component.

parseActionParams() 方法
protected string parseActionParams(string $pathInfo)
$pathInfo string path info
{return} string action ID
源码: framework/web/CWebApplication.php#365 (显示)
protected function parseActionParams($pathInfo)
{
    if((
$pos=strpos($pathInfo,'/'))!==false)
    {
        
$manager=$this->getUrlManager();
        
$manager->parsePathInfo((string)substr($pathInfo,$pos+1));
        
$actionID=substr($pathInfo,0,$pos);
        return 
$manager->caseSensitive $actionID strtolower($actionID);
    }
    else
        return 
$pathInfo;
}

Parses a path info into an action ID and GET variables.

processRequest() 方法
public void processRequest()
源码: framework/web/CWebApplication.php#125 (显示)
public function processRequest()
{
    if(
is_array($this->catchAllRequest) && isset($this->catchAllRequest[0]))
    {
        
$route=$this->catchAllRequest[0];
        foreach(
array_splice($this->catchAllRequest,1) as $name=>$value)
            
$_GET[$name]=$value;
    }
    else
        
$route=$this->getUrlManager()->parseUrl($this->getRequest());
    
$this->runController($route);
}

Processes the current request. It first resolves the request into controller and action, and then creates the controller to perform the action.

registerCoreComponents() 方法
protected void registerCoreComponents()
源码: framework/web/CWebApplication.php#143 (显示)
protected function registerCoreComponents()
{
    
parent::registerCoreComponents();

    
$components=array(
        
'session'=>array(
            
'class'=>'CHttpSession',
        ),
        
'assetManager'=>array(
            
'class'=>'CAssetManager',
        ),
        
'user'=>array(
            
'class'=>'CWebUser',
        ),
        
'themeManager'=>array(
            
'class'=>'CThemeManager',
        ),
        
'authManager'=>array(
            
'class'=>'CPhpAuthManager',
        ),
        
'clientScript'=>array(
            
'class'=>'CClientScript',
        ),
        
'widgetFactory'=>array(
            
'class'=>'CWidgetFactory',
        ),
    );

    
$this->setComponents($components);
}

Registers the core application components. This method overrides the parent implementation by registering additional core components.

参见

runController() 方法
public void runController(string $route)
$route string the route of the current request. See createController for more details.
源码: framework/web/CWebApplication.php#268 (显示)
public function runController($route)
{
    if((
$ca=$this->createController($route))!==null)
    {
        list(
$controller,$actionID)=$ca;
        
$oldController=$this->_controller;
        
$this->_controller=$controller;
        
$controller->init();
        
$controller->run($actionID);
        
$this->_controller=$oldController;
    }
    else
        throw new 
CHttpException(404,Yii::t('yii','Unable to resolve the request "{route}".',
            array(
'{route}'=>$route===''?$this->defaultController:$route)));
}

Creates the controller and performs the specified action.

setController() 方法
public void setController(CController $value)
$value CController the currently active controller
源码: framework/web/CWebApplication.php#389 (显示)
public function setController($value)
{
    
$this->_controller=$value;
}

setControllerPath() 方法
public void setControllerPath(string $value)
$value string the directory that contains the controller classes.
源码: framework/web/CWebApplication.php#409 (显示)
public function setControllerPath($value)
{
    if((
$this->_controllerPath=realpath($value))===false || !is_dir($this->_controllerPath))
        throw new 
CException(Yii::t('yii','The controller path "{path}" is not a valid directory.',
            array(
'{path}'=>$value)));
}

setLayoutPath() 方法
public void setLayoutPath(string $path)
$path string the root directory of layout files.
源码: framework/web/CWebApplication.php#475 (显示)
public function setLayoutPath($path)
{
    if((
$this->_layoutPath=realpath($path))===false || !is_dir($this->_layoutPath))
        throw new 
CException(Yii::t('yii','The layout path "{path}" is not a valid directory.',
            array(
'{path}'=>$path)));
}

setSystemViewPath() 方法
public void setSystemViewPath(string $path)
$path string the root directory of system view files.
源码: framework/web/CWebApplication.php#453 (显示)
public function setSystemViewPath($path)
{
    if((
$this->_systemViewPath=realpath($path))===false || !is_dir($this->_systemViewPath))
        throw new 
CException(Yii::t('yii','The system view path "{path}" is not a valid directory.',
            array(
'{path}'=>$path)));
}

setTheme() 方法
public void setTheme(string $value)
$value string the theme name
源码: framework/web/CWebApplication.php#258 (显示)
public function setTheme($value)
{
    
$this->_theme=$value;
}

setViewPath() 方法
public void setViewPath(string $path)
$path string the root directory of view files.
源码: framework/web/CWebApplication.php#431 (显示)
public function setViewPath($path)
{
    if((
$this->_viewPath=realpath($path))===false || !is_dir($this->_viewPath))
        throw new 
CException(Yii::t('yii','The view path "{path}" is not a valid directory.',
            array(
'{path}'=>$path)));
}

Copyright © 2008-2011 by Yii Software LLC
All Rights Reserved.