1
0
mirror of synced 2024-12-13 14:56:01 +03:00

Fixed issue with data dumping. Added exception throwing when you use data key that does not exist.

This commit is contained in:
Jonathan.Wage 2007-11-15 19:46:17 +00:00
parent 15bf4d70e0
commit f11e95497c
2 changed files with 14 additions and 5 deletions

View File

@ -174,7 +174,7 @@ class Doctrine_Data_Export extends Doctrine_Data
$relationValue = $relationClassName . '_' . $value;
$preparedData[$className][$recordKey][$relationClassName] = $relationValue;
$preparedData[$className][$recordKey][$relationAlias] = $relationValue;
} else {
$preparedData[$className][$recordKey][$key] = $value;
}

View File

@ -114,6 +114,15 @@ class Doctrine_Data_Import extends Doctrine_Data
}
}
protected function _getImportedObject($rowKey)
{
if (isset($this->_importedObjects[$rowKey])) {
return $this->_importedObjects[$rowKey];
} else {
throw new Doctrine_Data_Exception('Invalid row key specified: ' . $rowKey);
}
}
protected function _processRow($rowKey, $row)
{
$obj = $this->_importedObjects[$rowKey];
@ -130,18 +139,18 @@ class Doctrine_Data_Import extends Doctrine_Data
foreach ($value as $link) {
if ($obj->getTable()->getRelation($key)->getType() === Doctrine_Relation::ONE) {
$obj->set($key, $this->_importedObjects[$link]);
$obj->set($key, $this->_getImportedObject($link));
} else if ($obj->getTable()->getRelation($key)->getType() === Doctrine_Relation::MANY) {
$relation = $obj->$key;
$relation[] = $this->_importedObjects[$link];
$relation[] = $this->_getImportedObject($link);
}
}
} else {
$obj->$key->fromArray($value);
}
} else if (isset($this->_importedObjects[$value])) {
$obj->set($key, $this->_importedObjects[$value]);
} else {
$obj->set($key, $this->_getImportedObject($value));
}
}
}