ImportRowModifier: reduce instantiated objects

This commit is contained in:
Thomas Gelf 2016-07-20 12:59:02 +02:00
parent 2ff722e4d2
commit 225e9beec6
3 changed files with 18 additions and 9 deletions

View File

@ -88,11 +88,8 @@ class ImportsourceHookTable extends QuickTable
if (! array_key_exists($mod->property_name, $propertyModifiers)) {
$propertyModifiers[$mod->property_name] = array();
}
$obj = new $mod->provider_class;
$obj->setSettings($mod->getSettings());
$obj->setDb($this->source->getConnection());
$propertyModifiers[$mod->property_name][] = $obj;
$propertyModifiers[$mod->property_name][] = $mod->getInstance();
}
foreach ($this->dataCache as & $row) {

View File

@ -234,10 +234,8 @@ class Import
if (! array_key_exists($mod->property_name, $propertyModifiers)) {
$propertyModifiers[$mod->property_name] = array();
}
$obj = new $mod->provider_class;
$obj->setSettings($mod->getSettings());
$obj->setDb($this->connection);
$propertyModifiers[$mod->property_name][] = $obj;
$propertyModifiers[$mod->property_name][] = $mod->getInstance();
}
return $propertyModifiers;

View File

@ -23,4 +23,18 @@ class ImportRowModifier extends DbObjectWithSettings
protected $settingsTable = 'import_row_modifier_setting';
protected $settingsRemoteId = 'row_modifier_id';
private $hookInstance;
public function getInstance()
{
if ($this->hookInstance === null) {
$obj = new $this->provider_class;
$obj->setSettings($this->getSettings());
$obj->setDb($this->connection);
$this->hookInstance = $obj;
}
return $this->hookInstance;
}
}