function bibcite_entity_merge_entity_delete in Bibliography & Citation 8
Same name and namespace in other branches
- 2.0.x modules/bibcite_entity/bibcite_entity.batch.inc \bibcite_entity_merge_entity_delete()
 
Batch operation. Delete entity.
Parameters
int $source_id: Source entity identifier to delete.
string $entity_type_id: Entity type identifier.
string $field_name: Field name to search.
array $context: Batch context array.
2 string references to 'bibcite_entity_merge_entity_delete'
- MergeConfirmForm::submitForm in modules/
bibcite_entity/ src/ Form/ MergeConfirmForm.php  - Form submission handler.
 - MergeMultipleForm::submitForm in modules/
bibcite_entity/ src/ Form/ MergeMultipleForm.php  - Form submission handler.
 
File
- modules/
bibcite_entity/ bibcite_entity.batch.inc, line 143  - Batch callbacks.
 
Code
function bibcite_entity_merge_entity_delete($source_id, $entity_type_id, $field_name, array &$context) {
  $count = \Drupal::entityQuery('bibcite_reference')
    ->condition($field_name, $source_id)
    ->count()
    ->execute();
  $storage = \Drupal::entityTypeManager()
    ->getStorage($entity_type_id);
  $entity = $storage
    ->load($source_id);
  if ($count) {
    $context['results']['failed'][$entity
      ->id()] = $entity
      ->label();
  }
  else {
    $entity
      ->delete();
    $context['results']['entities'][$entity
      ->id()] = $entity
      ->label();
  }
}