public function ListExport::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/ ListExport.php, line 44
Class
- ListExport
- Defines a List 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 === 'list_label') {
$value = $field_item
->get($property_name)
->getValue();
$allowed_values = $field_definition
->getFieldStorageDefinition()
->getSetting('allowed_values');
return isset($allowed_values[$value]) ? $allowed_values[$value] : $value;
}
return $field_item
->get($property_name)
->getValue();
}