public function ContentHubSettingsForm::buildForm in Acquia Content Hub 8
Same name and namespace in other branches
- 8.2 src/Form/ContentHubSettingsForm.php \Drupal\acquia_contenthub\Form\ContentHubSettingsForm::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/ ContentHubSettingsForm.php, line 92
Class
- ContentHubSettingsForm
- Defines the form to configure the Content Hub connection settings.
Namespace
Drupal\acquia_contenthub\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this->configFactory
->get('acquia_contenthub.admin_settings');
$form['settings'] = [
'#type' => 'fieldset',
'#title' => $this
->t('Connection Settings'),
'#collapsible' => TRUE,
'#description' => $this
->t('Settings for connection to Acquia Content Hub'),
];
$form['settings']['hostname'] = [
'#type' => 'textfield',
'#title' => $this
->t('Acquia Content Hub Hostname'),
'#description' => $this
->t('The hostname of the Acquia Content Hub API without trailing slash at end of URL, e.g. http://localhost:5000'),
'#default_value' => $config
->get('hostname'),
'#required' => TRUE,
];
$form['settings']['api_key'] = [
'#type' => 'textfield',
'#title' => $this
->t('API Key'),
'#default_value' => $config
->get('api_key'),
'#required' => TRUE,
];
$form['settings']['secret_key'] = [
'#type' => 'password',
'#title' => $this
->t('Secret Key'),
'#default_value' => $config
->get('secret_key'),
];
$client_name = $config
->get('client_name');
$form['settings']['hmac_version'] = [
'#type' => 'select',
'#title' => 'HMAC Version',
'#options' => [
'V1' => $this
->t('Version 1'),
'V2' => $this
->t('Version 2'),
],
'#default' => 'V1',
'#description' => $this
->t('Choose which HMAC version your subscribers and publisher talk. Version 1 Is the only supported option, Version 2 is coming soon.'),
'#attributes' => [
'disabled' => TRUE,
],
];
$readonly = empty($client_name) ? [] : [
'readonly' => TRUE,
];
$form['settings']['client_name'] = [
'#type' => 'textfield',
'#title' => $this
->t('Client Name'),
'#default_value' => $client_name,
'#required' => TRUE,
'#description' => $this
->t('A unique client name by which Acquia Content Hub will identify this site. The name of this client site cannot be changed once set.'),
'#attributes' => $readonly,
];
$form['settings']['origin'] = [
'#type' => 'item',
'#title' => $this
->t("Site's Origin UUID"),
'#markup' => $config
->get('origin'),
];
return parent::buildForm($form, $form_state);
}