You are here

public function SearchApiAbstractService::preDelete in Search API 7

Implements SearchApiServiceInterface::__construct().

By default, deletes all indexes from this server.

Overrides SearchApiServiceInterface::preDelete

1 method overrides SearchApiAbstractService::preDelete()
SearchApiTestService::preDelete in tests/search_api_test.module
Overrides SearchApiAbstractService::preDelete().

File

includes/service.inc, line 420
Contains SearchApiServiceInterface and SearchApiAbstractService.

Class

SearchApiAbstractService
Abstract class with generic implementation of most service methods.

Code

public function preDelete() {
  $indexes = search_api_index_load_multiple(FALSE, array(
    'server' => $this->server->machine_name,
  ));
  foreach ($indexes as $index) {

    // removeIndex() might throw exceptions, but this method mustn't.
    try {
      $this
        ->removeIndex($index);
    } catch (SearchApiException $e) {
      $variables['%index'] = $index->name;
      $variables['%server'] = $this->server->name;
      watchdog_exception('search_api', $e, '%type while trying to remove index %index from deleted server %server: !message in %function (line %line of %file).', $variables);
    }
  }
}