summaryrefslogtreecommitdiffstats
path: root/library/Director/Objects/SyncProperty.php
diff options
context:
space:
mode:
Diffstat (limited to 'library/Director/Objects/SyncProperty.php')
-rw-r--r--library/Director/Objects/SyncProperty.php48
1 files changed, 48 insertions, 0 deletions
diff --git a/library/Director/Objects/SyncProperty.php b/library/Director/Objects/SyncProperty.php
new file mode 100644
index 0000000..20c4700
--- /dev/null
+++ b/library/Director/Objects/SyncProperty.php
@@ -0,0 +1,48 @@
+<?php
+
+namespace Icinga\Module\Director\Objects;
+
+use Icinga\Module\Director\Data\Db\DbObject;
+use Icinga\Module\Director\Objects\Extension\PriorityColumn;
+
+class SyncProperty extends DbObject
+{
+ use PriorityColumn;
+
+ protected $table = 'sync_property';
+
+ protected $keyName = 'id';
+
+ protected $autoincKeyName = 'id';
+
+ protected $defaultProperties = [
+ 'id' => null,
+ 'rule_id' => null,
+ 'source_id' => null,
+ 'source_expression' => null,
+ 'destination_field' => null,
+ 'priority' => null,
+ 'filter_expression' => null,
+ 'merge_policy' => null
+ ];
+
+ protected function beforeStore()
+ {
+ if (! $this->hasBeenLoadedFromDb() && $this->get('priority') === null) {
+ $this->setNextPriority('rule_id');
+ }
+ }
+
+ public function setSource($name)
+ {
+ $source = ImportSource::loadByName($name, $this->getConnection());
+ $this->set('source_id', $source->get('id'));
+
+ return $this;
+ }
+
+ protected function onInsert()
+ {
+ $this->refreshPriortyProperty();
+ }
+}