You are here

public function ConfigForm::buildForm in Auto Login URL 8

Same name and namespace in other branches
  1. 2.x src/Form/ConfigForm.php \Drupal\auto_login_url\Form\ConfigForm::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/ConfigForm.php, line 20

Class

ConfigForm

Namespace

Drupal\auto_login_url\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config('auto_login_url.settings');

  // Secret word.
  $form['auto_login_url_secret'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Secret word'),
    '#required' => TRUE,
    '#default_value' => \Drupal::service('auto_login_url.general')
      ->getSecret(),
    '#description' => $this
      ->t('Secret word to create hashes that are stored in DB.
        Every time this changes all previous URLs are invalidated.'),
  ];

  // Expiration.
  $form['auto_login_url_expiration'] = [
    '#title' => $this
      ->t('Expiration'),
    '#required' => TRUE,
    '#default_value' => $config
      ->get('expiration'),
    '#description' => $this
      ->t('Expiration of URLs in seconds.'),
  ];

  // Delete URLs on use.
  $form['auto_login_url_delete_on_use'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Delete on use'),
    '#default_value' => $config
      ->get('delete'),
    '#description' => $this
      ->t('Auto delete URLs after use.'),
  ];

  // Token length.
  $form['auto_login_url_token_length'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Token length'),
    '#required' => TRUE,
    '#default_value' => $config
      ->get('token_length') != FALSE ? $config
      ->get('token_length') : 64,
    '#description' => $this
      ->t('Length of generated URL token.
      WARNING: Please understand the security implications of a short auto-login-url string before you change this value.
      It has to be between 8 and 64 digits.'),
  ];
  return parent::buildForm($form, $form_state);
}