Merge pull request #1786 from Icinga/feature/delete-service-set-children

IcingaServiceSet: Delete host sets when deleting a set
This commit is contained in:
Markus Frosch 2019-03-26 12:56:31 +01:00 committed by GitHub
commit 0d3649ce3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 0 deletions

View File

@ -234,6 +234,19 @@ class IcingaServiceSet extends IcingaObject implements ExportInterface
return $object;
}
public function beforeDelete()
{
// check if this is a template, or directly assigned to a host
if ($this->get('host_id') === null) {
// find all host sets and delete them
foreach ($this->fetchHostSets() as $set) {
$set->delete();
}
}
parent::beforeDelete();
}
/**
* @throws \Icinga\Exception\NotFoundError
*/