You are here

public function SearchApiDenormalizedEntityDataSourceController::getMetadataWrapper in Search API Grouping 7.2

Get a metadata wrapper for the item type of this data source controller.

Parameters

mixed $item: Unless NULL, an item of the item type for this controller to be wrapped.

array $info: Optionally, additional information that should be used for creating the wrapper. Uses the same format as entity_metadata_wrapper().

Return value

EntityMetadataWrapper A wrapper for the item type of this data source controller, according to the info array, and optionally loaded with the given data.

Overrides SearchApiEntityDataSourceController::getMetadataWrapper

See also

entity_metadata_wrapper()

File

includes/datasource_denormalized_entity.inc, line 438
Contains the SearchApiDenormalizedEntityDataSourceController class.

Class

SearchApiDenormalizedEntityDataSourceController
Data source for all entities known to the Entity API.

Code

public function getMetadataWrapper($item = NULL, array $info = array()) {

  // If the item isn't the object and a denormalized id is provided extract
  // the entity id to load and wrap the entity.
  if (!is_object($item) && is_scalar($item)) {
    $parts = explode(SEARCH_API_GROUPING_ENTITY_FIELD_SEPERATOR, $item);
    $item = $parts[1];
  }
  return entity_metadata_wrapper($this->entityType, $item, $info);
}