Forked from Jaesin/delete_content_entities.d8.php
Created
September 25, 2018 08:17
-
-
Save davidjguru/01c267a22add9353b95536cc0f688eae to your computer and use it in GitHub Desktop.
Delete all content entities in Drupal 8.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Delete all nodes. | |
entity_delete_multiple('node', \Drupal::entityQuery('node')->execute()); | |
// Delete all files. | |
entity_delete_multiple('file', \Drupal::entityQuery('file')->execute()); | |
// Delete all taxonomy terms. | |
entity_delete_multiple('taxonomy_term', \Drupal::entityQuery('taxonomy_term')->execute()); | |
// Delete all block content. | |
entity_delete_multiple('block_content', \Drupal::entityQuery('block_content')->execute()); | |
// Delete all menu links. | |
entity_delete_multiple('menu_link_content', \Drupal::entityQuery('menu_link_content')->execute()); | |
// Delete all users except 1 and 0. | |
entity_delete_multiple('user', \Drupal::entityQuery('user')->condition('uid', '1', '!=')->condition('uid', '0', '!=')->execute()); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment