From 8680f04532e0cdf7509ebc0c9a5594e1a555e9fa Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Thu, 17 Mar 2016 23:08:57 +0100 Subject: [PATCH] IcingaObject: a bunch of timeperiod-related fixes --- library/Director/Objects/IcingaObject.php | 30 +++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/library/Director/Objects/IcingaObject.php b/library/Director/Objects/IcingaObject.php index 5b2a397d..6f18d034 100644 --- a/library/Director/Objects/IcingaObject.php +++ b/library/Director/Objects/IcingaObject.php @@ -401,6 +401,17 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer return parent::set($key, $value); } + protected function setRanges($ranges) + { + $this->ranges()->set((array) $ranges); + return $this; + } + + protected function getRanges() + { + return $this->ranges()->getValues(); + } + protected function normalizeBoolean($value) { if ($value === 'y' || $value === '1' || $value === true || $value === 1) { @@ -1526,10 +1537,18 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer } } + if ($this->supportsRanges()) { + // TODO: resolve + $props['ranges'] = $this->get('ranges'); + } + if ($skipDefaults) { - if (empty($props['imports'])) { - unset($props['imports']); + foreach (array('imports', 'ranges', 'arguments') as $key) { + if (empty($props[$key])) { + unset($props[$key]); + } } + if (array_key_exists('vars', $props)) { if (count((array) $props['vars']) === 0) { unset($props['vars']); @@ -1658,6 +1677,13 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer } } + if ($this->supportsRanges()) { + $ranges = $this->ranges()->getOriginalValues(); + if (!empty($ranges)) { + $props['ranges'] = $ranges; + } + } + foreach ($this->relatedSets() as $property => $set) { if ($set->isEmpty()) { continue;