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