Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions og.module
Original file line number Diff line number Diff line change
Expand Up @@ -531,8 +531,20 @@ function __og_update_entity_fields($entity_type, $entity) {

/**
* Implements hook_entity_delete().
* remove memberships of deleted group entities
*/
function _og_entity_delete($entity, $entity_type) {
if (Og::isGroup($entity->getEntityTypeId(), $entity->bundle())) {
$membership_ids = \Drupal::entityQuery('og_membership')
->condition('group_entity_type', $entity->getEntityTypeId())
->condition('group_entity_id', $entity->id())
->execute();
foreach (OgMembership::loadMultiple($membership_ids) as $membership) {
$membership->delete();
}
}
return;
//from d7
list($id, , $bundle) = entity_extract_ids($entity_type, $entity);
if (og_is_group($entity_type, $entity)) {
og_delete_user_roles_by_group($entity_type, $entity);
Expand Down Expand Up @@ -2638,3 +2650,4 @@ function _og_get_groups_by_user($account = NULL, $group_type = NULL) {
return $gids[$group_type];
}
}