You are here

public function FieldAttributeConverter::getAttributeValueFromField in Apigee Edge 8

Generate attribute value from field's value.

Parameters

string $entity_type: The entity type.

string $field_name: Name of the field in Drupal.

mixed $field_value: Field's value in Drupal.

Return value

null|string The field value as string for the attribute or NULL if no field formatter found.

Overrides FieldAttributeConverterInterface::getAttributeValueFromField

File

src/FieldAttributeConverter.php, line 125

Class

FieldAttributeConverter
Default field-attribute converter service implementation.

Namespace

Drupal\apigee_edge

Code

public function getAttributeValueFromField(string $entity_type, string $field_name, $field_value) {
  if ($formatter = $this
    ->findFieldStorageFormatter($entity_type, $field_name)) {
    return $formatter
      ->encode($field_value);
  }
  return NULL;
}