function ContentEntityDeleteForm::submitForm
Same name in other branches
- 9 core/lib/Drupal/Core/Entity/ContentEntityDeleteForm.php \Drupal\Core\Entity\ContentEntityDeleteForm::submitForm()
- 8.9.x core/lib/Drupal/Core/Entity/ContentEntityDeleteForm.php \Drupal\Core\Entity\ContentEntityDeleteForm::submitForm()
- 11.x core/lib/Drupal/Core/Entity/ContentEntityDeleteForm.php \Drupal\Core\Entity\ContentEntityDeleteForm::submitForm()
Overrides EntityDeleteFormTrait::submitForm
File
-
core/
lib/ Drupal/ Core/ Entity/ ContentEntityDeleteForm.php, line 58
Class
- ContentEntityDeleteForm
- Provides a generic base class for a content entity deletion form.
Namespace
Drupal\Core\EntityCode
public function submitForm(array &$form, FormStateInterface $form_state) {
/** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
$entity = $this->getEntity();
$message = $this->getDeletionMessage();
// Make sure that deleting a translation does not delete the whole entity.
if (!$entity->isDefaultTranslation()) {
$untranslated_entity = $entity->getUntranslated();
$untranslated_entity->removeTranslation($entity->language()
->getId());
$untranslated_entity->save();
$form_state->setRedirectUrl($untranslated_entity->toUrl('canonical'));
}
else {
$entity->delete();
$form_state->setRedirectUrl($this->getRedirectUrl());
}
$this->messenger()
->addStatus($message);
$this->logDeletionMessage();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.