IcingaObject: allow to unset relations

This commit is contained in:
Thomas Gelf 2015-12-03 15:09:49 +01:00
parent 7cdb44b1f9
commit 389fcf2fa6
1 changed files with 4 additions and 0 deletions

View File

@ -166,6 +166,10 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
}
if ($this->hasRelation($key)) {
if (! $value) {
return parent::set($key . '_id', null);
}
$class = $this->getRelationClass($key);
$object = $class::load($value, $this->connection);
if (in_array($object->object_type, array('object', 'external_object'))) {