private function AuthorizationProfileForm::buildProviderConfigForm in Authorization 8
Builds the provider-specific configuration form.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
1 call to AuthorizationProfileForm::buildProviderConfigForm()
- AuthorizationProfileForm::form in src/
Form/ AuthorizationProfileForm.php - Gets the actual form array to be built.
File
- src/
Form/ AuthorizationProfileForm.php, line 262
Class
- AuthorizationProfileForm
- Authorization profile form.
Namespace
Drupal\authorization\FormCode
private function buildProviderConfigForm(array &$form, FormStateInterface $form_state) : void {
$authorization_profile = $this
->getEntity();
$form['provider_config'] = [
'#type' => 'container',
'#attributes' => [
'id' => 'authorization-provider-config-form',
],
'#tree' => TRUE,
];
if ($authorization_profile
->hasValidProvider()) {
$provider = $authorization_profile
->getProvider();
if ($provider_form = $provider
->buildConfigurationForm([], $form_state)) {
// If the provider plugin changed, notify the user.
if (!empty($form_state
->getValues()['provider']) && count($this
->getProviderOptions()) > 1) {
$this
->messenger()
->addWarning($this
->t('You changed the provider, please review its configuration.'));
}
// Modify the provider plugin configuration container element.
$form['provider_config']['#type'] = 'details';
$form['provider_config']['#title'] = $this
->t('Configure %plugin provider', [
'%plugin' => $provider
->label(),
]);
$form['provider_config']['#description'] = $provider
->getDescription();
$form['provider_config']['#open'] = TRUE;
// Attach the provider plugin configuration form.
$form['provider_config'] += $provider_form;
}
}
elseif (!$authorization_profile
->isNew()) {
$this
->messenger()
->addError($this
->t('The provider plugin is missing or invalid.'));
}
}