ImportRowModifier: reduce instantiated objects
This commit is contained in:
parent
2ff722e4d2
commit
225e9beec6
|
@ -88,11 +88,8 @@ class ImportsourceHookTable extends QuickTable
|
||||||
if (! array_key_exists($mod->property_name, $propertyModifiers)) {
|
if (! array_key_exists($mod->property_name, $propertyModifiers)) {
|
||||||
$propertyModifiers[$mod->property_name] = array();
|
$propertyModifiers[$mod->property_name] = array();
|
||||||
}
|
}
|
||||||
$obj = new $mod->provider_class;
|
|
||||||
$obj->setSettings($mod->getSettings());
|
$propertyModifiers[$mod->property_name][] = $mod->getInstance();
|
||||||
$obj->setDb($this->source->getConnection());
|
|
||||||
$propertyModifiers[$mod->property_name][] = $obj;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($this->dataCache as & $row) {
|
foreach ($this->dataCache as & $row) {
|
||||||
|
|
|
@ -234,10 +234,8 @@ class Import
|
||||||
if (! array_key_exists($mod->property_name, $propertyModifiers)) {
|
if (! array_key_exists($mod->property_name, $propertyModifiers)) {
|
||||||
$propertyModifiers[$mod->property_name] = array();
|
$propertyModifiers[$mod->property_name] = array();
|
||||||
}
|
}
|
||||||
$obj = new $mod->provider_class;
|
|
||||||
$obj->setSettings($mod->getSettings());
|
$propertyModifiers[$mod->property_name][] = $mod->getInstance();
|
||||||
$obj->setDb($this->connection);
|
|
||||||
$propertyModifiers[$mod->property_name][] = $obj;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $propertyModifiers;
|
return $propertyModifiers;
|
||||||
|
|
|
@ -23,4 +23,18 @@ class ImportRowModifier extends DbObjectWithSettings
|
||||||
protected $settingsTable = 'import_row_modifier_setting';
|
protected $settingsTable = 'import_row_modifier_setting';
|
||||||
|
|
||||||
protected $settingsRemoteId = 'row_modifier_id';
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue