You are here

public function JsonApiFacets::getDataDefinition in JSON:API Search API 8

Returns a single field's data definition from the facet source.

Return value

\Drupal\Core\TypedData\DataDefinitionInterface A typed data definition.

Overrides FacetSourcePluginInterface::getDataDefinition

File

modules/jsonapi_search_api_facets/src/Plugin/facets/facet_source/JsonApiFacets.php, line 126

Class

JsonApiFacets
Provides a facet source for use in JSON:API.

Namespace

Drupal\jsonapi_search_api_facets\Plugin\facets\facet_source

Code

public function getDataDefinition($field_name) {
  $field = $this
    ->getIndex()
    ->getField($field_name);
  if ($field) {
    return $field
      ->getDataDefinition();
  }
  throw new Exception("Field with name {$field_name} does not have a definition");
}