You are here

public function EntityDeleteController::getEntitiesToDelete in Delete all 8

Same name and namespace in other branches
  1. 2.x src/Controller/EntityDeleteController.php \Drupal\delete_all\Controller\EntityDeleteController::getEntitiesToDelete()

Get ids of the entities to delete.

Parameters

string $entity_type: entity machine name

string $bundle_type: entity machine name

array $entity_info: entity definition information

Return value

array Array of ids of entities to delete.

File

src/Controller/EntityDeleteController.php, line 26

Class

EntityDeleteController
Returns responses for devel module routes.

Namespace

Drupal\delete_all\Controller

Code

public function getEntitiesToDelete($entity_type, $bundle_type = false, $entity_info) {
  $entities_to_delete = [];

  // Delete content by entity type.
  if ($entity_type !== FALSE) {
    $query = \Drupal::entityQuery($entity_type);
    if ($bundle_type) {
      $query
        ->condition($entity_info[$entity_type]['entity_bundle'], $bundle_type);
    }
    $to_delete = $query
      ->execute();
  }
  else {
    $to_delete = [];
  }
  return $to_delete;
}