function votingapi_entity_delete in Voting API 8.3
Same name and namespace in other branches
- 7.3 votingapi.module \votingapi_entity_delete()
- 7.2 votingapi.module \votingapi_entity_delete()
Implements hook_entity_delete().
File
- ./
votingapi.module, line 55 - Contains votingapi.module.
Code
function votingapi_entity_delete(EntityInterface $entity) {
// Only act on content entities.
if (!$entity instanceof FieldableEntityInterface) {
return;
}
// Delete all votes and result entries for the deleted entities.
if (!$entity instanceof VoteInterface) {
$vote_storage = \Drupal::entityTypeManager()
->getStorage('vote');
$vote_storage
->deleteVotesForDeletedEntity($entity
->getEntityTypeId(), $entity
->id());
}
}