Yii Framework v1.1.10 绫诲弬鑰

CAttributeCollection

system.collections
缁ф壙 class CAttributeCollection » CMap » CComponent
瀹炵幇 Countable, ArrayAccess, Traversable, IteratorAggregate
婧愯嚜 1.0
鐗堟湰 $Id: CAttributeCollection.php 3515 2011-12-28 12:29:24Z mdomba $
婧愮爜 framework/collections/CAttributeCollection.php
CAttributeCollection瀹炵幇浜嗕负鍌ㄥ瓨鐨勫睘鎬у悕绉板拰鍊肩殑闆嗗悎銆

CMap鎻愪緵鐨勬墍鏈夊姛鑳藉锛孋AttributeCollection 鍏佽浣犲儚getting鍜宻etting灞炴т竴鏍疯幏鍙栧拰璁剧疆 灞炴у笺備緥濡傦紝涓嬮潰鐨勭敤娉曞浜庝竴涓狢AttributeCollection瀵硅薄鏉ヨ锛 閮芥槸鏈夋晥鐨勶細
$collection->text='text'; // 绛変环浜庯細$collection->add('text','text');
echo $collection->text;   // 绛変环浜庯細echo $collection->itemAt('text');


灞炴у悕绉扮殑澶у皬鍐欐晱鎰熷彲浠ラ氳繃闆嗗悎鐨 caseSensitive灞炴у紑鍚垨鍏抽棴銆

鍏叡灞炴

闅愯棌缁ф壙灞炴

灞炴绫诲瀷鎻忚堪瀹氫箟鍦
caseSensitive boolean 閿悕鏄惁澶у皬鍐欐晱鎰熴傞粯璁や负false銆 CAttributeCollection
count integer 杩斿洖map涓殑椤圭洰鏁般 CMap
iterator CMapIterator 杩斿洖閬嶅巻杩欎釜鍒楄〃鐨勯」鐩殑杩唬鍣ㄣ CMap
keys array 杩斿洖閿悕鍒楄〃 CMap
readOnly boolean 杩斿洖鍊艰鏄庤繖涓垪琛ㄦ槸鍚︿负鍙銆傞粯璁や负false銆 CMap

鍏叡鏂规硶

闅愯棌缁ф壙鏂规硶

