You are here

public function EasyEmailRevisionDeleteForm::submitForm in Easy Email 2.0.x

Same name and namespace in other branches
  1. 8 src/Form/EasyEmailRevisionDeleteForm.php \Drupal\easy_email\Form\EasyEmailRevisionDeleteForm::submitForm()

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/EasyEmailRevisionDeleteForm.php, line 106

Class

EasyEmailRevisionDeleteForm
Provides a form for deleting a Email revision.

Namespace

Drupal\easy_email\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $this->EasyEmailStorage
    ->deleteRevision($this->revision
    ->getRevisionId());
  $this
    ->logger('content')
    ->notice('Email: deleted %title revision %revision.', [
    '%title' => $this->revision
      ->label(),
    '%revision' => $this->revision
      ->getRevisionId(),
  ]);
  \Drupal::messenger()
    ->addStatus(t('Revision from %revision-date of Email %title has been deleted.', [
    '%revision-date' => \Drupal::service('date.formatter')
      ->format($this->revision
      ->getRevisionCreationTime()),
    '%title' => $this->revision
      ->label(),
  ]));
  $form_state
    ->setRedirect('entity.easy_email.canonical', [
    'easy_email' => $this->revision
      ->id(),
  ]);
  if ($this->connection
    ->query('SELECT COUNT(DISTINCT vid) FROM {easy_email_field_revision} WHERE id = :id', [
    ':id' => $this->revision
      ->id(),
  ])
    ->fetchField() > 1) {
    $form_state
      ->setRedirect('entity.easy_email.version_history', [
      'easy_email' => $this->revision
        ->id(),
    ]);
  }
}