You are here

public function AccessGrantEntityController::delete in Access Control Kit 7

Deletes an access grant from the database.

Parameters

int $gid: The grant ID.

Return value

int Status constant indicating deletion.

File

./access_grant_entity_controller.inc, line 124
Contains the access grant entity controller.

Class

AccessGrantEntityController
Provides the entity controller for access grants.

Code

public function delete($gid) {
  $transaction = db_transaction();
  try {
    $grant = entity_load_unchanged('access_grant', $gid);
    if ($grant) {
      module_invoke_all('access_grant_delete', $grant);
      module_invoke_all('entity_delete', $grant, 'access_grant');
      field_attach_delete('access_grant', $grant);
      db_delete('access_grant')
        ->condition('gid', $gid)
        ->execute();
    }
    return SAVED_DELETED;
  } catch (Exception $e) {
    $transaction
      ->rollback();
    watchdog_exception('access', $e);
    throw $e;
  }
}