public function save($mapKey = 'save') { if (isset($this[0])) { return $this->createSaveTagWithPost(); } return parent::save($mapKey); }
public function remove() { if (isset($this[0])) { $dataClass = $this->getDataClass(); foreach ($this as $item) { $where = $item->getPrimaryArray(); $dataClass->where($where)->remove(); } } else { parent::remove(); } }
public function fill(AbstractItem $fillItemList, $fillByName, array $keyMap) { if (!$this->dataSource || !$fillItemList->getDataSource()) { return $this; } if (!isset($this[0])) { throw new Exception\InvalidArgumentException(sprintf('%s must be a item list', get_class($this))); } if (!isset($fillItemList[0])) { throw new Exception\InvalidArgumentException(sprintf('Filled item %s must be a list', get_class($fillItemList))); } list($primaryKey) = array_keys($keyMap); list($foreignKey) = array_values($keyMap); foreach ($this as $key => $item) { foreach ($fillItemList as $fillItem) { if ($item->{$primaryKey} == $fillItem->{$foreignKey}) { $this[$key][$fillByName] = $fillItem; } } } return $this; }