You are here

function answers_entity_delete in Answers 8

Implements hook_entity_delete().

File

./answers.module, line 67
Contains answers.module.

Code

function answers_entity_delete(EntityInterface $entity) {
  if ($entity
    ->getEntityTypeId() == 'node' && $entity
    ->bundle() == 'answers_question') {
    $result = \Drupal::entityQuery('node')
      ->condition('type', 'answers_answer')
      ->condition('answers_related_question.target_id', $entity
      ->id())
      ->execute();
    entity_delete_multiple('node', $result);
  }
}