class LocalTranslatorUi

Drupal user provider plugin UI.

Hierarchy

Expanded class hierarchy of LocalTranslatorUi

File

translators/tmgmt_local/src/LocalTranslatorUi.php, line 14

Namespace

Drupal\tmgmt_local
View source
class LocalTranslatorUi extends TranslatorPluginUiBase {

  /**
   * {@inheritdoc}
   */
  public function checkoutSettingsForm(array $form, FormStateInterface $form_state, JobInterface $job) {
    if ($translators = tmgmt_local_assignees($job
      ->getSourceLangcode(), array(
      $job
        ->getTargetLangcode(),
    ))) {
      $form['translator'] = array(
        '#title' => t('Assign job to'),
        '#type' => 'select',
        '#options' => array(
          '' => t('- Select user -'),
        ) + $translators,
        '#default_value' => $job
          ->getSetting('translator'),
      );
    }
    else {
      $form['message'] = array(
        '#markup' => t('There are no users available to assign.'),
      );
    }
    $form['job_comment'] = array(
      '#type' => 'textarea',
      '#title' => t('Comment for the translation'),
      '#description' => t('You can provide a comment so that the assigned user will better understand your requirements.'),
      '#default_value' => $job
        ->getSetting('job_comment'),
    );
    return $form;
  }

  /**
   * {@inheritdoc}
   */
  public function checkoutInfo(JobInterface $job) {
    $tuid = $job
      ->getSetting('translator');
    if ($tuid && ($translator = User::load($tuid))) {
      $form['job_status'] = array(
        '#type' => 'item',
        '#title' => t('Job status'),
        '#markup' => t('Translation job is assigned to %name.', array(
          '%name' => $translator
            ->getDisplayName(),
        )),
      );
    }
    else {
      $form['job_status'] = array(
        '#type' => 'item',
        '#title' => t('Job status'),
        '#markup' => t('Translation job is not assigned to any user.'),
      );
    }
    if ($job
      ->getSetting('job_comment')) {
      $form['job_comment'] = array(
        '#type' => 'item',
        '#title' => t('Job comment'),
        '#markup' => Xss::filter($job
          ->getSetting('job_comment')),
      );
    }
    return $form;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
LocalTranslatorUi::checkoutInfo public function Retrieves information about a translation job. Overrides TranslatorPluginUiBase::checkoutInfo
LocalTranslatorUi::checkoutSettingsForm public function Form callback for the checkout settings form. Overrides TranslatorPluginUiBase::checkoutSettingsForm
TranslatorPluginUiBase::addConnectButton public function Adds a "Connect" button to a form.
TranslatorPluginUiBase::buildConfigurationForm public function Overrides TranslatorPluginUiInterface::buildConfigurationForm 2
TranslatorPluginUiBase::checkoutInfoWrapper public function Provides a simple wrapper for the checkout info fieldset.
TranslatorPluginUiBase::reviewDataItemElement public function Form callback for the data item element form. Overrides TranslatorPluginUiInterface::reviewDataItemElement 1
TranslatorPluginUiBase::reviewForm public function Form callback for the job item review form. Overrides TranslatorPluginUiInterface::reviewForm
TranslatorPluginUiBase::reviewFormSubmit public function Submit callback for the job item review form. Overrides TranslatorPluginUiInterface::reviewFormSubmit
TranslatorPluginUiBase::reviewFormValidate public function Validation callback for the job item review form. Overrides TranslatorPluginUiInterface::reviewFormValidate
TranslatorPluginUiBase::submitConfigurationForm public function Overrides TranslatorPluginUiInterface::submitConfigurationForm
TranslatorPluginUiBase::submitConnect public function Handles submit call of "Connect" button.
TranslatorPluginUiBase::validateConfigurationForm public function Overrides TranslatorPluginUiInterface::validateConfigurationForm