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.
12 class TermDeleteForm extends ContentEntityDeleteForm {
17 public function getCancelUrl() {
18 // The cancel URL is the vocabulary collection, terms have no global
20 return new Url('entity.taxonomy_vocabulary.collection');
26 protected function getRedirectUrl() {
27 return $this->getCancelUrl();
33 public function getDescription() {
34 return $this->t('Deleting a term will delete all its children if there are any. This action cannot be undone.');
40 protected function getDeletionMessage() {
41 return $this->t('Deleted term %name.', ['%name' => $this->entity->label()]);
47 public function submitForm(array &$form, FormStateInterface $form_state) {
48 parent::submitForm($form, $form_state);
50 /** @var \Drupal\Core\Entity\ContentEntityInterface $term */
51 $term = $this->getEntity();
52 if ($term->isDefaultTranslation()) {
53 $storage = $this->entityManager->getStorage('taxonomy_vocabulary');
54 $vocabulary = $storage->load($this->entity->bundle());
56 // @todo Move to storage http://drupal.org/node/1988712
57 taxonomy_check_vocabulary_hierarchy($vocabulary, ['tid' => $term->id()]);