mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-30 17:24:18 +02:00
IcingaVar: use new CustomVar helpers
This commit is contained in:
parent
87bd531f2a
commit
2ea573e338
@ -32,7 +32,7 @@ class IcingaVar extends DbObject
|
|||||||
*/
|
*/
|
||||||
public static function forCustomVar(CustomVariable $customVar, Db $db)
|
public static function forCustomVar(CustomVariable $customVar, Db $db)
|
||||||
{
|
{
|
||||||
$rendered = static::renderVar($customVar);
|
$rendered = $customVar->render();
|
||||||
|
|
||||||
$var = static::create(array(
|
$var = static::create(array(
|
||||||
'checksum' => $customVar->checksum(),
|
'checksum' => $customVar->checksum(),
|
||||||
@ -47,24 +47,6 @@ class IcingaVar extends DbObject
|
|||||||
return $var;
|
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 CustomVariable $var
|
||||||
* @param Db $db
|
* @param Db $db
|
||||||
|
Loading…
x
Reference in New Issue
Block a user