| 包 | system.collections |
|---|---|
| 继承 | class CTypedList » CList » CComponent |
| 实现 | Countable, ArrayAccess, Traversable, IteratorAggregate |
| 源自 | 1.0 |
| 版本 | $Id: CTypedList.PHP 3001 2011-02-24 16:42:44Z alexander.makarow $ |
| 源码 |
CTypedList代表一个项目的某些类型的列表。
CTypedList继承于CList,它确定了 要添加到列表的元素是某些类型。
CTypedList继承于CList,它确定了 要添加到列表的元素是某些类型。
公共属性
| 属性 | 类型 | 描述 | 定义在 |
|---|---|---|---|
| count | integer | 返回列表的项目数。 | CList |
| iterator | Iterator | 返回遍历这个项目列表的迭代器。 | CList |
| readOnly | boolean | 返回值说明这个列表是否为只读。默认为false。 | CList |
公共方法
| 方法 | 描述 | 定义在 |
|---|---|---|
| __call() | 如果类中没有调的方法名,则调用这个方法。 | CComponent |
| __construct() | 构造方法 | CTypedList |
| __get() | 返回一个属性值、一个事件处理程序列表或一个行为名称。 | CComponent |
| __isset() | 检查一个属性是否为null。 | CComponent |
| __set() | 设置一个组件的属性值。 | CComponent |
| __unset() | 设置一个组件的属性为null。 | CComponent |
| add() | 在列表尾部添加一个项目。 | CList |
| asa() | 返回这个名字的行为对象。 | CComponent |
| attachBehavior() | 附加一个行为到组件。 | CComponent |
| attachBehaviors() | 附加一个行为列表到组件。 | CComponent |
| attachEventHandler() | 为事件附加一个事件处理程序。 | CComponent |
| canGetProperty() | 确定属性是否可读。 | CComponent |
| canSetProperty() | 确定属性是否可写。 | CComponent |
| clear() | 删除列表中所有项目。 | CList |
| contains() | CList | |
| copyFrom() | 将迭代器中的数据复制到列表。 | CList |
| count() | 返回列表的项目数。 | CList |
| detachBehavior() | 从组件中分离一个行为。 | CComponent |
| detachBehaviors() | 从组件中分离所有行为。 | CComponent |
| detachEventHandler() | 分离一个存在的事件处理程序。 | CComponent |
| disableBehavior() | 禁用一个附加行为。 | CComponent |
| disableBehaviors() | 禁用组件附加的所有行为。 | CComponent |
| enableBehavior() | 启用一个附加行为。 | CComponent |
| enableBehaviors() | 启用组件附加的所有行为。 | CComponent |
| evaLuateExpression() | 计算一个PHP表达式,或根据组件上下文执行回调。 | CComponent |
| getCount() | 返回列表的项目数。 | CList |
| getEventHandlers() | 返回一个事件的附加处理程序列表。 | CComponent |
| getIterator() | 返回遍历这个项目列表的迭代器。 | CList |
| getReadOnly() | 返回返回值说明这个列表是否为只读。默认为false。 | CList |
| hasEvent() | 确定一个事件是否定义。 | CComponent |
| hasEventHandler() | 检查事件是否有附加的处理程序。 | CComponent |
| hasProperty() | 确定属性是否被定义。 | CComponent |
| indexOf() | CList | |
| insertAt() | 将项目插入到指定位置。 | CTypedList |
| itemAt() | 返回指定位置的项目。 | CList |
| mergeWith() | 将迭代器的数据整合到map | CList |
| offsetExists() | 返回值说明列表中是否包含这个项目。 | CList |
| offsetGet() | 返回指定位置的项目。 | CList |
| offsetSet() | 在指定位置插入项目。 | CList |
| offsetUnset() | 删除指定位置的项目。 | CList |
| raiseEvent() | 发起一个事件。 | CComponent |
| remove() | 从列表中删除一个项目。 | CList |
| removeAt() | 删除指定位置的项目。 | CList |
| toArray() | CList |
受保护方法
| 方法 | 描述 | 定义在 |
|---|---|---|
| setReadOnly() | 设置设置这个列表是否为只读 | CList |
方法详细
__construct()
方法
|
public void __construct(string $type)
| ||
| $type | string | 类的类型 |
public function __construct($type)
{
$this->_type=$type;
}
构造方法
insertAt()
方法
|
public void insertAt(integer $index, mixed $item)
| ||
| $index | integer | 指定位置。 |
| $item | mixed | 新的项目 |
public function insertAt($index,$item)
{
if($item instanceof $this->_type)
parent::insertAt($index,$item);
else
throw new CException(Yii::t('yii','CTypedList<{type}> can only hold objects of {type} class.',
array('{type}'=>$this->_type)));
}
将项目插入到指定位置。 这个方法重写了父类方法, 实现了检查要插入的项目是否为某个类型。