public function delete($bids)
 {
     $transaction = db_transaction();
     if (!empty($bids)) {
         $entities = command_buttons_load_multiple($bids, 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', $bids, 'IN')->execute();
         } catch (Exception $e) {
             $transaction->rollback();
             watchdog_exception('command_button', $e);
             throw $e;
         }
         // Clear the page and block and entity_load_multiple caches.
         entity_get_controller('command_button')->resetCache();
     }
 }
 /**
  * Deletes the entities then rebuilds defaults if needed.
  *
  * @param $bids
  *  Can be an array of numeric BIDS, names, or combo as sutiable for load().
  */
 public function delete($bids)
 {
     $transaction = db_transaction();
     if (!empty($bids) && ($entities = command_buttons_load_multiple($bids, 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;
         }
     }
 }