CWebModule

优质
小牛编辑
135浏览
2023-12-01
所有包 | 属性 | 方法
system.web
继承class CWebModule » CModule » CComponent
子类GiiModule
版本$Id: CWebModule.php 3515 2011-12-28 12:29:24Z mdomba $
源码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.

公共属性

隐藏继承属性

属性类型描述定义在
basePathstring返回模块根目录。CModule
behaviorsarraythe behaviors that should be attached to the module.CModule
componentsarray返回应用组件。CModule
controllerMaparraymapping from controller ID to controller configurations.CWebModule
controllerPathstringthe directory that contains the controller classes.CWebModule
defaultControllerstringthe ID of the default controller for this module.CWebModule
descriptionstringReturns the description of this module.CWebModule
idstring返回模块ID。CModule
layoutmixedthe layout that is shared by the controllers inside this module.CWebModule
layoutPathstringthe root directory of layout files.CWebModule
modulePathstring返回包含应用程序模块的目录。CModule
modulesarray返回应用程序当前已经安装的模块。CModule
namestringReturns the name of this module.CWebModule
paramsCAttributeCollection返回用户定义的参数。CModule
parentModuleCModule返回父模块。CModule
preloadarraythe IDs of the application components that should be preloaded.CModule
versionstringReturns the version of this module.CWebModule
viewPathstringthe root directory of view files.CWebModule

公共方法

隐藏继承方法

方法描述定义在
__call()如果类中没有调的方法名,则调用这个方法。CComponent
__construct()构造方法。CModule
__get()getter魔术方法。CModule
__isset()检查一个属性值是否为null。CModule
__set()设置一个组件的属性值。CComponent
__unset()设置一个组件的属性为null。CComponent
afterControllerAction()The post-filter for controller actions.CWebModule
asa()返回这个名字的行为对象。CComponent
attachBehavior()附加一个行为到组件。CComponent
attachBehaviors()附加一个行为列表到组件。CComponent
attachEventHandler()为事件附加一个事件处理程序。CComponent
beforeControllerAction()The pre-filter for controller actions.CWebModule
canGetProperty()确定属性是否可读。CComponent
canSetProperty()确定属性是否可写。CComponent
configure()为模块指定配置。CModule
detachBehavior()从组件中分离一个行为。CComponent
detachBehaviors()从组件中分离所有行为。CComponent
detachEventHandler()分离一个存在的事件处理程序。CComponent
disableBehavior()禁用一个附加行为。CComponent
disableBehaviors()禁用组件附加的所有行为。CComponent
enableBehavior()启用一个附加行为。CComponent
enableBehaviors()启用组件附加的所有行为。CComponent
evaluateExpression()计算一个PHP表达式,或根据组件上下文执行回调。CComponent
getBasePath()返回模块根目录。CModule
getComponent()Retrieves the named application component.CModule
getComponents()返回应用组件。CModule
getControllerPath()返回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()返回一个事件的附加处理程序列表。CComponent
getId()返回模块ID。CModule
getLayoutPath()返回the root directory of layout files. Defaults to 'moduleDir/views/layouts' where moduleDir is the directory containing the module class.CWebModule
getModule()检索指定的应用模块。CModule
getModulePath()返回包含应用程序模块的目录。CModule
getModules()返回应用程序当前已经安装的模块。CModule
getName()Returns the name of this module.CWebModule
getParams()返回用户定义的参数。CModule
getParentModule()返回父模块。CModule
getVersion()Returns the version of this module.CWebModule
getViewPath()返回the root directory of view files. Defaults to 'moduleDir/views' where moduleDir is the directory containing the module class.CWebModule
hasComponent()检查是否存在指定组件。CModule
hasEvent()确定一个事件是否定义。CComponent
hasEventHandler()检查事件是否有附加的处理程序。CComponent
hasModule()检查是否已经安装了指定模块。CModule
hasProperty()确定属性是否被定义。CComponent
raiseEvent()发起一个事件。CComponent
setAliases()定义根目录的别名。CModule
setBasePath()设置块根目录。CModule
setComponent()添加一个组件到模块中CModule
setComponents()设置应用组件。CModule
setControllerPath()设置the directory that contains the controller classes.CWebModule
setId()设置模块ID。CModule
setImport()设置在模块中使用的路径别名。CModule
setLayoutPath()设置the root directory of layout files.CWebModule
setModulePath()设置包含应用程序模块的目录。CModule
setModules()配置模块的子模块。CModule
setParams()设置用户定义的参数。CModule
setViewPath()设置the root directory of view files.CWebModule

