$original_base_table = $original_entity_type->getBaseTable();
$revision_id_key = $temporary_entity_type->getKey('revision');
+ $revision_default_key = $temporary_entity_type->getRevisionMetadataKey('revision_default');
$revision_translation_affected_key = $temporary_entity_type->getKey('revision_translation_affected');
// If 'progress' is not set, then this will be the first run of the batch.
// Set the revision ID to be same as the entity ID.
$entity->set($revision_id_key, $entity_id);
+ // We had no revisions so far, so the existing data belongs to the
+ // default revision now.
+ $entity->set($revision_default_key, TRUE);
+
// Set the 'revision_translation_affected' flag to TRUE to match the
// previous API return value: if the field was not defined the value
// returned was always TRUE.
}
$updated_storage_definitions[$entity_type->getKey('revision')] = $revision_field;
+ // Add the default revision flag field.
+ $field_name = $entity_type->getRevisionMetadataKey('revision_default');
+ $storage_definition = BaseFieldDefinition::create('boolean')
+ ->setName($field_name)
+ ->setTargetEntityTypeId($entity_type->id())
+ ->setTargetBundle(NULL)
+ ->setLabel(t('Default revision'))
+ ->setDescription(t('A flag indicating whether this was a default revision when it was saved.'))
+ ->setStorageRequired(TRUE)
+ ->setTranslatable(FALSE)
+ ->setRevisionable(TRUE);
+
+ if ($update_cached_definitions) {
+ $this->entityDefinitionUpdateManager->installFieldStorageDefinition($field_name, $entity_type->id(), $entity_type->getProvider(), $storage_definition);
+ }
+ $updated_storage_definitions[$field_name] = $storage_definition;
+
// Add the 'revision_translation_affected' field if needed.
if ($entity_type->isTranslatable()) {
$revision_translation_affected_field = BaseFieldDefinition::create('boolean')