public function LingotekSettingsConnectForm::buildForm in Lingotek Translation 8
Same name and namespace in other branches
- 8.2 src/Form/LingotekSettingsConnectForm.php \Drupal\lingotek\Form\LingotekSettingsConnectForm::buildForm()
- 4.0.x src/Form/LingotekSettingsConnectForm.php \Drupal\lingotek\Form\LingotekSettingsConnectForm::buildForm()
- 3.0.x src/Form/LingotekSettingsConnectForm.php \Drupal\lingotek\Form\LingotekSettingsConnectForm::buildForm()
- 3.1.x src/Form/LingotekSettingsConnectForm.php \Drupal\lingotek\Form\LingotekSettingsConnectForm::buildForm()
- 3.2.x src/Form/LingotekSettingsConnectForm.php \Drupal\lingotek\Form\LingotekSettingsConnectForm::buildForm()
- 3.3.x src/Form/LingotekSettingsConnectForm.php \Drupal\lingotek\Form\LingotekSettingsConnectForm::buildForm()
- 3.4.x src/Form/LingotekSettingsConnectForm.php \Drupal\lingotek\Form\LingotekSettingsConnectForm::buildForm()
- 3.5.x src/Form/LingotekSettingsConnectForm.php \Drupal\lingotek\Form\LingotekSettingsConnectForm::buildForm()
- 3.6.x src/Form/LingotekSettingsConnectForm.php \Drupal\lingotek\Form\LingotekSettingsConnectForm::buildForm()
- 3.7.x src/Form/LingotekSettingsConnectForm.php \Drupal\lingotek\Form\LingotekSettingsConnectForm::buildForm()
- 3.8.x src/Form/LingotekSettingsConnectForm.php \Drupal\lingotek\Form\LingotekSettingsConnectForm::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/ LingotekSettingsConnectForm.php, line 28 - Contains \Drupal\lingotek\Form\LingotekSettingsConnectForm.
Class
- LingotekSettingsConnectForm
- Configure Lingotek
Namespace
Drupal\lingotek\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
// build the redirecting link for authentication to Lingotek
$host = $this->lingotek
->get('account.host');
$sandbox_host = $this->lingotek
->get('account.sandbox_host');
$auth_path = $this->lingotek
->get('account.authorize_path');
$id = $this->lingotek
->get('account.default_client_id');
$return_uri = new Url('lingotek.setup_account_handshake', array(
'success' => 'true',
'prod' => 'prod',
), array(
'absolute' => TRUE,
));
$login = $this->lingotek
->get('account.type');
$lingotek_register_link = $host . '/' . 'lingopoint/portal/requestAccount.action?client_id=' . $id . '&response_type=token&app=' . urlencode($return_uri
->toString());
$lingotek_connect_link = $host . '/' . $auth_path . '?client_id=' . $id . '&response_type=token&redirect_uri=' . urlencode($return_uri
->toString());
$return_uri
->setRouteParameter('prod', 'sandbox');
$lingotek_sandbox_link = $sandbox_host . '/' . $auth_path . '?client_id=' . $id . '&response_type=token&redirect_uri=' . urlencode($return_uri
->toString());
$form['new_account'] = [
'#type' => 'container',
];
$form['new_account']['intro'] = array(
'#type' => 'markup',
'#markup' => $this
->t('Get started by clicking the button below to connect your Lingotek account to this Drupal site.') . '<br/>',
);
$form['new_account']['submit'] = array(
'#type' => 'link',
'#title' => t('Create New Lingotek Account'),
'#url' => Url::fromUri($lingotek_register_link),
'#options' => array(
'attributes' => array(
'title' => t('Create New Lingotek Account'),
'class' => array(
'button',
'action-connect',
),
),
),
);
$form['connect_account'] = [
'#type' => 'container',
];
$form['connect_account']['text'] = [
'#markup' => t('Do you already have a Lingotek account?') . ' ',
];
$form['connect_account']['link'] = [
'#type' => 'link',
'#title' => t('Connect Lingotek Account'),
'#url' => Url::fromUri($lingotek_connect_link),
];
$form['connect_sandbox'] = [
'#type' => 'container',
];
$form['connect_sandbox'] = [
'#markup' => t('Do you have a Lingotek sandbox account?') . ' ',
];
$form['connect_sandbox']['link'] = [
'#type' => 'link',
'#title' => t('Connect Sandbox Account'),
'#url' => Url::fromUri($lingotek_sandbox_link),
];
$form['#attached']['library'][] = 'lingotek/lingotek.icons';
return $form;
}