IcingaTimeperiodRanges(Legacy): Implement toLegacyConfigString
refs #12919
This commit is contained in:
parent
ab7d0fb085
commit
f2ff967b07
|
@ -1912,6 +1912,17 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function renderLegacyRanges()
|
||||
{
|
||||
if ($this->supportsRanges()) {
|
||||
return $this->ranges()->toLegacyConfigString();
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
|
@ -2030,7 +2041,7 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
|
|||
$this->renderLegacyObjectHeader(),
|
||||
$this->renderLegacyImports(),
|
||||
$this->renderLegacyProperties(),
|
||||
//$this->renderRanges(),
|
||||
$this->renderLegacyRanges(),
|
||||
//$this->renderArguments(),
|
||||
//$this->renderRelatedSets(),
|
||||
$this->renderLegacyGroups(),
|
||||
|
|
|
@ -7,6 +7,7 @@ use Iterator;
|
|||
use Countable;
|
||||
use Icinga\Module\Director\IcingaConfig\IcingaConfigRenderer;
|
||||
use Icinga\Module\Director\IcingaConfig\IcingaConfigHelper as c;
|
||||
use Icinga\Module\Director\IcingaConfig\IcingaLegacyConfigHelper as c1;
|
||||
|
||||
class IcingaTimePeriodRanges implements Iterator, Countable, IcingaConfigRenderer
|
||||
{
|
||||
|
@ -286,4 +287,25 @@ class IcingaTimePeriodRanges implements Iterator, Countable, IcingaConfigRendere
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function toLegacyConfigString()
|
||||
{
|
||||
if (empty($this->ranges) && $this->object->object_type === 'template') {
|
||||
return '';
|
||||
}
|
||||
|
||||
$out = '';
|
||||
|
||||
foreach ($this->ranges as $range) {
|
||||
$out .= c1::renderKeyValue(
|
||||
$range->range_key,
|
||||
$range->range_value
|
||||
);
|
||||
}
|
||||
if ($out !== '') {
|
||||
$out = "\n".$out;
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue