You are here

function sarnia_entity_type_delete in Sarnia 7

Delete a Sarnia entity type.

2 calls to sarnia_entity_type_delete()
sarnia_entity_delete_form_submit in ./sarnia.entities.inc
sarnia_search_api_server_delete in ./sarnia.module
Implements hook_search_api_server_delete().

File

./sarnia.entities.inc, line 95

Code

function sarnia_entity_type_delete($machine_name) {
  $entity_type = sarnia_entity_type_load($machine_name);

  // Delete the related Search API index, if it exists.
  if ($index = search_api_index_load($entity_type['search_api_index'])) {
    search_api_index_delete($index->machine_name);
  }

  // Delete any Field API fields on the entity type.
  field_attach_delete_bundle($machine_name, $machine_name);

  // Delete our record of the entity type.
  db_query("DELETE FROM {sarnia_entity_type} WHERE machine_name = :machine_name", array(
    ':machine_name' => $machine_name,
  ));

  // Reset the array returned by _sarnia_entity_types().
  drupal_static_reset('_sarnia_entity_types');
}