IcingaConfig: improve prefix/intendation handling
This commit is contained in:
parent
055895a553
commit
f354d3c034
|
@ -65,9 +65,8 @@ class CustomVariables
|
|||
|
||||
foreach ($this->vars as $key => $var) {
|
||||
$out .= c::renderKeyValue(
|
||||
c::escapeIfReserved($key),
|
||||
$var->toConfigString(),
|
||||
' vars.'
|
||||
'vars.' . c::escapeIfReserved($key),
|
||||
$var->toConfigString()
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -35,14 +35,19 @@ class IcingaConfigHelper
|
|||
'in',
|
||||
);
|
||||
|
||||
public static function renderKeyValue($key, $value, $prefix = '')
|
||||
public static function renderKeyValue($key, $value, $prefix = ' ')
|
||||
{
|
||||
return sprintf(
|
||||
"%s%s = %s\n",
|
||||
$prefix,
|
||||
$string = sprintf(
|
||||
"%s = %s",
|
||||
$key,
|
||||
$value
|
||||
);
|
||||
|
||||
if ($prefix && strpos($string, "\n") !== false) {
|
||||
return $prefix . implode("\n" . $prefix, explode("\n", $string)) . "\n";
|
||||
}
|
||||
|
||||
return $prefix . $string . "\n";
|
||||
}
|
||||
|
||||
public static function renderBoolean($value)
|
||||
|
|
|
@ -21,6 +21,6 @@ class IcingaCommand extends IcingaObject
|
|||
protected function renderMethods_execute()
|
||||
{
|
||||
// Execute is a reserved word in SQL, column name was prefixed
|
||||
return c::renderKeyValue('execute', $this->methods_execute, ' ');
|
||||
return c::renderKeyValue('execute', $this->methods_execute);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,7 +98,7 @@ abstract class IcingaObject extends DbObject
|
|||
if (method_exists($this, $method)) {
|
||||
$out .= $this->$method($value);
|
||||
} else {
|
||||
$out .= c::renderKeyValue($key, c::renderString($value), ' ');
|
||||
$out .= c::renderKeyValue($key, c::renderString($value));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,7 @@ abstract class IcingaObject extends DbObject
|
|||
|
||||
protected function renderBooleanProperty($key)
|
||||
{
|
||||
return c::renderKeyValue($key, c::renderBoolean($this->$key), ' ');
|
||||
return c::renderKeyValue($key, c::renderBoolean($this->$key));
|
||||
}
|
||||
|
||||
protected function renderSuffix()
|
||||
|
@ -135,8 +135,7 @@ abstract class IcingaObject extends DbObject
|
|||
{
|
||||
return c::renderKeyValue(
|
||||
$propertyName,
|
||||
c::renderString($this->connection->getCommandName($commandId)),
|
||||
' '
|
||||
c::renderString($this->connection->getCommandName($commandId))
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -144,8 +143,7 @@ abstract class IcingaObject extends DbObject
|
|||
{
|
||||
return c::renderKeyValue(
|
||||
$propertyName,
|
||||
c::renderString($this->connection->getZoneName($zoneId)),
|
||||
' '
|
||||
c::renderString($this->connection->getZoneName($zoneId))
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue