示例#1
0
 /**
  * Inserts an item at the specified position.
  * This method overrides the parent implementation by
  * checking the item to be inserted is of certain type.
  * @param integer $index the specified position.
  * @param mixed $item new item
  * @throws CException If the index specified exceeds the bound,
  * the list is read-only or the element is not of the expected type.
  */
 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)));
     }
 }
示例#2
0
 public function insertAt($index, $item)
 {
     if ($item instanceof IFilter) {
         parent::insertAt($index, $item);
     } else {
         throw new CException(Yii::t('yii', 'CFilterChain can only take objects implementing the IFilter interface.'));
     }
 }
 public function testCanNotInsertWhenReadOnly()
 {
     $list = new CList(array(), true);
     $this->setExpectedException('CException');
     $list->insertAt(1, 2);
 }