public function SimpleMegaMenuRevisionDeleteForm::submitForm in Simple Mega Menu 8
Same name and namespace in other branches
- 2.0.x src/Form/SimpleMegaMenuRevisionDeleteForm.php \Drupal\simple_megamenu\Form\SimpleMegaMenuRevisionDeleteForm::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/ SimpleMegaMenuRevisionDeleteForm.php, line 117
Class
- SimpleMegaMenuRevisionDeleteForm
- Provides a form for deleting a Simple mega menu revision.
Namespace
Drupal\simple_megamenu\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->simpleMegaMenuStorage
->deleteRevision($this->revision
->getRevisionId());
$this
->logger('content')
->notice('Simple mega menu: deleted %title revision %revision.', [
'%title' => $this->revision
->label(),
'%revision' => $this->revision
->getRevisionId(),
]);
$this
->messenger()
->addStatus($this
->t('Revision from %revision-date of Simple mega menu %title has been deleted.', [
'%revision-date' => $this->dateFormatter
->format($this->revision
->getRevisionCreationTime()),
'%title' => $this->revision
->label(),
]));
$form_state
->setRedirect('entity.simple_mega_menu.canonical', [
'simple_mega_menu' => $this->revision
->id(),
]);
if ($this->connection
->query('SELECT COUNT(DISTINCT vid) FROM {simple_mega_menu_field_revision} WHERE id = :id', [
':id' => $this->revision
->id(),
])
->fetchField() > 1) {
$form_state
->setRedirect('entity.simple_mega_menu.version_history', [
'simple_mega_menu' => $this->revision
->id(),
]);
}
}