IcingaObject: add new helper methods for seconds

This commit is contained in:
Thomas Gelf 2015-12-03 18:00:48 +01:00
parent d516a050ac
commit d8d12d38b4
3 changed files with 13 additions and 6 deletions

View File

@ -74,11 +74,7 @@ class IcingaCommand extends IcingaObject
protected function renderTimeout()
{
$value = $this->timeout;
if ($value % 60 === 0) {
$value = ((int) $value / 60) . 'm';
}
return c::renderKeyValue('timeout', $value);
return $this->renderPropertyAsSecond('timeout');
}
public static function setPluginDir($pluginDir)

View File

@ -24,6 +24,6 @@ class IcingaEndpoint extends IcingaObject
protected function renderLog_duration()
{
return c::renderKeyValue('log_duration', $this->log_duration);
return $this->renderPropertyAsSecond('log_duration');
}
}

View File

@ -705,6 +705,17 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
return c::renderKeyValue($key, c::renderBoolean($this->$key));
}
protected function renderPropertyAsSeconds($key)
{
$value = $this->$key;
if ($value % 60 === 0) {
$value = ((int) $value / 60) . 'm';
}
return c::renderKeyValue($key, $value);
}
protected function renderSuffix()
{
return "}\n\n";