diff options
author | Silvio <silvio@devlet.com.br> | 2010-11-16 18:03:03 -0200 |
---|---|---|
committer | Silvio <silvio@devlet.com.br> | 2010-11-16 18:03:03 -0200 |
commit | d665bccaa9ea9af94342a4fa96be545dc1dcd571 (patch) | |
tree | c2f566e80f762b514d03df1c41837307b233472a | |
parent | 83581a1f366295983a015b6e4c931102d04e0c49 (diff) | |
download | sf_isis_importer_plugin-d665bccaa9ea9af94342a4fa96be545dc1dcd571.tar.gz sf_isis_importer_plugin-d665bccaa9ea9af94342a4fa96be545dc1dcd571.tar.bz2 |
Trying to avoid duplicate entries at addManyToManyEntities()
-rw-r--r-- | lib/sfIsisImporter.class.php | 1 | ||||
-rw-r--r-- | lib/sfIsisImporterRelations.class.php | 12 |
2 files changed, 12 insertions, 1 deletions
diff --git a/lib/sfIsisImporter.class.php b/lib/sfIsisImporter.class.php index 9b2273a..4b2d587 100644 --- a/lib/sfIsisImporter.class.php +++ b/lib/sfIsisImporter.class.php @@ -104,6 +104,7 @@ class sfIsisImporter extends sfIsisImporterRelations { if (!$this->hasDeniedCombinations($base_model, $field)) { + $this->log("Calling $method for field ". $field['name'] .'.', 'debug'); $this->{$method}($model, $field); } } diff --git a/lib/sfIsisImporterRelations.class.php b/lib/sfIsisImporterRelations.class.php index bf41120..248bf99 100644 --- a/lib/sfIsisImporterRelations.class.php +++ b/lib/sfIsisImporterRelations.class.php @@ -151,9 +151,19 @@ class sfIsisImporterRelations extends sfIsisImporterEntities { */ public function addManyToManyEntities(&$model, array $values, $relation, $key = 'name') { + $existing = array(); + foreach ($values as $value) { - $this->addManyToMany($model, $value, $relation, $key); + // Prevent duplicate entries. + if (!in_array($value, $existing)) + { + $existing[] = $value; + $this->addManyToMany($model, $value, $relation, $key); + } + else { + $this->log("Found duplicate entry $value for relation $key.", 'debug'); + } } } |