You are here

public function MediaRevisionRevertTranslationForm::buildForm in Media Revisions UI 2.0.x

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

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

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

Return value

array The form structure.

Overrides MediaRevisionRevertForm::buildForm

File

src/Form/MediaRevisionRevertTranslationForm.php, line 90

Class

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

Namespace

Drupal\media_revisions_ui\Form

Code

public function buildForm(array $form, FormStateInterface $form_state, $media_revision = NULL, $langcode = NULL) {
  $this->langcode = $langcode;
  $form = parent::buildForm($form, $form_state, $media_revision);
  $isDefaultTranslationAffectedOnly = $this->revision
    ->isDefaultTranslationAffectedOnly();
  $form['revert_untranslated_fields'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Revert content shared among translations'),
    '#default_value' => $isDefaultTranslationAffectedOnly && $this->revision
      ->getTranslation($this->langcode)
      ->isDefaultTranslation(),
    '#access' => !$isDefaultTranslationAffectedOnly,
  ];
  return $form;
}