IcingaObject: allow to access relations by key

This commit is contained in:
Thomas Gelf 2015-12-17 20:32:15 +01:00
parent 6466e3392e
commit 313ac50f81
1 changed files with 13 additions and 0 deletions

View File

@ -133,6 +133,19 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
return parent::hasBeenModified();
}
public function get($key)
{
if ($this->hasRelation($key)) {
if ($id = $this->get($key . '_id')) {
$class = $this->getRelationClass($key);
$object = $class::loadWithAutoIncId($id, $this->connection);
return $object->object_name;
}
}
return parent::get($key);
}
public function set($key, $value)
{
if ($key === 'groups') {