EntityDeleteController.php in Delete all 8
File
src/Controller/EntityDeleteController.php
View source
<?php
namespace Drupal\delete_all\Controller;
use Drupal\delete_all\Controller\DeleteControllerBase;
class EntityDeleteController extends DeleteControllerBase {
public function getEntitiesToDelete($entity_type, $bundle_type = false, $entity_info) {
$entities_to_delete = [];
if ($entity_type !== FALSE) {
$query = \Drupal::entityQuery($entity_type);
if ($bundle_type) {
$query
->condition($entity_info[$entity_type]['entity_bundle'], $bundle_type);
}
$to_delete = $query
->execute();
}
else {
$to_delete = [];
}
return $to_delete;
}
public function getEntitiesDeleteBatch($entities_to_delete = FALSE, $entity_type) {
$batch = [
'operations' => [
[
'delete_all_entities_batch_delete',
[
$entities_to_delete,
$entity_type,
],
],
],
'finished' => 'delete_all_entities_batch_delete_finished',
'title' => $this
->t('Deleting entities'),
'init_message' => $this
->t('Entity deletion is starting.'),
'progress_message' => $this
->t('Deleting entities...'),
'error_message' => $this
->t('Entity deletion has encountered an error.'),
];
return $batch;
}
}