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