diff --git a/core/modules/content_translation/content_translation.pages.inc b/core/modules/content_translation/content_translation.pages.inc index b6473ae..efb6615 100644 --- a/core/modules/content_translation/content_translation.pages.inc +++ b/core/modules/content_translation/content_translation.pages.inc @@ -243,45 +243,3 @@ function content_translation_prepare_translation(EntityInterface $entity, Langua $entity->addTranslation($target->id, $source_translation->getPropertyValues()); } } - -/** - * Form constructor for the translation deletion confirmation. - * - * @deprecated Use \Drupal\content_translation\Form\ContentTranslationForm::deleteTranslation() - */ -function content_translation_delete_confirm(array $form, array $form_state, EntityInterface $entity, Language $language) { - $controller = content_translation_controller($entity->entityType()); - $uri = $entity->uri('drupal:content-translation-overview'); - - return confirm_form( - $form, - t('Are you sure you want to delete the @language translation of %label?', array('@language' => $language->name, '%label' => $entity->label())), - $uri['path'], - t('This action cannot be undone.'), - t('Delete'), - t('Cancel') - ); -} - -/** - * Form submission handler for content_translation_delete_confirm(). - */ -function content_translation_delete_confirm_submit(array $form, array &$form_state) { - list($entity, $language) = $form_state['build_info']['args']; - $controller = content_translation_controller($entity->entityType()); - - // Remove the translated values. - $entity->removeTranslation($language->id); - $entity->save(); - - // Remove any existing path alias for the removed translation. - // @todo This should be taken care of by the Path module. - if (\Drupal::moduleHandler()->moduleExists('path')) { - $uri = $entity->uri(); - $conditions = array('source' => $uri['path'], 'langcode' => $language->id); - \Drupal::service('path.crud')->delete($conditions); - } - - $uri = $entity->uri('drupal:content-translation-overview'); - $form_state['redirect'] = $uri['path']; -} diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Form/ContentTranslationDeleteForm.php b/core/modules/content_translation/lib/Drupal/content_translation/Form/ContentTranslationDeleteForm.php new file mode 100644 index 0000000..0ddbfc6 --- /dev/null +++ b/core/modules/content_translation/lib/Drupal/content_translation/Form/ContentTranslationDeleteForm.php @@ -0,0 +1,94 @@ +entity = $this->getRequest()->attributes->get($_entity_type); + $uri = $this->entity->uri('drupal:content-translation-overview'); + $this->language = language_load($language); + return parent::buildForm($form, $form_state); + } + + /** + * {@inheritdoc} + */ + public function getConfirmText() { + return $this->t('Delete'); + } + + /** + * {@inheritdoc} + */ + public function getQuestion() { + return $this->t('Are you sure you want to delete the @language translation of %label?', array('@language' => $this->language->name, '%label' => $this->entity->label())); + } + + /** + * {@inheritdoc} + */ + public function getCancelRoute() { + $entity_info = $this->entity->entityInfo(); + return array( + 'route_name' => $entity_info['links']['drupal:content-translation-overview'], + 'route_parameters' => array( + $this->entity->entityType() => $this->entity->id(), + ), + ); + } + + /** + * {@inheritdoc} + */ + public function submitForm(array &$form, array &$form_state) { + // Remove the translated values. + $this->entity->removeTranslation($this->language->id); + $this->entity->save(); + + // Remove any existing path alias for the removed translation. + // @todo This should be taken care of by the Path module. + if (\Drupal::moduleHandler()->moduleExists('path')) { + $uri = $this->entity->uri(); + $conditions = array('source' => $uri['path'], 'langcode' => $this->language->id); + \Drupal::service('path.crud')->delete($conditions); + } + + $form_state['redirect_route'] = $this->getCancelRoute(); + } + +} diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Form/ContentTranslationForm.php b/core/modules/content_translation/lib/Drupal/content_translation/Form/ContentTranslationForm.php deleted file mode 100644 index 4ec42ba..0000000 --- a/core/modules/content_translation/lib/Drupal/content_translation/Form/ContentTranslationForm.php +++ /dev/null @@ -1,29 +0,0 @@ -attributes->get($request->attributes->get('_entity_type')); - module_load_include('pages.inc', 'content_translation'); - $language = language_load($language); - return drupal_get_form('content_translation_delete_confirm', $entity, $language); - } - -} diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Routing/ContentTranslationRouteSubscriber.php b/core/modules/content_translation/lib/Drupal/content_translation/Routing/ContentTranslationRouteSubscriber.php index 08dddca..b36c654 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/Routing/ContentTranslationRouteSubscriber.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Routing/ContentTranslationRouteSubscriber.php @@ -140,7 +140,7 @@ protected function routes(RouteCollection $collection) { $route = new Route( $path . '/delete/{language}', array( - '_content' => '\Drupal\content_translation\Form\ContentTranslationForm::deleteTranslation', + '_form' => '\Drupal\content_translation\Form\ContentTranslationDeleteForm', 'language' => NULL, '_title' => 'Delete', '_entity_type' => $entity_type,