function _entity_bulk_delete_query in Entity Bulk Delete 7
Returns an EntityFieldQuery object for querying entities to delete.
Parameters
string $entity_type: The entity type.
array $bundles: (optional) An array of bundle keys to specifically delete.
Return value
1 call to _entity_bulk_delete_query()
- drush_entity_bulk_delete in ./
entity_bulk_delete.drush.inc - Command callback for drush entity-bulk-delete
File
- ./
entity_bulk_delete.module, line 66
Code
function _entity_bulk_delete_query($entity_type, array $bundles = array()) {
$query = new EntityFieldQuery();
$query
->entityCondition('entity_type', $entity_type);
if (!empty($bundles)) {
$query
->entityCondition('bundle', $bundles);
}
if ($entity_type == 'user') {
// Prevent deletion of user 0 (anonymous) or user 1 (super-administrator).
$query
->entityCondition('entity_id', array(
0,
1,
), 'NOT IN');
}
$query
->entityOrderby('entity_id');
$query
->addTag('DANGEROUS_ACCESS_CHECK_OPT_OUT');
$query
->addTag('entity_bulk_delete');
return $query;
}