Yii Framework v1.1.10 绫诲弬鑰

CModelBehavior

system.base
缁ф壙 class CModelBehavior » CBehavior » CComponent
瀹炵幇 IBehavior
瀛愮被 CActiveRecordBehavior
鐗堟湰 $Id: CModelBehavior.php 3515 2011-12-28 12:29:24Z mdomba $
婧愮爜 framework/base/CModelBehavior.php
CModelBehavior鏄墍鏈夋ā鍨嬬粍浠堕檮鍔犺涓虹殑鍩虹被銆 妯″瀷绫诲簲璇ョ户鎵CModel鎴栧畠鐨勫瓙绫汇

鍏叡灞炴

闅愯棌缁ф壙灞炴

灞炴绫诲瀷鎻忚堪瀹氫箟鍦
enabled boolean 浜嬩欢鏄惁琚惎鐢ㄣ CBehavior
owner CComponent 鑾峰緱闄勫姞琛屼负鐨勭粍浠躲 CBehavior

鍏叡鏂规硶

闅愯棌缁ф壙鏂规硶

鏂规硶鎻忚堪瀹氫箟鍦
__call() 濡傛灉绫讳腑娌℃湁璋冪殑鏂规硶鍚嶏紝鍒欒皟鐢ㄨ繖涓柟娉曘 CComponent
__get() 杩斿洖涓涓睘鎬у笺佷竴涓簨浠跺鐞嗙▼搴忓垪琛ㄦ垨涓涓涓哄悕绉般 CComponent
__isset() 妫鏌ヤ竴涓睘鎬ф槸鍚︿负null銆 CComponent
__set() 璁剧疆涓涓粍浠剁殑灞炴у笺 CComponent
__unset() 璁剧疆涓涓粍浠剁殑灞炴т负null銆 CComponent
afterConstruct() 鍝嶅簲CModel::onAfterConstruct浜嬩欢銆 CModelBehavior
afterValidate() 鍝嶅簲CModel::onAfterValidate浜嬩欢銆 CModelBehavior
asa() 杩斿洖杩欎釜鍚嶅瓧鐨勮涓哄璞° CComponent
attach() 闄勫姞浜嬩欢澶勭悊绋嬪簭鍒扮粍浠躲 CBehavior
attachBehavior() 闄勫姞涓涓涓哄埌缁勪欢銆 CComponent
attachBehaviors() 闄勫姞涓涓涓哄垪琛ㄥ埌缁勪欢銆 CComponent
attachEventHandler() 涓轰簨浠堕檮鍔犱竴涓簨浠跺鐞嗙▼搴忋 CComponent
beforeValidate() 鍝嶅簲CModel::onBeforeValidate浜嬩欢銆 CModelBehavior
canGetProperty() 纭畾灞炴ф槸鍚﹀彲璇汇 CComponent
canSetProperty() 纭畾灞炴ф槸鍚﹀彲鍐欍 CComponent
detach() 浠庣粍浠跺垎绂昏涓哄璞° CBehavior
detachBehavior() 浠庣粍浠朵腑鍒嗙涓涓涓恒 CComponent
detachBehaviors() 浠庣粍浠朵腑鍒嗙鎵鏈夎涓恒 CComponent
detachEventHandler() 鍒嗙涓涓瓨鍦ㄧ殑浜嬩欢澶勭悊绋嬪簭銆 CComponent
disableBehavior() 绂佺敤涓涓檮鍔犺涓恒 CComponent
disableBehaviors() 绂佺敤缁勪欢闄勫姞鐨勬墍鏈夎涓恒 CComponent
enableBehavior() 鍚敤涓涓檮鍔犺涓恒 CComponent
enableBehaviors() 鍚敤缁勪欢闄勫姞鐨勬墍鏈夎涓恒 CComponent
evaluateExpression() 璁$畻涓涓狿HP琛ㄨ揪寮忥紝鎴栨牴鎹粍浠朵笂涓嬫枃鎵ц鍥炶皟銆 CComponent
events() 澹版槑浜嬩欢鍜岀浉搴旂殑浜嬩欢澶勭悊鏂规硶銆 CModelBehavior
getEnabled() 杩斿洖浜嬩欢鏄惁琚惎鐢ㄣ CBehavior
getEventHandlers() 杩斿洖涓涓簨浠剁殑闄勫姞澶勭悊绋嬪簭鍒楄〃銆 CComponent
getOwner() 杩斿洖鑾峰緱闄勫姞琛屼负鐨勭粍浠躲 CBehavior
hasEvent() 纭畾涓涓簨浠舵槸鍚﹀畾涔夈 CComponent
hasEventHandler() 妫鏌ヤ簨浠舵槸鍚︽湁闄勫姞鐨勫鐞嗙▼搴忋 CComponent
hasProperty() 纭畾灞炴ф槸鍚﹁瀹氫箟銆 CComponent
raiseEvent() 鍙戣捣涓涓簨浠躲 CComponent
setEnabled() 璁剧疆鏄惁鍚敤琛屼负 CBehavior

