You are here

function search_api_search_api_server_update in Search API 7

Implements hook_search_api_server_update().

Calls the server's postUpdate() method and marks all of this server's indexes for reindexing, if necessary.

1 call to search_api_search_api_server_update()
search_api_search_api_server_insert in ./search_api.module
Implements hook_search_api_server_insert().

File

./search_api.module, line 606
Provides a flexible framework for implementing search services.

Code

function search_api_search_api_server_update(SearchApiServer $server) {
  if ($server
    ->postUpdate()) {
    foreach (search_api_index_load_multiple(FALSE, array(
      'server' => $server->machine_name,
    )) as $index) {
      $index
        ->reindex();
    }
  }
  if (!empty($server->original) && $server->enabled != $server->original->enabled) {
    if ($server->enabled) {
      search_api_server_tasks_check($server);
    }
    else {
      foreach (search_api_index_load_multiple(FALSE, array(
        'server' => $server->machine_name,
      )) as $index) {
        $index
          ->update(array(
          'enabled' => 0,
          'server' => NULL,
        ));
      }
    }
  }
}