<?php
namespace Drupal\tmgmt;
use Drupal\Core\Plugin\PluginBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\Element;
use Drupal\tmgmt\Form\TranslatorForm;
class TranslatorPluginUiBase extends PluginBase implements TranslatorPluginUiInterface {
public function checkoutSettingsForm(array $form, FormStateInterface $form_state, JobInterface $job) {
if (!Element::children($form)) {
$form['#description'] = t("The @translator translator doesn't provide any checkout settings.", array(
'@translator' => $job
->getTranslator()
->label(),
));
}
return $form;
}
public function checkoutInfo(JobInterface $job) {
return array();
}
public function checkoutInfoWrapper(JobInterface $job, $form) {
$label = $job
->getTranslator()
->label();
$form += array(
'#title' => t('@translator translation job information', array(
'@translator' => $label,
)),
'#type' => 'details',
'#open' => FALSE,
);
return $form;
}
public function reviewForm(array $form, FormStateInterface $form_state, JobItemInterface $item) {
return $form;
}
public function reviewDataItemElement(array $form, FormStateInterface $form_state, $data_item_key, $parent_key, array $data_item, JobItemInterface $item) {
return $form;
}
public function reviewFormValidate(array $form, FormStateInterface $form_state, JobItemInterface $item) {
}
public function reviewFormSubmit(array $form, FormStateInterface $form_state, JobItemInterface $item) {
}
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
return $form;
}
public function submitConnect(array $form, FormStateInterface $form_state) {
$this
->messenger()
->addStatus(t('Successfully connected!'));
}
public function addConnectButton() {
$form['connect'] = array(
'#type' => 'submit',
'#value' => t('Connect'),
'#submit' => [
[
TranslatorForm::class,
'updateRemoteLanguagesMappings',
],
[
$this,
'submitConnect',
],
],
'#limit_validation_errors' => array(
array(
'settings',
),
),
'#executes_submit_callback' => TRUE,
'#ajax' => [
'callback' => [
TranslatorForm::class,
'ajaxTranslatorPluginSelect',
],
'wrapper' => 'tmgmt-plugin-wrapper',
],
);
return $form;
}
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
}
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
}
}