function ContentEntityStorageBase::invokeTranslationHooks

Same name in other branches
  1. 9 core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php \Drupal\Core\Entity\ContentEntityStorageBase::invokeTranslationHooks()
  2. 8.9.x core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php \Drupal\Core\Entity\ContentEntityStorageBase::invokeTranslationHooks()
  3. 11.x core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php \Drupal\Core\Entity\ContentEntityStorageBase::invokeTranslationHooks()

Checks translation statuses and invokes the related hooks if needed.

Parameters

\Drupal\Core\Entity\ContentEntityInterface $entity: The entity being saved.

1 call to ContentEntityStorageBase::invokeTranslationHooks()
ContentEntityStorageBase::doPostSave in core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php
Performs post save entity processing.

File

core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php, line 839

Class

ContentEntityStorageBase
Base class for content entity storage handlers.

Namespace

Drupal\Core\Entity

Code

protected function invokeTranslationHooks(ContentEntityInterface $entity) {
    $translations = $entity->getTranslationLanguages(FALSE);
    $original_translations = $entity->original
        ->getTranslationLanguages(FALSE);
    $all_translations = array_keys($translations + $original_translations);
    // Notify modules of translation insertion/deletion.
    foreach ($all_translations as $langcode) {
        if (isset($translations[$langcode]) && !isset($original_translations[$langcode])) {
            $this->invokeHook('translation_insert', $entity->getTranslation($langcode));
        }
        elseif (!isset($translations[$langcode]) && isset($original_translations[$langcode])) {
            $this->invokeHook('translation_delete', $entity->original
                ->getTranslation($langcode));
        }
    }
}

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