Added notifiers for ServiceGroupMembershipResolver to IcingaService & IcingaServiceGroup, created ServiceGroupMembershipResolver

This commit is contained in:
Gregory Hargreaves 2018-10-20 14:43:24 +01:00 committed by Thomas Gelf
parent c7eb34af97
commit 2efd90302c
3 changed files with 66 additions and 0 deletions

View File

@ -117,6 +117,9 @@ class IcingaService extends IcingaObject implements ExportInterface
'apply_for'
];
/** @var ServiceGroupMembershipResolver */
protected $servicegroupMembershipResolver;
/**
* @return IcingaCommand
* @throws IcingaException
@ -730,4 +733,30 @@ class IcingaService extends IcingaObject implements ExportInterface
);
}
}
protected function notifyResolvers()
{
$resolver = $this->getServiceGroupMembershipResolver();
$resolver->addObject($this);
$resolver->refreshDb();
return $this;
}
protected function getServiceGroupMembershipResolver()
{
if ($this->servicegroupMembershipResolver === null) {
$this->servicegroupMembershipResolver = new ServiceGroupMembershipResolver(
$this->getConnection()
);
}
return $this->servicegroupMembershipResolver;
}
public function setServiceGroupMembershipResolver(ServiceGroupMembershipResolver $resolver)
{
$this->servicegroupMembershipResolver = $resolver;
return $this;
}
}

View File

@ -6,8 +6,37 @@ class IcingaServiceGroup extends IcingaObjectGroup
{
protected $table = 'icinga_servicegroup';
/** @var ServiceGroupMembershipResolver */
protected $servicegroupMembershipResolver;
public function supportsAssignments()
{
return true;
}
protected function getServiceGroupMembershipResolver()
{
if ($this->servicegroupMembershipResolver === null) {
$this->servicegroupMembershipResolver = new ServiceGroupMembershipResolver(
$this->getConnection()
);
}
return $this->servicegroupMembershipResolver;
}
public function setServiceGroupMembershipResolver(ServiceGroupMembershipResolver $resolver)
{
$this->servicegroupMembershipResolver = $resolver;
return $this;
}
protected function notifyResolvers()
{
$resolver = $this->getServiceGroupMembershipResolver();
$resolver->addGroup($this);
$resolver->refreshDb();
return $this;
}
}

View File

@ -0,0 +1,8 @@
<?php
namespace Icinga\Module\Director\Objects;
class ServiceGroupMembershipResolver extends GroupMembershipResolver
{
protected $type = 'service';
}