You are here

public function PetDiffRevisionOverviewForm::submitForm in Previewable email templates 8.3

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 RevisionOverviewForm::submitForm

File

src/Form/PetDiffRevisionOverviewForm.php, line 193

Class

PetDiffRevisionOverviewForm
Provides a form for Pet revision overview page.

Namespace

Drupal\pet\Form

Code

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

  // 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('entity.pet.revisions_diff', array(
    'pet' => $pid,
    'left_revision' => $vid_left,
    'right_revision' => $vid_right,
    'filter' => $this->diffLayoutManager
      ->getDefaultLayout(),
  ));
  $form_state
    ->setRedirectUrl($redirect_url);
}