mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-29 16:54:06 +02:00
IcingaObject: first simple toJson support
This commit is contained in:
parent
a2d1594eaf
commit
d5c20e6e53
@ -811,6 +811,33 @@ return '';
|
|||||||
return $class::loadAll($db, $query, $keyColumn);
|
return $class::loadAll($db, $query, $keyColumn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function toJson($resolved = false)
|
||||||
|
{
|
||||||
|
$props = array();
|
||||||
|
foreach ($this->getProperties() as $k => $v) {
|
||||||
|
if ($v !== null) {
|
||||||
|
$props[$k] = $v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->supportsGroups()) {
|
||||||
|
// TODO: resolve
|
||||||
|
$props['groups'] = $this->groups()->listGroupNames();
|
||||||
|
}
|
||||||
|
if ($this->supportsCustomVars()) {
|
||||||
|
if ($resolved) {
|
||||||
|
$props['vars'] = $this->getVars();
|
||||||
|
} else {
|
||||||
|
$props['vars'] = $this->getResolvedVars();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($this->supportsImports()) {
|
||||||
|
$props['imports'] = $this->imports()->listImportNames();
|
||||||
|
}
|
||||||
|
|
||||||
|
return json_encode($props);
|
||||||
|
}
|
||||||
|
|
||||||
public function __toString()
|
public function __toString()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user