protected function LingotekContentTranslationService::checkForTimeout in Lingotek Translation 3.8.x
Same name and namespace in other branches
- 4.0.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::checkForTimeout()
- 3.4.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::checkForTimeout()
- 3.5.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::checkForTimeout()
- 3.6.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::checkForTimeout()
- 3.7.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::checkForTimeout()
Checks the time elapsed since the last upload and sets the entity to error if the max time has elapsed.
Parameters
\Drupal\Core\Entity\ContentEntityInterface $entity:
1 call to LingotekContentTranslationService::checkForTimeout()
- LingotekContentTranslationService::checkSourceStatus in src/
LingotekContentTranslationService.php - Checks the source is uploaded correctly.
File
- src/
LingotekContentTranslationService.php, line 211
Class
- LingotekContentTranslationService
- Service for managing Lingotek content translations.
Namespace
Drupal\lingotekCode
protected function checkForTimeout(ContentEntityInterface &$entity) {
// We set a max time of 1 hour for the import (in seconds)
$maxImportTime = 3600;
$timedOut = FALSE;
if ($last_uploaded_time = $this
->getLastUpdated($entity) ?: $this
->getLastUploaded($entity)) {
// If document has not successfully imported after MAX_IMPORT_TIME
// then move to ERROR state.
if (\Drupal::time()
->getRequestTime() - $last_uploaded_time > $maxImportTime) {
$this
->setSourceStatus($entity, Lingotek::STATUS_ERROR);
$timedOut = TRUE;
}
else {
// Document still may be importing and the MAX import time didn't
// complete yet, so we do nothing.
}
// TODO: Remove the elseif clause after 4.0.0 is released
}
elseif ($entity
->getEntityType()
->entityClassImplements(EntityChangedInterface::class)) {
$last_uploaded_time = $entity
->getChangedTime();
if (\Drupal::time()
->getRequestTime() - $last_uploaded_time > $maxImportTime) {
$timedOut = TRUE;
$this
->setSourceStatus($entity, Lingotek::STATUS_ERROR);
}
}
return $timedOut;
}