You are here

public function UnsavedIndexConfiguration::addField in Search API 8

Adds a field to this index.

Parameters

\Drupal\search_api\Item\FieldInterface $field: The field to add.

Return value

$this

Throws

\Drupal\search_api\SearchApiException Thrown if the field could not be added, either because a field with the same field ID already exists, or because the field identifier is one of the reserved field IDs of pseudo-fields that can be used in search queries.

Overrides IndexInterface::addField

File

src/UnsavedIndexConfiguration.php, line 445

Class

UnsavedIndexConfiguration
Represents a configuration of an index that was not yet permanently saved.

Namespace

Drupal\search_api

Code

public function addField(FieldInterface $field) {
  $this->entity
    ->addField($field);
  return $this;
}