public function DrupalRolesConsumer::buildRowForm in Authorization 8
Builds the authorization form row.
Return array.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
int $index: The row number of the mapping.
Overrides ConfigurableAuthorizationPluginBase::buildRowForm
File
- authorization_drupal_roles/
src/ Plugin/ authorization/ Consumer/ DrupalRolesConsumer.php, line 95
Class
- DrupalRolesConsumer
- Provides a consumer for Drupal roles.
Namespace
Drupal\authorization_drupal_roles\Plugin\authorization\ConsumerCode
public function buildRowForm(array $form, FormStateInterface $form_state, $index = 0) : array {
$row = [];
$mappings = $this->configuration['profile']
->getConsumerMappings();
$roleOptions = [
'none' => $this
->t('- N/A -'),
];
$roles = user_roles(TRUE);
foreach ($roles as $key => $role) {
if ($key !== 'authenticated') {
$roleOptions[$key] = $role
->label();
}
}
$roleOptions['source'] = $this
->t('Source (Any group)');
$row['role'] = [
'#type' => 'select',
'#title' => $this
->t('Role'),
'#options' => $roleOptions,
'#default_value' => isset($mappings[$index]) ? $mappings[$index]['role'] : NULL,
'#description' => $this
->t("Choosing 'Source' maps any input directly to Drupal, use with caution."),
];
return $row;
}