mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-28 16:24:05 +02:00
IcingaObject: allow to prefetch related object...
...types
This commit is contained in:
parent
875627ead7
commit
18c0ce3c4f
@ -318,6 +318,25 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
|
||||
return null;
|
||||
}
|
||||
|
||||
public function prefetchAllRelatedTypes()
|
||||
{
|
||||
foreach (array_unique(array_values($this->relations)) as $relClass) {
|
||||
/** @var static $class */
|
||||
$class = __NAMESPACE__ . '\\' . $relClass;
|
||||
$class::prefetchAll($this->getConnection());
|
||||
}
|
||||
}
|
||||
|
||||
public static function prefetchAllRelationsByType($type, Db $db)
|
||||
{
|
||||
/** @var static $class */
|
||||
$class = self::classByType($type);
|
||||
/** @var static $dummy */
|
||||
$dummy = $class::create(array(), $db);
|
||||
$dummy->prefetchAllRelatedTypes();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Whether this Object supports custom variables
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user