IcingaObject: add new helper methods for seconds
This commit is contained in:
parent
d516a050ac
commit
d8d12d38b4
|
@ -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)
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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";
|
||||
|
|
Loading…
Reference in New Issue