function tmgmt_smartling_create_job_form_submit in TMGMT Translator Smartling 8.4
Same name and namespace in other branches
- 8.3 tmgmt_smartling.module \tmgmt_smartling_create_job_form_submit()
Submit "Create 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_create_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 769 - Contains
Code
function tmgmt_smartling_create_job_form_submit(array $settings, Translator $translator, FormStateInterface $form_state) {
$job_attributes = $settings['create_new_job_tab'];
if (!empty($job_attributes['due_date'])) {
$users_time_zone = new DateTimeZone($settings['smartling_users_time_zone']);
$job_attributes['due_date'] = DateTime::createFromFormat('Y-m-d H:i:s', date('Y-m-d H:i:s', $job_attributes['due_date']
->getTimestamp()), $users_time_zone);
$job_attributes['due_date']
->setTimeZone(new DateTimeZone('UTC'));
}
$job_id = $translator
->getPlugin()
->getApiWrapper($translator
->getSettings())
->createJob($job_attributes['name'], $job_attributes['description'], $job_attributes['due_date']);
$due_date_string = $job_attributes['due_date'] instanceof DateTime ? $job_attributes['due_date']
->format('Y-m-d\\TH:i:s\\Z') : "";
if (empty($job_id)) {
\Drupal::messenger()
->addError(t('Job has not been created. See <a href="@url">logs</a> for more information.', [
'@url' => Url::fromUri('internal:/admin/reports/dblog')
->toString(),
]));
return [
'job_id' => NULL,
'job_name' => $job_attributes['name'],
'due_date' => $due_date_string,
'authorize' => $job_attributes['authorize'],
];
}
return [
'job_id' => $job_id,
'job_name' => $job_attributes['name'],
'due_date' => $due_date_string,
'authorize' => $job_attributes['authorize'],
];
}