public function Item::getField in Search API 8
Retrieves a single field of this item.
Parameters
string $field_id: The identifier of the field to retrieve.
bool $extract: (optional) If FALSE, only returns the field if it was previously set or extracted. Defaults to extracting all fields from the original object if necessary.
Return value
\Drupal\search_api\Item\FieldInterface|null The field object with this identifier, or NULL if the field is unknown.
Overrides ItemInterface::getField
File
- src/
Item/ Item.php, line 222
Class
- Item
- Provides a default implementation for a search item.
Namespace
Drupal\search_api\ItemCode
public function getField($field_id, $extract = TRUE) {
if (isset($this->fields[$field_id])) {
return $this->fields[$field_id];
}
$fields = $this
->getFields($extract);
return isset($fields[$field_id]) ? $fields[$field_id] : NULL;
}