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

Fix schema merging and fixed issue with fixtures saving.

This commit is contained in:
Jonathan.Wage 2007-11-08 20:59:38 +00:00
parent c50b2bc375
commit ee9e79d09e
2 changed files with 18 additions and 5 deletions

View File

@ -64,7 +64,7 @@ class Doctrine_Data_Import extends Doctrine_Data
// If they specified a specific yml file
if (end($e) == 'yml') {
$array = array_merge_recursive(Doctrine_Parser::load($dir, $this->getFormat()), $array);
$array = array_merge(Doctrine_Parser::load($dir, $this->getFormat()), $array);
// If they specified a directory
} else if(is_dir($dir)) {
$it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir),
@ -73,7 +73,7 @@ class Doctrine_Data_Import extends Doctrine_Data
foreach ($it as $file) {
$e = explode('.', $file->getFileName());
if (in_array(end($e), $this->getFormats())) {
$array = array_merge_recursive(Doctrine_Parser::load($file->getPathName(), $this->getFormat()), $array);
$array = array_merge(Doctrine_Parser::load($file->getPathName(), $this->getFormat()), $array);
}
}
}
@ -172,7 +172,20 @@ class Doctrine_Data_Import extends Doctrine_Data
$manager = Doctrine_Manager::getInstance();
foreach ($manager as $connection) {
$connection->flush();
$objects = array();
foreach ($this->_importedObjects as $object) {
$objects[] = get_class($object);
}
$tree = $connection->unitOfWork->buildFlushTree($objects);
foreach ($tree as $model) {
foreach ($this->_importedObjects as $obj) {
if ($obj instanceof $model) {
$obj->save();
}
}
}
}
}

View File

@ -103,7 +103,7 @@ class Doctrine_Import_Schema
foreach ((array) $schema AS $s) {
if (is_file($s)) {
$array = array_merge($array, $this->parseSchema($s, $format));
$array = array_merge($this->parseSchema($s, $format), $array);
} else if (is_dir($s)) {
$it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($s),
RecursiveIteratorIterator::LEAVES_ONLY);
@ -111,7 +111,7 @@ class Doctrine_Import_Schema
foreach ($it as $file) {
$e = explode('.', $file->getFileName());
if (end($e) === $format) {
$array = array_merge($array, $this->parseSchema($file->getPathName(), $format));
$array = array_merge($this->parseSchema($file->getPathName(), $format), $array);
}
}
}