public function ConfigEntityRevisionsDeleteFormBase::submitForm in Config Entity Revisions 8
Same name and namespace in other branches
- 8.2 src/ConfigEntityRevisionsDeleteFormBase.php \Drupal\config_entity_revisions\ConfigEntityRevisionsDeleteFormBase::submitForm()
- 1.x src/ConfigEntityRevisionsDeleteFormBase.php \Drupal\config_entity_revisions\ConfigEntityRevisionsDeleteFormBase::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/
ConfigEntityRevisionsDeleteFormBase.php, line 192
Class
- ConfigEntityRevisionsDeleteFormBase
- Provides a form for reverting a config entity revision.
Namespace
Drupal\config_entity_revisionsCode
public function submitForm(array &$form, FormStateInterface $form_state) {
// Someone else may have deleted a revision so we can't assume the state
// when the form was rendered is still valid.
$revisions = $this->controller
->getRevisionIds($this->config_entity
->getContentEntityID());
if (count($revisions) == 1) {
\Drupal::messenger()
->addError(t('There is only one revision remaining. You may not delete it, sorry.'));
}
else {
if ($this->config_entity
->has_own_content()) {
$this->config_entity
->deleteRelatedContentEntities($this->revision->revision->value);
}
$this->controller
->deleteRevision($this->revision);
$this
->logUpdate();
$this
->displayUpdate();
}
if (count($revisions) > 2) {
$this
->setRevisionsFormRedirect($form_state);
}
else {
$this
->setBuildFormRedirect($form_state);
}
}