Author: mcantelon
Date: Fri Jan 6 16:14:58 2012
New Revision: 10594
Log:
Made an option handler for import class.
Modified:
trunk/lib/QubitFlatfileImport.class.php
Modified: trunk/lib/QubitFlatfileImport.class.php
==============================================================================
--- trunk/lib/QubitFlatfileImport.class.php Fri Jan 6 16:11:45 2012
(r10593)
+++ trunk/lib/QubitFlatfileImport.class.php Fri Jan 6 16:14:58 2012
(r10594)
@@ -46,17 +46,7 @@
'arrayColumns'
);
- // set properties from options, halting upon invalid option
- foreach($options as $option => $value)
- {
- if (in_array($option, $allowedOptions))
- {
- $this->$option = $value;
- }
- else {
- throw new Exception('Option "'. $option .'" not allowed.');
- }
- }
+ $this->setPropertiesFromArray($this, $options, $allowedOptions);
// initialize bookkeeping of rows processed
$this->status = ($options['status']) ? $options['status'] : array();
@@ -66,6 +56,24 @@
$this->rowStatusVars = array();
}
+ protected function setPropertiesFromArray(&$object, $propertyArray,
$allowedOptions, $ignore = array())
+ {
+ // set properties from options, halting upon invalid option
+ foreach($propertyArray as $option => $value)
+ {
+ if (!in_array($option, $ignore))
+ {
+ if (in_array($option, $allowedOptions))
+ {
+ $object->$option = $value;
+ }
+ else {
+ throw new Exception('Option "'. $option .'" not allowed.');
+ }
+ }
+ }
+ }
+
public function setStatus($var, $value)
{
$this->status[$var] = $value;
@@ -321,10 +329,10 @@
$event->informationObjectId = $this->informationObject->id;
$event->typeId = $typeId;
- if (isset($options['date']))
- {
- $event->date = $options['date'];
- }
+ $allowedOptions = array('date', 'description', 'startDate', 'endDate');
+ $ignoreOptions = array('actorName', 'actorHistory');
+
+ $this->setPropertiesFromArray($event, $options, $allowedOptions,
$ignoreOptions);
if (isset($options['actorName']))
{
@@ -333,21 +341,6 @@
$event->actorId = $actor->id;
}
- if (isset($options['description']))
- {
- $event->description = $options['description'];
- }
-
- if (isset($options['startDate']))
- {
- $event->startDate = $options['startDate'];
- }
-
- if (isset($options['endDate']))
- {
- $event->endDate = $options['endDate'];
- }
-
if (!isset($self->testing) || !$self->testing)
{
$event->save();
--
You received this message because you are subscribed to the Google Groups
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/qubit-commits?hl=en.