public function EntityAPIController::delete in Entity API 7
Implements EntityAPIControllerInterface.
Parameters
$transaction: Optionally a DatabaseTransaction object to use. Allows overrides to pass in their transaction object.
Overrides EntityAPIControllerInterface::delete
1 call to EntityAPIController::delete()
- EntityAPIControllerExportable::delete in includes/
entity.controller.inc - Overridden to care about reverted entities.
1 method overrides EntityAPIController::delete()
- EntityAPIControllerExportable::delete in includes/
entity.controller.inc - Overridden to care about reverted entities.
File
- includes/
entity.controller.inc, line 377 - Provides a controller building upon the core controller but providing more features like full CRUD functionality.
Class
- EntityAPIController
- A controller implementing EntityAPIControllerInterface for the database.
Code
public function delete($ids, DatabaseTransaction $transaction = NULL) {
$entities = $ids ? $this
->load($ids) : FALSE;
if (!$entities) {
// Do nothing, in case invalid or no ids have been passed.
return;
}
$transaction = isset($transaction) ? $transaction : db_transaction();
try {
$ids = array_keys($entities);
db_delete($this->entityInfo['base table'])
->condition($this->idKey, $ids, 'IN')
->execute();
if (isset($this->revisionTable)) {
db_delete($this->revisionTable)
->condition($this->idKey, $ids, 'IN')
->execute();
}
// Reset the cache as soon as the changes have been applied.
$this
->resetCache($ids);
foreach ($entities as $id => $entity) {
$this
->invoke('delete', $entity);
}
// Ignore slave server temporarily.
db_ignore_slave();
} catch (Exception $e) {
$transaction
->rollback();
watchdog_exception($this->entityType, $e);
throw $e;
}
}