public function DeleteContent::deleteAllEntity in Drush Delete All 8.2
Same name and namespace in other branches
- 3.x src/DeleteContent.php \Drupal\drush_delete\DeleteContent::deleteAllEntity()
To delete the entity content.
Parameters
string $type: Entity type.
Return value
string return.
File
- src/
DeleteContent.php, line 70
Class
Namespace
Drupal\drush_deleteCode
public function deleteAllEntity($type) {
$query = \Drupal::entityQuery($type);
$nids = $query
->execute();
$no_delete = 0;
if (!empty($nids)) {
foreach ($nids as $nid) {
$delete = \Drupal::entityTypeManager()
->getStorage($type)
->load($nid)
->delete();
$no_delete++;
}
return $no_delete . " no of contents are deleted";
}
else {
return "Content not found !";
}
}