public function LibraryItemRevisionRevertForm::submitForm in Paragraphs 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
- modules/
paragraphs_library/ src/ Form/ LibraryItemRevisionRevertForm.php, line 102
Class
Namespace
Drupal\paragraphs_library\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$original_revision_timestamp = $this->revision
->getChangedTime();
$this->revision = $this
->prepareRevertedRevision($this->revision);
$this->revision->revision_log = $this
->t('Copy of the revision from %date.', [
'%date' => $this->dateFormatter
->format($original_revision_timestamp),
]);
$this->revision
->setChangedTime($this->time
->getRequestTime());
$this->revision
->save();
$this->messenger
->addMessage($this
->t('%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.paragraphs_library_item.version_history', [
'paragraphs_library_item' => $this->revision
->id(),
]);
}