public function SimplesamlphpCustomAttributesController::ssoMappings in SimpleSAMLphp Custom Attribute Mapping 8
Creates the mapping table page.
Return value
array Table.
1 string reference to 'SimplesamlphpCustomAttributesController::ssoMappings'
File
- src/
Controller/ SimplesamlphpCustomAttributesController.php, line 52
Class
Namespace
Drupal\simplesamlphp_custom_attributes\ControllerCode
public function ssoMappings() {
// Load the mappings.
$mappings = $this->mappingConfig
->get('mappings');
// Load the user fields.
$fields = $this->entityFieldManager
->getFieldDefinitions('user', 'user');
// Set up the table.
$table = [
'#theme' => 'table',
'#header' => [
$this
->t('SAML Attribute'),
$this
->t('User Field'),
$this
->t('Operations'),
],
'#sticky' => TRUE,
'#empty' => $this
->t("There are no mappings. You can add one using the link above."),
];
// If there are mapping, process them.
if ($mappings) {
foreach ($mappings as $id => $mapping) {
// If this is a custom mapping, specify the correct label for it.
if ($mapping['field_name'] === 'custom') {
$user_field = $this
->t('Custom');
}
else {
if (isset($fields[$mapping['field_name']])) {
$user_field = $fields[$mapping['field_name']]
->getLabel();
}
else {
$user_field = $this
->t('Missing field: %field', [
'%field' => $mapping['field_name'],
]);
}
}
// Set up the operations dropbutton.
$operations = [
'#type' => 'dropbutton',
'#links' => [
'edit' => [
'title' => $this
->t('edit'),
'url' => Url::fromRoute('simplesamlphp_custom_attributes.edit', [
'mapping' => $id,
]),
],
'delete' => [
'title' => $this
->t('delete'),
'url' => Url::fromRoute('simplesamlphp_custom_attributes.delete', [
'mapping' => $id,
]),
],
],
];
// Add the row to the table.
$table['#rows'][$id] = [
'saml_attribute' => $mapping['attribute_name'],
'user_field' => $user_field,
'operations' => render($operations),
];
}
}
return $table;
}