public function EntityReferenceExport::massageExportPropertyValue in Entity Export CSV 8
Massage the field item property value to CSV value.
Parameters
\Drupal\Core\Field\FieldItemInterface $field_item: The field item.
string $property_name: The property name.
\Drupal\Core\Field\FieldDefinitionInterface $field_definition: The field definition.
array $options: An array of optional options.
Return value
mixed The CSV value.
Overrides FieldTypeExportBase::massageExportPropertyValue
File
- src/
Plugin/ FieldTypeExport/ EntityReferenceExport.php, line 43
Class
- EntityReferenceExport
- Defines an Entity Reference field type export plugin.
Namespace
Drupal\entity_export_csv\Plugin\FieldTypeExportCode
public function massageExportPropertyValue(FieldItemInterface $field_item, $property_name, FieldDefinitionInterface $field_definition, $options = []) {
if ($field_item
->isEmpty()) {
return NULL;
}
$configuration = $this
->getConfiguration();
if (empty($configuration['format'])) {
return $field_item
->get($property_name)
->getValue();
}
$format = $configuration['format'];
if ($format === 'entity_reference_label') {
$entity = $field_item
->get('entity')
->getValue();
if ($entity instanceof EntityInterface) {
return $entity
->label();
}
}
return $field_item
->get($property_name)
->getValue();
}