You are here

function drush_node_revision_delete_nrd_delete_cron_run in Node Revision Delete 8

Same name and namespace in other branches
  1. 7.3 node_revision_delete.drush.inc \drush_node_revision_delete_nrd_delete_cron_run()

Callback for the nrd-delete-cron-run command.

File

./node_revision_delete.drush.inc, line 217
Drush commands related to the Node Revision Delete module.

Code

function drush_node_revision_delete_nrd_delete_cron_run() {
  $args = func_get_args();

  // Getting an editable config because we will get and set a value.
  $config = \Drupal::service('config.factory')
    ->getEditable('node_revision_delete.settings');

  // Getting or setting values?
  if (isset($args[0])) {

    // Saving the values in the config.
    $config
      ->set('node_revision_delete_cron', $args[0]);
    $config
      ->save();
    $message = dt('The module was configurated to delete @revisions revisions per cron run.', [
      '@revisions' => $args[0],
    ]);
    drush_log($message, 'success');
  }
  else {

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