You are here

public function LingotekConfigTranslationService::uploadConfig in Lingotek Translation 8

Same name and namespace in other branches
  1. 8.2 src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::uploadConfig()
  2. 4.0.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::uploadConfig()
  3. 3.0.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::uploadConfig()
  4. 3.1.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::uploadConfig()
  5. 3.2.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::uploadConfig()
  6. 3.3.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::uploadConfig()
  7. 3.4.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::uploadConfig()
  8. 3.5.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::uploadConfig()
  9. 3.6.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::uploadConfig()
  10. 3.7.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::uploadConfig()
  11. 3.8.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::uploadConfig()

Uploads a document to the Lingotek service.

Parameters

string $mapper_id: The entity being uploaded.

Return value

boolean TRUE if the document was uploaded successfully, FALSE if not.

Overrides LingotekConfigTranslationServiceInterface::uploadConfig

File

src/LingotekConfigTranslationService.php, line 768
Contains \Drupal\lingotek\LingotekConfigTranslationService.

Class

LingotekConfigTranslationService
Service for managing Lingotek configuration translations.

Namespace

Drupal\lingotek

Code

public function uploadConfig($mapper_id) {
  $mapper = $this->mappers[$mapper_id];
  if (!empty($this
    ->getConfigDocumentId($mapper))) {
    return $this
      ->updateConfig($mapper_id);
  }
  $source_data = json_encode($this
    ->getConfigSourceData($mapper));
  $document_name = $mapper_id . ' (config): ' . $mapper
    ->getTitle();
  $document_id = $this->lingotek
    ->uploadDocument($document_name, $source_data, $this
    ->getConfigSourceLocale($mapper), NULL, $this->lingotekConfiguration
    ->getConfigProfile($mapper_id));
  if ($document_id) {
    $this
      ->setConfigDocumentId($mapper, $document_id);
    $this
      ->setConfigSourceStatus($mapper, Lingotek::STATUS_IMPORTING);
    $this
      ->setConfigTargetStatuses($mapper, Lingotek::STATUS_REQUEST);
    return $document_id;
  }
  return FALSE;
}