| Package | system.collections |
|---|---|
| Inheritance | class CTypedMap » CMap » CComponent |
| Implements | Countable, ArrayAccess, Traversable, IteratorAggregate |
| Since | 1.0 |
| Source Code | framework/collections/CTypedMap.php |
| Property | Type | Description | Defined By |
|---|---|---|---|
| count | integer | Returns the number of items in the map. | CMap |
| iterator | CMapIterator | Returns an iterator for traversing the items in the list. | CMap |
| keys | array | the key list | CMap |
| readOnly | boolean | whether this map is read-only or not. | CMap |
| Method | Description | Defined By |
|---|---|---|
| __call() | Calls the named method which is not a class method. | CComponent |
| __construct() | Constructor. | CTypedMap |
| __get() | Returns a property value, an event handler list or a behavior based on its name. | CComponent |
| __isset() | Checks if a property value is null. | CComponent |
| __set() | Sets value of a component property. | CComponent |
| __unset() | Sets a component property to be null. | CComponent |
| add() | Adds an item into the map. | CTypedMap |
| asa() | Returns the named behavior object. | CComponent |
| attachBehavior() | Attaches a behavior to this component. | CComponent |
| attachBehaviors() | Attaches a list of behaviors to the component. | CComponent |
| attachEventHandler() | Attaches an event handler to an event. | CComponent |
| canGetProperty() | Determines whether a property can be read. | CComponent |
| canSetProperty() | Determines whether a property can be set. | CComponent |
| clear() | Removes all items in the map. | CMap |
| contains() | CMap | |
| copyFrom() | Copies iterable data into the map. | CMap |
| count() | Returns the number of items in the map. | CMap |
| detachBehavior() | Detaches a behavior from the component. | CComponent |
| detachBehaviors() | Detaches all behaviors from the component. | CComponent |
| detachEventHandler() | Detaches an existing event handler. | CComponent |
| disableBehavior() | Disables an attached behavior. | CComponent |
| disableBehaviors() | Disables all behaviors attached to this component. | CComponent |
| enableBehavior() | Enables an attached behavior. | CComponent |
| enableBehaviors() | Enables all behaviors attached to this component. | CComponent |
| evaluateExpression() | Evaluates a PHP expression or callback under the context of this component. | CComponent |
| getCount() | Returns the number of items in the map. | CMap |
| getEventHandlers() | Returns the list of attached event handlers for an event. | CComponent |
| getIterator() | Returns an iterator for traversing the items in the list. | CMap |
| getKeys() | Returns the key list | CMap |
| getReadOnly() | Returns whether this map is read-only or not. Defaults to false. | CMap |
| hasEvent() | Determines whether an event is defined. | CComponent |
| hasEventHandler() | Checks whether the named event has attached handlers. | CComponent |
| hasProperty() | Determines whether a property is defined. | CComponent |
| itemAt() | Returns the item with the specified key. | CMap |
| mergeArray() | Merges two or more arrays into one recursively. | CMap |
| mergeWith() | Merges iterable data into the map. | CMap |
| offsetExists() | Returns whether there is an element at the specified offset. | CMap |
| offsetGet() | Returns the element at the specified offset. | CMap |
| offsetSet() | Sets the element at the specified offset. | CMap |
| offsetUnset() | Unsets the element at the specified offset. | CMap |
| raiseEvent() | Raises an event. | CComponent |
| remove() | Removes an item from the map by its key. | CMap |
| toArray() | CMap |
| Method | Description | Defined By |
|---|---|---|
| setReadOnly() | Sets whether this list is read-only or not | CMap |
public void __construct(string $type) | ||
| $type | string | class type |
public function __construct($type)
{
$this->_type=$type;
}
Constructor.
public void add(integer $index, mixed $item) | ||
| $index | integer | the specified position. |
| $item | mixed | new item |
public function add($index,$item)
{
if($item instanceof $this->_type)
parent::add($index,$item);
else
throw new CException(Yii::t('yii','CTypedMap<{type}> can only hold objects of {type} class.',
array('{type}'=>$this->_type)));
}
Adds an item into the map. This method overrides the parent implementation by checking the item to be inserted is of certain type.
© 2008–2017 by Yii Software LLC
Licensed under the three clause BSD license.
http://www.yiiframework.com/doc/api/1.1/CTypedMap