You are here

public function RevisionOverviewForm::submitForm in Diff 8

Form submission handler.

Parameters

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

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

Overrides FormInterface::submitForm

File

src/Form/RevisionOverviewForm.php, line 387

Class

RevisionOverviewForm
Provides a form for revision overview page.

Namespace

Drupal\diff\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $input = $form_state
    ->getUserInput();
  $vid_left = $input['radios_left'];
  $vid_right = $input['radios_right'];
  $nid = $input['nid'];

  // Always place the older revision on the left side of the comparison
  // and the newer revision on the right side (however revisions can be
  // compared both ways if we manually change the order of the parameters).
  if ($vid_left > $vid_right) {
    $aux = $vid_left;
    $vid_left = $vid_right;
    $vid_right = $aux;
  }

  // Builds the redirect Url.
  $redirect_url = Url::fromRoute('diff.revisions_diff', array(
    'node' => $nid,
    'left_revision' => $vid_left,
    'right_revision' => $vid_right,
    'filter' => $this->diffLayoutManager
      ->getDefaultLayout(),
  ));
  $form_state
    ->setRedirectUrl($redirect_url);
}