You are here

public function ScheduleRevisionDeleteForm::submitForm in Business Rules 8

Same name and namespace in other branches
  1. 2.x src/Form/ScheduleRevisionDeleteForm.php \Drupal\business_rules\Form\ScheduleRevisionDeleteForm::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/ScheduleRevisionDeleteForm.php, line 106

Class

ScheduleRevisionDeleteForm
Provides a form for deleting a Schedule revision.

Namespace

Drupal\business_rules\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $this->ScheduleStorage
    ->deleteRevision($this->revision
    ->getRevisionId());
  $this
    ->logger('content')
    ->notice('Schedule: deleted %title revision %revision.', [
    '%title' => $this->revision
      ->label(),
    '%revision' => $this->revision
      ->getRevisionId(),
  ]);
  drupal_set_message(t('Revision from %revision-date of Schedule %title has been deleted.', [
    '%revision-date' => format_date($this->revision
      ->getRevisionCreationTime()),
    '%title' => $this->revision
      ->label(),
  ]));
  $form_state
    ->setRedirect('entity.business_rules_schedule.canonical', [
    'schedule' => $this->revision
      ->id(),
  ]);
  if ($this->connection
    ->query('SELECT COUNT(DISTINCT vid) FROM {schedule_field_revision} WHERE id = :id', [
    ':id' => $this->revision
      ->id(),
  ])
    ->fetchField() > 1) {
    $form_state
      ->setRedirect('entity.business_rules_schedule.version_history', [
      'schedule' => $this->revision
        ->id(),
    ]);
  }
}