IcingaVar: use new CustomVar helpers

This commit is contained in:
Thomas Gelf 2016-12-07 08:29:20 +01:00
parent 87bd531f2a
commit 2ea573e338

View File

@ -32,7 +32,7 @@ class IcingaVar extends DbObject
*/
public static function forCustomVar(CustomVariable $customVar, Db $db)
{
$rendered = static::renderVar($customVar);
$rendered = $customVar->render();
$var = static::create(array(
'checksum' => $customVar->checksum(),
@ -47,24 +47,6 @@ class IcingaVar extends DbObject
return $var;
}
protected static function renderVar(CustomVariable $var)
{
$renderExpressions = false; // TODO!
return c::renderKeyValue(
static::renderKeyName($var->getKey()),
$var->toConfigStringPrefetchable($renderExpressions)
);
}
protected static function renderKeyName($key)
{
if (preg_match('/^[a-z0-9_]+\d*$/i', $key)) {
return 'vars.' . c::escapeIfReserved($key);
} else {
return 'vars[' . c::renderString($key) . ']';
}
}
/**
* @param CustomVariable $var
* @param Db $db