aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-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