You are here

function search_api_track_item_insert in Search API 7

Inserts new unindexed items for all indexes on the specified type.

Parameters

string $type: The item type of the new items.

array $item_ids: The IDs of the new items.

1 call to search_api_track_item_insert()
search_api_entity_insert in ./search_api.module
Implements hook_entity_insert().

File

./search_api.module, line 1235
Provides a flexible framework for implementing search services.

Code

function search_api_track_item_insert($type, array $item_ids) {
  $conditions = array(
    'enabled' => 1,
    'item_type' => $type,
    'read_only' => 0,
  );
  $indexes = search_api_index_load_multiple(FALSE, $conditions);
  if (!$indexes) {
    return;
  }
  try {
    $returned_indexes = search_api_get_datasource_controller($type)
      ->trackItemInsert($item_ids, $indexes);
    if (isset($returned_indexes)) {
      $indexes = $returned_indexes;
    }
  } catch (SearchApiException $e) {
    $vars['%item_type'] = $type;
    watchdog_exception('search_api', $e, '%type while inserting items of type %item_type: !message in %function (line %line of %file).', $vars);
    return;
  }
  foreach ($indexes as $index) {
    if (!empty($index->options['index_directly'])) {
      search_api_index_specific_items_delayed($index, $item_ids);
    }
  }
}