/** * Delete Resources. * * @param array $entities * An array of Resources to delete. * * @throws Exception */ public function deleteMultiple($entities) { $ids = array(); if (!empty($entities)) { $transaction = db_transaction(); try { foreach ($entities as $entity) { module_invoke_all('lti_tool_provider_outcomes_resource_delete', $entity); // Invoke hook_entity_delete(). module_invoke_all('entity_delete', $entity, 'lti_tool_provider_outcomes_resource'); field_attach_delete('lti_tool_provider_outcomes_resource', $entity); $ids[] = $entity->lti_tool_provider_outcomes_resource_id; } db_delete('lti_tool_provider_outcomes_resource')->condition('lti_tool_provider_outcomes_resource_id', $ids, 'IN')->execute(); } catch (Exception $e) { $transaction->rollback(); watchdog_exception('lti_tool_provider_outcomes_resource', $e); throw $e; } } }
/** * Delete a list of memberships context entities. * * @param object $entities * An array of memberships contexts to be deleted. */ public function delete_multiple($entities) { $ids = array(); if (!empty($entities)) { $transaction = db_transaction(); try { foreach ($entities as $entity) { module_invoke_all('lti_tool_provider_memberships_context_delete', $entity); module_invoke_all('entity_delete', $entity, 'lti_tool_provider_memberships_context'); field_attach_delete('lti_tool_provider_memberships_context', $entity); $ids[] = $entity->lti_tool_provider_memberships_context_id; } db_delete('lti_tool_provider_memberships_context')->condition('lti_tool_provider_memberships_context_id', $ids, 'IN')->execute(); } catch (Exception $e) { $transaction->rollback(); watchdog_exception('lti_tool_provider_memberships_context', $e); throw $e; } } }
/** * Delete a user from the system. * * This is a copy of user_delete() minus the user_load() call. */ private function delete_single(stdClass $account) { $uids = array($account->uid); $transaction = db_transaction(); try { module_invoke_all('user_delete', $account); module_invoke_all('entity_delete', $account, 'user'); field_attach_delete('user', $account); drupal_session_destroy_uid($account->uid); db_delete('users')->condition('uid', $uids, 'IN')->execute(); db_delete('users_roles')->condition('uid', $uids, 'IN')->execute(); db_delete('authmap')->condition('uid', $uids, 'IN')->execute(); } catch (Exception $e) { $transaction->rollback(); watchdog_exception('user', $e); throw $e; } $this->resetCache($uids); }
public function delete($fpids) { $transaction = db_transaction(); if (!empty($fpids)) { $entities = fieldable_panels_panes_load_multiple($fpids, array()); try { foreach ($entities as $fpid => $entity) { // Call the entity-specific callback (if any): module_invoke_all('entity_delete', $entity, 'fieldable_panels_pane'); field_attach_delete('fieldable_panels_pane', $entity); } // Delete after calling hooks so that they can query entity tables as needed. db_delete('fieldable_panels_panes')->condition('fpid', $fpids, 'IN')->execute(); db_delete('fieldable_panels_panes_revision')->condition('fpid', $fpids, 'IN')->execute(); } catch (Exception $e) { $transaction->rollback(); watchdog_exception('fieldable_panels_pane', $e); throw $e; } // Clear the page and block and entity_load_multiple caches. entity_get_controller('fieldable_panels_pane')->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; } } }