You are here

protected function EntityProcessorBase::getEntityTranslations in Content Synchronizer 8

Same name and namespace in other branches
  1. 8.2 src/Processors/Entity/EntityProcessorBase.php \Drupal\content_synchronizer\Processors\Entity\EntityProcessorBase::getEntityTranslations()
  2. 3.x src/Processors/Entity/EntityProcessorBase.php \Drupal\content_synchronizer\Processors\Entity\EntityProcessorBase::getEntityTranslations()

Return the entity translations.

Parameters

\Drupal\Core\Entity\Entity $entity: The entity.

Return value

array|\Drupal\Core\Language\LanguageInterface[] The array of translations.

2 calls to EntityProcessorBase::getEntityTranslations()
EntityProcessorBase::export in src/Processors/Entity/EntityProcessorBase.php
Export the entity and return the gid if exists, else false.
EntityProcessorBase::getEntityToImport in src/Processors/Entity/EntityProcessorBase.php
Return the entity to import.

File

src/Processors/Entity/EntityProcessorBase.php, line 162

Class

EntityProcessorBase
The entity processor base.

Namespace

Drupal\content_synchronizer\Processors\Entity

Code

protected function getEntityTranslations(Entity $entity) {
  $translations = [];
  foreach ($entity
    ->getTranslationLanguages() as $languageId => $data) {
    $translations[$languageId] = \Drupal::service('entity.repository')
      ->getTranslationFromContext($entity, $languageId);
  }
  return $translations;
}