3 namespace Drupal\entity_test\Plugin\Field\FieldType;
5 use Drupal\Core\Field\Plugin\Field\FieldType\ChangedItem;
8 * Defines the 'changed_test' entity field type.
10 * Wraps Drupal\Core\Field\Plugin\Field\FieldType\ChangedItem.
13 * id = "changed_test",
14 * label = @Translation("Last changed"),
15 * description = @Translation("An entity field containing a UNIX timestamp of when the entity has been last updated."),
17 * list_class = "\Drupal\Core\Field\ChangedFieldItemList"
20 * @see \Drupal\Core\Entity\EntityChangedInterface
22 class ChangedTestItem extends ChangedItem {
27 public function preSave() {
30 if ($this->value == REQUEST_TIME) {
31 // During a test the request time is immutable. To allow tests of the
33 // Drupal\Core\Field\Plugin\Field\FieldType\ChangedItem::preSave() we need
34 // to set a real time value here.
35 $this->value = time();