ContentDeleteController.php in Delete all 2.x
File
src/Controller/ContentDeleteController.php
View source
<?php
namespace Drupal\delete_all\Controller;
use Drupal\delete_all\Controller\DeleteControllerBase;
class ContentDeleteController extends DeleteControllerBase {
public function getContentToDelete($content_types = FALSE) {
$nodes_to_delete = [];
if ($content_types !== FALSE) {
$nodes_to_delete = [];
foreach ($content_types as $content_type) {
if ($content_type) {
$nids = $this->connection
->select('node', 'n')
->fields('n', [
'nid',
])
->condition('type', $content_type)
->execute()
->fetchCol('nid');
$nodes_to_delete = array_merge($nodes_to_delete, $nids);
}
}
}
else {
$nodes_to_delete = FALSE;
}
return $nodes_to_delete;
}
public function getContentDeleteBatch($nodes_to_delete = FALSE) {
$batch = [
'operations' => [
[
'delete_all_content_batch_delete',
[
$nodes_to_delete,
],
],
],
'finished' => 'delete_all_content_batch_delete_finished',
'title' => $this
->t('Deleting Node'),
'init_message' => $this
->t('Node deletion is starting.'),
'progress_message' => $this
->t('Deleting Node...'),
'error_message' => $this
->t('Node deletion has encountered an error.'),
];
return $batch;
}
}