You are here

protected function FarmFieldFactory::modifyTimestampField in farmOS 2.x

Timestamp field modifier.

Parameters

\Drupal\Core\Field\BaseFieldDefinition &$field: A base field definition object.

array $options: An array of options.

1 call to FarmFieldFactory::modifyTimestampField()
FarmFieldFactory::buildFieldDefinition in modules/core/field/src/FarmFieldFactory.php
Builds a field definition with farmOS opinions.

File

modules/core/field/src/FarmFieldFactory.php, line 817

Class

FarmFieldFactory
Factory for generating farmOS field definitions.

Namespace

Drupal\farm_field

Code

protected function modifyTimestampField(BaseFieldDefinition &$field, array $options = []) {

  // Build form and view display settings.
  $field
    ->setDisplayOptions('form', [
    'type' => 'datetime_timestamp_optional',
    'weight' => $options['weight']['form'] ?? 0,
  ]);
  $field
    ->setDisplayOptions('view', [
    'label' => 'inline',
    'type' => 'timestamp',
    'settings' => [
      'date_format' => 'medium',
      'custom_date_format' => '',
      'timezone' => '',
    ],
    'weight' => $options['weight']['view'] ?? 0,
  ]);
}