You are here

public function Item::getExtraData in Search API 8

Retrieves extra data for this item.

Parameters

string $key: The key of the extra data. The following keys are used in the Search API project itself:

  • highlighted_fields: Contains highlighted fields data for the result. The structure is an array, keyed by field IDs, mapped to arrays of values for that field. If possible, the array for a field with highlighting data should also include any non-highlighted field values, to avoid having to determine which values are included and which aren't.
  • highlighted_keys: The exact tokens that matched keys in this item's text values. The value is an array of strings.

However, contrib modules can define arbitrary other keys. (Usually they should be prefixed with the module name, though.)

mixed $default: (optional) The value to return if the data is not set.

Return value

mixed The data set for that key, or $default if the data is not present.

Overrides ItemInterface::getExtraData

File

src/Item/Item.php, line 401

Class

Item
Provides a default implementation for a search item.

Namespace

Drupal\search_api\Item

Code

public function getExtraData($key, $default = NULL) {
  return array_key_exists($key, $this->extraData) ? $this->extraData[$key] : $default;
}