受保护方法

隐藏继承方法

方法描述定义在
init()初始化模块。CModule
preinit()模块预初始化。CModule
preloadComponents()加载静态应用组件。CModule

属性详细

controllerMap 属性 public array $controllerMap;

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

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)
$controllerCControllerthe controller
$actionCActionthe action
源码: framework/web/CWebModule.php#191 (显示) publicfunctionafterControllerAction($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)
$controllerCControllerthe controller
$actionCActionthe action
{return}booleanwhether the action should be executed.
源码: framework/web/CWebModule.php#177 (显示) publicfunctionbeforeControllerAction($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}stringthe directory that contains the controller classes. Defaults to 'moduleDir/controllers' where moduleDir is the directory containing the module class.
源码: framework/web/CWebModule.php#95 (显示) publicfunctiongetControllerPath()
{
if($this->_controllerPath!==null)
return$this->_controllerPath;
else
return$this->_controllerPath=$this->getBasePath().DIRECTORY_SEPARATOR.'controllers';
}
getDescription() 方法
public string getDescription()
{return}stringthe description of this module.
源码: framework/web/CWebModule.php#75 (显示) publicfunctiongetDescription()
{
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}stringthe root directory of layout files. Defaults to 'moduleDir/views/layouts' where moduleDir is the directory containing the module class.
源码: framework/web/CWebModule.php#141 (显示) publicfunctiongetLayoutPath()
{
if($this->_layoutPath!==null)
return$this->_layoutPath;
else
return$this->_layoutPath=$this->getViewPath().DIRECTORY_SEPARATOR.'layouts';
}
getName() 方法
public string getName()
{return}stringthe name of this module.
源码: framework/web/CWebModule.php#64 (显示) publicfunctiongetName()
{
returnbasename($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}stringthe version of this module.
源码: framework/web/CWebModule.php#86 (显示) publicfunctiongetVersion()
{
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}stringthe root directory of view files. Defaults to 'moduleDir/views' where moduleDir is the directory containing the module class.
源码: framework/web/CWebModule.php#118 (显示) publicfunctiongetViewPath()
{
if($this->_viewPath!==null)
return$this->_viewPath;
else
return$this->_viewPath=$this->getBasePath().DIRECTORY_SEPARATOR.'views';
}
setControllerPath() 方法
public void setControllerPath(string $value)
$valuestringthe directory that contains the controller classes.
源码: framework/web/CWebModule.php#107 (显示) 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/CWebModule.php#153 (显示) publicfunctionsetLayoutPath($path)
{
if(($this->_layoutPath=realpath($path))===false||!is_dir($this->_layoutPath))
thrownewCException(Yii::t('yii','Thelayoutpath"{path}"isnotavaliddirectory.',
array('{path}'=>$path)));
}
setViewPath() 方法
public void setViewPath(string $path)
$pathstringthe root directory of view files.
源码: framework/web/CWebModule.php#130 (显示) publicfunctionsetViewPath($path)
{
if(($this->_viewPath=realpath($path))===false||!is_dir($this->_viewPath))
thrownewCException(Yii::t('yii','Theviewpath"{path}"isnotavaliddirectory.',
array('{path}'=>$path)));
}