diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sfIsisImporter.class.php | 26 | ||||
-rw-r--r-- | lib/sfIsisImporterManager.class.php | 6 |
2 files changed, 27 insertions, 5 deletions
diff --git a/lib/sfIsisImporter.class.php b/lib/sfIsisImporter.class.php index 22541e3..d0d9a9f 100644 --- a/lib/sfIsisImporter.class.php +++ b/lib/sfIsisImporter.class.php @@ -142,21 +142,43 @@ class sfIsisImporter extends IsisConnector if ($id) { - if (!call_user_func(array($base_model, 'getById'), $id)) + $existing = call_user_func(array($base_model, 'getById'), $id); + + if (!$existing) { $this->setBaseModelId($model); return $model; } - else + elseif ($this->skipExisting()) { return false; } + else + { + return $existing; + } } return $model; } /** + * Check if ISIS database configuration is set to not skip existing + * entries during an import. + * + * @return boolean + */ + public function skipExisting() + { + if (isset($this->format['import']['skip_existing'])) + { + return $this->format['import']['skip_existing']; + } + + return true; + } + + /** * Set the primary key for the model by getting it or just saving it. * * @param object $model Base model diff --git a/lib/sfIsisImporterManager.class.php b/lib/sfIsisImporterManager.class.php index 24b483e..e615f0c 100644 --- a/lib/sfIsisImporterManager.class.php +++ b/lib/sfIsisImporterManager.class.php @@ -90,9 +90,9 @@ class sfIsisImporterManager extends IsisConnector $database = basename($file, '.yaml'); $options = sfYaml::load($file); - if (isset($options['db']['order'])) + if (isset($options['import']['order'])) { - $databases[$options['db']['order']] = $database; + $databases[$options['import']['order']] = $database; } else { @@ -145,7 +145,7 @@ class sfIsisImporterManager extends IsisConnector { // Determine base model and max entries. $this->log('Starting mass import procedure for config '. $database .'.', 'notice'); - $base_model = $importer->format['db']['base_model']; + $base_model = $importer->format['import']['base_model']; $this->entries = ($entries != NULL && $entries <= $importer->entries) ? $entries : $importer->entries; if ($base_model) { |