MyAccountAction::BASE_URL_EN.'/groups/create-my-group', 'fr' => MyAccountAction::BASE_URL_FR.'/groupes/creer-mon-groupe', ], name: 'create', )] public function createGroup(Request $request, #[CurrentUser] User $user): Response { // Admin must use the admin interface if ($user->isAdmin()) { return $this->redirect( $this->adminUrlGenerator ->setController(GroupCrudController::class) ->set('crudAction', Crud::PAGE_NEW) ->generateUrl() ); } $configuration = $this->configurationRepository->getInstanceConfigurationOrCreate(); if (!$configuration->isGroupsCreationForAll()) { throw $this->createAccessDeniedException('Cannot create group with current settings.'); } $newGroup = (new Group())->setInvitationByAdmin(true); $form = $this->createForm(CreateGroupFormType::class, $newGroup)->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $this->groupRepository->save($newGroup, true); $newAdminGroup = UserGroup::newUserGroup($user, $newGroup); $this->userGroupRepository->save($newAdminGroup, true); // force login to refresh the roles so the user can access its group // in the group admin interface $this->doctrine->refresh($user); $this->security->login($user); return $this->redirect( $this->adminUrlGenerator ->setController(GroupCrudController::class) ->setEntityId($newGroup->getId()) ->set('crudAction', Crud::PAGE_EDIT) ->generateUrl() ); } return $this->render('pages/group/create.html.twig', compact('form')); } }