function ContentTranslationHandler::entityFormDeleteTranslation

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

Class

ContentTranslationHandler
Base class for content translation handlers.

Namespace

Drupal\content_translation

Code

public function entityFormDeleteTranslation($form, FormStateInterface $form_state) {
    @trigger_error('Calling ContentTranslationHandler::entityFormDeleteTranslation() is deprecated in drupal:10.2.0 and will be removed in drupal:11.0.0. See https://www.drupal.org/node/3375492', E_USER_DEPRECATED);
    
    /** @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.