public function DeleteContent::deleteAllEntity in Drush Delete All 3.x
Same name and namespace in other branches
- 8.2 src/DeleteContent.php \Drupal\drush_delete\DeleteContent::deleteAllEntity()
To delete the entity content.
Parameters
string $type: Entity type.
Return value
string The message to be displayed when entity contents are deleted.
File
- src/
DeleteContent.php, line 116
Class
- DeleteContent
- Delete content service class.
Namespace
Drupal\drush_deleteCode
public function deleteAllEntity($type) {
$query = $this->entityTypeManager
->getStorage($type)
->getQuery();
$nids = $query
->execute();
$no_delete = 0;
if (!empty($nids)) {
foreach ($nids as $nid) {
$this->entityTypeManager
->getStorage($type)
->load($nid)
->delete();
$no_delete++;
}
return $no_delete . " entities deleted.";
}
else {
return "Nothing to delete.";
}
}