public function AccessSchemeEntityController::delete in Access Control Kit 7
Deletes an access scheme from the database.
Parameters
int $sid: The scheme ID.
Return value
int Status constant indicating deletion.
File
- ./
access_scheme_entity_controller.inc, line 208 - Contains the access scheme entity controller.
Class
- AccessSchemeEntityController
- Provides the entity controller for access schemes.
Code
public function delete($sid) {
$transaction = db_transaction();
try {
$scheme = entity_load_unchanged('access_scheme', $sid);
if ($scheme) {
// Delete all access grants in the scheme.
$gids = db_query('SELECT gid FROM {access_grant} WHERE scheme = :scheme', array(
':scheme' => $scheme->machine_name,
))
->fetchCol();
foreach ($gids as $gid) {
access_grant_delete($gid);
}
// Detach any access handlers for this scheme.
db_delete('access_handler')
->condition('scheme', $scheme->machine_name)
->execute();
// Delete the access scheme definition.
db_delete('access_scheme')
->condition('sid', $sid)
->execute();
// Notify the Field API and other interested modules of the deletion.
field_attach_delete_bundle('access_grant', $scheme->machine_name);
module_invoke_all('access_scheme_delete', $scheme);
module_invoke_all('entity_delete', $scheme, 'access_scheme');
cache_clear_all();
access_scheme_static_reset();
}
return SAVED_DELETED;
} catch (Exception $e) {
$transaction
->rollback();
watchdog_exception('access', $e);
throw $e;
}
}