mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-09-25 10:57:41 +02:00
Icinga(Commmand)Arguments: small improvements
This commit is contained in:
parent
6ba5e44071
commit
a0b5e79115
@ -100,26 +100,41 @@ class IcingaArguments implements Iterator, Countable, IcingaConfigRenderer
|
|||||||
$attrs[$dbKey] = $value->$apiKey;
|
$attrs[$dbKey] = $value->$apiKey;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (property_exists($value, 'value')) {
|
|
||||||
$argValue = $value->value;
|
|
||||||
}
|
|
||||||
if (property_exists($value, 'type')) {
|
if (property_exists($value, 'type')) {
|
||||||
if ($value->type === 'Function') {
|
if ($value->type === 'Function') {
|
||||||
$attrs['argument_value'] = '/* Unable to fetch function body through API */';
|
$attrs['argument_value'] = '/* Unable to fetch function body through API */';
|
||||||
$attrs['argument_format'] = 'expression';
|
$attrs['argument_format'] = 'expression';
|
||||||
}
|
}
|
||||||
|
} elseif (property_exists($value, 'value')) {
|
||||||
|
if (is_object($value->value)) {
|
||||||
|
if ($value->value->type === 'Function') {
|
||||||
|
$attrs['argument_value'] = '/* Unable to fetch function body through API */';
|
||||||
|
$attrs['argument_format'] = 'expression';
|
||||||
|
} else {
|
||||||
|
var_dump($value);
|
||||||
|
die('Unable to resolve command argument');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$argValue = $value;
|
$argValue = $value->value;
|
||||||
}
|
|
||||||
|
|
||||||
if (is_string($argValue)) {
|
if (is_string($argValue)) {
|
||||||
$attrs['argument_value'] = $argValue;
|
$attrs['argument_value'] = $argValue;
|
||||||
$attrs['argument_format'] = 'string';
|
$attrs['argument_format'] = 'string';
|
||||||
} elseif ($argValue !== null) {
|
} else {
|
||||||
$attrs['argument_value'] = $argValue;
|
$attrs['argument_value'] = json_encode($argValue);
|
||||||
$attrs['argument_format'] = 'json';
|
$attrs['argument_format'] = 'json';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (is_string($value)) {
|
||||||
|
$attrs['argument_value'] = $value;
|
||||||
|
$attrs['argument_format'] = 'string';
|
||||||
|
} else {
|
||||||
|
$attrs['argument_value'] = json_encode($value);
|
||||||
|
$attrs['argument_format'] = 'json';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$this->add(IcingaCommandArgument::create($attrs));
|
$this->add(IcingaCommandArgument::create($attrs));
|
||||||
|
|
||||||
|
@ -58,8 +58,13 @@ class IcingaCommandArgument extends IcingaObject
|
|||||||
$data['value'] = c::renderDictionary($this->argument_value);
|
$data['value'] = c::renderDictionary($this->argument_value);
|
||||||
} elseif (is_array($this->argument_value)) {
|
} elseif (is_array($this->argument_value)) {
|
||||||
$data['value'] = c::renderArray($this->argument_value);
|
$data['value'] = c::renderArray($this->argument_value);
|
||||||
|
} elseif (is_null($this->argument_value)) {
|
||||||
|
// TODO: recheck all this. I bet we never reach this:
|
||||||
|
$data['value'] = 'null';
|
||||||
|
} elseif (is_bool($this->argument_value)) {
|
||||||
|
$data['value'] = c::renderBoolean($this->argument_value);
|
||||||
} else {
|
} else {
|
||||||
die('Unhandled');
|
$data['value'] = $this->argument_value;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'expression':
|
case 'expression':
|
||||||
|
Loading…
x
Reference in New Issue
Block a user