Skip to content
Snippets Groups Projects

2978727: Use current time setting for the timestamp widget

1 unresolved thread

Updated use_current_time as an 'select' type Fix some phpcs issue Added test

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
69 102 ]);
70 103
71 104 $this->drupalLogin($web_user);
72 $field_name = 'field_timestamp';
105 $this->fieldName = $field_name = 'field_timestamp';
  • Suggest to replace the remaining three instances of $field_name in TimestampTest::setup() should become references to $this->fieldName, then you can eliminate the duplicated variable on line 105. (Provided there's not something complicated happening I missed!)

    Suggested change
    105 $this->fieldName = $field_name = 'field_timestamp';
    106 $type = 'timestamp';
    107 $widget_type = 'datetime_timestamp';
    108 $formatter_type = 'timestamp';
    109
    110 $this->fieldStorage = FieldStorageConfig::create([
    111 'field_name' => $field_name,
    112 'entity_type' => 'entity_test',
    113 'type' => $type,
    114 ]);
    115 $this->fieldStorage->save();
    116 $this->field = FieldConfig::create([
    117 'field_storage' => $this->fieldStorage,
    118 'bundle' => 'entity_test',
    119 'required' => TRUE,
    120 'description' => 'Description for timestamp field.',
    121 ]);
    122 $this->field->save();
    123
    124 EntityFormDisplay::load('entity_test.entity_test.default')
    125 ->setComponent($field_name, ['type' => $widget_type])
    126 ->save();
    127
    128 $this->displayOptions = [
    129 'type' => $formatter_type,
    130 'label' => 'hidden',
    131 ];
    132
    133 EntityViewDisplay::create([
    134 'targetEntityType' => $this->field->getTargetEntityTypeId(),
    135 'bundle' => $this->field->getTargetBundle(),
    136 'mode' => 'full',
    137 'status' => TRUE,
    138 ])->setComponent($field_name, $this->displayOptions)
    139 ->save();
    105 $this->fieldName = 'field_timestamp';
    106 $type = 'timestamp';
    107 $widget_type = 'datetime_timestamp';
    108 $formatter_type = 'timestamp';
    109
    110 $this->fieldStorage = FieldStorageConfig::create([
    111 'field_name' => $this->fieldName,
    112 'entity_type' => 'entity_test',
    113 'type' => $type,
    114 ]);
    115 $this->fieldStorage->save();
    116 $this->field = FieldConfig::create([
    117 'field_storage' => $this->fieldStorage,
    118 'bundle' => 'entity_test',
    119 'required' => TRUE,
    120 'description' => 'Description for timestamp field.',
    121 ]);
    122 $this->field->save();
    123
    124 EntityFormDisplay::load('entity_test.entity_test.default')
    125 ->setComponent($this->fieldName, ['type' => $widget_type])
    126 ->save();
    127
    128 $this->displayOptions = [
    129 'type' => $formatter_type,
    130 'label' => 'hidden',
    131 ];
    132
    133 EntityViewDisplay::create([
    134 'targetEntityType' => $this->field->getTargetEntityTypeId(),
    135 'bundle' => $this->field->getTargetBundle(),
    136 'mode' => 'full',
    137 'status' => TRUE,
    138 ])->setComponent($this->fieldName, $this->displayOptions)
    139 ->save();
    Edited by Chris Burgess
  • Please register or sign in to reply
Please register or sign in to reply
Loading