protected function Keycloak::getGroupRuleRow in Keycloak OpenID Connect 8
Helper method to construct a setting form user group role mapping row.
Parameters
array $roles: Options array holding the available user roles and an empty placeholder keyed by 'NONE'.
array $operations: Options array holding the available evaluation methods.
array $defaults: Default values for the rule row.
Return value
array Array of form element definitions for a user group role mapping rule.
1 call to Keycloak::getGroupRuleRow()
- Keycloak::getGroupRuleTable in src/
Plugin/ OpenIDConnectClient/ Keycloak.php - Helper method returning user group mapping rules form array table.
File
- src/
Plugin/ OpenIDConnectClient/ Keycloak.php, line 585
Class
- Keycloak
- OpenID Connect client for Keycloak.
Namespace
Drupal\keycloak\Plugin\OpenIDConnectClientCode
protected function getGroupRuleRow(array $roles, array $operations, array $defaults = []) {
$uuid = empty($defaults['id']) ? $this->uuid
->generate() : $defaults['id'];
$row['#attributes']['class'][] = 'draggable';
$row['#weight'] = !empty($defaults['weight']) ? $defaults['weight'] : 0;
$row['id'] = [
'#type' => 'hidden',
'#value' => $uuid,
];
$row['weight'] = [
'#type' => 'weight',
'#title' => t('Weight'),
'#title_display' => 'invisible',
'#default_value' => !empty($defaults['weight']) ? $defaults['weight'] : 0,
'#attributes' => [
'class' => [
'keycloak-groups-rules-weight',
],
],
];
$row['role'] = [
'#title' => $this
->t('User role'),
'#title_display' => 'invisible',
'#type' => 'select',
'#options' => $roles,
'#default_value' => !empty($defaults['role']) ? $defaults['role'] : NULL,
];
$row['action'] = [
'#title' => $this
->t('Action'),
'#title_display' => 'invisible',
'#type' => 'select',
'#options' => [
'add' => $this
->t('add'),
'remove' => $this
->t('remove'),
],
'#default_value' => !empty($defaults['action']) ? $defaults['action'] : NULL,
];
$row['operation'] = [
'#title' => $this
->t('Evaluation type'),
'#title_display' => 'invisible',
'#type' => 'select',
'#options' => $operations,
'#default_value' => !empty($defaults['operation']) ? $defaults['operation'] : NULL,
];
$row['pattern'] = [
'#title' => $this
->t('Pattern'),
'#title_display' => 'invisible',
'#type' => 'textfield',
'#size' => 50,
'#default_value' => !empty($defaults['pattern']) ? $defaults['pattern'] : NULL,
];
$row['case_sensitive'] = [
'#title' => $this
->t('Case sensitive'),
'#title_display' => 'invisible',
'#type' => 'checkbox',
'#default_value' => !empty($defaults['case_sensitive']) ? $defaults['case_sensitive'] : FALSE,
];
$row['enabled'] = [
'#title' => $this
->t('Case sensitive'),
'#title_display' => 'invisible',
'#type' => 'checkbox',
'#default_value' => !empty($defaults['enabled']) ? $defaults['enabled'] : FALSE,
];
$row['delete'] = [
'#type' => 'submit',
'#name' => 'delete[row-' . $uuid . ']',
'#value' => $this
->t('Delete'),
'#submit' => [
[
$this,
'deleteRuleSubmit',
],
],
'#attributes' => [
'data-delete-target' => $uuid,
],
'#ajax' => [
'callback' => [
$this,
'rulesAjaxCallback',
],
'wrapper' => 'keycloak-group-roles-replace',
'effect' => 'none',
],
];
return $row;
}