mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-05 14:25:00 +00:00
apply more cs rules for php-cs
This commit is contained in:
@@ -37,11 +37,8 @@ use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\FormFactoryInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
use Symfony\Component\Security\Core\Role\Role;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
use function count;
|
||||
|
||||
/**
|
||||
* Class EventController.
|
||||
*/
|
||||
@@ -90,7 +87,6 @@ class EventController extends AbstractController
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $event_id
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/event/event/{event_id}/delete", name="chill_event__event_delete", requirements={"event_id"="\d+"}, methods={"GET", "DELETE"})
|
||||
*/
|
||||
public function deleteAction($event_id, Request $request): \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
|
||||
@@ -109,7 +105,7 @@ class EventController extends AbstractController
|
||||
|
||||
$form = $this->createDeleteForm($event_id);
|
||||
|
||||
if ($request->getMethod() === Request::METHOD_DELETE) {
|
||||
if (Request::METHOD_DELETE === $request->getMethod()) {
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isValid()) {
|
||||
@@ -142,9 +138,8 @@ class EventController extends AbstractController
|
||||
/**
|
||||
* Displays a form to edit an existing Event entity.
|
||||
*
|
||||
* @param $event_id
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/event/event/{event_id}/edit", name="chill_event__event_edit")
|
||||
*/
|
||||
public function editAction($event_id)
|
||||
@@ -168,11 +163,10 @@ class EventController extends AbstractController
|
||||
/**
|
||||
* List events subscriptions for a person.
|
||||
*
|
||||
* @param $person_id
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*
|
||||
* @throws \Doctrine\ORM\NonUniqueResultException
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/event/event/{person_id}/list", name="chill_event__list_by_person", methods={"GET"})
|
||||
*/
|
||||
public function listByPersonAction($person_id)
|
||||
@@ -233,9 +227,8 @@ class EventController extends AbstractController
|
||||
/**
|
||||
* Displays a form to create a new Event entity.
|
||||
*
|
||||
* @param Center $center
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/event/event/new", name="chill_event__event_new", methods={"GET", "POST"})
|
||||
*/
|
||||
public function newAction(?Center $center, Request $request)
|
||||
@@ -270,6 +263,7 @@ class EventController extends AbstractController
|
||||
|
||||
/**
|
||||
* First step of new Event form.
|
||||
*
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/event/event/new/pick-center", name="chill_event__event_new_pickcenter", options={null})
|
||||
*/
|
||||
public function newPickCenterAction()
|
||||
@@ -281,7 +275,7 @@ class EventController extends AbstractController
|
||||
*/
|
||||
$centers = $this->authorizationHelper->getReachableCenters($this->getUser(), $role);
|
||||
|
||||
if (count($centers) === 1) {
|
||||
if (1 === \count($centers)) {
|
||||
return $this->redirectToRoute('chill_event__event_new', [
|
||||
'center_id' => $centers[0]->getId(),
|
||||
]);
|
||||
@@ -316,9 +310,10 @@ class EventController extends AbstractController
|
||||
*
|
||||
* @ParamConverter("event", options={"id": "event_id"})
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/event/event/{event_id}/show", name="chill_event__event_show")
|
||||
*/
|
||||
public function showAction(Event $event, Request $request)
|
||||
@@ -351,7 +346,6 @@ class EventController extends AbstractController
|
||||
/**
|
||||
* Edits an existing Event entity.
|
||||
*
|
||||
* @param $event_id
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/event/event/{event_id}/update", name="chill_event__event_update", methods={"POST", "PUT"})
|
||||
*/
|
||||
public function updateAction(Request $request, $event_id): \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
|
||||
@@ -493,9 +487,9 @@ class EventController extends AbstractController
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*
|
||||
* @return Spreadsheet
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*/
|
||||
protected function createExportSpreadsheet(Event $event)
|
||||
{
|
||||
@@ -527,14 +521,14 @@ class EventController extends AbstractController
|
||||
$columnLetter = 'A';
|
||||
|
||||
foreach ($columnNames as $columnName) {
|
||||
$sheet->setCellValue($columnLetter . '8', $columnName);
|
||||
$sheet->setCellValue($columnLetter.'8', $columnName);
|
||||
++$columnLetter;
|
||||
}
|
||||
|
||||
$columnValues = [];
|
||||
|
||||
foreach ($event->getParticipations() as $participation) {
|
||||
/** @var Participation $participation */
|
||||
/* @var Participation $participation */
|
||||
$columnValues[] = [
|
||||
$participation->getPerson()->getId(),
|
||||
$participation->getPerson()->getFirstname(),
|
||||
@@ -553,7 +547,7 @@ class EventController extends AbstractController
|
||||
$columnLetter = 'A';
|
||||
|
||||
foreach ($columnValue as $value) {
|
||||
$sheet->setCellValue($columnLetter . $i, $value);
|
||||
$sheet->setCellValue($columnLetter.$i, $value);
|
||||
++$columnLetter;
|
||||
}
|
||||
++$i;
|
||||
@@ -563,9 +557,9 @@ class EventController extends AbstractController
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*/
|
||||
protected function exportParticipationsList(Event $event, Request $request)
|
||||
{
|
||||
@@ -575,7 +569,7 @@ class EventController extends AbstractController
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$data = $form->getData();
|
||||
$format = $data['format'];
|
||||
$filename = 'export_event' . $event->getId() . '_participations.' . $format;
|
||||
$filename = 'export_event'.$event->getId().'_participations.'.$format;
|
||||
|
||||
$spreadsheet = $this->createExportSpreadsheet($event);
|
||||
|
||||
@@ -604,7 +598,7 @@ class EventController extends AbstractController
|
||||
|
||||
$response = new StreamedResponse();
|
||||
$response->headers->set('Content-Type', $contentType);
|
||||
$response->headers->set('Content-Disposition', 'attachment;filename="' . $filename . '"');
|
||||
$response->headers->set('Content-Disposition', 'attachment;filename="'.$filename.'"');
|
||||
$response->setPrivate();
|
||||
$response->headers->addCacheControlDirective('no-cache', true);
|
||||
$response->headers->addCacheControlDirective('must-revalidate', true);
|
||||
@@ -639,8 +633,6 @@ class EventController extends AbstractController
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $event_id
|
||||
*
|
||||
* @return \Symfony\Component\Form\FormInterface
|
||||
*/
|
||||
private function createDeleteForm($event_id)
|
||||
|
@@ -24,6 +24,7 @@ class EventTypeController extends AbstractController
|
||||
{
|
||||
/**
|
||||
* Creates a new EventType entity.
|
||||
*
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/event_type/create", name="chill_eventtype_admin_create", methods={"POST"})
|
||||
*/
|
||||
public function createAction(Request $request)
|
||||
@@ -48,6 +49,7 @@ class EventTypeController extends AbstractController
|
||||
|
||||
/**
|
||||
* Deletes a EventType entity.
|
||||
*
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/event_type/{id}/delete", name="chill_eventtype_admin_delete", methods={"POST", "DELETE"})
|
||||
*/
|
||||
public function deleteAction(Request $request, mixed $id)
|
||||
@@ -72,6 +74,7 @@ class EventTypeController extends AbstractController
|
||||
|
||||
/**
|
||||
* Displays a form to edit an existing EventType entity.
|
||||
*
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/event_type/{id}/edit", name="chill_eventtype_admin_edit")
|
||||
*/
|
||||
public function editAction(mixed $id)
|
||||
@@ -96,6 +99,7 @@ class EventTypeController extends AbstractController
|
||||
|
||||
/**
|
||||
* Lists all EventType entities.
|
||||
*
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/event_type/", name="chill_eventtype_admin", options={null})
|
||||
*/
|
||||
public function indexAction()
|
||||
@@ -111,6 +115,7 @@ class EventTypeController extends AbstractController
|
||||
|
||||
/**
|
||||
* Displays a form to create a new EventType entity.
|
||||
*
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/event_type/new", name="chill_eventtype_admin_new")
|
||||
*/
|
||||
public function newAction()
|
||||
@@ -126,6 +131,7 @@ class EventTypeController extends AbstractController
|
||||
|
||||
/**
|
||||
* Finds and displays a EventType entity.
|
||||
*
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/event_type/{id}/show", name="chill_eventtype_admin_show")
|
||||
*/
|
||||
public function showAction(mixed $id)
|
||||
@@ -148,6 +154,7 @@ class EventTypeController extends AbstractController
|
||||
|
||||
/**
|
||||
* Edits an existing EventType entity.
|
||||
*
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/event_type/{id}/update", name="chill_eventtype_admin_update", methods={"POST", "PUT"})
|
||||
*/
|
||||
public function updateAction(Request $request, mixed $id)
|
||||
|
@@ -11,16 +11,12 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\EventBundle\Controller;
|
||||
|
||||
use ArrayIterator;
|
||||
use Chill\EventBundle\Entity\Event;
|
||||
use Chill\EventBundle\Entity\Participation;
|
||||
use Chill\EventBundle\Form\ParticipationType;
|
||||
use Chill\EventBundle\Security\Authorization\ParticipationVoter;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\Common\Collections\ReadableCollection;
|
||||
use LogicException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use RuntimeException;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
@@ -28,8 +24,6 @@ use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
use function count;
|
||||
|
||||
/**
|
||||
* Class ParticipationController.
|
||||
*/
|
||||
@@ -41,15 +35,14 @@ class ParticipationController extends AbstractController
|
||||
public function __construct(private readonly LoggerInterface $logger) {}
|
||||
|
||||
/**
|
||||
* @return Response|\Symfony\Component\HttpFoundation\RedirectResponse
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/event/participation/create", name="chill_event_participation_create")
|
||||
*/
|
||||
public function createAction(Request $request): \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
|
||||
public function createAction(Request $request): Response|\Symfony\Component\HttpFoundation\RedirectResponse
|
||||
{
|
||||
// test the request is correct
|
||||
try {
|
||||
$this->testRequest($request);
|
||||
} catch (RuntimeException $ex) {
|
||||
} catch (\RuntimeException $ex) {
|
||||
$this->logger->warning($ex->getMessage());
|
||||
|
||||
return (new Response())
|
||||
@@ -73,7 +66,7 @@ class ParticipationController extends AbstractController
|
||||
return (new Response())
|
||||
->setStatusCode(Response::HTTP_BAD_REQUEST)
|
||||
->setContent("You must provide either 'person_id' or "
|
||||
. "'persons_ids' argument in query");
|
||||
."'persons_ids' argument in query");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -159,10 +152,7 @@ class ParticipationController extends AbstractController
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Response|\Symfony\Component\HttpFoundation\RedirectResponse
|
||||
*/
|
||||
public function createMultiple(Request $request): \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
|
||||
public function createMultiple(Request $request): Response|\Symfony\Component\HttpFoundation\RedirectResponse
|
||||
{
|
||||
$participations = $this->handleRequest($request, new Participation(), true);
|
||||
|
||||
@@ -202,10 +192,7 @@ class ParticipationController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Response|\Symfony\Component\HttpFoundation\RedirectResponse
|
||||
*/
|
||||
public function createSingle(Request $request): \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
|
||||
public function createSingle(Request $request): Response|\Symfony\Component\HttpFoundation\RedirectResponse
|
||||
{
|
||||
$participation = $this->handleRequest($request, new Participation(), false);
|
||||
|
||||
@@ -246,10 +233,9 @@ class ParticipationController extends AbstractController
|
||||
/**
|
||||
* @param int $participation_id
|
||||
*
|
||||
* @return Response|\Symfony\Component\HttpFoundation\RedirectResponse
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/event/participation/{participation_id}/delete", name="chill_event_participation_delete", requirements={"participation_id"="\d+"}, methods={"GET", "DELETE"})
|
||||
*/
|
||||
public function deleteAction($participation_id, Request $request): \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
|
||||
public function deleteAction($participation_id, Request $request): Response|\Symfony\Component\HttpFoundation\RedirectResponse
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$participation = $em->getRepository(\Chill\EventBundle\Entity\Participation::class)->findOneBy([
|
||||
@@ -265,7 +251,7 @@ class ParticipationController extends AbstractController
|
||||
|
||||
$form = $this->createDeleteForm($participation_id);
|
||||
|
||||
if ($request->getMethod() === Request::METHOD_DELETE) {
|
||||
if (Request::METHOD_DELETE === $request->getMethod()) {
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isValid()) {
|
||||
@@ -293,8 +279,9 @@ class ParticipationController extends AbstractController
|
||||
/**
|
||||
* Show an edit form for the participation with the given id.
|
||||
*
|
||||
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException if the participation is not found
|
||||
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException if the participation is not found
|
||||
* @throws \Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException if the user is not allowed to edit the participation
|
||||
*
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/event/participation/{participation_id}/edit", name="chill_event_participation_edit")
|
||||
*/
|
||||
public function editAction(int $participation_id): Response
|
||||
@@ -327,10 +314,9 @@ class ParticipationController extends AbstractController
|
||||
*
|
||||
* @param int $event_id
|
||||
*
|
||||
* @return Response|\Symfony\Component\HttpFoundation\RedirectResponse
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/event/participation/{event_id}/edit_multiple", name="chill_event_participation_edit_multiple")
|
||||
*/
|
||||
public function editMultipleAction($event_id): \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
|
||||
public function editMultipleAction($event_id): Response|\Symfony\Component\HttpFoundation\RedirectResponse
|
||||
{
|
||||
$event = $this->getDoctrine()->getRepository(\Chill\EventBundle\Entity\Event::class)
|
||||
->find($event_id);
|
||||
@@ -341,13 +327,13 @@ class ParticipationController extends AbstractController
|
||||
|
||||
// check for ACL, on Event level and on Participation Level
|
||||
$this->denyAccessUnlessGranted('CHILL_EVENT_SEE', $event, 'You are not allowed '
|
||||
. 'to see this event');
|
||||
.'to see this event');
|
||||
|
||||
foreach ($event->getParticipations() as $participation) {
|
||||
$this->denyAccessUnlessGranted(
|
||||
ParticipationVoter::UPDATE,
|
||||
$participation,
|
||||
'You are not allowed to update participation with id ' . $participation->getId()
|
||||
'You are not allowed to update participation with id '.$participation->getId()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -385,15 +371,14 @@ class ParticipationController extends AbstractController
|
||||
* and decide if it should process a single or multiple participation. Depending
|
||||
* on this, the appropriate layout and form.
|
||||
*
|
||||
* @return Response|\Symfony\Component\HttpFoundation\RedirectResponse
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/event/participation/new", name="chill_event_participation_new")
|
||||
*/
|
||||
public function newAction(Request $request): \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
|
||||
public function newAction(Request $request): Response|\Symfony\Component\HttpFoundation\RedirectResponse
|
||||
{
|
||||
// test the request is correct
|
||||
try {
|
||||
$this->testRequest($request);
|
||||
} catch (RuntimeException $ex) {
|
||||
} catch (\RuntimeException $ex) {
|
||||
$this->logger->warning($ex->getMessage());
|
||||
|
||||
return (new Response())
|
||||
@@ -417,7 +402,7 @@ class ParticipationController extends AbstractController
|
||||
return (new Response())
|
||||
->setStatusCode(Response::HTTP_BAD_REQUEST)
|
||||
->setContent("You must provide either 'person_id' or "
|
||||
. "'persons_ids' argument in query");
|
||||
."'persons_ids' argument in query");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -478,13 +463,13 @@ class ParticipationController extends AbstractController
|
||||
}
|
||||
|
||||
$this->denyAccessUnlessGranted('CHILL_EVENT_SEE', $event, 'You are not allowed '
|
||||
. 'to see this event');
|
||||
.'to see this event');
|
||||
|
||||
foreach ($event->getParticipations() as $participation) {
|
||||
$this->denyAccessUnlessGranted(
|
||||
ParticipationVoter::UPDATE,
|
||||
$participation,
|
||||
'You are not allowed to update participation with id ' . $participation->getId()
|
||||
'You are not allowed to update participation with id '.$participation->getId()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -496,7 +481,7 @@ class ParticipationController extends AbstractController
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
|
||||
$this->addFlash('success', $this->get('translator')->trans('The participations '
|
||||
. 'have been successfully updated.'));
|
||||
.'have been successfully updated.'));
|
||||
|
||||
return $this->redirectToRoute(
|
||||
'chill_event__event_show',
|
||||
@@ -551,10 +536,10 @@ class ParticipationController extends AbstractController
|
||||
* If the request is multiple, the $participation object is cloned.
|
||||
* Limitations: the $participation should not be persisted.
|
||||
*
|
||||
* @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
|
||||
* @return Participation|Participation[] return one single participation if $multiple == 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,
|
||||
@@ -564,8 +549,7 @@ class ParticipationController extends AbstractController
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
if ($em->contains($participation)) {
|
||||
throw new LogicException('The participation object should not be managed by '
|
||||
. 'the object manager using the method ' . __METHOD__);
|
||||
throw new \LogicException('The participation object should not be managed by the object manager using the method '.__METHOD__);
|
||||
}
|
||||
|
||||
$event_id = $request->query->getInt('event_id', 0); // sf4 check:
|
||||
@@ -576,7 +560,7 @@ class ParticipationController extends AbstractController
|
||||
->find($event_id);
|
||||
|
||||
if (null === $event) {
|
||||
throw $this->createNotFoundException('The event with id ' . $event_id . ' is not found');
|
||||
throw $this->createNotFoundException('The event with id '.$event_id.' is not found');
|
||||
}
|
||||
|
||||
$this->denyAccessUnlessGranted(
|
||||
@@ -598,14 +582,14 @@ class ParticipationController extends AbstractController
|
||||
|
||||
foreach ($persons_ids as $person_id) {
|
||||
// clone if we have to reuse the $participation
|
||||
$participation = count($persons_ids) > 1 ? clone $participation : $participation;
|
||||
$participation = \count($persons_ids) > 1 ? clone $participation : $participation;
|
||||
|
||||
if (null !== $person_id) {
|
||||
$person = $em->getRepository(\Chill\PersonBundle\Entity\Person::class)
|
||||
->find($person_id);
|
||||
|
||||
if (null === $person) {
|
||||
throw $this->createNotFoundException('The person with id ' . $person_id . ' is not found');
|
||||
throw $this->createNotFoundException('The person with id '.$person_id.' is not found');
|
||||
}
|
||||
|
||||
$this->denyAccessUnlessGranted(
|
||||
@@ -634,16 +618,14 @@ class ParticipationController extends AbstractController
|
||||
*
|
||||
* If all participations must be ignored, an error is shown and the method redirects
|
||||
* to the event 'show' view with an appropriate flash message.
|
||||
*
|
||||
* @return Response|\Symfony\Component\HttpFoundation\RedirectResponse
|
||||
*/
|
||||
protected function newMultiple(Request $request): \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
|
||||
protected function newMultiple(Request $request): Response|\Symfony\Component\HttpFoundation\RedirectResponse
|
||||
{
|
||||
$participations = $this->handleRequest($request, new Participation(), true);
|
||||
$ignoredParticipations = $newParticipations = [];
|
||||
|
||||
foreach ($participations as $participation) {
|
||||
/** @var Participation $participation */
|
||||
/* @var Participation $participation */
|
||||
// check for authorization
|
||||
$this->denyAccessUnlessGranted(
|
||||
ParticipationVoter::CREATE,
|
||||
@@ -652,7 +634,6 @@ class ParticipationController extends AbstractController
|
||||
);
|
||||
|
||||
// create a collection of person's id participating to the event
|
||||
/** @var \Doctrine\Common\Collections\ArrayCollection $peopleParticipating */
|
||||
$peopleParticipating ??= $participation->getEvent()->getParticipations()->map(
|
||||
static fn (Participation $p) => $p->getPerson()->getId()
|
||||
);
|
||||
@@ -673,7 +654,7 @@ class ParticipationController extends AbstractController
|
||||
// if we do not have nay participants, redirect to event view
|
||||
$this->addFlash('error', $this->get('translator')->trans(
|
||||
'None of the requested people may participate '
|
||||
. 'the event: they are maybe already participating.'
|
||||
.'the event: they are maybe already participating.'
|
||||
));
|
||||
|
||||
return $this->redirectToRoute('chill_event__event_show', [
|
||||
@@ -681,7 +662,7 @@ class ParticipationController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
if (count($newParticipations) > 1) {
|
||||
if (\count($newParticipations) > 1) {
|
||||
// if we have multiple participations, show a form with multiple participations
|
||||
$form = $this->createCreateFormMultiple($newParticipations);
|
||||
|
||||
@@ -742,7 +723,7 @@ class ParticipationController extends AbstractController
|
||||
* - `person_id` and `persons_ids` are **not** both present ;
|
||||
* - `persons_id` is correct (contains only numbers and a ','.
|
||||
*
|
||||
* @throws RuntimeException if an error is detected
|
||||
* @throws \RuntimeException if an error is detected
|
||||
*/
|
||||
protected function testRequest(Request $request)
|
||||
{
|
||||
@@ -751,28 +732,24 @@ class ParticipationController extends AbstractController
|
||||
|
||||
if (true === $single && true === $multiple) {
|
||||
// we are not allowed to have both person_id and persons_ids
|
||||
throw new RuntimeException("You are not allow to provide both 'person_id' and "
|
||||
. "'persons_ids' simulaneously");
|
||||
throw new \RuntimeException("You are not allow to provide both 'person_id' and 'persons_ids' simulaneously");
|
||||
}
|
||||
|
||||
if (true === $multiple) {
|
||||
$persons_ids = $request->query->get('persons_ids');
|
||||
|
||||
if (!preg_match('/^([0-9]{1,},{0,1}){1,}[0-9]{0,}$/', (string) $persons_ids)) {
|
||||
throw new RuntimeException('The persons_ids value should '
|
||||
. "contains int separated by ','");
|
||||
throw new \RuntimeException('The persons_ids value should '."contains int separated by ','");
|
||||
}
|
||||
}
|
||||
|
||||
// check for event_id - this could be removed later
|
||||
if ($request->query->has('event_id') === false) {
|
||||
throw new RuntimeException('You must provide an event_id');
|
||||
if (false === $request->query->has('event_id')) {
|
||||
throw new \RuntimeException('You must provide an event_id');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $participation_id
|
||||
*
|
||||
* @return \Symfony\Component\Form\FormInterface
|
||||
*/
|
||||
private function createDeleteForm($participation_id)
|
||||
|
@@ -24,6 +24,7 @@ class RoleController extends AbstractController
|
||||
{
|
||||
/**
|
||||
* Creates a new Role entity.
|
||||
*
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/role/create", name="chill_event_admin_role_create", methods={"POST"})
|
||||
*/
|
||||
public function createAction(Request $request)
|
||||
@@ -48,6 +49,7 @@ class RoleController extends AbstractController
|
||||
|
||||
/**
|
||||
* Deletes a Role entity.
|
||||
*
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/role/{id}/delete", name="chill_event_admin_role_delete", methods={"POST", "DELETE"})
|
||||
*/
|
||||
public function deleteAction(Request $request, mixed $id)
|
||||
@@ -72,6 +74,7 @@ class RoleController extends AbstractController
|
||||
|
||||
/**
|
||||
* Displays a form to edit an existing Role entity.
|
||||
*
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/role/{id}/edit", name="chill_event_admin_role_edit")
|
||||
*/
|
||||
public function editAction(mixed $id)
|
||||
@@ -96,6 +99,7 @@ class RoleController extends AbstractController
|
||||
|
||||
/**
|
||||
* Lists all Role entities.
|
||||
*
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/role/", name="chill_event_admin_role", options={null})
|
||||
*/
|
||||
public function indexAction()
|
||||
@@ -111,6 +115,7 @@ class RoleController extends AbstractController
|
||||
|
||||
/**
|
||||
* Displays a form to create a new Role entity.
|
||||
*
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/role/new", name="chill_event_admin_role_new")
|
||||
*/
|
||||
public function newAction()
|
||||
@@ -126,6 +131,7 @@ class RoleController extends AbstractController
|
||||
|
||||
/**
|
||||
* Finds and displays a Role entity.
|
||||
*
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/role/{id}/show", name="chill_event_admin_role_show")
|
||||
*/
|
||||
public function showAction(mixed $id)
|
||||
@@ -148,6 +154,7 @@ class RoleController extends AbstractController
|
||||
|
||||
/**
|
||||
* Edits an existing Role entity.
|
||||
*
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/role/{id}/update", name="chill_event_admin_role_update", methods={"POST", "PUT"})
|
||||
*/
|
||||
public function updateAction(Request $request, mixed $id)
|
||||
|
@@ -24,6 +24,7 @@ class StatusController extends AbstractController
|
||||
{
|
||||
/**
|
||||
* Creates a new Status entity.
|
||||
*
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/status/create", name="chill_event_admin_status_create", methods={"POST"})
|
||||
*/
|
||||
public function createAction(Request $request)
|
||||
@@ -48,6 +49,7 @@ class StatusController extends AbstractController
|
||||
|
||||
/**
|
||||
* Deletes a Status entity.
|
||||
*
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/status/{id}/delete", name="chill_event_admin_status_delete", methods={"POST", "DELETE"})
|
||||
*/
|
||||
public function deleteAction(Request $request, mixed $id)
|
||||
@@ -72,6 +74,7 @@ class StatusController extends AbstractController
|
||||
|
||||
/**
|
||||
* Displays a form to edit an existing Status entity.
|
||||
*
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/status/{id}/edit", name="chill_event_admin_status_edit")
|
||||
*/
|
||||
public function editAction(mixed $id)
|
||||
@@ -96,6 +99,7 @@ class StatusController extends AbstractController
|
||||
|
||||
/**
|
||||
* Lists all Status entities.
|
||||
*
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/status/", name="chill_event_admin_status", options={null})
|
||||
*/
|
||||
public function indexAction()
|
||||
@@ -111,6 +115,7 @@ class StatusController extends AbstractController
|
||||
|
||||
/**
|
||||
* Displays a form to create a new Status entity.
|
||||
*
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/status/new", name="chill_event_admin_status_new")
|
||||
*/
|
||||
public function newAction()
|
||||
@@ -126,6 +131,7 @@ class StatusController extends AbstractController
|
||||
|
||||
/**
|
||||
* Finds and displays a Status entity.
|
||||
*
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/status/{id}/show", name="chill_event_admin_status_show")
|
||||
*/
|
||||
public function showAction(mixed $id)
|
||||
@@ -148,6 +154,7 @@ class StatusController extends AbstractController
|
||||
|
||||
/**
|
||||
* Edits an existing Status entity.
|
||||
*
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/event/status/{id}/update", name="chill_event_admin_status_update", methods={"POST", "PUT"})
|
||||
*/
|
||||
public function updateAction(Request $request, mixed $id)
|
||||
|
Reference in New Issue
Block a user