[REF] Extract validateRow
authorEileen McNaughton <emcnaughton@wikimedia.org>
Mon, 26 Sep 2022 02:26:38 +0000 (15:26 +1300)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Mon, 26 Sep 2022 02:26:38 +0000 (15:26 +1300)
CRM/Import/Parser.php

index 65eba6fdf1c663fedee519a9d825d3ff0f037051..22a14bcafa4f4f10d7995348ccad504047ff895b 100644 (file)
@@ -1820,15 +1820,7 @@ abstract class CRM_Import_Parser implements UserJobInterface {
   public function validate(): void {
     $dataSource = $this->getDataSourceObject();
     while ($row = $dataSource->getRow()) {
-      try {
-        $rowNumber = $row['_id'];
-        $values = array_values($row);
-        $this->validateValues($values);
-        $this->setImportStatus($rowNumber, 'VALID', '');
-      }
-      catch (CRM_Core_Exception $e) {
-        $this->setImportStatus($rowNumber, 'ERROR', $e->getMessage());
-      }
+      $this->validateRow($row);
     }
   }
 
@@ -2551,4 +2543,19 @@ abstract class CRM_Import_Parser implements UserJobInterface {
     return $dedupeRules;
   }
 
+  /**
+   * @param array|null $row
+   */
+  public function validateRow(?array $row): void {
+    try {
+      $rowNumber = $row['_id'];
+      $values = array_values($row);
+      $this->validateValues($values);
+      $this->setImportStatus($rowNumber, 'VALID', '');
+    }
+    catch (CRM_Core_Exception $e) {
+      $this->setImportStatus($rowNumber, 'ERROR', $e->getMessage());
+    }
+  }
+
 }