system system.base system.caching system.caching.dependencies system.collections system.console system.db system.db.ar system.db.schema system.db.schema.cubrid system.db.schema.mssql system.db.schema.mysql system.db.schema.oci system.db.schema.pgsql system.db.schema.sqlite system.gii system.i18n system.i18n.gettext system.logging system.test system.utils system.validators system.web system.web.actions system.web.auth system.web.filters system.web.form system.web.helpers system.web.renderers system.web.services system.web.widgets system.web.widgets.captcha system.web.widgets.pagers zii.behaviors zii.widgets zii.widgets.grid zii.widgets.jui

CWebModule

system.web
继承 class CWebModule » CModule » CComponent
子类 GiiModule
源码 framework/web/CWebModule.php
CWebModule represents an application module.

An application module may be considered as a self-contained sub-application that has its own controllers, models and views and can be reused in a different project as a whole. Controllers inside a module must be accessed with routes that are prefixed with the module ID.

公共属性

隐藏继承的属性

属性类型描述被定义在
basePath string 返回模块的根目录。 CModule
behaviors array the behaviors that should be attached to the module. CModule
components array 返回应用程序组件。 CModule
controllerMap array mapping from controller ID to controller configurations. CWebModule
controllerNamespace string Namespace that should be used when loading controllers. CWebModule
controllerPath string the directory that contains the controller classes. CWebModule
defaultController string the ID of the default controller for this module. CWebModule
description string Returns the description of this module. CWebModule
id string 返回模块的 ID。 CModule
layout mixed the layout that is shared by the controllers inside this module. CWebModule
layoutPath string the root directory of layout files. CWebModule
modulePath string Returns the directory that contains the application modules. CModule
modules array Returns the configuration of the currently installed modules. CModule
name string Returns the name of this module. CWebModule
params CAttributeCollection 返回用户定义的参数。 CModule
parentModule CModule 返回父模块。 CModule
preload array the IDs of the application components that should be preloaded. CModule
version string Returns the version of this module. CWebModule
viewPath string the root directory of view files. CWebModule

公共方法

隐藏继承的方法

方法描述被定义在
__call() Calls the named method which is not a class method. CComponent
__construct() 构造器。 CModule
__get() Getter 魔术方法。 CModule
__isset() 检查一个属性值是否为空。 CModule
__set() Sets value of a component property. CComponent
__unset() Sets a component property to be null. CComponent
afterControllerAction() The post-filter for controller actions. CWebModule
asa() Returns the named behavior object. CComponent
attachBehavior() Attaches a behavior to this component. CComponent
attachBehaviors() Attaches a list of behaviors to the component. CComponent
attachEventHandler() Attaches an event handler to an event. CComponent
beforeControllerAction() The pre-filter for controller actions. CWebModule
canGetProperty() Determines whether a property can be read. CComponent
canSetProperty() Determines whether a property can be set. CComponent
configure() Configures the module with the specified configuration. CModule
detachBehavior() Detaches a behavior from the component. CComponent
detachBehaviors() Detaches all behaviors from the component. CComponent
detachEventHandler() Detaches an existing event handler. CComponent
disableBehavior() Disables an attached behavior. CComponent
disableBehaviors() Disables all behaviors attached to this component. CComponent
enableBehavior() Enables an attached behavior. CComponent
enableBehaviors() Enables all behaviors attached to this component. CComponent
evaluateExpression() Evaluates a PHP expression or callback under the context of this component. CComponent
getBasePath() 返回模块的根目录。 CModule
getComponent() Retrieves the named application component. CModule
getComponents() 返回应用程序组件。 CModule
getControllerPath() Returns the directory that contains the controller classes. Defaults to 'moduleDir/controllers' where moduleDir is the directory containing the module class. CWebModule
getDescription() Returns the description of this module. CWebModule
getEventHandlers() Returns the list of attached event handlers for an event. CComponent
getId() 返回模块的 ID。 CModule
getLayoutPath() Returns the root directory of layout files. Defaults to 'moduleDir/views/layouts' where moduleDir is the directory containing the module class. CWebModule
getModule() 检索指定的应用程序模块。 CModule
getModulePath() Returns the directory that contains the application modules. CModule
getModules() Returns the configuration of the currently installed modules. CModule
getName() Returns the name of this module. CWebModule
getParams() 返回用户定义的参数。 CModule
getParentModule() 返回父模块。 CModule
getVersion() Returns the version of this module. CWebModule
getViewPath() Returns the root directory of view files. Defaults to 'moduleDir/views' where moduleDir is the directory containing the module class. CWebModule
hasComponent() Checks whether the named component exists. CModule
hasEvent() Determines whether an event is defined. CComponent
hasEventHandler() Checks whether the named event has attached handlers. CComponent
hasModule() Returns a value indicating whether the specified module is installed. CModule
hasProperty() Determines whether a property is defined. CComponent
raiseEvent() Raises an event. CComponent
setAliases() Defines the root aliases. CModule
setBasePath() 设置模块的根目录。 CModule
setComponent() Puts a component under the management of the module. CModule
setComponents() 设置应用程序组件。 CModule
setControllerPath() Sets the directory that contains the controller classes. CWebModule
setId() 设置模块的 ID。 CModule
setImport() 设置用于在模块中使用的别名。 CModule
setLayoutPath() Sets the root directory of layout files. CWebModule
setModulePath() Sets the directory that contains the application modules. CModule
setModules() Configures the sub-modules of this module. CModule
setParams() 设置用户定义的参数 CModule
setViewPath() Sets the root directory of view files. CWebModule

