You are here

function SearchApiEtPropertyInfoAlter::propertyInfoAlter in Search API Entity Translation 7.2

Alters property information to add ET-specific properties.

Parameters

EntityMetadataWrapper $wrapper: The wrapper whose property info should be altered.

array $property_info: The current property info array.

Return value

array An altered property info array, with ET-specific properties added.

See also

entity_metadata_wrapper()

File

includes/SearchApiEtPropertyInfoAlter.php, line 50
Contains the SearchApiEtPropertyInfoAlter class.

Class

SearchApiEtPropertyInfoAlter
Helper class for altering Entity API property info arrays.

Code

function propertyInfoAlter(EntityMetadataWrapper $wrapper, array $property_info) {
  if ($this->callback) {
    $property_info = call_user_func($this->callback, $wrapper, $property_info);
  }
  $additional['search_api_et_id'] = array(
    'type' => 'token',
    'label' => t('Multilingual ID'),
    'description' => t("The item's language-specific ID."),
  );
  if (!empty($property_info['properties']['language'])) {

    // Just make sure the language has the right type.
    $property_info['properties']['language']['type'] = 'token';
  }
  else {
    $additional['language'] = array(
      'type' => 'token',
      'label' => t('Language'),
      'description' => t("The item's language."),
      'options list' => 'entity_metadata_language_list',
    );
  }

  // It's just prettier if ID and language are the first, not last.
  $property_info['properties'] = array_merge($additional, $property_info['properties']);
  return $property_info;
}