You are here

protected function MediaRevisionRevertTranslationForm::prepareRevertedRevision in Media Revisions UI 8

Same name and namespace in other branches
  1. 2.0.x src/Form/MediaRevisionRevertTranslationForm.php \Drupal\media_revisions_ui\Form\MediaRevisionRevertTranslationForm::prepareRevertedRevision()

Prepares a revision to be reverted.

Parameters

\Drupal\media\MediaInterface $revision: The revision to be reverted.

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

Return value

\Drupal\media\MediaInterface The prepared revision ready to be stored.

Overrides MediaRevisionRevertForm::prepareRevertedRevision

File

src/Form/MediaRevisionRevertTranslationForm.php, line 108

Class

MediaRevisionRevertTranslationForm
Provides a form for reverting media revision for a single translation.

Namespace

Drupal\media_revisions_ui\Form

Code

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