class TaxonomyMultideleteBatch in Taxonomy Multi-delete Terms 8
Batch Processor of the deletion of terms.
Hierarchy
- class \Drupal\taxonomy_multidelete_terms\TaxonomyMultideleteBatch
Expanded class hierarchy of TaxonomyMultideleteBatch
File
- src/
TaxonomyMultideleteBatch.php, line 8
Namespace
Drupal\taxonomy_multidelete_termsView source
class TaxonomyMultideleteBatch {
/**
* Process delete all the terms.
*
* @param string $tids
* The Term ID.
* @param array $context
* The batch context.
*/
public static function processTerms($tids, array $context) {
$controller = \Drupal::entityTypeManager()
->getStorage('taxonomy_term');
$entities = $controller
->loadMultiple($tids);
$controller
->delete($entities);
$context['results']['terms'] = count($tids);
}
/**
* Display message about how many terms are deleted in the vocabulary.
*
* @param bool $success
* Success flag.
* @param array $results
* Results from the batch handler.
* @param array $operations
* Operations flag.
*/
public static function finishProcess($success, array $results, array $operations) {
if ($success) {
$message = \Drupal::translation()
->formatPlural($results['terms'], '1 term deleted ', '@count terms deleted');
}
else {
$message = t("Processed with errors");
}
\Drupal::messenger()
->addMessage($message);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
TaxonomyMultideleteBatch:: |
public static | function | Display message about how many terms are deleted in the vocabulary. | |
TaxonomyMultideleteBatch:: |
public static | function | Process delete all the terms. |