From ab2e55321d2ab536bccfaac8c3d66fde4020c265 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Sun, 2 Aug 2015 13:43:16 +0200 Subject: [PATCH] IcingaObject: new static loadByType() method --- library/Director/Objects/IcingaObject.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/library/Director/Objects/IcingaObject.php b/library/Director/Objects/IcingaObject.php index 40f2047e..8b761114 100644 --- a/library/Director/Objects/IcingaObject.php +++ b/library/Director/Objects/IcingaObject.php @@ -4,6 +4,7 @@ namespace Icinga\Module\Director\Objects; use Icinga\Module\Director\CustomVariable\CustomVariables; use Icinga\Module\Director\Data\Db\DbObject; +use Icinga\Module\Director\Db; use Icinga\Module\Director\IcingaConfig\IcingaConfigRenderer; use Icinga\Module\Director\IcingaConfig\IcingaConfigHelper as c; use Icinga\Exception\ProgrammingError; @@ -616,6 +617,13 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer } } + public static function loadByType($type, $id, Db $connection) + { + $class = 'Icinga\\Module\\Director\\Objects\\Icinga' . ucfirst($type); + + return $class::load($id, $connection); + } + public function __toString() { try {