IcingaObject: add merge method, use in Sync
This commit is contained in:
parent
f0d02edbe6
commit
1261bd93e1
|
@ -600,7 +600,7 @@ class Sync
|
|||
case 'merge':
|
||||
// TODO: re-evaluate merge settings. vars.x instead of
|
||||
// just "vars" might suffice.
|
||||
$this->objects[$key]->setProperties($object);
|
||||
$this->objects[$key]->merge($object);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -1114,6 +1114,21 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
|
|||
return $this;
|
||||
}
|
||||
|
||||
// TODO: with rules? What if I want to override vars? Drop in favour of vars.x?
|
||||
public function merge(IcingaObject $object)
|
||||
{
|
||||
$object = clone($object);
|
||||
$vars = $object->getVars();
|
||||
$object->vars = array();
|
||||
$this->setProperties((array) $object->toPlainObject());
|
||||
$myVars = $this->vars();
|
||||
foreach ($vars as $key => $var) {
|
||||
$myVars->set($key, $var);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function toPlainObject(
|
||||
$resolved = false,
|
||||
$skipDefaults = false,
|
||||
|
|
Loading…
Reference in New Issue