function JobForm::checkoutSettingsForm

Helper function for retrieving the job settings form.

@todo Make use of the response object here.

1 call to JobForm::checkoutSettingsForm()

File

src/Form/JobForm.php, line 740

Class

JobForm
Form controller for the job edit forms.

Namespace

Drupal\tmgmt\Form

Code

function checkoutSettingsForm(FormStateInterface $form_state, JobInterface $job) {
  $form = array();
  if (!$job
    ->hasTranslator()) {
    return $form;
  }
  $translator = $job
    ->getTranslator();
  $result = $translator
    ->checkAvailable();
  if (!$result
    ->getSuccess()) {
    $form['#description'] = $result
      ->getReason();
    return $form;
  }

  // @todo: if the target language is not defined, the check will not work if the first language in the list is not available.
  $result = $translator
    ->checkTranslatable($job);
  if ($job
    ->getTargetLangcode() && !$result
    ->getSuccess()) {
    $form['#description'] = $result
      ->getReason();
    return $form;
  }
  $plugin_ui = $this->translatorManager
    ->createUIInstance($translator
    ->getPluginId());
  $form = $plugin_ui
    ->checkoutSettingsForm($form, $form_state, $job);
  return $form;
}