IcingaConfigHelper: add reserved words
This commit is contained in:
parent
9e52629d6e
commit
38221e0605
|
@ -4,6 +4,37 @@ namespace Icinga\Module\Director;
|
|||
|
||||
class IcingaConfigHelper
|
||||
{
|
||||
/**
|
||||
* Reserved words according to
|
||||
* http://docs.icinga.org/icinga2/snapshot/doc/module/icinga2/chapter/language-reference#reserved-keywords
|
||||
*/
|
||||
protected static $reservedWords = array(
|
||||
'object',
|
||||
'template',
|
||||
'include',
|
||||
'include_recursive',
|
||||
'library',
|
||||
'null',
|
||||
'true',
|
||||
'false',
|
||||
'const',
|
||||
'var',
|
||||
'this',
|
||||
'use',
|
||||
'apply',
|
||||
'to',
|
||||
'where',
|
||||
'import',
|
||||
'assign',
|
||||
'ignore',
|
||||
'function',
|
||||
'return',
|
||||
'for',
|
||||
'if',
|
||||
'else',
|
||||
'in',
|
||||
);
|
||||
|
||||
public static function renderKeyValue($key, $value, $prefix = '')
|
||||
{
|
||||
return sprintf(
|
||||
|
@ -32,4 +63,18 @@ class IcingaConfigHelper
|
|||
|
||||
return sprintf('"%s"', $string);
|
||||
}
|
||||
|
||||
public static function isReserved($string)
|
||||
{
|
||||
return in_array($string, self::$reservedWords);
|
||||
}
|
||||
|
||||
public static function escapeIfReserved($string)
|
||||
{
|
||||
if (self::isReserved($string)) {
|
||||
return '@' . $string;
|
||||
} else {
|
||||
return $string;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -91,9 +91,6 @@ abstract class IcingaObject extends DbObject
|
|||
}
|
||||
|
||||
/**
|
||||
* TODO: take care for reserved words, because we need them escaped
|
||||
* http://docs.icinga.org/icinga2/snapshot/doc/module/icinga2/chapter/language-reference#reserved-keywords
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function renderCustomVars()
|
||||
|
|
Loading…
Reference in New Issue