Overview

Packages

  • application
    • commands
    • components
      • actions
      • filters
      • leftWidget
      • permissions
      • sortableWidget
      • util
      • webupdater
      • x2flow
        • actions
        • triggers
      • X2GridView
      • X2Settings
    • controllers
    • models
      • embedded
    • modules
      • accounts
        • controllers
        • models
      • actions
        • controllers
        • models
      • calendar
        • controllers
        • models
      • charts
        • models
      • contacts
        • controllers
        • models
      • docs
        • components
        • controllers
        • models
      • groups
        • controllers
        • models
      • marketing
        • components
        • controllers
        • models
      • media
        • controllers
        • models
      • mobile
        • components
      • opportunities
        • controllers
        • models
      • products
        • controllers
        • models
      • quotes
        • controllers
        • models
      • services
        • controllers
        • models
      • template
        • models
      • users
        • controllers
        • models
      • workflow
        • controllers
        • models
      • x2Leads
        • controllers
        • models
  • Net
  • None
  • PHP
  • system
    • base
    • caching
      • dependencies
    • collections
    • console
    • db
      • ar
      • schema
        • cubrid
        • mssql
        • mysql
        • oci
        • pgsql
        • sqlite
    • i18n
      • gettext
    • logging
    • test
    • utils
    • validators
    • web
      • actions
      • auth
      • filters
      • form
      • helpers
      • renderers
      • services
      • widgets
        • captcha
        • pagers
  • Text
    • Highlighter
  • zii
    • behaviors
    • widgets
      • grid
      • jui

Classes

  • CAttributeCollection
  • CConfiguration
  • CList
  • CListIterator
  • CMap
  • CMapIterator
  • CQueue
  • CQueueIterator
  • CStack
  • CStackIterator
  • CTypedList
  • CTypedMap
  • Overview
  • Package
  • Class
  • Tree
 1: <?php
 2: /**
 3:  * This file contains CTypedMap class.
 4:  *
 5:  * @author Qiang Xue <qiang.xue@gmail.com>
 6:  * @link http://www.yiiframework.com/
 7:  * @copyright 2008-2013 Yii Software LLC
 8:  * @license http://www.yiiframework.com/license/
 9:  */
10: 
11: /**
12:  * CTypedMap represents a map whose items are of the certain type.
13:  *
14:  * CTypedMap extends {@link CMap} by making sure that the elements to be
15:  * added to the list is of certain class type.
16:  *
17:  * @author Qiang Xue <qiang.xue@gmail.com>
18:  * @package system.collections
19:  * @since 1.0
20:  */
21: class CTypedMap extends CMap
22: {
23:     private $_type;
24: 
25:     /**
26:      * Constructor.
27:      * @param string $type class type
28:      */
29:     public function __construct($type)
30:     {
31:         $this->_type=$type;
32:     }
33: 
34:     /**
35:      * Adds an item into the map.
36:      * This method overrides the parent implementation by
37:      * checking the item to be inserted is of certain type.
38:      * @param integer $index the specified position.
39:      * @param mixed $item new item
40:      * @throws CException If the index specified exceeds the bound,
41:      * the map is read-only or the element is not of the expected type.
42:      */
43:     public function add($index,$item)
44:     {
45:         if($item instanceof $this->_type)
46:             parent::add($index,$item);
47:         else
48:             throw new CException(Yii::t('yii','CTypedMap<{type}> can only hold objects of {type} class.',
49:                 array('{type}'=>$this->_type)));
50:     }
51: }
52: 
API documentation generated by ApiGen 2.8.0