IcingaObject: support merge for objects with no CV

This commit is contained in:
Thomas Gelf 2016-03-11 13:56:34 +01:00
parent b6dc8e5faf
commit 8b903486d3
1 changed files with 12 additions and 5 deletions

View File

@ -1301,12 +1301,19 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
public function merge(IcingaObject $object)
{
$object = clone($object);
$vars = $object->getVars();
$object->vars = array();
if ($object->supportsCustomVars()) {
$vars = $object->getVars();
$object->vars = array();
}
$this->setProperties((array) $object->toPlainObject(null, true));
$myVars = $this->vars();
foreach ($vars as $key => $var) {
$myVars->set($key, $var);
if ($object->supportsCustomVars()) {
$myVars = $this->vars();
foreach ($vars as $key => $var) {
$myVars->set($key, $var);
}
}
return $this;