Update budget element voter and improve form handling in permissions group

The base class of BudgetElementVoter has been changed to Voter, and the form handling in PermissionsGroupController has been improved for better validation. In addition, minor changes were made for better menu building and service configuration was updated. Unnecessary date validation in AbstractElement has been removed as well.
This commit is contained in:
2024-04-10 10:31:00 +02:00
parent 76fdd6d889
commit a3efae7831
5 changed files with 19 additions and 18 deletions

View File

@@ -49,7 +49,7 @@ final class PermissionsGroupController extends AbstractController
private readonly RoleScopeRepository $roleScopeRepository,
) {}
#[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/permissionsgroup/{id}/add_link_role_scope', name: 'admin_permissionsgroup_add_role_scope', methods: ['PUT'])]
#[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/permissionsgroup/{id}/add_link_role_scope', name: 'admin_permissionsgroup_add_role_scope', methods: ['POST'])]
public function addLinkRoleScopeAction(Request $request, int $id): Response
{
$permissionsGroup = $this->permissionsGroupRepository->find($id);
@@ -61,7 +61,9 @@ final class PermissionsGroupController extends AbstractController
$form = $this->createAddRoleScopeForm($permissionsGroup);
$form->handleRequest($request);
if ($form->isValid()) {
dump($form->isSubmitted());
if ($form->isSubmitted() && $form->isValid()) {
$roleScope = $this->getPersistentRoleScopeBy(
$form['composed_role_scope']->getData()->getRole(),
$form['composed_role_scope']->getData()->getScope()
@@ -74,7 +76,7 @@ final class PermissionsGroupController extends AbstractController
$this->em->flush();
$this->addFlash(
'notice',
'success',
$this->translator->trans('The permissions have been added')
);
@@ -416,7 +418,6 @@ final class PermissionsGroupController extends AbstractController
'admin_permissionsgroup_add_role_scope',
['id' => $permissionsGroup->getId()]
))
->setMethod('PUT')
->add('composed_role_scope', ComposedRoleScopeType::class)
->add('submit', SubmitType::class, ['label' => 'Add permission'])
->getForm();