You are here

public function FieldsHelperInterface::createFieldFromProperty in Search API 8

Creates a new field on an index based on a property.

Will find and set a new unique field identifier for the field on the index.

Parameters

\Drupal\search_api\IndexInterface $index: The search index.

\Drupal\Core\TypedData\DataDefinitionInterface $property: The data definition of the property.

string|null $datasourceId: The ID of the index's datasource this property belongs to, or NULL if it is a datasource-independent property.

string $propertyPath: The property's property path within the property structure of the datasource.

string|null $fieldId: (optional) The identifier to use for the field. If not set, a new unique field identifier on the index will be chosen automatically.

string|null $type: (optional) The type to set for the field, or NULL to determine a default type automatically.

Return value

\Drupal\search_api\Item\FieldInterface A new field object for the index, based on the given property.

Throws

\Drupal\search_api\SearchApiException Thrown if no type was given and no default could be determined.

1 method overrides FieldsHelperInterface::createFieldFromProperty()
FieldsHelper::createFieldFromProperty in src/Utility/FieldsHelper.php
Creates a new field on an index based on a property.

File

src/Utility/FieldsHelperInterface.php, line 244

Class

FieldsHelperInterface
Provides an interface for implementations of the fields helper service.

Namespace

Drupal\search_api\Utility

Code

public function createFieldFromProperty(IndexInterface $index, DataDefinitionInterface $property, $datasourceId, $propertyPath, $fieldId = NULL, $type = NULL);