You are here

public function SalesforceMappingCommands::interactPrune in Salesforce Suite 8.4

Same name and namespace in other branches
  1. 8.3 modules/salesforce_mapping/src/Commands/SalesforceMappingCommands.php \Drupal\salesforce_mapping\Commands\SalesforceMappingCommands::interactPrune()
  2. 5.0.x modules/salesforce_mapping/src/Commands/SalesforceMappingCommands.php \Drupal\salesforce_mapping\Commands\SalesforceMappingCommands::interactPrune()

Get a limit argument interactively.

@hook interact salesforce_mapping:prune-revisions

File

modules/salesforce_mapping/src/Commands/SalesforceMappingCommands.php, line 73

Class

SalesforceMappingCommands
A Drush commandfile.

Namespace

Drupal\salesforce_mapping\Commands

Code

public function interactPrune(Input $input, Output $output) {
  if ($input
    ->getArgument('limit')) {
    return;
  }
  $config_limit = $this->salesforceConfig
    ->get('limit_mapped_object_revisions');

  // These 2 lines give different results:
  while (TRUE) {
    if (!($limit = $this
      ->io()
      ->ask('Enter a revision limit (integer). All revisions beyond this limit will be deleted, oldest first', $config_limit))) {
      throw new UserAbortException();
    }
    elseif ($limit > 0) {
      $input
        ->setArgument('limit', $limit);
      return;
    }
    else {
      $this
        ->logger()
        ->error('A positive integer limit is required.');
    }
  }
}