public function NodeRevisionDeleteCommands::nodeRevisionDelete in Node Revision Delete 8
Deletes old node revisions for a given content type.
@option dry_run Test run without deleting revisions but seeing the output.
@usage nrd article Delete article revisions according to set configuration. @usage nrd page --dry_run Execute the deletion process without delete the revisions, just to see the output result.
@command node-revision-delete @aliases nrd
Parameters
string $type: Content type machine name.
File
- src/
Commands/ NodeRevisionDeleteCommands.php, line 101
Class
- NodeRevisionDeleteCommands
- Class NodeRevisionDeleteCommands.
Namespace
Drupal\node_revision_delete\CommandsCode
public function nodeRevisionDelete($type, $options = [
'dry_run' => FALSE,
]) {
// Get all the candidate revisions.
$candidate_revisions = $this->nodeRevisionDelete
->getCandidatesRevisions($type);
// Checking if this is a dry run.
if ($options['dry_run']) {
$this
->io()
->writeln(dt('This is a dry run. No revision will be deleted.'));
}
// Start the batch job.
batch_set($this->nodeRevisionDelete
->getRevisionDeletionBatch($candidate_revisions, $options['dry_run']));
drush_backend_batch_process();
}