ContentTranslationHandler::entityFormDeleteTranslation

ContentTranslationHandler::entityFormDeleteTranslation($form, FormStateInterface $form_state)

Form submission handler for ContentTranslationHandler::entityFormAlter().

Takes care of content translation deletion.

File

core/modules/content_translation/src/ContentTranslationHandler.php, line 677

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),
    ]);
  }
}
doc_Drupal
2016-10-29 08:58:14
Comments
Leave a Comment

Please login to continue.