Fixed issue with data dumping. Added exception throwing when you use data key that does not exist.
This commit is contained in:
parent
15bf4d70e0
commit
f11e95497c
@ -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;
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user