fixed import
This commit is contained in:
@@ -14,7 +14,8 @@ public function getEntityClass(): string
|
||||
}
|
||||
|
||||
/**
|
||||
* Override validate to skip validation if email is empty.
|
||||
* Override validate to skip validation if email is empty or invalid.
|
||||
* Invalid emails should be skipped, not cause transaction rollback.
|
||||
*/
|
||||
public function validate(array $mapped): array
|
||||
{
|
||||
@@ -23,6 +24,12 @@ public function validate(array $mapped): array
|
||||
return ['valid' => true, 'errors' => []];
|
||||
}
|
||||
|
||||
// Validate email format - if invalid, mark as valid to skip instead of failing
|
||||
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||
// Return valid=true but we'll skip it in process()
|
||||
return ['valid' => true, 'errors' => []];
|
||||
}
|
||||
|
||||
return parent::validate($mapped);
|
||||
}
|
||||
|
||||
@@ -48,6 +55,14 @@ public function process(Import $import, array $mapped, array $raw, array $contex
|
||||
];
|
||||
}
|
||||
|
||||
// Skip if email format is invalid
|
||||
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||
return [
|
||||
'action' => 'skipped',
|
||||
'message' => 'Invalid email format',
|
||||
];
|
||||
}
|
||||
|
||||
// Resolve person_id from context
|
||||
$personId = $mapped['person_id'] ?? $context['person']['entity']?->id ?? null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user