fixed import

This commit is contained in:
Simon Pocrnjič
2025-12-28 13:55:09 +01:00
parent 84b75143df
commit 36b63a180d
9 changed files with 548 additions and 34 deletions
+16 -1
View File
@@ -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;