You are here

public function CommerceLicenseEntityController::delete in Commerce License 7

Overrides EntityBundlePluginEntityController::delete().

Overrides EntityAPIController::delete

File

includes/commerce_license.controller.inc, line 59
Controller for the commerce_license entity type.

Class

CommerceLicenseEntityController
@file Controller for the commerce_license entity type.

Code

public function delete($ids, DatabaseTransaction $transaction = NULL) {
  $entities = $ids ? $this
    ->load($ids) : FALSE;
  if (!$entities) {

    // Do nothing, in case invalid or no ids have been passed.
    return;
  }
  try {
    parent::delete($ids, $transaction);

    // Try to delete references to the given licenses.
    // Do this after deleting the entities in question in order to give
    // hook_entity_delete() implementations a chance to do their own thing
    // (for example, deleting both the reference AND the referencing entity).
    foreach ($entities as $entity) {
      commerce_license_delete_references($entity);
    }
  } catch (Exception $e) {
    if (isset($transaction)) {
      $transaction
        ->rollback();
    }
    throw $e;
  }
}