/**
* @param array|null $row
+ *
+ * @return bool
*/
- public function validateRow(?array $row): void {
+ public function validateRow(?array $row): bool {
try {
$rowNumber = $row['_id'];
$values = array_values($row);
$this->validateValues($values);
$this->setImportStatus($rowNumber, 'VALID', '');
+ return TRUE;
}
catch (CRM_Core_Exception $e) {
$this->setImportStatus($rowNumber, 'ERROR', $e->getMessage());
+ return FALSE;
}
}
public function _run(Result $result): void {
$userJobID = (int) str_replace('Import_', '', $this->_entityName);
$where = $this->where;
- $this->addWhere('_status', 'IN', ['new', 'valid']);
$this->getImportRows($result);
$parser = $this->getParser($userJobID);
foreach ($result as $row) {
+ if (!in_array($row['_status'], ['new', 'valid'], TRUE) && !$parser->validateRow($row)) {
+ continue;
+ }
$parser->import(array_values($row));
}
$parser->doPostImportActions();
->indexBy('name'));
$importFields[] = '_id';
$importFields[] = '_entity_id';
+ $importFields[] = '_status';
$this->setSelect($importFields);
parent::_run($result);
foreach ($result as &$row) {