You are here

function JobForm::checkoutSettingsForm in Translation Management Tool 8

Helper function for retrieving the job settings form.

@todo Make use of the response object here.

1 call to JobForm::checkoutSettingsForm()
JobForm::form in src/Form/JobForm.php
Gets the actual form array to be built.

File

src/Form/JobForm.php, line 700

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;
}