You are here

public function HomeboxLayoutRevisionDeleteForm::submitForm in Homebox 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/HomeboxLayoutRevisionDeleteForm.php, line 122

Class

HomeboxLayoutRevisionDeleteForm
Provides a form for deleting a Homebox Layout revision.

Namespace

Drupal\homebox\Form

Code

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