You are here

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

Parameters

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

array $entity_ids: The entity ids to get the trackable entity ids for.

Return value

array An array with all trackable Entity IDs for a given index.

2 calls to SearchApiEtDatasourceController::getTrackableEntityIds()
SearchApiEtDatasourceController::getTrackableItemIds in includes/SearchApiEtDatasourceController.php
Retrieves all Item IDs from the given index, filtered by the Entity IDs.
SearchApiEtDatasourceController::startTracking in includes/SearchApiEtDatasourceController.php
Overrides SearchApiEntityDataSourceController::startTracking().

File

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

Class

SearchApiEtDatasourceController
Provides multilingual versions of all entity types.

Code

public function getTrackableEntityIds(SearchApiIndex $index, $entity_ids = NULL) {
  $entity_type = $index
    ->getEntityType();
  if (!empty($this->entityInfo['base table']) && $this->idKey) {

    // Assumes that all entities use the "base table" property and the
    // "entity keys[id]" in the same way as the default controller.
    $table = $this->entityInfo['base table'];

    // Select all entity ids.
    $query = db_select($table, 't');
    $query
      ->addField('t', $this->idKey);
    if ($bundles = $this
      ->getIndexBundles($index)) {
      $query
        ->condition($this->bundleKey, $bundles);
    }
    if ($entity_ids) {
      $query
        ->condition($this->idKey, $entity_ids);
    }
    $ids = $query
      ->execute()
      ->fetchCol();
  }
  else {

    // In the absence of a 'base table', load the entities.
    $query = new EntityFieldQuery();
    $query
      ->entityCondition('entity_type', $entity_type);
    if ($bundles = $this
      ->getIndexBundles($index)) {
      $query
        ->entityCondition('bundle', $bundles);
    }
    if ($entity_ids) {
      $query
        ->entityCondition('entity_id', $entity_ids);
    }
    $entities = $query
      ->execute();
    $ids = array_keys($entities[$entity_type]);
  }
  return $ids;
}