function opigno_moxtra_entity_delete in Opigno Moxtra 8
Same name and namespace in other branches
- 3.x opigno_moxtra.module \opigno_moxtra_entity_delete()
Implements hook_entity_delete().
File
- ./
opigno_moxtra.module, line 561 - Contains opigno_moxtra.module.
Code
function opigno_moxtra_entity_delete(EntityInterface $entity) {
if ($entity
->bundle() == 'user') {
try {
// Get user Opigno Live Meeting results ids.
$meeting_result_ids = \Drupal::entityQuery('opigno_moxtra_meeting_result')
->condition('user_id', $entity
->id())
->execute();
} catch (\Exception $e) {
\Drupal::logger('opigno_ilt')
->error($e
->getMessage());
\Drupal::messenger()
->addMessage($e
->getMessage(), 'error');
}
if (!empty($meeting_result_ids)) {
// Remove user Opigno Live Meeting results.
foreach ($meeting_result_ids as $id) {
if ($meeting_result = MeetingResult::load($id)) {
$meeting_result
->delete();
}
}
}
}
}