IcingaObject: generic loadAll support...

...also for multi-key objects
This commit is contained in:
Thomas Gelf 2016-02-24 15:18:30 +01:00
parent f2f6bdfadf
commit 4292f31f4f
1 changed files with 6 additions and 2 deletions

View File

@ -1033,9 +1033,13 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
public static function loadAllByType($type, Db $db, $query = null, $keyColumn = 'object_name')
{
if ($type === 'datalistEntry') $keyColumn = 'entry_name';
$class = self::classByType($type);
return $class::loadAll($db, $query, $keyColumn);
if (is_array($class::create()->getKeyName())) {
return $class::loadAll($db, $query);
} else {
return $class::loadAll($db, $query, $keyColumn);
}
}
public static function fromJson($json, Db $connection = null)