public function DeleteContent::deleteAllTerms in Drush Delete All 3.x
Same name and namespace in other branches
- 8.2 src/DeleteContent.php \Drupal\drush_delete\DeleteContent::deleteAllTerms()
To delete the taxonomy vocabulary terms.
Parameters
string $type: Entity type.
Return value
string The message to be displayed when terms are deleted.
File
- src/
DeleteContent.php, line 141
Class
- DeleteContent
- Delete content service class.
Namespace
Drupal\drush_deleteCode
public function deleteAllTerms($type) {
$tids = $this->entityTypeManager
->getStorage('taxonomy_term')
->getQuery()
->condition('vid', $type)
->execute();
if (!empty($tids)) {
$count = count($tids);
$controller = $this->entityTypeManager
->getStorage('taxonomy_term');
$entities = $controller
->loadMultiple($tids);
$controller
->delete($entities);
return $count . " terms deleted.";
}
else {
return "Nothing to delete.";
}
}