From f12e4b2033f5a9fdd6ed51c8f9e5b78fc78aa1bd Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Wed, 20 Jul 2016 14:25:18 +0200 Subject: [PATCH] ImportSource: provide applyModifiers helper method --- application/tables/ImportsourceHookTable.php | 7 +------ library/Director/Import/Import.php | 7 +------ library/Director/Objects/ImportSource.php | 13 +++++++++++++ 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/application/tables/ImportsourceHookTable.php b/application/tables/ImportsourceHookTable.php index 1f142c08..1de1927d 100644 --- a/application/tables/ImportsourceHookTable.php +++ b/application/tables/ImportsourceHookTable.php @@ -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; diff --git a/library/Director/Import/Import.php b/library/Director/Import/Import.php index c90d7011..ddef2257 100644 --- a/library/Director/Import/Import.php +++ b/library/Director/Import/Import.php @@ -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; } diff --git a/library/Director/Objects/ImportSource.php b/library/Director/Objects/ImportSource.php index fc2dd303..226500aa 100644 --- a/library/Director/Objects/ImportSource.php +++ b/library/Director/Objects/ImportSource.php @@ -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();