You are here

public function SearchApiIndex::entityWrapper in Search API 7

Helper function for creating an entity metadata wrapper appropriate for this index.

Parameters

$item: Unless NULL, an item of this index's item type which should be wrapped.

$alter: Whether to apply the index's active data alterations on the property information used. To also apply the data alteration to the wrapped item, execute SearchApiIndex::dataAlter() on it before calling this method.

Return value

EntityMetadataWrapper A wrapper for the item type of this index, optionally loaded with the given data and having additional fields according to the data alterations of this index (if $alter wasn't set to FALSE).

2 calls to SearchApiIndex::entityWrapper()
SearchApiIndex::getFields in includes/index_entity.inc
Returns a list of all known fields for this index.
SearchApiIndex::index in includes/index_entity.inc
Indexes items on this index.

File

includes/index_entity.inc, line 983
Contains SearchApiIndex.

Class

SearchApiIndex
Class representing a search index.

Code

public function entityWrapper($item = NULL, $alter = TRUE) {
  try {
    $info['property info alter'] = $alter ? array(
      $this,
      'propertyInfoAlter',
    ) : '_search_api_wrapper_add_all_properties';
    $info['property defaults']['property info alter'] = '_search_api_wrapper_add_all_properties';
    return $this
      ->datasource()
      ->getMetadataWrapper($item, $info);
  } catch (SearchApiException $e) {
    watchdog_exception('search_api', $e);
    return entity_metadata_wrapper($this->item_type);
  }
}