Skip to content
Browse files

added some phpDoc blocks and updated dryRun a lil bit

  • Loading branch information...
1 parent c9af266 commit 918a6754f5f243e75c4b909c44e2cd74eb168f8d @druid628 druid628 committed Mar 29, 2012
View
45 lib/import/PluginBsdImporterCsv.class.php
@@ -14,6 +14,12 @@ public function readData($filename)
}
}
+ /**
+ * validateHeaders() - Examines the header row in given csv
+ * file and verifies that these headers exist.
+ *
+ * @return boolean
+ */
public function validateHeaders()
{
foreach($this->getRequiredHeaders() as $key => $header)
@@ -27,6 +33,14 @@ public function validateHeaders()
return true;
}
+ /**
+ * validateRequiredFieldsInRow() - examines row provided
+ * and determines if the predefined required fields exist
+ * and returns based of that examination.
+ *
+ * @param array $row
+ * @return boolean
+ */
public function validateRequiredFieldsInRow($row)
{
$requiredFields = $this->getRequiredFields();
@@ -40,6 +54,13 @@ public function validateRequiredFieldsInRow($row)
}
}
+ /**
+ * Validates all rows in csv for the fields set as required
+ * by passing them through $this->validateRequiredFieldsInRow()
+ *
+ * @see validateRequiredFieldsInRow
+ * @return boolean
+ */
public function validateRequiredFields()
{
$requiredFields = $this->getRequiredFields();
@@ -54,6 +75,15 @@ public function validateRequiredFields()
return true;
}
+ /**
+ * processImport() - Runs validation and beings import functonality
+ * dryRun gives you the optional parameter that can be passed
+ * on to your execute function so you can treat dryRun import
+ * differently than a real import.
+ *
+ * @param boolean $dryRun
+ * @return array
+ */
public function processImport($dryRun = null)
{
if ( $this->validation == self::PRE_PROCCESS_VALIDATE )
@@ -84,10 +114,21 @@ public function processImport($dryRun = null)
$this->execute($rowData);
}
}
-
-
+
+ return array("success" => true);
}
+ /**
+ * execute() - Programmer defined logic for what should be done
+ * with each row as it's processed.
+ *
+ * @see processImport()
+ * @param array $row
+ * @param boolean $dryRun
+ */
+ public function execute($row, $dryRun = false)
+ {
+ }
}
View
2 lib/import/base/BsdImporterInterface.class.php
@@ -23,6 +23,6 @@ public function processImport($dryRun = false);
/**
* action to execute for each row during import process
*/
- public function execute($row);
+ public function execute($row, $dryRun = false);
}
View
29 lib/import/base/PluginBsdImporter.class.php
@@ -142,6 +142,15 @@ public function lcfirst($string)
return $string;
}
+ /**
+ * processImport() - Runs validation and beings import functonality
+ * dryRun gives you the optional parameter that can be passed
+ * on to your execute function so you can treat dryRun import
+ * differently than a real import.
+ *
+ * @param boolean $dryRun
+ * @return array
+ */
public function processImport($dryRun = false)
{
if ( $this->validation == self::PRE_PROCCESS_VALIDATE )
@@ -164,21 +173,21 @@ public function processImport($dryRun = false)
}
}
- if($dryRun)
- {
- $this->dryRunExecute($rowData);
- }
- else {
- $this->execute($rowData);
- }
+ $this->execute($rowData, $dryRun);
+
}
return array("success" => true);
}
+
/**
- *
- *
+ * execute() - Programmer defined logic for what should be done
+ * with each row as it's processed.
+ *
+ * @see processImport()
+ * @param array $row
+ * @param boolean $dryRun
*/
- public function execute($row)
+ public function execute($row, $dryRun = false)
{
/**
*

0 comments on commit 918a675

Please sign in to comment.
Something went wrong with that request. Please try again.