You are here

function sarnia_search_api_server_delete in Sarnia 7

Implements hook_search_api_server_delete().

Delete any associated Sarnia entity type when a Search API server is deleted.

File

./sarnia.module, line 892

Code

function sarnia_search_api_server_delete(SearchApiServer $server) {
  if ($server->class == 'sarnia_solr_server') {
    $entity_type_machine_name = sarnia_entity_server_name_load($server->machine_name);

    // Delete the entity type.
    module_load_include('inc', 'sarnia', 'sarnia.entities');
    sarnia_entity_type_delete($entity_type_machine_name);

    // Rebuild the entity info cache and the menus, so that tabs provided by the
    // Field UI module disappear immediately.
    entity_info_cache_clear();
    menu_rebuild();

    // Tell the user what just happened.
    drupal_set_message(t('Deleted the Sarnia entity type and a Search API index for the %server_name server.', array(
      '%server_name' => $server->name,
    )));
  }
}