mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-31 01:34:12 +02:00
CoreApi: implement getConstant(s)
This commit is contained in:
parent
ed3624239b
commit
c0c3d1b16d
@ -51,6 +51,39 @@ class CoreApi
|
||||
return $this->client->get($url, $params)->getResult('name');
|
||||
}
|
||||
|
||||
public function getConstants()
|
||||
{
|
||||
$constants = array();
|
||||
$command = 'var constants = [];
|
||||
for (k => v in globals) {
|
||||
if (typeof(v) in [String, Number, Boolean]) {
|
||||
res = { name = k, value = v }
|
||||
constants.add({name = k, value = v})
|
||||
}
|
||||
};
|
||||
constants
|
||||
';
|
||||
|
||||
foreach ($this->client->post(
|
||||
'console/execute-script',
|
||||
array('command' => $command)
|
||||
)->getSingleResult() as $row) {
|
||||
$constants[$row->name] = $row->value;
|
||||
}
|
||||
|
||||
return $constants;
|
||||
}
|
||||
|
||||
public function getConstant($name)
|
||||
{
|
||||
$constants = $this->getConstants();
|
||||
if (array_key_exists($name, $constants)) {
|
||||
return $constants[$name];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getTypes()
|
||||
{
|
||||
return $this->client->get('types')->getResult('name');
|
||||
@ -196,11 +229,6 @@ class CoreApi
|
||||
);
|
||||
}
|
||||
|
||||
public function getConstants()
|
||||
{
|
||||
// TODO: var results = []; for (k => v in globals) { if (typeof(v) in [String, Number, Boolean]) { results.add(k) } }; results
|
||||
}
|
||||
|
||||
public function hasModule($moduleName)
|
||||
{
|
||||
$modules = $this->getModules();
|
||||
|
Loading…
x
Reference in New Issue
Block a user