You are here

public function SearchApiAlgoliaService::deleteItems in Search API Algolia 7

Implements deleteItems.

Overrides SearchApiServiceInterface::deleteItems

File

includes/service.inc, line 212
Contains SearchApiAlgoliaService.

Class

SearchApiAlgoliaService
SearchApiAlgoliaService class.

Code

public function deleteItems($ids = 'all', SearchApiIndex $index = NULL) {

  // Connect to the Algolia service.
  $this
    ->connect($index);
  if ($ids == 'all') {

    // Action triggered from the index admin page, when "Clear all indexed
    // data" button is clicked.
    $this
      ->getAlgoliaIndex()
      ->clearIndex();
  }
  else {

    // Action triggered when individual nodes are deleted. When deleting
    // multiple nodes from the admin content page, DeleteItems is being called
    // as many times as the number of nodes being deleted, making the foreach
    // irrelevant. There might be other contexts in which calls to deleteItems
    // are bundled though.
    foreach ($ids as $id) {
      $this
        ->getAlgoliaIndex()
        ->deleteObject($id);
    }
  }
}