LingotekDownloaderQueueWorker.php in Lingotek Translation 8.2
Same filename and directory in other branches
- 4.0.x src/Plugin/QueueWorker/LingotekDownloaderQueueWorker.php
- 3.0.x src/Plugin/QueueWorker/LingotekDownloaderQueueWorker.php
- 3.1.x src/Plugin/QueueWorker/LingotekDownloaderQueueWorker.php
- 3.2.x src/Plugin/QueueWorker/LingotekDownloaderQueueWorker.php
- 3.3.x src/Plugin/QueueWorker/LingotekDownloaderQueueWorker.php
- 3.4.x src/Plugin/QueueWorker/LingotekDownloaderQueueWorker.php
- 3.5.x src/Plugin/QueueWorker/LingotekDownloaderQueueWorker.php
- 3.6.x src/Plugin/QueueWorker/LingotekDownloaderQueueWorker.php
- 3.7.x src/Plugin/QueueWorker/LingotekDownloaderQueueWorker.php
- 3.8.x src/Plugin/QueueWorker/LingotekDownloaderQueueWorker.php
Namespace
Drupal\lingotek\Plugin\QueueWorkerFile
src/Plugin/QueueWorker/LingotekDownloaderQueueWorker.phpView source
<?php
namespace Drupal\lingotek\Plugin\QueueWorker;
use Drupal\Core\Queue\QueueWorkerBase;
use Drupal\lingotek\Lingotek;
use Drupal\Component\Render\FormattableMarkup;
/**
* Provides base functionality for the Lingotek Queue Workers.
*
* @QueueWorker(
* id = "lingotek_downloader_queue_worker",
* title = @Translation("Lingotek Download Queue"),
* cron = {"time" = 60}
* )
*/
class LingotekDownloaderQueueWorker extends QueueWorkerBase {
/**
* {@inheritdoc}
*/
public function processItem($data) {
$locale = $data['locale'];
$entity_type_id = $data['entity_type_id'];
$entity_id = $data['entity_id'];
$document_id = $data['document_id'];
$entity = \Drupal::entityTypeManager()
->getStorage($entity_type_id)
->load($entity_id);
/** @var \Drupal\lingotek\LingotekContentTranslationServiceInterface $translation_service */
$translation_service = \Drupal::service('lingotek.content_translation');
$translation_service
->setTargetStatus($entity, $locale, Lingotek::STATUS_READY);
$download = $translation_service
->downloadDocument($entity, $locale);
if ($download === FALSE || $download === NULL) {
$message = new FormattableMarkup('No download for target @locale happened in document @document on @entity @bundle @id.', [
'@locale' => $locale,
'@document' => $document_id,
'@entity' => $entity
->label(),
'@id' => $entity
->id(),
'@bundle' => $entity
->bundle(),
]);
\Drupal::logger('lingotek')
->error($message);
throw new \Exception($message);
}
}
}
Classes
Name | Description |
---|---|
LingotekDownloaderQueueWorker | Provides base functionality for the Lingotek Queue Workers. |