You are here

public function FieldInterface::setIndex in Search API 8

Returns the index of this field.

This is useful when retrieving fields from cache, to have the index always set to the same object that is returning them. The method shouldn't be used in any other case.

Parameters

\Drupal\search_api\IndexInterface $index: The index to which this field belongs.

Return value

$this

Throws

\InvalidArgumentException Thrown if the ID of the given index is not the same as the ID of the index that was set up to now.

1 method overrides FieldInterface::setIndex()
Field::setIndex in src/Item/Field.php
Returns the index of this field.

File

src/Item/FieldInterface.php, line 38

Class

FieldInterface
Represents a field on a search item that can be indexed.

Namespace

Drupal\search_api\Item

Code

public function setIndex(IndexInterface $index);