diff --git a/Controller/ParticipationController.php b/Controller/ParticipationController.php index 1b23db177..4c597a818 100644 --- a/Controller/ParticipationController.php +++ b/Controller/ParticipationController.php @@ -102,7 +102,7 @@ class ParticipationController extends Controller if ($multiple === true) { $persons_ids = $request->query->get('persons_ids'); - if (!preg_match('/^([0-9]{1,},){1,}[0-9]{1,}$/', $persons_ids)) { + if (!preg_match('/^([0-9]{1,},{0,1}){1,}[0-9]{0,}$/', $persons_ids)) { throw new \RuntimeException("The persons_ids value should " . "contains int separated by ','"); } @@ -123,7 +123,7 @@ class ParticipationController extends Controller */ protected function newSingle(Request $request) { - $participation = $this->handleRequest($request, new Participation()); + $participation = $this->handleRequest($request, new Participation(), false); $this->denyAccessUnlessGranted(ParticipationVoter::CREATE, $participation, 'The user is not allowed to create this participation'); @@ -154,7 +154,7 @@ class ParticipationController extends Controller */ protected function newMultiple(Request $request) { - $participations = $this->handleRequest($request, new Participation()); + $participations = $this->handleRequest($request, new Participation(), true); foreach ($participations as $i => $participation) { @@ -249,7 +249,7 @@ class ParticipationController extends Controller public function createSingle(Request $request) { - $participation = $this->handleRequest($request, new Participation()); + $participation = $this->handleRequest($request, new Participation(), false); $this->denyAccessUnlessGranted(ParticipationVoter::CREATE, $participation, 'The user is not allowed to create this participation'); @@ -280,7 +280,7 @@ class ParticipationController extends Controller public function createMultiple(Request $request) { - $participations = $this->handleRequest($request, new Participation()); + $participations = $this->handleRequest($request, new Participation(), true); foreach($participations as $participation) { $this->denyAccessUnlessGranted(ParticipationVoter::CREATE, @@ -324,11 +324,15 @@ class ParticipationController extends Controller * * @param Request $request * @param Participation $participation - * @return Participation + * @param boolean $multiple (default false) + * @return Participation|Participations[] return one single participation if $multiple == false * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException if the event/person is not found * @throws \Symfony\Component\Security\Core\Exception\AccessDeniedException if the user does not have access to event/person */ - protected function handleRequest(Request $request, Participation $participation) + protected function handleRequest( + Request $request, + Participation $participation, + $multiple = false) { $em = $this->getDoctrine()->getManager(); if ($em->contains($participation)) { @@ -382,7 +386,7 @@ class ParticipationController extends Controller $participations[] = $participation; } - return count($participations) > 1 ? $participations : $participations[0]; + return $multiple ? $participations : $participations[0]; } /** diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml index 07f5ec9ce..0a38cf10b 100644 --- a/Resources/translations/messages.fr.yml +++ b/Resources/translations/messages.fr.yml @@ -33,7 +33,7 @@ Back to the event: Retour à l'événement The participation was created: La participation a été créée The participation was updated: La participation a été mise à jour Participation Edit: Modifier une participation -'Any of the requested people may be added on the event: they are maybe already participating.': 'Aucune des personnes suggérées ne peut être ajoutée à l''événement: elles sont peut-être déjà inscrites comme participantes.' +'None of the requested people may participate the event: they are maybe already participating.': 'Aucune des personnes indiquées ne peut être ajoutée à l''événement: elles sont peut-être déjà inscrites comme participantes.' 'The following people have been ignored because they are already participating on the event': '{1} La personne suivante a été ignorée parce qu''elle participe déjà à l''événement | ]1,Inf] Les personnes suivantes ont été ignorées parce qu''elles participent déjà à l''événement' There are no participation to edit for this event: Il n'y a pas de participation pour cet événement The participations have been successfully updated.: Les participations ont été mises à jour.