summaryrefslogtreecommitdiffstats
path: root/library/Director/Objects/IcingaTimePeriodRanges.php
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--library/Director/Objects/IcingaTimePeriodRanges.php35
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;
+ }
+}