ContentEntityStorageBase::invokeTranslationHooks

protected ContentEntityStorageBase::invokeTranslationHooks(ContentEntityInterface $entity)

Checks translation statuses and invoke the related hooks if needed.

Parameters

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

File

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

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));
    }
  }
}
doc_Drupal
2016-10-29 08:57:35
Comments
Leave a Comment

Please login to continue.