CWebApplication

优质
小牛编辑
126浏览
2023-12-01
所有包 | 属性 | 方法 | 事件
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'.

公共属性

隐藏继承属性

属性类型描述定义在
assetManagerCAssetManagerthe asset manager componentCWebApplication
authManagerIAuthManagerthe authorization manager componentCWebApplication
basePathstring返回应用程序的根目录。CApplication
baseUrlstring返回应用程序的相对URL。CApplication
behaviorsarraythe behaviors that should be attached to the module.CModule
cacheCCache返回缓存组件。CApplication
catchAllRequestarraythe configuration specifying a controller which should handle all user requests.CWebApplication
charsetstring应用程序当前使用的字符集。默认为‘UTF-8’。CApplication
clientScriptCClientScriptReturns the client script manager.CWebApplication
componentsarray返回应用组件。CModule
controllerCControllerthe currently active controllerCWebApplication
controllerMaparraymapping from controller ID to controller configurations.CWebApplication
controllerPathstringthe directory that contains the controller classes.CWebApplication
coreMessagesCPhpMessageSource返回核心信息翻译组件。CApplication
dateFormatterCDateFormatter返回本地化的日期格式。CApplication
dbCDbConnection返回数据库连接组件。CApplication
defaultControllerstringthe route of the default controller, action or module.CWebApplication
errorHandlerCErrorHandler返回错误处理组件。CApplication
extensionPathstring返回第三方扩展根目录。CApplication
homeUrlstring主页URLCApplication
idstring返回应用程序的唯一标识符。CApplication
languagestring返回用户正在使用的应用程序语言。CApplication
layoutmixedthe application-wide layout.CWebApplication
layoutPathstringthe root directory of layout files.CWebApplication
localeCLocale返回本地(环境)实例。CApplication
localeDataPathstring返回包含本地化的数据目录。CApplication
messagesCMessageSource返回应用程序信息翻译组件。CApplication
modulePathstring返回包含应用程序模块的目录。CModule
modulesarray返回应用程序当前已经安装的模块。CModule
namestring应用程序名字。默认为‘My Application’。CApplication
numberFormatterCNumberFormatter本地化数字格式。 将使用当前application locale。CApplication
paramsCAttributeCollection返回用户定义的参数。CModule
parentModuleCModule返回父模块。CModule
preloadarraythe IDs of the application components that should be preloaded.CModule
requestCHttpRequest返回请求组件。CApplication
runtimePathstring返回存储运行时文件目录。CApplication
securityManagerCSecurityManager返回安全管理器组件。CApplication
sessionCHttpSessionthe session componentCWebApplication
sourceLanguagestring应用程序使用语言.CApplication
statePersisterCStatePersister返回持久状态组件。CApplication
systemViewPathstringthe root directory of system view files.CWebApplication
themeCThemethe theme used currently.CWebApplication
themeManagerCThemeManagerthe theme manager.CWebApplication
timeZonestring返回应用程序所使用的时区。CApplication
urlManagerCUrlManager返回URL管理器组件。CApplication
userCWebUserthe user session informationCWebApplication
viewPathstringthe root directory of view files.CWebApplication
viewRendererIViewRendererReturns the view renderer.CWebApplication
widgetFactoryIWidgetFactoryReturns 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 componentCWebApplication
getAuthManager()返回the authorization manager componentCWebApplication
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 controllerCWebApplication
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()返回主页URLCApplication
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 componentCWebApplication
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 informationCWebApplication
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 controllerCWebApplication
setControllerPath()设置the directory that contains the controller classes.CWebApplication
setExtensionPath()设置第三方扩展目录。CApplication
setGlobalState()设置一个全局值。CApplication
setHomeUrl()设置设置主页URLCApplication
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 nameCWebApplication
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 属性 只读 public CAssetManager getAssetManager()

the asset manager component

authManager 属性 只读 public IAuthManager getAuthManager()

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 属性 只读 public CClientScript getClientScript()

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 属性 只读 public CHttpSession getSession()

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 属性 只读 public CThemeManager getThemeManager()

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 属性 只读 public IViewRenderer getViewRenderer()

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) public IWidgetFactory getWidgetFactory()

Returns the widget factory.

方法详细

