You are here

public function ItemInterface::setField in Search API 8

Sets one of the item's fields.

Parameters

string $field_id: The field's identifier.

\Drupal\search_api\Item\FieldInterface|null $field: (optional) The information and contents of this field. Or NULL to remove the field from the item.

Return value

$this

Throws

\InvalidArgumentException Thrown if a $field is passed but has another field identifier than given as $field_id.

1 method overrides ItemInterface::setField()
Item::setField in src/Item/Item.php
Sets one of the item's fields.

File

src/Item/ItemInterface.php, line 137

Class

ItemInterface
Represents a search item being indexed or returned as a search result.

Namespace

Drupal\search_api\Item

Code

public function setField($field_id, FieldInterface $field = NULL);