IcingaObject: more choices for toPlainObject

This commit is contained in:
Thomas Gelf 2015-12-10 18:41:09 +01:00
parent 75bbf9c7da
commit 7f558d1523
1 changed files with 12 additions and 3 deletions

View File

@ -978,8 +978,11 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
return $this;
}
public function toPlainObject($resolved = false)
{
public function toPlainObject(
$resolved = false,
$skipNull = false,
array $chosenProperties = null
) {
$props = array();
if ($resolved) {
@ -1007,8 +1010,14 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
}
}
if ($chosenProperties !== null) {
if (! in_array($v, $chosenProperties)) {
continue;
}
}
// TODO: Do not ship null properties based on flag?
if (true || $v !== null) {
if (!$skipNull || $v !== null) {
$props[$k] = $v;
}
}