/**
* {@inheritdoc}
*/
public static function processDefaultValue($default_value, FieldableEntityInterface
$entity, FieldDefinitionInterface
$definition) { $default_value = parent::
processDefaultValue($default_value,
$entity,
$definition);
if (isset($default_value[0
]['default_date_type'
])) { if ($definition->
getSetting('datetime_type'
) === DateTimeItem::DATETIME_TYPE_DATE
) { // A default date only value should be in the format used for date
// storage but in the user's local timezone.
$date =
new DrupalDateTime($default_value[0
]['default_date'
],
date_default_timezone_get());
$format = DateTimeItemInterface::DATE_STORAGE_FORMAT;
} else { // A default date+time value should be in the format and timezone used
// for date storage.
$date =
new DrupalDateTime($default_value[0
]['default_date'
], DateTimeItemInterface::STORAGE_TIMEZONE
);
$format = DateTimeItemInterface::DATETIME_STORAGE_FORMAT;
} $value =
$date->
format($format);
// We only provide a default value for the first item, as do all fields.
// Otherwise, there is no way to clear out unwanted values on multiple value