You are here

public function LTIToolProviderConsumerEntityController::deleteMultiple in LTI Tool Provider 7

Delete multiple consumers.

Parameters

array $entities: An array of consumers.

Throws

Exception From the db api.

1 call to LTIToolProviderConsumerEntityController::deleteMultiple()
LTIToolProviderConsumerEntityController::delete in ./LTIToolProviderConsumerEntityController.class.php
Delete a consumer.

File

./LTIToolProviderConsumerEntityController.class.php, line 118
Contains LTIToolProviderConsumerEntityController.

Class

LTIToolProviderConsumerEntityController

Code

public function deleteMultiple($entities) {
  $ids = array();
  if (!empty($entities)) {
    $transaction = db_transaction();
    try {
      foreach ($entities as $entity) {
        module_invoke_all('lti_tool_provider_consumer_delete', $entity);

        // Invoke hook_entity_delete().
        module_invoke_all('entity_delete', $entity, 'lti_tool_provider_consumer');
        field_attach_delete('lti_tool_provider_consumer', $entity);
        $ids[] = $entity->lti_tool_provider_consumer_id;
      }
      db_delete('lti_tool_provider_consumer')
        ->condition('lti_tool_provider_consumer_id', $ids, 'IN')
        ->execute();
    } catch (Exception $e) {
      $transaction
        ->rollback();
      watchdog_exception('lti_tool_provider_consumer', $e);
      throw $e;
    }
  }
}