You are here

public static function ServerForm::refreshTokenSettings in OAuth2 Server 8

Same name and namespace in other branches
  1. 2.0.x src/Form/ServerForm.php \Drupal\oauth2_server\Form\ServerForm::refreshTokenSettings()

Provides a settings form for the refresh_token grant type.

Parameters

array $config: The config array.

array $dom_ids: The DOM ids.

Return value

array A renderable form array.

File

src/Form/ServerForm.php, line 201

Class

ServerForm
Class Server Form.

Namespace

Drupal\oauth2_server\Form

Code

public static function refreshTokenSettings(array $config, array $dom_ids = []) {
  $form = [];
  $form['always_issue_new_refresh_token'] = [
    '#type' => 'checkbox',
    '#title' => t('Always issue a new refresh token after the existing one has been used'),
    '#default_value' => $config['always_issue_new_refresh_token'],
  ];
  $form['unset_refresh_token_after_use'] = [
    '#type' => 'checkbox',
    '#title' => t('Unset (delete) the refresh token after it has been used'),
    '#default_value' => $config['unset_refresh_token_after_use'],
  ];
  foreach ($dom_ids as $dom_id) {
    $form['always_issue_new_refresh_token']['#states']['visible']['#' . $dom_id]['checked'] = TRUE;
    $form['unset_refresh_token_after_use']['#states']['visible']['#' . $dom_id]['checked'] = TRUE;
  }
  return $form;
}