public static function Job::postDelete in Translation Management Tool 8
Acts on deleted entities before the delete hook is invoked.
Used after the entities are deleted but before invoking the delete hook.
Parameters
\Drupal\Core\Entity\EntityStorageInterface $storage: The entity storage object.
\Drupal\Core\Entity\EntityInterface[] $entities: An array of entities.
Overrides EntityBase::postDelete
File
- src/
Entity/ Job.php, line 263
Class
- Job
- Entity class for the tmgmt_job entity.
Namespace
Drupal\tmgmt\EntityCode
public static function postDelete(EntityStorageInterface $storage, array $entities) {
parent::postDelete($storage, $entities);
$entity_type_manager = \Drupal::entityTypeManager();
// Since we are deleting one or multiple jobs here we also need to delete
// the attached job items and messages.
$tjiids = \Drupal::entityQuery('tmgmt_job_item')
->condition('tjid', array_keys($entities), 'IN')
->execute();
if (!empty($tjiids)) {
$job_items = $entity_type_manager
->getStorage('tmgmt_job_item')
->loadMultiple($tjiids);
$entity_type_manager
->getStorage('tmgmt_job_item')
->delete($job_items);
}
$mids = \Drupal::entityQuery('tmgmt_message')
->condition('tjid', 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')
->condition('tjid', 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);
}
}