IcingaObject: new static loadByType() method

This commit is contained in:
Thomas Gelf 2015-08-02 13:43:16 +02:00
parent bf596d98ee
commit ab2e55321d
1 changed files with 8 additions and 0 deletions

View File

@ -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 {