IcingaService: override setKey, allows for...

...different kind of links (host/service name VS id)
This commit is contained in:
Thomas Gelf 2016-03-06 19:13:58 +01:00
parent e09459625d
commit 8cc7b0834e
1 changed files with 17 additions and 0 deletions

View File

@ -85,6 +85,23 @@ class IcingaService extends IcingaObject
);
}
protected function setKey($key)
{
if (is_int($key)) {
$this->id = $key;
} elseif (is_array($key)) {
foreach (array('id', 'host_id', 'object_name') as $k) {
if (array_key_exists($k, $key)) {
$this->set($k, $key[$k]);
}
}
} else {
return parent::setKey($key);
}
return $this;
}
/**
* Render host_id as host_name
*