diff --git a/library/Director/CustomVariable/CustomVariableArray.php b/library/Director/CustomVariable/CustomVariableArray.php index 4d6fbc9f..bf8a8493 100644 --- a/library/Director/CustomVariable/CustomVariableArray.php +++ b/library/Director/CustomVariable/CustomVariableArray.php @@ -37,13 +37,6 @@ class CustomVariableArray extends CustomVariable public function toConfigString() { - $str = '[ ' . implode(', ', $this->value) . ' ]'; - - if (strlen($str) < 60) { - return $str; - } - - // Prefix for toConfigString? - return "[\n " . implode(",\n ", $this->value) . "\n]"; + return c::renderArray($this->value); } } diff --git a/library/Director/IcingaConfig/IcingaConfigHelper.php b/library/Director/IcingaConfig/IcingaConfigHelper.php index 4ad9d057..92002968 100644 --- a/library/Director/IcingaConfig/IcingaConfigHelper.php +++ b/library/Director/IcingaConfig/IcingaConfigHelper.php @@ -92,6 +92,20 @@ class IcingaConfigHelper return '"' . $string . '"'; } + // Requires an array of CustomVariable objects + public static function renderArray($array) + { + $str = '[ ' . implode(', ', $array) . ' ]'; + + if (strlen($str) < 60) { + return $str; + } + + // Prefix for toConfigString? + return "[\n " . implode(",\n ", $array) . "\n]"; + + } + public static function isReserved($string) { return in_array($string, self::$reservedWords);