public function TimestampExport::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/ TimestampExport.php, line 72
Class
- TimestampExport
- Defines a Timestamp 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();
}
$langcode = NULL;
$timezone = NULL;
$date_format = $configuration['format'];
$custom_date_format = !empty($configuration['custom_date_format']) ? $configuration['custom_date_format'] : '';
$value = $field_item
->get($property_name)
->getValue();
// If an RFC2822 date format is requested, then the month and day have to
// be in English. @see http://www.faqs.org/rfcs/rfc2822.html
if ($date_format === 'custom' && $custom_date_format === 'r') {
$langcode = 'en';
}
return $this->dateFormatter
->format($value, $date_format, $custom_date_format, $timezone, $langcode);
}