Programmatically set property based on other properties in a custom entity I created a custom entity and want to programmatically set the title based on 2 other properties.

For example, the entity has year and state properties. When the entity is created, I want to populate the title property with year state.

How can I achieve this?
For a custom entity type, you can override EntityStorage::doPreSave() in your entity class:

function doPreSave(EntityInterface $entity) {
  parent::doPreSave();

  // Perform field manipulation here.

  return $entity-&gt;id();
}