鏂规硶鎻忚堪瀹氫箟鍦
__call() 濡傛灉绫讳腑娌℃湁璋冪殑鏂规硶鍚嶏紝鍒欒皟鐢ㄨ繖涓柟娉曘 CComponent
__construct() 鏋勯犳柟娉曘 CMap
__get() 閫氳繃灞炴ф垨浜嬩欢鍚嶈繑鍥炰竴涓睘鎬у兼垨涓涓簨浠跺鐞嗙▼搴忓垪琛ㄣ CAttributeCollection
__isset() 妫娴嬩竴涓睘鎬у兼槸鍚︿负null銆 CAttributeCollection
__set() 璁剧疆涓涓粍浠跺睘鎬х殑鍊笺 CAttributeCollection
__unset() 璁剧疆涓涓粍浠跺睘鎬т负null銆 CAttributeCollection
add() 娣诲姞涓涓」鍒癿ap銆 CAttributeCollection
asa() 杩斿洖杩欎釜鍚嶅瓧鐨勮涓哄璞° CComponent
attachBehavior() 闄勫姞涓涓涓哄埌缁勪欢銆 CComponent
attachBehaviors() 闄勫姞涓涓涓哄垪琛ㄥ埌缁勪欢銆 CComponent
attachEventHandler() 涓轰簨浠堕檮鍔犱竴涓簨浠跺鐞嗙▼搴忋 CComponent
canGetProperty() 纭畾涓涓睘鎬ф槸鍚﹀彲璇汇 CAttributeCollection
canSetProperty() 纭畾涓涓睘鎬ф槸鍚﹀彲璁剧疆銆 CAttributeCollection
clear() 鍒犻櫎map涓墍鏈夐」鐩 CMap
contains() 杩斿洖鍊艰鏄庢寚瀹氱殑椤圭洰鏄惁鍦╩ap涓 CAttributeCollection
copyFrom() 灏嗚凯浠e櫒涓殑鏁版嵁澶嶅埗鍒癿ap銆 CMap
count() 杩斿洖map涓殑椤圭洰鏁般 CMap
detachBehavior() 浠庣粍浠朵腑鍒嗙涓涓涓恒 CComponent
detachBehaviors() 浠庣粍浠朵腑鍒嗙鎵鏈夎涓恒 CComponent
detachEventHandler() 鍒嗙涓涓瓨鍦ㄧ殑浜嬩欢澶勭悊绋嬪簭銆 CComponent
disableBehavior() 绂佺敤涓涓檮鍔犺涓恒 CComponent
disableBehaviors() 绂佺敤缁勪欢闄勫姞鐨勬墍鏈夎涓恒 CComponent
enableBehavior() 鍚敤涓涓檮鍔犺涓恒 CComponent
enableBehaviors() 鍚敤缁勪欢闄勫姞鐨勬墍鏈夎涓恒 CComponent
evaluateExpression() 璁$畻涓涓狿HP琛ㄨ揪寮忥紝鎴栨牴鎹粍浠朵笂涓嬫枃鎵ц鍥炶皟銆 CComponent
getCount() 杩斿洖map涓殑椤圭洰鏁般 CMap
getEventHandlers() 杩斿洖涓涓簨浠剁殑闄勫姞澶勭悊绋嬪簭鍒楄〃銆 CComponent
getIterator() 杩斿洖閬嶅巻杩欎釜鍒楄〃鐨勯」鐩殑杩唬鍣ㄣ CMap
getKeys() 杩斿洖杩斿洖閿悕鍒楄〃 CMap
getReadOnly() 杩斿洖杩斿洖鍊艰鏄庤繖涓垪琛ㄦ槸鍚︿负鍙銆傞粯璁や负false銆 CMap
hasEvent() 纭畾涓涓簨浠舵槸鍚﹀畾涔夈 CComponent
hasEventHandler() 妫鏌ヤ簨浠舵槸鍚︽湁闄勫姞鐨勫鐞嗙▼搴忋 CComponent
hasProperty() 纭畾鏄惁涓涓睘鎬у凡瀹氫箟銆 CAttributeCollection
itemAt() 杩斿洖鎸囧畾閿殑椤广 CAttributeCollection
mergeArray() 閫掑綊鍚堝苟涓や釜鎴栧涓暟缁勩 CMap
mergeWith() 灏嗚凯浠e櫒鐨勬暟鎹暣鍚堝埌map銆 CMap
offsetExists() 杩斿洖鍊艰鏄庢寚瀹氫綅缃槸鍚﹀瓨鍦ㄥ厓绱犮 CMap
offsetGet() 杩斿洖鍊兼寚瀹氫綅缃殑鍏冪礌銆 CMap
offsetSet() 璁剧疆鎸囧畾浣嶇疆鐨勫厓绱犮 CMap
offsetUnset() 鍒犻櫎鎸囧畾浣嶇疆鐨勫厓绱犮 CMap
raiseEvent() 鍙戣捣涓涓簨浠躲 CComponent
remove() 閫氳繃瀹冪殑閿粠map涓Щ闄や竴涓」鐩 CAttributeCollection
toArray() CMap

鍙椾繚鎶ゆ柟娉

闅愯棌缁ф壙鏂规硶

鏂规硶鎻忚堪瀹氫箟鍦
setReadOnly() 璁剧疆璁剧疆杩欎釜鍒楄〃鏄惁涓哄彧璇 CMap

灞炴ц缁

caseSensitive 灞炴
public boolean $caseSensitive;

閿悕鏄惁澶у皬鍐欐晱鎰熴傞粯璁や负false銆

鏂规硶璇︾粏

__get() 鏂规硶
public mixed __get(string $name)
$name string 灞炴у悕鎴栦簨浠跺悕
{return} mixed 灞炴у兼垨浜嬩欢澶勭悊绋嬪簭鍒楄〃
婧愮爜锛 framework/collections/CAttributeCollection.php#47 (鏄剧ず)
public function __get($name)
{
    if(
$this->contains($name))
        return 
$this->itemAt($name);
    else
        return 
parent::__get($name);
}

