You are here

function ContentTranslationHandler::entityFormDeleteTranslation in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/content_translation/src/ContentTranslationHandler.php \Drupal\content_translation\ContentTranslationHandler::entityFormDeleteTranslation()

Form submission handler for ContentTranslationHandler::entityFormAlter().

Takes care of content translation deletion.

File

core/modules/content_translation/src/ContentTranslationHandler.php, line 682
Contains \Drupal\content_translation\ContentTranslationHandler.

Class

ContentTranslationHandler
Base class for content translation handlers.

Namespace

Drupal\content_translation

Code

function entityFormDeleteTranslation($form, FormStateInterface $form_state) {

  /** @var \Drupal\Core\Entity\ContentEntityFormInterface $form_object */
  $form_object = $form_state
    ->getFormObject();

  /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
  $entity = $form_object
    ->getEntity();
  $entity_type_id = $entity
    ->getEntityTypeId();
  if ($entity
    ->access('delete') && $this->entityType
    ->hasLinkTemplate('delete-form')) {
    $form_state
      ->setRedirectUrl($entity
      ->urlInfo('delete-form'));
  }
  else {
    $form_state
      ->setRedirect("entity.{$entity_type_id}.content_translation_delete", [
      $entity_type_id => $entity
        ->id(),
      'language' => $form_object
        ->getFormLangcode($form_state),
    ]);
  }
}