3 namespace Drupal\taxonomy\Form;
5 use Drupal\Core\Form\FormStateInterface;
6 use Drupal\Core\Entity\ContentEntityDeleteForm;
10 * Provides a deletion confirmation form for taxonomy term.
14 class TermDeleteForm extends ContentEntityDeleteForm {
19 public function getCancelUrl() {
20 // The cancel URL is the vocabulary collection, terms have no global
22 return new Url('entity.taxonomy_vocabulary.collection');
28 protected function getRedirectUrl() {
29 return $this->getCancelUrl();
35 public function getDescription() {
36 return $this->t('Deleting a term will delete all its children if there are any. This action cannot be undone.');
42 protected function getDeletionMessage() {
43 return $this->t('Deleted term %name.', ['%name' => $this->entity->label()]);
49 public function submitForm(array &$form, FormStateInterface $form_state) {
50 parent::submitForm($form, $form_state);
52 /** @var \Drupal\Core\Entity\ContentEntityInterface $term */
53 $term = $this->getEntity();
54 if ($term->isDefaultTranslation()) {
55 $storage = $this->entityManager->getStorage('taxonomy_vocabulary');
56 $vocabulary = $storage->load($this->entity->bundle());
58 // @todo Move to storage http://drupal.org/node/1988712
59 taxonomy_check_vocabulary_hierarchy($vocabulary, ['tid' => $term->id()]);