Act on a newly created entity.
This hook runs after a new entity object has just been instantiated. It can be used to set initial values, e.g. to provide defaults.
\Drupal\Core\Entity\EntityInterface $entity: The entity object.
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
function hook_entity_create(\Drupal\Core\Entity\EntityInterface $entity) {
// @todo Remove the check for EntityNG once all entity types have been
// converted to it.
if (!isset($entity->foo) && $entity instanceof \Drupal\Core\Entity\EntityNG) {
$entity->foo->value = 'some_initial_value';
}
}