afterControllerAction() 方法
public void afterControllerAction(CController $controller, CAction $action)
$controllerCControllerthe controller
$actionCActionthe action
源码: framework/web/CWebApplication.php#504 (显示) publicfunctionafterControllerAction($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)
$controllerCControllerthe controller
$actionCActionthe action
{return}booleanwhether the action should be executed.
源码: framework/web/CWebApplication.php#491 (显示) publicfunctionbeforeControllerAction($controller,$action)
{
returntrue;
}

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)
$routestringthe route of the request.
$ownerCWebModulethe module that the new controller will belong to. Defaults to null, meaning the application instance is the owner.
{return}arraythe controller instance and the action ID. Null if the controller class does not exist or the route is invalid.
源码: framework/web/CWebApplication.php#304 (显示) publicfunctioncreateController($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))
returnnull;
if(!$caseSensitive)
$id=strtolower($id);
$route=(string)substr($route,$pos+1);
if(!isset($basePath))//firstsegment
{
if(isset($owner->controllerMap[$id]))
{
returnarray(
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]);
returnarray(
new$className($controllerID.$id,$owner===$this?null:$owner),
$this->parseActionParams($route),
);
}
returnnull;
}
$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)
$idstringmodule ID
{return}CWebModulethe module that has the specified ID. Null if no module is found.
源码: framework/web/CWebApplication.php#513 (显示) publicfunctionfindModule($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}CAssetManagerthe asset manager component
源码: framework/web/CWebApplication.php#185 (显示) publicfunctiongetAssetManager()
{
return$this->getComponent('assetManager');
}
getAuthManager() 方法
public IAuthManager getAuthManager()
{return}IAuthManagerthe authorization manager component
源码: framework/web/CWebApplication.php#177 (显示) publicfunctiongetAuthManager()
{
return$this->getComponent('authManager');
}
getClientScript() 方法
public CClientScript getClientScript()
{return}CClientScriptthe client script manager
源码: framework/web/CWebApplication.php#222 (显示) publicfunctiongetClientScript()
{
return$this->getComponent('clientScript');
}

Returns the client script manager.

getController() 方法
public CController getController()
{return}CControllerthe currently active controller
源码: framework/web/CWebApplication.php#381 (显示) publicfunctiongetController()
{
return$this->_controller;
}
getControllerPath() 方法
public string getControllerPath()
{return}stringthe directory that contains the controller classes. Defaults to 'protected/controllers'.
源码: framework/web/CWebApplication.php#397 (显示) publicfunctiongetControllerPath()
{
if($this->_controllerPath!==null)
return$this->_controllerPath;
else
return$this->_controllerPath=$this->getBasePath().DIRECTORY_SEPARATOR.'controllers';
}
getLayoutPath() 方法
public string getLayoutPath()
{return}stringthe root directory of layout files. Defaults to 'protected/views/layouts'.
源码: framework/web/CWebApplication.php#463 (显示) publicfunctiongetLayoutPath()
{
if($this->_layoutPath!==null)
return$this->_layoutPath;
else
return$this->_layoutPath=$this->getViewPath().DIRECTORY_SEPARATOR.'layouts';
}
getSession() 方法
public CHttpSession getSession()
{return}CHttpSessionthe session component
源码: framework/web/CWebApplication.php#193 (显示) publicfunctiongetSession()
{
return$this->getComponent('session');
}
getSystemViewPath() 方法
public string getSystemViewPath()
{return}stringthe root directory of system view files. Defaults to 'protected/views/system'.
源码: framework/web/CWebApplication.php#441 (显示) publicfunctiongetSystemViewPath()
{
if($this->_systemViewPath!==null)
return$this->_systemViewPath;
else
return$this->_systemViewPath=$this->getViewPath().DIRECTORY_SEPARATOR.'system';
}
getTheme() 方法
public CTheme getTheme()
{return}CThemethe theme used currently. Null if no theme is being used.
源码: framework/web/CWebApplication.php#248 (显示) publicfunctiongetTheme()
{
if(is_string($this->_theme))
$this->_theme=$this->getThemeManager()->getTheme($this->_theme);
return$this->_theme;
}
getThemeManager() 方法
public CThemeManager getThemeManager()
{return}CThemeManagerthe theme manager.
源码: framework/web/CWebApplication.php#240 (显示) publicfunctiongetThemeManager()
{
return$this->getComponent('themeManager');
}
getUser() 方法
public CWebUser getUser()
{return}CWebUserthe user session information
源码: framework/web/CWebApplication.php#201 (显示) publicfunctiongetUser()
{
return$this->getComponent('user');
}
getViewPath() 方法
public string getViewPath()
{return}stringthe root directory of view files. Defaults to 'protected/views'.
源码: framework/web/CWebApplication.php#419 (显示) publicfunctiongetViewPath()
{
if($this->_viewPath!==null)
return$this->_viewPath;
else
return$this->_viewPath=$this->getBasePath().DIRECTORY_SEPARATOR.'views';
}
getViewRenderer() 方法
public IViewRenderer getViewRenderer()
{return}IViewRendererthe view renderer.
源码: framework/web/CWebApplication.php#213 (显示) publicfunctiongetViewRenderer()
{
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}IWidgetFactorythe widget factory
源码: framework/web/CWebApplication.php#232 (显示) publicfunctiongetWidgetFactory()
{
return$this->getComponent('widgetFactory');
}

