function search_api_et_item_languages in Search API Entity Translation 7.2
Determines the languages that are available for an entity in a certain index.
Parameters
object $entity: The entity for which languages should be determined.
string $entity_type: The entity type of the entity.
SearchApiIndex $index: The index whose settings should be used for determining the languages.
Return value
array An array of language codes for the languages that are available.
2 calls to search_api_et_item_languages()
- SearchApiEtDatasourceController::getTrackableItemIds in includes/
SearchApiEtDatasourceController.php - Retrieves all Item IDs from the given index, filtered by the Entity IDs.
- search_api_et_batch_queue_entities in ./
search_api_et.batch.inc - Batch API callback for the item queueing functionality.
File
- ./
search_api_et.module, line 267 - Adds Entity Translation support to the Search API.
Code
function search_api_et_item_languages($entity, $entity_type, SearchApiIndex $index) {
module_load_include('inc', 'search_api_et');
$settings = search_api_et_get_index_settings($index);
switch ($settings['include']) {
case 'all':
$languages = search_api_et_item_languages_all();
break;
case 'complete':
$languages = search_api_et_item_languages_complete($entity, $entity_type);
break;
case 'incomplete':
default:
$languages = search_api_et_item_languages_entity($entity, $entity_type);
break;
}
// Removing the LANGUAGE_NONE from the available translations, if the original
// entity is not translated, or if we are adding all the enabled languages to
// the index.
if (TRUE == $settings['restrict undefined']) {
$language = entity_language($entity_type, $entity);
if ($language != LANGUAGE_NONE || $settings['include'] == 'all') {
// $languages is an array, flipping to easily remove the LANGUAGE_NONE item.
$languages = array_flip($languages);
unset($languages[LANGUAGE_NONE]);
$languages = array_keys($languages);
}
}
return $languages;
}