閫氳繃灞炴ф垨浜嬩欢鍚嶈繑鍥炰竴涓睘鎬у兼垨涓涓簨浠跺鐞嗙▼搴忓垪琛ㄣ 杩欎釜鏂规硶閫氳繃杩斿洖涓涓敭鍊兼槸鍚﹀瓨鍦ㄤ簬闆嗗悎鏉 瑕嗙洊鐖剁被鏂规硶銆

__isset() 鏂规硶
public boolean __isset(string $name)
$name string 灞炴у悕鎴栦簨浠跺悕
{return} boolean 杩斿洖鍊艰鏄庡睘鎬у兼槸鍚︿负null
婧愮爜锛 framework/collections/CAttributeCollection.php#75 (鏄剧ず)
public function __isset($name)
{
    if(
$this->contains($name))
        return 
$this->itemAt($name)!==null;
    else
        return 
parent::__isset($name);
}

妫娴嬩竴涓睘鎬у兼槸鍚︿负null銆 杩欎釜鏂规硶閫氳繃妫鏌ラ敭鍚嶆槸鍚﹀瓨鍦ㄤ簬闆嗗悎褰撲腑锛屽苟涓斾负闈瀗ull鍊硷紝杈惧埌 瑕嗙洊鐖剁被鏂规硶瀹炵幇銆

__set() 鏂规硶
public void __set(string $name, mixed $value)
$name string 灞炴у悕鎴栦簨浠跺悕
$value mixed 灞炴у兼垨浜嬩欢澶勭悊绋嬪簭
婧愮爜锛 framework/collections/CAttributeCollection.php#63 (鏄剧ず)
public function __set($name,$value)
{
    
$this->add($name,$value);
}

璁剧疆涓涓粍浠跺睘鎬х殑鍊笺 杩欎釜鏂规硶閫氳繃娣诲姞涓涓柊鐨勯敭鍚嶅拰閿煎埌闆嗗悎锛岃揪鍒 瑕嗙洊鐖剁被鏂规硶瀹炵幇銆

__unset() 鏂规硶
public void __unset(string $name)
$name string 灞炴у悕鎴栦簨浠跺悕
婧愮爜锛 framework/collections/CAttributeCollection.php#89 (鏄剧ず)
public function __unset($name)
{
    
$this->remove($name);
}

璁剧疆涓涓粍浠跺睘鎬т负null銆 杩欎釜鏂规硶閫氳繃娓呴櫎鎸囧畾鐨勯敭鍚嶉敭鍊硷紝杈惧埌 瑕嗙洊鐖剁被鏂规硶瀹炵幇銆

add() 鏂规硶
public void add(mixed $key, mixed $value)
$key mixed key
$value mixed value
婧愮爜锛 framework/collections/CAttributeCollection.php#114 (鏄剧ず)
public function add($key,$value)
{
    if(
$this->caseSensitive)
        
parent::add($key,$value);
    else
        
parent::add(strtolower($key),$value);
}

娣诲姞涓涓」鍒癿ap銆 杩欎釜鏂规硶鏄紝濡傛灉caseSensitive涓篺alse锛屽垯鍏堝皢閿悕杞崲鎴愬皬鍐欙紝杈惧埌瑕嗙洊鐖剁被鏂规硶瀹炵幇銆

canGetProperty() 鏂规硶
public boolean canGetProperty(string $name)
$name string 灞炴у悕
{return} boolean 杩斿洖鍊艰鏄庤灞炴ф槸鍚﹀彲璇
婧愮爜锛 framework/collections/CAttributeCollection.php#169 (鏄剧ず)
public function canGetProperty($name)
{
    return 
$this->contains($name) || parent::canGetProperty($name);
}

纭畾涓涓睘鎬ф槸鍚﹀彲璇汇 杩欎釜鏂规硶鏄紝濡傛灉闆嗗悎涓寘鍚閿悕瀵瑰簲鐨勯敭鍊硷紝鍒欒繑鍥瀟rue锛岃揪鍒 瑕嗙洊鐖剁被鏂规硶瀹炵幇銆

