You are here

public function SearchApiEtDatasourceController::trackItemInsert in Search API Entity Translation 7.2

Starts tracking the index status for the given items on the given indexes.

Parameters

array $item_ids: The IDs of new items to track.

SearchApiIndex[] $indexes: The indexes for which items should be tracked.

Return value

SearchApiIndex[]|null All indexes for which any items were added; or NULL if items were added for all of them.

Throws

SearchApiDataSourceException If any error state was encountered.

Overrides SearchApiEntityDataSourceController::trackItemInsert

File

includes/SearchApiEtDatasourceController.php, line 280
Contains the SearchApiEtDatasourceController class.

Class

SearchApiEtDatasourceController
Provides multilingual versions of all entity types.

Code

public function trackItemInsert(array $item_ids, array $indexes) {
  $ret = array();
  foreach ($indexes as $index_id => $index) {

    // Sometimes we get item_ids not meant to be tracked, just filter them out.
    $ids = $this
      ->filterTrackableIds($index, $item_ids);
    if ($ids) {

      // Some times the item could be already in the index, let try to remove
      // them before inserting.
      parent::trackItemDelete($ids, array(
        $index,
      ));

      // Actually add the items to the index.
      parent::trackItemInsert($ids, array(
        $index,
      ));
      $ret[$index_id] = $index;
    }
  }
  return $ret;
}