public function entityPrepareForm(EntityInterface
$entity,
$operation, FormStateInterface
$form_state) { /** @var \Drupal\Core\Entity\EntityFormInterface $form_object */
$form_object =
$form_state->
getFormObject();
if ($this->
isModeratedEntityEditForm($form_object) && !
$entity->
isNew()) { // Generate a proper revision object for the current entity. This allows
// to correctly handle translatable entities having pending revisions.
/** @var \Drupal\Core\Entity\ContentEntityStorageInterface $storage */
$storage =
$this->entityTypeManager->
getStorage($entity->
getEntityTypeId());
/** @var \Drupal\Core\Entity\ContentEntityInterface $new_revision */
$new_revision =
$storage->
createRevision($entity, FALSE
);
// Restore the revision ID as other modules may expect to find it still
// populated. This will reset the "new revision" flag, however the entity
// object will be marked as a new revision again on submit.
// @see \Drupal\Core\Entity\ContentEntityForm::buildEntity()