public function OpignoAnswerRevisionDeleteForm::submitForm in Opigno module 3.x
Same name and namespace in other branches
- 8 src/Form/OpignoAnswerRevisionDeleteForm.php \Drupal\opigno_module\Form\OpignoAnswerRevisionDeleteForm::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/ OpignoAnswerRevisionDeleteForm.php, line 108
Class
- OpignoAnswerRevisionDeleteForm
- Provides a form for deleting a Answer revision.
Namespace
Drupal\opigno_module\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->OpignoAnswerStorage
->deleteRevision($this->revision
->getRevisionId());
$date_formatter = \Drupal::service('date.formatter');
$this
->logger('content')
->notice('Answer: deleted %title revision %revision.', [
'%title' => $this->revision
->label(),
'%revision' => $this->revision
->getRevisionId(),
]);
\Drupal::messenger()
->addMessage(t('Revision from %revision-date of Answer %title has been deleted.', [
'%revision-date' => $date_formatter
->format($this->revision
->getRevisionCreationTime()),
'%title' => $this->revision
->label(),
]));
$form_state
->setRedirect('entity.opigno_answer.canonical', [
'opigno_answer' => $this->revision
->id(),
]);
if ($this->connection
->query('SELECT COUNT(DISTINCT vid) FROM {opigno_answer_field_revision} WHERE id = :id', [
':id' => $this->revision
->id(),
])
->fetchField() > 1) {
$form_state
->setRedirect('entity.opigno_answer.version_history', [
'opigno_answer' => $this->revision
->id(),
]);
}
}