private function AuthorizationProfileForm::buildConsumerConfigForm in Authorization 8
Builds the consumer-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::buildConsumerConfigForm()
- AuthorizationProfileForm::form in src/
Form/ AuthorizationProfileForm.php - Gets the actual form array to be built.
File
- src/
Form/ AuthorizationProfileForm.php, line 305
Class
- AuthorizationProfileForm
- Authorization profile form.
Namespace
Drupal\authorization\FormCode
private function buildConsumerConfigForm(array &$form, FormStateInterface $form_state) : void {
$authorization_profile = $this
->getEntity();
$form['consumer_config'] = [
'#type' => 'container',
'#attributes' => [
'id' => 'authorization-consumer-config-form',
],
'#tree' => TRUE,
];
if ($authorization_profile
->hasValidConsumer()) {
$consumer = $authorization_profile
->getConsumer();
if ($consumer_form = $consumer
->buildConfigurationForm([], $form_state)) {
// If the consumer plugin changed, notify the user.
if (!empty($form_state
->getValues()['consumer']) && count($this
->getConsumerOptions()) > 1) {
$this
->messenger()
->addWarning($this
->t('You changed the consumer, please review its configuration.'));
}
// Modify the consumer plugin configuration container element.
$form['consumer_config']['#type'] = 'details';
$form['consumer_config']['#title'] = $this
->t('Configure %plugin consumer', [
'%plugin' => $consumer
->label(),
]);
$form['consumer_config']['#description'] = $consumer
->getDescription();
$form['consumer_config']['#open'] = TRUE;
// Attach the consumer plugin configuration form.
$form['consumer_config'] += $consumer_form;
}
}
elseif (!$authorization_profile
->isNew()) {
$this
->messenger()
->addError($this
->t('The consumer plugin is missing or invalid.'));
}
}