From d23149bf3e62bfe40107e14ed8b42975f4ce4fd8 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Fri, 6 Nov 2015 09:49:05 +0100 Subject: [PATCH] IcingaObject: prepare command object access --- library/Director/Objects/IcingaHost.php | 14 ++++++++++++++ library/Director/Objects/IcingaObject.php | 15 +++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/library/Director/Objects/IcingaHost.php b/library/Director/Objects/IcingaHost.php index 5ef365af..3a175e59 100644 --- a/library/Director/Objects/IcingaHost.php +++ b/library/Director/Objects/IcingaHost.php @@ -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); diff --git a/library/Director/Objects/IcingaObject.php b/library/Director/Objects/IcingaObject.php index 3c25e095..f8d625d0 100644 --- a/library/Director/Objects/IcingaObject.php +++ b/library/Director/Objects/IcingaObject.php @@ -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) {