public function LingotekConfigTranslationService::setJobId in Lingotek Translation 3.4.x
Same name and namespace in other branches
- 8.2 src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::setJobId()
- 4.0.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::setJobId()
- 3.0.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::setJobId()
- 3.1.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::setJobId()
- 3.2.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::setJobId()
- 3.3.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::setJobId()
- 3.5.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::setJobId()
- 3.6.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::setJobId()
- 3.7.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::setJobId()
- 3.8.x src/LingotekConfigTranslationService.php \Drupal\lingotek\LingotekConfigTranslationService::setJobId()
Sets the job ID of a given entity.
Parameters
\Drupal\Core\Config\Entity\ConfigEntityInterface $entity: The entity which we want the document id.
$job_id: The job ID being saved.
bool $update_tms: (Optional) Flag indicating if the change should be communicated to the TMS. False by default.
Return value
\Drupal\Core\Config\Entity\ConfigEntityInterface Returns the entity which job ID is saved.
Throws
\Drupal\lingotek\Exception\LingotekPaymentRequiredException
\Drupal\lingotek\Exception\LingotekDocumentArchivedException
\Drupal\lingotek\Exception\LingotekDocumentLockedException
\Drupal\lingotek\Exception\LingotekApiException
Overrides LingotekConfigTranslationServiceInterface::setJobId
2 calls to LingotekConfigTranslationService::setJobId()
- LingotekConfigTranslationService::updateDocument in src/
LingotekConfigTranslationService.php - Resends a document to the translation service.
- LingotekConfigTranslationService::uploadDocument in src/
LingotekConfigTranslationService.php - Uploads a document to the Lingotek service.
File
- src/
LingotekConfigTranslationService.php, line 1689
Class
- LingotekConfigTranslationService
- Service for managing Lingotek configuration translations.
Namespace
Drupal\lingotekCode
public function setJobId(ConfigEntityInterface $entity, $job_id, $update_tms = FALSE) {
$newDocumentID = FALSE;
$metadata = LingotekConfigMetadata::loadByConfigName($entity
->getEntityTypeId() . '.' . $entity
->id());
if ($update_tms && ($document_id = $this
->getDocumentId($entity))) {
try {
$newDocumentID = $this->lingotek
->updateDocument($document_id, NULL, NULL, NULL, NULL, $job_id, $this
->getSourceLocale($entity));
} catch (LingotekDocumentLockedException $exception) {
$this
->setDocumentId($entity, $exception
->getNewDocumentId());
throw $exception;
} catch (LingotekDocumentArchivedException $exception) {
$old_job_id = $this
->getJobId($entity);
$this
->setDocumentId($entity, NULL);
$this
->deleteMetadata($entity);
$metadata
->setJobId($old_job_id);
$metadata
->save();
throw $exception;
} catch (LingotekPaymentRequiredException $exception) {
throw $exception;
} catch (LingotekApiException $exception) {
throw $exception;
}
}
if (is_string($newDocumentID)) {
$metadata
->setDocumentId($newDocumentID);
}
$metadata
->setJobId($job_id);
$metadata
->save();
return $entity;
}