You are here

protected function ClientAuthorizationPluginBase::expandedProviderOptions in Entity Share 8.3

Helper method to build the credential provider elements of the form.

Parameters

array $form: The configuration form.

4 calls to ClientAuthorizationPluginBase::expandedProviderOptions()
Anonymous::buildConfigurationForm in modules/entity_share_client/src/Plugin/ClientAuthorization/Anonymous.php
Form constructor.
BasicAuth::buildConfigurationForm in modules/entity_share_client/src/Plugin/ClientAuthorization/BasicAuth.php
Form constructor.
Header::buildConfigurationForm in modules/entity_share_client/src/Plugin/ClientAuthorization/Header.php
Form constructor.
Oauth::buildConfigurationForm in modules/entity_share_client/src/Plugin/ClientAuthorization/Oauth.php
Form constructor.

File

modules/entity_share_client/src/ClientAuthorization/ClientAuthorizationPluginBase.php, line 215

Class

ClientAuthorizationPluginBase
Base class for Client authorization plugins.

Namespace

Drupal\entity_share_client\ClientAuthorization

Code

protected function expandedProviderOptions(array &$form) {
  $provider = $this
    ->getCredentialProvider();

  // Provide selectors for the api key credential provider.
  $form['credential_provider'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Credential provider'),
    '#default_value' => empty($provider) ? 'entity_share' : $provider,
    '#options' => [
      'entity_share' => $this
        ->t('Local storage'),
      'key' => $this
        ->t('Key module'),
    ],
    '#attributes' => [
      'data-states-selector' => 'provider',
    ],
    '#weight' => -99,
  ];
  $form['entity_share']['#states'] = [
    'required' => [
      ':input[data-states-selector="provider"]' => [
        'value' => 'entity_share',
      ],
    ],
    'visible' => [
      ':input[data-states-selector="provider"]' => [
        'value' => 'entity_share',
      ],
    ],
    'enabled' => [
      ':input[data-states-selector="provider"]' => [
        'value' => 'entity_share',
      ],
    ],
  ];
  $key_id = $provider == 'key' ? $this
    ->getStorageKey() : '';
  $form['key'] = [
    '#type' => 'fieldset',
    '#title' => $this
      ->t('Managed by the Key module'),
    '#states' => [
      'required' => [
        ':input[data-states-selector="provider"]' => [
          'value' => 'key',
        ],
      ],
      'visible' => [
        ':input[data-states-selector="provider"]' => [
          'value' => 'key',
        ],
      ],
      'enabled' => [
        ':input[data-states-selector="provider"]' => [
          'value' => 'key',
        ],
      ],
    ],
  ];
  $form['key']['id'] = [
    '#type' => 'key_select',
    '#title' => $this
      ->t('Select a stored Key'),
    '#default_value' => $key_id,
    '#empty_option' => $this
      ->t('- Please select -'),
  ];
}