public function FlaggingCollectionRevisionRevertForm::submitForm in Flag Lists 8
Same name and namespace in other branches
- 4.0.x src/Form/FlaggingCollectionRevisionRevertForm.php \Drupal\flag_lists\Form\FlaggingCollectionRevisionRevertForm::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/ FlaggingCollectionRevisionRevertForm.php, line 113
Class
- FlaggingCollectionRevisionRevertForm
- Provides a form for reverting a Flagging collection revision.
Namespace
Drupal\flag_lists\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
// The revision timestamp will be updated when the revision is saved. Keep
// the original one for the confirmation message.
$original_revision_timestamp = $this->revision
->getRevisionCreationTime();
$this->revision = $this
->prepareRevertedRevision($this->revision, $form_state);
$this->revision->revision_log = $this
->t('Copy of the revision from %date.', [
'%date' => $this->dateFormatter
->format($original_revision_timestamp),
]);
$this->revision
->save();
$this
->logger('content')
->notice('Flagging collection: reverted %title revision %revision.', [
'%title' => $this->revision
->label(),
'%revision' => $this->revision
->getRevisionId(),
]);
$this
->messenger()
->addMessage(t('Flagging collection %title has been reverted to the revision from %revision-date.', [
'%title' => $this->revision
->label(),
'%revision-date' => $this->dateFormatter
->format($original_revision_timestamp),
]));
$form_state
->setRedirect('entity.flagging_collection.version_history', [
'flagging_collection' => $this->revision
->id(),
]);
}