diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Form/TermDelete.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Form/TermDelete.php index ec22b73..07ac408 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Form/TermDelete.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Form/TermDelete.php @@ -7,14 +7,17 @@ namespace Drupal\taxonomy\Form; +use Symfony\Component\DependencyInjection\ContainerInterface; +use Drupal\Core\ControllerInterface; +use Drupal\Core\Entity\EntityManager; use Drupal\Core\Form\ConfirmFormBase; -use Drupal\taxonomy\Plugin\Core\Entity\Term; +use Drupal\taxonomy\TermInterface; use Drupal\Core\Cache\Cache; /** * Provides a deletion confirmation form for taxonomy term. */ -class TermDelete extends ConfirmFormBase { +class TermDelete extends ConfirmFormBase implements ControllerInterface { /** * The term being deleted. @@ -24,6 +27,32 @@ class TermDelete extends ConfirmFormBase { protected $term; /** + * Stores the Entity manager. + * + * @var \Drupal\Core\Entity\EntityManager + */ + protected $entityManager; + + /** + * Constructs a new TermDelete object. + * + * @param \Drupal\Core\Entity\EntityManager $entity_manager + * The Entity manager. + */ + public function __construct(EntityManager $entity_manager) { + $this->entityManager = $entity_manager; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container) { + return new static( + $container->get('plugin.manager.entity') + ); + } + + /** * {@inheritdoc} */ public function getFormID() { @@ -61,7 +90,7 @@ protected function getConfirmText() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, Term $taxonomy_term = NULL) { + public function buildForm(array $form, array &$form_state, TermInterface $taxonomy_term = NULL) { $this->term = $taxonomy_term; return parent::buildForm($form, $form_state); } @@ -71,7 +100,8 @@ public function buildForm(array $form, array &$form_state, Term $taxonomy_term = */ public function submitForm(array &$form, array &$form_state) { $this->term->delete(); - taxonomy_check_vocabulary_hierarchy(entity_load('taxonomy_vocabulary', $this->term->bundle()), array('tid' => $this->term->id())); + // @todo Replace procedural code http://drupal.org/node/1980982 + taxonomy_check_vocabulary_hierarchy($this->entityManager->getStorageController('taxonomy_vocabulary')->load(array($this->term->bundle())), 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); $form_state['redirect'] = 'admin/structure/taxonomy'; diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Form/VocabularyDelete.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Form/VocabularyDelete.php index d755846..5e6fb0e 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Form/VocabularyDelete.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Form/VocabularyDelete.php @@ -8,7 +8,7 @@ namespace Drupal\taxonomy\Form; use Drupal\Core\Form\ConfirmFormBase; -use Drupal\taxonomy\Plugin\Core\Entity\Vocabulary; +use Drupal\taxonomy\VocabularyInterface; use Drupal\Core\Cache\Cache; /** @@ -61,7 +61,7 @@ protected function getConfirmText() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, Vocabulary $taxonomy_vocabulary = NULL) { + public function buildForm(array $form, array &$form_state, VocabularyInterface $taxonomy_vocabulary = NULL) { $this->vocabulary = $taxonomy_vocabulary; return parent::buildForm($form, $form_state); }