public static function SmartDateItem::generateSampleValue in Smart Date 3.4.x
Same name and namespace in other branches
- 8.2 src/Plugin/Field/FieldType/SmartDateItem.php \Drupal\smart_date\Plugin\Field\FieldType\SmartDateItem::generateSampleValue()
- 8 src/Plugin/Field/FieldType/SmartDateItem.php \Drupal\smart_date\Plugin\Field\FieldType\SmartDateItem::generateSampleValue()
- 3.x src/Plugin/Field/FieldType/SmartDateItem.php \Drupal\smart_date\Plugin\Field\FieldType\SmartDateItem::generateSampleValue()
- 3.0.x src/Plugin/Field/FieldType/SmartDateItem.php \Drupal\smart_date\Plugin\Field\FieldType\SmartDateItem::generateSampleValue()
- 3.1.x src/Plugin/Field/FieldType/SmartDateItem.php \Drupal\smart_date\Plugin\Field\FieldType\SmartDateItem::generateSampleValue()
- 3.2.x src/Plugin/Field/FieldType/SmartDateItem.php \Drupal\smart_date\Plugin\Field\FieldType\SmartDateItem::generateSampleValue()
- 3.3.x src/Plugin/Field/FieldType/SmartDateItem.php \Drupal\smart_date\Plugin\Field\FieldType\SmartDateItem::generateSampleValue()
Generates placeholder field values.
Useful when populating site with placeholder content during site building or profiling.
Parameters
\Drupal\Core\Field\FieldDefinitionInterface $field_definition: The field definition.
Return value
array An associative array of values.
Overrides TimestampItem::generateSampleValue
File
- src/
Plugin/ Field/ FieldType/ SmartDateItem.php, line 133
Class
- SmartDateItem
- Plugin implementation of the 'smartdate' field type.
Namespace
Drupal\smart_date\Plugin\Field\FieldTypeCode
public static function generateSampleValue(FieldDefinitionInterface $field_definition) {
// Pick a random timestamp in the past year.
$timestamp = \Drupal::time()
->getRequestTime() - mt_rand(0, 86400 * 365);
$duration = 60;
$values['value'] = $timestamp;
$values['end_value'] = $timestamp + $duration * 60;
$values['duration'] = $duration;
$values['timezone'] = 'UTC';
return $values;
}