Yii Framework v1.1.10 绫诲弬鑰

CInlineFilter

system.web.filters
缁ф壙 class CInlineFilter » CFilter » CComponent
瀹炵幇 IFilter
婧愯嚜 1.0
鐗堟湰 $Id: CInlineFilter.php 3026 2011-03-06 10:41:56Z haertl.mike $
婧愮爜 framework/web/filters/CInlineFilter.php
CInlineFilter浠h〃浣滀负鎺у埗鍣ㄧ殑鏂规硶瀹氫箟涓涓繃婊ゅ櫒銆

CInlineFilter杩愯閭d簺鍦ㄦ帶鍒跺櫒涓互鈥檉ilterXYZ($action)鈥樿繖鏍峰舰寮忓畾涔夛紝 鍚嶅瓧鈥榅YZ鈥欏彲浠ヤ粠name灞炴т腑璇诲彇銆

鍏叡灞炴

闅愯棌缁ф壙灞炴

灞炴绫诲瀷鎻忚堪瀹氫箟鍦
name string 杩囨护鍣ㄥ悕瀛椼傗榅YZ鈥欎唬琛ㄧ潃鈥榝ilterXYZ鈥欒繃婊ゆ柟娉曘 CInlineFilter

鍏叡鏂规硶

闅愯棌缁ф壙鏂规硶

鏂规硶鎻忚堪瀹氫箟鍦
__call() 濡傛灉绫讳腑娌℃湁璋冪殑鏂规硶鍚嶏紝鍒欒皟鐢ㄨ繖涓柟娉曘 CComponent
__get() 杩斿洖涓涓睘鎬у笺佷竴涓簨浠跺鐞嗙▼搴忓垪琛ㄦ垨涓涓涓哄悕绉般 CComponent
__isset() 妫鏌ヤ竴涓睘鎬ф槸鍚︿负null銆 CComponent
__set() 璁剧疆涓涓粍浠剁殑灞炴у笺 CComponent
__unset() 璁剧疆涓涓粍浠剁殑灞炴т负null銆 CComponent
asa() 杩斿洖杩欎釜鍚嶅瓧鐨勮涓哄璞° CComponent
attachBehavior() 闄勫姞涓涓涓哄埌缁勪欢銆 CComponent
attachBehaviors() 闄勫姞涓涓涓哄垪琛ㄥ埌缁勪欢銆 CComponent
attachEventHandler() 涓轰簨浠堕檮鍔犱竴涓簨浠跺鐞嗙▼搴忋 CComponent
canGetProperty() 纭畾灞炴ф槸鍚﹀彲璇汇 CComponent
canSetProperty() 纭畾灞炴ф槸鍚﹀彲鍐欍 CComponent
create() 鍒涘缓涓涓唴宓岀殑杩囨护鍣ㄥ疄渚嬨 CInlineFilter
detachBehavior() 浠庣粍浠朵腑鍒嗙涓涓涓恒 CComponent
detachBehaviors() 浠庣粍浠朵腑鍒嗙鎵鏈夎涓恒 CComponent
detachEventHandler() 鍒嗙涓涓瓨鍦ㄧ殑浜嬩欢澶勭悊绋嬪簭銆 CComponent
disableBehavior() 绂佺敤涓涓檮鍔犺涓恒 CComponent
disableBehaviors() 绂佺敤缁勪欢闄勫姞鐨勬墍鏈夎涓恒 CComponent
enableBehavior() 鍚敤涓涓檮鍔犺涓恒 CComponent
enableBehaviors() 鍚敤缁勪欢闄勫姞鐨勬墍鏈夎涓恒 CComponent
evaluateExpression() 璁$畻涓涓狿HP琛ㄨ揪寮忥紝鎴栨牴鎹粍浠朵笂涓嬫枃鎵ц鍥炶皟銆 CComponent
filter() 鎵ц杩囨护銆 CInlineFilter
getEventHandlers() 杩斿洖涓涓簨浠剁殑闄勫姞澶勭悊绋嬪簭鍒楄〃銆 CComponent
hasEvent() 纭畾涓涓簨浠舵槸鍚﹀畾涔夈 CComponent
hasEventHandler() 妫鏌ヤ簨浠舵槸鍚︽湁闄勫姞鐨勫鐞嗙▼搴忋 CComponent
hasProperty() 纭畾灞炴ф槸鍚﹁瀹氫箟銆 CComponent
init() 鍒濆鍖栬繃婊ゅ櫒銆 CFilter
raiseEvent() 鍙戣捣涓涓簨浠躲 CComponent

鍙椾繚鎶ゆ柟娉

闅愯棌缁ф壙鏂规硶

鏂规硶鎻忚堪瀹氫箟鍦
postFilter() 鎵цpost鎿嶄綔杩囨护鍣ㄣ CFilter
preFilter() 鎵ц棰勬搷浣滆繃婊ゅ櫒銆 CFilter

灞炴ц缁

name 灞炴
public string $name;

杩囨护鍣ㄥ悕瀛椼傗榅YZ鈥欎唬琛ㄧ潃鈥榝ilterXYZ鈥欒繃婊ゆ柟娉曘

鏂规硶璇︾粏

create() 鏂规硶
public static CInlineFilter create(CController $controller, string $filterName)
$controller CController 杩囨护鏂规硶鐨勫涓绘帶鍒跺櫒銆
$filterName string 杩囨护鍣ㄥ悕瀛椼
{return} CInlineFilter 瀹炰緥鍖栫殑瀵硅薄銆
婧愮爜锛 framework/web/filters/CInlineFilter.php#38 (鏄剧ず)
public static function create($controller,$filterName)
{
    if(
method_exists($controller,'filter'.$filterName))
    {
        
$filter=new CInlineFilter;
        
$filter->name=$filterName;
        return 
$filter;
    }
    else
        throw new 
CException(Yii::t('yii','Filter "{filter}" is invalid. Controller "{class}" does not have the filter method "filter{filter}".',
            array(
'{filter}'=>$filterName'{class}'=>get_class($controller))));
}

鍒涘缓涓涓唴宓岀殑杩囨护鍣ㄥ疄渚嬨 杩欎釜鍒涘缓鏄熀浜庤繃婊ゅ櫒鏄惁浼氬簲鐢ㄥ唴宓岀殑 鏂规硶鍚嶅瓧鎻忚堪鍜屽姩浣滃悕瀛楁潵瀹氱殑銆

filter() 鏂规硶
public void filter(CFilterChain $filterChain)
$filterChain CFilterChain 閫忚繃杩囨护鍣ㄥ凡鍚姩銆
婧愮爜锛 framework/web/filters/CInlineFilter.php#56 (鏄剧ず)
public function filter($filterChain)
{
    
$method='filter'.$this->name;
    
$filterChain->controller->$method($filterChain);
}

鎵ц杩囨护銆 杩欎釜鏂规硶璋冪敤瀹氫箟鍦ㄦ帶鍒跺櫒閲岄潰鐨勮繃婊ゆ柟娉曠殑銆

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