You are here

public function SearchApiTestService::deleteItems in Search API 7

Deletes indexed items from this server.

Might be either used to delete some items (given by their ids) from a specified index, or all items from that index, or all items from all indexes on this server.

Parameters

$ids: Either an array containing the ids of the items that should be deleted, or 'all' if all items should be deleted. Other formats might be recognized by implementing classes, but these are not standardized.

SearchApiIndex $index: The index from which items should be deleted, or NULL if all indexes on this server should be cleared (then, $ids has to be 'all').

Throws

SearchApiException If an error occurred while trying to delete the items.

Overrides SearchApiServiceInterface::deleteItems

File

tests/search_api_test.module, line 312
Test functions and classes for testing the Search API.

Class

SearchApiTestService
Test service class.

Code

public function deleteItems($ids = 'all', SearchApiIndex $index = NULL) {
  $this
    ->checkErrorState();
  if ($ids == 'all') {
    if ($index) {
      $this->options['indexes'][$index->machine_name] = array();
    }
    else {
      $this->options['indexes'] = array();
    }
  }
  else {
    foreach ($ids as $id) {
      unset($this->options['indexes'][$index->machine_name][$id]);
    }
  }
  $this->server
    ->save();
}