ImportRowModifier: also use PriorityColumn helper
This commit is contained in:
parent
4c7b940705
commit
3c4d4de633
|
@ -3,16 +3,20 @@
|
||||||
namespace Icinga\Module\Director\Objects;
|
namespace Icinga\Module\Director\Objects;
|
||||||
|
|
||||||
use Icinga\Module\Director\Data\Db\DbObjectWithSettings;
|
use Icinga\Module\Director\Data\Db\DbObjectWithSettings;
|
||||||
|
use Icinga\Module\Director\Hook\PropertyModifierHook;
|
||||||
|
use Icinga\Module\Director\Objects\Extension\PriorityColumn;
|
||||||
|
|
||||||
class ImportRowModifier extends DbObjectWithSettings
|
class ImportRowModifier extends DbObjectWithSettings
|
||||||
{
|
{
|
||||||
|
use PriorityColumn;
|
||||||
|
|
||||||
protected $table = 'import_row_modifier';
|
protected $table = 'import_row_modifier';
|
||||||
|
|
||||||
protected $keyName = 'id';
|
protected $keyName = 'id';
|
||||||
|
|
||||||
protected $autoincKeyName = 'id';
|
protected $autoincKeyName = 'id';
|
||||||
|
|
||||||
protected $defaultProperties = array(
|
protected $defaultProperties = [
|
||||||
'id' => null,
|
'id' => null,
|
||||||
'source_id' => null,
|
'source_id' => null,
|
||||||
'property_name' => null,
|
'property_name' => null,
|
||||||
|
@ -20,7 +24,7 @@ class ImportRowModifier extends DbObjectWithSettings
|
||||||
'target_property' => null,
|
'target_property' => null,
|
||||||
'priority' => null,
|
'priority' => null,
|
||||||
'description' => null,
|
'description' => null,
|
||||||
);
|
];
|
||||||
|
|
||||||
protected $settingsTable = 'import_row_modifier_setting';
|
protected $settingsTable = 'import_row_modifier_setting';
|
||||||
|
|
||||||
|
@ -31,13 +35,26 @@ class ImportRowModifier extends DbObjectWithSettings
|
||||||
public function getInstance()
|
public function getInstance()
|
||||||
{
|
{
|
||||||
if ($this->hookInstance === null) {
|
if ($this->hookInstance === null) {
|
||||||
$obj = new $this->provider_class;
|
/** @var PropertyModifierHook $obj */
|
||||||
|
$obj = new $this->get('provider_class');
|
||||||
$obj->setSettings($this->getSettings());
|
$obj->setSettings($this->getSettings());
|
||||||
$obj->setTargetProperty($this->target_property);
|
$obj->setTargetProperty($this->get('target_property'));
|
||||||
$obj->setDb($this->connection);
|
$obj->setDb($this->connection);
|
||||||
$this->hookInstance = $obj;
|
$this->hookInstance = $obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->hookInstance;
|
return $this->hookInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function beforeStore()
|
||||||
|
{
|
||||||
|
if (! $this->hasBeenLoadedFromDb()) {
|
||||||
|
$this->setNextPriority('source_id');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function onInsert()
|
||||||
|
{
|
||||||
|
$this->refreshPriortyProperty();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue