function tmgmt_smartling_add_to_job_form_submit in TMGMT Translator Smartling 8.4
Same name and namespace in other branches
- 8.3 tmgmt_smartling.module \tmgmt_smartling_add_to_job_form_submit()
Submit "Add to job" tmgmt_smartling checkout job form.
Parameters
array $settings:
\Drupal\tmgmt\Entity\Translator $translator:
\Drupal\Core\Form\FormStateInterface $form_state:
Return value
mixed
1 call to tmgmt_smartling_add_to_job_form_submit()
- tmgmt_smartling_tmgmt_job_edit_form_submit in ./
tmgmt_smartling.module - Submit tmgmt_smartling checkout job form.
File
- ./
tmgmt_smartling.module, line 819 - Contains
Code
function tmgmt_smartling_add_to_job_form_submit(array $settings, Translator $translator, FormStateInterface $form_state) {
$job_attributes = $settings['add_to_job_tab']['container'];
$job_raw_attributes = $form_state
->getUserInput()['settings']['add_to_job_tab']['container'];
if (!empty($job_attributes['job_info']['due_date'])) {
$users_time_zone = new DateTimeZone($settings['smartling_users_time_zone']);
$job_attributes['job_info']['due_date'] = DateTime::createFromFormat('Y-m-d H:i:s', date('Y-m-d H:i:s', $job_attributes['job_info']['due_date']
->getTimestamp()), $users_time_zone);
$job_attributes['job_info']['due_date']
->setTimeZone(new DateTimeZone('UTC'));
}
$job_result = $translator
->getPlugin()
->getApiWrapper($translator
->getSettings())
->updateJob($job_attributes['job_id'], $job_attributes['job_info']['name'], $job_raw_attributes['job_info']['description'], $job_attributes['job_info']['due_date']);
$authorize = !empty($job_raw_attributes['job_info']['authorize']);
if (empty($job_result['translationJobUid'])) {
$due_date_string = $job_attributes['job_info']['due_date'] instanceof DateTime ? $job_attributes['job_info']['due_date']
->format('Y-m-d\\TH:i:s\\Z') : "";
return [
'job_id' => NULL,
'job_name' => $job_attributes['job_info']['name'],
'due_date' => $due_date_string,
'authorize' => $authorize,
];
}
return [
'job_id' => $job_result['translationJobUid'],
'job_name' => $job_result['jobName'],
'due_date' => $job_result['dueDate'],
'authorize' => $authorize,
];
}