You are here

public function NodeRevisionDeleteCommands::deleteCronRun in Node Revision Delete 8

Configures how many revisions delete per cron run.

@usage nrd-delete-cron-run Show how many revisions the module will delete per cron run. @usage nrd-delete-cron-run 50 Configure the module to delete 50 revisions per cron run.

@command nrd:delete-cron-run @aliases nrd-dcr, nrd-delete-cron-run

Parameters

int $quantity: Revisions quantity to delete per cron run.

File

src/Commands/NodeRevisionDeleteCommands.php, line 128

Class

NodeRevisionDeleteCommands
Class NodeRevisionDeleteCommands.

Namespace

Drupal\node_revision_delete\Commands

Code

public function deleteCronRun($quantity = NULL) {

  // Getting an editable config because we will get and set a value.
  $config = $this->configFactory
    ->getEditable('node_revision_delete.settings');

  // If no argument found?
  if (!is_null($quantity)) {

    // Saving the values in the config.
    $config
      ->set('node_revision_delete_cron', $quantity);
    $config
      ->save();
    $message = dt('<info>The module was configured to delete @revisions revisions per cron run.</info>', [
      '@revisions' => $quantity,
    ]);
    $this
      ->io()
      ->writeln($message);
  }
  else {

    // Getting the values from the config.
    $revisions = $config
      ->get('node_revision_delete_cron');
    $message = dt('<info>The revisions quantity to delete per cron run is: @revisions.</info>', [
      '@revisions' => $revisions,
    ]);
    $this
      ->io()
      ->writeln($message);
  }
}