function og_entity_delete in Organic groups 8
Same name and namespace in other branches
- 7.2 og.module \og_entity_delete()
- 7 og.module \og_entity_delete()
Implements hook_entity_delete().
File
- ./
og.module, line 100
Code
function og_entity_delete(EntityInterface $entity) {
// Invalidate cache tags after a group or group content entity is deleted.
og_invalidate_group_content_cache_tags($entity);
// Clear static caches after a group or group content entity is deleted.
if (Og::isGroup($entity
->getEntityTypeId(), $entity
->bundle()) || Og::isGroupContent($entity
->getEntityTypeId(), $entity
->bundle())) {
Og::invalidateCache();
}
// If a group content type is deleted, make sure to remove it from the list of
// groups.
if ($entity instanceof ConfigEntityBundleBase) {
$bundle = $entity
->id();
$entity_type_id = \Drupal::entityTypeManager()
->getDefinition($entity
->getEntityTypeId())
->getBundleOf();
if (Og::isGroup($entity_type_id, $bundle)) {
Og::groupTypeManager()
->removeGroup($entity_type_id, $bundle);
}
}
}