You are here

public function LTIToolProviderMembershipsEntityController::delete_multiple in LTI Tool Provider 7

Delete a list of memberships entities.

Parameters

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

Throws

Exception

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

File

lti_tool_provider_memberships/LTIToolProviderMembershipsEntityController.class.php, line 98
Contains LTIToolProviderMembershipsEntityController.

Class

LTIToolProviderMembershipsEntityController
Memberships 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_delete', $entity);
        module_invoke_all('entity_delete', $entity, 'lti_tool_provider_memberships');
        field_attach_delete('lti_tool_provider_memberships', $entity);
        $ids[] = $entity->lti_tool_provider_memberships_id;
      }
      db_delete('lti_tool_provider_memberships')
        ->condition('lti_tool_provider_memberships_id', $ids, 'IN')
        ->execute();
    } catch (Exception $e) {
      $transaction
        ->rollback();
      watchdog_exception('lti_tool_provider_memberships', $e);
      throw $e;
    }
  }
}