diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 13:17:31 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 13:17:31 +0000 |
commit | f66ab8dae2f3d0418759f81a3a64dc9517a62449 (patch) | |
tree | fbff2135e7013f196b891bbde54618eb050e4aaf /library/Director/Objects/IcingaTimePeriodRanges.php | |
parent | Initial commit. (diff) | |
download | icingaweb2-module-director-upstream/1.10.2.tar.xz icingaweb2-module-director-upstream/1.10.2.zip |
Adding upstream version 1.10.2.upstream/1.10.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'library/Director/Objects/IcingaTimePeriodRanges.php')
-rw-r--r-- | library/Director/Objects/IcingaTimePeriodRanges.php | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/library/Director/Objects/IcingaTimePeriodRanges.php b/library/Director/Objects/IcingaTimePeriodRanges.php new file mode 100644 index 0000000..b18437d --- /dev/null +++ b/library/Director/Objects/IcingaTimePeriodRanges.php @@ -0,0 +1,35 @@ +<?php + +namespace Icinga\Module\Director\Objects; + +use Countable; +use Iterator; +use Icinga\Module\Director\IcingaConfig\IcingaConfigRenderer; +use Icinga\Module\Director\IcingaConfig\IcingaLegacyConfigHelper as c1; + +class IcingaTimePeriodRanges extends IcingaRanges implements Iterator, Countable, IcingaConfigRenderer +{ + protected $rangeClass = IcingaTimePeriodRange::class; + protected $objectIdColumn = 'timeperiod_id'; + + public function toLegacyConfigString() + { + if (empty($this->ranges) && $this->object->isTemplate()) { + return ''; + } + + $out = ''; + + foreach ($this->ranges as $range) { + $out .= c1::renderKeyValue( + $range->get('range_key'), + $range->get('range_value') + ); + } + if ($out !== '') { + $out = "\n".$out; + } + + return $out; + } +} |