You are here

protected function NodeRevisionRevertTranslationForm::prepareRevertedRevision in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/node/src/Form/NodeRevisionRevertTranslationForm.php \Drupal\node\Form\NodeRevisionRevertTranslationForm::prepareRevertedRevision()

Prepares a revision to be reverted.

Parameters

\Drupal\node\NodeInterface $revision: The revision to be reverted.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

\Drupal\node\NodeInterface The prepared revision ready to be stored.

Overrides NodeRevisionRevertForm::prepareRevertedRevision

File

core/modules/node/src/Form/NodeRevisionRevertTranslationForm.php, line 108

Class

NodeRevisionRevertTranslationForm
Provides a form for reverting a node revision for a single translation.

Namespace

Drupal\node\Form

Code

protected function prepareRevertedRevision(NodeInterface $revision, FormStateInterface $form_state) {
  $revert_untranslated_fields = (bool) $form_state
    ->getValue('revert_untranslated_fields');
  $translation = $revision
    ->getTranslation($this->langcode);
  return $this->nodeStorage
    ->createRevision($translation, TRUE, $revert_untranslated_fields);
}