public function SupportTicketRevisionRevertForm::submitForm in Support Ticketing System 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/
support_ticket/ src/ Form/ SupportTicketRevisionRevertForm.php, line 103 - Contains \Drupal\support_ticket\Form\SupportTicketRevisionRevertForm.
Class
- SupportTicketRevisionRevertForm
- Provides a form for reverting a support ticket revision.
Namespace
Drupal\support_ticket\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$revision = $this
->prepareRevertedRevision($this->revision);
// The revision timestamp will be updated when the revision is saved. Keep the
// original one for the confirmation message.
$original_revision_timestamp = $revision
->getRevisionCreationTime();
$revision->revision_log = t('Copy of the revision from %date.', array(
'%date' => format_date($original_revision_timestamp),
));
$revision
->save();
$this
->logger('content')
->notice('@type: reverted %title revision %revision.', array(
'@type' => $this->revision
->bundle(),
'%title' => $this->revision
->label(),
'%revision' => $this->revision
->getRevisionId(),
));
drupal_set_message(t('@type %title has been reverted to the revision from %revision-date.', array(
'@type' => support_ticket_get_type_label($this->revision),
'%title' => $this->revision
->label(),
'%revision-date' => format_date($original_revision_timestamp),
)));
$form_state
->setRedirect('entity.support_ticket.version_history', array(
'support_ticket' => $this->revision
->id(),
));
}