public function LingotekConfigSet::contentUpdated in Lingotek Translation 7.6
Event handler for updates to the config set's data.
File
- lib/
Drupal/ lingotek/ LingotekConfigSet.php, line 540 - Defines LingotekConfigSet.
Class
- LingotekConfigSet
- A class wrapper for Lingotek-specific behavior on ConfigSets.
Code
public function contentUpdated() {
$metadata = $this
->metadata();
if (empty($metadata['document_id'])) {
$this
->createLingotekDocument();
}
else {
$update_result = $this
->updateLingotekDocument();
}
// Synchronize the local content with the translations from Lingotek.
// We instruct the users to configure config set translation with a
// single-phase machine translation-only Workflow, so the updated content
// should be available right after our create/update document calls from above.
// If it isn't, Lingotek will call us back via LINGOTEK_NOTIFICATIONS_URL
// when machine translation for the item has finished.
if (!self::$content_update_in_progress) {
// Only update the local content if the Document is 100% complete
// according to Lingotek.
$document_id = $this
->getMetadataValue('document_id');
if ($document_id) {
$document = $this->api
->getDocument($document_id);
if (!empty($document->percentComplete) && $document->percentComplete == 100) {
$this
->updateLocalContent();
}
}
else {
LingotekLog::error('Unable to retrieve Lingotek Document ID for config set @id', array(
'@id' => $this->sid,
));
}
}
}