Skip to content

Commit

Permalink
Check for data rows with no data items before migrating
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan Hall committed Jun 15, 2017
1 parent 1d28853 commit 3f6ad72
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Objects/DataRow.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,18 @@ public function getKeyDataItems() {

public function prepare(array $keyFields, array $fieldMap, callable $dataItemManipulator)
{
$this->validate();
$this->setKeyFields($keyFields);
$this->mapFields($fieldMap);
$this->callDataItemManipulator($dataItemManipulator);
}

private function validate() {
if (!$this->dataItems) {
throw new Exception('Data row contains no data items. The specified source may be producing an invalid data row.');
}
}

private function setKeyFields(array $keyFields) {
foreach($this->dataItems as $key => $dataItem) {
if (in_array($dataItem->fieldName, $keyFields)) {
Expand Down

0 comments on commit 3f6ad72

Please sign in to comment.