public function RequestTranslationSubscriber::onUploadRequest in TMGMT Translator Smartling 8.4
Same name and namespace in other branches
- 8 src/EventSubscriber/RequestTranslationSubscriber.php \Drupal\tmgmt_smartling\EventSubscriber\RequestTranslationSubscriber::onUploadRequest()
- 8.2 src/EventSubscriber/RequestTranslationSubscriber.php \Drupal\tmgmt_smartling\EventSubscriber\RequestTranslationSubscriber::onUploadRequest()
- 8.3 src/EventSubscriber/RequestTranslationSubscriber.php \Drupal\tmgmt_smartling\EventSubscriber\RequestTranslationSubscriber::onUploadRequest()
Code that should be triggered on event specified
File
- src/
EventSubscriber/ RequestTranslationSubscriber.php, line 27
Class
Namespace
Drupal\tmgmt_smartling\EventSubscriberCode
public function onUploadRequest(RequestTranslationEvent $event) {
/** @var JobInterface $job */
$job = $event
->getJob();
if (!$job
->getTranslator()
->getPlugin() instanceof SmartlingTranslator) {
return;
}
$job_items = $job
->getItems();
if (empty($job_items)) {
return;
}
$filename = $job
->getTranslatorPlugin()
->getFileName($job);
foreach ($job_items as $item) {
$url = $this->urlConverter
->convert($item);
$cloned_item = clone $item;
\Drupal::moduleHandler()
->alter('tmgmt_smartling_context_url', $url, $cloned_item);
if (!empty($url)) {
$this->contextUploadQueue
->createItem([
'url' => $url,
'filename' => $filename,
'job_id' => $job
->id(),
'upload_date' => time() + self::WAIT_BEFORE_CONTEXT_UPLOAD,
]);
}
}
}