You are here

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

Retrieves all Item IDs from the given index, filtered by the Entity IDs.

Is used instead of SearchApiAbstractDataSourceController::getAllItemIds(), since available items depend on the index configuration.

Parameters

SearchApiIndex $index: The index for which item IDs should be retrieved.

array $entity_ids: The Entity IDs to get the ItemIDs for.

Return value

array An array with all item IDs for a given index, with keys and values both being the IDs.

2 calls to SearchApiEtDatasourceController::getTrackableItemIds()
SearchApiEtDatasourceController::filterTrackableIds in includes/SearchApiEtDatasourceController.php
Filters the given Item IDs to include only the ones handled by the Index.
SearchApiEtDatasourceController::getTrackableItemIdsFromMixedSource in includes/SearchApiEtDatasourceController.php
Helper function to return the list of ItemIDs, fiven

File

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

Class

SearchApiEtDatasourceController
Provides multilingual versions of all entity types.

Code

public function getTrackableItemIds(SearchApiIndex $index, $entity_ids = NULL) {
  $entity_ids = $this
    ->getTrackableEntityIds($index, $entity_ids);
  if (empty($entity_ids)) {
    return array();
  }
  $ids = array();
  $entity_type = $index
    ->getEntityType();
  $entity_controller = entity_get_controller($entity_type);
  $entity_controller
    ->resetCache($entity_ids);
  $entities = entity_load($entity_type, $entity_ids);
  foreach ($entities as $entity_id => $entity) {
    foreach (search_api_et_item_languages($entity, $entity_type, $index) as $lang) {
      $item_id = SearchApiEtHelper::buildItemId($entity_id, $lang);
      $ids[$item_id] = $item_id;
    }
  }
  return $ids;
}