public function SmartlingApiWrapper::updateJob in TMGMT Translator Smartling 8.4
Same name and namespace in other branches
- 8.3 src/Smartling/SmartlingApiWrapper.php \Drupal\tmgmt_smartling\Smartling\SmartlingApiWrapper::updateJob()
Updates Smartling job.
Parameters
$job_id:
$name:
$description:
\DateTime|NULL $due_date:
Return value
array
File
- src/
Smartling/ SmartlingApiWrapper.php, line 162 - SmartlingApiWrapper.php.
Class
- SmartlingApiWrapper
- Class SmartlingApiWrapper @package Drupal\tmgmt_smartling\Smartling
Namespace
Drupal\tmgmt_smartling\SmartlingCode
public function updateJob($job_id, $name, $description, DateTime $due_date = NULL) {
$result = NULL;
try {
$params = new UpdateJobParameters();
$params
->setName($name);
if (!empty($description)) {
$params
->setDescription($description);
}
if (!empty($due_date)) {
$params
->setDueDate($due_date);
}
$result = $this
->getApi('jobs')
->updateJob($job_id, $params);
$this->logger
->info('Smartling updated a job:<br/>
Id: @id<br/>
Name: @name<br/>
Description: @description<br/>
Due date (UTC): @due_date<br/>', [
'@id' => $result['translationJobUid'],
'@name' => $name,
'@description' => $description,
'@due_date' => empty($due_date) ? '' : $due_date
->format('Y-m-d H:i'),
]);
} catch (Exception $e) {
$this->logger
->error('Smartling failed to update a job:<br/>
Name: @name<br/>
Description: @description<br/>
Due date (UTC): @due_date<br/>
Error: @error', [
'@name' => $name,
'@description' => $description,
'@due_date' => empty($due_date) ? '' : $due_date
->format('Y-m-d H:i'),
'@error' => $e
->getMessage(),
]);
}
return $result;
}