class OpenIdConnectSettingsForm in Simple OAuth (OAuth2) & OpenID Connect 5.x
The settings form.
@internal
Hierarchy
- class \Drupal\Core\Form\FormBase implements ContainerInjectionInterface, FormInterface uses DependencySerializationTrait, LoggerChannelTrait, MessengerTrait, RedirectDestinationTrait, StringTranslationTrait
- class \Drupal\Core\Form\ConfigFormBase uses ConfigFormBaseTrait
- class \Drupal\simple_oauth\Form\OpenIdConnectSettingsForm
- class \Drupal\Core\Form\ConfigFormBase uses ConfigFormBaseTrait
Expanded class hierarchy of OpenIdConnectSettingsForm
1 string reference to 'OpenIdConnectSettingsForm'
File
- src/
Form/ OpenIdConnectSettingsForm.php, line 16
Namespace
Drupal\simple_oauth\FormView source
class OpenIdConnectSettingsForm extends ConfigFormBase {
/**
* The claim names.
*
* @var string[]
*/
private $claimNames;
/**
* Oauth2TokenSettingsForm constructor.
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The configuration factory.
* @param string[] $claim_names
* The names of the claims.
*/
public function __construct(ConfigFactoryInterface $config_factory, array $claim_names) {
parent::__construct($config_factory);
$this->claimNames = $claim_names;
}
/**
* Creates the form.
*
* @param \Symfony\Component\DependencyInjection\ContainerInterface $container
* The container.
*
* @return \Drupal\simple_oauth\Form\OpenIdConnectSettingsForm
* The form.
*/
public static function create(ContainerInterface $container) {
return new static($container
->get('config.factory'), $container
->getParameter('simple_oauth.openid.claims'));
}
/**
* Returns a unique string identifying the form.
*
* @return string
* The unique string identifying the form.
*/
public function getFormId() {
return 'openid_connect_settings';
}
/**
* {@inheritdoc}
*/
protected function getEditableConfigNames() {
return [
'simple_oauth.settings',
];
}
/**
* Defines the settings form for Access Token entities.
*
* @param array $form
* An associative array containing the structure of the form.
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The current state of the form.
*
* @return array
* Form definition array.
*/
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);
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$disable = $form_state
->getValue('disable_openid_connect');
$config = $this
->config('simple_oauth.settings');
$config
->set('disable_openid_connect', $disable);
$config
->save();
parent::submitForm($form, $form_state);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConfigFormBaseTrait:: |
protected | function | Retrieves a configuration object. | |
DependencySerializationTrait:: |
protected | property | ||
DependencySerializationTrait:: |
protected | property | ||
DependencySerializationTrait:: |
public | function | 2 | |
DependencySerializationTrait:: |
public | function | 2 | |
FormBase:: |
protected | property | The config factory. | 3 |
FormBase:: |
protected | property | The request stack. | 1 |
FormBase:: |
protected | property | The route match. | |
FormBase:: |
protected | function | Gets the config factory for this form. | 3 |
FormBase:: |
private | function | Returns the service container. | |
FormBase:: |
protected | function | Gets the current user. | |
FormBase:: |
protected | function | Gets the request object. | |
FormBase:: |
protected | function | Gets the route match. | |
FormBase:: |
protected | function | Gets the logger for a specific channel. | |
FormBase:: |
protected | function | Returns a redirect response object for the specified route. | |
FormBase:: |
public | function | Resets the configuration factory. | |
FormBase:: |
public | function | Sets the config factory for this form. | |
FormBase:: |
public | function | Sets the request stack object to use. | |
FormBase:: |
public | function |
Form validation handler. Overrides FormInterface:: |
72 |
LoggerChannelTrait:: |
protected | property | The logger channel factory service. | |
LoggerChannelTrait:: |
protected | function | Gets the logger for a specific channel. | |
LoggerChannelTrait:: |
public | function | Injects the logger channel factory. | |
MessengerTrait:: |
protected | property | The messenger. | 27 |
MessengerTrait:: |
public | function | Gets the messenger. | 27 |
MessengerTrait:: |
public | function | Sets the messenger. | |
OpenIdConnectSettingsForm:: |
private | property | The claim names. | |
OpenIdConnectSettingsForm:: |
public | function |
Defines the settings form for Access Token entities. Overrides ConfigFormBase:: |
|
OpenIdConnectSettingsForm:: |
public static | function |
Creates the form. Overrides ConfigFormBase:: |
|
OpenIdConnectSettingsForm:: |
protected | function |
Gets the configuration names that will be editable. Overrides ConfigFormBaseTrait:: |
|
OpenIdConnectSettingsForm:: |
public | function |
Returns a unique string identifying the form. Overrides FormInterface:: |
|
OpenIdConnectSettingsForm:: |
public | function |
Form submission handler. Overrides ConfigFormBase:: |
|
OpenIdConnectSettingsForm:: |
public | function |
Oauth2TokenSettingsForm constructor. Overrides ConfigFormBase:: |
|
RedirectDestinationTrait:: |
protected | property | The redirect destination service. | 1 |
RedirectDestinationTrait:: |
protected | function | Prepares a 'destination' URL query parameter for use with \Drupal\Core\Url. | |
RedirectDestinationTrait:: |
protected | function | Returns the redirect destination service. | |
RedirectDestinationTrait:: |
public | function | Sets the redirect destination service. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 4 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |