IcingaTimeperiodRanges(Legacy): Implement toLegacyConfigString

refs #12919
This commit is contained in:
Markus Frosch 2016-10-14 13:03:54 +02:00
parent ab7d0fb085
commit f2ff967b07
2 changed files with 34 additions and 1 deletions

View File

@ -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(),

View File

@ -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;
}
}