diff --git a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php index 3f94cad67..153ffd01a 100644 --- a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php +++ b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php @@ -135,7 +135,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente #[Serializer\Groups(['calendar:read', 'read', 'calendar:light', 'docgen:read'])] #[Assert\NotNull(message: 'calendar.A main user is mandatory')] #[ORM\ManyToOne(targetEntity: User::class)] - #[Serializer\Context(normalizationContext: ['read'], groups: ['calendar:light'])] + #[Serializer\Context(normalizationContext: ['groups' => ['read']], groups: ['read', 'calendar:light'])] private ?User $mainUser = null; #[ORM\ManyToOne(targetEntity: Person::class)] @@ -149,7 +149,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente #[Assert\Count(min: 1, minMessage: 'calendar.At least {{ limit }} person is required.')] #[ORM\ManyToMany(targetEntity: Person::class, inversedBy: 'calendars')] #[ORM\JoinTable(name: 'chill_calendar.calendar_to_persons')] - #[Serializer\Context(normalizationContext: ['read'], groups: ['calendar:light'])] + #[Serializer\Context(normalizationContext: ['groups' => ['read']], groups: ['calendar:light'])] private Collection $persons; #[Serializer\Groups(['calendar:read'])] @@ -162,7 +162,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente #[Serializer\Groups(['calendar:read', 'read', 'calendar:light', 'docgen:read'])] #[ORM\ManyToMany(targetEntity: ThirdParty::class)] #[ORM\JoinTable(name: 'chill_calendar.calendar_to_thirdparties')] - #[Serializer\Context(normalizationContext: ['read'], groups: ['calendar:light'])] + #[Serializer\Context(normalizationContext: ['groups' => ['read']], groups: ['calendar:light'])] private Collection $professionals; #[Serializer\Groups(['docgen:read'])] @@ -175,12 +175,12 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente #[Serializer\Groups(['calendar:read', 'read', 'calendar:light', 'docgen:read'])] #[Assert\NotNull(message: 'calendar.A start date is required')] #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE, nullable: false)] - #[Serializer\Context(normalizationContext: ['read'], groups: ['calendar:light'])] + #[Serializer\Context(normalizationContext: ['groups' => ['read']], groups: ['calendar:light'])] private ?\DateTimeImmutable $startDate = null; #[Serializer\Groups(['calendar:read', 'read', 'calendar:light'])] #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 255, nullable: false, options: ['default' => 'valid'])] - #[Serializer\Context(normalizationContext: ['read'], groups: ['calendar:light'])] + #[Serializer\Context(normalizationContext: ['groups' => ['read']], groups: ['calendar:light'])] private string $status = self::STATUS_VALID; #[Serializer\Groups(['docgen:read'])] diff --git a/src/Bundle/ChillMainBundle/Export/Formatter/CSVFormatter.php b/src/Bundle/ChillMainBundle/Export/Formatter/CSVFormatter.php index 17fe6a67f..dd5e66acf 100644 --- a/src/Bundle/ChillMainBundle/Export/Formatter/CSVFormatter.php +++ b/src/Bundle/ChillMainBundle/Export/Formatter/CSVFormatter.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\MainBundle\Export\Formatter; +use Chill\MainBundle\Export\ExportGenerationContext; use Chill\MainBundle\Export\ExportManager; use Chill\MainBundle\Export\FormatterInterface; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; @@ -24,6 +25,8 @@ use Symfony\Contracts\Translation\TranslatorInterface; * curl --user "center a_social:password" "http://localhost:8000/fr/exports/generate/count_person?export[filters][person_gender_filter][enabled]=&export[filters][person_nationality_filter][enabled]=&export[filters][person_nationality_filter][form][nationalities]=&export[aggregators][person_nationality_aggregator][order]=1&export[aggregators][person_nationality_aggregator][form][group_by_level]=country&export[submit]=&export[_token]=RHpjHl389GrK-bd6iY5NsEqrD5UKOTHH40QKE9J1edU" --globoff. * * @deprecated this formatter is not used any more + * + * @method generate($result, $formatterData, string $exportAlias, array $exportData, array $filtersData, array $aggregatorsData, ExportGenerationContext $context) */ class CSVFormatter implements FormatterInterface { @@ -118,7 +121,7 @@ class CSVFormatter implements FormatterInterface array $exportData, array $filtersData, array $aggregatorsData, - \Chill\MainBundle\Export\ExportGenerationContext $context, + ExportGenerationContext $context, ): Response { $this->result = $result; $this->orderingHeaders($formatterData); @@ -420,7 +423,7 @@ class CSVFormatter implements FormatterInterface * * @throws \RuntimeException */ - private function getPositionnalHeaders($position) + private function getPositionnalHeaders(string $position): array { $headers = []; @@ -438,4 +441,19 @@ class CSVFormatter implements FormatterInterface return $headers; } + + public function normalizeFormData(array $formData): array + { + return $formData; + } + + public function denormalizeFormData(array $formData, int $fromVersion): array + { + return []; + } + + public function getNormalizationVersion(): int + { + return 1; + } } diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodController.php index 37d72c61b..b9324b2fb 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodController.php @@ -23,7 +23,6 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Validator\ConstraintViolationListInterface; use Symfony\Component\Validator\Validator\ValidatorInterface; @@ -41,7 +40,6 @@ class AccompanyingPeriodController extends AbstractController private readonly ValidatorInterface $validator, private readonly TranslatorInterface $translator, private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry, - private readonly RequestStack $requestStack, ) {} /** @@ -55,12 +53,11 @@ class AccompanyingPeriodController extends AbstractController $this->denyAccessUnlessGranted(PersonVoter::UPDATE, $person, 'You are not allowed to update this person'); if (false === $person->isOpen()) { - $this->requestStack->getSession()->getFlashBag() - ->add('error', $this->translator - ->trans( - 'Beware period is closed', - ['%name%' => $person->__toString()] - )); + $this->addFlash('error', $this->translator + ->trans( + 'Beware period is closed', + ['%name%' => $person->__toString()] + )); return $this->redirectToRoute('chill_person_accompanying_period_list', [ 'person_id' => $person->getId(), @@ -82,11 +79,10 @@ class AccompanyingPeriodController extends AbstractController $errors = $this->_validatePerson($person); if (0 === \count($errors)) { - $this->requestStack->getSession()->getFlashBag() - ->add('success', $this->translator - ->trans('An accompanying period has been closed.', [ - '%name%' => $person->__toString(), - ])); + $this->addFlash('success', $this->translator + ->trans('An accompanying period has been closed.', [ + '%name%' => $person->__toString(), + ])); $this->managerRegistry->getManager()->flush(); @@ -94,25 +90,21 @@ class AccompanyingPeriodController extends AbstractController 'person_id' => $person->getId(), ]); } - $this->requestStack->getSession()->getFlashBag() - ->add('error', $this->translator - ->trans('Error! Period not closed!')); + $this->addFlash('error', $this->translator + ->trans('Error! Period not closed!')); foreach ($errors as $error) { - $this->requestStack->getSession()->getFlashBag() - ->add('info', $error->getMessage()); + $this->addFlash('info', $error->getMessage()); } } else { // if form is not valid - $this->requestStack->getSession()->getFlashBag() - ->add( - 'error', - $this->translator - ->trans('Pediod closing form is not valid') - ); + $this->addFlash( + 'error', + $this->translator + ->trans('Pediod closing form is not valid') + ); foreach ($form->getErrors() as $error) { - $this->requestStack->getSession()->getFlashBag() - ->add('info', $error->getMessage()); + $this->addFlash('info', $error->getMessage()); } } } @@ -153,7 +145,6 @@ class AccompanyingPeriodController extends AbstractController if ('POST' === $request->getMethod()) { $form->handleRequest($request); $errors = $this->_validatePerson($person); - $flashBag = $this->requestStack->getSession()->getFlashBag(); if ( $form->isValid(['Default', 'closed']) @@ -162,7 +153,7 @@ class AccompanyingPeriodController extends AbstractController $em = $this->managerRegistry->getManager(); $em->persist($accompanyingPeriod); $em->flush(); - $flashBag->add( + $this->addFlash( 'success', $this->translator->trans( 'A period has been created.' @@ -173,11 +164,11 @@ class AccompanyingPeriodController extends AbstractController 'person_id' => $person->getId(), ]); } - $flashBag->add('error', $this->translator + $this->addFlash('error', $this->translator ->trans('Error! Period not created!')); foreach ($errors as $error) { - $flashBag->add('info', $error->getMessage()); + $this->addFlash('info', $error->getMessage()); } } @@ -229,12 +220,11 @@ class AccompanyingPeriodController extends AbstractController // in case the person is already open if ($person->isOpen()) { - $this->requestStack->getSession()->getFlashBag() - ->add('error', $this->translator - ->trans( - 'Error! Period %name% is not closed ; it can be open', - ['%name%' => $person->__toString()] - )); + $this->addFlash('error', $this->translator + ->trans( + 'Error! Period %name% is not closed ; it can be open', + ['%name%' => $person->__toString()] + )); return $this->redirectToRoute('chill_person_accompanying_period_list', [ 'person_id' => $person->getId(), @@ -261,12 +251,11 @@ class AccompanyingPeriodController extends AbstractController $errors = $this->_validatePerson($person); if (\count($errors) <= 0) { - $this->requestStack->getSession()->getFlashBag() - ->add('success', $this->translator - ->trans( - 'An accompanying period has been opened.', - ['%name%' => $person->__toString()] - )); + $this->addFlash('success', $this->translator + ->trans( + 'An accompanying period has been opened.', + ['%name%' => $person->__toString()] + )); $this->managerRegistry->getManager()->flush(); @@ -274,21 +263,18 @@ class AccompanyingPeriodController extends AbstractController 'person_id' => $person->getId(), ]); } - $this->requestStack->getSession()->getFlashBag() - ->add('error', $this->translator - ->trans('Period not opened')); + $this->addFlash('error', $this->translator + ->trans('Period not opened')); foreach ($errors as $error) { - $this->requestStack->getSession()->getFlashBag() - ->add('info', $error->getMessage()); + $this->addFlash('info', $error->getMessage()); } } else { // if errors in forms - $this->requestStack->getSession()->getFlashBag() - ->add( - 'error', - $this->translator - ->trans('Period not opened : form is invalid') - ); + $this->addFlash( + 'error', + $this->translator + ->trans('Period not opened : form is invalid') + ); } } @@ -386,7 +372,6 @@ class AccompanyingPeriodController extends AbstractController if ('POST' === $request->getMethod()) { $form->handleRequest($request); $errors = $this->_validatePerson($person); - $flashBag = $this->requestStack->getSession()->getFlashBag(); if ( $form->isValid(['Default', 'closed']) @@ -394,7 +379,7 @@ class AccompanyingPeriodController extends AbstractController ) { $em->flush(); - $flashBag->add( + $this->addFlash( 'success', $this->translator->trans('An accompanying period has been updated.') ); @@ -404,11 +389,11 @@ class AccompanyingPeriodController extends AbstractController ]); } - $flashBag->add('error', $this->translator + $this->addFlash('error', $this->translator ->trans('Error when updating the period')); foreach ($errors as $error) { - $flashBag->add('info', $error->getMessage()); + $this->addFlash('info', $error->getMessage()); } } diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonController.php b/src/Bundle/ChillPersonBundle/Controller/PersonController.php index ba6edec67..c22584505 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonController.php @@ -75,18 +75,17 @@ final class PersonController extends AbstractController $form->handleRequest($request); if ($form->isSubmitted() && !$form->isValid()) { - $this->requestStack->getSession() - ->getFlashBag()->add('error', $this->translator + + $this->addFlash('error', $this->translator ->trans('This form contains errors')); } elseif ($form->isSubmitted() && $form->isValid()) { $this->em->flush(); - $this->requestStack->getSession()->getFlashBag() - ->add( - 'success', - $this->translator - ->trans('The person data has been updated') - ); + $this->addFlash( + 'success', + $this->translator + ->trans('The person data has been updated') + ); return $this->redirectToRoute('chill_person_view', [ 'person_id' => $person->getId(), diff --git a/src/Bundle/ChillReportBundle/Controller/ReportController.php b/src/Bundle/ChillReportBundle/Controller/ReportController.php index 71f874abe..b682adfe8 100644 --- a/src/Bundle/ChillReportBundle/Controller/ReportController.php +++ b/src/Bundle/ChillReportBundle/Controller/ReportController.php @@ -22,7 +22,6 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\FormType; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Contracts\Translation\TranslatorInterface; /** @@ -39,7 +38,6 @@ class ReportController extends AbstractController private readonly PaginatorFactory $paginator, private readonly TranslatorInterface $translator, private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry, - private readonly RequestStack $requestStack, ) {} /** @@ -80,23 +78,20 @@ class ReportController extends AbstractController $em->persist($entity); $em->flush(); - $this->requestStack->getSession() - ->getFlashBag() - ->add( - 'success', - $this->translator - ->trans('Success : report created!') - ); + $this->addFlash( + 'success', + $this->translator + ->trans('Success : report created!') + ); return $this->redirectToRoute('report_view', ['person_id' => $person_id, 'report_id' => $entity->getId()]); } - $this->requestStack->getSession() - ->getFlashBag()->add( - 'error', - $this->translator - ->trans('The form is not valid. The report has not been created !') - ); + $this->addFlash( + 'error', + $this->translator + ->trans('The form is not valid. The report has not been created !') + ); return $this->render('@ChillReport/Report/new.html.twig', [ 'entity' => $entity, @@ -415,13 +410,11 @@ class ReportController extends AbstractController if ($editForm->isSubmitted() && $editForm->isValid()) { $em->flush(); - $this->requestStack->getSession() - ->getFlashBag() - ->add( - 'success', - $this->translator - ->trans('Success : report updated!') - ); + $this->addFlash( + 'success', + $this->translator + ->trans('Success : report updated!') + ); $person = $report->getPerson(); @@ -435,13 +428,11 @@ class ReportController extends AbstractController return $this->redirectToRoute('report_view', ['person_id' => $report->getPerson()->getId(), 'report_id' => $report_id]); } - $this->requestStack->getSession() - ->getFlashBag() - ->add( - 'error', - $this->translator - ->trans('The form is not valid. The report has not been updated !') - ); + $this->addFlash( + 'error', + $this->translator + ->trans('The form is not valid. The report has not been updated !') + ); return $this->render('@ChillReport/Report/edit.html.twig', [ 'edit_form' => $editForm,