IcingaServiceSet: simplify code
This commit is contained in:
parent
5de24c6ec4
commit
f09560a89e
|
@ -50,29 +50,21 @@ class IcingaServiceSet extends IcingaObject
|
||||||
*/
|
*/
|
||||||
public function getServiceObjects()
|
public function getServiceObjects()
|
||||||
{
|
{
|
||||||
if (! $this->hasBeenLoadedFromDb()) {
|
if ($this->host_id) {
|
||||||
return array();
|
$imports = $this->imports;
|
||||||
|
if (empty($imports)) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
$base = IcingaServiceSet::load(array(
|
||||||
|
'object_name' => array_shift($imports),
|
||||||
|
'object_type' => 'template'
|
||||||
|
), $this->getConnection());
|
||||||
|
} else {
|
||||||
|
$base = $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
$conn = $this->getConnection();
|
return $base->getMultiRelation('service')->getObjects();
|
||||||
$db = $conn->getDbAdapter();
|
|
||||||
|
|
||||||
$query = $db->select()->from(
|
|
||||||
array('s' => 'icinga_service'),
|
|
||||||
'*'
|
|
||||||
)->join(
|
|
||||||
array('sset' => 'icinga_service_set_service'),
|
|
||||||
'sset.service_id = s.id',
|
|
||||||
array()
|
|
||||||
)->where(
|
|
||||||
$db->quoteInto(
|
|
||||||
'sset.service_set_id = ?',
|
|
||||||
(int) $this->id
|
|
||||||
)
|
|
||||||
)->order('s.object_name');
|
|
||||||
|
|
||||||
// TODO: This cannot be prefetched
|
|
||||||
return IcingaService::loadAll($conn, $query, 'object_name');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function renderToConfig(IcingaConfig $config)
|
public function renderToConfig(IcingaConfig $config)
|
||||||
|
|
Loading…
Reference in New Issue