mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-09-26 03:09:11 +02:00
IcingaObject: add merge method, use in Sync
This commit is contained in:
parent
f0d02edbe6
commit
1261bd93e1
@ -600,7 +600,7 @@ class Sync
|
|||||||
case 'merge':
|
case 'merge':
|
||||||
// TODO: re-evaluate merge settings. vars.x instead of
|
// TODO: re-evaluate merge settings. vars.x instead of
|
||||||
// just "vars" might suffice.
|
// just "vars" might suffice.
|
||||||
$this->objects[$key]->setProperties($object);
|
$this->objects[$key]->merge($object);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -1114,6 +1114,21 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
|
|||||||
return $this;
|
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(
|
public function toPlainObject(
|
||||||
$resolved = false,
|
$resolved = false,
|
||||||
$skipDefaults = false,
|
$skipDefaults = false,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user