You are here

public function LingotekConfigTranslationService::saveTargetData in Lingotek Translation 8.2

Same name and namespace in other branches
  1. 8 src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::saveTargetData()
  2. 4.0.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::saveTargetData()
  3. 3.0.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::saveTargetData()
  4. 3.1.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::saveTargetData()
  5. 3.2.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::saveTargetData()
  6. 3.3.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::saveTargetData()
  7. 3.4.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::saveTargetData()
  8. 3.5.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::saveTargetData()
  9. 3.6.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::saveTargetData()
  10. 3.7.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::saveTargetData()
  11. 3.8.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::saveTargetData()
1 call to LingotekConfigTranslationService::saveTargetData()
LingotekConfigTranslationService::downloadDocument in src/LingotekConfigTranslationService.php
Downloads a document from the Lingotek service for a given locale.

File

src/LingotekConfigTranslationService.php, line 859

Class

LingotekConfigTranslationService
Service for managing Lingotek configuration translations.

Namespace

Drupal\lingotek

Code

public function saveTargetData(ConfigEntityInterface $entity, $langcode, $data) {

  // Allow other modules to alter the translation before it is saved.
  \Drupal::moduleHandler()
    ->invokeAll('lingotek_config_entity_translation_presave', [
    &$entity,
    $langcode,
    &$data,
  ]);
  if ($entity
    ->getEntityTypeId() == 'field_config') {
    $id = $entity
      ->getTargetEntityTypeId();
    $mapper = clone $this->mappers[$id . '_fields'];
    $mapper
      ->setEntity($entity);
  }
  else {
    $mapper = clone $this->mappers[$entity
      ->getEntityTypeId()];
    $mapper
      ->setEntity($entity);
  }

  // For retro-compatibility, if there is only one config name, we expand our
  // data.
  $names = $mapper
    ->getConfigNames();
  if (count($names) == 1) {
    $expanded[$names[0]] = $data;
  }
  else {
    $expanded = $data;
  }
  $this
    ->saveConfigTargetData($mapper, $langcode, $expanded);
}