You are here

function drush_taxonomy_delete_term_delete in Taxonomy Delete 8

Submit handler for term delete.

File

./taxonomy_delete.drush.inc, line 26
Contains taxonomy_delete.drush.inc.

Code

function drush_taxonomy_delete_term_delete($vid = NULL) {
  if (!isset($vid)) {
    drush_set_error("Missing argument - Vocabulary");
    return;
  }
  if (drush_confirm("Are you sure your want to delete all terms in {$vid}")) {
    $service = \Drupal::service('taxonomy_delete.term_delete');
    $term_count = $service
      ->deleteTermByVid($vid);
    $message = \Drupal::translation()
      ->formatPlural($term_count, 'One term deleted in ', '@count terms deleted in @vid', [
      '@vid' => $vid,
    ]);
    drush_print($message);
  }
  else {
    drush_user_abort();
  }
}