IcingaObjectGroups: history-related modifications

This commit is contained in:
Thomas Gelf 2015-08-28 17:12:46 +02:00
parent 3811c1612b
commit 9f7e97d80a
1 changed files with 15 additions and 2 deletions

View File

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