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