public function ButtonController::delete in Command Buttons 7
Deletes the entities then rebuilds defaults if needed.
Parameters
$ids: Can be an array of numeric BIDS, names, or combo as sutiable for load().
Overrides EntityAPIControllerExportable::delete
File
- includes/
ButtonController.class.php, line 159 - Contains the controller class for the OA Button entity.
Class
- ButtonController
- Entity controller class.
Code
public function delete($ids, DatabaseTransaction $transaction = NULL) {
$transaction = db_transaction();
if (!empty($ids) && ($entities = command_buttons_load_multiple($ids, array()))) {
try {
foreach ($entities as $bid => $entity) {
// Call the entity-specific callback (if any):
module_invoke_all('entity_delete', $entity, 'command_button');
field_attach_delete('command_button', $entity);
}
// Delete after calling hooks so that they can query entity tables as needed.
db_delete('command_buttons')
->condition('bid', array_keys($entities), 'IN')
->execute();
// Clear the page and block and entity_load_multiple caches.
entity_get_controller('command_button')
->resetCache();
foreach ($entities as $id => $entity) {
if (entity_has_status($this->entityType, $entity, ENTITY_IN_CODE)) {
entity_defaults_rebuild(array(
$this->entityType,
));
break;
}
}
} catch (Exception $e) {
$transaction
->rollback();
watchdog_exception('command_button', $e);
throw $e;
}
}
}