diff --git a/library/Director/Objects/IcingaObjectGroups.php b/library/Director/Objects/IcingaObjectGroups.php index 18095f8d..6a6b4cf3 100644 --- a/library/Director/Objects/IcingaObjectGroups.php +++ b/library/Director/Objects/IcingaObjectGroups.php @@ -180,6 +180,11 @@ class IcingaObjectGroups implements Iterator, Countable, IcingaConfigRenderer return array_keys($this->groups); } + public function listOriginalGroupNames() + { + return array_keys($this->storedGroups); + } + public function getType() { return $this->object->getShortTableName(); @@ -209,7 +214,7 @@ class IcingaObjectGroups implements Iterator, Countable, IcingaConfigRenderer $class = $this->getGroupClass(); $this->groups = $class::loadAll($connection, $query, 'object_name'); - $this->storedGroups = $this->groups; + $this->cloneStored(); return $this; } @@ -249,11 +254,19 @@ class IcingaObjectGroups implements Iterator, Countable, IcingaConfigRenderer ) ); } - $this->storedGroups = $this->groups; + $this->cloneStored(); return true; } + protected function cloneStored() + { + $this->storedGroups = array(); + foreach ($this->groups as $k => $v) { + $this->storedGroups[$k] = clone($v); + } + } + protected function getGroupClass() { return __NAMESPACE__ . '\\Icinga' .ucfirst($this->object->getShortTableName()) . 'Group';