diff --git a/core/lib/Drupal/Core/Entity/ContentEntityDeleteForm.php b/core/lib/Drupal/Core/Entity/ContentEntityDeleteForm.php index 6116520..e86495e 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityDeleteForm.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityDeleteForm.php @@ -23,6 +23,39 @@ class ContentEntityDeleteForm extends ContentEntityConfirmFormBase { /** * {@inheritdoc} */ + public function buildForm(array $form, FormStateInterface $form_state) { + $form = parent::buildForm($form, $form_state); + + /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */ + $entity = $this->getEntity(); + if ($entity->isDefaultTranslation()) { + $languages = []; + foreach ($entity->getTranslationLanguages() as $language) { + $languages[] = $language->getName(); + } + + if (count($languages) > 1) { + $form['entity_deletes'] = array( + '#theme' => 'item_list', + '#title' => $this->t('The following @entity-type translations will be deleted:', [ + '@entity-type' => $entity->getEntityType()->getLowercaseLabel() + ]), + '#items' => $languages, + ); + + $form['actions']['submit']['#value'] = $this->t('Delete all translations'); + } + } + else { + $form['actions']['submit']['#value'] = $this->t('Delete @language translation', array('@language' => $entity->language()->getName()));; + } + + return $form; + } + + /** + * {@inheritdoc} + */ public function submitForm(array &$form, FormStateInterface $form_state) { /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */ $entity = $this->getEntity(); diff --git a/core/lib/Drupal/Core/Entity/EntityDeleteFormTrait.php b/core/lib/Drupal/Core/Entity/EntityDeleteFormTrait.php index d35bcea..433945c 100644 --- a/core/lib/Drupal/Core/Entity/EntityDeleteFormTrait.php +++ b/core/lib/Drupal/Core/Entity/EntityDeleteFormTrait.php @@ -9,6 +9,7 @@ use Drupal\Core\Config\Entity\ConfigDependencyDeleteFormTrait; use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\Url; /** * Provides a trait for an entity deletion form. @@ -85,8 +86,8 @@ public function getCancelUrl() { return $entity->urlInfo('collection'); } else { - // Otherwise fall back to the default link template. - return $entity->urlInfo(); + // Otherwise fall back to the front page. + return Url::fromRoute(''); } } diff --git a/core/modules/content_translation/content_translation.module b/core/modules/content_translation/content_translation.module index 5448046..4a71db7 100644 --- a/core/modules/content_translation/content_translation.module +++ b/core/modules/content_translation/content_translation.module @@ -280,11 +280,8 @@ function content_translation_form_alter(array &$form, FormStateInterface $form_s $entity = $form_object->getEntity(); if ($entity instanceof ContentEntityInterface && $entity->isTranslatable() && count($entity->getTranslationLanguages()) > 1) { - $controller = \Drupal::entityManager()->getHandler($entity->getEntityTypeId(), 'translation'); - if ($form_object->getOperation() == 'delete') { - $controller->entityDeleteFormAlter($form, $form_state, $entity); - } - else { + if ($form_object->getOperation() != 'delete') { + $controller = \Drupal::entityManager()->getHandler($entity->getEntityTypeId(), 'translation'); $controller->entityFormAlter($form, $form_state, $entity); } diff --git a/core/modules/content_translation/src/ContentTranslationHandler.php b/core/modules/content_translation/src/ContentTranslationHandler.php index 3f82a78..0bd26f4 100644 --- a/core/modules/content_translation/src/ContentTranslationHandler.php +++ b/core/modules/content_translation/src/ContentTranslationHandler.php @@ -9,7 +9,6 @@ use Drupal\Core\Access\AccessResult; use Drupal\Core\DependencyInjection\DependencySerializationTrait; -use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Entity\EntityHandlerInterface; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityTypeInterface; @@ -18,7 +17,6 @@ use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Language\LanguageManagerInterface; use Drupal\Core\Render\Element; -use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\user\Entity\User; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -29,7 +27,6 @@ */ class ContentTranslationHandler implements ContentTranslationHandlerInterface, EntityHandlerInterface { use DependencySerializationTrait; - use StringTranslationTrait; /** * The type of the entity being translated. @@ -605,33 +602,6 @@ function entityFormDelete($form, FormStateInterface $form_state) { } /** - * {@inheritdoc} - */ - public function entityDeleteFormAlter(array &$form, FormStateInterface $form_state, ContentEntityInterface $entity) { - if ($entity->isDefaultTranslation()) { - $languages = []; - foreach ($entity->getTranslationLanguages() as $language) { - $languages[] = $language->getName(); - } - - if (count($languages) > 1) { - $form['entity_deletes'] = array( - '#theme' => 'item_list', - '#title' => $this->t('The following @entity-type translations will be deleted:', [ - '@entity-type' => $entity->getEntityType()->getLowercaseLabel() - ]), - '#items' => $languages, - ); - - $form['actions']['submit']['#value'] = $this->t('Delete all translations'); - } - } - else { - $form['actions']['submit']['#value'] = $this->t('Delete @language translation', array('@language' => $entity->language()->getName()));; - } - } - - /** * Form submission handler for ContentTranslationHandler::entityFormAlter(). * * Takes care of content translation deletion. diff --git a/core/modules/content_translation/src/ContentTranslationHandlerInterface.php b/core/modules/content_translation/src/ContentTranslationHandlerInterface.php index 759c3b7..d21e287 100644 --- a/core/modules/content_translation/src/ContentTranslationHandlerInterface.php +++ b/core/modules/content_translation/src/ContentTranslationHandlerInterface.php @@ -77,16 +77,4 @@ public function retranslate(EntityInterface $entity, $langcode = NULL); */ public function entityFormAlter(array &$form, FormStateInterface $form_state, EntityInterface $entity); - /** - * Performs the needed alterations to the entity delete form. - * - * @param array $form - * The entity delete form to be altered to provide the translation workflow. - * @param \Drupal\Core\Form\FormStateInterface $form_state - * The current state of the form. - * @param \Drupal\Core\Entity\ContentEntityInterface $entity - * The entity being deleted. - */ - public function entityDeleteFormAlter(array &$form, FormStateInterface $form_state, ContentEntityInterface $entity); - } diff --git a/core/modules/node/src/Form/NodeDeleteForm.php b/core/modules/node/src/Form/NodeDeleteForm.php index cd36d98..80a12f6 100644 --- a/core/modules/node/src/Form/NodeDeleteForm.php +++ b/core/modules/node/src/Form/NodeDeleteForm.php @@ -42,16 +42,6 @@ protected function getDeletionMessage() { /** * {@inheritdoc} */ - public function submitForm(array &$form, FormStateInterface $form_state) { - parent::submitForm($form, $form_state); - if ($this->getEntity()->isDefaultTranslation()) { - $form_state->setRedirect(''); - } - } - - /** - * {@inheritdoc} - */ protected function logDeletionMessage() { /** @var \Drupal\node\NodeInterface $entity */ $entity = $this->getEntity();