You are here

public function Index::trackItemsDeleted in Search API 8

Deletes items from the index.

Note that this method receives datasource-specific item IDs as the parameter, not containing the datasource prefix.

Parameters

string $datasource_id: The ID of the datasource to which the items belong.

array $ids: An array of datasource-specific items IDs.

Overrides IndexInterface::trackItemsDeleted

1 call to Index::trackItemsDeleted()
Index::loadItemsMultiple in src/Entity/Index.php
Loads multiple search objects for this index.

File

src/Entity/Index.php, line 1100

Class

Index
Defines the search index configuration entity.

Namespace

Drupal\search_api\Entity

Code

public function trackItemsDeleted($datasource_id, array $ids) {
  if (!$this
    ->status()) {
    return;
  }
  $item_ids = [];
  foreach ($ids as $id) {
    $item_ids[] = Utility::createCombinedId($datasource_id, $id);
  }
  if ($this
    ->hasValidTracker()) {
    $this
      ->getTrackerInstance()
      ->trackItemsDeleted($item_ids);
  }
  if (!$this
    ->isReadOnly() && $this
    ->hasValidServer()) {
    $this
      ->getServerInstance()
      ->deleteItems($this, $item_ids);
  }
}