You are here

public function Item::setExtraData in Search API 8

Sets some extra data for this item.

Parameters

string $key: The key for the extra data.

mixed $data: (optional) The data to set. If NULL, remove the extra data with the given key instead.

Return value

$this

Overrides ItemInterface::setExtraData

File

src/Item/Item.php, line 415

Class

Item
Provides a default implementation for a search item.

Namespace

Drupal\search_api\Item

Code

public function setExtraData($key, $data = NULL) {
  if (isset($data)) {
    $this->extraData[$key] = $data;
  }
  else {
    unset($this->extraData[$key]);
  }
  return $this;
}