You are here

public function FieldsHelper::extractField in Search API 8

Extracts value and original type from a single piece of data.

Parameters

\Drupal\Core\TypedData\TypedDataInterface $data: The piece of data from which to extract information.

\Drupal\search_api\Item\FieldInterface $field: The field into which to put the extracted data.

Overrides FieldsHelperInterface::extractField

1 call to FieldsHelper::extractField()
FieldsHelper::extractFields in src/Utility/FieldsHelper.php
Extracts specific field values from a complex data object.

File

src/Utility/FieldsHelper.php, line 175

Class

FieldsHelper
Provides helper methods for dealing with Search API fields and properties.

Namespace

Drupal\search_api\Utility

Code

public function extractField(TypedDataInterface $data, FieldInterface $field) {
  $values = $this
    ->extractFieldValues($data);
  foreach ($values as $i => $value) {
    $field
      ->addValue($value);
  }
  $field
    ->setOriginalType($data
    ->getDataDefinition()
    ->getDataType());
}