You are here

public function OpenIdConnectSettingsForm::buildForm in Simple OAuth (OAuth2) & OpenID Connect 5.x

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/Form/OpenIdConnectSettingsForm.php, line 82

Class

OpenIdConnectSettingsForm
The settings form.

Namespace

Drupal\simple_oauth\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form['disable_openid_connect'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Disable OpenID Connect'),
    '#description' => $this
      ->t('Disable OpenID Connect if you have a conflicting custom or contributed implementation of OpenID Connect in your site.'),
    '#default_value' => $this
      ->config('simple_oauth.settings')
      ->get('disable_openid_connect'),
  ];
  $form['info'] = [
    '#type' => 'container',
    'customize' => [
      '#markup' => '<p>' . $this
        ->t('Check the <a href="@href" rel="noopener" target="_blank">Simple OAuth guide</a> for OpenID Connect to learn how to customize the user claims for OpenID Connect.', [
        '@href' => Url::fromUri('https://www.drupal.org/node/3172149')
          ->toString(),
      ]) . '</p>',
    ],
    'claims' => [
      '#type' => 'checkboxes',
      '#title' => $this
        ->t('Available claims'),
      '#description' => $this
        ->t('Claims are defined and managed in the service container. They are only listed here for reference. Please see the documentation above for more information.'),
      '#options' => array_combine($this->claimNames, $this->claimNames),
      '#default_value' => $this->claimNames,
      '#disabled' => TRUE,
    ],
    '#states' => [
      'invisible' => [
        ':input[name="disable_openid_connect"]' => [
          'checked' => TRUE,
        ],
      ],
    ],
  ];
  return parent::buildForm($form, $form_state);
}