You are here

public function Oauth2TokenSettingsForm::buildForm in Simple OAuth (OAuth2) & OpenID Connect 8.2

Same name and namespace in other branches
  1. 8.4 src/Entity/Form/Oauth2TokenSettingsForm.php \Drupal\simple_oauth\Entity\Form\Oauth2TokenSettingsForm::buildForm()
  2. 8.3 src/Entity/Form/Oauth2TokenSettingsForm.php \Drupal\simple_oauth\Entity\Form\Oauth2TokenSettingsForm::buildForm()
  3. 5.x src/Entity/Form/Oauth2TokenSettingsForm.php \Drupal\simple_oauth\Entity\Form\Oauth2TokenSettingsForm::buildForm()

Defines the settings form for Access Token entities.

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 Form definition array.

Overrides ConfigFormBase::buildForm

File

src/Entity/Form/Oauth2TokenSettingsForm.php, line 59

Class

Oauth2TokenSettingsForm
@internal

Namespace

Drupal\simple_oauth\Entity\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form['access_token_expiration'] = [
    '#type' => 'number',
    '#title' => $this
      ->t('Access token expiration time'),
    '#description' => $this
      ->t('The default value, in seconds, to be used as expiration time when creating new tokens.'),
    '#default_value' => $this
      ->config('simple_oauth.settings')
      ->get('access_token_expiration'),
  ];
  $form['refresh_token_expiration'] = [
    '#type' => 'number',
    '#title' => $this
      ->t('Refresh token expiration time'),
    '#description' => $this
      ->t('The default value, in seconds, to be used as expiration time when creating new tokens.'),
    '#default_value' => $this
      ->config('simple_oauth.settings')
      ->get('refresh_token_expiration'),
  ];
  $form['public_key'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Public Key'),
    '#description' => $this
      ->t('The path to the public key file.'),
    '#default_value' => $this
      ->config('simple_oauth.settings')
      ->get('public_key'),
    '#element_validate' => [
      '::validateExistingFile',
    ],
    '#required' => TRUE,
  ];
  $form['private_key'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Private Key'),
    '#description' => $this
      ->t('The path to the private key file.'),
    '#default_value' => $this
      ->config('simple_oauth.settings')
      ->get('private_key'),
    '#element_validate' => [
      '::validateExistingFile',
    ],
    '#required' => TRUE,
  ];
  return parent::buildForm($form, $form_state);
}