public function LtiToolProviderRolesSettingsForm::buildForm in LTI Tool Provider 2.x
Same name and namespace in other branches
- 8 modules/lti_tool_provider_roles/src/Form/LtiToolProviderRolesSettingsForm.php \Drupal\lti_tool_provider_roles\Form\LtiToolProviderRolesSettingsForm::buildForm()
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides ConfigFormBase::buildForm
File
- modules/
lti_tool_provider_roles/ src/ Form/ LtiToolProviderRolesSettingsForm.php, line 20
Class
Namespace
Drupal\lti_tool_provider_roles\FormCode
public function buildForm(array $form, FormStateInterface $form_state, $filter = '') : array {
$settings = $this
->config('lti_tool_provider_roles.settings');
$mapped_roles = $settings
->get('mapped_roles');
$lti_roles = $this
->config('lti_tool_provider.settings')
->get('lti_roles');
$form['mapped_roles'] = [
'#type' => 'table',
'#tree' => TRUE,
'#caption' => t('This page allows you to map LTI roles to Drupal user roles. This is applied every time a user logs in via LTI. Please note that if roles are mapped and they are not present on the LMS, they will be removed from the Drupal user. Please be careful when setting this for the authenticated user role.'),
'#header' => [
t('User Role'),
t('LTI Role'),
],
];
foreach (user_roles(TRUE) as $key => $user_role) {
$form['mapped_roles'][$key] = [
'user_role' => [
'#type' => 'item',
'#title' => $user_role
->label(),
],
'lti_role' => [
'#type' => 'select',
'#required' => FALSE,
'#empty_option' => t('None'),
'#empty_value' => TRUE,
'#default_value' => $mapped_roles[$key],
'#options' => array_combine($lti_roles, $lti_roles),
],
];
}
return parent::buildForm($form, $form_state);
}