From 5419d4428c86c488a43124f85e5407d7cbae6541 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 14 Apr 2024 15:17:47 +0200 Subject: Adding upstream version 1.11.1. Signed-off-by: Daniel Baumann --- library/Director/Objects/SyncRule.php | 70 +++++------------------------------ 1 file changed, 9 insertions(+), 61 deletions(-) (limited to 'library/Director/Objects/SyncRule.php') diff --git a/library/Director/Objects/SyncRule.php b/library/Director/Objects/SyncRule.php index 89f7fd1..270a882 100644 --- a/library/Director/Objects/SyncRule.php +++ b/library/Director/Objects/SyncRule.php @@ -43,6 +43,10 @@ class SyncRule extends DbObject implements ExportInterface 'last_attempt', ]; + protected $booleans = [ + 'purge_existing' => 'purge_existing', + ]; + private $sync; private $purgeStrategy; @@ -60,8 +64,6 @@ class SyncRule extends DbObject implements ExportInterface private $newSyncProperties; - private $originalId; - public function listInvolvedSourceIds() { if (! $this->hasBeenLoadedFromDb()) { @@ -257,61 +259,13 @@ class SyncRule extends DbObject implements ExportInterface } /** - * @deprecated please use \Icinga\Module\Director\Data\Exporter - * @return object - */ - public function export() - { - $plain = $this->getProperties(); - $plain['originalId'] = $plain['id']; - unset($plain['id']); - - foreach ($this->stateProperties as $key) { - unset($plain[$key]); - } - $plain['properties'] = $this->exportSyncProperties(); - ksort($plain); - - return (object) $plain; - } - - /** - * @param object $plain - * @param Db $db - * @param bool $replace - * @return static - * @throws DuplicateKeyException - * @throws \Icinga\Exception\NotFoundError + * Flat object has 'properties', but setProperties() is not available in DbObject + * + * @return void */ - public static function import($plain, Db $db, $replace = false) + public function setSyncProperties(?array $value) { - $properties = (array) $plain; - if (isset($properties['originalId'])) { - $id = $properties['originalId']; - unset($properties['originalId']); - } else { - $id = null; - } - $name = $properties['rule_name']; - - if ($replace && $id && static::existsWithNameAndId($name, $id, $db)) { - $object = static::loadWithAutoIncId($id, $db); - } elseif ($replace && static::exists($name, $db)) { - $object = static::load($name, $db); - } elseif (static::existsWithName($name, $db)) { - throw new DuplicateKeyException( - 'Sync Rule %s already exists', - $name - ); - } else { - $object = static::create([], $db); - } - - $object->newSyncProperties = $properties['properties']; - unset($properties['properties']); - $object->setProperties($properties); - - return $object; + $this->newSyncProperties = $value; } public function getUniqueIdentifier() @@ -329,12 +283,6 @@ class SyncRule extends DbObject implements ExportInterface $connection = $this->getConnection(); $db = $connection->getDbAdapter(); $myId = $this->get('id'); - if ($this->originalId === null) { - $originalId = $myId; - } else { - $originalId = $this->originalId; - $this->originalId = null; - } if ($this->hasBeenLoadedFromDb()) { $db->delete( 'sync_property', -- cgit v1.2.3