function globallink_cron in GlobalLink Connect for Drupal 8
Same name and namespace in other branches
- 8.2 globallink.module \globallink_cron()
- 7.7 globallink.module \globallink_cron()
- 7.5 globallink.module \globallink_cron()
- 7.6 globallink.module \globallink_cron()
Implements hook_cron().
File
- ./
globallink.module, line 20
Code
function globallink_cron() {
$globallink_translators = \Drupal::entityTypeManager()
->getStorage('tmgmt_translator')
->loadByProperties([
'plugin' => 'globallink',
]);
/** @var \Drupal\tmgmt\TranslatorInterface $translator */
foreach ($globallink_translators as $translator) {
/** @var \Drupal\globallink\Plugin\tmgmt\Translator\GlobalLinkTranslator $translator_plugin */
$translator_plugin = $translator
->getPlugin();
$completed_translations = $translator_plugin
->getCompletedTranslations($translator);
if (!empty($completed_translations)) {
foreach ($completed_translations as $completed_translation) {
$query = \Drupal::entityQuery('tmgmt_job')
->condition('uuid', $completed_translation->clientIdentifier);
$job_ids = $query
->execute();
if (!empty($job_ids)) {
/** @var \Drupal\tmgmt\JobInterface $job */
$job = Job::load(array_shift($job_ids));
$translator_plugin
->retrieveTranslation($completed_translation->ticket, $job);
}
}
}
}
}