public function Field::setType in Search API 8
Sets the Search API data type of this field.
Parameters
string $type: The data type of the field.
Return value
$this
Throws
\Drupal\search_api\SearchApiException Thrown if the type of this field is locked.
Overrides FieldInterface::setType
File
- src/
Item/ Field.php, line 526
Class
- Field
- Represents a field on a search item that can be indexed.
Namespace
Drupal\search_api\ItemCode
public function setType($type) {
if ($type != $this->type && $this
->isTypeLocked()) {
$field_label = $this
->getLabel();
$index_label = $this
->getIndex()
->label();
throw new SearchApiException("Trying to change the type of field '{$field_label}' on index '{$index_label}', which is locked.");
}
$this->type = $type;
return $this;
}