public function LingotekSettingsTabUtilitiesForm::buildForm in Lingotek Translation 4.0.x
Same name and namespace in other branches
- 8 src/Form/LingotekSettingsTabUtilitiesForm.php \Drupal\lingotek\Form\LingotekSettingsTabUtilitiesForm::buildForm()
- 8.2 src/Form/LingotekSettingsTabUtilitiesForm.php \Drupal\lingotek\Form\LingotekSettingsTabUtilitiesForm::buildForm()
- 3.0.x src/Form/LingotekSettingsTabUtilitiesForm.php \Drupal\lingotek\Form\LingotekSettingsTabUtilitiesForm::buildForm()
- 3.1.x src/Form/LingotekSettingsTabUtilitiesForm.php \Drupal\lingotek\Form\LingotekSettingsTabUtilitiesForm::buildForm()
- 3.2.x src/Form/LingotekSettingsTabUtilitiesForm.php \Drupal\lingotek\Form\LingotekSettingsTabUtilitiesForm::buildForm()
- 3.3.x src/Form/LingotekSettingsTabUtilitiesForm.php \Drupal\lingotek\Form\LingotekSettingsTabUtilitiesForm::buildForm()
- 3.4.x src/Form/LingotekSettingsTabUtilitiesForm.php \Drupal\lingotek\Form\LingotekSettingsTabUtilitiesForm::buildForm()
- 3.5.x src/Form/LingotekSettingsTabUtilitiesForm.php \Drupal\lingotek\Form\LingotekSettingsTabUtilitiesForm::buildForm()
- 3.6.x src/Form/LingotekSettingsTabUtilitiesForm.php \Drupal\lingotek\Form\LingotekSettingsTabUtilitiesForm::buildForm()
- 3.7.x src/Form/LingotekSettingsTabUtilitiesForm.php \Drupal\lingotek\Form\LingotekSettingsTabUtilitiesForm::buildForm()
- 3.8.x src/Form/LingotekSettingsTabUtilitiesForm.php \Drupal\lingotek\Form\LingotekSettingsTabUtilitiesForm::buildForm()
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides ConfigFormBase::buildForm
File
- src/
Form/ LingotekSettingsTabUtilitiesForm.php, line 77
Class
- LingotekSettingsTabUtilitiesForm
- Tab for running Lingotek utilities in the settings page.
Namespace
Drupal\lingotek\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$accountConfig = $this
->configFactory()
->get('lingotek.account');
$form['utilities'] = [
'#type' => 'details',
'#title' => $this
->t('Utilities'),
];
$lingotek_table = [
'#type' => 'table',
'#empty' => $this
->t('No Entries'),
];
// Refresh resources via API row
$api_refresh_row = [];
$api_refresh_row['refresh_description'] = [
'#markup' => '<h5>' . $this
->t('Refresh Project, Workflow, Vault, and Filter Information') . '</h5>' . '<p>' . $this
->t('This module locally caches the available projects, workflows, vaults, and filters. Use this utility whenever you need to pull down names for any newly created projects, workflows, vaults, or filters from the Lingotek Translation Management System.') . '</p>',
];
$api_refresh_row['actions']['refresh_button'] = [
'#type' => 'submit',
'#value' => $this
->t('Refresh'),
'#button_type' => 'primary',
'#submit' => [
'::refreshResources',
],
];
// Update Callback URL row
$callback_url = $accountConfig
->get('callback_url');
$update_callback_url_row = [];
$update_callback_url_row['update_description'] = [
'#markup' => '<h5>' . $this
->t('Update Notification Callback URL') . '</h5>' . '<p>' . $this
->t('Update the notification callback URL. This can be run whenever your site is moved (e.g., domain name change or sub-directory re-location) or whenever you would like your security token re-generated.') . '</p>' . $this
->t('<b>Current notification callback URL:</b> %callback_url', [
'%callback_url' => $callback_url,
]),
];
$update_callback_url_row['actions']['update_url'] = [
'#type' => 'submit',
'#value' => $this
->t('Update URL'),
'#button_type' => 'primary',
'#submit' => [
'::updateCallbackUrl',
],
];
// Disassociate All Translations row
$disassociate_row = [];
$disassociate_row['disassociate_description'] = [
'#markup' => '<h5>' . $this
->t('Disassociate All Translations (use with caution)') . '</h5>' . '<p>' . $this
->t('Should only be used to change the Lingotek project or TM vault associated with the node’s translation. Option to disassociate node translations on Lingotek’s servers from the copies downloaded to Drupal. Additional translation using Lingotek will require re-uploading the node’s content to restart the translation process.') . '</p>',
];
$disassociate_row['actions']['#type'] = 'actions';
$disassociate_row['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this
->t('Disassociate'),
'#submit' => [
'::disassociateAllTranslations',
],
'#attributes' => [
'class' => [
'button',
'button--danger',
],
],
];
$debug_enabled = $this->state
->get('lingotek.enable_debug_utilities', FALSE);
$enable_debug_utilities_row = [];
$enable_debug_utilities_row['enable_debug_utilities_description'] = [
'#markup' => '<h5>' . $this
->t('Debug utilities') . '</h5>' . '<p>' . $this
->t('Should only be used to debug Lingotek') . '</p>',
];
$enable_debug_utilities_row['actions']['submit'] = [
'#type' => 'submit',
'#value' => $debug_enabled ? $this
->t('Disable debug operations') : $this
->t('Enable debug operations'),
'#button_type' => 'primary',
'#submit' => [
'::switchDebugUtilities',
],
];
$lingotek_table['api_refresh'] = $api_refresh_row;
$lingotek_table['update_url'] = $update_callback_url_row;
$lingotek_table['disassociate'] = $disassociate_row;
$lingotek_table['enable_debug_utilities'] = $enable_debug_utilities_row;
$form['utilities']['lingotek_table'] = $lingotek_table;
return $form;
}