aboutsummaryrefslogtreecommitdiff
path: root/lib/sfIsisImporterRelations.class.php
diff options
context:
space:
mode:
authorSilvio <s1lv10@uol.com.br>2010-09-21 16:32:06 -0300
committerSilvio <s1lv10@uol.com.br>2010-09-21 16:32:06 -0300
commitbb31ca3127470a2abf15b5110e8b80f9fdc6e4a3 (patch)
treeb9eaff14ed704a2e6f8e1239f111b277ee052bd3 /lib/sfIsisImporterRelations.class.php
parent504341d67c0887d4d496465ab0ed052be46c6390 (diff)
downloadsf_isis_importer_plugin-bb31ca3127470a2abf15b5110e8b80f9fdc6e4a3.tar.gz
sf_isis_importer_plugin-bb31ca3127470a2abf15b5110e8b80f9fdc6e4a3.tar.bz2
Adding method addOneToManySubfields
Diffstat (limited to 'lib/sfIsisImporterRelations.class.php')
-rw-r--r--lib/sfIsisImporterRelations.class.php37
1 files changed, 34 insertions, 3 deletions
diff --git a/lib/sfIsisImporterRelations.class.php b/lib/sfIsisImporterRelations.class.php
index 956d287..bf41120 100644
--- a/lib/sfIsisImporterRelations.class.php
+++ b/lib/sfIsisImporterRelations.class.php
@@ -44,10 +44,12 @@ class sfIsisImporterRelations extends sfIsisImporterEntities {
}
/**
- * Add simple entities data into the model.
+ * Add simple entities data into the model using main item data.
*
- * @param object $model Model
- * @param array $field Field data from ISIS database schema
+ * @param object $model Model
+ * @param array $field Field data from ISIS database schema
+ * @param string $entity Entity name
+ * @param string $key Optional data key
*/
public function addOneToManyMain(&$model, array $field, $entity, $key = 'name')
{
@@ -61,6 +63,35 @@ class sfIsisImporterRelations extends sfIsisImporterEntities {
}
/**
+ * Add simple entities data into the model using subfield data.
+ *
+ * @param object $model Model
+ * @param array $field Field data from ISIS database schema
+ * @param string $entity Entity name
+ */
+ public function addOneToManySubfields(&$model, array $field, $entity)
+ {
+ $relations = array();
+
+ foreach (new IsisSubfieldIterator($this->isis, $field) as $row => $subfield)
+ {
+ if (!isset($relations[$row]))
+ {
+ // Initialize a new relation.
+ $relations[$row] = $this->addOneToMany($model, $entity);
+ }
+
+ $relations[$row]->{$subfield} = $this->isis->getSubfield($field, $subfield, $row);
+ }
+
+ // Save all relations.
+ foreach($relations as $relation)
+ {
+ $relation->save();
+ }
+ }
+
+ /**
* Import a single value to a many to many data model.
*
* @param object $model Model