You are here

public function UserRevisionDeleteForm::submitForm in User Revision 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/UserRevisionDeleteForm.php, line 93

Class

UserRevisionDeleteForm
Provides a form for delete a user revision.

Namespace

Drupal\user_revision\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $this->userStorage
    ->deleteRevision($this->revision
    ->getRevisionId());
  $this
    ->logger('user_revision')
    ->notice('user: deleted %name revision %revision.', array(
    '%name' => $this->revision
      ->label(),
    '%revision' => $this->revision
      ->getRevisionId(),
  ));
  $this
    ->messenger()
    ->addStatus(t('Revision from %revision-date of user %name has been deleted.', array(
    '%revision-date' => \Drupal::service('date.formatter')
      ->format($this->revision->revision_timestamp->value),
    '%name' => $this->revision
      ->label(),
  )));
  $form_state
    ->setRedirect('entity.user.canonical', array(
    'user' => $this->revision
      ->id(),
  ));
  if (user_revision_count($this->revision) > 1) {
    $form_state
      ->setRedirect('entity.user.version_history', array(
      'user' => $this->revision
        ->id(),
    ));
  }
}