From b21ba5dc543f51e7e03e72a6294c72b884ac3a3b Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Fri, 18 Aug 2017 16:42:56 +0200 Subject: [PATCH] IcingaHost: add helper methods for Sets, Services --- library/Director/Objects/IcingaHost.php | 36 +++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/library/Director/Objects/IcingaHost.php b/library/Director/Objects/IcingaHost.php index 8a617aee..c884f2b1 100644 --- a/library/Director/Objects/IcingaHost.php +++ b/library/Director/Objects/IcingaHost.php @@ -421,6 +421,42 @@ class IcingaHost extends IcingaObject return $str; } + /** + * @return IcingaService[] + */ + public function fetchServices() + { + $connection = $this->getConnection(); + $db = $connection->getDbAdapter(); + + /** @var IcingaService[] $services */ + $services = IcingaService::loadAll( + $connection, + $db->select()->from('icinga_service') + ->where('host_id = ?', $this->get('id')) + ); + + return $services; + } + + /** + * @return IcingaServiceSet[] + */ + public function fetchServiceSets() + { + $connection = $this->getConnection(); + $db = $connection->getDbAdapter(); + + /** @var IcingaServiceSet[] $sets */ + $sets = IcingaServiceSet::loadAll( + $connection, + $db->select()->from('icinga_service_set') + ->where('host_id = ?', $this->get('id')) + ); + + return $sets; + } + /** * @return string */