function ContentTranslationHandler::entityFormDeleteTranslation

Same name in other branches
  1. 8.9.x core/modules/content_translation/src/ContentTranslationHandler.php \Drupal\content_translation\ContentTranslationHandler::entityFormDeleteTranslation()
  2. 10 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 777

Class

ContentTranslationHandler
Base class for content translation handlers.

Namespace

Drupal\content_translation

Code

public 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->toUrl('delete-form'));
    }
    else {
        $form_state->setRedirect("entity.{$entity_type_id}.content_translation_delete", [
            $entity_type_id => $entity->id(),
            'language' => $form_object->getFormLangcode($form_state),
        ]);
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.