feat: admin-managed roles and hotel codes
This commit is contained in:
@@ -27,6 +27,7 @@ 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']),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ use App\Form\Service\Condition\TravelStartCutoffReachedCondition;
|
||||
use App\Form\Service\CreateFieldStateProvider;
|
||||
use App\Form\Service\EditFieldStateProvider;
|
||||
use App\Model\DomainConfig;
|
||||
use App\Security\Role;
|
||||
use App\Service\ParticipantEligibilityChecker;
|
||||
use Symfony\Component\Form\FormView;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
@@ -124,6 +125,33 @@ class AppRuntime implements RuntimeExtensionInterface
|
||||
return $this->countryDataProvider->get($nationality)?->nationality;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @param string[] $roles
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function mapRoles(array $roles): array
|
||||
{
|
||||
$labels = Role::labels();
|
||||
|
||||
$mapped = [];
|
||||
|
||||
foreach ($roles as $role) {
|
||||
if ('ROLE_USER' === $role) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$mapped[] = $labels[$role] ?? $role;
|
||||
}
|
||||
|
||||
return $mapped;
|
||||
}
|
||||
|
||||
public function isParticipantEligible(BookingDto $bookingDto, int $participantIndex): bool
|
||||
{
|
||||
return $this->participantEligibilityService->isParticipantEligible($bookingDto, $participantIndex);
|
||||
|
||||
Reference in New Issue
Block a user