CWebModule
鍖 | system.web |
---|---|
缁ф壙 | class CWebModule » CModule » CComponent |
瀛愮被 | GiiModule |
鐗堟湰 | $Id: CWebModule.php 3515 2011-12-28 12:29:24Z mdomba $ |
婧愮爜 | framework/web/CWebModule.php |
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 |
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 | 杩斿洖鍖呭惈搴旂敤绋嬪簭妯″潡鐨勭洰褰曘 | CModule |
modules | array | 杩斿洖搴旂敤绋嬪簭褰撳墠宸茬粡瀹夎鐨勬ā鍧椼 | 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() | 濡傛灉绫讳腑娌℃湁璋冪殑鏂规硶鍚嶏紝鍒欒皟鐢ㄨ繖涓柟娉曘 | 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() | 璁$畻涓涓狿HP琛ㄨ揪寮忥紝鎴栨牴鎹粍浠朵笂涓嬫枃鎵ц鍥炶皟銆 | 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 |
灞炴ц缁
mapping from controller ID to controller configurations. Pleaser refer to CWebApplication::controllerMap for more details.
the directory that contains the controller classes. Defaults to 'moduleDir/controllers' where moduleDir is the directory containing the module class.
the ID of the default controller for this module. Defaults to 'default'.
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.
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.
the root directory of layout files. Defaults to 'moduleDir/views/layouts' where moduleDir is the directory containing the module class.
Returns the name of this module. The default implementation simply returns id. You may override this method to customize the name of this module.
Returns the version of this module. The default implementation returns '1.0'. You may override this method to customize the version of this module.
the root directory of view files. Defaults to 'moduleDir/views' where moduleDir is the directory containing the module class.
鏂规硶璇︾粏
public void afterControllerAction(CController $controller, CAction $action)
| ||
$controller | CController | the controller |
$action | CAction | the action |
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.
public boolean beforeControllerAction(CController $controller, CAction $action)
| ||
$controller | CController | the controller |
$action | CAction | the action |
{return} | boolean | whether the action should be executed. |
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;
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. |
public function getControllerPath()
{
if($this->_controllerPath!==null)
return $this->_controllerPath;
else
return $this->_controllerPath=$this->getBasePath().DIRECTORY_SEPARATOR.'controllers';
}
public string getDescription()
| ||
{return} | string | the description of this module. |
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.
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. |
public function getLayoutPath()
{
if($this->_layoutPath!==null)
return $this->_layoutPath;
else
return $this->_layoutPath=$this->getViewPath().DIRECTORY_SEPARATOR.'layouts';
}
public string getName()
| ||
{return} | string | the name of this module. |
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.
public string getVersion()
| ||
{return} | string | the version of this module. |
Returns the version of this module. The default implementation returns '1.0'. You may override this method to customize the version of this module.
public string getViewPath()
| ||
{return} | string | the root directory of view files. Defaults to 'moduleDir/views' where moduleDir is the directory containing the module class. |
public function getViewPath()
{
if($this->_viewPath!==null)
return $this->_viewPath;
else
return $this->_viewPath=$this->getBasePath().DIRECTORY_SEPARATOR.'views';
}
public void setControllerPath(string $value)
| ||
$value | string | the directory that contains the controller classes. |
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)));
}
public void setLayoutPath(string $path)
| ||
$path | string | the root directory of layout files. |
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)));
}
public void setViewPath(string $path)
| ||
$path | string | the root directory of view files. |
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)));
}