ImportSource: allow Property Modifiers to reject

fixes #1369
This commit is contained in:
Thomas Gelf 2018-01-25 12:16:49 +01:00
parent 14e5aa8da4
commit 8ed76d4888

View File

@ -94,12 +94,21 @@ class ImportSource extends DbObjectWithSettings
{
$modifiers = $this->getRowModifiers();
$rejected = [];
if (! empty($modifiers)) {
foreach ($data as &$row) {
foreach ($data as $key => &$row) {
$this->applyModifiersToRow($row);
if (null === $row) {
$rejected[] = $row;
}
}
}
foreach ($rejected as $key) {
unset($data[$key]);
}
return $this;
}
@ -116,7 +125,7 @@ class ImportSource extends DbObjectWithSettings
foreach ($mods as $mod) {
$this->applyPropertyModifierToRow($mod, $key, $row);
if (null === $row) {
return $this;
return;
}
}
}
@ -154,6 +163,9 @@ class ImportSource extends DbObjectWithSettings
$row->$target = $modifier->transform($value);
}
if ($modifier->rejectsRow()) {
$row = null;
}
}
public function getRowModifiers()