You are here

public function EventRevisionDeleteForm::submitForm in Event 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/EventRevisionDeleteForm.php, line 106

Class

EventRevisionDeleteForm
Provides a form for deleting a Event revision.

Namespace

Drupal\event\Form

Code

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