鏂规硶璇︾粏

afterConstruct() 鏂规硶
public void afterConstruct(CEvent $event)
$event CEvent 浜嬩欢鍙傛暟
婧愮爜锛 framework/base/CModelBehavior.php#44 (鏄剧ず)
public function afterConstruct($event)
{
}

鍝嶅簲CModel::onAfterConstruct浜嬩欢銆 濡傛灉浣犳兂澶勭悊owner瀵瑰簲鐨勪簨浠讹紝璇烽噸杞芥鏂规硶銆

afterValidate() 鏂规硶
public void afterValidate(CEvent $event)
$event CEvent 浜嬩欢鍙傛暟
婧愮爜锛 framework/base/CModelBehavior.php#63 (鏄剧ず)
public function afterValidate($event)
{
}

鍝嶅簲CModel::onAfterValidate浜嬩欢銆 濡傛灉浣犳兂澶勭悊owner瀵瑰簲鐨勪簨浠讹紝璇烽噸杞芥鏂规硶銆

beforeValidate() 鏂规硶
public void beforeValidate(CModelEvent $event)
$event CModelEvent 浜嬩欢鍙傛暟
婧愮爜锛 framework/base/CModelBehavior.php#54 (鏄剧ず)
public function beforeValidate($event)
{
}

鍝嶅簲CModel::onBeforeValidate浜嬩欢銆 濡傛灉浣犳兂澶勭悊owner瀵瑰簲鐨勪簨浠讹紝璇烽噸杞芥鏂规硶銆 浣犲彲浠ヨ缃CModelEvent::isValid涓篺alse閫鍑洪獙璇佽繃绋嬨

events() 鏂规硶
public array events()
{return} array 浜嬩欢锛堟暟缁勯敭锛夊搴旂殑浜嬩欢澶勭悊鏂规硶锛堟暟缁勫硷級銆
婧愮爜锛 framework/base/CModelBehavior.php#30 (鏄剧ず)
public function events()
{
    return array(
        
'onAfterConstruct'=>'afterConstruct',
        
'onBeforeValidate'=>'beforeValidate',
        
'onAfterValidate'=>'afterValidate',
    );
}

澹版槑浜嬩欢鍜岀浉搴旂殑浜嬩欢澶勭悊鏂规硶銆 榛樿瀹炵幇浜嗏榦nAfterConstruct鈥欙紝鈥榦nBeforeValidate鈥欏拰鈥榦nAfterValidate鈥欎簨浠跺拰浜嬩欢澶勭悊銆 濡傛灉浣犻噸杞芥鏂规硶锛岃纭繚鍚堝苟鐖剁被鐨勮繑鍥炲笺

鍙傝

Copyright © 2008-2011 by Yii Software LLC
All Rights Reserved.