function opigno_ilt_group_content_delete in Opigno Instructor-led Trainings 8
Same name and namespace in other branches
- 3.x opigno_ilt.module \opigno_ilt_group_content_delete()
Implements hook_ENTITY_TYPE_delete().
Removes the related training field in an instructor-led training.
File
- ./
opigno_ilt.module, line 186 - Contains opigno_ilt.module.
Code
function opigno_ilt_group_content_delete(EntityInterface $entity) {
/** @var \Drupal\group\Entity\GroupContentInterface $entity */
$content = $entity
->getEntity();
if (!isset($content)) {
// If related entity is already deleted.
return;
}
$type = $content
->getEntityTypeId();
if ($type === 'opigno_ilt') {
/** @var \Drupal\opigno_ilt\ILTInterface $content */
$content
->setTrainingId(NULL);
$content
->save();
}
}