Delete all nodes on a Drupal 8 site. We invoke this using "drush scr" while rolling back migrations as a workaround for migrate-rollback not being fully implemented in D8 yet. Could also be useful for awesome April Fool's Day pranks (just kidding, don't do that).
|$query = \Drupal::entityQuery('node');|
|// Optionally, add the following line to delete only a certain type of node.|
|$nids = $query->execute();|
|$storage_handler = \Drupal::entityManager()->getStorage('node');|
|$entities = $storage_handler->loadMultiple($nids);|