public function WSEntityAPIController::delete in Web Service Data 7
Implements EntityAPIControllerInterface.
WS Delete's the entity
Parameters
$transaction: Optionally a DatabaseTransaction object to use. Allows overrides to pass in their transaction object.
Overrides EntityAPIController::delete
File
- modules/
wsentities/ includes/ wsentity.controller.inc, line 55 - Provides a controller building upon the core controller but providing more features like full CRUD functionality.
Class
- WSEntityAPIController
- WSEntityAPIController extends and overrides most EntityAPIController features
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;
}
// This transaction causes troubles on MySQL, see
// http://drupal.org/node/1007830. So we deactivate this by default until
// is shipped in a point release.
// $transaction = isset($transaction) ? $transaction : db_transaction();
try {
$ids = array_keys($entities);
/*
TODO: WS delete
db_delete($this->entityInfo['base table'])
->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) {
if (isset($transaction)) {
$transaction
->rollback();
}
watchdog_exception($this->entityType, $e);
throw $e;
}
}