受保护的方法

隐藏继承的方法

方法描述被定义在
init() 初始化模块。 CModule
preinit() Preinitializes the module. CModule
preloadComponents() 加载静态应用程序组件。 CModule

属性详情

controllerMap 属性
public array $controllerMap;

mapping from controller ID to controller configurations. Pleaser refer to CWebApplication::controllerMap for more details.

controllerNamespace 属性 (自版本 v1.1.11 可用)
public string $controllerNamespace;

Namespace that should be used when loading controllers. Default is to use global namespace.

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

the directory that contains the controller classes. Defaults to 'moduleDir/controllers' where moduleDir is the directory containing the module class.

defaultController 属性
public string $defaultController;

the ID of the default controller for this module. Defaults to 'default'.

description 属性 只读
public string getDescription()

Returns the description of this module. The default implementation returns an empty string. You may override this method to customize the description of this module.

layout 属性
public mixed $layout;

the layout that is shared by the controllers inside this module. If a controller has explicitly declared its own layout, this property will be ignored. If this is null (default), the application's layout or the parent module's layout (if available) will be used. 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 'moduleDir/views/layouts' where moduleDir is the directory containing the module class.

name 属性 只读
public string getName()

Returns the name of this module. The default implementation simply returns id. You may override this method to customize the name of this module.

version 属性 只读
public string getVersion()

Returns the version of this module. The default implementation returns '1.0'. You may override this method to customize the version of this module.

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

the root directory of view files. Defaults to 'moduleDir/views' where moduleDir is the directory containing the module class.

方法详情

afterControllerAction() 方法
public void afterControllerAction(CController $controller, CAction $action)
$controller CController the controller
$action CAction the action
源码: framework/web/CWebModule.php#196 (显示)
public function afterControllerAction($controller,$action)
{
    if((
$parent=$this->getParentModule())===null)
        
$parent=Yii::app();
    
$parent->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. If you override this method, make sure you call the parent implementation at the end.

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/CWebModule.php#182 (显示)
public function beforeControllerAction($controller,$action)
{
    if((
$parent=$this->getParentModule())===null)
        
$parent=Yii::app();
    return 
$parent->beforeControllerAction($controller,$action);
}

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 in the following way:

if(parent::beforeControllerAction($controller,$action))
{
    // your code
    return true;
}
else
    return false;

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

getDescription() 方法
public string getDescription()
{return} string the description of this module.
源码: framework/web/CWebModule.php#80 (显示)
public function getDescription()
{
    return 
'';
}

Returns the description of this module. The default implementation returns an empty string. You may override this method to customize the description of this module.

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

getName() 方法
public string getName()
{return} string the name of this module.
源码: framework/web/CWebModule.php#69 (显示)
public function getName()
{
    return 
basename($this->getId());
}

Returns the name of this module. The default implementation simply returns id. You may override this method to customize the name of this module.

getVersion() 方法
public string getVersion()
{return} string the version of this module.
源码: framework/web/CWebModule.php#91 (显示)
public function getVersion()
{
    return 
'1.0';
}

Returns the version of this module. The default implementation returns '1.0'. You may override this method to customize the version of this module.

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

setControllerPath() 方法
public void setControllerPath(string $value)
$value string the directory that contains the controller classes.
源码: framework/web/CWebModule.php#112 (显示)
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/CWebModule.php#158 (显示)
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)));
}

setViewPath() 方法
public void setViewPath(string $path)
$path string the root directory of view files.
源码: framework/web/CWebModule.php#135 (显示)
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)));
}