authman-1.x-dev/src/Plugin/KeyInput/OauthClientKeyInput.php
src/Plugin/KeyInput/OauthClientKeyInput.php
<?php
declare(strict_types = 1);
namespace Drupal\authman\Plugin\KeyInput;
use Drupal\Core\Form\FormStateInterface;
use Drupal\key\Plugin\KeyInputBase;
/**
* Input for OAuth 2.
*
* @KeyInput(
* id = "authman_oauth_client",
* label = @Translation("OAuth 2 client details")
* )
*/
class OauthClientKeyInput extends KeyInputBase {
/**
* {@inheritdoc}
*/
public function defaultConfiguration() {
return [
'client_id' => '',
'client_secret' => '',
];
}
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form['client_id'] = [
'#type' => 'textfield',
'#title' => $this->t('Client ID'),
'#default_value' => $this->configuration['client_id'],
];
$form['client_secret'] = [
'#type' => 'textfield',
'#title' => $this->t('Client Secret'),
'#default_value' => $this->configuration['client_secret'],
];
return $form;
}
/**
* {@inheritdoc}
*/
public function processSubmittedKeyValue(FormStateInterface $form_state) {
$values = $form_state->getValues();
return [
'submitted' => $values,
'processed_submitted' => $values,
];
}
}
