diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Form/TermDelete.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Form/TermDeleteForm.php similarity index 62% rename from core/modules/taxonomy/lib/Drupal/taxonomy/Form/TermDelete.php rename to core/modules/taxonomy/lib/Drupal/taxonomy/Form/TermDeleteForm.php index 7354809..be78113 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Form/TermDelete.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Form/TermDeleteForm.php @@ -2,7 +2,7 @@ /** * @file - * Contains \Drupal\taxonomy\Form\TermDelete. + * Contains \Drupal\taxonomy\Form\TermDeleteForm. */ namespace Drupal\taxonomy\Form; @@ -10,24 +10,16 @@ use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\Core\Controller\ControllerInterface; use Drupal\Core\Entity\EntityStorageControllerInterface; -use Drupal\Core\Form\ConfirmFormBase; -use Drupal\taxonomy\TermInterface; +use Drupal\Core\Entity\EntityConfirmFormBase; use Drupal\Core\Cache\Cache; /** * Provides a deletion confirmation form for taxonomy term. */ -class TermDelete extends ConfirmFormBase implements ControllerInterface { +class TermDeleteForm extends EntityConfirmFormBase implements ControllerInterface { /** - * The term being deleted. - * - * @var \Drupal\taxonomy\TermInterface - */ - protected $term; - - /** - * Stores the Entity manager. + * The taxonomy vocabulary storage controller. * * @var \Drupal\Core\Entity\EntityStorageControllerInterface */ @@ -62,52 +54,41 @@ public function getFormID() { /** * {@inheritdoc} */ - protected function getQuestion() { - return t('Are you sure you want to delete the term %title?', array('%title' => $this->term->label())); + public function getQuestion() { + return t('Are you sure you want to delete the term %title?', array('%title' => $this->entity->label())); } /** * {@inheritdoc} */ - protected function getCancelPath() { + public function getCancelPath() { return 'admin/structure/taxonomy'; } /** * {@inheritdoc} */ - protected function getDescription() { + public function getDescription() { return t('Deleting a term will delete all its children if there are any. This action cannot be undone.'); } /** * {@inheritdoc} */ - protected function getConfirmText() { + public function getConfirmText() { return t('Delete'); } /** * {@inheritdoc} - * - * @param \Drupal\taxonomy\TermInterface $taxonomy_term - * The taxonomy term to delete. - */ - public function buildForm(array $form, array &$form_state, TermInterface $taxonomy_term = NULL) { - $this->term = $taxonomy_term; - return parent::buildForm($form, $form_state); - } - - /** - * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { - $this->term->delete(); - $vocabulary = $this->storageController->load(array($this->term->bundle())); + public function submit(array $form, array &$form_state) { + $this->entity->delete(); + $vocabulary = $this->storageController->load(array($this->entity->bundle())); // @todo Move to storage controller http://drupal.org/node/1988712 - taxonomy_check_vocabulary_hierarchy(reset($vocabulary), array('tid' => $this->term->id())); - drupal_set_message(t('Deleted term %name.', array('%name' => $this->term->label()))); - watchdog('taxonomy', 'Deleted term %name.', array('%name' => $this->term->label()), WATCHDOG_NOTICE); + taxonomy_check_vocabulary_hierarchy(reset($vocabulary), array('tid' => $this->entity->id())); + drupal_set_message(t('Deleted term %name.', array('%name' => $this->entity->label()))); + watchdog('taxonomy', 'Deleted term %name.', array('%name' => $this->entity->label()), WATCHDOG_NOTICE); $form_state['redirect'] = 'admin/structure/taxonomy'; Cache::invalidateTags(array('content' => TRUE)); } diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Form/VocabularyDelete.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Form/VocabularyDeleteForm.php similarity index 46% rename from core/modules/taxonomy/lib/Drupal/taxonomy/Form/VocabularyDelete.php rename to core/modules/taxonomy/lib/Drupal/taxonomy/Form/VocabularyDeleteForm.php index 9aeb127..77c38a5 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Form/VocabularyDelete.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Form/VocabularyDeleteForm.php @@ -2,26 +2,18 @@ /** * @file - * Contains \Drupal\taxonomy\Form\VocabularyDelete. + * Contains \Drupal\taxonomy\Form\VocabularyDeleteForm. */ namespace Drupal\taxonomy\Form; -use Drupal\Core\Form\ConfirmFormBase; -use Drupal\taxonomy\VocabularyInterface; +use Drupal\Core\Entity\EntityConfirmFormBase; use Drupal\Core\Cache\Cache; /** * Provides a deletion confirmation form for taxonomy vocabulary. */ -class VocabularyDelete extends ConfirmFormBase { - - /** - * The vocabulary being deleted. - * - * @var \Drupal\taxonomy\VocabularyInterface - */ - protected $vocabulary; +class VocabularyDeleteForm extends EntityConfirmFormBase { /** * {@inheritdoc} @@ -33,49 +25,38 @@ public function getFormID() { /** * {@inheritdoc} */ - protected function getQuestion() { - return t('Are you sure you want to delete the vocabulary %title?', array('%title' => $this->vocabulary->label())); + public function getQuestion() { + return t('Are you sure you want to delete the vocabulary %title?', array('%title' => $this->entity->label())); } /** * {@inheritdoc} */ - protected function getCancelPath() { + public function getCancelPath() { return 'admin/structure/taxonomy'; } /** * {@inheritdoc} */ - protected function getDescription() { + public function getDescription() { return t('Deleting a vocabulary will delete all the terms in it. This action cannot be undone.'); } /** * {@inheritdoc} */ - protected function getConfirmText() { + public function getConfirmText() { return t('Delete'); } /** * {@inheritdoc} - * - * @param \Drupal\taxonomy\VocabularyInterface $taxonomy_vocabulary - * The taxonomy vocabulary to delete. - */ - public function buildForm(array $form, array &$form_state, VocabularyInterface $taxonomy_vocabulary = NULL) { - $this->vocabulary = $taxonomy_vocabulary; - return parent::buildForm($form, $form_state); - } - - /** - * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { - $this->vocabulary->delete(); - drupal_set_message(t('Deleted vocabulary %name.', array('%name' => $this->vocabulary->label()))); - watchdog('taxonomy', 'Deleted vocabulary %name.', array('%name' => $this->vocabulary->label()), WATCHDOG_NOTICE); + public function submit(array $form, array &$form_state) { + $this->entity->delete(); + drupal_set_message(t('Deleted vocabulary %name.', array('%name' => $this->entity->label()))); + watchdog('taxonomy', 'Deleted vocabulary %name.', array('%name' => $this->entity->label()), WATCHDOG_NOTICE); $form_state['redirect'] = 'admin/structure/taxonomy'; Cache::invalidateTags(array('content' => TRUE)); } diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Core/Entity/Term.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Core/Entity/Term.php index 0bf0aac..2ad4d4d 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Core/Entity/Term.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Core/Entity/Term.php @@ -27,7 +27,8 @@ * "render" = "Drupal\taxonomy\TermRenderController", * "access" = "Drupal\taxonomy\TermAccessController", * "form" = { - * "default" = "Drupal\taxonomy\TermFormController" + * "default" = "Drupal\taxonomy\TermFormController", + * "delete" = "Drupal\taxonomy\Form\TermDeleteForm" * }, * "translation" = "Drupal\taxonomy\TermTranslationController" * }, diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Core/Entity/Vocabulary.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Core/Entity/Vocabulary.php index dab74c6..1d3b709 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Core/Entity/Vocabulary.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Core/Entity/Vocabulary.php @@ -25,7 +25,8 @@ * "access" = "Drupal\taxonomy\VocabularyAccessController", * "list" = "Drupal\taxonomy\VocabularyListController", * "form" = { - * "default" = "Drupal\taxonomy\VocabularyFormController" + * "default" = "Drupal\taxonomy\VocabularyFormController", + * "delete" = "Drupal\taxonomy\Form\VocabularyDeleteForm" * } * }, * config_prefix = "taxonomy.vocabulary", diff --git a/core/modules/taxonomy/taxonomy.routing.yml b/core/modules/taxonomy/taxonomy.routing.yml index 083909b..728a68e 100644 --- a/core/modules/taxonomy/taxonomy.routing.yml +++ b/core/modules/taxonomy/taxonomy.routing.yml @@ -1,16 +1,16 @@ taxonomy_term_delete: pattern: '/taxonomy/term/{taxonomy_term}/delete' defaults: - _form: '\Drupal\taxonomy\Form\TermDelete' + _entity_form: taxonomy_term.delete requirements: - _entity_access: 'taxonomy_term.delete' + _entity_access: taxonomy_term.delete taxonomy_vocabulary_delete: pattern: '/admin/structure/taxonomy/manage/{taxonomy_vocabulary}/delete' defaults: - _form: '\Drupal\taxonomy\Form\VocabularyDelete' + _entity_form: taxonomy_vocabulary.delete requirements: - _entity_access: 'taxonomy_vocabulary.delete' + _entity_access: taxonomy_vocabulary.delete taxonomy_vocabulary_list: pattern: '/admin/structure/taxonomy'