public function Field::getDataDefinition in Search API 8
Retrieves this field's data definition.
Return value
\Drupal\Core\TypedData\DataDefinitionInterface The data definition object for this field.
Throws
\Drupal\search_api\SearchApiException Thrown if the field's data definition is unknown.
Overrides FieldInterface::getDataDefinition
1 call to Field::getDataDefinition()
- Field::getDescription in src/
Item/ Field.php - Retrieves this field's description.
File
- src/
Item/ Field.php, line 472
Class
- Field
- Represents a field on a search item that can be indexed.
Namespace
Drupal\search_api\ItemCode
public function getDataDefinition() {
if (!isset($this->dataDefinition)) {
$definitions = $this
->getIndex()
->getPropertyDefinitions($this
->getDatasourceId());
$definition = \Drupal::getContainer()
->get('search_api.fields_helper')
->retrieveNestedProperty($definitions, $this
->getPropertyPath());
if (!$definition) {
$field_label = $this
->getLabel();
$index_label = $this
->getIndex()
->label();
throw new SearchApiException("Could not retrieve data definition for field '{$field_label}' on index '{$index_label}'.");
}
$this->dataDefinition = $definition;
}
return $this->dataDefinition;
}