You are here

public function LTIToolProviderMembershipsContextEntityController::delete_multiple in LTI Tool Provider 7

Delete a list of memberships context entities.

Parameters

object $entities: An array of memberships contexts to be deleted.

1 call to LTIToolProviderMembershipsContextEntityController::delete_multiple()
LTIToolProviderMembershipsContextEntityController::delete in lti_tool_provider_memberships/LTIToolProviderMembershipsContextEntityController.class.php
Delete a memberships context entity.

File

lti_tool_provider_memberships/LTIToolProviderMembershipsContextEntityController.class.php, line 86
Contains LTIToolProviderMembershipsContextEntityController.

Class

LTIToolProviderMembershipsContextEntityController
Memberships Context Entity controller.

Code

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;
    }
  }
}