diff --git a/library/Director/IcingaConfig/ExtensibleSet.php b/library/Director/IcingaConfig/ExtensibleSet.php index 3570d8c2..d073501f 100644 --- a/library/Director/IcingaConfig/ExtensibleSet.php +++ b/library/Director/IcingaConfig/ExtensibleSet.php @@ -113,6 +113,35 @@ class ExtensibleSet return $plain; } + public function getPlainUnmodifiedObject() + { + if ($this->fromDb === null) { + return null; + } + + $old = $this->fromDb; + + if ($old['override'] !== null) { + if (empty($old['blacklist']) && empty($old['extend'])) { + return $old['override']; + } + } + + $plain = (object) array(); + + if ($old['override'] !== null) { + $plain->override = $old['override']; + } + if (! empty($old['extend'])) { + $plain->extend = $old['extend']; + } + if (! empty($old['blacklist'])) { + $plain->blacklist = $old['blacklist']; + } + + return $plain; + } + public function hasBeenLoadedFromDb() { return $this->fromDb !== null; diff --git a/library/Director/Objects/IcingaObject.php b/library/Director/Objects/IcingaObject.php index 39775c5a..a1657b79 100644 --- a/library/Director/Objects/IcingaObject.php +++ b/library/Director/Objects/IcingaObject.php @@ -1290,6 +1290,13 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer foreach ($this->relatedSets() as $property => $set) { if ($resolved) { + if ($this->supportsImports()) { + $set = clone($set); + foreach ($this->importedObjects() as $parent) { + $set->inheritFrom($parent->getRelatedSet($property)); + } + } + $values = $set->getResolvedValues(); if (empty($values)) { if (!$skipDefaults) { @@ -1377,6 +1384,11 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer } } + foreach ($this->relatedSets() as $property => $set) { + if ($set->isEmpty()) { continue; } + $props[$property] = $set->getPlainUnmodifiedObject(); + } + return $props; }