Yii Framework v1.1.10 绫诲弬鑰

CWebModule

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.

鍏叡灞炴

闅愯棌缁ф壙灞炴

灞炴绫诲瀷鎻忚堪瀹氫箟鍦
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

灞炴ц缁

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)
$controller CController the controller
$action CAction the action
婧愮爜锛 framework/web/CWebModule.php#191 (鏄剧ず)
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#177 (鏄剧ず)
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#95 (鏄剧ず)
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#75 (鏄剧ず)
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#141 (鏄剧ず)
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#64 (鏄剧ず)
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#86 (鏄剧ず)
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#118 (鏄剧ず)
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#107 (鏄剧ず)
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#153 (鏄剧ず)
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#130 (鏄剧ず)
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.