You are here

public function EntityBlockController::deleteMultiple in Entity Blocks 7

Deletes multiple entity_blocks.

Parameters

array $entities: An array of entity IDs or a single numeric ID.

Throws

\Exception

1 call to EntityBlockController::deleteMultiple()
EntityBlockController::delete in ./entity_block.controller.inc
Deletes an entity_block.

File

./entity_block.controller.inc, line 101
The controller for the EntityBlock entity.

Class

EntityBlockController
The controller class for Entity Block.

Code

public function deleteMultiple($entities) {
  $entity_block_ids = array();
  if (!empty($entities)) {
    $transaction = db_transaction();
    try {
      foreach ($entities as $entity) {

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