diff --git a/library/Director/Objects/IcingaService.php b/library/Director/Objects/IcingaService.php index e97a709f..78cde10c 100644 --- a/library/Director/Objects/IcingaService.php +++ b/library/Director/Objects/IcingaService.php @@ -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; + } } diff --git a/library/Director/Objects/IcingaServiceGroup.php b/library/Director/Objects/IcingaServiceGroup.php index 937e5b5e..ae43ff32 100644 --- a/library/Director/Objects/IcingaServiceGroup.php +++ b/library/Director/Objects/IcingaServiceGroup.php @@ -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; + } } diff --git a/library/Director/Objects/ServiceGroupMembershipResolver.php b/library/Director/Objects/ServiceGroupMembershipResolver.php new file mode 100644 index 00000000..4649212d --- /dev/null +++ b/library/Director/Objects/ServiceGroupMembershipResolver.php @@ -0,0 +1,8 @@ +