function EntityExampleBasicController::deleteMultiple
Delete one or more entity_example_basic entities.
Deletion is unfortunately not supported in the base DrupalDefaultEntityController class.
Parameters
array $entities: An array of entity IDs or a single numeric ID.
1 call to EntityExampleBasicController::deleteMultiple()
- EntityExampleBasicController::delete in entity_example/
entity_example.module - Delete a single entity.
File
-
entity_example/
entity_example.module, line 609
Class
- EntityExampleBasicController
- EntityExampleBasicController extends DrupalDefaultEntityController.
Code
public function deleteMultiple($entities) {
$basic_ids = array();
if (!empty($entities)) {
$transaction = db_transaction();
try {
foreach ($entities as $entity) {
// Invoke hook_entity_delete().
module_invoke_all('entity_delete', $entity, 'entity_example_basic');
field_attach_delete('entity_example_basic', $entity);
$basic_ids[] = $entity->basic_id;
}
db_delete('entity_example_basic')->condition('basic_id', $basic_ids, 'IN')
->execute();
} catch (Exception $e) {
$transaction->rollback();
watchdog_exception('entity_example', $e);
throw $e;
}
}
}