public function GlobalLinkTranslatorUi::checkoutSettingsForm in GlobalLink Connect for Drupal 8
Same name and namespace in other branches
- 8.2 src/GlobalLinkTranslatorUi.php \Drupal\globallink\GlobalLinkTranslatorUi::checkoutSettingsForm()
Form callback for the checkout settings form.
Overrides TranslatorPluginUiBase::checkoutSettingsForm
File
- src/
GlobalLinkTranslatorUi.php, line 195 - Contains Drupal\globallink\GlobalLinkTranslatorUi.
Class
- GlobalLinkTranslatorUi
- GlobalLink translator UI.
Namespace
Drupal\globallinkCode
public function checkoutSettingsForm(array $form, FormStateInterface $form_state, JobInterface $job) {
/** @var \Drupal\globallink\Plugin\tmgmt\Translator\GlobalLinkTranslator $translator_plugin */
$translator_plugin = $job
->getTranslator()
->getPlugin();
$translator_plugin
->setTranslator($job
->getTranslator());
$form['comment'] = [
'#type' => 'textarea',
'#title' => t('Instructions'),
'#description' => t('You can provide a set of instructions so that the translator will better understand your requirements.'),
'#default_value' => $job
->getSetting('comment') ? $job
->getSetting('comment') : '',
];
$offset_days = $job
->getTranslator()
->getSetting('pd_due_date_offset') ?: 3;
if ($job
->getSetting('due') && isset($job
->getSetting('due')['object']) && $job
->getSetting('due')['object'] instanceof DrupalDateTime) {
$default_due = $job
->getSetting('due')['object'];
}
else {
$default_due = new DrupalDateTime("+{$offset_days} weekday");
}
if ($job
->isContinuous()) {
$form['required_by'] = [
'#type' => 'number',
'#title' => t('Required By (Workdays days)'),
'#description' => t('Enter the number of working days before the translation is required.'),
'#default_value' => $job
->getSetting('required_by') ? $job
->getSetting('required_by') : $offset_days,
'#min' => 1,
];
$this
->buildContinuousFilter($form, $form_state, $job);
}
else {
$form['due'] = [
'#type' => 'datetime',
'#date_time_element' => 'none',
'#title' => t('Due date'),
'#required' => TRUE,
'#default_value' => $default_due,
'#element_validate' => [
[
get_class($this),
'validateDueDate',
],
],
'#description' => t('Due will be set using %timezone timezone.', [
'%timezone' => drupal_get_user_timezone(),
]),
];
$form['urgent'] = [
'#type' => 'checkbox',
'#title' => t('Urgent'),
'#default_value' => $job
->getSetting('urgent') ? $job
->getSetting('urgent') : FALSE,
'#description' => t('Translation will be treated as high priority and may result in additional fees.'),
];
}
return $form;
}