2015-07-01 15:15:49 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Icinga\Module\Director\Objects;
|
|
|
|
|
|
|
|
use Countable;
|
2021-12-14 08:33:50 +01:00
|
|
|
use Iterator;
|
2015-07-01 15:15:49 +02:00
|
|
|
use Icinga\Module\Director\IcingaConfig\IcingaConfigRenderer;
|
2016-10-14 13:03:54 +02:00
|
|
|
use Icinga\Module\Director\IcingaConfig\IcingaLegacyConfigHelper as c1;
|
2015-07-01 15:15:49 +02:00
|
|
|
|
2021-12-14 08:33:50 +01:00
|
|
|
class IcingaTimePeriodRanges extends IcingaRanges implements Iterator, Countable, IcingaConfigRenderer
|
2015-07-01 15:15:49 +02:00
|
|
|
{
|
2021-12-14 08:33:50 +01:00
|
|
|
protected $rangeClass = IcingaTimePeriodRange::class;
|
|
|
|
protected $objectIdColumn = 'timeperiod_id';
|
2016-10-14 13:03:54 +02:00
|
|
|
|
|
|
|
public function toLegacyConfigString()
|
|
|
|
{
|
2021-12-14 08:33:50 +01:00
|
|
|
if (empty($this->ranges) && $this->object->isTemplate()) {
|
2016-10-14 13:03:54 +02:00
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
|
|
|
$out = '';
|
|
|
|
|
|
|
|
foreach ($this->ranges as $range) {
|
|
|
|
$out .= c1::renderKeyValue(
|
2021-12-14 08:33:50 +01:00
|
|
|
$range->get('range_key'),
|
|
|
|
$range->get('range_value')
|
2016-10-14 13:03:54 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
if ($out !== '') {
|
|
|
|
$out = "\n".$out;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $out;
|
|
|
|
}
|
2015-07-01 15:15:49 +02:00
|
|
|
}
|