Returns the widget factory.

init() 方法
protected void init()
源码: framework/web/CWebApplication.php#531 (显示) protectedfunctioninit()
{
parent::init();
//preload'request'sothatithaschancetorespondtoonBeginRequestevent.
$this->getRequest();
}

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

parseActionParams() 方法
protected string parseActionParams(string $pathInfo)
$pathInfostringpath info
{return}stringaction ID
源码: framework/web/CWebApplication.php#365 (显示) protectedfunctionparseActionParams($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 (显示) publicfunctionprocessRequest()
{
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 (显示) protectedfunctionregisterCoreComponents()
{
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.

参见

  • setComponents
runController() 方法
public void runController(string $route)
$routestringthe route of the current request. See createController for more details.
源码: framework/web/CWebApplication.php#268 (显示) publicfunctionrunController($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
thrownewCHttpException(404,Yii::t('yii','Unabletoresolvetherequest"{route}".',
array('{route}'=>$route===''?$this->defaultController:$route)));
}

Creates the controller and performs the specified action.

setController() 方法
public void setController(CController $value)
$valueCControllerthe currently active controller
源码: framework/web/CWebApplication.php#389 (显示) publicfunctionsetController($value)
{
$this->_controller=$value;
}
setControllerPath() 方法
public void setControllerPath(string $value)
$valuestringthe directory that contains the controller classes.
源码: framework/web/CWebApplication.php#409 (显示) publicfunctionsetControllerPath($value)
{
if(($this->_controllerPath=realpath($value))===false||!is_dir($this->_controllerPath))
thrownewCException(Yii::t('yii','Thecontrollerpath"{path}"isnotavaliddirectory.',
array('{path}'=>$value)));
}
setLayoutPath() 方法
public void setLayoutPath(string $path)
$pathstringthe root directory of layout files.
源码: framework/web/CWebApplication.php#475 (显示) publicfunctionsetLayoutPath($path)
{
if(($this->_layoutPath=realpath($path))===false||!is_dir($this->_layoutPath))
thrownewCException(Yii::t('yii','Thelayoutpath"{path}"isnotavaliddirectory.',
array('{path}'=>$path)));
}
setSystemViewPath() 方法
public void setSystemViewPath(string $path)
$pathstringthe root directory of system view files.
源码: framework/web/CWebApplication.php#453 (显示) publicfunctionsetSystemViewPath($path)
{
if(($this->_systemViewPath=realpath($path))===false||!is_dir($this->_systemViewPath))
thrownewCException(Yii::t('yii','Thesystemviewpath"{path}"isnotavaliddirectory.',
array('{path}'=>$path)));
}
setTheme() 方法
public void setTheme(string $value)
$valuestringthe theme name
源码: framework/web/CWebApplication.php#258 (显示) publicfunctionsetTheme($value)
{
$this->_theme=$value;
}
setViewPath() 方法
public void setViewPath(string $path)
$pathstringthe root directory of view files.
源码: framework/web/CWebApplication.php#431 (显示) publicfunctionsetViewPath($path)
{
if(($this->_viewPath=realpath($path))===false||!is_dir($this->_viewPath))
thrownewCException(Yii::t('yii','Theviewpath"{path}"isnotavaliddirectory.',
array('{path}'=>$path)));
}