function EntityOperations::entityTranslationDelete

Same name in other branches
  1. 9 core/modules/content_moderation/src/EntityOperations.php \Drupal\content_moderation\EntityOperations::entityTranslationDelete()
  2. 8.9.x core/modules/content_moderation/src/EntityOperations.php \Drupal\content_moderation\EntityOperations::entityTranslationDelete()
  3. 11.x core/modules/content_moderation/src/EntityOperations.php \Drupal\content_moderation\EntityOperations::entityTranslationDelete()

Parameters

\Drupal\Core\Entity\EntityInterface $translation: The entity translation being deleted.

See also

hook_entity_translation_delete()

File

core/modules/content_moderation/src/EntityOperations.php, line 256

Class

EntityOperations
Defines a class for reacting to entity events.

Namespace

Drupal\content_moderation

Code

public function entityTranslationDelete(EntityInterface $translation) {
    
    /** @var \Drupal\Core\Entity\ContentEntityInterface $translation */
    if (!$translation->isDefaultTranslation()) {
        $langcode = $translation->language()
            ->getId();
        $content_moderation_state = ContentModerationStateEntity::loadFromModeratedEntity($translation);
        if ($content_moderation_state && $content_moderation_state->hasTranslation($langcode)) {
            $content_moderation_state->removeTranslation($langcode);
            ContentModerationStateEntity::updateOrCreateFromEntity($content_moderation_state);
        }
    }
}

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