ImportSource: provide applyModifiers helper method

This commit is contained in:
Thomas Gelf 2016-07-20 14:25:18 +02:00
parent 29564ab742
commit f12e4b2033
3 changed files with 15 additions and 12 deletions

View File

@ -68,12 +68,7 @@ class ImportsourceHookTable extends QuickTable
}
$this->dataCache = $query->fetchAll();
if ($this->source->hasRowModifiers()) {
foreach ($this->dataCache as & $row) {
$this->source->applyModifiersToRow($row);
}
}
$this->source->applyModifiers($this->dataCache);
}
return $this->dataCache;

View File

@ -166,12 +166,7 @@ class Import
)->fetchData();
}
if ($this->source->hasRowModifiers()) {
foreach ($this->data as & $row) {
$this->source->applyModifiersToRow($row);
}
}
$this->source->applyModifiers($this->data);
return $this->data;
}

View File

@ -77,6 +77,19 @@ class ImportSource extends DbObjectWithSettings
return null;
}
public function applyModifiers(& $data)
{
$modifiers = $this->getRowModifiers();
if (! empty($modifiers)) {
foreach ($data as &$row) {
$this->applyModifiersToRow($row);
}
}
return $this;
}
public function applyModifiersToRow(& $row)
{
$modifiers = $this->getRowModifiers();