canSetProperty() 鏂规硶
public boolean canSetProperty(string $name)
$name string the property name
{return} boolean true
婧愮爜锛 framework/collections/CAttributeCollection.php#181 (鏄剧ず)
public function canSetProperty($name)
{
    return 
true;
}

纭畾涓涓睘鎬ф槸鍚﹀彲璁剧疆銆 杩欎釜鏂规硶閫氳繃杩斿洖鐪熻鐩栫埗绫绘柟娉曞疄鐜般 鍥犱负浣犳绘槸澧炲姞涓涓柊鍊煎埌闆嗗悎銆

contains() 鏂规硶
public boolean contains(mixed $key)
$key mixed 閿悕
{return} boolean 杩斿洖鍊艰鏄巑ap鏄惁鍖呭惈鐫鎸囧畾閿悕瀵瑰簲鐨勯」鐩
婧愮爜锛 framework/collections/CAttributeCollection.php#142 (鏄剧ず)
public function contains($key)
{
    if(
$this->caseSensitive)
        return 
parent::contains($key);
    else
        return 
parent::contains(strtolower($key));
}

杩斿洖鍊艰鏄庢寚瀹氱殑椤圭洰鏄惁鍦╩ap涓 杩欎釜鏂规硶鏄紝濡傛灉caseSensitive涓篺alse锛屽垯鍏堝皢閿悕杞崲鎴愬皬鍐欙紝杈惧埌瑕嗙洊鐖剁被鏂规硶瀹炵幇銆

hasProperty() 鏂规硶
public boolean hasProperty(string $name)
$name string 灞炴у悕
{return} boolean 杩斿洖鍊艰鏄庤灞炴ф槸鍚﹁瀹氫箟
婧愮爜锛 framework/collections/CAttributeCollection.php#157 (鏄剧ず)
public function hasProperty($name)
{
    return 
$this->contains($name) || parent::hasProperty($name);
}

纭畾鏄惁涓涓睘鎬у凡瀹氫箟銆 杩欎釜鏂规硶鏄紝濡傛灉闆嗗悎涓寘鍚閿悕瀵瑰簲鐨勯敭鍊硷紝鍒欒繑鍥瀟rue锛岃揪鍒 瑕嗙洊鐖剁被鏂规硶瀹炵幇銆

itemAt() 鏂规硶
public mixed itemAt(mixed $key)
$key mixed 閿悕
{return} mixed 杩斿洖鍦ㄥ亸绉婚噺浣嶇疆鐨勫厓绱狅紝濡傛灉鍦ㄦ鍋忕Щ浣嶇疆姝ゅ厓绱犳病鎵惧埌鍒欒繑鍥瀗ull銆
婧愮爜锛 framework/collections/CAttributeCollection.php#100 (鏄剧ず)
public function itemAt($key)
{
    if(
$this->caseSensitive)
        return 
parent::itemAt($key);
    else
        return 
parent::itemAt(strtolower($key));
}

杩斿洖鎸囧畾閿殑椤广 杩欎釜鏂规硶鏄紝濡傛灉caseSensitive涓篺alse锛屽垯鍏堝皢閿悕杞崲鎴愬皬鍐欙紝杈惧埌瑕嗙洊鐖剁被鏂规硶瀹炵幇銆

remove() 鏂规硶
public mixed remove(mixed $key)
$key mixed 琚Щ闄ょ殑椤圭洰鐨勯敭鍚嶃
{return} mixed 杩斿洖绉婚櫎鐨勯敭鍊硷紝濡傛灉閿悕涓嶅瓨鍦ㄥ垯杩斿洖null銆
婧愮爜锛 framework/collections/CAttributeCollection.php#128 (鏄剧ず)
public function remove($key)
{
    if(
$this->caseSensitive)
        return 
parent::remove($key);
    else
        return 
parent::remove(strtolower($key));
}

閫氳繃瀹冪殑閿粠map涓Щ闄や竴涓」鐩 杩欎釜鏂规硶鏄紝濡傛灉caseSensitive涓篺alse锛屽垯鍏堝皢閿悕杞崲鎴愬皬鍐欙紝杈惧埌瑕嗙洊鐖剁被鏂规硶瀹炵幇銆

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