feat: align role assignment logic with myep-team

This commit is contained in:
Björn Fromme
2026-08-19 12:14:09 +02:00
parent 5a3957e143
commit 0c667d6b69
23 changed files with 1109 additions and 527 deletions
+2 -1
View File
@@ -27,7 +27,8 @@ class AppExtension extends AbstractExtension
new TwigFilter('map_status', [AppRuntime::class, 'mapStatus']),
new TwigFilter('map_country', [AppRuntime::class, 'mapCountry']),
new TwigFilter('map_nationality', [AppRuntime::class, 'mapNationality']),
new TwigFilter('map_roles', [AppRuntime::class, 'mapRoles']),
new TwigFilter('effective_roles', [AppRuntime::class, 'effectiveRoles']),
new TwigFilter('nominated_roles', [AppRuntime::class, 'nominatedRoles']),
];
}
+28 -6
View File
@@ -126,22 +126,44 @@ class AppRuntime implements RuntimeExtensionInterface
}
/**
* Turns the roles stored on a User into the labels the edit form uses.
*
* ROLE_USER is dropped because every account holds it implicitly; a role without a label
* is passed through unchanged so it stays visible instead of silently disappearing.
* The labels of the roles an account actually holds — no ROLE_USER, no nominations.
*
* @param string[] $roles
*
* @return string[]
*/
public function mapRoles(array $roles): array
public function effectiveRoles(array $roles): array
{
return $this->roleLabels(Role::effectiveOnly($roles));
}
/**
* The labels of the roles the BusPro CRM claims for an account but nobody has approved.
*
* @param string[] $roles
*
* @return string[]
*/
public function nominatedRoles(array $roles): array
{
return array_values(Role::nominatedFrom($roles));
}
/**
* A role without a label is passed through unchanged so it stays visible instead of
* silently disappearing.
*
* @param string[] $roles
*
* @return string[]
*/
private function roleLabels(array $roles): array
{
$labels = Role::labels();
$mapped = [];
foreach (Role::assignedOnly($roles) as $role) {
foreach ($roles as $role) {
$mapped[] = $labels[$role] ?? $role;
}