I have a custom content entity type. When I create an instance, the first one got the right created time stamp. But starting with the second one, they all have the same created time stamp: as the first one have!
Why is this happening?
Base field definition:
$fields['created'] = BaseFieldDefinition::create('created')
->setLabel(t('Created'))
->setDescription(t('The time that the entity was created.'))
->setReadOnly(TRUE)
->setDisplayConfigurable('view', TRUE);
Setter / getter methods:
/**
* {@inheritdoc}
*/
public function getCreatedTime() {
return $this->get('created')->value;
}
/**
* {@inheritdoc}
*/
public function setCreatedTime($timestamp) {
$this->set('created', $timestamp);
return $this;
}