mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-30 01:04:12 +02:00
IcingaObject: skipDefaults instead of skipNull
This commit is contained in:
parent
7665cb2424
commit
1f71def70c
@ -1056,7 +1056,7 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
|
|||||||
|
|
||||||
public function toPlainObject(
|
public function toPlainObject(
|
||||||
$resolved = false,
|
$resolved = false,
|
||||||
$skipNull = false,
|
$skipDefaults = false,
|
||||||
array $chosenProperties = null
|
array $chosenProperties = null
|
||||||
) {
|
) {
|
||||||
$props = array();
|
$props = array();
|
||||||
@ -1093,7 +1093,7 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Do not ship null properties based on flag?
|
// TODO: Do not ship null properties based on flag?
|
||||||
if (!$skipNull || $v !== null) {
|
if (!$skipDefaults || $this->differsFromDefaultValue($k, $v)) {
|
||||||
$props[$k] = $v;
|
$props[$k] = $v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1118,9 +1118,11 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($skipNull) {
|
if ($skipDefaults) {
|
||||||
if (empty($props['imports'])) unset($props['imports']);
|
if (empty($props['imports'])) unset($props['imports']);
|
||||||
if (count((array) $props['vars']) === 0) unset($props['vars']);
|
if (array_key_exists('vars', $props)) {
|
||||||
|
if (count((array) $props['vars']) === 0) unset($props['vars']);
|
||||||
|
}
|
||||||
if (empty($props['groups'])) unset($props['groups']);
|
if (empty($props['groups'])) unset($props['groups']);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1140,10 +1142,11 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
|
|||||||
|
|
||||||
public function toJson(
|
public function toJson(
|
||||||
$resolved = false,
|
$resolved = false,
|
||||||
$skipNull = false,
|
$skipDefaults = false,
|
||||||
array $chosenProperties = null
|
array $chosenProperties = null
|
||||||
) {
|
) {
|
||||||
return json_encode($this->toPlainObject($resolved, $skipNull, $chosenProperties));
|
|
||||||
|
return json_encode($this->toPlainObject($resolved, $skipDefaults, $chosenProperties));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __toString()
|
public function __toString()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user