public static function postDelete(EntityStorageInterface $storage, array $entities) {
parent::postDelete($storage, $entities);
$entity_type_manager = \Drupal::entityTypeManager();
// Since we are deleting one or multiple job items here we also need to
// delete the attached messages.
$mids = \Drupal::entityQuery('tmgmt_message')
->accessCheck(TRUE)
->condition('tjiid', array_keys($entities), 'IN')
->execute();
if (!empty($mids)) {
$messages = $entity_type_manager
->getStorage('tmgmt_message')
->loadMultiple($mids);
$entity_type_manager
->getStorage('tmgmt_message')
->delete($messages);
}
$trids = \Drupal::entityQuery('tmgmt_remote')
->accessCheck(TRUE)
->condition('tjiid', array_keys($entities), 'IN')
->execute();
if (!empty($trids)) {
$remotes = $entity_type_manager
->getStorage('tmgmt_remote')
->loadMultiple($trids);
$entity_type_manager
->getStorage('tmgmt_remote')
->delete($remotes);
}
}