IcingaObject: prepare command object access

This commit is contained in:
Thomas Gelf 2015-11-06 09:49:05 +01:00
parent 4f64d79e15
commit d23149bf3e
2 changed files with 29 additions and 0 deletions

View File

@ -66,6 +66,20 @@ class IcingaHost extends IcingaObject
return $properties;
}
public function getCheckCommand()
{
$id = $this->getResolvedProperty('check_command_id');
return IcingaCommand::loadWithAutoIncId(
$id,
$this->getConnection()
);
}
public function hasCheckCommand()
{
return $this->getResolvedProperty('check_command_id') !== null;
}
protected function renderCheck_command_id()
{
return $this->renderCommandProperty($this->check_command_id);

View File

@ -199,6 +199,16 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
return $this;
}
public function getResolvedProperty($key)
{
$properties = $this->getResolvedProperties();
if (property_exists($properties, $key)) {
return $properties->$key;
}
return null;
}
public function getResolvedProperties()
{
return $this->getResolved('Properties');
@ -685,6 +695,11 @@ return '';
return substr($this->getType(), -5) === 'Group';
}
public function hasCheckCommand()
{
return false;
}
protected function getType()
{
if ($this->type === null) {