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 /lib/sfIsisImporterRelations.class.php | |
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()
Diffstat (limited to 'lib/sfIsisImporterRelations.class.php')
-rw-r--r-- | lib/sfIsisImporterRelations.class.php | 12 |
1 files changed, 11 insertions, 1 deletions
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'); + } } } |