You are here

protected function ContactStorageExportService::formatEntityReference in Contact Storage Export 8

Formats entity reference value.

Parameters

\Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem $entity_reference_item: The entity reference item.

string $property: The main property.

Return value

string Formatted entity reference value.

1 call to ContactStorageExportService::formatEntityReference()
ContactStorageExportService::getFormattedValue in src/ContactStorageExportService.php
Formats values of the given field.

File

src/ContactStorageExportService.php, line 217

Class

ContactStorageExportService
Provides a set of methods to export contact messages in CSV format.

Namespace

Drupal\contact_storage_export

Code

protected function formatEntityReference(EntityReferenceItem $entity_reference_item, $property) {

  // Display a label without a link.
  $display_options = [
    'type' => 'entity_reference_label',
    'settings' => [
      'link' => FALSE,
    ],
  ];
  if ($render_array = $entity_reference_item
    ->view($display_options)) {
    return $this
      ->renderAsString($render_array);
  }

  // Fallback to the main property.
  return (string) $entity_reference_item->{$property};
}