-
-
Save algotrader-dotcom/2712436e9b8f60877424c255ee7f4a1c to your computer and use it in GitHub Desktop.
Delete all content entities in Drupal 8.
This file contains hidden or 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