public function Item::setFields in Search API 8
Sets the item's fields.
Parameters
\Drupal\search_api\Item\FieldInterface[] $fields: An array with the fields of this item, keyed by field identifier.
Return value
$this
Overrides ItemInterface::setFields
File
- src/
Item/ Item.php, line 320
Class
- Item
- Provides a default implementation for a search item.
Namespace
Drupal\search_api\ItemCode
public function setFields(array $fields) {
// Make sure that all fields have the same index object set as we. This
// might otherwise cause impossibly hard-to-detect bugs.
/** @var \Drupal\search_api\Item\FieldInterface $field */
foreach ($fields as $field) {
$field
->setIndex($this->index);
}
$this->fields = $fields;
return $this;
}