Merge branch 'master' of gitlab.com:Chill-Projet/chill-bundles

This commit is contained in:
2021-12-20 12:58:35 +01:00
22 changed files with 128 additions and 73 deletions

View File

@@ -20,7 +20,6 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Role\Role;
use function array_filter;
use function array_values;
@@ -69,13 +68,4 @@ class PersonApiController extends ApiController
return $this->json(array_values($addresses), Response::HTTP_OK, [], ['groups' => ['read']]);
}
protected function createEntity(string $action, Request $request): object
{
return parent::createEntity($action, $request);
// TODO temporary hack to allow creation of person with fake center
/* $centers = $this->authorizationHelper->getReachableCenters($this->getUser(),
new Role(PersonVoter::CREATE));
$person->setCenter($centers[0]); */
}
}

View File

@@ -131,6 +131,8 @@ final class PersonController extends AbstractController
->getFlashBag()->add('error', $this->translator
->trans('This form contains errors'));
} elseif ($form->isSubmitted() && $form->isValid()) {
$this->em->flush();
$this->get('session')->getFlashBag()
->add(
'success',
@@ -138,8 +140,6 @@ final class PersonController extends AbstractController
->trans('The person data has been updated')
);
$this->em->flush();
return $this->redirectToRoute('chill_person_view', [
'person_id' => $person->getId(),
]);
@@ -216,13 +216,12 @@ final class PersonController extends AbstractController
);
}
$form = $this->createForm(CreationPersonType::class, $person, [
'validation_groups' => ['create'],
])->add('editPerson', SubmitType::class, [
'label' => 'Add the person',
])->add('createPeriod', SubmitType::class, [
'label' => 'Add the person and create an accompanying period',
]);
$form = $this->createForm(CreationPersonType::class, $person)
->add('editPerson', SubmitType::class, [
'label' => 'Add the person',
])->add('createPeriod', SubmitType::class, [
'label' => 'Add the person and create an accompanying period',
]);
$form->handleRequest($request);