You are here

public function DeleteContent::deleteAllEntityType in Drush Delete All 8.2

Same name and namespace in other branches
  1. 3.x src/DeleteContent.php \Drupal\drush_delete\DeleteContent::deleteAllEntityType()

Function that provides the deleteing content functionality

File

src/DeleteContent.php, line 25

Class

DeleteContent

Namespace

Drupal\drush_delete

Code

public function deleteAllEntityType($type) {
  $nids = $this
    ->getEntityIds($type);
  if (!empty($nids)) {
    $no_delete = 0;
    foreach ($nids as $nid) {
      $delete = \Drupal::entityTypeManager()
        ->getStorage('node')
        ->load($nid)
        ->delete();
      $no_delete++;
    }
    return $no_delete . " no of contents are deleted";
  }
  else {
    return "Content not found !";
  }
}