feat: streamlined role-revocation logic

This commit is contained in:
Björn Fromme committed 2026-08-10 16:24:41 +02:00
1 parent b39a78da82
commit fd5d478a5c
14 files changed
+426 -22

No files matched your search

+25 -2
View File
@@ -33,8 +33,6 @@ class UserType extends AbstractType
'required' => false,
'help' => 'Setzt die Rolle Admin voraus.',
])
// must stay ahead of the reason: properties are written in field order and
// unblocking clears the reasons
->add('disabled', CheckboxType::class, [
'label' => 'Account gesperrt',
'required' => false,
@@ -49,8 +47,33 @@ class UserType extends AbstractType
'data-action' => 'textarea-autosize#resize',
],
])
->add('disabledReasonInternal', TextareaType::class, [
'label' => 'Begründung intern',
'required' => false,
'help' => 'Wird der Benutzer:in nicht angezeigt.',
'attr' => [
'data-controller' => 'textarea-autosize',
'data-action' => 'textarea-autosize#resize',
],
])
;
// the reasons only ever describe a block, so an unblocked account carries none.
// Done after mapping instead of relying on the field order, as the submitted text
// would otherwise be written back over the reset done by setDisabled()
$builder->addEventListener(FormEvents::POST_SUBMIT, static function (FormEvent $event): void {
$user = $event->getData();
if (false === $user instanceof User || true === $user->isDisabled()) {
return;
}
$user
->setDisabledReason(null)
->setDisabledReasonInternal(null)
;
});
// hotel codes already assigned to the user may predate the catalog, so they are
// added as choices to keep them selectable instead of failing
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event): void {