From ecb8ef0146fb4ea0b32731f10a03453d9c1ae24c Mon Sep 17 00:00:00 2001 From: Lucas Silva Date: Tue, 21 Mar 2023 14:34:38 +0100 Subject: [PATCH 001/724] add notification service for AccompanyingPeriodWork in show --- ...ompanyingPeriodWorkNotificationHandler.php | 46 +++++++++++++++++++ .../AccompanyingCourseWork/_item.html.twig | 7 +++ .../AccompanyingCourseWork/show.html.twig | 27 +++++++++-- .../showInNotification.html.twig | 28 +++++++++++ .../showInNotification.html.twig | 1 + .../config/services/notification.yaml | 3 ++ 6 files changed, 109 insertions(+), 3 deletions(-) create mode 100644 src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodWorkNotificationHandler.php create mode 100644 src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showInNotification.html.twig diff --git a/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodWorkNotificationHandler.php b/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodWorkNotificationHandler.php new file mode 100644 index 000000000..dbb30e983 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodWorkNotificationHandler.php @@ -0,0 +1,46 @@ +accompanyingPeriodWorkRepository = $accompanyingPeriodWorkRepository; + } + + public function getTemplate(Notification $notification, array $options = []): string + { + return 'ChillPersonBundle:AccompanyingCourseWork:showInNotification.html.twig'; + } + + public function getTemplateData(Notification $notification, array $options = []): array + { + return [ + 'notification' => $notification, + 'work' => $this->accompanyingPeriodWorkRepository->find($notification->getRelatedEntityId()), + ]; + } + + public function supports(Notification $notification, array $options = []): bool + { + return $notification->getRelatedEntityClass() === AccompanyingPeriodWork::class; + } +} diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_item.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_item.html.twig index 001ac1661..728554aaf 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_item.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_item.html.twig @@ -129,6 +129,13 @@ {% if displayAction is defined and displayAction == true %} diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showInNotification.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showInNotification.html.twig new file mode 100644 index 000000000..70a1a0980 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showInNotification.html.twig @@ -0,0 +1,28 @@ +{% macro recordAction(work) %} +
  • + +
  • +{% endmacro %} +{% if work is not null %} +
    + {% if is_granted('CHILL_PERSON_ACCOMPANYING_PERIOD_SEE', work) %} + {% else %} + {% endif %} + {% include 'ChillPersonBundle:AccompanyingCourseWork:_item.html.twig' with { + 'itemBlocClass': 'bg-chill-llight-gray', + 'displayAction': true, + 'displayContent': 'short', + 'displayFontSmall': true, + 'w': work + } %} +
    + {{ 'This is the minimal period details'|trans ~ ': ' ~ work.id }}
    + {{ 'You are getting a notification for a period you are not allowed to see'|trans }} +
    +
    +{% else %} +
    + {{ 'You are getting a notification for a period which does not exists any more'|trans }} +
    +{% endif %} diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/showInNotification.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/showInNotification.html.twig index 630dcf100..d6d13cd17 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/showInNotification.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/showInNotification.html.twig @@ -6,6 +6,7 @@ {% endmacro %} {% if period is not null %} + {{ dump(period) }}
    {% if is_granted('CHILL_PERSON_ACCOMPANYING_PERIOD_SEE', period) %} {% include 'ChillPersonBundle:AccompanyingPeriod:_list_item.html.twig' with { diff --git a/src/Bundle/ChillPersonBundle/config/services/notification.yaml b/src/Bundle/ChillPersonBundle/config/services/notification.yaml index a7c9f4142..7fd64bfbf 100644 --- a/src/Bundle/ChillPersonBundle/config/services/notification.yaml +++ b/src/Bundle/ChillPersonBundle/config/services/notification.yaml @@ -2,3 +2,6 @@ services: Chill\PersonBundle\Notification\AccompanyingPeriodNotificationHandler: autowire: true autoconfigure: true + Chill\PersonBundle\Notification\AccompanyingPeriodWorkNotificationHandler: + autowire: true + autoconfigure: true From 457d71b4f3e0870555bd3ebc12b840d09a633ee6 Mon Sep 17 00:00:00 2001 From: Lucas Silva Date: Tue, 21 Mar 2023 16:03:22 +0100 Subject: [PATCH 002/724] add service + template pour documents --- ...eriodWorkEvaluationNotificationHandler.php | 46 +++++++++++++++++++ .../_objectifs_results_evaluations.html.twig | 6 ++- .../showEvaluationInNotification.html.twig | 24 ++++++++++ .../config/services/notification.yaml | 3 ++ 4 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodWorkEvaluationNotificationHandler.php create mode 100644 src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showEvaluationInNotification.html.twig diff --git a/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodWorkEvaluationNotificationHandler.php b/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodWorkEvaluationNotificationHandler.php new file mode 100644 index 000000000..63e395a98 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodWorkEvaluationNotificationHandler.php @@ -0,0 +1,46 @@ +accompanyingPeriodWorkEvaluationRepository = $accompanyingPeriodWorkEvaluationRepository; + } + + public function getTemplate(Notification $notification, array $options = []): string + { + return 'ChillPersonBundle:AccompanyingCourseWork:showEvaluationInNotification.html.twig'; + } + + public function getTemplateData(Notification $notification, array $options = []): array + { + return [ + 'notification' => $notification, + 'evaluation' => $this->accompanyingPeriodWorkEvaluationRepository->find($notification->getRelatedEntityId()), + ]; + } + + public function supports(Notification $notification, array $options = []): bool + { + return $notification->getRelatedEntityClass() === AccompanyingPeriodWorkEvaluation::class; + } +} diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_objectifs_results_evaluations.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_objectifs_results_evaluations.html.twig index 0dd0cc84a..3778f312b 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_objectifs_results_evaluations.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_objectifs_results_evaluations.html.twig @@ -129,13 +129,15 @@ {% import "@ChillDocStore/Macro/macro.html.twig" as m %} {% import "@ChillDocStore/Macro/macro_mimeicon.html.twig" as mm %} - {% if e.documents|length > 0 %} {% for d in e.documents %} + {% endfor %} @@ -143,7 +145,7 @@ {% else %} {{ 'No document found'|trans }} {% endif %} - + {% endif %} diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showEvaluationInNotification.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showEvaluationInNotification.html.twig new file mode 100644 index 000000000..d35cf44c3 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showEvaluationInNotification.html.twig @@ -0,0 +1,24 @@ +{% macro recordAction(evaluation) %} +
  • + +
  • +{% endmacro %} +{% if evaluation is not null %} +
    + {% if is_granted('CHILL_PERSON_ACCOMPANYING_PERIOD_SEE', evaluation) %} + {% else %} + {% endif %} + {% include 'ChillPersonBundle:AccompanyingCourseWork:_objectifs_results_evaluations.html.twig' with { + 'w': evaluation.accompanyingPeriodWork + } %} +
    + {{ 'This is the minimal period details'|trans ~ ': ' ~ evaluation.id }}
    + {{ 'You are getting a notification for a period you are not allowed to see'|trans }} +
    +
    +{% else %} +
    + {{ 'You are getting a notification for a period which does not exists any more'|trans }} +
    +{% endif %} diff --git a/src/Bundle/ChillPersonBundle/config/services/notification.yaml b/src/Bundle/ChillPersonBundle/config/services/notification.yaml index 7fd64bfbf..360873bee 100644 --- a/src/Bundle/ChillPersonBundle/config/services/notification.yaml +++ b/src/Bundle/ChillPersonBundle/config/services/notification.yaml @@ -5,3 +5,6 @@ services: Chill\PersonBundle\Notification\AccompanyingPeriodWorkNotificationHandler: autowire: true autoconfigure: true + Chill\PersonBundle\Notification\AccompanyingPeriodWorkEvaluationNotificationHandler: + autowire: true + autoconfigure: true From 1a759cabe4fc369ba6bd6eac99303d774b6816ee Mon Sep 17 00:00:00 2001 From: Lucas Silva Date: Wed, 22 Mar 2023 18:11:41 +0100 Subject: [PATCH 003/724] changing evaluation for document -> no render for twig --- ...kEvaluationDocumentNotificationHandler.php} | 18 +++++++++--------- .../_objectifs_results_evaluations.html.twig | 4 +++- ...EvaluationDocumentInNotification.html.twig} | 12 +++++++----- .../config/services/notification.yaml | 2 +- 4 files changed, 20 insertions(+), 16 deletions(-) rename src/Bundle/ChillPersonBundle/Notification/{AccompanyingPeriodWorkEvaluationNotificationHandler.php => AccompanyingPeriodWorkEvaluationDocumentNotificationHandler.php} (60%) rename src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/{showEvaluationInNotification.html.twig => showEvaluationDocumentInNotification.html.twig} (81%) diff --git a/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodWorkEvaluationNotificationHandler.php b/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodWorkEvaluationDocumentNotificationHandler.php similarity index 60% rename from src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodWorkEvaluationNotificationHandler.php rename to src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodWorkEvaluationDocumentNotificationHandler.php index 63e395a98..1f3ed0fb6 100644 --- a/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodWorkEvaluationNotificationHandler.php +++ b/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodWorkEvaluationDocumentNotificationHandler.php @@ -14,33 +14,33 @@ namespace Chill\PersonBundle\Notification; use Chill\MainBundle\Entity\Notification; use Chill\MainBundle\Notification\NotificationHandlerInterface; -use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation; -use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationRepository; +use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocument; +use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocumentRepository; -final class AccompanyingPeriodWorkEvaluationNotificationHandler implements NotificationHandlerInterface +final class AccompanyingPeriodWorkEvaluationDocumentNotificationHandler implements NotificationHandlerInterface { - private AccompanyingPeriodWorkEvaluationRepository $accompanyingPeriodWorkEvaluationRepository; + private AccompanyingPeriodWorkEvaluationDocumentRepository $accompanyingPeriodWorkEvaluationDocumentRepository; - public function __construct(AccompanyingPeriodWorkEvaluationRepository $accompanyingPeriodWorkEvaluationRepository) + public function __construct(AccompanyingPeriodWorkEvaluationDocumentRepository $accompanyingPeriodWorkEvaluationDocumentRepository) { - $this->accompanyingPeriodWorkEvaluationRepository = $accompanyingPeriodWorkEvaluationRepository; + $this->accompanyingPeriodWorkEvaluationDocumentRepository = $accompanyingPeriodWorkEvaluationDocumentRepository; } public function getTemplate(Notification $notification, array $options = []): string { - return 'ChillPersonBundle:AccompanyingCourseWork:showEvaluationInNotification.html.twig'; + return 'ChillPersonBundle:AccompanyingCourseWork:showEvaluationDocumentInNotification.html.twig'; } public function getTemplateData(Notification $notification, array $options = []): array { return [ 'notification' => $notification, - 'evaluation' => $this->accompanyingPeriodWorkEvaluationRepository->find($notification->getRelatedEntityId()), + 'document' => $this->accompanyingPeriodWorkEvaluationDocumentRepository->find($notification->getRelatedEntityId()), ]; } public function supports(Notification $notification, array $options = []): bool { - return $notification->getRelatedEntityClass() === AccompanyingPeriodWorkEvaluation::class; + return $notification->getRelatedEntityClass() === AccompanyingPeriodWorkEvaluationDocument::class; } } diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_objectifs_results_evaluations.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_objectifs_results_evaluations.html.twig index 3778f312b..029e347b1 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_objectifs_results_evaluations.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_objectifs_results_evaluations.html.twig @@ -130,13 +130,15 @@ {% import "@ChillDocStore/Macro/macro.html.twig" as m %} {% import "@ChillDocStore/Macro/macro_mimeicon.html.twig" as mm %} {% if e.documents|length > 0 %} +
    {{ d.title }} {{ mm.mimeIcon(d.storedObject.type) }} + + {{ d.storedObject|chill_document_button_group(d.title, is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_UPDATE', w), {'small': true}) }}
    {% for d in e.documents %} + {{ dump(d) }} diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showEvaluationInNotification.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showEvaluationDocumentInNotification.html.twig similarity index 81% rename from src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showEvaluationInNotification.html.twig rename to src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showEvaluationDocumentInNotification.html.twig index d35cf44c3..b9fd07a11 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showEvaluationInNotification.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showEvaluationDocumentInNotification.html.twig @@ -1,19 +1,21 @@ -{% macro recordAction(evaluation) %} +{% macro recordAction(document) %}
  • {% endmacro %} -{% if evaluation is not null %} +{% if document is not null %}
    - {% if is_granted('CHILL_PERSON_ACCOMPANYING_PERIOD_SEE', evaluation) %} + {% if is_granted('CHILL_PERSON_ACCOMPANYING_PERIOD_SEE', document) %} {% else %} {% endif %} + {{ dump(document) }} {% include 'ChillPersonBundle:AccompanyingCourseWork:_objectifs_results_evaluations.html.twig' with { - 'w': evaluation.accompanyingPeriodWork + + 'w': document.accompanyingPeriodWorkEvaluation.accompanyingPeriodWork } %}
    - {{ 'This is the minimal period details'|trans ~ ': ' ~ evaluation.id }}
    + {{ 'This is the minimal period details'|trans ~ ': ' ~ document.id }}
    {{ 'You are getting a notification for a period you are not allowed to see'|trans }}
    diff --git a/src/Bundle/ChillPersonBundle/config/services/notification.yaml b/src/Bundle/ChillPersonBundle/config/services/notification.yaml index 360873bee..f5d227429 100644 --- a/src/Bundle/ChillPersonBundle/config/services/notification.yaml +++ b/src/Bundle/ChillPersonBundle/config/services/notification.yaml @@ -5,6 +5,6 @@ services: Chill\PersonBundle\Notification\AccompanyingPeriodWorkNotificationHandler: autowire: true autoconfigure: true - Chill\PersonBundle\Notification\AccompanyingPeriodWorkEvaluationNotificationHandler: + Chill\PersonBundle\Notification\AccompanyingPeriodWorkEvaluationDocumentNotificationHandler: autowire: true autoconfigure: true From e850f67b0095aeac8601af69fe04074a1442134e Mon Sep 17 00:00:00 2001 From: Lucas Silva Date: Thu, 23 Mar 2023 14:59:32 +0100 Subject: [PATCH 004/724] rajout du voter, pour document et action dans la notif -> affiche les documents mais aussi le fais de partager dans notification create --- .../AccompanyingCourseWork/_item.html.twig | 2 +- .../_objectifs_results_evaluations.html.twig | 7 +++---- .../AccompanyingCourseWork/show.html.twig | 4 ++-- ...EvaluationDocumentInNotification.html.twig | 20 +++++++++---------- .../showInNotification.html.twig | 6 +++--- 5 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_item.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_item.html.twig index 728554aaf..76c61407d 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_item.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_item.html.twig @@ -131,7 +131,7 @@
    • - diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_objectifs_results_evaluations.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_objectifs_results_evaluations.html.twig index 029e347b1..4f5d36230 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_objectifs_results_evaluations.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_objectifs_results_evaluations.html.twig @@ -133,13 +133,12 @@
    {{ d.title }} {{ mm.mimeIcon(d.storedObject.type) }} - + {{ d.storedObject|chill_document_button_group(d.title, is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_UPDATE', w), {'small': true}) }}
    {% for d in e.documents %} - {{ dump(d) }} - + {% endfor %} diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/show.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/show.html.twig index 016ac10bb..bd83310b7 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/show.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/show.html.twig @@ -46,11 +46,11 @@
  • - +
  • {% else %} - + {% endif %} diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showEvaluationDocumentInNotification.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showEvaluationDocumentInNotification.html.twig index b9fd07a11..83ba7bf91 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showEvaluationDocumentInNotification.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showEvaluationDocumentInNotification.html.twig @@ -6,18 +6,18 @@ {% endmacro %} {% if document is not null %}
    - {% if is_granted('CHILL_PERSON_ACCOMPANYING_PERIOD_SEE', document) %} + {% if is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_EVALUATION_DOCUMENT_SHOW', document) %} + {% include 'ChillPersonBundle:AccompanyingCourseWork:_objectifs_results_evaluations.html.twig' with { + 'w': document.accompanyingPeriodWorkEvaluation.accompanyingPeriodWork, + 'd': document.storedObject, + 'displayContent': 'long', + } %} {% else %} +
    + {{ 'This is the minimal period details'|trans ~ ': ' ~ document.id }}
    + {{ 'You are getting a notification for a period you are not allowed to see'|trans }} +
    {% endif %} - {{ dump(document) }} - {% include 'ChillPersonBundle:AccompanyingCourseWork:_objectifs_results_evaluations.html.twig' with { - - 'w': document.accompanyingPeriodWorkEvaluation.accompanyingPeriodWork - } %} -
    - {{ 'This is the minimal period details'|trans ~ ': ' ~ document.id }}
    - {{ 'You are getting a notification for a period you are not allowed to see'|trans }} -
    {% else %}
    diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showInNotification.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showInNotification.html.twig index 70a1a0980..311692030 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showInNotification.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showInNotification.html.twig @@ -6,9 +6,7 @@ {% endmacro %} {% if work is not null %}
    - {% if is_granted('CHILL_PERSON_ACCOMPANYING_PERIOD_SEE', work) %} - {% else %} - {% endif %} + {% if is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_SEE', work) %} {% include 'ChillPersonBundle:AccompanyingCourseWork:_item.html.twig' with { 'itemBlocClass': 'bg-chill-llight-gray', 'displayAction': true, @@ -16,10 +14,12 @@ 'displayFontSmall': true, 'w': work } %} + {% else %}
    {{ 'This is the minimal period details'|trans ~ ': ' ~ work.id }}
    {{ 'You are getting a notification for a period you are not allowed to see'|trans }}
    + {% endif %}
    {% else %}
    From afb25276ee40e3f1adaa4871d5d19735853c2a18 Mon Sep 17 00:00:00 2001 From: Lucas Silva Date: Thu, 23 Mar 2023 15:32:30 +0100 Subject: [PATCH 005/724] enleve l'id en bas de page --- .../Resources/views/AccompanyingCourseWork/show.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/show.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/show.html.twig index bd83310b7..73b871260 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/show.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/show.html.twig @@ -55,7 +55,7 @@ {% endif %}
    - {{ work.id }} + {% if is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_UPDATE', work) %}
  • Date: Wed, 29 Mar 2023 22:32:52 +0200 Subject: [PATCH 006/724] DX: apply rector rulesset up to PHP72 --- .../DataFixtures/ORM/LoadActivity.php | 4 +-- .../DependencyInjection/Configuration.php | 2 +- .../Form/ActivityReasonCategoryType.php | 2 +- .../ChillActivityBundle/Form/ActivityType.php | 4 +-- .../Type/TranslatableActivityReasonTest.php | 6 ++-- .../Authorization/ActivityVoterTest.php | 2 +- .../src/DependencyInjection/Configuration.php | 2 +- .../src/Form/AsideActivityFormType.php | 4 +-- .../Controller/AbstractElementController.php | 2 +- .../Compiler/CalculatorCompilerPass.php | 2 +- .../DependencyInjection/Configuration.php | 2 +- .../MapAndSubscribeUserCalendarCommand.php | 14 ++++---- .../DependencyInjection/Configuration.php | 2 +- .../MSGraphChangeNotificationHandler.php | 6 ++-- .../RemoteToLocalSync/CalendarRangeSyncer.php | 6 ++-- .../RemoteToLocalSync/CalendarSyncer.php | 4 +-- .../BulkCalendarShortMessageSender.php | 2 +- .../Command/CreateFieldsOnGroupCommand.php | 8 ++--- .../CustomFields/CustomFieldChoice.php | 2 +- .../DataFixtures/ORM/LoadOption.php | 4 +-- .../DependencyInjection/Configuration.php | 2 +- .../Form/CustomFieldType.php | 2 +- .../Form/Type/ChoicesListType.php | 2 +- .../Form/Type/CustomFieldType.php | 2 +- .../Service/CustomFieldsHelper.php | 4 +-- .../CustomFieldsGroupControllerTest.php | 2 +- .../Tests/CustomFieldTestHelper.php | 4 +-- .../CustomFields/CustomFieldsTextTest.php | 4 +-- .../Twig/CustomFieldRenderingTwigTest.php | 2 +- .../CustomFieldsGroupRenderingTwigTest.php | 2 +- .../DependencyInjection/Configuration.php | 2 +- .../DataFixtures/ORM/LoadParticipation.php | 4 +-- .../DependencyInjection/Configuration.php | 2 +- .../ChillEventBundle/Form/EventType.php | 2 +- .../ChillEventBundle/Form/EventTypeType.php | 2 +- src/Bundle/ChillEventBundle/Form/RoleType.php | 2 +- .../ChillEventBundle/Form/StatusType.php | 2 +- .../DependencyInjection/Configuration.php | 2 +- .../Command/LoadPostalCodesCommand.php | 6 +--- .../Controller/ExportController.php | 4 +-- .../ORM/LoadAddressReferences.php | 6 ++-- .../CompilerPass/MenuCompilerPass.php | 6 +--- .../CompilerPass/ShortMessageCompilerPass.php | 10 +++--- .../DependencyInjection/Configuration.php | 2 +- .../Widget/AbstractWidgetsCompilerPass.php | 3 +- .../Widget/AddWidgetConfigurationTrait.php | 4 +-- src/Bundle/ChillMainBundle/Entity/Address.php | 16 +++------- .../Embeddable/PrivateCommentEmbeddable.php | 2 +- .../Export/Formatter/SpreadSheetFormatter.php | 4 +-- .../ChillMainBundle/Form/CenterType.php | 2 +- .../ChillMainBundle/Form/LocationFormType.php | 2 +- .../Form/PermissionsGroupType.php | 2 +- src/Bundle/ChillMainBundle/Form/ScopeType.php | 2 +- .../Form/Type/AppendScopeChoiceTypeTrait.php | 4 +-- .../Form/Type/ComposedGroupCenterType.php | 6 ++-- .../Form/Type/ComposedRoleScopeType.php | 2 +- .../Form/Type/Select2CountryType.php | 2 +- .../Form/Type/Select2LanguageType.php | 2 +- src/Bundle/ChillMainBundle/Form/UserType.php | 2 +- .../ChillMainBundle/Form/WorkflowStepType.php | 2 +- .../Pagination/PaginatorFactory.php | 5 ++- .../ChillMainBundle/Search/SearchProvider.php | 12 ++----- ...eographicalUnitMaterializedViewCronJob.php | 2 +- .../Import/PostalCodeBEFromBestAddress.php | 4 +-- .../Import/PostalCodeFRFromOpenData.php | 2 +- .../Test/Export/AbstractAggregatorTest.php | 2 +- .../Test/Export/AbstractExportTest.php | 2 +- .../Test/PrepareCenterTrait.php | 2 +- .../Test/PrepareCircleTrait.php | 2 +- .../Tests/Export/ExportManagerTest.php | 32 +++++++++---------- .../Tests/Form/Type/PickCenterTypeTest.php | 8 ++--- .../Tests/Search/AbstractSearchTest.php | 2 +- .../Tests/Search/SearchProviderTest.php | 4 +-- .../Authorization/AuthorizationHelperTest.php | 20 ++++++------ .../Controller/PersonController.php | 2 +- .../DataFixtures/ORM/LoadCustomFields.php | 4 +-- .../ChillPersonExtension.php | 4 +-- .../DependencyInjection/Configuration.php | 4 +-- .../Entity/Household/Household.php | 6 ++-- .../Entity/Household/HouseholdMember.php | 2 +- .../ChillPersonBundle/Entity/Person.php | 2 +- .../Export/Filter/PersonFilters/AgeFilter.php | 4 +-- .../Form/AccompanyingPeriodType.php | 2 +- .../ChillPersonBundle/Form/PersonType.php | 2 +- .../Form/Type/Select2MaritalStatusType.php | 4 +-- .../Household/MembersEditor.php | 2 +- .../ResidentialAddressRepository.php | 2 +- .../OldDraftAccompanyingPeriodRemover.php | 4 +-- .../Events/PersonMoveEventSubscriberTest.php | 2 +- .../Controller/PersonControllerCreateTest.php | 2 +- .../Authorization/PersonVoterTest.php | 2 +- ...mpanyingPeriodWorkDocGenNormalizerTest.php | 2 +- .../DocGenerator/PersonContextTest.php | 3 +- .../Controller/ReportController.php | 4 +-- .../DataFixtures/ORM/LoadCustomField.php | 6 ++-- .../ORM/LoadCustomFieldsGroup.php | 2 +- .../DataFixtures/ORM/LoadReports.php | 8 ++--- .../ChillReportExtension.php | 2 +- .../DependencyInjection/Configuration.php | 2 +- .../ChillReportBundle/Form/ReportType.php | 4 +-- .../ChillReportBundle/Search/ReportSearch.php | 2 +- .../Controller/ReportControllerNextTest.php | 2 +- .../Tests/Controller/ReportControllerTest.php | 8 ++--- .../ChillReportExtensionTest.php | 2 +- .../Authorization/ReportVoterTest.php | 2 +- .../Tests/Timeline/TimelineProviderTest.php | 2 +- .../DependencyInjection/Configuration.php | 2 +- .../ChillTaskBundle/Menu/MenuBuilder.php | 2 +- .../TaskLifeCycleEventTimelineProvider.php | 2 +- .../DependencyInjection/Configuration.php | 2 +- 110 files changed, 194 insertions(+), 229 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivity.php b/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivity.php index 8c53ca2d9..82949d635 100644 --- a/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivity.php +++ b/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivity.php @@ -50,7 +50,7 @@ class LoadActivity extends AbstractFixture implements OrderedFixtureInterface ->findAll(); foreach ($persons as $person) { - $activityNbr = mt_rand(0, 3); + $activityNbr = random_int(0, 3); for ($i = 0; $i < $activityNbr; ++$i) { $activity = $this->newRandomActivity($person); @@ -75,7 +75,7 @@ class LoadActivity extends AbstractFixture implements OrderedFixtureInterface // ->setAttendee($this->faker->boolean()) - for ($i = 0; mt_rand(0, 4) > $i; ++$i) { + for ($i = 0; random_int(0, 4) > $i; ++$i) { $reason = $this->getRandomActivityReason(); if (null !== $reason) { diff --git a/src/Bundle/ChillActivityBundle/DependencyInjection/Configuration.php b/src/Bundle/ChillActivityBundle/DependencyInjection/Configuration.php index e22f6242c..c6b3189cc 100644 --- a/src/Bundle/ChillActivityBundle/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillActivityBundle/DependencyInjection/Configuration.php @@ -26,7 +26,7 @@ class Configuration implements ConfigurationInterface public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder('chill_activity'); - $rootNode = $treeBuilder->getRootNode('chill_activity'); + $rootNode = $treeBuilder->getRootNode(); $rootNode ->children() diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityReasonCategoryType.php b/src/Bundle/ChillActivityBundle/Form/ActivityReasonCategoryType.php index b8e03d2c7..3a0f2a318 100644 --- a/src/Bundle/ChillActivityBundle/Form/ActivityReasonCategoryType.php +++ b/src/Bundle/ChillActivityBundle/Form/ActivityReasonCategoryType.php @@ -32,7 +32,7 @@ class ActivityReasonCategoryType extends AbstractType public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults([ - 'data_class' => 'Chill\ActivityBundle\Entity\ActivityReasonCategory', + 'data_class' => \Chill\ActivityBundle\Entity\ActivityReasonCategory::class, ]); } diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityType.php b/src/Bundle/ChillActivityBundle/Form/ActivityType.php index 6d198c5fa..4bb1c1352 100644 --- a/src/Bundle/ChillActivityBundle/Form/ActivityType.php +++ b/src/Bundle/ChillActivityBundle/Form/ActivityType.php @@ -400,9 +400,7 @@ class ActivityType extends AbstractType // the datetimetransformer will then handle timezone as GMT $timezoneUTC = new DateTimeZone('GMT'); /** @var DateTime $data */ - $data = $formEvent->getData() === null ? - DateTime::createFromFormat('U', '300') : - $formEvent->getData(); + $data = $formEvent->getData() ?? DateTime::createFromFormat('U', '300'); $seconds = $data->getTimezone()->getOffset($data); $data->setTimeZone($timezoneUTC); $data->add(new DateInterval('PT' . $seconds . 'S')); diff --git a/src/Bundle/ChillActivityBundle/Tests/Form/Type/TranslatableActivityReasonTest.php b/src/Bundle/ChillActivityBundle/Tests/Form/Type/TranslatableActivityReasonTest.php index 3c9777051..881e5a607 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Form/Type/TranslatableActivityReasonTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Form/Type/TranslatableActivityReasonTest.php @@ -79,15 +79,15 @@ final class TranslatableActivityReasonTest extends TypeTestCase $request = $prophet->prophesize(); $translator = $prophet->prophesize(); - $request->willExtend('Symfony\Component\HttpFoundation\Request'); + $request->willExtend(\Symfony\Component\HttpFoundation\Request::class); $request->getLocale()->willReturn($fallbackLocale); - $requestStack->willExtend('Symfony\Component\HttpFoundation\RequestStack'); + $requestStack->willExtend(\Symfony\Component\HttpFoundation\RequestStack::class); $requestStack->getCurrentRequest()->will(static function () use ($request) { return $request; }); - $translator->willExtend('Symfony\Component\Translation\Translator'); + $translator->willExtend(\Symfony\Component\Translation\Translator::class); $translator->getFallbackLocales()->willReturn($locale); return new TranslatableStringHelper( diff --git a/src/Bundle/ChillActivityBundle/Tests/Security/Authorization/ActivityVoterTest.php b/src/Bundle/ChillActivityBundle/Tests/Security/Authorization/ActivityVoterTest.php index a9b9e2ec7..1fb90a4ae 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Security/Authorization/ActivityVoterTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Security/Authorization/ActivityVoterTest.php @@ -160,7 +160,7 @@ final class ActivityVoterTest extends KernelTestCase { $token = $this->prophet->prophesize(); $token - ->willImplement('\Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + ->willImplement('\\' . \Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class); if (null === $user) { $token->getUser()->willReturn(null); diff --git a/src/Bundle/ChillAsideActivityBundle/src/DependencyInjection/Configuration.php b/src/Bundle/ChillAsideActivityBundle/src/DependencyInjection/Configuration.php index d01998358..8341e0240 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillAsideActivityBundle/src/DependencyInjection/Configuration.php @@ -22,7 +22,7 @@ class Configuration implements ConfigurationInterface { $treeBuilder = new TreeBuilder('chill_aside_activity'); - $treeBuilder->getRootNode('chill_aside_activity') + $treeBuilder->getRootNode() ->children() ->arrayNode('form') ->canBeEnabled() diff --git a/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityFormType.php b/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityFormType.php index 9a95a8d09..727287972 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityFormType.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityFormType.php @@ -95,9 +95,7 @@ final class AsideActivityFormType extends AbstractType // the datetimetransformer will then handle timezone as GMT $timezoneUTC = new DateTimeZone('GMT'); /** @var DateTimeImmutable $data */ - $data = $formEvent->getData() === null ? - DateTime::createFromFormat('U', '300') : - $formEvent->getData(); + $data = $formEvent->getData() ?? DateTime::createFromFormat('U', '300'); $seconds = $data->getTimezone()->getOffset($data); $data->setTimeZone($timezoneUTC); $data->add(new DateInterval('PT' . $seconds . 'S')); diff --git a/src/Bundle/ChillBudgetBundle/Controller/AbstractElementController.php b/src/Bundle/ChillBudgetBundle/Controller/AbstractElementController.php index badccf3b3..125c72ce4 100644 --- a/src/Bundle/ChillBudgetBundle/Controller/AbstractElementController.php +++ b/src/Bundle/ChillBudgetBundle/Controller/AbstractElementController.php @@ -116,7 +116,7 @@ abstract class AbstractElementController extends AbstractController $indexPage = 'chill_budget_elements_household_index'; } - $entity = null !== $element->getPerson() ? $element->getPerson() : $element->getHousehold(); + $entity = $element->getPerson() ?? $element->getHousehold(); $form = $this->createForm($this->getType(), $element); $form->add('submit', SubmitType::class); diff --git a/src/Bundle/ChillBudgetBundle/DependencyInjection/Compiler/CalculatorCompilerPass.php b/src/Bundle/ChillBudgetBundle/DependencyInjection/Compiler/CalculatorCompilerPass.php index 64df79202..012c4eab5 100644 --- a/src/Bundle/ChillBudgetBundle/DependencyInjection/Compiler/CalculatorCompilerPass.php +++ b/src/Bundle/ChillBudgetBundle/DependencyInjection/Compiler/CalculatorCompilerPass.php @@ -19,7 +19,7 @@ class CalculatorCompilerPass implements CompilerPassInterface { public function process(ContainerBuilder $container) { - $manager = $container->getDefinition('Chill\BudgetBundle\Calculator\CalculatorManager'); + $manager = $container->getDefinition(\Chill\BudgetBundle\Calculator\CalculatorManager::class); foreach ($container->findTaggedServiceIds('chill_budget.calculator') as $id => $tags) { foreach ($tags as $tag) { diff --git a/src/Bundle/ChillBudgetBundle/DependencyInjection/Configuration.php b/src/Bundle/ChillBudgetBundle/DependencyInjection/Configuration.php index 8856df22b..ff9931f2d 100644 --- a/src/Bundle/ChillBudgetBundle/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillBudgetBundle/DependencyInjection/Configuration.php @@ -19,7 +19,7 @@ class Configuration implements ConfigurationInterface public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder('chill_budget'); - $rootNode = $treeBuilder->getRootNode('chill_budget'); + $rootNode = $treeBuilder->getRootNode(); $rootNode ->children() diff --git a/src/Bundle/ChillCalendarBundle/Command/MapAndSubscribeUserCalendarCommand.php b/src/Bundle/ChillCalendarBundle/Command/MapAndSubscribeUserCalendarCommand.php index 902fe4c38..63ac15348 100644 --- a/src/Bundle/ChillCalendarBundle/Command/MapAndSubscribeUserCalendarCommand.php +++ b/src/Bundle/ChillCalendarBundle/Command/MapAndSubscribeUserCalendarCommand.php @@ -60,7 +60,7 @@ class MapAndSubscribeUserCalendarCommand extends Command public function execute(InputInterface $input, OutputInterface $output): int { - $this->logger->info(__CLASS__ . ' execute command'); + $this->logger->info(self::class . ' execute command'); $limit = 50; $offset = 0; @@ -71,7 +71,7 @@ class MapAndSubscribeUserCalendarCommand extends Command $created = 0; $renewed = 0; - $this->logger->info(__CLASS__ . ' the number of user to get - renew', [ + $this->logger->info(self::class . ' the number of user to get - renew', [ 'total' => $total, 'expiration' => $expiration->format(DateTimeImmutable::ATOM), ]); @@ -92,7 +92,7 @@ class MapAndSubscribeUserCalendarCommand extends Command // we first try to renew an existing subscription, if any. // if not, or if it fails, we try to create a new one if ($this->mapCalendarToUser->hasActiveSubscription($user)) { - $this->logger->debug(__CLASS__ . ' renew a subscription for', [ + $this->logger->debug(self::class . ' renew a subscription for', [ 'userId' => $user->getId(), 'username' => $user->getUsernameCanonical(), ]); @@ -104,7 +104,7 @@ class MapAndSubscribeUserCalendarCommand extends Command if (0 !== $expirationTs) { ++$renewed; } else { - $this->logger->warning(__CLASS__ . ' could not renew subscription for a user', [ + $this->logger->warning(self::class . ' could not renew subscription for a user', [ 'userId' => $user->getId(), 'username' => $user->getUsernameCanonical(), ]); @@ -112,7 +112,7 @@ class MapAndSubscribeUserCalendarCommand extends Command } if (!$this->mapCalendarToUser->hasActiveSubscription($user)) { - $this->logger->debug(__CLASS__ . ' create a subscription for', [ + $this->logger->debug(self::class . ' create a subscription for', [ 'userId' => $user->getId(), 'username' => $user->getUsernameCanonical(), ]); @@ -124,7 +124,7 @@ class MapAndSubscribeUserCalendarCommand extends Command if (0 !== $expirationTs) { ++$created; } else { - $this->logger->warning(__CLASS__ . ' could not create subscription for a user', [ + $this->logger->warning(self::class . ' could not create subscription for a user', [ 'userId' => $user->getId(), 'username' => $user->getUsernameCanonical(), ]); @@ -139,7 +139,7 @@ class MapAndSubscribeUserCalendarCommand extends Command $this->em->clear(); } - $this->logger->warning(__CLASS__ . ' process executed', [ + $this->logger->warning(self::class . ' process executed', [ 'created' => $created, 'renewed' => $renewed, ]); diff --git a/src/Bundle/ChillCalendarBundle/DependencyInjection/Configuration.php b/src/Bundle/ChillCalendarBundle/DependencyInjection/Configuration.php index 127b69047..a3e4ae391 100644 --- a/src/Bundle/ChillCalendarBundle/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillCalendarBundle/DependencyInjection/Configuration.php @@ -24,7 +24,7 @@ class Configuration implements ConfigurationInterface public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder('chill_calendar'); - $rootNode = $treeBuilder->getRootNode('chill_calendar'); + $rootNode = $treeBuilder->getRootNode(); $rootNode ->children() diff --git a/src/Bundle/ChillCalendarBundle/Messenger/Handler/MSGraphChangeNotificationHandler.php b/src/Bundle/ChillCalendarBundle/Messenger/Handler/MSGraphChangeNotificationHandler.php index 9c1e84511..a09c70c1e 100644 --- a/src/Bundle/ChillCalendarBundle/Messenger/Handler/MSGraphChangeNotificationHandler.php +++ b/src/Bundle/ChillCalendarBundle/Messenger/Handler/MSGraphChangeNotificationHandler.php @@ -77,7 +77,7 @@ class MSGraphChangeNotificationHandler implements MessageHandlerInterface $user = $this->userRepository->find($changeNotificationMessage->getUserId()); if (null === $user) { - $this->logger->warning(__CLASS__ . ' notification concern non-existent user, skipping'); + $this->logger->warning(self::class . ' notification concern non-existent user, skipping'); return; } @@ -86,7 +86,7 @@ class MSGraphChangeNotificationHandler implements MessageHandlerInterface $secret = $this->mapCalendarToUser->getSubscriptionSecret($user); if ($secret !== ($notification['clientState'] ?? -1)) { - $this->logger->warning(__CLASS__ . ' could not validate secret, skipping'); + $this->logger->warning(self::class . ' could not validate secret, skipping'); continue; } @@ -101,7 +101,7 @@ class MSGraphChangeNotificationHandler implements MessageHandlerInterface $this->calendarSyncer->handleCalendarSync($calendar, $notification, $user); $this->em->flush(); } else { - $this->logger->info(__CLASS__ . ' id not found in any calendar nor calendar range'); + $this->logger->info(self::class . ' id not found in any calendar nor calendar range'); } } diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteToLocalSync/CalendarRangeSyncer.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteToLocalSync/CalendarRangeSyncer.php index a9227282d..d05adfed7 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteToLocalSync/CalendarRangeSyncer.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteToLocalSync/CalendarRangeSyncer.php @@ -59,7 +59,7 @@ class CalendarRangeSyncer } $calendarRange->preventEnqueueChanges = true; - $this->logger->info(__CLASS__ . ' remove a calendar range because deleted on remote calendar'); + $this->logger->info(self::class . ' remove a calendar range because deleted on remote calendar'); $this->em->remove($calendarRange); break; @@ -71,7 +71,7 @@ class CalendarRangeSyncer $notification['resource'] )->toArray(); } catch (ClientExceptionInterface $clientException) { - $this->logger->warning(__CLASS__ . ' could not retrieve event from ms graph. Already deleted ?', [ + $this->logger->warning(self::class . ' could not retrieve event from ms graph. Already deleted ?', [ 'calendarRangeId' => $calendarRange->getId(), 'remoteEventId' => $notification['resource'], ]); @@ -82,7 +82,7 @@ class CalendarRangeSyncer $lastModified = RemoteEventConverter::convertStringDateWithTimezone($new['lastModifiedDateTime']); if ($calendarRange->getRemoteAttributes()['lastModifiedDateTime'] === $lastModified->getTimestamp()) { - $this->logger->info(__CLASS__ . ' change key is equals. Source is probably a local update', [ + $this->logger->info(self::class . ' change key is equals. Source is probably a local update', [ 'calendarRangeId' => $calendarRange->getId(), 'remoteEventId' => $notification['resource'], ]); diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteToLocalSync/CalendarSyncer.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteToLocalSync/CalendarSyncer.php index c5a640f32..b3febf4d4 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteToLocalSync/CalendarSyncer.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteToLocalSync/CalendarSyncer.php @@ -79,7 +79,7 @@ class CalendarSyncer $notification['resource'] )->toArray(); } catch (ClientExceptionInterface $clientException) { - $this->logger->warning(__CLASS__ . ' could not retrieve event from ms graph. Already deleted ?', [ + $this->logger->warning(self::class . ' could not retrieve event from ms graph. Already deleted ?', [ 'calendarId' => $calendar->getId(), 'remoteEventId' => $notification['resource'], ]); @@ -96,7 +96,7 @@ class CalendarSyncer ); if ($calendar->getRemoteAttributes()['lastModifiedDateTime'] === $lastModified->getTimestamp()) { - $this->logger->info(__CLASS__ . ' change key is equals. Source is probably a local update', [ + $this->logger->info(self::class . ' change key is equals. Source is probably a local update', [ 'calendarRangeId' => $calendar->getId(), 'remoteEventId' => $notification['resource'], ]); diff --git a/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/BulkCalendarShortMessageSender.php b/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/BulkCalendarShortMessageSender.php index a35fffce0..83826bbcf 100644 --- a/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/BulkCalendarShortMessageSender.php +++ b/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/BulkCalendarShortMessageSender.php @@ -66,6 +66,6 @@ class BulkCalendarShortMessageSender $this->em->refresh($calendar); } - $this->logger->info(__CLASS__ . 'a bulk of messages was sent', ['count_calendars' => $countCalendars, 'count_sms' => $countSms]); + $this->logger->info(self::class . 'a bulk of messages was sent', ['count_calendars' => $countCalendars, 'count_sms' => $countSms]); } } diff --git a/src/Bundle/ChillCustomFieldsBundle/Command/CreateFieldsOnGroupCommand.php b/src/Bundle/ChillCustomFieldsBundle/Command/CreateFieldsOnGroupCommand.php index c8c8ad4fc..2a03e90bb 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Command/CreateFieldsOnGroupCommand.php +++ b/src/Bundle/ChillCustomFieldsBundle/Command/CreateFieldsOnGroupCommand.php @@ -192,9 +192,7 @@ class CreateFieldsOnGroupCommand extends Command foreach ($languages as $lang) { //todo replace with service to find lang when available - $names[] = (isset($cf->getName()[$lang])) ? - $cf->getName()[$lang] : - 'Not available in this language'; + $names[] = $cf->getName()[$lang] ?? 'Not available in this language'; } if ($this->validator->validate($cf)) { @@ -249,9 +247,7 @@ class CreateFieldsOnGroupCommand extends Command foreach ($languages as $lang) { //todo replace with service to find lang when available - $row[] = (isset($customFieldGroup->getName()[$lang])) ? - $customFieldGroup->getName()[$lang] : - 'Not available in this language'; + $row[] = $customFieldGroup->getName()[$lang] ?? 'Not available in this language'; } $rows[] = $row; } diff --git a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldChoice.php b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldChoice.php index 7876dd026..781b2b233 100644 --- a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldChoice.php +++ b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldChoice.php @@ -294,7 +294,7 @@ class CustomFieldChoice extends AbstractCustomField public function render($value, CustomField $customField, $documentType = 'html') { //extract the data. They are under a _choice key if they are stored with allow_other - $data = (isset($value['_choices'])) ? $value['_choices'] : $value; + $data = $value['_choices'] ?? $value; $selected = (is_array($data)) ? $data : [$data]; $choices = $customField->getOptions()[self::CHOICES]; diff --git a/src/Bundle/ChillCustomFieldsBundle/DataFixtures/ORM/LoadOption.php b/src/Bundle/ChillCustomFieldsBundle/DataFixtures/ORM/LoadOption.php index 0edc2457a..5b2598ab7 100644 --- a/src/Bundle/ChillCustomFieldsBundle/DataFixtures/ORM/LoadOption.php +++ b/src/Bundle/ChillCustomFieldsBundle/DataFixtures/ORM/LoadOption.php @@ -104,7 +104,7 @@ class LoadOption extends AbstractFixture implements OrderedFixtureInterface $manager->persist($parent); //Load children - $expected_nb_children = mt_rand(10, 50); + $expected_nb_children = random_int(10, 50); for ($i = 0; $i < $expected_nb_children; ++$i) { $companyName = $this->fakerFr->company; @@ -144,7 +144,7 @@ class LoadOption extends AbstractFixture implements OrderedFixtureInterface $manager->persist($parent); //Load children - $expected_nb_children = mt_rand(10, 50); + $expected_nb_children = random_int(10, 50); for ($i = 0; $i < $expected_nb_children; ++$i) { $manager->persist($this->createChildOption($parent, [ diff --git a/src/Bundle/ChillCustomFieldsBundle/DependencyInjection/Configuration.php b/src/Bundle/ChillCustomFieldsBundle/DependencyInjection/Configuration.php index d0db269a2..e68fdd2c4 100644 --- a/src/Bundle/ChillCustomFieldsBundle/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillCustomFieldsBundle/DependencyInjection/Configuration.php @@ -25,7 +25,7 @@ class Configuration implements ConfigurationInterface public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder('chill_custom_fields'); - $rootNode = $treeBuilder->getRootNode('chill_custom_fields'); + $rootNode = $treeBuilder->getRootNode(); $classInfo = 'The class which may receive custom fields'; $nameInfo = 'The name which will appears in the user interface. May be translatable'; diff --git a/src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldType.php b/src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldType.php index aa1d1b7e1..ea572759b 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldType.php +++ b/src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldType.php @@ -119,7 +119,7 @@ class CustomFieldType extends AbstractType public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults([ - 'data_class' => 'Chill\CustomFieldsBundle\Entity\CustomField', + 'data_class' => \Chill\CustomFieldsBundle\Entity\CustomField::class, ]); $resolver->setRequired(['type', 'group_widget']) diff --git a/src/Bundle/ChillCustomFieldsBundle/Form/Type/ChoicesListType.php b/src/Bundle/ChillCustomFieldsBundle/Form/Type/ChoicesListType.php index 071363451..c50bd856e 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Form/Type/ChoicesListType.php +++ b/src/Bundle/ChillCustomFieldsBundle/Form/Type/ChoicesListType.php @@ -38,7 +38,7 @@ class ChoicesListType extends AbstractType $formData = $form->getData(); if (null === $formData['slug']) { - $slug = uniqid(mt_rand(), true); + $slug = uniqid(random_int(0, mt_getrandmax()), true); $data['slug'] = $slug; $event->setData($data); diff --git a/src/Bundle/ChillCustomFieldsBundle/Form/Type/CustomFieldType.php b/src/Bundle/ChillCustomFieldsBundle/Form/Type/CustomFieldType.php index 5b1d39529..67ea171e6 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Form/Type/CustomFieldType.php +++ b/src/Bundle/ChillCustomFieldsBundle/Form/Type/CustomFieldType.php @@ -49,7 +49,7 @@ class CustomFieldType extends AbstractType { $resolver ->setRequired(['group']) - ->addAllowedTypes('group', ['Chill\CustomFieldsBundle\Entity\CustomFieldsGroup']); + ->addAllowedTypes('group', [\Chill\CustomFieldsBundle\Entity\CustomFieldsGroup::class]); } public function getBlockPrefix() diff --git a/src/Bundle/ChillCustomFieldsBundle/Service/CustomFieldsHelper.php b/src/Bundle/ChillCustomFieldsBundle/Service/CustomFieldsHelper.php index 67afdec85..9ffd836e6 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Service/CustomFieldsHelper.php +++ b/src/Bundle/ChillCustomFieldsBundle/Service/CustomFieldsHelper.php @@ -49,7 +49,7 @@ class CustomFieldsHelper public function isEmptyValue(array $fields, CustomField $customField) { $slug = $customField->getSlug(); - $rawValue = (isset($fields[$slug])) ? $fields[$slug] : null; + $rawValue = $fields[$slug] ?? null; $customFieldType = $this->provider->getCustomFieldByType($customField->getType()); $deserializedValue = $customFieldType->deserialize($rawValue, $customField); @@ -71,7 +71,7 @@ class CustomFieldsHelper public function renderCustomField(array $fields, CustomField $customField, $documentType = 'html') { $slug = $customField->getSlug(); - $rawValue = (isset($fields[$slug])) ? $fields[$slug] : null; + $rawValue = $fields[$slug] ?? null; $customFieldType = $this->provider->getCustomFieldByType($customField->getType()); return $customFieldType->render($rawValue, $customField, $documentType); diff --git a/src/Bundle/ChillCustomFieldsBundle/Tests/Controller/CustomFieldsGroupControllerTest.php b/src/Bundle/ChillCustomFieldsBundle/Tests/Controller/CustomFieldsGroupControllerTest.php index 067fe7de6..7e0fe12d2 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Tests/Controller/CustomFieldsGroupControllerTest.php +++ b/src/Bundle/ChillCustomFieldsBundle/Tests/Controller/CustomFieldsGroupControllerTest.php @@ -52,7 +52,7 @@ final class CustomFieldsGroupControllerTest extends WebTestCase // Fill in the form and submit it $form = $crawler->selectButton('Créer')->form([ 'custom_fields_group[name][fr]' => 'Test', - 'custom_fields_group[entity]' => 'Chill\PersonBundle\Entity\Person', + 'custom_fields_group[entity]' => \Chill\PersonBundle\Entity\Person::class, ]); $crawler = $client->submit($form); diff --git a/src/Bundle/ChillCustomFieldsBundle/Tests/CustomFieldTestHelper.php b/src/Bundle/ChillCustomFieldsBundle/Tests/CustomFieldTestHelper.php index 35a9ee82b..79f547fe2 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Tests/CustomFieldTestHelper.php +++ b/src/Bundle/ChillCustomFieldsBundle/Tests/CustomFieldTestHelper.php @@ -34,12 +34,12 @@ trait CustomFieldTestHelper $kernel = static::$kernel; //check a kernel is accessible - $customFieldsGroup = $this->createMock('Chill\CustomFieldsBundle\Entity\CustomFieldsGroup'); + $customFieldsGroup = $this->createMock(\Chill\CustomFieldsBundle\Entity\CustomFieldsGroup::class); $customFieldsGroup->expects($this->once()) ->method('getActiveCustomFields') ->will($this->returnValue([$field])); - $request = $this->createMock('Symfony\Component\HttpFoundation\Request'); + $request = $this->createMock(\Symfony\Component\HttpFoundation\Request::class); $request->expects($this->any()) ->method('getLocale') ->will($this->returnValue($locale)); diff --git a/src/Bundle/ChillCustomFieldsBundle/Tests/CustomFields/CustomFieldsTextTest.php b/src/Bundle/ChillCustomFieldsBundle/Tests/CustomFields/CustomFieldsTextTest.php index cc1b4db64..6bfe2663c 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Tests/CustomFields/CustomFieldsTextTest.php +++ b/src/Bundle/ChillCustomFieldsBundle/Tests/CustomFields/CustomFieldsTextTest.php @@ -41,11 +41,11 @@ final class CustomFieldsTextTest extends WebTestCase $customField = $this->customFieldProvider->getCustomFieldByType('text'); $this->assertInstanceOf( - 'Chill\CustomFieldsBundle\CustomFields\CustomFieldInterface', + \Chill\CustomFieldsBundle\CustomFields\CustomFieldInterface::class, $customField ); $this->assertInstanceOf( - 'Chill\CustomFieldsBundle\CustomFields\CustomFieldText', + \Chill\CustomFieldsBundle\CustomFields\CustomFieldText::class, $customField ); } diff --git a/src/Bundle/ChillCustomFieldsBundle/Tests/Templating/Twig/CustomFieldRenderingTwigTest.php b/src/Bundle/ChillCustomFieldsBundle/Tests/Templating/Twig/CustomFieldRenderingTwigTest.php index 420e79dff..2e29d988b 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Tests/Templating/Twig/CustomFieldRenderingTwigTest.php +++ b/src/Bundle/ChillCustomFieldsBundle/Tests/Templating/Twig/CustomFieldRenderingTwigTest.php @@ -46,7 +46,7 @@ final class CustomFieldRenderingTwigTest extends KernelTestCase // set locale to fr $prophet = new \Prophecy\Prophet(); $request = $prophet->prophesize(); - $request->willExtend('Symfony\Component\HttpFoundation\Request'); + $request->willExtend(\Symfony\Component\HttpFoundation\Request::class); $request->getLocale()->willReturn('fr'); self::$kernel->getContainer()->get('request_stack') ->push($request->reveal()); diff --git a/src/Bundle/ChillCustomFieldsBundle/Tests/Templating/Twig/CustomFieldsGroupRenderingTwigTest.php b/src/Bundle/ChillCustomFieldsBundle/Tests/Templating/Twig/CustomFieldsGroupRenderingTwigTest.php index 7ffa31db5..f3b93c390 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Tests/Templating/Twig/CustomFieldsGroupRenderingTwigTest.php +++ b/src/Bundle/ChillCustomFieldsBundle/Tests/Templating/Twig/CustomFieldsGroupRenderingTwigTest.php @@ -48,7 +48,7 @@ final class CustomFieldsGroupRenderingTwigTest extends KernelTestCase // set locale to fr $prophet = new \Prophecy\Prophet(); $request = $prophet->prophesize(); - $request->willExtend('Symfony\Component\HttpFoundation\Request'); + $request->willExtend(\Symfony\Component\HttpFoundation\Request::class); $request->getLocale()->willReturn('fr'); self::$kernel->getContainer()->get('request_stack') ->push($request->reveal()); diff --git a/src/Bundle/ChillDocStoreBundle/DependencyInjection/Configuration.php b/src/Bundle/ChillDocStoreBundle/DependencyInjection/Configuration.php index d2c56d8d1..466158783 100644 --- a/src/Bundle/ChillDocStoreBundle/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillDocStoreBundle/DependencyInjection/Configuration.php @@ -24,7 +24,7 @@ class Configuration implements ConfigurationInterface public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder('chill_doc_store'); - $rootNode = $treeBuilder->getRootNode('chill_doc_store'); + $rootNode = $treeBuilder->getRootNode(); // Here you should define the parameters that are allowed to // configure your bundle. See the documentation linked above for diff --git a/src/Bundle/ChillEventBundle/DataFixtures/ORM/LoadParticipation.php b/src/Bundle/ChillEventBundle/DataFixtures/ORM/LoadParticipation.php index ed38faf01..71b07a123 100644 --- a/src/Bundle/ChillEventBundle/DataFixtures/ORM/LoadParticipation.php +++ b/src/Bundle/ChillEventBundle/DataFixtures/ORM/LoadParticipation.php @@ -43,7 +43,7 @@ class LoadParticipation extends AbstractFixture implements OrderedFixtureInterfa for ($i = 0; $i < $expectedNumber; ++$i) { $event = (new Event()) ->setDate($this->faker->dateTimeBetween('-2 years', '+6 months')) - ->setName($this->faker->words(mt_rand(2, 4), true)) + ->setName($this->faker->words(random_int(2, 4), true)) ->setType($this->getReference(LoadEventTypes::$refs[array_rand(LoadEventTypes::$refs)])) ->setCenter($center) ->setCircle( @@ -75,7 +75,7 @@ class LoadParticipation extends AbstractFixture implements OrderedFixtureInterfa /** @var \Chill\PersonBundle\Entity\Person $person */ foreach ($people as $person) { - $nb = mt_rand(0, 3); + $nb = random_int(0, 3); for ($i = 0; $i < $nb; ++$i) { $event = $events[array_rand($events)]; diff --git a/src/Bundle/ChillEventBundle/DependencyInjection/Configuration.php b/src/Bundle/ChillEventBundle/DependencyInjection/Configuration.php index b36f7b6a9..fe42ad99a 100644 --- a/src/Bundle/ChillEventBundle/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillEventBundle/DependencyInjection/Configuration.php @@ -24,7 +24,7 @@ class Configuration implements ConfigurationInterface public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder('chill_event'); - $rootNode = $treeBuilder->getRootNode('chill_event'); + $rootNode = $treeBuilder->getRootNode(); // Here you should define the parameters that are allowed to // configure your bundle. See the documentation linked above for diff --git a/src/Bundle/ChillEventBundle/Form/EventType.php b/src/Bundle/ChillEventBundle/Form/EventType.php index fec26c373..a72b90494 100644 --- a/src/Bundle/ChillEventBundle/Form/EventType.php +++ b/src/Bundle/ChillEventBundle/Form/EventType.php @@ -54,7 +54,7 @@ class EventType extends AbstractType public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults([ - 'data_class' => 'Chill\EventBundle\Entity\Event', + 'data_class' => \Chill\EventBundle\Entity\Event::class, ]); $resolver ->setRequired(['center', 'role']) diff --git a/src/Bundle/ChillEventBundle/Form/EventTypeType.php b/src/Bundle/ChillEventBundle/Form/EventTypeType.php index 9f971f55d..bab13c374 100644 --- a/src/Bundle/ChillEventBundle/Form/EventTypeType.php +++ b/src/Bundle/ChillEventBundle/Form/EventTypeType.php @@ -36,7 +36,7 @@ class EventTypeType extends AbstractType public function setDefaultOptions(OptionsResolverInterface $resolver) { $resolver->setDefaults([ - 'data_class' => 'Chill\EventBundle\Entity\EventType', + 'data_class' => \Chill\EventBundle\Entity\EventType::class, ]); } } diff --git a/src/Bundle/ChillEventBundle/Form/RoleType.php b/src/Bundle/ChillEventBundle/Form/RoleType.php index e4e55faca..9c56d17e6 100644 --- a/src/Bundle/ChillEventBundle/Form/RoleType.php +++ b/src/Bundle/ChillEventBundle/Form/RoleType.php @@ -55,7 +55,7 @@ class RoleType extends AbstractType public function setDefaultOptions(OptionsResolverInterface $resolver) { $resolver->setDefaults([ - 'data_class' => 'Chill\EventBundle\Entity\Role', + 'data_class' => \Chill\EventBundle\Entity\Role::class, ]); } } diff --git a/src/Bundle/ChillEventBundle/Form/StatusType.php b/src/Bundle/ChillEventBundle/Form/StatusType.php index e70011d22..5801f3264 100644 --- a/src/Bundle/ChillEventBundle/Form/StatusType.php +++ b/src/Bundle/ChillEventBundle/Form/StatusType.php @@ -38,7 +38,7 @@ class StatusType extends AbstractType public function setDefaultOptions(OptionsResolverInterface $resolver) { $resolver->setDefaults([ - 'data_class' => 'Chill\EventBundle\Entity\Status', + 'data_class' => \Chill\EventBundle\Entity\Status::class, ]); } } diff --git a/src/Bundle/ChillFamilyMembersBundle/DependencyInjection/Configuration.php b/src/Bundle/ChillFamilyMembersBundle/DependencyInjection/Configuration.php index d2c09d7fa..98ea3125a 100644 --- a/src/Bundle/ChillFamilyMembersBundle/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillFamilyMembersBundle/DependencyInjection/Configuration.php @@ -24,7 +24,7 @@ class Configuration implements ConfigurationInterface public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder('chill_amli_family_members'); - $rootNode = $treeBuilder->getRootNode('chill_amli_family_members'); + $rootNode = $treeBuilder->getRootNode(); $rootNode ->children() diff --git a/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php b/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php index fd8a469d6..ea42fde78 100644 --- a/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php +++ b/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php @@ -102,11 +102,7 @@ class LoadPostalCodesCommand extends Command try { $this->addPostalCode($row, $output); ++$num; - } catch (ExistingPostalCodeException $ex) { - $output->writeln(' on line ' . $line . ' : ' . $ex->getMessage() . ''); - } catch (CountryCodeNotFoundException $ex) { - $output->writeln(' on line ' . $line . ' : ' . $ex->getMessage() . ''); - } catch (PostalCodeNotValidException $ex) { + } catch (ExistingPostalCodeException|CountryCodeNotFoundException|PostalCodeNotValidException $ex) { $output->writeln(' on line ' . $line . ' : ' . $ex->getMessage() . ''); } ++$line; diff --git a/src/Bundle/ChillMainBundle/Controller/ExportController.php b/src/Bundle/ChillMainBundle/Controller/ExportController.php index caeec8327..686b4cbce 100644 --- a/src/Bundle/ChillMainBundle/Controller/ExportController.php +++ b/src/Bundle/ChillMainBundle/Controller/ExportController.php @@ -164,7 +164,7 @@ class ExportController extends AbstractController { $this->denyAccessUnlessGranted(SavedExportVoter::GENERATE, $savedExport); - $key = md5(uniqid((string) mt_rand(), false)); + $key = md5(uniqid((string) random_int(0, mt_getrandmax()), false)); $this->redis->setEx($key, 3600, serialize($savedExport->getOptions())); @@ -481,7 +481,7 @@ class ExportController extends AbstractController 'alias' => $alias, ]; unset($parameters['_token']); - $key = md5(uniqid((string) mt_rand(), false)); + $key = md5(uniqid((string) random_int(0, mt_getrandmax()), false)); $this->redis->setEx($key, 3600, serialize($parameters)); diff --git a/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadAddressReferences.php b/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadAddressReferences.php index 93aaf01b3..0fef33c2f 100644 --- a/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadAddressReferences.php +++ b/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadAddressReferences.php @@ -69,7 +69,7 @@ class LoadAddressReferences extends AbstractFixture implements ContainerAwareInt $ar->setRefId($this->faker->numerify('ref-id-######')); $ar->setStreet($this->faker->streetName); - $ar->setStreetNumber((string) mt_rand(0, 199)); + $ar->setStreetNumber((string) random_int(0, 199)); $ar->setPoint($this->getRandomPoint()); $ar->setPostcode($this->getReference( LoadPostalCodes::$refs[array_rand(LoadPostalCodes::$refs)] @@ -89,8 +89,8 @@ class LoadAddressReferences extends AbstractFixture implements ContainerAwareInt { $lonBrussels = 4.35243; $latBrussels = 50.84676; - $lon = $lonBrussels + 0.01 * mt_rand(-5, 5); - $lat = $latBrussels + 0.01 * mt_rand(-5, 5); + $lon = $lonBrussels + 0.01 * random_int(-5, 5); + $lat = $latBrussels + 0.01 * random_int(-5, 5); return Point::fromLonLat($lon, $lat); } diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/MenuCompilerPass.php b/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/MenuCompilerPass.php index c41a32056..ae53f09df 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/MenuCompilerPass.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/MenuCompilerPass.php @@ -38,11 +38,7 @@ class MenuCompilerPass implements CompilerPassInterface } usort($services, static function ($a, $b) { - if ($a['priority'] === $b['priority']) { - return 0; - } - - return ($a['priority'] < $b['priority']) ? -1 : 1; + return $a['priority'] <=> $b['priority']; }); foreach ($services as $service) { diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/ShortMessageCompilerPass.php b/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/ShortMessageCompilerPass.php index f75840c3a..f9fdb80d0 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/ShortMessageCompilerPass.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/ShortMessageCompilerPass.php @@ -34,7 +34,7 @@ class ShortMessageCompilerPass implements CompilerPassInterface { public function process(ContainerBuilder $container) { - $config = $container->resolveEnvPlaceholders($container->getParameter('chill_main.short_messages', null), true); + $config = $container->resolveEnvPlaceholders($container->getParameter('chill_main.short_messages'), true); // weird fix for special characters $config['dsn'] = str_replace(['%%'], ['%'], $config['dsn']); $dsn = parse_url($config['dsn']); @@ -43,7 +43,7 @@ class ShortMessageCompilerPass implements CompilerPassInterface if ('null' === $dsn['scheme'] || false === $config['enabled']) { $defaultTransporter = new Reference(NullShortMessageSender::class); } elseif ('ovh' === $dsn['scheme']) { - if (!class_exists('\Ovh\Api')) { + if (!class_exists('\\' . \Ovh\Api::class)) { throw new RuntimeException('Class \\Ovh\\Api not found'); } @@ -66,17 +66,17 @@ class ShortMessageCompilerPass implements CompilerPassInterface $ovh = new Definition(); $ovh - ->setClass('\Ovh\Api') + ->setClass('\\' . \Ovh\Api::class) ->setArgument(0, $dsn['user']) ->setArgument(1, $dsn['pass']) ->setArgument(2, $dsn['host']) ->setArgument(3, $dsn['queries']['consumer_key']); - $container->setDefinition('Ovh\Api', $ovh); + $container->setDefinition(\Ovh\Api::class, $ovh); $ovhSender = new Definition(); $ovhSender ->setClass(OvhShortMessageSender::class) - ->setArgument(0, new Reference('Ovh\Api')) + ->setArgument(0, new Reference(\Ovh\Api::class)) ->setArgument(1, $dsn['queries']['service_name']) ->setArgument(2, $dsn['queries']['sender']) ->setArgument(3, new Reference(LoggerInterface::class)) diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php b/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php index 9631900ab..4605f35ab 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php @@ -37,7 +37,7 @@ class Configuration implements ConfigurationInterface public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder('chill_main'); - $rootNode = $treeBuilder->getRootNode('chill_main'); + $rootNode = $treeBuilder->getRootNode(); $rootNode ->children() diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/Widget/AbstractWidgetsCompilerPass.php b/src/Bundle/ChillMainBundle/DependencyInjection/Widget/AbstractWidgetsCompilerPass.php index 223a7b6cb..d5234bfbe 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/Widget/AbstractWidgetsCompilerPass.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/Widget/AbstractWidgetsCompilerPass.php @@ -193,8 +193,7 @@ abstract class AbstractWidgetsCompilerPass implements CompilerPassInterface /** @var WidgetFactoryInterface $factory */ $factory = $this->widgetServices[$alias]; // get the config (under the key which equals to widget_alias - $config = isset($param[$factory->getWidgetAlias()]) ? - $param[$factory->getWidgetAlias()] : []; + $config = $param[$factory->getWidgetAlias()] ?? []; // register the service into the container $serviceId = $this->registerServiceIntoContainer( $container, diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/Widget/AddWidgetConfigurationTrait.php b/src/Bundle/ChillMainBundle/DependencyInjection/Widget/AddWidgetConfigurationTrait.php index a6688fca2..ec603236e 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/Widget/AddWidgetConfigurationTrait.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/Widget/AddWidgetConfigurationTrait.php @@ -139,7 +139,7 @@ trait AddWidgetConfigurationTrait protected function addWidgetsConfiguration(string $place, ContainerBuilder $containerBuilder) { $treeBuilder = new TreeBuilder($place); - $root = $treeBuilder->getRootNode($place) + $root = $treeBuilder->getRootNode() ->canBeUnset() ->info('register widgets on place "' . $place . '"'); @@ -170,7 +170,7 @@ trait AddWidgetConfigurationTrait // adding the possible config on each widget under the widget_alias foreach ($this->filterWidgetByPlace($place) as $factory) { $builder = new TreeBuilder($factory->getWidgetAlias()); - $widgetOptionsRoot = $builder->getRootNode($factory->getWidgetAlias()); + $widgetOptionsRoot = $builder->getRootNode(); $widgetOptionsRoot->canBeUnset() ->info(sprintf( 'the configuration for the widget "%s" (only required if this widget is set in widget_alias)', diff --git a/src/Bundle/ChillMainBundle/Entity/Address.php b/src/Bundle/ChillMainBundle/Entity/Address.php index 9a0f8b7b3..962050d6f 100644 --- a/src/Bundle/ChillMainBundle/Entity/Address.php +++ b/src/Bundle/ChillMainBundle/Entity/Address.php @@ -527,28 +527,20 @@ class Address /** * Set streetAddress1 (legacy function). - * - * @param string $streetAddress1 - * - * @return Address */ - public function setStreetAddress1($streetAddress1) + public function setStreetAddress1(?string $streetAddress1): self { - $this->street = null === $streetAddress1 ? '' : $streetAddress1; + $this->street = (string) $streetAddress1; return $this; } /** * Set streetAddress2 (legacy function). - * - * @param string $streetAddress2 - * - * @return Address */ - public function setStreetAddress2($streetAddress2) + public function setStreetAddress2(?string $streetAddress2): self { - $this->streetNumber = null === $streetAddress2 ? '' : $streetAddress2; + $this->streetNumber = (string) $streetAddress2; return $this; } diff --git a/src/Bundle/ChillMainBundle/Entity/Embeddable/PrivateCommentEmbeddable.php b/src/Bundle/ChillMainBundle/Entity/Embeddable/PrivateCommentEmbeddable.php index 560b0dd7f..44e53671d 100644 --- a/src/Bundle/ChillMainBundle/Entity/Embeddable/PrivateCommentEmbeddable.php +++ b/src/Bundle/ChillMainBundle/Entity/Embeddable/PrivateCommentEmbeddable.php @@ -45,7 +45,7 @@ class PrivateCommentEmbeddable public function merge(PrivateCommentEmbeddable $newComment): self { - $currentComments = null === $this->getComments() ? [] : $this->getComments(); + $currentComments = $this->getComments() ?? []; $mergedComments = $newComment->getComments() + $currentComments; diff --git a/src/Bundle/ChillMainBundle/Export/Formatter/SpreadSheetFormatter.php b/src/Bundle/ChillMainBundle/Export/Formatter/SpreadSheetFormatter.php index 6b77e5b2b..66db056c4 100644 --- a/src/Bundle/ChillMainBundle/Export/Formatter/SpreadSheetFormatter.php +++ b/src/Bundle/ChillMainBundle/Export/Formatter/SpreadSheetFormatter.php @@ -435,7 +435,7 @@ class SpreadSheetFormatter implements FormatterInterface * Get the displayable result. * * @param string $key - * @param string $value + * @param mixed $value * * @return string */ @@ -445,7 +445,7 @@ class SpreadSheetFormatter implements FormatterInterface $this->initializeCache($key); } - $value = null === $value ? '' : $value; + $value = $value ?? ''; return call_user_func($this->cacheDisplayableResult[$key], $value); } diff --git a/src/Bundle/ChillMainBundle/Form/CenterType.php b/src/Bundle/ChillMainBundle/Form/CenterType.php index 6af579870..ff758ca49 100644 --- a/src/Bundle/ChillMainBundle/Form/CenterType.php +++ b/src/Bundle/ChillMainBundle/Form/CenterType.php @@ -30,7 +30,7 @@ class CenterType extends AbstractType public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults([ - 'data_class' => 'Chill\MainBundle\Entity\Center', + 'data_class' => \Chill\MainBundle\Entity\Center::class, ]); } diff --git a/src/Bundle/ChillMainBundle/Form/LocationFormType.php b/src/Bundle/ChillMainBundle/Form/LocationFormType.php index 8e6861029..5a6776daf 100644 --- a/src/Bundle/ChillMainBundle/Form/LocationFormType.php +++ b/src/Bundle/ChillMainBundle/Form/LocationFormType.php @@ -75,7 +75,7 @@ final class LocationFormType extends AbstractType public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults([ - 'data_class' => 'Chill\MainBundle\Entity\Location', + 'data_class' => \Chill\MainBundle\Entity\Location::class, ]); } diff --git a/src/Bundle/ChillMainBundle/Form/PermissionsGroupType.php b/src/Bundle/ChillMainBundle/Form/PermissionsGroupType.php index ad5f7243b..16aafeb41 100644 --- a/src/Bundle/ChillMainBundle/Form/PermissionsGroupType.php +++ b/src/Bundle/ChillMainBundle/Form/PermissionsGroupType.php @@ -60,7 +60,7 @@ class PermissionsGroupType extends AbstractType public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults([ - 'data_class' => 'Chill\MainBundle\Entity\PermissionsGroup', + 'data_class' => \Chill\MainBundle\Entity\PermissionsGroup::class, ]); } diff --git a/src/Bundle/ChillMainBundle/Form/ScopeType.php b/src/Bundle/ChillMainBundle/Form/ScopeType.php index 86335c554..c5a7657b0 100644 --- a/src/Bundle/ChillMainBundle/Form/ScopeType.php +++ b/src/Bundle/ChillMainBundle/Form/ScopeType.php @@ -36,7 +36,7 @@ class ScopeType extends AbstractType public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults([ - 'data_class' => 'Chill\MainBundle\Entity\Scope', + 'data_class' => \Chill\MainBundle\Entity\Scope::class, ]); } diff --git a/src/Bundle/ChillMainBundle/Form/Type/AppendScopeChoiceTypeTrait.php b/src/Bundle/ChillMainBundle/Form/Type/AppendScopeChoiceTypeTrait.php index 547aeb3ec..8eda0d9d9 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/AppendScopeChoiceTypeTrait.php +++ b/src/Bundle/ChillMainBundle/Form/Type/AppendScopeChoiceTypeTrait.php @@ -83,8 +83,8 @@ trait AppendScopeChoiceTypeTrait { $resolver ->setRequired(['center', 'role']) - ->setAllowedTypes('center', 'Chill\MainBundle\Entity\Center') - ->setAllowedTypes('role', 'Symfony\Component\Security\Core\Role\Role'); + ->setAllowedTypes('center', \Chill\MainBundle\Entity\Center::class) + ->setAllowedTypes('role', 'string'); } /** diff --git a/src/Bundle/ChillMainBundle/Form/Type/ComposedGroupCenterType.php b/src/Bundle/ChillMainBundle/Form/Type/ComposedGroupCenterType.php index d78cf813b..cfc838f5a 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/ComposedGroupCenterType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/ComposedGroupCenterType.php @@ -23,12 +23,12 @@ class ComposedGroupCenterType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('permissionsgroup', EntityType::class, [ - 'class' => 'Chill\MainBundle\Entity\PermissionsGroup', + 'class' => \Chill\MainBundle\Entity\PermissionsGroup::class, 'choice_label' => static function (PermissionsGroup $group) { return $group->getName(); }, ])->add('center', EntityType::class, [ - 'class' => 'Chill\MainBundle\Entity\Center', + 'class' => \Chill\MainBundle\Entity\Center::class, 'choice_label' => static function (Center $center) { return $center->getName(); }, @@ -37,7 +37,7 @@ class ComposedGroupCenterType extends AbstractType public function configureOptions(OptionsResolver $resolver) { - $resolver->setDefault('data_class', 'Chill\MainBundle\Entity\GroupCenter'); + $resolver->setDefault('data_class', \Chill\MainBundle\Entity\GroupCenter::class); } public function getBlockPrefix() diff --git a/src/Bundle/ChillMainBundle/Form/Type/ComposedRoleScopeType.php b/src/Bundle/ChillMainBundle/Form/Type/ComposedRoleScopeType.php index 1d541cbd7..a09130c03 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/ComposedRoleScopeType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/ComposedRoleScopeType.php @@ -98,6 +98,6 @@ class ComposedRoleScopeType extends AbstractType public function configureOptions(OptionsResolver $resolver) { - $resolver->setDefault('data_class', 'Chill\MainBundle\Entity\RoleScope'); + $resolver->setDefault('data_class', \Chill\MainBundle\Entity\RoleScope::class); } } diff --git a/src/Bundle/ChillMainBundle/Form/Type/Select2CountryType.php b/src/Bundle/ChillMainBundle/Form/Type/Select2CountryType.php index 5b4d49edd..bc4d7d3ef 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/Select2CountryType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/Select2CountryType.php @@ -77,7 +77,7 @@ class Select2CountryType extends AbstractType asort($choices, SORT_STRING | SORT_FLAG_CASE); $resolver->setDefaults([ - 'class' => 'Chill\MainBundle\Entity\Country', + 'class' => \Chill\MainBundle\Entity\Country::class, 'choices' => array_combine(array_values($choices), array_keys($choices)), 'preferred_choices' => array_combine(array_values($preferredChoices), array_keys($preferredChoices)), ]); diff --git a/src/Bundle/ChillMainBundle/Form/Type/Select2LanguageType.php b/src/Bundle/ChillMainBundle/Form/Type/Select2LanguageType.php index 164a138d9..328f3c174 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/Select2LanguageType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/Select2LanguageType.php @@ -73,7 +73,7 @@ class Select2LanguageType extends AbstractType asort($choices, SORT_STRING | SORT_FLAG_CASE); $resolver->setDefaults([ - 'class' => 'Chill\MainBundle\Entity\Language', + 'class' => \Chill\MainBundle\Entity\Language::class, 'choices' => array_combine(array_values($choices), array_keys($choices)), 'preferred_choices' => array_combine(array_values($preferredChoices), array_keys($preferredChoices)), ]); diff --git a/src/Bundle/ChillMainBundle/Form/UserType.php b/src/Bundle/ChillMainBundle/Form/UserType.php index dc2140997..e2255a1ab 100644 --- a/src/Bundle/ChillMainBundle/Form/UserType.php +++ b/src/Bundle/ChillMainBundle/Form/UserType.php @@ -167,7 +167,7 @@ class UserType extends AbstractType public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults([ - 'data_class' => 'Chill\MainBundle\Entity\User', + 'data_class' => \Chill\MainBundle\Entity\User::class, ]); $resolver diff --git a/src/Bundle/ChillMainBundle/Form/WorkflowStepType.php b/src/Bundle/ChillMainBundle/Form/WorkflowStepType.php index 1b18b3ef8..cc7d70f74 100644 --- a/src/Bundle/ChillMainBundle/Form/WorkflowStepType.php +++ b/src/Bundle/ChillMainBundle/Form/WorkflowStepType.php @@ -196,7 +196,7 @@ class WorkflowStepType extends AbstractType public function configureOptions(OptionsResolver $resolver) { $resolver - ->setDefined('class', EntityWorkflowStep::class) + ->setDefined('class') ->setRequired('transition') ->setAllowedTypes('transition', 'bool') ->setRequired('entity_workflow') diff --git a/src/Bundle/ChillMainBundle/Pagination/PaginatorFactory.php b/src/Bundle/ChillMainBundle/Pagination/PaginatorFactory.php index e6e0863a2..7f06bf216 100644 --- a/src/Bundle/ChillMainBundle/Pagination/PaginatorFactory.php +++ b/src/Bundle/ChillMainBundle/Pagination/PaginatorFactory.php @@ -78,9 +78,8 @@ class PaginatorFactory $totalItems, $this->getCurrentItemsPerPage(), $this->getCurrentPageNumber(), - null === $route ? $this->getCurrentRoute() : $route, - null === $routeParameters ? $this->getCurrentRouteParameters() : - $routeParameters, + $route ?? $this->getCurrentRoute(), + $routeParameters ?? $this->getCurrentRouteParameters(), $this->router, self::DEFAULT_CURRENT_PAGE_KEY, self::DEFAULT_ITEM_PER_NUMBER_KEY diff --git a/src/Bundle/ChillMainBundle/Search/SearchProvider.php b/src/Bundle/ChillMainBundle/Search/SearchProvider.php index f63d3c04f..a629a45d2 100644 --- a/src/Bundle/ChillMainBundle/Search/SearchProvider.php +++ b/src/Bundle/ChillMainBundle/Search/SearchProvider.php @@ -91,11 +91,7 @@ class SearchProvider { //sort the array uasort($this->searchServices, static function (SearchInterface $a, SearchInterface $b) { - if ($a->getOrder() === $b->getOrder()) { - return 0; - } - - return ($a->getOrder() < $b->getOrder()) ? -1 : 1; + return $a->getOrder() <=> $b->getOrder(); }); return $this->searchServices; @@ -124,11 +120,7 @@ class SearchProvider { //sort the array uasort($this->hasAdvancedFormSearchServices, static function (SearchInterface $a, SearchInterface $b) { - if ($a->getOrder() === $b->getOrder()) { - return 0; - } - - return ($a->getOrder() < $b->getOrder()) ? -1 : 1; + return $a->getOrder() <=> $b->getOrder(); }); return $this->hasAdvancedFormSearchServices; diff --git a/src/Bundle/ChillMainBundle/Service/AddressGeographicalUnit/RefreshAddressToGeographicalUnitMaterializedViewCronJob.php b/src/Bundle/ChillMainBundle/Service/AddressGeographicalUnit/RefreshAddressToGeographicalUnitMaterializedViewCronJob.php index 3c1ff0a75..9dbb38a3f 100644 --- a/src/Bundle/ChillMainBundle/Service/AddressGeographicalUnit/RefreshAddressToGeographicalUnitMaterializedViewCronJob.php +++ b/src/Bundle/ChillMainBundle/Service/AddressGeographicalUnit/RefreshAddressToGeographicalUnitMaterializedViewCronJob.php @@ -41,7 +41,7 @@ class RefreshAddressToGeographicalUnitMaterializedViewCronJob implements CronJob return $cronJobExecution->getLastStart() < $now->sub(new DateInterval('P1D')) // introduce a random component to ensure a roll when multiple instances are hosted on same machines - && mt_rand(0, 10) === 0; + && random_int(0, 10) === 0; } public function getKey(): string diff --git a/src/Bundle/ChillMainBundle/Service/Import/PostalCodeBEFromBestAddress.php b/src/Bundle/ChillMainBundle/Service/Import/PostalCodeBEFromBestAddress.php index a6d9512c7..64acd072a 100644 --- a/src/Bundle/ChillMainBundle/Service/Import/PostalCodeBEFromBestAddress.php +++ b/src/Bundle/ChillMainBundle/Service/Import/PostalCodeBEFromBestAddress.php @@ -66,11 +66,11 @@ class PostalCodeBEFromBestAddress gzclose($uncompressedStream); unlink($tmpname); - $this->logger->info(__CLASS__ . ' list of postal code downloaded'); + $this->logger->info(self::class . ' list of postal code downloaded'); $this->baseImporter->finalize(); - $this->logger->info(__CLASS__ . ' postal code fetched', ['offset' => $offset ?? 0]); + $this->logger->info(self::class . ' postal code fetched', ['offset' => $offset ?? 0]); } private function getFileDownloadUrl(string $lang): string diff --git a/src/Bundle/ChillMainBundle/Service/Import/PostalCodeFRFromOpenData.php b/src/Bundle/ChillMainBundle/Service/Import/PostalCodeFRFromOpenData.php index f6cc2bd99..4a63db490 100644 --- a/src/Bundle/ChillMainBundle/Service/Import/PostalCodeFRFromOpenData.php +++ b/src/Bundle/ChillMainBundle/Service/Import/PostalCodeFRFromOpenData.php @@ -73,7 +73,7 @@ class PostalCodeFRFromOpenData $this->baseImporter->finalize(); fclose($tmpfile); - $this->logger->info(__CLASS__ . ' postal code fetched', ['offset' => $offset ?? 0]); + $this->logger->info(self::class . ' postal code fetched', ['offset' => $offset ?? 0]); } private function handleRecord(array $record): void diff --git a/src/Bundle/ChillMainBundle/Test/Export/AbstractAggregatorTest.php b/src/Bundle/ChillMainBundle/Test/Export/AbstractAggregatorTest.php index af0e3843a..99a75582f 100644 --- a/src/Bundle/ChillMainBundle/Test/Export/AbstractAggregatorTest.php +++ b/src/Bundle/ChillMainBundle/Test/Export/AbstractAggregatorTest.php @@ -243,7 +243,7 @@ abstract class AbstractAggregatorTest extends KernelTestCase $result = $results[0]; $this->assertTrue( - $result instanceof Traversable || is_array($result), + is_iterable($result), 'test that each row in the result is traversable or an array' ); diff --git a/src/Bundle/ChillMainBundle/Test/Export/AbstractExportTest.php b/src/Bundle/ChillMainBundle/Test/Export/AbstractExportTest.php index 0e5b56ae0..23f6c4b84 100644 --- a/src/Bundle/ChillMainBundle/Test/Export/AbstractExportTest.php +++ b/src/Bundle/ChillMainBundle/Test/Export/AbstractExportTest.php @@ -230,7 +230,7 @@ abstract class AbstractExportTest extends WebTestCase $result = $results[0]; $this->assertTrue( - $result instanceof Traversable || is_array($result), + is_iterable($result), 'test that each row in the result is traversable or an array' ); diff --git a/src/Bundle/ChillMainBundle/Test/PrepareCenterTrait.php b/src/Bundle/ChillMainBundle/Test/PrepareCenterTrait.php index 343c41180..e43cc8fdb 100644 --- a/src/Bundle/ChillMainBundle/Test/PrepareCenterTrait.php +++ b/src/Bundle/ChillMainBundle/Test/PrepareCenterTrait.php @@ -38,7 +38,7 @@ trait PrepareCenterTrait } $center = $this->centerProphet->prophesize(); - $center->willExtend('\Chill\MainBundle\Entity\Center'); + $center->willExtend('\\' . \Chill\MainBundle\Entity\Center::class); $center->getId()->willReturn($id); $center->getName()->willReturn($name); diff --git a/src/Bundle/ChillMainBundle/Test/PrepareCircleTrait.php b/src/Bundle/ChillMainBundle/Test/PrepareCircleTrait.php index 4621fce04..8cbe9337c 100644 --- a/src/Bundle/ChillMainBundle/Test/PrepareCircleTrait.php +++ b/src/Bundle/ChillMainBundle/Test/PrepareCircleTrait.php @@ -38,7 +38,7 @@ trait PrepareCircleTrait } $scope = $this->circleProphet->prophesize(); - $scope->willExtend('\Chill\MainBundle\Entity\Scope'); + $scope->willExtend('\\' . \Chill\MainBundle\Entity\Scope::class); $scope->getId()->willReturn($id); $scope->getName()->willReturn($name); diff --git a/src/Bundle/ChillMainBundle/Tests/Export/ExportManagerTest.php b/src/Bundle/ChillMainBundle/Tests/Export/ExportManagerTest.php index 77f5aa1e1..f0a57e1b0 100644 --- a/src/Bundle/ChillMainBundle/Tests/Export/ExportManagerTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Export/ExportManagerTest.php @@ -198,10 +198,10 @@ final class ExportManagerTest extends KernelTestCase //create a formatter $formatterFoo = $this->prophet->prophesize(); - $formatterFoo->willImplement('Chill\MainBundle\Export\FormatterInterface'); + $formatterFoo->willImplement(\Chill\MainBundle\Export\FormatterInterface::class); $formatterFoo->getType()->willReturn('foo'); $formatterBar = $this->prophet->prophesize(); - $formatterBar->willImplement('Chill\MainBundle\Export\FormatterInterface'); + $formatterBar->willImplement(\Chill\MainBundle\Export\FormatterInterface::class); $formatterBar->getType()->willReturn('bar'); $exportManager->addFormatter($formatterFoo->reveal(), 'foo'); $exportManager->addFormatter($formatterBar->reveal(), 'bar'); @@ -380,12 +380,12 @@ final class ExportManagerTest extends KernelTestCase //create a filter and add it to ExportManager $agg = $this->prophet->prophesize(); - $agg->willImplement('Chill\MainBundle\Export\AggregatorInterface'); + $agg->willImplement(\Chill\MainBundle\Export\AggregatorInterface::class); $exportManager->addAggregator($agg->reveal(), 'dummy'); $obtained = $exportManager->getAggregator('dummy'); - $this->assertInstanceof('Chill\MainBundle\Export\AggregatorInterface', $obtained); + $this->assertInstanceof(\Chill\MainBundle\Export\AggregatorInterface::class, $obtained); } public function testGetAggregatorNonExistant() @@ -403,11 +403,11 @@ final class ExportManagerTest extends KernelTestCase //create three filters and add them to ExportManager $aggFoo = $this->prophet->prophesize(); - $aggFoo->willImplement('Chill\MainBundle\Export\AggregatorInterface'); + $aggFoo->willImplement(\Chill\MainBundle\Export\AggregatorInterface::class); $aggBar = $this->prophet->prophesize(); - $aggBar->willImplement('Chill\MainBundle\Export\AggregatorInterface'); + $aggBar->willImplement(\Chill\MainBundle\Export\AggregatorInterface::class); $aggFooBar = $this->prophet->prophesize(); - $aggFooBar->willImplement('Chill\MainBundle\Export\AggregatorInterface'); + $aggFooBar->willImplement(\Chill\MainBundle\Export\AggregatorInterface::class); $exportManager->addAggregator($aggFoo->reveal(), 'foo'); $exportManager->addAggregator($aggBar->reveal(), 'bar'); $exportManager->addAggregator($aggFooBar->reveal(), 'foobar'); @@ -477,12 +477,12 @@ final class ExportManagerTest extends KernelTestCase //create a filter and add it to ExportManager $filter = $this->prophet->prophesize(); - $filter->willImplement('Chill\MainBundle\Export\FilterInterface'); + $filter->willImplement(\Chill\MainBundle\Export\FilterInterface::class); $exportManager->addFilter($filter->reveal(), 'dummy'); $obtained = $exportManager->getFilter('dummy'); - $this->assertInstanceof('Chill\MainBundle\Export\FilterInterface', $obtained); + $this->assertInstanceof(\Chill\MainBundle\Export\FilterInterface::class, $obtained); } public function testGetFilterNonExistant() @@ -500,11 +500,11 @@ final class ExportManagerTest extends KernelTestCase //create three filters and add them to ExportManager $filterFoo = $this->prophet->prophesize(); - $filterFoo->willImplement('Chill\MainBundle\Export\FilterInterface'); + $filterFoo->willImplement(\Chill\MainBundle\Export\FilterInterface::class); $filterBar = $this->prophet->prophesize(); - $filterBar->willImplement('Chill\MainBundle\Export\FilterInterface'); + $filterBar->willImplement(\Chill\MainBundle\Export\FilterInterface::class); $filterFooBar = $this->prophet->prophesize(); - $filterFooBar->willImplement('Chill\MainBundle\Export\FilterInterface'); + $filterFooBar->willImplement(\Chill\MainBundle\Export\FilterInterface::class); $exportManager->addFilter($filterFoo->reveal(), 'foo'); $exportManager->addFilter($filterBar->reveal(), 'bar'); $exportManager->addFilter($filterFooBar->reveal(), 'foobar'); @@ -522,12 +522,12 @@ final class ExportManagerTest extends KernelTestCase //create a formatter $formatter = $this->prophet->prophesize(); - $formatter->willImplement('Chill\MainBundle\Export\FormatterInterface'); + $formatter->willImplement(\Chill\MainBundle\Export\FormatterInterface::class); $exportManager->addFormatter($formatter->reveal(), 'dummy'); $obtained = $exportManager->getFormatter('dummy'); - $this->assertInstanceOf('Chill\MainBundle\Export\FormatterInterface', $obtained); + $this->assertInstanceOf(\Chill\MainBundle\Export\FormatterInterface::class, $obtained); } public function testIsGrantedForElementWithExportAndUserIsGranted() @@ -536,7 +536,7 @@ final class ExportManagerTest extends KernelTestCase $user = $this->prepareUser([]); $authorizationChecker = $this->prophet->prophesize(); - $authorizationChecker->willImplement('Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface'); + $authorizationChecker->willImplement(\Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface::class); $authorizationChecker->isGranted('CHILL_STAT_DUMMY', $center) ->willReturn(true); @@ -564,7 +564,7 @@ final class ExportManagerTest extends KernelTestCase $user = $this->prepareUser([]); $authorizationChecker = $this->prophet->prophesize(); - $authorizationChecker->willImplement('Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface'); + $authorizationChecker->willImplement(\Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface::class); $authorizationChecker->isGranted('CHILL_STAT_DUMMY', $center) ->willReturn(true); $authorizationChecker->isGranted('CHILL_STAT_DUMMY', $centerB) diff --git a/src/Bundle/ChillMainBundle/Tests/Form/Type/PickCenterTypeTest.php b/src/Bundle/ChillMainBundle/Tests/Form/Type/PickCenterTypeTest.php index ad32ecee7..ffb7c6bed 100644 --- a/src/Bundle/ChillMainBundle/Tests/Form/Type/PickCenterTypeTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Form/Type/PickCenterTypeTest.php @@ -101,7 +101,7 @@ final class PickCenterTypeTest extends TypeTestCase $prophet = new \Prophecy\Prophet(); $prophecyCenter = $prophet->prophesize(); - $prophecyCenter->willExtend('\Chill\MainBundle\Entity\Center'); + $prophecyCenter->willExtend('\\' . \Chill\MainBundle\Entity\Center::class); $prophecyCenter->getId()->willReturn($id); $prophecyCenter->getName()->willReturn($name); @@ -122,18 +122,18 @@ final class PickCenterTypeTest extends TypeTestCase //create a center transformer $centerTransformerProphecy = $prophet->prophesize(); $centerTransformerProphecy - ->willExtend('Chill\MainBundle\Form\Type\DataTransformer\CenterTransformer'); + ->willExtend(\Chill\MainBundle\Form\Type\DataTransformer\CenterTransformer::class); $transformer = $centerTransformerProphecy->reveal(); $tokenProphecy = $prophet->prophesize(); $tokenProphecy - ->willImplement('\Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + ->willImplement('\\' . \Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class); $tokenProphecy->getUser()->willReturn($user); $token = $tokenProphecy->reveal(); $tokenStorageProphecy = $prophet->prophesize(); $tokenStorageProphecy - ->willExtend('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage'); + ->willExtend(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage::class); $tokenStorageProphecy->getToken()->willReturn($token); $tokenStorage = $tokenStorageProphecy->reveal(); diff --git a/src/Bundle/ChillMainBundle/Tests/Search/AbstractSearchTest.php b/src/Bundle/ChillMainBundle/Tests/Search/AbstractSearchTest.php index 497f91271..9348c6fe2 100644 --- a/src/Bundle/ChillMainBundle/Tests/Search/AbstractSearchTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Search/AbstractSearchTest.php @@ -26,7 +26,7 @@ final class AbstractSearchTest extends \PHPUnit\Framework\TestCase protected function setUp(): void { - $this->stub = $this->getMockForAbstractClass('Chill\MainBundle\Search\AbstractSearch'); + $this->stub = $this->getMockForAbstractClass(\Chill\MainBundle\Search\AbstractSearch::class); } public function testParseDateRegular() diff --git a/src/Bundle/ChillMainBundle/Tests/Search/SearchProviderTest.php b/src/Bundle/ChillMainBundle/Tests/Search/SearchProviderTest.php index 362787b84..f9dbcec51 100644 --- a/src/Bundle/ChillMainBundle/Tests/Search/SearchProviderTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Search/SearchProviderTest.php @@ -245,7 +245,7 @@ final class SearchProviderTest extends TestCase private function createDefaultSearchService($result, $order) { $mock = $this - ->getMockForAbstractClass('Chill\MainBundle\Search\AbstractSearch'); + ->getMockForAbstractClass(\Chill\MainBundle\Search\AbstractSearch::class); //set the mock as default $mock->expects($this->any()) @@ -267,7 +267,7 @@ final class SearchProviderTest extends TestCase private function createNonDefaultDomainSearchService($result, $order, $domain) { $mock = $this - ->getMockForAbstractClass('Chill\MainBundle\Search\AbstractSearch'); + ->getMockForAbstractClass(\Chill\MainBundle\Search\AbstractSearch::class); //set the mock as default $mock->expects($this->any()) diff --git a/src/Bundle/ChillMainBundle/Tests/Security/Authorization/AuthorizationHelperTest.php b/src/Bundle/ChillMainBundle/Tests/Security/Authorization/AuthorizationHelperTest.php index cc5a49096..8e3c27e99 100644 --- a/src/Bundle/ChillMainBundle/Tests/Security/Authorization/AuthorizationHelperTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Security/Authorization/AuthorizationHelperTest.php @@ -279,8 +279,8 @@ final class AuthorizationHelperTest extends KernelTestCase ]); $helper = $this->getAuthorizationHelper(); $entity = $this->getProphet()->prophesize(); - $entity->willImplement('\Chill\MainBundle\Entity\HasCenterInterface'); - $entity->willImplement('\Chill\MainBundle\Entity\HasScopeInterface'); + $entity->willImplement('\\' . \Chill\MainBundle\Entity\HasCenterInterface::class); + $entity->willImplement('\\' . \Chill\MainBundle\Entity\HasScopeInterface::class); $entity->getCenter()->willReturn($center); $entity->getScope()->willReturn($scope); @@ -386,7 +386,7 @@ final class AuthorizationHelperTest extends KernelTestCase ]); $helper = $this->getAuthorizationHelper(); $entity = $this->getProphet()->prophesize(); - $entity->willImplement('\Chill\MainBundle\Entity\HasCenterInterface'); + $entity->willImplement('\\' . \Chill\MainBundle\Entity\HasCenterInterface::class); $entity->getCenter()->willReturn($center); $this->assertTrue($helper->userHasAccess( @@ -410,7 +410,7 @@ final class AuthorizationHelperTest extends KernelTestCase $helper = $this->getAuthorizationHelper(); $entity = $this->getProphet()->prophesize(); - $entity->willImplement('\Chill\MainBundle\Entity\HasCenterInterface'); + $entity->willImplement('\\' . \Chill\MainBundle\Entity\HasCenterInterface::class); $entity->getCenter()->willReturn($center); $this->assertTrue($helper->userHasAccess( @@ -434,8 +434,8 @@ final class AuthorizationHelperTest extends KernelTestCase ]); $helper = $this->getAuthorizationHelper(); $entity = $this->getProphet()->prophesize(); - $entity->willImplement('\Chill\MainBundle\Entity\HasCenterInterface'); - $entity->willImplement('\Chill\MainBundle\Entity\HasScopeInterface'); + $entity->willImplement('\\' . \Chill\MainBundle\Entity\HasCenterInterface::class); + $entity->willImplement('\\' . \Chill\MainBundle\Entity\HasScopeInterface::class); $entity->getCenter()->willReturn($centerB); $entity->getScope()->willReturn($scope); @@ -455,7 +455,7 @@ final class AuthorizationHelperTest extends KernelTestCase ]); $helper = $this->getAuthorizationHelper(); $entity = $this->getProphet()->prophesize(); - $entity->willImplement('\Chill\MainBundle\Entity\HasCenterInterface'); + $entity->willImplement('\\' . \Chill\MainBundle\Entity\HasCenterInterface::class); $entity->getCenter()->willReturn($center); $this->assertFalse($helper->userHasAccess($user, $entity->reveal(), 'CHILL_ROLE')); @@ -474,8 +474,8 @@ final class AuthorizationHelperTest extends KernelTestCase ]); $helper = $this->getAuthorizationHelper(); $entity = $this->getProphet()->prophesize(); - $entity->willImplement('\Chill\MainBundle\Entity\HasCenterInterface'); - $entity->willImplement('\Chill\MainBundle\Entity\HasScopeInterface'); + $entity->willImplement('\\' . \Chill\MainBundle\Entity\HasCenterInterface::class); + $entity->willImplement('\\' . \Chill\MainBundle\Entity\HasScopeInterface::class); $entity->getCenter()->willReturn($center); $entity->getScope()->willReturn($scope); @@ -506,7 +506,7 @@ final class AuthorizationHelperTest extends KernelTestCase ]); $helper = $this->getAuthorizationHelper(); $entity = $this->getProphet()->prophesize(); - $entity->willImplement('\Chill\MainBundle\Entity\HasCenterInterface'); + $entity->willImplement('\\' . \Chill\MainBundle\Entity\HasCenterInterface::class); $entity->getCenter()->willReturn($centerA); $this->assertFalse($helper->userHasAccess($user, $entity->reveal(), 'CHILL_ROLE')); diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonController.php b/src/Bundle/ChillPersonBundle/Controller/PersonController.php index bb03a6b33..4b1c10e0f 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonController.php @@ -162,7 +162,7 @@ final class PersonController extends AbstractController $cFGroup = null; $cFDefaultGroup = $this->em->getRepository(\Chill\CustomFieldsBundle\Entity\CustomFieldsDefaultGroup::class) - ->findOneByEntity('Chill\\PersonBundle\\Entity\\Person'); + ->findOneByEntity(\Chill\PersonBundle\Entity\Person::class); if ($cFDefaultGroup) { $cFGroup = $cFDefaultGroup->getCustomFieldsGroup(); diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadCustomFields.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadCustomFields.php index 14434be6e..87746842a 100644 --- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadCustomFields.php +++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadCustomFields.php @@ -125,12 +125,12 @@ class LoadCustomFields extends AbstractFixture implements // select a set of people and add data foreach ($personIds as $id) { // add info on 1 person on 2 - if (mt_rand(0, 1) === 1) { + if (random_int(0, 1) === 1) { /** @var Person $person */ $person = $manager->getRepository(Person::class)->find($id); $person->setCFData([ 'remarques' => $this->createCustomFieldText() - ->serialize($faker->text(mt_rand(150, 250)), $this->customFieldText), + ->serialize($faker->text(random_int(150, 250)), $this->customFieldText), 'document-d-identite' => $this->createCustomFieldChoice() ->serialize([$choices[array_rand($choices)]], $this->customFieldChoice), ]); diff --git a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php index d60e15e41..6a2dc924e 100644 --- a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php +++ b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php @@ -1006,7 +1006,7 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac 'property' => 'step', ], 'supports' => [ - 'Chill\PersonBundle\Entity\AccompanyingPeriod', + \Chill\PersonBundle\Entity\AccompanyingPeriod::class, ], 'initial_marking' => 'DRAFT', 'places' => [ @@ -1043,7 +1043,7 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac $container->prependExtensionConfig( 'chill_custom_fields', ['customizables_entities' => [ - ['class' => 'Chill\PersonBundle\Entity\Person', 'name' => 'PersonEntity'], + ['class' => \Chill\PersonBundle\Entity\Person::class, 'name' => 'PersonEntity'], ], ] ); diff --git a/src/Bundle/ChillPersonBundle/DependencyInjection/Configuration.php b/src/Bundle/ChillPersonBundle/DependencyInjection/Configuration.php index f9686c900..a591663ad 100644 --- a/src/Bundle/ChillPersonBundle/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillPersonBundle/DependencyInjection/Configuration.php @@ -30,7 +30,7 @@ class Configuration implements ConfigurationInterface public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder('cl_chill_person'); - $rootNode = $treeBuilder->getRootNode('cl_chill_person'); + $rootNode = $treeBuilder->getRootNode(); $rootNode ->canBeDisabled() @@ -137,7 +137,7 @@ class Configuration implements ConfigurationInterface private function addFieldNode($key) { $tree = new TreeBuilder($key, 'enum'); - $node = $tree->getRootNode($key); + $node = $tree->getRootNode(); switch ($key) { case 'accompanying_period': diff --git a/src/Bundle/ChillPersonBundle/Entity/Household/Household.php b/src/Bundle/ChillPersonBundle/Entity/Household/Household.php index b463312c8..48e1ac1fc 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Household/Household.php +++ b/src/Bundle/ChillPersonBundle/Entity/Household/Household.php @@ -200,7 +200,7 @@ class Household */ public function getCurrentAddress(?DateTime $at = null): ?Address { - $at = null === $at ? new DateTime('today') : $at; + $at = $at ?? new DateTime('today'); $addrs = $this->getAddresses()->filter(static function (Address $a) use ($at) { return $a->getValidFrom() <= $at && ( @@ -412,7 +412,7 @@ class Household { $criteria = new Criteria(); $expr = Criteria::expr(); - $date = null === $now ? (new DateTimeImmutable('today')) : $now; + $date = $now ?? new DateTimeImmutable('today'); $criteria ->where( @@ -634,7 +634,7 @@ class Household { $criteria = new Criteria(); $expr = Criteria::expr(); - $date = null === $now ? (new DateTimeImmutable('today')) : $now; + $date = $now ?? new DateTimeImmutable('today'); $criteria ->where($expr->orX( diff --git a/src/Bundle/ChillPersonBundle/Entity/Household/HouseholdMember.php b/src/Bundle/ChillPersonBundle/Entity/Household/HouseholdMember.php index e5e5e4626..031279173 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Household/HouseholdMember.php +++ b/src/Bundle/ChillPersonBundle/Entity/Household/HouseholdMember.php @@ -142,7 +142,7 @@ class HouseholdMember public function isCurrent(?DateTimeImmutable $at = null): bool { - $at = null === $at ? new DateTimeImmutable('now') : $at; + $at = $at ?? new DateTimeImmutable('now'); return $this->getStartDate() < $at && ( null === $this->getEndDate() || $this->getEndDate() > $at diff --git a/src/Bundle/ChillPersonBundle/Entity/Person.php b/src/Bundle/ChillPersonBundle/Entity/Person.php index 27c34ba23..63bd6efba 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person.php @@ -1087,7 +1087,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI { $criteria = new Criteria(); $expr = Criteria::expr(); - $date = null === $at ? new DateTimeImmutable('today') : $at; + $date = $at ?? new DateTimeImmutable('today'); $datef = $date->format('Y-m-d'); if ( diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AgeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AgeFilter.php index 0bf175ce4..c05f97ca8 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AgeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AgeFilter.php @@ -42,8 +42,8 @@ class AgeFilter implements ExportElementValidatedInterface, FilterInterface { $where = $qb->getDQLPart('where'); - $min = null !== $data['min_age'] ? $data['min_age'] : 0; - $max = null !== $data['max_age'] ? $data['max_age'] : 150; + $min = $data['min_age'] ?? 0; + $max = $data['max_age'] ?? 150; $calc = $this->rollingDateConverter->convert($data['date_calc']); $minDate = $calc->sub(new DateInterval('P' . $max . 'Y')); diff --git a/src/Bundle/ChillPersonBundle/Form/AccompanyingPeriodType.php b/src/Bundle/ChillPersonBundle/Form/AccompanyingPeriodType.php index f6bf4962e..25d380562 100644 --- a/src/Bundle/ChillPersonBundle/Form/AccompanyingPeriodType.php +++ b/src/Bundle/ChillPersonBundle/Form/AccompanyingPeriodType.php @@ -98,7 +98,7 @@ class AccompanyingPeriodType extends AbstractType public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults([ - 'data_class' => 'Chill\PersonBundle\Entity\AccompanyingPeriod', + 'data_class' => \Chill\PersonBundle\Entity\AccompanyingPeriod::class, ]); $resolver diff --git a/src/Bundle/ChillPersonBundle/Form/PersonType.php b/src/Bundle/ChillPersonBundle/Form/PersonType.php index 15888c015..42e62929d 100644 --- a/src/Bundle/ChillPersonBundle/Form/PersonType.php +++ b/src/Bundle/ChillPersonBundle/Form/PersonType.php @@ -250,7 +250,7 @@ class PersonType extends AbstractType $resolver->setAllowedTypes( 'cFGroup', - ['null', 'Chill\CustomFieldsBundle\Entity\CustomFieldsGroup'] + ['null', \Chill\CustomFieldsBundle\Entity\CustomFieldsGroup::class] ); } diff --git a/src/Bundle/ChillPersonBundle/Form/Type/Select2MaritalStatusType.php b/src/Bundle/ChillPersonBundle/Form/Type/Select2MaritalStatusType.php index 0099e6367..f057bc1d1 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/Select2MaritalStatusType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/Select2MaritalStatusType.php @@ -40,13 +40,13 @@ class Select2MaritalStatusType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { - $transformer = new ObjectToIdTransformer($this->em, 'Chill\PersonBundle\Entity\MaritalStatus'); + $transformer = new ObjectToIdTransformer($this->em, \Chill\PersonBundle\Entity\MaritalStatus::class); $builder->addModelTransformer($transformer); } public function configureOptions(OptionsResolver $resolver) { - $maritalStatuses = $this->em->getRepository('Chill\PersonBundle\Entity\MaritalStatus')->findAll(); + $maritalStatuses = $this->em->getRepository(\Chill\PersonBundle\Entity\MaritalStatus::class)->findAll(); $choices = []; foreach ($maritalStatuses as $ms) { diff --git a/src/Bundle/ChillPersonBundle/Household/MembersEditor.php b/src/Bundle/ChillPersonBundle/Household/MembersEditor.php index bdb7a8eca..2b2564091 100644 --- a/src/Bundle/ChillPersonBundle/Household/MembersEditor.php +++ b/src/Bundle/ChillPersonBundle/Household/MembersEditor.php @@ -168,7 +168,7 @@ class MembersEditor $criteria->where( $expr->andX( $expr->lt('startDate', $date), - $expr->isNull('endDate', $date) + $expr->isNull('endDate') ) ); diff --git a/src/Bundle/ChillPersonBundle/Repository/ResidentialAddressRepository.php b/src/Bundle/ChillPersonBundle/Repository/ResidentialAddressRepository.php index 424411a72..5f75d537b 100644 --- a/src/Bundle/ChillPersonBundle/Repository/ResidentialAddressRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/ResidentialAddressRepository.php @@ -44,7 +44,7 @@ class ResidentialAddressRepository extends ServiceEntityRepository public function buildQueryFindCurrentResidentialAddresses(Person $person, ?DateTimeImmutable $at = null): QueryBuilder { - $date = null === $at ? new DateTimeImmutable('today') : $at; + $date = $at ?? new DateTimeImmutable('today'); $qb = $this->createQueryBuilder('ra'); $dateFilter = $qb->expr()->andX( diff --git a/src/Bundle/ChillPersonBundle/Service/AccompanyingPeriod/OldDraftAccompanyingPeriodRemover.php b/src/Bundle/ChillPersonBundle/Service/AccompanyingPeriod/OldDraftAccompanyingPeriodRemover.php index 2a608e4c1..a5663050a 100644 --- a/src/Bundle/ChillPersonBundle/Service/AccompanyingPeriod/OldDraftAccompanyingPeriodRemover.php +++ b/src/Bundle/ChillPersonBundle/Service/AccompanyingPeriod/OldDraftAccompanyingPeriodRemover.php @@ -34,7 +34,7 @@ class OldDraftAccompanyingPeriodRemover implements OldDraftAccompanyingPeriodRem public function remove(DateInterval $interval): void { - $this->logger->debug('[' . __CLASS__ . '] start to remove old periods', [ + $this->logger->debug('[' . self::class . '] start to remove old periods', [ 'interval' => $interval->format('%d days'), ]); @@ -96,7 +96,7 @@ class OldDraftAccompanyingPeriodRemover implements OldDraftAccompanyingPeriodRem ]; }); - $this->logger->info('[' . __CLASS__ . '] periods removed', array_merge($results, [ + $this->logger->info('[' . self::class . '] periods removed', array_merge($results, [ 'interval' => $interval->format('%d days'), ])); } diff --git a/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/Events/PersonMoveEventSubscriberTest.php b/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/Events/PersonMoveEventSubscriberTest.php index e35766a75..4f9977b6d 100644 --- a/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/Events/PersonMoveEventSubscriberTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/Events/PersonMoveEventSubscriberTest.php @@ -162,7 +162,7 @@ final class PersonMoveEventSubscriberTest extends KernelTestCase ->setNextMembership($nextMembership); $notificationPersister = $this->prophesize(NotificationPersisterInterface::class); - $notificationPersister->persist(Argument::type(Notification::class))->shouldBeCalled(1); + $notificationPersister->persist(Argument::type(Notification::class))->shouldBeCalled(); $eventSubscriber = $this->buildSubscriber(null, $notificationPersister->reveal(), null, null); $eventSubscriber->resetPeriodLocation($event); diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerCreateTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerCreateTest.php index fbba0bbc3..6f92c864b 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerCreateTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerCreateTest.php @@ -89,7 +89,7 @@ final class PersonControllerCreateTest extends WebTestCase $form = $crawler->selectButton('Ajouter la personne')->form(); $this->assertInstanceOf( - 'Symfony\Component\DomCrawler\Form', + \Symfony\Component\DomCrawler\Form::class, $form, 'The page contains a butto ' ); diff --git a/src/Bundle/ChillPersonBundle/Tests/Security/Authorization/PersonVoterTest.php b/src/Bundle/ChillPersonBundle/Tests/Security/Authorization/PersonVoterTest.php index d7f08a3a4..e6651028c 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Security/Authorization/PersonVoterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Security/Authorization/PersonVoterTest.php @@ -158,7 +158,7 @@ final class PersonVoterTest extends KernelTestCase { $token = $this->prophet->prophesize(); $token - ->willImplement('\Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + ->willImplement('\\' . \Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class); if (null === $permissions) { $token->getUser()->willReturn(null); diff --git a/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/AccompanyingPeriodWorkDocGenNormalizerTest.php b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/AccompanyingPeriodWorkDocGenNormalizerTest.php index e71e0bf51..ce226834b 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/AccompanyingPeriodWorkDocGenNormalizerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/AccompanyingPeriodWorkDocGenNormalizerTest.php @@ -88,7 +88,7 @@ final class AccompanyingPeriodWorkDocGenNormalizerTest extends KernelTestCase $this->assertEqualsCanonicalizing(array_keys($expected), array_keys($actual)); foreach ($expected as $key => $item) { - if ('@ignored' === $item) { + if (0 === $item) { continue; } diff --git a/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextTest.php b/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextTest.php index 44414cdba..17c6195b3 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextTest.php @@ -187,8 +187,7 @@ final class PersonContextTest extends TestCase { $builder = $this->prophesize(FormBuilderInterface::class); - $builder->add('title', TextType::class, Argument::type('array')) - ->shouldBeCalled(1); + $builder->add('title', TextType::class, Argument::type('array'))->shouldBeCalled(); if ($withScope) { $builder->add('scope', ScopePickerType::class, Argument::type('array')) diff --git a/src/Bundle/ChillReportBundle/Controller/ReportController.php b/src/Bundle/ChillReportBundle/Controller/ReportController.php index 0a62a4b33..da39aedec 100644 --- a/src/Bundle/ChillReportBundle/Controller/ReportController.php +++ b/src/Bundle/ChillReportBundle/Controller/ReportController.php @@ -344,7 +344,7 @@ class ReportController extends AbstractController } $cFGroups = $em->getRepository(\Chill\CustomFieldsBundle\Entity\CustomFieldsGroup::class) - ->findByEntity('Chill\ReportBundle\Entity\Report'); + ->findByEntity(\Chill\ReportBundle\Entity\Report::class); if (count($cFGroups) === 1) { return $this->redirect( @@ -403,7 +403,7 @@ class ReportController extends AbstractController $em = $this->getDoctrine()->getManager(); $cFGroups = $em->getRepository(\Chill\CustomFieldsBundle\Entity\CustomFieldsGroup::class) - ->findByEntity('Chill\ReportBundle\Entity\Report'); + ->findByEntity(\Chill\ReportBundle\Entity\Report::class); if (count($cFGroups) === 1) { return $this->redirect( diff --git a/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadCustomField.php b/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadCustomField.php index 5eebbaad1..a9b8edc30 100644 --- a/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadCustomField.php +++ b/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadCustomField.php @@ -68,15 +68,15 @@ class LoadCustomField extends AbstractFixture implements OrderedFixtureInterface ]; for ($i = 0; 25 >= $i; ++$i) { - $cFType = $cFTypes[mt_rand(0, count($cFTypes) - 1)]; + $cFType = $cFTypes[random_int(0, count($cFTypes) - 1)]; $customField = (new CustomField()) ->setSlug("cf_report_{$i}") ->setType($cFType['type']) ->setOptions($cFType['options']) ->setName(['fr' => "CustomField {$i}"]) - ->setOrdering(mt_rand(0, 1000) / 1000) - ->setCustomFieldsGroup($this->getReference('cf_group_report_' . (mt_rand(0, 3)))); + ->setOrdering(random_int(0, 1000) / 1000) + ->setCustomFieldsGroup($this->getReference('cf_group_report_' . (random_int(0, 3)))); $manager->persist($customField); } diff --git a/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadCustomFieldsGroup.php b/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadCustomFieldsGroup.php index 47cc2511d..32bd5c346 100644 --- a/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadCustomFieldsGroup.php +++ b/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadCustomFieldsGroup.php @@ -66,7 +66,7 @@ class LoadCustomFieldsGroup extends AbstractFixture implements OrderedFixtureInt $cFGroup = (new CustomFieldsGroup()) ->setName($name) - ->setEntity('Chill\ReportBundle\Entity\Report') + ->setEntity(\Chill\ReportBundle\Entity\Report::class) ->setOptions($options); $manager->persist($cFGroup); diff --git a/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReports.php b/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReports.php index 2148a370a..db4646eed 100644 --- a/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReports.php +++ b/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReports.php @@ -88,7 +88,7 @@ class LoadReports extends AbstractFixture implements ContainerAwareInterface, Or $report = (new Report()) ->setPerson($person) ->setCFGroup( - mt_rand(0, 10) > 5 ? + random_int(0, 10) > 5 ? $this->getReference('cf_group_report_logement') : $this->getReference('cf_group_report_education') ) @@ -111,7 +111,7 @@ class LoadReports extends AbstractFixture implements ContainerAwareInterface, Or //set date. 30% of the dates are 2015-05-01 $expectedDate = new DateTime('2015-01-05'); - if (mt_rand(0, 100) < 30) { + if (random_int(0, 100) < 30) { $report->setDate($expectedDate); } else { $report->setDate($this->faker->dateTimeBetween('-1 year', 'now') @@ -155,7 +155,7 @@ class LoadReports extends AbstractFixture implements ContainerAwareInterface, Or $selectedPeople = []; foreach ($people as $person) { - if (mt_rand(0, 100) < $percentage) { + if (random_int(0, 100) < $percentage) { $selectedPeople[] = $person; } } @@ -183,7 +183,7 @@ class LoadReports extends AbstractFixture implements ContainerAwareInterface, Or $picked = []; if ($multiple) { - $numberSelected = mt_rand(1, count($choices) - 1); + $numberSelected = random_int(1, count($choices) - 1); for ($i = 0; $i < $numberSelected; ++$i) { $picked[] = $this->pickChoice($choices); diff --git a/src/Bundle/ChillReportBundle/DependencyInjection/ChillReportExtension.php b/src/Bundle/ChillReportBundle/DependencyInjection/ChillReportExtension.php index 9d8bf8fbe..8f1c5d0d4 100644 --- a/src/Bundle/ChillReportBundle/DependencyInjection/ChillReportExtension.php +++ b/src/Bundle/ChillReportBundle/DependencyInjection/ChillReportExtension.php @@ -41,7 +41,7 @@ class ChillReportExtension extends Extension implements PrependExtensionInterfac 'chill_custom_fields', ['customizables_entities' => [ [ - 'class' => 'Chill\ReportBundle\Entity\Report', + 'class' => \Chill\ReportBundle\Entity\Report::class, 'name' => 'ReportEntity', 'options' => [ 'summary_fields' => [ diff --git a/src/Bundle/ChillReportBundle/DependencyInjection/Configuration.php b/src/Bundle/ChillReportBundle/DependencyInjection/Configuration.php index 565ff08a7..70c9f532b 100644 --- a/src/Bundle/ChillReportBundle/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillReportBundle/DependencyInjection/Configuration.php @@ -24,7 +24,7 @@ class Configuration implements ConfigurationInterface public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder('chill_report'); - $rootNode = $treeBuilder->getRootNode('chill_report'); + $rootNode = $treeBuilder->getRootNode(); // Here you should define the parameters that are allowed to // configure your bundle. See the documentation linked above for diff --git a/src/Bundle/ChillReportBundle/Form/ReportType.php b/src/Bundle/ChillReportBundle/Form/ReportType.php index 435d894d9..8d6551443 100644 --- a/src/Bundle/ChillReportBundle/Form/ReportType.php +++ b/src/Bundle/ChillReportBundle/Form/ReportType.php @@ -88,14 +88,14 @@ class ReportType extends AbstractType public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults([ - 'data_class' => 'Chill\ReportBundle\Entity\Report', + 'data_class' => \Chill\ReportBundle\Entity\Report::class, ]); $resolver->setRequired([ 'cFGroup', ]); - $resolver->setAllowedTypes('cFGroup', 'Chill\CustomFieldsBundle\Entity\CustomFieldsGroup'); + $resolver->setAllowedTypes('cFGroup', \Chill\CustomFieldsBundle\Entity\CustomFieldsGroup::class); $this->appendScopeChoicesOptions($resolver); } diff --git a/src/Bundle/ChillReportBundle/Search/ReportSearch.php b/src/Bundle/ChillReportBundle/Search/ReportSearch.php index 55bbe9f66..e392c37f5 100644 --- a/src/Bundle/ChillReportBundle/Search/ReportSearch.php +++ b/src/Bundle/ChillReportBundle/Search/ReportSearch.php @@ -167,7 +167,7 @@ class ReportSearch extends AbstractSearch implements ContainerAwareInterface ->orderBy('r.date', 'desc'); $reportQuery = $qb->getQuery(); - $reportQuery->setFetchMode('Chill\\ReportBundle\\Entity\\Report', 'person', \Doctrine\ORM\Mapping\ClassMetadata::FETCH_EAGER); + $reportQuery->setFetchMode(\Chill\ReportBundle\Entity\Report::class, 'person', \Doctrine\ORM\Mapping\ClassMetadata::FETCH_EAGER); return $reportQuery->getResult(); } diff --git a/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerNextTest.php b/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerNextTest.php index ea30084ae..d299860bc 100644 --- a/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerNextTest.php +++ b/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerNextTest.php @@ -64,7 +64,7 @@ final class ReportControllerNextTest extends WebTestCase $customFieldsGroups = self::$kernel->getContainer() ->get('doctrine.orm.entity_manager') ->getRepository(\Chill\CustomFieldsBundle\Entity\CustomFieldsGroup::class) - ->findBy(['entity' => 'Chill\ReportBundle\Entity\Report']); + ->findBy(['entity' => \Chill\ReportBundle\Entity\Report::class]); //filter customFieldsGroup to get only "situation de logement" $filteredCustomFieldsGroupHouse = array_filter( $customFieldsGroups, diff --git a/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerTest.php b/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerTest.php index 6a6ee99f1..1afe851b8 100644 --- a/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerTest.php +++ b/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerTest.php @@ -82,7 +82,7 @@ final class ReportControllerTest extends WebTestCase $customFieldsGroups = self::$kernel->getContainer() ->get('doctrine.orm.entity_manager') ->getRepository(\Chill\CustomFieldsBundle\Entity\CustomFieldsGroup::class) - ->findBy(['entity' => 'Chill\ReportBundle\Entity\Report']); + ->findBy(['entity' => \Chill\ReportBundle\Entity\Report::class]); //filter customFieldsGroup to get only "situation de logement" $filteredCustomFieldsGroupHouse = array_filter( $customFieldsGroups, @@ -132,7 +132,7 @@ final class ReportControllerTest extends WebTestCase $form = $crawlerAddAReportPage->selectButton('Créer un nouveau rapport')->form(); $this->assertInstanceOf( - 'Symfony\Component\DomCrawler\Form', + \Symfony\Component\DomCrawler\Form::class, $form, 'I can see a form with a button "add a new report" ' ); @@ -251,7 +251,7 @@ final class ReportControllerTest extends WebTestCase $link = $crawlerPersonPage->selectLink("AJOUT D'UN RAPPORT")->link(); $this->assertInstanceOf( - 'Symfony\Component\DomCrawler\Link', + \Symfony\Component\DomCrawler\Link::class, $link, 'There is a "add a report" link in menu' ); @@ -278,7 +278,7 @@ final class ReportControllerTest extends WebTestCase ->form(); $this->assertInstanceOf( - 'Symfony\Component\DomCrawler\Form', + \Symfony\Component\DomCrawler\Form::class, $addForm, 'I have a report form' ); diff --git a/src/Bundle/ChillReportBundle/Tests/DependencyInjection/ChillReportExtensionTest.php b/src/Bundle/ChillReportBundle/Tests/DependencyInjection/ChillReportExtensionTest.php index 2b02159ca..e480ca960 100644 --- a/src/Bundle/ChillReportBundle/Tests/DependencyInjection/ChillReportExtensionTest.php +++ b/src/Bundle/ChillReportBundle/Tests/DependencyInjection/ChillReportExtensionTest.php @@ -32,7 +32,7 @@ final class ChillReportExtensionTest extends KernelTestCase $reportFounded = false; foreach ($customizablesEntities as $customizablesEntity) { - if ('Chill\ReportBundle\Entity\Report' === $customizablesEntity['class']) { + if (\Chill\ReportBundle\Entity\Report::class === $customizablesEntity['class']) { $reportFounded = true; } } diff --git a/src/Bundle/ChillReportBundle/Tests/Security/Authorization/ReportVoterTest.php b/src/Bundle/ChillReportBundle/Tests/Security/Authorization/ReportVoterTest.php index be32edc8d..4179df56d 100644 --- a/src/Bundle/ChillReportBundle/Tests/Security/Authorization/ReportVoterTest.php +++ b/src/Bundle/ChillReportBundle/Tests/Security/Authorization/ReportVoterTest.php @@ -167,7 +167,7 @@ final class ReportVoterTest extends KernelTestCase { $token = $this->prophet->prophesize(); $token - ->willImplement('\Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + ->willImplement('\\' . \Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class); if (null === $user) { $token->getUser()->willReturn(null); diff --git a/src/Bundle/ChillReportBundle/Tests/Timeline/TimelineProviderTest.php b/src/Bundle/ChillReportBundle/Tests/Timeline/TimelineProviderTest.php index 9f39fb87e..ecaabb495 100644 --- a/src/Bundle/ChillReportBundle/Tests/Timeline/TimelineProviderTest.php +++ b/src/Bundle/ChillReportBundle/Tests/Timeline/TimelineProviderTest.php @@ -191,6 +191,6 @@ final class TimelineProviderTest extends WebTestCase } } - return $groups[mt_rand(0, count($groups) - 1)]; + return $groups[random_int(0, count($groups) - 1)]; } } diff --git a/src/Bundle/ChillTaskBundle/DependencyInjection/Configuration.php b/src/Bundle/ChillTaskBundle/DependencyInjection/Configuration.php index 8c57ef0f6..f01050684 100644 --- a/src/Bundle/ChillTaskBundle/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillTaskBundle/DependencyInjection/Configuration.php @@ -24,7 +24,7 @@ class Configuration implements ConfigurationInterface public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder('chill_task'); - $rootNode = $treeBuilder->getRootNode('chill_task'); + $rootNode = $treeBuilder->getRootNode(); // Here you should define the parameters that are allowed to // configure your bundle. See the documentation linked above for diff --git a/src/Bundle/ChillTaskBundle/Menu/MenuBuilder.php b/src/Bundle/ChillTaskBundle/Menu/MenuBuilder.php index 4933b063c..2ecd2f5de 100644 --- a/src/Bundle/ChillTaskBundle/Menu/MenuBuilder.php +++ b/src/Bundle/ChillTaskBundle/Menu/MenuBuilder.php @@ -71,7 +71,7 @@ class MenuBuilder implements LocalMenuBuilderInterface break; case 'section': - $menu->setExtras('icons', 'tasks'); + $menu->setExtras('icons'); break; diff --git a/src/Bundle/ChillTaskBundle/Timeline/TaskLifeCycleEventTimelineProvider.php b/src/Bundle/ChillTaskBundle/Timeline/TaskLifeCycleEventTimelineProvider.php index e5414cac1..4d8ddd062 100644 --- a/src/Bundle/ChillTaskBundle/Timeline/TaskLifeCycleEventTimelineProvider.php +++ b/src/Bundle/ChillTaskBundle/Timeline/TaskLifeCycleEventTimelineProvider.php @@ -108,7 +108,7 @@ class TaskLifeCycleEventTimelineProvider implements TimelineProviderInterface { $workflow = $this->registry->get( $entity->getTask(), - (isset($entity->getData()['workflow'])) ? $entity->getData()['workflow'] : null + $entity->getData()['workflow'] ?? null ); // sf4 check: prevent error message: // `Notice: Undefined property: Chill\TaskBundle\Entity\Task\SingleTaskPlaceEvent::$getData` diff --git a/src/Bundle/ChillThirdPartyBundle/DependencyInjection/Configuration.php b/src/Bundle/ChillThirdPartyBundle/DependencyInjection/Configuration.php index 3248f58d7..d4c2cd598 100644 --- a/src/Bundle/ChillThirdPartyBundle/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillThirdPartyBundle/DependencyInjection/Configuration.php @@ -24,7 +24,7 @@ class Configuration implements ConfigurationInterface public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder('chill_third_party'); - $rootNode = $treeBuilder->getRootNode('chill_third_party'); + $rootNode = $treeBuilder->getRootNode(); // Here you should define the parameters that are allowed to // configure your bundle. See the documentation linked above for From 4c5dae60a8d5f68a28879ca29ab56f60191862dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 29 Mar 2023 22:39:11 +0200 Subject: [PATCH 007/724] DX: apply rector rulesets up to PHP 73 --- .../Export/LinkedToPerson/ListActivity.php | 4 +- .../Export/Export/ListActivityHelper.php | 2 +- .../JsonCustomFieldToArrayTransformer.php | 2 +- .../GeneratorDriver/RelatorioDriver.php | 4 +- .../Form/StoredObjectType.php | 4 +- .../Controller/ExportController.php | 2 +- .../Controller/SearchController.php | 4 +- .../ChillMainBundle/Doctrine/Model/Point.php | 4 +- .../Export/Helper/AggregateStringHelper.php | 2 +- .../Export/Helper/ExportAddressHelper.php | 4 +- .../TranslatableStringExportLabelHelper.php | 4 +- .../Export/Helper/UserHelper.php | 2 +- .../EntityToJsonTransformer.php | 2 +- .../Phonenumber/PhonenumberHelper.php | 2 +- .../PermissionApiControllerTest.php | 4 +- .../PostalCodeApiControllerTest.php | 2 +- .../Controller/UserApiControllerTest.php | 2 +- .../GeographicalUnitBaseImporterTest.php | 4 +- .../migrations/Version20180709181423.php | 40 +++++++-------- .../ReassignAccompanyingPeriodController.php | 4 +- .../Export/Export/ListAccompanyingPeriod.php | 6 +-- .../Export/Export/ListPerson.php | 4 +- .../Export/Helper/LabelPersonHelper.php | 2 +- .../Export/Helper/ListPersonHelper.php | 2 +- .../AccompanyingPeriodConfidentialTest.php | 2 +- .../AccompanyingCourseApiControllerTest.php | 42 ++++++++-------- .../Controller/HouseholdApiControllerTest.php | 2 +- .../HouseholdMemberControllerTest.php | 4 +- .../Controller/PersonApiControllerTest.php | 2 +- .../RelationshipApiControllerTest.php | 2 +- .../SocialIssueApiControllerTest.php | 4 +- .../SocialWorkEvaluationApiControllerTest.php | 2 +- .../migrations/Version20160818113633.php | 2 +- .../migrations/Version20181023101621.php | 50 +++++++++---------- .../migrations/Version20200130213446.php | 28 +++++------ .../Export/Export/ReportList.php | 6 +-- .../Export/Helper/LabelThirdPartyHelper.php | 2 +- 37 files changed, 129 insertions(+), 131 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php index 5d438d3a5..8b69216b6 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php @@ -152,7 +152,7 @@ class ListActivity implements ListInterface, GroupedExportInterface return 'circle'; } - return $this->translatableStringHelper->localize(json_decode($value, true)); + return $this->translatableStringHelper->localize(json_decode($value, true, 512, JSON_THROW_ON_ERROR)); }; case 'type_name': @@ -161,7 +161,7 @@ class ListActivity implements ListInterface, GroupedExportInterface return 'activity type'; } - return $this->translatableStringHelper->localize(json_decode($value, true)); + return $this->translatableStringHelper->localize(json_decode($value, true, 512, JSON_THROW_ON_ERROR)); }; default: diff --git a/src/Bundle/ChillActivityBundle/Export/Export/ListActivityHelper.php b/src/Bundle/ChillActivityBundle/Export/Export/ListActivityHelper.php index 0e8b28ab4..fae6ea6a6 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/ListActivityHelper.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/ListActivityHelper.php @@ -179,7 +179,7 @@ class ListActivityHelper } } - $decoded = json_decode($value); + $decoded = json_decode($value, null, 512, JSON_THROW_ON_ERROR); return implode( '|', diff --git a/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/JsonCustomFieldToArrayTransformer.php b/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/JsonCustomFieldToArrayTransformer.php index 6bd12a07a..bccf797e5 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/JsonCustomFieldToArrayTransformer.php +++ b/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/JsonCustomFieldToArrayTransformer.php @@ -108,7 +108,7 @@ class JsonCustomFieldToArrayTransformer implements DataTransformerInterface //echo json_encode($customFieldsArrayRet); - return json_encode($customFieldsArrayRet); + return json_encode($customFieldsArrayRet, JSON_THROW_ON_ERROR); } public function transform($customFieldsJSON) diff --git a/src/Bundle/ChillDocGeneratorBundle/GeneratorDriver/RelatorioDriver.php b/src/Bundle/ChillDocGeneratorBundle/GeneratorDriver/RelatorioDriver.php index 0f62931b4..c14b67df7 100644 --- a/src/Bundle/ChillDocGeneratorBundle/GeneratorDriver/RelatorioDriver.php +++ b/src/Bundle/ChillDocGeneratorBundle/GeneratorDriver/RelatorioDriver.php @@ -44,7 +44,7 @@ final class RelatorioDriver implements DriverInterface { $form = new FormDataPart( [ - 'variables' => json_encode($data), + 'variables' => json_encode($data, JSON_THROW_ON_ERROR), 'template' => new DataPart($template, $templateName ?? uniqid('template_'), $resourceType), ] ); @@ -61,7 +61,7 @@ final class RelatorioDriver implements DriverInterface $content = $e->getResponse()->getContent(false); if (400 === $e->getResponse()->getStatusCode()) { - $content = json_decode($content, true); + $content = json_decode($content, true, 512, JSON_THROW_ON_ERROR); $this->logger->error('relatorio: template error', [ 'error' => $content['message'] ?? '_not defined', ]); diff --git a/src/Bundle/ChillDocStoreBundle/Form/StoredObjectType.php b/src/Bundle/ChillDocStoreBundle/Form/StoredObjectType.php index 664e7a2aa..4f3cd315f 100644 --- a/src/Bundle/ChillDocStoreBundle/Form/StoredObjectType.php +++ b/src/Bundle/ChillDocStoreBundle/Form/StoredObjectType.php @@ -95,7 +95,7 @@ class StoredObjectType extends AbstractType return null; } - return json_decode($value, true); + return json_decode($value, true, 512, JSON_THROW_ON_ERROR); } public function reverseTransformObject($object) @@ -120,7 +120,7 @@ class StoredObjectType extends AbstractType return null; } - return json_encode($object); + return json_encode($object, JSON_THROW_ON_ERROR); } public function transformObject($object = null) diff --git a/src/Bundle/ChillMainBundle/Controller/ExportController.php b/src/Bundle/ChillMainBundle/Controller/ExportController.php index 686b4cbce..6c4ea0269 100644 --- a/src/Bundle/ChillMainBundle/Controller/ExportController.php +++ b/src/Bundle/ChillMainBundle/Controller/ExportController.php @@ -665,7 +665,7 @@ class ExportController extends AbstractController $this->logger->notice('[export] choices for an export unserialized', [ 'key' => $key, - 'rawData' => json_encode($rawData), + 'rawData' => json_encode($rawData, JSON_THROW_ON_ERROR), ]); return $rawData; diff --git a/src/Bundle/ChillMainBundle/Controller/SearchController.php b/src/Bundle/ChillMainBundle/Controller/SearchController.php index 8592dd2c3..7eec60324 100644 --- a/src/Bundle/ChillMainBundle/Controller/SearchController.php +++ b/src/Bundle/ChillMainBundle/Controller/SearchController.php @@ -109,10 +109,8 @@ class SearchController extends AbstractController ->getHasAdvancedFormSearchServices(); if (count($advancedSearchProviders) === 1) { - reset($advancedSearchProviders); - return $this->redirectToRoute('chill_main_advanced_search', [ - 'name' => key($advancedSearchProviders), + 'name' => array_key_first($advancedSearchProviders), ]); } diff --git a/src/Bundle/ChillMainBundle/Doctrine/Model/Point.php b/src/Bundle/ChillMainBundle/Doctrine/Model/Point.php index c4c18d179..684030ee3 100644 --- a/src/Bundle/ChillMainBundle/Doctrine/Model/Point.php +++ b/src/Bundle/ChillMainBundle/Doctrine/Model/Point.php @@ -41,7 +41,7 @@ class Point implements JsonSerializable public static function fromGeoJson(string $geojson): self { - $a = json_decode($geojson); + $a = json_decode($geojson, null, 512, JSON_THROW_ON_ERROR); if (null === $a) { throw PointException::badJsonString($geojson); @@ -96,7 +96,7 @@ class Point implements JsonSerializable { $array = $this->toArrayGeoJson(); - return json_encode($array); + return json_encode($array, JSON_THROW_ON_ERROR); } public function toWKT(): string diff --git a/src/Bundle/ChillMainBundle/Export/Helper/AggregateStringHelper.php b/src/Bundle/ChillMainBundle/Export/Helper/AggregateStringHelper.php index 6266ce86f..3ee5f20d8 100644 --- a/src/Bundle/ChillMainBundle/Export/Helper/AggregateStringHelper.php +++ b/src/Bundle/ChillMainBundle/Export/Helper/AggregateStringHelper.php @@ -29,7 +29,7 @@ class AggregateStringHelper return implode( '|', - json_decode($value, true) + json_decode($value, true, 512, JSON_THROW_ON_ERROR) ); }; } diff --git a/src/Bundle/ChillMainBundle/Export/Helper/ExportAddressHelper.php b/src/Bundle/ChillMainBundle/Export/Helper/ExportAddressHelper.php index 9077b501a..c9882f557 100644 --- a/src/Bundle/ChillMainBundle/Export/Helper/ExportAddressHelper.php +++ b/src/Bundle/ChillMainBundle/Export/Helper/ExportAddressHelper.php @@ -310,7 +310,7 @@ class ExportAddressHelper return ''; } - return $this->translatableStringHelper->localize(json_decode($value, true)); + return $this->translatableStringHelper->localize(json_decode($value, true, 512, JSON_THROW_ON_ERROR)); }; case 'isNoAddress': @@ -369,7 +369,7 @@ class ExportAddressHelper return ''; } - $decodedValues = json_decode($value, true); + $decodedValues = json_decode($value, true, 512, JSON_THROW_ON_ERROR); switch (count($decodedValues)) { case 0: diff --git a/src/Bundle/ChillMainBundle/Export/Helper/TranslatableStringExportLabelHelper.php b/src/Bundle/ChillMainBundle/Export/Helper/TranslatableStringExportLabelHelper.php index 44ce2b194..9b49d476b 100644 --- a/src/Bundle/ChillMainBundle/Export/Helper/TranslatableStringExportLabelHelper.php +++ b/src/Bundle/ChillMainBundle/Export/Helper/TranslatableStringExportLabelHelper.php @@ -39,7 +39,7 @@ class TranslatableStringExportLabelHelper return ''; } - return $this->translatableStringHelper->localize(json_decode($value, true)); + return $this->translatableStringHelper->localize(json_decode($value, true, 512, JSON_THROW_ON_ERROR)); }; } @@ -54,7 +54,7 @@ class TranslatableStringExportLabelHelper return ''; } - $decoded = json_decode($value, true); + $decoded = json_decode($value, true, 512, JSON_THROW_ON_ERROR); return implode( '|', diff --git a/src/Bundle/ChillMainBundle/Export/Helper/UserHelper.php b/src/Bundle/ChillMainBundle/Export/Helper/UserHelper.php index 0e770786d..2821bf1a6 100644 --- a/src/Bundle/ChillMainBundle/Export/Helper/UserHelper.php +++ b/src/Bundle/ChillMainBundle/Export/Helper/UserHelper.php @@ -54,7 +54,7 @@ class UserHelper return ''; } - $decoded = json_decode($value); + $decoded = json_decode($value, null, 512, JSON_THROW_ON_ERROR); if (0 === count($decoded)) { return ''; diff --git a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php index 46fa8799f..d4759a794 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php +++ b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php @@ -43,7 +43,7 @@ class EntityToJsonTransformer implements DataTransformerInterface public function reverseTransform($value) { - $denormalized = json_decode($value, true); + $denormalized = json_decode($value, true, 512, JSON_THROW_ON_ERROR); if ($this->multiple) { if (null === $denormalized) { diff --git a/src/Bundle/ChillMainBundle/Phonenumber/PhonenumberHelper.php b/src/Bundle/ChillMainBundle/Phonenumber/PhonenumberHelper.php index 9ee013b1a..a92db39ce 100644 --- a/src/Bundle/ChillMainBundle/Phonenumber/PhonenumberHelper.php +++ b/src/Bundle/ChillMainBundle/Phonenumber/PhonenumberHelper.php @@ -224,7 +224,7 @@ final class PhonenumberHelper implements PhoneNumberHelperInterface return null; } - $validation = json_decode($response->getBody()->getContents())->carrier->type; + $validation = json_decode($response->getBody()->getContents(), null, 512, JSON_THROW_ON_ERROR)->carrier->type; $item ->set($validation) diff --git a/src/Bundle/ChillMainBundle/Tests/Controller/PermissionApiControllerTest.php b/src/Bundle/ChillMainBundle/Tests/Controller/PermissionApiControllerTest.php index 59adb374a..2b89ec3db 100644 --- a/src/Bundle/ChillMainBundle/Tests/Controller/PermissionApiControllerTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Controller/PermissionApiControllerTest.php @@ -44,7 +44,7 @@ final class PermissionApiControllerTest extends WebTestCase $this->assertResponseIsSuccessful(); - $data = json_decode($client->getResponse()->getContent(), true); + $data = json_decode($client->getResponse()->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertFalse($data['roles']['FOO_ROLE']); } @@ -67,7 +67,7 @@ final class PermissionApiControllerTest extends WebTestCase $this->assertResponseIsSuccessful(); - $data = json_decode($client->getResponse()->getContent(), true); + $data = json_decode($client->getResponse()->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertTrue($data['roles']['ROLE_USER']); $this->assertFalse($data['roles']['ROLE_ADMIN']); } diff --git a/src/Bundle/ChillMainBundle/Tests/Controller/PostalCodeApiControllerTest.php b/src/Bundle/ChillMainBundle/Tests/Controller/PostalCodeApiControllerTest.php index 31bfab285..a777be44c 100644 --- a/src/Bundle/ChillMainBundle/Tests/Controller/PostalCodeApiControllerTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Controller/PostalCodeApiControllerTest.php @@ -35,7 +35,7 @@ final class PostalCodeApiControllerTest extends WebTestCase $this->assertResponseIsSuccessful(); - $data = json_decode($client->getResponse()->getContent(), true); + $data = json_decode($client->getResponse()->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertEquals('Fontenay Le Comte', $data['results'][0]['name']); diff --git a/src/Bundle/ChillMainBundle/Tests/Controller/UserApiControllerTest.php b/src/Bundle/ChillMainBundle/Tests/Controller/UserApiControllerTest.php index 57800c6cb..ef421020e 100644 --- a/src/Bundle/ChillMainBundle/Tests/Controller/UserApiControllerTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Controller/UserApiControllerTest.php @@ -47,7 +47,7 @@ final class UserApiControllerTest extends WebTestCase $this->assertResponseIsSuccessful(); - $data = json_decode($client->getResponse()->getContent(), true); + $data = json_decode($client->getResponse()->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertTrue(array_key_exists('count', $data)); $this->assertGreaterThan(0, $data['count']); $this->assertTrue(array_key_exists('results', $data)); diff --git a/src/Bundle/ChillMainBundle/Tests/Services/Import/GeographicalUnitBaseImporterTest.php b/src/Bundle/ChillMainBundle/Tests/Services/Import/GeographicalUnitBaseImporterTest.php index 33198c500..b3bd856ff 100644 --- a/src/Bundle/ChillMainBundle/Tests/Services/Import/GeographicalUnitBaseImporterTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Services/Import/GeographicalUnitBaseImporterTest.php @@ -64,7 +64,7 @@ final class GeographicalUnitBaseImporterTest extends KernelTestCase $this->assertEquals($results['unitrefid'], 'layer_one'); $this->assertEquals($results['unitname'], 'Layer one'); - $this->assertEquals(json_decode($results['layername'], true), ['fr' => 'Test Layer']); + $this->assertEquals(json_decode($results['layername'], true, 512, JSON_THROW_ON_ERROR), ['fr' => 'Test Layer']); $this->assertEquals($results['layerrefid'], 'test'); $this->assertEquals($results['geom'], 'MULTIPOLYGON(((30 20,45 40,10 40,30 20)),((15 5,40 10,10 20,5 10,15 5)))'); @@ -93,7 +93,7 @@ final class GeographicalUnitBaseImporterTest extends KernelTestCase $this->assertEquals($results['unitrefid'], 'layer_one'); $this->assertEquals($results['unitname'], 'Layer one fixed'); - $this->assertEquals(json_decode($results['layername'], true), ['fr' => 'Test Layer fixed']); + $this->assertEquals(json_decode($results['layername'], true, 512, JSON_THROW_ON_ERROR), ['fr' => 'Test Layer fixed']); $this->assertEquals($results['layerrefid'], 'test'); $this->assertEquals($results['geom'], 'MULTIPOLYGON(((130 120,45 40,10 40,130 120)),((0 0,15 5,40 10,10 20,0 0)))'); } diff --git a/src/Bundle/ChillMainBundle/migrations/Version20180709181423.php b/src/Bundle/ChillMainBundle/migrations/Version20180709181423.php index 5da4509bf..1c410970b 100644 --- a/src/Bundle/ChillMainBundle/migrations/Version20180709181423.php +++ b/src/Bundle/ChillMainBundle/migrations/Version20180709181423.php @@ -49,18 +49,18 @@ final class Version20180709181423 extends AbstractMigration $this->addSql('CREATE UNIQUE INDEX UNIQ_1483A5E9885281E ON users (emailCanonical)'); $this->addSql( - <<<'SQL' - CREATE OR REPLACE FUNCTION canonicalize_user_on_update() RETURNS TRIGGER AS - $BODY$ - BEGIN - IF NEW.username <> OLD.username OR NEW.email <> OLD.email OR OLD.emailcanonical IS NULL OR OLD.usernamecanonical IS NULL THEN - UPDATE users SET usernamecanonical=LOWER(UNACCENT(NEW.username)), emailcanonical=LOWER(UNACCENT(NEW.email)) WHERE id=NEW.id; - END IF; + <<<'SQL_WRAP' + CREATE OR REPLACE FUNCTION canonicalize_user_on_update() RETURNS TRIGGER AS + $BODY$ + BEGIN + IF NEW.username <> OLD.username OR NEW.email <> OLD.email OR OLD.emailcanonical IS NULL OR OLD.usernamecanonical IS NULL THEN + UPDATE users SET usernamecanonical=LOWER(UNACCENT(NEW.username)), emailcanonical=LOWER(UNACCENT(NEW.email)) WHERE id=NEW.id; + END IF; - RETURN NEW; - END; - $BODY$ LANGUAGE PLPGSQL - SQL + RETURN NEW; + END; + $BODY$ LANGUAGE PLPGSQL +SQL_WRAP ); $this->addSql( @@ -74,16 +74,16 @@ final class Version20180709181423 extends AbstractMigration ); $this->addSql( - <<<'SQL' - CREATE OR REPLACE FUNCTION canonicalize_user_on_insert() RETURNS TRIGGER AS - $BODY$ - BEGIN - UPDATE users SET usernamecanonical=LOWER(UNACCENT(NEW.username)), emailcanonical=LOWER(UNACCENT(NEW.email)) WHERE id=NEW.id; + <<<'SQL_WRAP' + CREATE OR REPLACE FUNCTION canonicalize_user_on_insert() RETURNS TRIGGER AS + $BODY$ + BEGIN + UPDATE users SET usernamecanonical=LOWER(UNACCENT(NEW.username)), emailcanonical=LOWER(UNACCENT(NEW.email)) WHERE id=NEW.id; - RETURN NEW; - END; - $BODY$ LANGUAGE PLPGSQL; - SQL + RETURN NEW; + END; + $BODY$ LANGUAGE PLPGSQL; +SQL_WRAP ); $this->addSql( diff --git a/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php b/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php index 5b2de9f65..bafc4b1cb 100644 --- a/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php +++ b/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php @@ -120,7 +120,7 @@ class ReassignAccompanyingPeriodController extends AbstractController $assignForm->handleRequest($request); if ($assignForm->isSubmitted() && $assignForm->isValid()) { - $assignPeriodIds = json_decode($assignForm->get('periods')->getData(), true); + $assignPeriodIds = json_decode($assignForm->get('periods')->getData(), true, 512, JSON_THROW_ON_ERROR); $userTo = $assignForm->get('userTo')->getData(); $userFrom = $assignForm->get('userFrom')->getData(); @@ -179,7 +179,7 @@ class ReassignAccompanyingPeriodController extends AbstractController { $defaultData = [ 'userFrom' => $userFrom, - 'periods' => json_encode($periodIds), + 'periods' => json_encode($periodIds, JSON_THROW_ON_ERROR), ]; $builder = $this->formFactory->createNamedBuilder('reassign', FormType::class, $defaultData); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php index 8c96906fc..cacdf2ee1 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php @@ -182,7 +182,7 @@ class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface return ''; } - return $this->translatableStringHelper->localize(json_decode($value, true)); + return $this->translatableStringHelper->localize(json_decode($value, true, 512, JSON_THROW_ON_ERROR)); }; case 'locationPersonName': @@ -226,7 +226,7 @@ class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface '|', array_map( fn ($s) => $this->translatableStringHelper->localize($s), - json_decode($value, true) + json_decode($value, true, 512, JSON_THROW_ON_ERROR) ) ); }; @@ -245,7 +245,7 @@ class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface '|', array_map( fn ($s) => $this->socialIssueRender->renderString($this->socialIssueRepository->find($s), []), - json_decode($value, true) + json_decode($value, true, 512, JSON_THROW_ON_ERROR) ) ); }; diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php b/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php index acaeb498c..21675a86a 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php @@ -334,7 +334,7 @@ class ListPerson implements ExportElementValidatedInterface, ListInterface, Grou return $this->customFieldProvider ->getCustomFieldByType($cf->getType()) - ->render(json_decode($value, true), $cf, 'csv'); + ->render(json_decode($value, true, 512, JSON_THROW_ON_ERROR), $cf, 'csv'); }; if ($cfType instanceof CustomFieldChoice && $cfType->isMultiple($cf)) { @@ -344,7 +344,7 @@ class ListPerson implements ExportElementValidatedInterface, ListInterface, Grou if (null === $value) { return ''; } - $decoded = json_decode($value, true); + $decoded = json_decode($value, true, 512, JSON_THROW_ON_ERROR); if ('_header' === $value) { $label = $cfType->getChoices($cf)[$slugChoice]; diff --git a/src/Bundle/ChillPersonBundle/Export/Helper/LabelPersonHelper.php b/src/Bundle/ChillPersonBundle/Export/Helper/LabelPersonHelper.php index 2cfc8d3cf..fc196dd50 100644 --- a/src/Bundle/ChillPersonBundle/Export/Helper/LabelPersonHelper.php +++ b/src/Bundle/ChillPersonBundle/Export/Helper/LabelPersonHelper.php @@ -39,7 +39,7 @@ class LabelPersonHelper return ''; } - $decoded = json_decode($value); + $decoded = json_decode($value, null, 512, JSON_THROW_ON_ERROR); if (0 === count($decoded)) { return ''; diff --git a/src/Bundle/ChillPersonBundle/Export/Helper/ListPersonHelper.php b/src/Bundle/ChillPersonBundle/Export/Helper/ListPersonHelper.php index de8870674..77a1d9c86 100644 --- a/src/Bundle/ChillPersonBundle/Export/Helper/ListPersonHelper.php +++ b/src/Bundle/ChillPersonBundle/Export/Helper/ListPersonHelper.php @@ -361,7 +361,7 @@ class ListPersonHelper return ''; } - $ids = json_decode($value); + $ids = json_decode($value, null, 512, JSON_THROW_ON_ERROR); return implode( diff --git a/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/AccompanyingPeriodConfidentialTest.php b/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/AccompanyingPeriodConfidentialTest.php index 1d1711ce4..dc5c5c2ce 100644 --- a/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/AccompanyingPeriodConfidentialTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/AccompanyingPeriodConfidentialTest.php @@ -110,7 +110,7 @@ final class AccompanyingPeriodConfidentialTest extends WebTestCase [], // parameters [], // files [], // server parameters - json_encode(['type' => 'accompanying_period', 'user' => $user]) + json_encode(['type' => 'accompanying_period', 'user' => $user], JSON_THROW_ON_ERROR) ); $response = $this->client->getResponse(); diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseApiControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseApiControllerTest.php index 154dbd884..596e0a870 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseApiControllerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseApiControllerTest.php @@ -313,10 +313,10 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase [], // parameters [], // files [], // server parameters - json_encode(['type' => 'person', 'id' => $personId]) + json_encode(['type' => 'person', 'id' => $personId], JSON_THROW_ON_ERROR) ); $response = $this->client->getResponse(); - $data = json_decode($response->getContent(), true); + $data = json_decode($response->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertTrue(in_array($response->getStatusCode(), [200, 422], true)); @@ -338,7 +338,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase } $response = $this->client->getResponse(); - $data = json_decode($response->getContent()); + $data = json_decode($response->getContent(), null, 512, JSON_THROW_ON_ERROR); // check that the person id is contained $participationsPersonsIds = array_map( @@ -357,10 +357,10 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase [], // parameters [], // files [], // server parameters - json_encode(['type' => 'person', 'id' => $personId]) + json_encode(['type' => 'person', 'id' => $personId], JSON_THROW_ON_ERROR) ); $response = $this->client->getResponse(); - $data = json_decode($response->getContent(), true); + $data = json_decode($response->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertTrue(in_array($response->getStatusCode(), [200, 422], true)); @@ -387,7 +387,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase [], [], [], - json_encode(['type' => 'social_issue', 'id' => $si->getId()]) + json_encode(['type' => 'social_issue', 'id' => $si->getId()], JSON_THROW_ON_ERROR) ); $this->assertTrue(in_array($this->client->getResponse()->getStatusCode(), [200, 422], true)); @@ -396,7 +396,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase $this->markTestSkipped('the next tests should appears only on valid accompanying period'); } - $data = json_decode($this->client->getResponse()->getContent(), true); + $data = json_decode($this->client->getResponse()->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertArrayHasKey('id', $data); $this->assertArrayHasKey('type', $data); $this->assertEquals('social_issue', $data['type']); @@ -407,7 +407,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase [], [], [], - json_encode(['type' => 'social_issue', 'id' => $si->getId()]) + json_encode(['type' => 'social_issue', 'id' => $si->getId()], JSON_THROW_ON_ERROR) ); $this->assertTrue(in_array($this->client->getResponse()->getStatusCode(), [200, 422], true)); @@ -427,7 +427,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase $this->markTestSkipped('the next tests should appears only on valid accompanying period'); } - $data = json_decode($response->getContent()); + $data = json_decode($response->getContent(), null, 512, JSON_THROW_ON_ERROR); $this->assertEquals( $data->id, $periodId, @@ -453,7 +453,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase [], // parameters [], // files [], // server parameters - json_encode(['type' => 'accompanying_period', 'emergency' => !$initialValueEmergency]) + json_encode(['type' => 'accompanying_period', 'emergency' => !$initialValueEmergency], JSON_THROW_ON_ERROR) ); $response = $this->client->getResponse(); @@ -492,7 +492,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase json_encode(['type' => 'accompanying_period_comment', 'content' => 'this is a text']) ); $response = $this->client->getResponse(); - $data = json_decode($response->getContent(), true); + $data = json_decode($response->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertTrue(in_array($response->getStatusCode(), [200, 422], true)); @@ -508,10 +508,10 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase [], // parameters [], // files [], // server parameters - json_encode(['type' => 'accompanying_period_comment', 'id' => $data['id']]) + json_encode(['type' => 'accompanying_period_comment', 'id' => $data['id']], JSON_THROW_ON_ERROR) ); $response = $this->client->getResponse(); - $data = json_decode($response->getContent(), true); + $data = json_decode($response->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertTrue(in_array($response->getStatusCode(), [200, 422], true)); } @@ -568,10 +568,10 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase [], // parameters [], // files [], // server parameters - json_encode(['type' => 'person', 'id' => $personId]) + json_encode(['type' => 'person', 'id' => $personId], JSON_THROW_ON_ERROR) ); $response = $this->client->getResponse(); - $data = json_decode($response->getContent(), true); + $data = json_decode($response->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertTrue(in_array($response->getStatusCode(), [200, 422], true)); @@ -595,10 +595,10 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase [], // parameters [], // files [], // server parameters - json_encode(['type' => 'thirdparty', 'id' => $thirdPartyId]) + json_encode(['type' => 'thirdparty', 'id' => $thirdPartyId], JSON_THROW_ON_ERROR) ); $response = $this->client->getResponse(); - $data = json_decode($response->getContent(), true); + $data = json_decode($response->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertTrue(in_array($response->getStatusCode(), [200, 422], true)); @@ -655,7 +655,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase json_encode(['type' => 'accompanying_period_resource', 'resource' => ['type' => 'person', 'id' => $personId]]) ); $response = $this->client->getResponse(); - $data = json_decode($response->getContent(), true); + $data = json_decode($response->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertTrue(in_array($response->getStatusCode(), [200, 422], true)); @@ -680,7 +680,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase [], [], [], //server - json_encode(['type' => 'accompanying_period_resource', 'id' => $resource->getId()]) + json_encode(['type' => 'accompanying_period_resource', 'id' => $resource->getId()], JSON_THROW_ON_ERROR) ); $response = $this->client->getResponse(); $this->assertTrue(in_array($response->getStatusCode(), [200, 422], true)); @@ -699,7 +699,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase json_encode(['type' => 'accompanying_period_resource', 'resource' => ['type' => 'thirdparty', 'id' => $thirdPartyId]]) ); $response = $this->client->getResponse(); - $data = json_decode($response->getContent(), true); + $data = json_decode($response->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertTrue(in_array($response->getStatusCode(), [200, 422], true)); @@ -724,7 +724,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase [], [], [], //server - json_encode(['type' => 'accompanying_period_resource', 'id' => $resource->getId()]) + json_encode(['type' => 'accompanying_period_resource', 'id' => $resource->getId()], JSON_THROW_ON_ERROR) ); $response = $this->client->getResponse(); $this->assertTrue(in_array($response->getStatusCode(), [200, 422], true)); diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdApiControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdApiControllerTest.php index 8686172ee..710c5fc6b 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdApiControllerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdApiControllerTest.php @@ -157,7 +157,7 @@ final class HouseholdApiControllerTest extends WebTestCase ); $this->assertResponseIsSuccessful(); - $data = json_decode($client->getResponse()->getContent(), true); + $data = json_decode($client->getResponse()->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertArrayHasKey('count', $data); $this->assertArrayHasKey('results', $data); diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdMemberControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdMemberControllerTest.php index 34c7e3113..56000c3e0 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdMemberControllerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdMemberControllerTest.php @@ -179,7 +179,7 @@ final class HouseholdMemberControllerTest extends WebTestCase $client->getResponse()->getStatusCode() ); - $data = json_decode($client->getResponse()->getContent(), true); + $data = json_decode($client->getResponse()->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertEquals(null, $data); } @@ -284,7 +284,7 @@ final class HouseholdMemberControllerTest extends WebTestCase $client->getResponse()->getStatusCode() ); - $data = json_decode($client->getResponse()->getContent(), true); + $data = json_decode($client->getResponse()->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertIsArray($data); $this->assertArrayHasKey('members', $data); diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonApiControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonApiControllerTest.php index f5a886fa6..0de312d84 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonApiControllerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonApiControllerTest.php @@ -112,7 +112,7 @@ final class PersonApiControllerTest extends WebTestCase $this->assertResponseIsSuccessful(); - $data = json_decode($client->getResponse()->getContent(), true); + $data = json_decode($client->getResponse()->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertArrayHasKey('type', $data); $this->assertArrayHasKey('id', $data); diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/RelationshipApiControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/RelationshipApiControllerTest.php index 67b45acd5..d6fb7a8da 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/RelationshipApiControllerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/RelationshipApiControllerTest.php @@ -136,7 +136,7 @@ final class RelationshipApiControllerTest extends WebTestCase 'toPerson' => ['id' => $toPersonId, 'type' => 'person'], 'relation' => ['id' => $relationId, 'type' => 'relation'], 'reverse' => $isReverse, - ]) + ], JSON_THROW_ON_ERROR) ); $response = $this->client->getResponse(); diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/SocialIssueApiControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/SocialIssueApiControllerTest.php index a0dcae59a..ba19fc56e 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/SocialIssueApiControllerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/SocialIssueApiControllerTest.php @@ -47,7 +47,7 @@ final class SocialIssueApiControllerTest extends WebTestCase $this->assertEquals(200, $client->getResponse()->getStatusCode()); - $data = json_decode($client->getResponse()->getContent(), true); + $data = json_decode($client->getResponse()->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertArrayHasKey('id', $data); $this->assertArrayHasKey('type', $data); @@ -60,7 +60,7 @@ final class SocialIssueApiControllerTest extends WebTestCase $this->assertEquals(200, $client->getResponse()->getStatusCode()); - $data = json_decode($client->getResponse()->getContent(), true); + $data = json_decode($client->getResponse()->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertGreaterThan(0, $data['count']); $this->assertGreaterThan(0, count($data['results'])); diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/SocialWorkEvaluationApiControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/SocialWorkEvaluationApiControllerTest.php index aa98fdcd3..9ed62e4b3 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/SocialWorkEvaluationApiControllerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/SocialWorkEvaluationApiControllerTest.php @@ -77,7 +77,7 @@ final class SocialWorkEvaluationApiControllerTest extends WebTestCase $this->assertResponseIsSuccessful(); - $content = json_decode($client->getResponse()->getContent(), true); + $content = json_decode($client->getResponse()->getContent(), true, 512, JSON_THROW_ON_ERROR); $ids = array_map(static fn (array $item) => $item['id'], $content['results']); diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20160818113633.php b/src/Bundle/ChillPersonBundle/migrations/Version20160818113633.php index 0e06fccab..6b11a1d63 100644 --- a/src/Bundle/ChillPersonBundle/migrations/Version20160818113633.php +++ b/src/Bundle/ChillPersonBundle/migrations/Version20160818113633.php @@ -45,7 +45,7 @@ class Version20160818113633 extends AbstractMigration foreach ($personIdAndCFData as $person) { $personId = $person['id']; $cFDataArray = unserialize($person['cfdata']); - $cFDataJson = json_encode($cFDataArray); + $cFDataJson = json_encode($cFDataArray, JSON_THROW_ON_ERROR); $this->addSql( 'UPDATE person set cfdata = :cfdatajson WHERE id = :id', ['cfdatajson' => $cFDataJson, 'id' => $personId] diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20181023101621.php b/src/Bundle/ChillPersonBundle/migrations/Version20181023101621.php index 4f7765000..d3adb3401 100644 --- a/src/Bundle/ChillPersonBundle/migrations/Version20181023101621.php +++ b/src/Bundle/ChillPersonBundle/migrations/Version20181023101621.php @@ -40,20 +40,20 @@ final class Version20181023101621 extends AbstractMigration $this->addSql('CREATE INDEX fullnameCanonical_trgm_idx ON chill_person_person USING GIN (fullnameCanonical gin_trgm_ops)'); $this->addSql( - <<<'SQL' - CREATE OR REPLACE FUNCTION canonicalize_fullname_on_update() RETURNS TRIGGER AS - $BODY$ - BEGIN - IF NEW.firstname <> OLD.firstname OR NEW.lastname <> OLD.lastname - THEN - UPDATE chill_person_person - SET fullnameCanonical=LOWER(UNACCENT(CONCAT(NEW.firstname, ' ', NEW.lastname))) - WHERE id=NEW.id; - END IF; - RETURN NEW; - END; - $BODY$ LANGUAGE PLPGSQL; - SQL + <<<'SQL_WRAP' + CREATE OR REPLACE FUNCTION canonicalize_fullname_on_update() RETURNS TRIGGER AS + $BODY$ + BEGIN + IF NEW.firstname <> OLD.firstname OR NEW.lastname <> OLD.lastname + THEN + UPDATE chill_person_person + SET fullnameCanonical=LOWER(UNACCENT(CONCAT(NEW.firstname, ' ', NEW.lastname))) + WHERE id=NEW.id; + END IF; + RETURN NEW; + END; + $BODY$ LANGUAGE PLPGSQL; +SQL_WRAP ); $this->addSql( <<<'SQL' @@ -67,17 +67,17 @@ final class Version20181023101621 extends AbstractMigration ); $this->addSql( - <<<'SQL' - CREATE OR REPLACE FUNCTION canonicalize_fullname_on_insert() RETURNS TRIGGER AS - $BODY$ - BEGIN - UPDATE chill_person_person - SET fullnameCanonical=LOWER(UNACCENT(CONCAT(NEW.firstname, ' ', NEW.lastname))) - WHERE id=NEW.id; - RETURN NEW; - END; - $BODY$ LANGUAGE PLPGSQL; - SQL + <<<'SQL_WRAP' + CREATE OR REPLACE FUNCTION canonicalize_fullname_on_insert() RETURNS TRIGGER AS + $BODY$ + BEGIN + UPDATE chill_person_person + SET fullnameCanonical=LOWER(UNACCENT(CONCAT(NEW.firstname, ' ', NEW.lastname))) + WHERE id=NEW.id; + RETURN NEW; + END; + $BODY$ LANGUAGE PLPGSQL; +SQL_WRAP ); $this->addSql( <<<'SQL' diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20200130213446.php b/src/Bundle/ChillPersonBundle/migrations/Version20200130213446.php index 947d26357..7d48b5f53 100644 --- a/src/Bundle/ChillPersonBundle/migrations/Version20200130213446.php +++ b/src/Bundle/ChillPersonBundle/migrations/Version20200130213446.php @@ -130,20 +130,20 @@ final class Version20200130213446 extends AbstractMigration $this->addSql('DROP TRIGGER canonicalize_fullname_on_alt_name_delete ON chill_person_alt_name;'); $this->addSql('DROP FUNCTION canonicalize_fullname_on_alt_name_alter();'); $this->addSql( - <<<'SQL' - CREATE OR REPLACE FUNCTION canonicalize_fullname_on_update() RETURNS TRIGGER AS - $BODY$ - BEGIN - IF NEW.firstname <> OLD.firstname OR NEW.lastname <> OLD.lastname - THEN - UPDATE chill_person_person - SET fullnameCanonical=LOWER(UNACCENT(CONCAT(NEW.firstname, ' ', NEW.lastname))) - WHERE id=NEW.id; - END IF; - RETURN NEW; - END; - $BODY$ LANGUAGE PLPGSQL; - SQL + <<<'SQL_WRAP' + CREATE OR REPLACE FUNCTION canonicalize_fullname_on_update() RETURNS TRIGGER AS + $BODY$ + BEGIN + IF NEW.firstname <> OLD.firstname OR NEW.lastname <> OLD.lastname + THEN + UPDATE chill_person_person + SET fullnameCanonical=LOWER(UNACCENT(CONCAT(NEW.firstname, ' ', NEW.lastname))) + WHERE id=NEW.id; + END IF; + RETURN NEW; + END; + $BODY$ LANGUAGE PLPGSQL; +SQL_WRAP ); } diff --git a/src/Bundle/ChillReportBundle/Export/Export/ReportList.php b/src/Bundle/ChillReportBundle/Export/Export/ReportList.php index 21606d807..16ae19daa 100644 --- a/src/Bundle/ChillReportBundle/Export/Export/ReportList.php +++ b/src/Bundle/ChillReportBundle/Export/Export/ReportList.php @@ -276,7 +276,7 @@ class ReportList implements ExportElementValidatedInterface, ListInterface return ''; } - return $this->translatableStringHelper->localize(json_decode($value, true)); + return $this->translatableStringHelper->localize(json_decode($value, true, 512, JSON_THROW_ON_ERROR)); }; default: @@ -526,13 +526,13 @@ class ReportList implements ExportElementValidatedInterface, ListInterface return $this->customFieldProvider ->getCustomFieldByType($cf->getType()) - ->render(json_decode($value, true), $cf, 'csv'); + ->render(json_decode($value, true, 512, JSON_THROW_ON_ERROR), $cf, 'csv'); }; if ($cfType instanceof CustomFieldChoice && $cfType->isMultiple($cf)) { return function ($value) use ($cf, $cfType, $key) { $slugChoice = $this->extractInfosFromSlug($key)['additionnalInfos']['choiceSlug']; - $decoded = json_decode($value, true); + $decoded = json_decode($value, true, 512, JSON_THROW_ON_ERROR); if ('_header' === $value) { $label = $cfType->getChoices($cf)[$slugChoice]; diff --git a/src/Bundle/ChillThirdPartyBundle/Export/Helper/LabelThirdPartyHelper.php b/src/Bundle/ChillThirdPartyBundle/Export/Helper/LabelThirdPartyHelper.php index f87fe41b4..2e7a20840 100644 --- a/src/Bundle/ChillThirdPartyBundle/Export/Helper/LabelThirdPartyHelper.php +++ b/src/Bundle/ChillThirdPartyBundle/Export/Helper/LabelThirdPartyHelper.php @@ -54,7 +54,7 @@ class LabelThirdPartyHelper return ''; } - $decoded = json_decode($value); + $decoded = json_decode($value, null, 512, JSON_THROW_ON_ERROR); if (0 === count($decoded)) { return ''; From 087ada22504e08914a21947270e8e1316277ee62 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Thu, 30 Mar 2023 00:07:38 +0200 Subject: [PATCH 008/724] UX: Better use of flex-table and tables in budget twig templates --- .../Resources/views/Budget/_budget.html.twig | 20 ++++++------------- .../views/Budget/_current_budget.html.twig | 15 +++----------- .../Resources/views/Budget/_macros.html.twig | 8 +++----- .../Resources/views/Person/index.html.twig | 10 ++++------ 4 files changed, 16 insertions(+), 37 deletions(-) diff --git a/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_budget.html.twig b/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_budget.html.twig index 6e248bf0c..e11a822cd 100644 --- a/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_budget.html.twig +++ b/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_budget.html.twig @@ -32,28 +32,21 @@ {% endif %} {% endfor %} -

    {{ 'Actual budget'|trans }}

    - {% if actualCharges|length > 0 or actualResources|length > 0 %} - {% include 'ChillBudgetBundle:Budget:_current_budget.html.twig' with { + {% include '@ChillBudget/Budget/_current_budget.html.twig' with { 'actualResources': actualResources, 'actualCharges': actualCharges, 'results': results, 'entity': entity } %} {% else %} -
    -
    -

    {{ "There isn't any element recorded"|trans }}

    -
    -
    +

    {{ "There isn't any element recorded"|trans }}

    {% endif %} {% if pastCharges|length > 0 or pastResources|length > 0 %} -

    {{ 'Past budget'|trans }}

    - - {% include 'ChillBudgetBundle:Budget:_past_budget.html.twig' with { +

    {{ 'Past budget'|trans }}

    a + {% include '@ChillBudget/Budget/_past_budget.html.twig' with { 'pastCharges': pastCharges, 'pastResources': pastResources, 'entity': entity @@ -61,9 +54,8 @@ {% endif %} {% if futureCharges|length > 0 or futureResources|length > 0 %} -

    {{ 'Future budget'|trans }}

    - - {% include 'ChillBudgetBundle:Budget:_future_budget.html.twig' with { +

    {{ 'Future budget'|trans }}

    + {% include '@ChillBudget/Budget/_future_budget.html.twig' with { 'futureResources': futureResources, 'futureCharges': futureCharges, 'entity': entity diff --git a/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_current_budget.html.twig b/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_current_budget.html.twig index b996da211..98e784cc5 100644 --- a/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_current_budget.html.twig +++ b/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_current_budget.html.twig @@ -1,30 +1,21 @@ -{% from 'ChillBudgetBundle:Budget:_macros.html.twig' import table_elements, table_results %} +{% from '@ChillBudget/Budget/_macros.html.twig' import table_elements, table_results %} {#

    {{ 'Actual budget'|trans }}

    #} -
    +

    {{ 'Actual resources'|trans }}

    - {% if actualResources|length > 0 %} -
    {{ table_elements(actualResources, 'resource') }} -
    {% else %} -
    {{ 'No resources registered'|trans }} -
    {% endif %}
    -
    +

    {{ 'Actual charges'|trans }}

    {% if actualCharges|length > 0 %} -
    {{ table_elements(actualCharges, 'charge') }} -
    {% else %} -
    {{ 'No charges registered'|trans }} -
    {% endif %}
    diff --git a/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_macros.html.twig b/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_macros.html.twig index e8d10578b..42090984a 100644 --- a/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_macros.html.twig +++ b/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_macros.html.twig @@ -1,5 +1,5 @@ {% macro table_elements(elements, family) %} -
  • {{ d.title }} {{ mm.mimeIcon(d.storedObject.type) }} - - + + {{ d.storedObject|chill_document_button_group(d.title, is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_UPDATE', w), {'small': true}) }}
    +
    @@ -28,7 +28,7 @@ {% if f.endDate is not null %} {{ f.startDate|format_date('short') ~ ' - ' ~ f.endDate|format_date('short') }} {% else %} - {{ f.startDate|format_date('short') ~ ' - ...' }} + {{ 'depuis le ' ~ f.startDate|format_date('short') }} {% endif %} - - - + - From 4ab4554e631a162e5018cb1623fe4355fff0f1ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 3 May 2023 22:30:20 +0200 Subject: [PATCH 061/724] DX: embed test app inside bundle --- .env.test | 35 +++++++++++ .gitmodules | 3 - composer.json | 6 +- phpunit.xml.dist | 4 +- .../Tests/Form/CalendarTypeTest.php | 4 +- .../DataFixtures/ORM/LoadRelationships.php | 1 + .../DataFixtures/ORM/LoadReports.php | 4 ++ tests/Kernel.php | 55 ++++++++++++++++++ tests/app | 1 - tests/app/config/bootstrap.php | 23 ++++++++ tests/app/config/bundles.php | 39 +++++++++++++ tests/app/config/packages/assets.yaml | 3 + tests/app/config/packages/cache.yaml | 33 +++++++++++ tests/app/config/packages/champs-libres.yaml | 14 +++++ tests/app/config/packages/chill.yaml | 23 ++++++++ tests/app/config/packages/chill_budget.yaml | 14 +++++ tests/app/config/packages/dev/debug.yaml | 4 ++ tests/app/config/packages/dev/monolog.yaml | 21 +++++++ tests/app/config/packages/doctrine.yaml | 18 ++++++ .../config/packages/doctrine_migrations.yaml | 30 ++++++++++ tests/app/config/packages/framework.yaml | 30 ++++++++++ .../packages/lexik_jwt_authentication.yaml | 12 ++++ tests/app/config/packages/loophp_psr17.yaml | 8 +++ tests/app/config/packages/nyholm_psr7.yaml | 21 +++++++ .../config/packages/prod/deprecations.yaml | 8 +++ tests/app/config/packages/prod/doctrine.yaml | 20 +++++++ tests/app/config/packages/prod/monolog.yaml | 14 +++++ tests/app/config/packages/prod/routing.yaml | 3 + .../config/packages/prod/webpack_encore.yaml | 4 ++ .../config/packages/ramsey_uuid_doctrine.yaml | 4 ++ tests/app/config/packages/routing.yaml | 7 +++ tests/app/config/packages/security.yaml | 58 +++++++++++++++++++ .../packages/sensio_framework_extra.yaml | 3 + tests/app/config/packages/test/chill.yaml | 5 ++ tests/app/config/packages/test/framework.yaml | 6 ++ tests/app/config/packages/test/mailer.yaml | 5 ++ tests/app/config/packages/test/monolog.yaml | 12 ++++ tests/app/config/packages/test/security.yaml | 8 +++ tests/app/config/packages/test/twig.yaml | 2 + tests/app/config/packages/test/validator.yaml | 3 + .../config/packages/test/webpack_encore.yaml | 2 + tests/app/config/packages/translation.yaml | 7 +++ tests/app/config/packages/twig.yaml | 17 ++++++ tests/app/config/packages/validator.yaml | 8 +++ tests/app/config/packages/webpack_encore.yaml | 33 +++++++++++ tests/app/config/packages/workflow.yaml | 2 + tests/app/config/preload.php | 9 +++ tests/app/config/routes.yaml | 8 +++ tests/app/config/routes/annotations.yaml | 3 + tests/app/config/routes/dev/framework.yaml | 3 + tests/app/config/routes/dev/web_profiler.yaml | 7 +++ tests/app/config/services.yaml | 15 +++++ tests/bootstrap.php | 11 ++++ tests/console | 42 ++++++++++++++ 54 files changed, 723 insertions(+), 12 deletions(-) create mode 100644 tests/Kernel.php delete mode 160000 tests/app create mode 100644 tests/app/config/bootstrap.php create mode 100644 tests/app/config/bundles.php create mode 100644 tests/app/config/packages/assets.yaml create mode 100644 tests/app/config/packages/cache.yaml create mode 100644 tests/app/config/packages/champs-libres.yaml create mode 100644 tests/app/config/packages/chill.yaml create mode 100644 tests/app/config/packages/chill_budget.yaml create mode 100644 tests/app/config/packages/dev/debug.yaml create mode 100644 tests/app/config/packages/dev/monolog.yaml create mode 100644 tests/app/config/packages/doctrine.yaml create mode 100644 tests/app/config/packages/doctrine_migrations.yaml create mode 100644 tests/app/config/packages/framework.yaml create mode 100644 tests/app/config/packages/lexik_jwt_authentication.yaml create mode 100644 tests/app/config/packages/loophp_psr17.yaml create mode 100644 tests/app/config/packages/nyholm_psr7.yaml create mode 100644 tests/app/config/packages/prod/deprecations.yaml create mode 100644 tests/app/config/packages/prod/doctrine.yaml create mode 100644 tests/app/config/packages/prod/monolog.yaml create mode 100644 tests/app/config/packages/prod/routing.yaml create mode 100644 tests/app/config/packages/prod/webpack_encore.yaml create mode 100644 tests/app/config/packages/ramsey_uuid_doctrine.yaml create mode 100644 tests/app/config/packages/routing.yaml create mode 100644 tests/app/config/packages/security.yaml create mode 100644 tests/app/config/packages/sensio_framework_extra.yaml create mode 100644 tests/app/config/packages/test/chill.yaml create mode 100644 tests/app/config/packages/test/framework.yaml create mode 100644 tests/app/config/packages/test/mailer.yaml create mode 100644 tests/app/config/packages/test/monolog.yaml create mode 100644 tests/app/config/packages/test/security.yaml create mode 100644 tests/app/config/packages/test/twig.yaml create mode 100644 tests/app/config/packages/test/validator.yaml create mode 100644 tests/app/config/packages/test/webpack_encore.yaml create mode 100644 tests/app/config/packages/translation.yaml create mode 100644 tests/app/config/packages/twig.yaml create mode 100644 tests/app/config/packages/validator.yaml create mode 100644 tests/app/config/packages/webpack_encore.yaml create mode 100644 tests/app/config/packages/workflow.yaml create mode 100644 tests/app/config/preload.php create mode 100644 tests/app/config/routes.yaml create mode 100644 tests/app/config/routes/annotations.yaml create mode 100644 tests/app/config/routes/dev/framework.yaml create mode 100644 tests/app/config/routes/dev/web_profiler.yaml create mode 100644 tests/app/config/services.yaml create mode 100644 tests/bootstrap.php create mode 100755 tests/console diff --git a/.env.test b/.env.test index 914deb541..d431ad16c 100644 --- a/.env.test +++ b/.env.test @@ -3,3 +3,38 @@ # Run tests from root to adapt your own environment KERNEL_CLASS='App\Kernel' APP_SECRET='$ecretf0rt3st' + +ADMIN_PASSWORD=admin + +LOCALE=fr +REDIS_URL=redis +REDIS_PORT=6379 +REDIS_URL=redis://${REDIS_HOST}:${REDIS_PORT} + +JWT_SECRET_KEY=%kernel.project_dir%/config/jwt/private.pem +JWT_PUBLIC_KEY=%kernel.project_dir%/config/jwt/public.pem +JWT_PASSPHRASE=2a30f6ba26521a2613821da35f28386e + +TWILIO_SID=~ +TWILIO_SECRET=~ +DEFAULT_CARRIER_CODE=BE + +ADD_ADDRESS_DEFAULT_COUNTRY=BE + +ADD_ADDRESS_MAP_CENTER_X=50.8443 +ADD_ADDRESS_MAP_CENTER_Y=4.3523 +ADD_ADDRESS_MAP_CENTER_Z=15 + +SHORT_MESSAGE_DSN=null://null +MESSENGER_TRANSPORT_DSN=sync:// +###< symfony/messenger ### + +###> doctrine/doctrine-bundle ### +# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url +# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml +# +DATABASE_URL="postgresql://postgres:postgres@db:5432/test?serverVersion=14&charset=utf8" + +ASYNC_UPLOAD_TEMP_URL_KEY= +ASYNC_UPLOAD_TEMP_URL_BASE_PATH= +ASYNC_UPLOAD_TEMP_URL_CONTAINER= diff --git a/.gitmodules b/.gitmodules index 560ba7980..7bc519c88 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ [submodule "_exts/sphinx-php"] path = _exts/sphinx-php url = https://github.com/fabpot/sphinx-php.git -[submodule "tests/app"] - path = tests/app - url = https://gitlab.com/Chill-projet/chill-app.git diff --git a/composer.json b/composer.json index b47856954..c5cd9c982 100644 --- a/composer.json +++ b/composer.json @@ -107,7 +107,7 @@ }, "autoload-dev": { "psr-4": { - "App\\": "tests/app/src/", + "App\\": "tests/", "Chill\\DocGeneratorBundle\\Tests\\": "src/Bundle/ChillDocGeneratorBundle/tests", "Chill\\WopiBundle\\Tests\\": "src/Bundle/ChillDocGeneratorBundle/tests" } @@ -123,12 +123,10 @@ }, "bin-dir": "bin", "optimize-autoloader": true, - "sort-packages": true, - "vendor-dir": "tests/app/vendor" + "sort-packages": true }, "scripts": { "auto-scripts": { - "assets:install %PUBLIC_DIR%": "symfony-cmd", "cache:clear": "symfony-cmd" } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 8f157fcc5..996eae432 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -2,10 +2,10 @@ diff --git a/src/Bundle/ChillCalendarBundle/Tests/Form/CalendarTypeTest.php b/src/Bundle/ChillCalendarBundle/Tests/Form/CalendarTypeTest.php index f9392ba57..5adce17b2 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Form/CalendarTypeTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Form/CalendarTypeTest.php @@ -97,9 +97,9 @@ final class CalendarTypeTest extends TypeTestCase $calendar = new Calendar(); $calendar->setMainUser(new class () extends User { - public function getId() + public function getId(): ?int { - return '1'; + return 1; } }); diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelationships.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelationships.php index 151ecf0c2..7024e732b 100644 --- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelationships.php +++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelationships.php @@ -42,6 +42,7 @@ class LoadRelationships extends Fixture implements DependentFixtureInterface public function load(ObjectManager $manager): void { + return; $existing = []; for ($i = 0; 20 > $i; ++$i) { diff --git a/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReports.php b/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReports.php index 2dcf69c50..565266a5e 100644 --- a/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReports.php +++ b/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReports.php @@ -198,6 +198,8 @@ class LoadReports extends AbstractFixture implements ContainerAwareInterface, Or return $result; } + + return $picked; } else { $picked = $this->pickChoice($choices); @@ -210,6 +212,8 @@ class LoadReports extends AbstractFixture implements ContainerAwareInterface, Or return $result; } + + return $picked; } throw new \LogicException("should not happens"); diff --git a/tests/Kernel.php b/tests/Kernel.php new file mode 100644 index 000000000..5047bfa32 --- /dev/null +++ b/tests/Kernel.php @@ -0,0 +1,55 @@ + $envs) { + if ($envs[$this->environment] ?? $envs['all'] ?? false) { + yield new $class(); + } + } + } + + public function getProjectDir() + { + return \dirname(__DIR__); + } + + protected function configureRoutes(RouteCollectionBuilder $routes) + { + $confDir = $this->getProjectDir().'/tests/app/config'; + + $routes->import($confDir.'/{routes}/'.$this->environment.'/*'.self::CONFIG_EXTS, '/', 'glob'); + $routes->import($confDir.'/{routes}/*'.self::CONFIG_EXTS, '/', 'glob'); + $routes->import($confDir.'/{routes}'.self::CONFIG_EXTS, '/', 'glob'); + } + + protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader) + { + $container->addResource(new FileResource($this->getProjectDir().'/tests/app/config/bundles.php')); + $container->setParameter('container.dumper.inline_class_loader', \PHP_VERSION_ID < 70400 || $this->debug); + $container->setParameter('container.dumper.inline_factories', true); + $confDir = $this->getProjectDir().'/tests/app/config'; + + $loader->load($confDir.'/{packages}/*'.self::CONFIG_EXTS, 'glob'); + $loader->load($confDir.'/{packages}/'.$this->environment.'/*'.self::CONFIG_EXTS, 'glob'); + $loader->load($confDir.'/{services}'.self::CONFIG_EXTS, 'glob'); + $loader->load($confDir.'/{services}_'.$this->environment.self::CONFIG_EXTS, 'glob'); + } +} diff --git a/tests/app b/tests/app deleted file mode 160000 index 5e478fdfb..000000000 --- a/tests/app +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 5e478fdfbf429baf3ce852ae69eb1f7101b1b416 diff --git a/tests/app/config/bootstrap.php b/tests/app/config/bootstrap.php new file mode 100644 index 000000000..10c196e4e --- /dev/null +++ b/tests/app/config/bootstrap.php @@ -0,0 +1,23 @@ +=1.2) +if (is_array($env = @include dirname(__DIR__).'/.env.local.php') && (!isset($env['APP_ENV']) || ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? $env['APP_ENV']) === $env['APP_ENV'])) { + (new Dotenv(false))->populate($env); +} else { + // load all the .env files + (new Dotenv(false))->loadEnv(dirname(__DIR__).'/../../.env.test'); +} + +$_SERVER += $_ENV; +$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) ?: 'dev'; +$_SERVER['APP_DEBUG'] = $_SERVER['APP_DEBUG'] ?? $_ENV['APP_DEBUG'] ?? 'prod' !== $_SERVER['APP_ENV']; +$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = (int) $_SERVER['APP_DEBUG'] || filter_var($_SERVER['APP_DEBUG'], FILTER_VALIDATE_BOOLEAN) ? '1' : '0'; diff --git a/tests/app/config/bundles.php b/tests/app/config/bundles.php new file mode 100644 index 000000000..970afaa99 --- /dev/null +++ b/tests/app/config/bundles.php @@ -0,0 +1,39 @@ + ['all' => true], + Chill\ActivityBundle\ChillActivityBundle::class => ['all' => true], + Chill\AsideActivityBundle\ChillAsideActivityBundle::class => ['all' => true], + Chill\CalendarBundle\ChillCalendarBundle::class => ['all' => true], + Chill\CustomFieldsBundle\ChillCustomFieldsBundle::class => ['all' => true], + Chill\DocGeneratorBundle\ChillDocGeneratorBundle::class => ['all' => true], + Chill\DocStoreBundle\ChillDocStoreBundle::class => ['all' => true], + Chill\EventBundle\ChillEventBundle::class => ['all' => true], + Chill\MainBundle\ChillMainBundle::class => ['all' => true], + Chill\PersonBundle\ChillPersonBundle::class => ['all' => true], + Chill\ReportBundle\ChillReportBundle::class => ['all' => true], + Chill\TaskBundle\ChillTaskBundle::class => ['all' => true], + Chill\ThirdPartyBundle\ChillThirdPartyBundle::class => ['all' => true], + Chill\BudgetBundle\ChillBudgetBundle::class => ['all' => true], + Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true], + Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['dev' => true, 'test' => true], + Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true], + Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true], + Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true, 'test' => true], + Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true], + Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true], + Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true], + Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true], + Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true], + //Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true], + Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true], + Knp\Bundle\MenuBundle\KnpMenuBundle::class => ['all' => true], + Knp\Bundle\TimeBundle\KnpTimeBundle::class => ['all' => true], + Twig\Extra\TwigExtraBundle\TwigExtraBundle::class => ['all' => true], + loophp\PsrHttpMessageBridgeBundle\PsrHttpMessageBridgeBundle::class => ['all' => true], + \Misd\PhoneNumberBundle\MisdPhoneNumberBundle::class => ['all' => true], + ChampsLibres\WopiBundle\WopiBundle::class => ['all' => true], + Chill\WopiBundle\ChillWopiBundle::class => ['all' => true], + \Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle::class => ['all' => true], + +]; diff --git a/tests/app/config/packages/assets.yaml b/tests/app/config/packages/assets.yaml new file mode 100644 index 000000000..051d36dce --- /dev/null +++ b/tests/app/config/packages/assets.yaml @@ -0,0 +1,3 @@ +framework: + assets: + json_manifest_path: '%kernel.project_dir%/public/build/manifest.json' diff --git a/tests/app/config/packages/cache.yaml b/tests/app/config/packages/cache.yaml new file mode 100644 index 000000000..c7a5f169d --- /dev/null +++ b/tests/app/config/packages/cache.yaml @@ -0,0 +1,33 @@ +framework: + cache: + # Unique name of your app: used to compute stable namespaces for cache keys. + #prefix_seed: your_vendor_name/app_name + + # The "app" cache stores to the filesystem by default. + # The data in this cache should persist between deploys. + # Other options include: + + # Redis + #app: cache.adapter.redis + #default_redis_provider: redis://localhost + + # APCu (not recommended with heavy random-write workloads as memory fragmentation can cause perf issues) + #app: cache.adapter.apcu + + # Namespaced pools use the above "app" backend by default + #pools: + #my.dedicated.cache: null + + default_redis_provider: '%env(resolve:REDIS_URL)%' + + pools: + cache.user_data: + adapter: cache.adapter.redis + public: true + default_lifetime: 300 # 5 minutes + + # will be used in chill_main.tag_aware_cache service + cache.tags: + adapter: cache.adapter.redis + public: false + default_lifetime: 300 diff --git a/tests/app/config/packages/champs-libres.yaml b/tests/app/config/packages/champs-libres.yaml new file mode 100644 index 000000000..ebea3ef58 --- /dev/null +++ b/tests/app/config/packages/champs-libres.yaml @@ -0,0 +1,14 @@ +champs_libres_async_uploader: + openstack: + os_username: '%env(resolve:OS_USERNAME)%' # Required + os_password: '%env(resolve:OS_PASSWORD)%' # Required + os_tenant_id: '%env(resolve:OS_TENANT_ID)%' # Required + os_region_name: '%env(resolve:OS_REGION_NAME)%' # Required + os_auth_url: '%env(resolve:OS_AUTH_URL)%' # Required + temp_url: + temp_url_key: '%env(resolve:ASYNC_UPLOAD_TEMP_URL_KEY)%' # Required + container: '%env(resolve:ASYNC_UPLOAD_TEMP_URL_CONTAINER)%' # Required + temp_url_base_path: '%env(resolve:ASYNC_UPLOAD_TEMP_URL_BASE_PATH)%' # Required. Do not forget a trailing slash + max_post_file_size: 15000000 # 15Mo (bytes) + max_expires_delay: 180 + max_submit_delay: 3600 diff --git a/tests/app/config/packages/chill.yaml b/tests/app/config/packages/chill.yaml new file mode 100644 index 000000000..92dbd0769 --- /dev/null +++ b/tests/app/config/packages/chill.yaml @@ -0,0 +1,23 @@ +chill_main: + available_languages: [ '%env(resolve:LOCALE)%' ] + notifications: + from_email: 'test@yopmail.com' + from_name: 'TEST CHILL' + host: 'localhost' + redis: + host: '%env(resolve:REDIS_HOST)%' + port: '%env(resolve:REDIS_PORT)%' + phone_helper: + twilio_sid: '%env(resolve:TWILIO_SID)%' + twilio_secret: '%env(resolve:TWILIO_SECRET)%' + default_carrier_code: '%env(resolve:DEFAULT_CARRIER_CODE)%' + +chill_custom_fields: + show_empty_values_in_views: false + +# Enable/disable specific libraries (css and js) +twig: + globals: + active_bootstrap: false + active_forkawesome: true + active_ckeditor: false diff --git a/tests/app/config/packages/chill_budget.yaml b/tests/app/config/packages/chill_budget.yaml new file mode 100644 index 000000000..dfb50ac9f --- /dev/null +++ b/tests/app/config/packages/chill_budget.yaml @@ -0,0 +1,14 @@ +#chill_amli_budget: +# resources: +# - { key: travail-temporaire, labels: [{ lang: fr, label: "Travail temporaire" }]} +# - { key: chomage, labels: [{ lang: fr, label: "Allocation de chômage"}]} +# - { key: cpas, labels: [{ lang: fr, label: "CPAS"}]} +# - { key: mutuelle, labels: [{ lang: fr, label: "Mutuelle"}]} +# - { key: pension-alimentaire, labels: [{ lang: fr, label: "Pension alimentaire"}]} +# - { key: allocation-fam, labels: [{ lang: fr, label: "Allocations familiales"}]} +# charges: +# - { key: charge-communes, labels: [{ lang: fr, label: "Charges communes" }]} +# - { key: electricity, labels: [{ lang: fr, label: "Électricité" }]} +# - { key: gaz, labels: [{ lang: fr, label: "Gaz" }]} +# - { key: water, labels: [{ lang: fr, label: "Eau" }]} +# - { key: autres, labels: [ { lang: fr, label: "Autres"}]} diff --git a/tests/app/config/packages/dev/debug.yaml b/tests/app/config/packages/dev/debug.yaml new file mode 100644 index 000000000..26d4e53d2 --- /dev/null +++ b/tests/app/config/packages/dev/debug.yaml @@ -0,0 +1,4 @@ +debug: + # Forwards VarDumper Data clones to a centralized server allowing to inspect dumps on CLI or in your browser. + # See the "server:dump" command to start a new server. + dump_destination: "tcp://%env(VAR_DUMPER_SERVER)%" diff --git a/tests/app/config/packages/dev/monolog.yaml b/tests/app/config/packages/dev/monolog.yaml new file mode 100644 index 000000000..423fc10df --- /dev/null +++ b/tests/app/config/packages/dev/monolog.yaml @@ -0,0 +1,21 @@ +monolog: + handlers: + main: + type: stream + path: "%kernel.logs_dir%/%kernel.environment%.log" + level: debug + channels: ["!event"] + # uncomment to get logging in your browser + # you may have to allow bigger header sizes in your Web server configuration + #firephp: + # type: firephp + # level: info + #chromephp: + # type: chromephp + # level: info + console: + type: console + process_psr_3_messages: false + channels: ['!event', '!doctrine', '!console'] + bubble: false + diff --git a/tests/app/config/packages/doctrine.yaml b/tests/app/config/packages/doctrine.yaml new file mode 100644 index 000000000..9046f2e44 --- /dev/null +++ b/tests/app/config/packages/doctrine.yaml @@ -0,0 +1,18 @@ +doctrine: + dbal: + url: '%env(resolve:DATABASE_URL)%' + + # IMPORTANT: You MUST configure your server version, + # either here or in the DATABASE_URL env var (see .env file) + #server_version: '5.7' + orm: + auto_generate_proxy_classes: true + naming_strategy: doctrine.orm.naming_strategy.default + auto_mapping: true + #mappings: + # App: + # is_bundle: false + # type: annotation + # dir: '%kernel.project_dir%/src/Entity' + # prefix: 'App\Entity' + # alias: App diff --git a/tests/app/config/packages/doctrine_migrations.yaml b/tests/app/config/packages/doctrine_migrations.yaml new file mode 100644 index 000000000..a559780d3 --- /dev/null +++ b/tests/app/config/packages/doctrine_migrations.yaml @@ -0,0 +1,30 @@ +doctrine_migrations: + migrations_paths: + # migrations for default chill modules + 'Chill\Migrations\Main': '@ChillMainBundle/migrations' + 'Chill\Migrations\Activity': '@ChillActivityBundle/migrations' + 'Chill\Migrations\DocStore': '@ChillDocStoreBundle/migrations' + 'Chill\Migrations\CustomFields': '@ChillCustomFieldsBundle/migrations' + 'Chill\Migrations\Event': '@ChillEventBundle/migrations' + 'Chill\Migrations\Person': '@ChillPersonBundle/migrations' + 'Chill\Migrations\Report': '@ChillReportBundle/migrations' + 'Chill\Migrations\Task': '@ChillTaskBundle/migrations' + 'Chill\Migrations\ThirdParty': '@ChillThirdPartyBundle/migrations' + 'Chill\Migrations\AsideActivity': '@ChillAsideActivityBundle/migrations' + 'Chill\Migrations\DocGenerator': '@ChillDocGeneratorBundle/migrations' + 'Chill\Migrations\Calendar': '@ChillCalendarBundle/migrations' + 'Chill\Migrations\Budget': '@ChillBudgetBundle/migrations' + + all_or_nothing: + true + + services: + 'Doctrine\Migrations\Version\Comparator': 'Chill\MainBundle\Doctrine\Migrations\VersionComparator' + + storage: + table_storage: + table_name: 'migration_versions' + version_column_name: 'version' + version_column_length: 1024 + executed_at_column_name: 'executed_at' + execution_time_column_name: 'execution_time' diff --git a/tests/app/config/packages/framework.yaml b/tests/app/config/packages/framework.yaml new file mode 100644 index 000000000..1ce5cb7ac --- /dev/null +++ b/tests/app/config/packages/framework.yaml @@ -0,0 +1,30 @@ +# see https://symfony.com/doc/current/reference/configuration/framework.html +framework: + secret: '%env(APP_SECRET)%' + + # DIRTY FIX un bug dans symfony4 empêche de récupérer un tableau de variables depuis .env + # cfr. https://github.com/symfony/symfony/issues/28599 + trusted_hosts: + - '^(localhost|127.0.0.1)$' + + #csrf_protection: true + #http_method_override: true + + # Enables session support. Note that the session will ONLY be started if you read or write from it. + # Remove or comment this section to explicitly disable session support. + session: + handler_id: null + cookie_secure: auto + cookie_samesite: lax + + #esi: true + #fragments: true + php_errors: + log: true + + ## sf4 check: ou à déplacer dans un chill.yaml + assets: + json_manifest_path: '%kernel.project_dir%/public/build/manifest.json' + + templating: + engines: ['twig'] diff --git a/tests/app/config/packages/lexik_jwt_authentication.yaml b/tests/app/config/packages/lexik_jwt_authentication.yaml new file mode 100644 index 000000000..93041d0a2 --- /dev/null +++ b/tests/app/config/packages/lexik_jwt_authentication.yaml @@ -0,0 +1,12 @@ +lexik_jwt_authentication: + secret_key: '%env(resolve:JWT_SECRET_KEY)%' + public_key: '%env(resolve:JWT_PUBLIC_KEY)%' + pass_phrase: '%env(JWT_PASSPHRASE)%' + + # required for wopi - recommended duration + token_ttl: 36000 + + token_extractors: + query_parameter: + enabled: true + name: access_token diff --git a/tests/app/config/packages/loophp_psr17.yaml b/tests/app/config/packages/loophp_psr17.yaml new file mode 100644 index 000000000..b5481376d --- /dev/null +++ b/tests/app/config/packages/loophp_psr17.yaml @@ -0,0 +1,8 @@ +services: + # Register loophp/psr17/Psr17 class and autowire/autoconfigure it. + loophp\psr17\Psr17: + autowire: true + autoconfigure: true + + # Alias the service to the Psr17 interface. + loophp\psr17\Psr17Interface: '@loophp\psr17\Psr17' diff --git a/tests/app/config/packages/nyholm_psr7.yaml b/tests/app/config/packages/nyholm_psr7.yaml new file mode 100644 index 000000000..f1357233b --- /dev/null +++ b/tests/app/config/packages/nyholm_psr7.yaml @@ -0,0 +1,21 @@ +services: + # Register nyholm/psr7 services for autowiring with PSR-17 (HTTP factories) + Psr\Http\Message\RequestFactoryInterface: '@nyholm.psr7.psr17_factory' + Psr\Http\Message\ResponseFactoryInterface: '@nyholm.psr7.psr17_factory' + Psr\Http\Message\ServerRequestFactoryInterface: '@nyholm.psr7.psr17_factory' + Psr\Http\Message\StreamFactoryInterface: '@nyholm.psr7.psr17_factory' + Psr\Http\Message\UploadedFileFactoryInterface: '@nyholm.psr7.psr17_factory' + Psr\Http\Message\UriFactoryInterface: '@nyholm.psr7.psr17_factory' + + # Register nyholm/psr7 services for autowiring with HTTPlug factories + Http\Message\MessageFactory: '@nyholm.psr7.httplug_factory' + Http\Message\RequestFactory: '@nyholm.psr7.httplug_factory' + Http\Message\ResponseFactory: '@nyholm.psr7.httplug_factory' + Http\Message\StreamFactory: '@nyholm.psr7.httplug_factory' + Http\Message\UriFactory: '@nyholm.psr7.httplug_factory' + + nyholm.psr7.psr17_factory: + class: Nyholm\Psr7\Factory\Psr17Factory + + nyholm.psr7.httplug_factory: + class: Nyholm\Psr7\Factory\HttplugFactory diff --git a/tests/app/config/packages/prod/deprecations.yaml b/tests/app/config/packages/prod/deprecations.yaml new file mode 100644 index 000000000..920a06197 --- /dev/null +++ b/tests/app/config/packages/prod/deprecations.yaml @@ -0,0 +1,8 @@ +# As of Symfony 5.1, deprecations are logged in the dedicated "deprecation" channel when it exists +#monolog: +# channels: [deprecation] +# handlers: +# deprecation: +# type: stream +# channels: [deprecation] +# path: "%kernel.logs_dir%/%kernel.environment%.deprecations.log" diff --git a/tests/app/config/packages/prod/doctrine.yaml b/tests/app/config/packages/prod/doctrine.yaml new file mode 100644 index 000000000..084f59a05 --- /dev/null +++ b/tests/app/config/packages/prod/doctrine.yaml @@ -0,0 +1,20 @@ +doctrine: + orm: + auto_generate_proxy_classes: false + metadata_cache_driver: + type: pool + pool: doctrine.system_cache_pool + query_cache_driver: + type: pool + pool: doctrine.system_cache_pool + result_cache_driver: + type: pool + pool: doctrine.result_cache_pool + +framework: + cache: + pools: + doctrine.result_cache_pool: + adapter: cache.app + doctrine.system_cache_pool: + adapter: cache.system diff --git a/tests/app/config/packages/prod/monolog.yaml b/tests/app/config/packages/prod/monolog.yaml new file mode 100644 index 000000000..8fb26a524 --- /dev/null +++ b/tests/app/config/packages/prod/monolog.yaml @@ -0,0 +1,14 @@ +monolog: + handlers: + graylog: + type: gelf + publisher: + hostname: "%env(resolve:GELF_HOST)%" + port: "%env(resolve:GELF_PORT)%" + level: warning + channels: ['!event'] + console: + type: console + process_psr_3_messages: false + channels: ['!event', '!doctrine', '!console'] + bubble: false diff --git a/tests/app/config/packages/prod/routing.yaml b/tests/app/config/packages/prod/routing.yaml new file mode 100644 index 000000000..b3e6a0af2 --- /dev/null +++ b/tests/app/config/packages/prod/routing.yaml @@ -0,0 +1,3 @@ +framework: + router: + strict_requirements: null diff --git a/tests/app/config/packages/prod/webpack_encore.yaml b/tests/app/config/packages/prod/webpack_encore.yaml new file mode 100644 index 000000000..d0b3ba81e --- /dev/null +++ b/tests/app/config/packages/prod/webpack_encore.yaml @@ -0,0 +1,4 @@ +#webpack_encore: + # Cache the entrypoints.json (rebuild Symfony's cache when entrypoints.json changes) + # Available in version 1.2 + #cache: true diff --git a/tests/app/config/packages/ramsey_uuid_doctrine.yaml b/tests/app/config/packages/ramsey_uuid_doctrine.yaml new file mode 100644 index 000000000..cfc3036f9 --- /dev/null +++ b/tests/app/config/packages/ramsey_uuid_doctrine.yaml @@ -0,0 +1,4 @@ +doctrine: + dbal: + types: + uuid: 'Ramsey\Uuid\Doctrine\UuidType' diff --git a/tests/app/config/packages/routing.yaml b/tests/app/config/packages/routing.yaml new file mode 100644 index 000000000..b45c1cec7 --- /dev/null +++ b/tests/app/config/packages/routing.yaml @@ -0,0 +1,7 @@ +framework: + router: + utf8: true + + # Configure how to generate URLs in non-HTTP contexts, such as CLI commands. + # See https://symfony.com/doc/current/routing.html#generating-urls-in-commands + #default_uri: http://localhost diff --git a/tests/app/config/packages/security.yaml b/tests/app/config/packages/security.yaml new file mode 100644 index 000000000..f93eb04c3 --- /dev/null +++ b/tests/app/config/packages/security.yaml @@ -0,0 +1,58 @@ +security: + + # https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers + providers: + + chain_provider: + chain : + providers: [in_memory, users] + in_memory: + memory: + users: + admin: { password: '%env(resolve:ADMIN_PASSWORD)%', roles: ['ROLE_ADMIN', 'ROLE_ALLOWED_TO_SWITCH'] } + users: + id: chill.main.user_provider + + encoders: + + Chill\MainBundle\Entity\User: + algorithm: bcrypt + Symfony\Component\Security\Core\User\User: plaintext + + firewalls: + + dev: + pattern: ^/(_(profiler|wdt)|css|images|js)/ + security: false + + default: + anonymous: ~ + provider: chain_provider + form_login: + csrf_parameter: _csrf_token + csrf_token_id: authenticate + #csrf_provider: security.csrf.token_manager + logout_on_user_change: true + logout: ~ + + # uncomment to enable impersonate mode in Chill + # https://symfony.com/doc/current/security/impersonating_user.html + # switch_user: true + + # activate different ways to authenticate + # https://symfony.com/doc/current/security.html#firewalls-authentication + + # Easy way to control access for large sections of your site + # Note: Only the *first* access control that matches will be used + access_control: + - { path: ^/(login|logout), roles: IS_AUTHENTICATED_ANONYMOUSLY } + - { path: ^/public, roles: IS_AUTHENTICATED_ANONYMOUSLY } + # access for homepage, the homepage redirect admin to admin section + - { path: ^/$, roles: [ IS_AUTHENTICATED_REMEMBERED ] } + - { path: ^/homepage$, roles: [ IS_AUTHENTICATED_REMEMBERED ] } + # idem + - { path: ^/([a-z]+/)?homepage, roles: [ IS_AUTHENTICATED_REMEMBERED ] } + # admin section, only for admin + - { path: ^/([a-z]+/)?admin, roles: ROLE_ADMIN } + # other pages, only for regular user (no admin) + - { path: ^/, roles: ROLE_USER } diff --git a/tests/app/config/packages/sensio_framework_extra.yaml b/tests/app/config/packages/sensio_framework_extra.yaml new file mode 100644 index 000000000..1821ccc07 --- /dev/null +++ b/tests/app/config/packages/sensio_framework_extra.yaml @@ -0,0 +1,3 @@ +sensio_framework_extra: + router: + annotations: false diff --git a/tests/app/config/packages/test/chill.yaml b/tests/app/config/packages/test/chill.yaml new file mode 100644 index 000000000..a6a68dee4 --- /dev/null +++ b/tests/app/config/packages/test/chill.yaml @@ -0,0 +1,5 @@ +--- +chill_main: + available_languages: + - 'fr' + - 'en' diff --git a/tests/app/config/packages/test/framework.yaml b/tests/app/config/packages/test/framework.yaml new file mode 100644 index 000000000..23906ec36 --- /dev/null +++ b/tests/app/config/packages/test/framework.yaml @@ -0,0 +1,6 @@ +framework: + test: true + session: + storage_id: session.storage.mock_file + assets: + json_manifest_path: NULL diff --git a/tests/app/config/packages/test/mailer.yaml b/tests/app/config/packages/test/mailer.yaml new file mode 100644 index 000000000..52b99299c --- /dev/null +++ b/tests/app/config/packages/test/mailer.yaml @@ -0,0 +1,5 @@ +framework: + mailer: + dsn: 'null://null' + envelope: + sender: 'test@chill.social' diff --git a/tests/app/config/packages/test/monolog.yaml b/tests/app/config/packages/test/monolog.yaml new file mode 100644 index 000000000..fc40641dc --- /dev/null +++ b/tests/app/config/packages/test/monolog.yaml @@ -0,0 +1,12 @@ +monolog: + handlers: + main: + type: fingers_crossed + action_level: error + handler: nested + excluded_http_codes: [404, 405] + channels: ["!event"] + nested: + type: stream + path: "%kernel.logs_dir%/%kernel.environment%.log" + level: debug diff --git a/tests/app/config/packages/test/security.yaml b/tests/app/config/packages/test/security.yaml new file mode 100644 index 000000000..4ff914485 --- /dev/null +++ b/tests/app/config/packages/test/security.yaml @@ -0,0 +1,8 @@ +--- +# config/packages/test/security.yaml +security: + firewalls: + default: + http_basic: ~ + role_hierarchy: + CHILL_MASTER_ROLE: [CHILL_INHERITED_ROLE_1] diff --git a/tests/app/config/packages/test/twig.yaml b/tests/app/config/packages/test/twig.yaml new file mode 100644 index 000000000..8c6e0b401 --- /dev/null +++ b/tests/app/config/packages/test/twig.yaml @@ -0,0 +1,2 @@ +twig: + strict_variables: true diff --git a/tests/app/config/packages/test/validator.yaml b/tests/app/config/packages/test/validator.yaml new file mode 100644 index 000000000..1e5ab7880 --- /dev/null +++ b/tests/app/config/packages/test/validator.yaml @@ -0,0 +1,3 @@ +framework: + validation: + not_compromised_password: false diff --git a/tests/app/config/packages/test/webpack_encore.yaml b/tests/app/config/packages/test/webpack_encore.yaml new file mode 100644 index 000000000..9ad967357 --- /dev/null +++ b/tests/app/config/packages/test/webpack_encore.yaml @@ -0,0 +1,2 @@ +webpack_encore: + strict_mode: false diff --git a/tests/app/config/packages/translation.yaml b/tests/app/config/packages/translation.yaml new file mode 100644 index 000000000..58f048218 --- /dev/null +++ b/tests/app/config/packages/translation.yaml @@ -0,0 +1,7 @@ +framework: + + default_locale: '%env(resolve:LOCALE)%' + + translator: + default_path: '%kernel.project_dir%/translations' + fallbacks: [ '%env(resolve:LOCALE)%' ] diff --git a/tests/app/config/packages/twig.yaml b/tests/app/config/packages/twig.yaml new file mode 100644 index 000000000..02d862922 --- /dev/null +++ b/tests/app/config/packages/twig.yaml @@ -0,0 +1,17 @@ +twig: + default_path: '%kernel.project_dir%/templates' + debug: '%kernel.debug%' + strict_variables: '%kernel.debug%' + exception_controller: null + + ## In Symfony 5, bootstrap_5 theme is supported. But not yet in sf4 !! + # see sf5 https://symfony.com/doc/current/form/form_themes.html + # see sf4 https://symfony.com/doc/4.4/form/form_themes.html + # + # While waiting for the upgrade, we get the form theme file + # (https://github.com/symfony/symfony/tree/5.4/src/Symfony/Bridge/Twig/Resources/views/Form), + # put it in ChillMainBundle/Resources/views/Form/bootstrap5/ + # and adapt it lightly. + # + form_themes: ['@ChillMain/Form/bootstrap5/bootstrap_5_horizontal_layout.html.twig'] + #form_themes: ['bootstrap_5_horizontal_layout.html.twig'] diff --git a/tests/app/config/packages/validator.yaml b/tests/app/config/packages/validator.yaml new file mode 100644 index 000000000..350786a13 --- /dev/null +++ b/tests/app/config/packages/validator.yaml @@ -0,0 +1,8 @@ +framework: + validation: + email_validation_mode: html5 + + # Enables validator auto-mapping support. + # For instance, basic validation constraints will be inferred from Doctrine's metadata. + #auto_mapping: + # App\Entity\: [] diff --git a/tests/app/config/packages/webpack_encore.yaml b/tests/app/config/packages/webpack_encore.yaml new file mode 100644 index 000000000..709531205 --- /dev/null +++ b/tests/app/config/packages/webpack_encore.yaml @@ -0,0 +1,33 @@ +--- +webpack_encore: + # The path where Encore is building the assets - i.e. Encore.setOutputPath() + output_path: '%kernel.project_dir%/public/build' + + # If multiple builds are defined (as shown below), you can disable the default build: + # output_path: false + + # Set attributes that will be rendered on all script and link tags + script_attributes: + defer: true + # link_attributes: + # + + # If using Encore.enableIntegrityHashes() and need the crossorigin attribute (default: false, or use 'anonymous' or 'use-credentials') + # crossorigin: 'anonymous' + + # Preload all rendered script and link tags automatically via the HTTP/2 Link header + # preload: true + + # Throw an exception if the entrypoints.json file is missing or an entry is missing from the data + # strict_mode: false + + # If you have multiple builds: + # builds: + # pass "frontend" as the 3rg arg to the Twig functions + # {{ encore_entry_script_tags('entry1', null, 'frontend') }} + + # frontend: '%kernel.project_dir%/public/frontend/build' + + # Cache the entrypoints.json (rebuild Symfony's cache when entrypoints.json changes) + # Put in config/packages/prod/webpack_encore.yaml + # cache: true diff --git a/tests/app/config/packages/workflow.yaml b/tests/app/config/packages/workflow.yaml new file mode 100644 index 000000000..855df59cd --- /dev/null +++ b/tests/app/config/packages/workflow.yaml @@ -0,0 +1,2 @@ +framework: + workflows: null diff --git a/tests/app/config/preload.php b/tests/app/config/preload.php new file mode 100644 index 000000000..064bdcd6a --- /dev/null +++ b/tests/app/config/preload.php @@ -0,0 +1,9 @@ +bootEnv(dirname(__DIR__).'/.env'); +} diff --git a/tests/console b/tests/console new file mode 100755 index 000000000..264e064a1 --- /dev/null +++ b/tests/console @@ -0,0 +1,42 @@ +#!/usr/bin/env php +getParameterOption(['--env', '-e'], null, true)) { + putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $env); +} + +if ($input->hasParameterOption('--no-debug', true)) { + putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0'); +} + +require dirname(__DIR__).'/tests/app/config/bootstrap.php'; + +if ($_SERVER['APP_DEBUG']) { + umask(0000); + + if (class_exists(Debug::class)) { + Debug::enable(); + } +} + +$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']); +$application = new Application($kernel); +$application->run($input); From 9252e92da02f801708849b59df35cdf65bfb7fd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 3 May 2023 23:00:24 +0200 Subject: [PATCH 062/724] gitlabci to new skeleton --- .gitlab-ci.yml | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3f1d75ed5..54c2cbfee 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,7 +3,6 @@ # Select what we should cache between builds cache: paths: - - tests/app/vendor/ - .cache # Bring in any services we need http://docs.gitlab.com/ee/ci/docker/using_docker_images.html#what-is-a-service @@ -28,7 +27,7 @@ variables: REDIS_PORT: 6379 REDIS_URL: redis://redis:6379 # change vendor dir to make the app install into tests/apps - COMPOSER_VENDOR_DIR: tests/app/vendor + #COMPOSER_VENDOR_DIR: /vendor DEFAULT_CARRIER_CODE: BE stages: @@ -49,7 +48,7 @@ build: expire_in: 30 min paths: - bin - - tests/app/vendor/ + - vendor/ code_style: stage: Tests @@ -63,7 +62,7 @@ code_style: expire_in: 30 min paths: - bin - - tests/app/vendor/ + - vendor/ phpstan_tests: stage: Tests @@ -77,7 +76,7 @@ phpstan_tests: expire_in: 30 min paths: - bin - - tests/app/vendor/ + - vendor/ rector_tests: stage: Tests @@ -91,7 +90,7 @@ rector_tests: expire_in: 30 min paths: - bin - - tests/app/vendor/ + - vendor/ # psalm_tests: # stage: Tests @@ -111,13 +110,12 @@ unit_tests: # until we fix testes allow_failure: true script: - - php tests/app/bin/console doctrine:migrations:migrate -n - - php -d memory_limit=2G tests/app/bin/console cache:clear --env=dev - - php -d memory_limit=3G tests/app/bin/console doctrine:fixtures:load -n - - php -d memory_limit=2G tests/app/bin/console cache:clear --env=test + - php tests/console doctrine:migrations:migrate -n + - php -d memory_limit=3G tests/console doctrine:fixtures:load -n + - php -d memory_limit=2G tests/console cache:clear --env=test - php -d memory_limit=4G bin/phpunit --colors=never artifacts: expire_in: 30 min paths: - bin - - tests/app/vendor/ + - vendor/ From f04ef9c9315869e00a45fcaee07f7409105b7942 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 5 May 2023 12:11:19 +0200 Subject: [PATCH 063/724] DX: add rector rules "symfony up to 4.4" --- rector.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rector.php b/rector.php index 00147e460..5337c5ece 100644 --- a/rector.php +++ b/rector.php @@ -12,6 +12,8 @@ return static function (RectorConfig $rectorConfig): void { __DIR__ . '/src', ]); + $rectorConfig->symfonyContainerXml(__DIR__ . '/var/cache/dev/testsApp_KernelDevDebugContainer.xml'); + //$rectorConfig->cacheClass(\Rector\Caching\ValueObject\Storage\FileCacheStorage::class); //$rectorConfig->cacheDirectory(__DIR__ . '/.cache/rector'); @@ -21,7 +23,8 @@ return static function (RectorConfig $rectorConfig): void { //define sets of rules $rectorConfig->sets([ - LevelSetList::UP_TO_PHP_82 + LevelSetList::UP_TO_PHP_82, + \Rector\Symfony\Set\SymfonySetList::SYMFONY_44, ]); // skip some path... From efaa01f4f6c8bc71b8958e4dcb6dc39c5bb75b0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 5 May 2023 18:21:09 +0200 Subject: [PATCH 064/724] DX: rector apply rules 'symfony up to 4.4 --- .../src/Templating/Entity/CategoryRender.php | 2 +- .../Templating/BudgetElementTypeRender.php | 2 +- .../AzureGrantAdminConsentAndAcquireToken.php | 2 +- .../SendShortMessageOnEligibleCalendar.php | 2 +- .../Controller/CalendarDocController.php | 2 +- .../MSGraph/RemoteEventConverter.php | 2 +- .../DefaultShortMessageForCalendarBuilder.php | 2 +- .../MSGraph/AddressConverterTest.php | 2 +- ...aultShortMessageForCalendarBuilderTest.php | 2 +- .../Command/CreateFieldsOnGroupCommand.php | 6 ++--- .../CustomFields/CustomFieldLongChoice.php | 2 +- .../ChillEventBundle/Search/EventSearch.php | 2 +- .../Command/ChillImportUsersCommand.php | 3 ++- .../ChillUserSendRenewPasswordCodeCommand.php | 3 ++- .../Command/ExecuteCronJobCommand.php | 2 +- .../Command/LoadAndUpdateLanguagesCommand.php | 3 ++- .../Command/LoadCountriesCommand.php | 3 ++- .../Command/LoadPostalCodesCommand.php | 3 ++- .../Command/SetPasswordCommand.php | 3 ++- .../Controller/SavedExportController.php | 2 +- .../ChillMainBundle/Notification/Mailer.php | 2 +- .../Service/RollingDate/RollingDate.php | 1 - .../Templating/Entity/AddressRender.php | 2 +- .../Templating/Entity/CommentRender.php | 2 +- .../Templating/Entity/UserRender.php | 2 +- .../Templating/Entity/AddressRenderTest.php | 18 +++++++------- .../NotificationOnTransitionTest.php | 2 +- .../NotificationOnTransition.php | 2 +- .../SendAccessKeyEventSubscriber.php | 2 +- .../PersonAddressMoveEventSubscriber.php | 2 +- .../Events/UserRefEventSubscriber.php | 2 +- .../Command/ChillPersonMoveCommand.php | 3 ++- .../Command/ImportSocialWorkMetadata.php | 2 +- ...mpanyingPeriodRegulationListController.php | 2 +- .../HouseholdCompositionController.php | 2 +- .../ReassignAccompanyingPeriodController.php | 2 +- .../DataFixtures/ORM/LoadRelationships.php | 11 +++++---- .../ChillPersonBundle/Search/PersonSearch.php | 2 +- .../Templating/Entity/PersonRender.php | 2 +- .../Templating/Entity/SocialActionRender.php | 2 +- .../Templating/Entity/SocialIssueRender.php | 2 +- .../Events/PersonMoveEventSubscriberTest.php | 4 ++-- .../DataFixtures/ORM/LoadReports.php | 24 ++++++++----------- .../Templating/Entity/ThirdPartyRender.php | 2 +- .../ChillWopiBundle/src/Controller/Editor.php | 2 +- 45 files changed, 75 insertions(+), 74 deletions(-) diff --git a/src/Bundle/ChillAsideActivityBundle/src/Templating/Entity/CategoryRender.php b/src/Bundle/ChillAsideActivityBundle/src/Templating/Entity/CategoryRender.php index 9094169c2..e4ffd99c0 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Templating/Entity/CategoryRender.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Templating/Entity/CategoryRender.php @@ -27,7 +27,7 @@ final readonly class CategoryRender implements ChillEntityRenderInterface public const SEPERATOR_KEY = 'default.separator'; - public function __construct(private TranslatableStringHelper $translatableStringHelper, private EngineInterface $engine) + public function __construct(private TranslatableStringHelper $translatableStringHelper, private \Twig\Environment $engine) { } diff --git a/src/Bundle/ChillBudgetBundle/Templating/BudgetElementTypeRender.php b/src/Bundle/ChillBudgetBundle/Templating/BudgetElementTypeRender.php index c48c952a1..83cfdc1da 100644 --- a/src/Bundle/ChillBudgetBundle/Templating/BudgetElementTypeRender.php +++ b/src/Bundle/ChillBudgetBundle/Templating/BudgetElementTypeRender.php @@ -22,7 +22,7 @@ use Symfony\Component\Templating\EngineInterface; */ final readonly class BudgetElementTypeRender implements ChillEntityRenderInterface { - public function __construct(private TranslatableStringHelperInterface $translatableStringHelper, private EngineInterface $engine) + public function __construct(private TranslatableStringHelperInterface $translatableStringHelper, private \Twig\Environment $engine) { } diff --git a/src/Bundle/ChillCalendarBundle/Command/AzureGrantAdminConsentAndAcquireToken.php b/src/Bundle/ChillCalendarBundle/Command/AzureGrantAdminConsentAndAcquireToken.php index de9b5477f..110adccdc 100644 --- a/src/Bundle/ChillCalendarBundle/Command/AzureGrantAdminConsentAndAcquireToken.php +++ b/src/Bundle/ChillCalendarBundle/Command/AzureGrantAdminConsentAndAcquireToken.php @@ -34,7 +34,7 @@ class AzureGrantAdminConsentAndAcquireToken extends Command parent::__construct('chill:calendar:msgraph-grant-admin-consent'); } - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { /** @var FormatterHelper $formatter */ $formatter = $this->getHelper('formatter'); diff --git a/src/Bundle/ChillCalendarBundle/Command/SendShortMessageOnEligibleCalendar.php b/src/Bundle/ChillCalendarBundle/Command/SendShortMessageOnEligibleCalendar.php index 8222d0ace..a027c1bc2 100644 --- a/src/Bundle/ChillCalendarBundle/Command/SendShortMessageOnEligibleCalendar.php +++ b/src/Bundle/ChillCalendarBundle/Command/SendShortMessageOnEligibleCalendar.php @@ -35,7 +35,7 @@ class SendShortMessageOnEligibleCalendar extends Command return 'chill:calendar:send-short-messages'; } - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $this->messageSender->sendBulkMessageToEligibleCalendars(); diff --git a/src/Bundle/ChillCalendarBundle/Controller/CalendarDocController.php b/src/Bundle/ChillCalendarBundle/Controller/CalendarDocController.php index 6542f5c97..cde6bcfe7 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/CalendarDocController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/CalendarDocController.php @@ -33,7 +33,7 @@ use UnexpectedValueException; class CalendarDocController { - public function __construct(private readonly DocGeneratorTemplateRepository $docGeneratorTemplateRepository, private readonly EngineInterface $engine, private readonly EntityManagerInterface $entityManager, private readonly FormFactoryInterface $formFactory, private readonly Security $security, private readonly UrlGeneratorInterface $urlGenerator) + public function __construct(private readonly DocGeneratorTemplateRepository $docGeneratorTemplateRepository, private readonly \Twig\Environment $engine, private readonly EntityManagerInterface $entityManager, private readonly FormFactoryInterface $formFactory, private readonly Security $security, private readonly UrlGeneratorInterface $urlGenerator) { } diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteEventConverter.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteEventConverter.php index c4d8e0b70..5b52a6ecd 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteEventConverter.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteEventConverter.php @@ -57,7 +57,7 @@ class RemoteEventConverter private readonly DateTimeZone $remoteDateTimeZone; public function __construct( - private readonly EngineInterface $engine, + private readonly \Twig\Environment $engine, private readonly LocationConverter $locationConverter, private readonly LoggerInterface $logger, private readonly PersonRenderInterface $personRender, diff --git a/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/DefaultShortMessageForCalendarBuilder.php b/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/DefaultShortMessageForCalendarBuilder.php index 8177be31a..d96cb450e 100644 --- a/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/DefaultShortMessageForCalendarBuilder.php +++ b/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/DefaultShortMessageForCalendarBuilder.php @@ -24,7 +24,7 @@ use Symfony\Component\Templating\EngineInterface; class DefaultShortMessageForCalendarBuilder implements ShortMessageForCalendarBuilderInterface { - public function __construct(private readonly EngineInterface $engine) + public function __construct(private readonly \Twig\Environment $engine) { } diff --git a/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/AddressConverterTest.php b/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/AddressConverterTest.php index 827e22381..7623cba64 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/AddressConverterTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/AddressConverterTest.php @@ -61,7 +61,7 @@ final class AddressConverterTest extends TestCase private function buildAddressConverter(): AddressConverter { - $engine = $this->prophesize(EngineInterface::class); + $engine = $this->prophesize(\Twig\Environment::class); $translatableStringHelper = $this->prophesize(TranslatableStringHelperInterface::class); $translatableStringHelper->localize(Argument::type('array'))->will(static fn ($args): string => ($args[0] ?? ['fr' => 'not provided'])['fr'] ?? 'not provided'); diff --git a/src/Bundle/ChillCalendarBundle/Tests/Service/ShortMessageNotification/DefaultShortMessageForCalendarBuilderTest.php b/src/Bundle/ChillCalendarBundle/Tests/Service/ShortMessageNotification/DefaultShortMessageForCalendarBuilderTest.php index 6d42540cc..67d124c40 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Service/ShortMessageNotification/DefaultShortMessageForCalendarBuilderTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Service/ShortMessageNotification/DefaultShortMessageForCalendarBuilderTest.php @@ -64,7 +64,7 @@ final class DefaultShortMessageForCalendarBuilderTest extends TestCase ->setMobilenumber($this->phoneNumberUtil->parse('+32470123456', 'BE')) ->setAcceptSMS(false); - $engine = $this->prophesize(EngineInterface::class); + $engine = $this->prophesize(\Twig\Environment::class); $engine->render(Argument::exact('@ChillCalendar/CalendarShortMessage/short_message.txt.twig'), Argument::withKey('calendar')) ->willReturn('message content') ->shouldBeCalledTimes(1); diff --git a/src/Bundle/ChillCustomFieldsBundle/Command/CreateFieldsOnGroupCommand.php b/src/Bundle/ChillCustomFieldsBundle/Command/CreateFieldsOnGroupCommand.php index 40a946bd2..c6a3fb63c 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Command/CreateFieldsOnGroupCommand.php +++ b/src/Bundle/ChillCustomFieldsBundle/Command/CreateFieldsOnGroupCommand.php @@ -85,10 +85,7 @@ class CreateFieldsOnGroupCommand extends Command } } - /** - * @return int|void|null - */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $helper = $this->getHelperSet()->get('question'); @@ -138,6 +135,7 @@ class CreateFieldsOnGroupCommand extends Command ); $fields = $this->_addFields($customFieldsGroup, $fieldsInput, $output); + return 0; } private function _addFields(CustomFieldsGroup $group, $values, OutputInterface $output) diff --git a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldLongChoice.php b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldLongChoice.php index 5f7351372..74115cfd3 100644 --- a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldLongChoice.php +++ b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldLongChoice.php @@ -35,7 +35,7 @@ class CustomFieldLongChoice extends AbstractCustomField public function __construct( private readonly OptionRepository $optionRepository, private readonly TranslatableStringHelper $translatableStringHelper, - private readonly EngineInterface $templating, + private readonly \Twig\Environment $templating, ) { } diff --git a/src/Bundle/ChillEventBundle/Search/EventSearch.php b/src/Bundle/ChillEventBundle/Search/EventSearch.php index 6b4192004..bb87a2f09 100644 --- a/src/Bundle/ChillEventBundle/Search/EventSearch.php +++ b/src/Bundle/ChillEventBundle/Search/EventSearch.php @@ -49,7 +49,7 @@ class EventSearch extends AbstractSearch TokenStorageInterface $tokenStorage, private readonly EntityRepository $er, private readonly AuthorizationHelper $helper, - private readonly TemplatingEngine $templating, + private readonly \Twig\Environment $templating, private readonly PaginatorFactory $paginationFactory ) { $this->user = $tokenStorage->getToken()->getUser(); diff --git a/src/Bundle/ChillMainBundle/Command/ChillImportUsersCommand.php b/src/Bundle/ChillMainBundle/Command/ChillImportUsersCommand.php index 48d460875..03c8b5742 100644 --- a/src/Bundle/ChillMainBundle/Command/ChillImportUsersCommand.php +++ b/src/Bundle/ChillMainBundle/Command/ChillImportUsersCommand.php @@ -198,7 +198,7 @@ class ChillImportUsersCommand extends Command return false; } - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $this->tempOutput = $output; $this->tempInput = $input; @@ -218,6 +218,7 @@ class ChillImportUsersCommand extends Command } catch (Exception $e) { throw $e; } + return 0; } /** diff --git a/src/Bundle/ChillMainBundle/Command/ChillUserSendRenewPasswordCodeCommand.php b/src/Bundle/ChillMainBundle/Command/ChillUserSendRenewPasswordCodeCommand.php index b7ef472a4..cb99db829 100644 --- a/src/Bundle/ChillMainBundle/Command/ChillUserSendRenewPasswordCodeCommand.php +++ b/src/Bundle/ChillMainBundle/Command/ChillUserSendRenewPasswordCodeCommand.php @@ -101,7 +101,7 @@ class ChillUserSendRenewPasswordCodeCommand extends Command ->addOption('subject', null, InputOption::VALUE_REQUIRED, 'Subject of the email', 'Recover your password'); } - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $this->input = $input; $this->output = $output; @@ -119,6 +119,7 @@ class ChillUserSendRenewPasswordCodeCommand extends Command $this->sendRecoverCode($user); } + return 0; } /** diff --git a/src/Bundle/ChillMainBundle/Command/ExecuteCronJobCommand.php b/src/Bundle/ChillMainBundle/Command/ExecuteCronJobCommand.php index b3f9a9f4d..ec38fa173 100644 --- a/src/Bundle/ChillMainBundle/Command/ExecuteCronJobCommand.php +++ b/src/Bundle/ChillMainBundle/Command/ExecuteCronJobCommand.php @@ -34,7 +34,7 @@ class ExecuteCronJobCommand extends Command ->addUsage(''); } - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { if ([] === $input->getArgument('job')) { $this->cronManager->run(); diff --git a/src/Bundle/ChillMainBundle/Command/LoadAndUpdateLanguagesCommand.php b/src/Bundle/ChillMainBundle/Command/LoadAndUpdateLanguagesCommand.php index 729051ea3..096845f47 100644 --- a/src/Bundle/ChillMainBundle/Command/LoadAndUpdateLanguagesCommand.php +++ b/src/Bundle/ChillMainBundle/Command/LoadAndUpdateLanguagesCommand.php @@ -80,7 +80,7 @@ class LoadAndUpdateLanguagesCommand extends Command * * @see \Symfony\Component\Console\Command\Command::execute() */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $em = $this->entityManager; $chillAvailableLanguages = $this->availableLanguages; @@ -130,5 +130,6 @@ class LoadAndUpdateLanguagesCommand extends Command } $em->flush(); + return 0; } } diff --git a/src/Bundle/ChillMainBundle/Command/LoadCountriesCommand.php b/src/Bundle/ChillMainBundle/Command/LoadCountriesCommand.php index c5cbdd78a..c26c698c1 100644 --- a/src/Bundle/ChillMainBundle/Command/LoadCountriesCommand.php +++ b/src/Bundle/ChillMainBundle/Command/LoadCountriesCommand.php @@ -73,7 +73,7 @@ class LoadCountriesCommand extends Command * * @see \Symfony\Component\Console\Command\Command::execute() */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $countries = static::prepareCountryList($this->availableLanguages); $em = $this->entityManager; @@ -90,5 +90,6 @@ class LoadCountriesCommand extends Command } $em->flush(); + return 0; } } diff --git a/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php b/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php index 7bda1d672..4bbc459a7 100644 --- a/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php +++ b/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php @@ -72,7 +72,7 @@ class LoadPostalCodesCommand extends Command ); } - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $csv = $this->getCSVResource($input); @@ -105,6 +105,7 @@ class LoadPostalCodesCommand extends Command $this->entityManager->flush(); $output->writeln('' . $num . ' were added !'); + return 0; } private function addPostalCode($row, OutputInterface $output) diff --git a/src/Bundle/ChillMainBundle/Command/SetPasswordCommand.php b/src/Bundle/ChillMainBundle/Command/SetPasswordCommand.php index c5eec91be..d27f18848 100644 --- a/src/Bundle/ChillMainBundle/Command/SetPasswordCommand.php +++ b/src/Bundle/ChillMainBundle/Command/SetPasswordCommand.php @@ -63,7 +63,7 @@ class SetPasswordCommand extends Command ->addArgument('password', InputArgument::OPTIONAL, 'the new password'); } - public function execute(InputInterface $input, OutputInterface $output) + public function execute(InputInterface $input, OutputInterface $output): int { $user = $this->_getUser($input->getArgument('username')); @@ -81,5 +81,6 @@ class SetPasswordCommand extends Command } $this->_setPassword($user, $password); + return 0; } } diff --git a/src/Bundle/ChillMainBundle/Controller/SavedExportController.php b/src/Bundle/ChillMainBundle/Controller/SavedExportController.php index 923394da9..0932c199a 100644 --- a/src/Bundle/ChillMainBundle/Controller/SavedExportController.php +++ b/src/Bundle/ChillMainBundle/Controller/SavedExportController.php @@ -36,7 +36,7 @@ use function count; class SavedExportController { - public function __construct(private readonly EngineInterface $templating, private readonly EntityManagerInterface $entityManager, private readonly ExportManager $exportManager, private readonly FormFactoryInterface $formFactory, private readonly SavedExportRepositoryInterface $savedExportRepository, private readonly Security $security, private readonly SessionInterface $session, private readonly TranslatorInterface $translator, private readonly UrlGeneratorInterface $urlGenerator) + public function __construct(private readonly \Twig\Environment $templating, private readonly EntityManagerInterface $entityManager, private readonly ExportManager $exportManager, private readonly FormFactoryInterface $formFactory, private readonly SavedExportRepositoryInterface $savedExportRepository, private readonly Security $security, private readonly SessionInterface $session, private readonly TranslatorInterface $translator, private readonly UrlGeneratorInterface $urlGenerator) { } diff --git a/src/Bundle/ChillMainBundle/Notification/Mailer.php b/src/Bundle/ChillMainBundle/Notification/Mailer.php index 082bff84c..6e35aecdc 100644 --- a/src/Bundle/ChillMainBundle/Notification/Mailer.php +++ b/src/Bundle/ChillMainBundle/Notification/Mailer.php @@ -40,7 +40,7 @@ class Mailer * @param $routeParameters * @param mixed[] $routeParameters */ - public function __construct(private readonly MailerInterface $mailer, private readonly LoggerInterface $logger, private readonly EngineInterface $twig, private readonly RouterInterface $router, private readonly TranslatorInterface $translator, protected $routeParameters) + public function __construct(private readonly MailerInterface $mailer, private readonly LoggerInterface $logger, private readonly \Twig\Environment $twig, private readonly RouterInterface $router, private readonly TranslatorInterface $translator, protected $routeParameters) { } diff --git a/src/Bundle/ChillMainBundle/Service/RollingDate/RollingDate.php b/src/Bundle/ChillMainBundle/Service/RollingDate/RollingDate.php index cc02dc822..35e6211b7 100644 --- a/src/Bundle/ChillMainBundle/Service/RollingDate/RollingDate.php +++ b/src/Bundle/ChillMainBundle/Service/RollingDate/RollingDate.php @@ -64,7 +64,6 @@ class RollingDate final public const T_YEAR_PREVIOUS_START = 'year_previous_start'; /** - * @param string $roll * @param DateTimeImmutable|null $fixedDate Only to insert if $roll equals @see{self::T_FIXED_DATE} * @param DateTimeImmutable $pivotDate Will be "now" if null is given */ diff --git a/src/Bundle/ChillMainBundle/Templating/Entity/AddressRender.php b/src/Bundle/ChillMainBundle/Templating/Entity/AddressRender.php index c952bb5aa..648d7b734 100644 --- a/src/Bundle/ChillMainBundle/Templating/Entity/AddressRender.php +++ b/src/Bundle/ChillMainBundle/Templating/Entity/AddressRender.php @@ -36,7 +36,7 @@ class AddressRender implements ChillEntityRenderInterface 'extended_infos' => false, ]; - public function __construct(private readonly EngineInterface $templating, private readonly TranslatableStringHelperInterface $translatableStringHelper) + public function __construct(private readonly \Twig\Environment $templating, private readonly TranslatableStringHelperInterface $translatableStringHelper) { } diff --git a/src/Bundle/ChillMainBundle/Templating/Entity/CommentRender.php b/src/Bundle/ChillMainBundle/Templating/Entity/CommentRender.php index ff8ea0dc3..0d42d2601 100644 --- a/src/Bundle/ChillMainBundle/Templating/Entity/CommentRender.php +++ b/src/Bundle/ChillMainBundle/Templating/Entity/CommentRender.php @@ -25,7 +25,7 @@ class CommentRender implements ChillEntityRenderInterface { use BoxUtilsChillEntityRenderTrait; - public function __construct(private readonly UserRepositoryInterface $userRepository, private readonly EngineInterface $engine) + public function __construct(private readonly UserRepositoryInterface $userRepository, private readonly \Twig\Environment $engine) { } diff --git a/src/Bundle/ChillMainBundle/Templating/Entity/UserRender.php b/src/Bundle/ChillMainBundle/Templating/Entity/UserRender.php index 880ee8587..a83e5369e 100644 --- a/src/Bundle/ChillMainBundle/Templating/Entity/UserRender.php +++ b/src/Bundle/ChillMainBundle/Templating/Entity/UserRender.php @@ -30,7 +30,7 @@ class UserRender implements ChillEntityRenderInterface 'absence' => true, ]; - public function __construct(private readonly TranslatableStringHelper $translatableStringHelper, private readonly EngineInterface $engine, private readonly TranslatorInterface $translator) + public function __construct(private readonly TranslatableStringHelper $translatableStringHelper, private readonly \Twig\Environment $engine, private readonly TranslatorInterface $translator) { } diff --git a/src/Bundle/ChillMainBundle/Tests/Templating/Entity/AddressRenderTest.php b/src/Bundle/ChillMainBundle/Tests/Templating/Entity/AddressRenderTest.php index 62bab9973..c8f062301 100644 --- a/src/Bundle/ChillMainBundle/Tests/Templating/Entity/AddressRenderTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Templating/Entity/AddressRenderTest.php @@ -220,7 +220,7 @@ final class AddressRenderTest extends KernelTestCase */ public function testRenderComplexAddressBE(Address $addr, string $expectedString): void { - $engine = self::$container->get(EngineInterface::class); + $engine = self::$container->get(\Twig\Environment::class); $translatableStringHelper = self::$container->get(TranslatableStringHelper::class); $renderer = new AddressRender($engine, $translatableStringHelper); @@ -232,7 +232,7 @@ final class AddressRenderTest extends KernelTestCase */ public function testRenderComplexAddressFR(Address $addr, string $expectedString): void { - $engine = self::$container->get(EngineInterface::class); + $engine = self::$container->get(\Twig\Environment::class); $translatableStringHelper = self::$container->get(TranslatableStringHelper::class); $renderer = new AddressRender($engine, $translatableStringHelper); @@ -244,7 +244,7 @@ final class AddressRenderTest extends KernelTestCase */ public function testRenderNoFullAddressBE(Address $addr, string $expectedString): void { - $engine = self::$container->get(EngineInterface::class); + $engine = self::$container->get(\Twig\Environment::class); $translatableStringHelper = self::$container->get(TranslatableStringHelper::class); $renderer = new AddressRender($engine, $translatableStringHelper); @@ -256,7 +256,7 @@ final class AddressRenderTest extends KernelTestCase */ public function testRenderStringSimpleAddressBE(Address $addr, string $expectedString): void { - $engine = self::$container->get(EngineInterface::class); + $engine = self::$container->get(\Twig\Environment::class); $translatableStringHelper = self::$container->get(TranslatableStringHelper::class); $renderer = new AddressRender($engine, $translatableStringHelper); @@ -268,7 +268,7 @@ final class AddressRenderTest extends KernelTestCase */ public function testRenderStringSimpleAddressFR(Address $addr, string $expectedString): void { - $engine = self::$container->get(EngineInterface::class); + $engine = self::$container->get(\Twig\Environment::class); $translatableStringHelper = self::$container->get(TranslatableStringHelper::class); $renderer = new AddressRender($engine, $translatableStringHelper); @@ -280,7 +280,7 @@ final class AddressRenderTest extends KernelTestCase */ public function testRenderWithBuildingAddressBE(Address $addr, string $expectedString): void { - $engine = self::$container->get(EngineInterface::class); + $engine = self::$container->get(\Twig\Environment::class); $translatableStringHelper = self::$container->get(TranslatableStringHelper::class); $renderer = new AddressRender($engine, $translatableStringHelper); @@ -292,7 +292,7 @@ final class AddressRenderTest extends KernelTestCase */ public function testRenderWithBuildingAddressFR(Address $addr, string $expectedString): void { - $engine = self::$container->get(EngineInterface::class); + $engine = self::$container->get(\Twig\Environment::class); $translatableStringHelper = self::$container->get(TranslatableStringHelper::class); $renderer = new AddressRender($engine, $translatableStringHelper); @@ -304,7 +304,7 @@ final class AddressRenderTest extends KernelTestCase */ public function testRenderWithStepsAddressBE(Address $addr, string $expectedString): void { - $engine = self::$container->get(EngineInterface::class); + $engine = self::$container->get(\Twig\Environment::class); $translatableStringHelper = self::$container->get(TranslatableStringHelper::class); $renderer = new AddressRender($engine, $translatableStringHelper); @@ -316,7 +316,7 @@ final class AddressRenderTest extends KernelTestCase */ public function testRenderWithStepsAddressFR(Address $addr, string $expectedString): void { - $engine = self::$container->get(EngineInterface::class); + $engine = self::$container->get(\Twig\Environment::class); $translatableStringHelper = self::$container->get(TranslatableStringHelper::class); $renderer = new AddressRender($engine, $translatableStringHelper); diff --git a/src/Bundle/ChillMainBundle/Tests/Workflow/EventSubscriber/NotificationOnTransitionTest.php b/src/Bundle/ChillMainBundle/Tests/Workflow/EventSubscriber/NotificationOnTransitionTest.php index 8cc190e65..c85ff3c05 100644 --- a/src/Bundle/ChillMainBundle/Tests/Workflow/EventSubscriber/NotificationOnTransitionTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Workflow/EventSubscriber/NotificationOnTransitionTest.php @@ -84,7 +84,7 @@ final class NotificationOnTransitionTest extends TestCase } ); - $engine = $this->prophesize(EngineInterface::class); + $engine = $this->prophesize(\Twig\Environment::class); $engine->render(Argument::type('string'), Argument::type('array')) ->willReturn('dummy text'); diff --git a/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/NotificationOnTransition.php b/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/NotificationOnTransition.php index 78b165a85..a79f726ba 100644 --- a/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/NotificationOnTransition.php +++ b/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/NotificationOnTransition.php @@ -25,7 +25,7 @@ use function in_array; class NotificationOnTransition implements EventSubscriberInterface { - public function __construct(private readonly EntityManagerInterface $entityManager, private readonly EngineInterface $engine, private readonly MetadataExtractor $metadataExtractor, private readonly Security $security, private readonly Registry $registry) + public function __construct(private readonly EntityManagerInterface $entityManager, private readonly \Twig\Environment $engine, private readonly MetadataExtractor $metadataExtractor, private readonly Security $security, private readonly Registry $registry) { } diff --git a/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/SendAccessKeyEventSubscriber.php b/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/SendAccessKeyEventSubscriber.php index adf19fb92..a4e8c6b78 100644 --- a/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/SendAccessKeyEventSubscriber.php +++ b/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/SendAccessKeyEventSubscriber.php @@ -21,7 +21,7 @@ use Symfony\Component\Workflow\Registry; class SendAccessKeyEventSubscriber { - public function __construct(private readonly EngineInterface $engine, private readonly MetadataExtractor $metadataExtractor, private readonly Registry $registry, private readonly EntityWorkflowManager $entityWorkflowManager, private readonly MailerInterface $mailer) + public function __construct(private readonly \Twig\Environment $engine, private readonly MetadataExtractor $metadataExtractor, private readonly Registry $registry, private readonly EntityWorkflowManager $entityWorkflowManager, private readonly MailerInterface $mailer) { } diff --git a/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Events/PersonAddressMoveEventSubscriber.php b/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Events/PersonAddressMoveEventSubscriber.php index ce26780a4..c532b5553 100644 --- a/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Events/PersonAddressMoveEventSubscriber.php +++ b/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Events/PersonAddressMoveEventSubscriber.php @@ -24,7 +24,7 @@ use Symfony\Contracts\Translation\TranslatorInterface; class PersonAddressMoveEventSubscriber implements EventSubscriberInterface { - public function __construct(private readonly EngineInterface $engine, private readonly NotificationPersisterInterface $notificationPersister, private readonly Security $security, private readonly TranslatorInterface $translator) + public function __construct(private readonly \Twig\Environment $engine, private readonly NotificationPersisterInterface $notificationPersister, private readonly Security $security, private readonly TranslatorInterface $translator) { } diff --git a/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Events/UserRefEventSubscriber.php b/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Events/UserRefEventSubscriber.php index b8ca31835..9e725b22c 100644 --- a/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Events/UserRefEventSubscriber.php +++ b/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Events/UserRefEventSubscriber.php @@ -24,7 +24,7 @@ use Symfony\Contracts\Translation\TranslatorInterface; class UserRefEventSubscriber implements EventSubscriberInterface { - public function __construct(private readonly Security $security, private readonly TranslatorInterface $translator, private readonly EngineInterface $engine, private readonly NotificationPersisterInterface $notificationPersister) + public function __construct(private readonly Security $security, private readonly TranslatorInterface $translator, private readonly \Twig\Environment $engine, private readonly NotificationPersisterInterface $notificationPersister) { } diff --git a/src/Bundle/ChillPersonBundle/Command/ChillPersonMoveCommand.php b/src/Bundle/ChillPersonBundle/Command/ChillPersonMoveCommand.php index 4817e3819..d587a55e5 100644 --- a/src/Bundle/ChillPersonBundle/Command/ChillPersonMoveCommand.php +++ b/src/Bundle/ChillPersonBundle/Command/ChillPersonMoveCommand.php @@ -63,7 +63,7 @@ final class ChillPersonMoveCommand extends Command ->addOption('delete-entity', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'entity to delete', []); } - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $repository = $this->em->getRepository(Person::class); $from = $repository->find($input->getOption('from')); @@ -100,6 +100,7 @@ final class ChillPersonMoveCommand extends Command $this->chillLogger->notice('Move a person from command line succeeded', $ctxt); } + return 0; } protected function interact(InputInterface $input, OutputInterface $output) diff --git a/src/Bundle/ChillPersonBundle/Command/ImportSocialWorkMetadata.php b/src/Bundle/ChillPersonBundle/Command/ImportSocialWorkMetadata.php index 643e176c4..8e4009364 100644 --- a/src/Bundle/ChillPersonBundle/Command/ImportSocialWorkMetadata.php +++ b/src/Bundle/ChillPersonBundle/Command/ImportSocialWorkMetadata.php @@ -41,7 +41,7 @@ final class ImportSocialWorkMetadata extends Command ->addOption('language', 'l', InputOption::VALUE_OPTIONAL, 'The default language'); } - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $filepath = $input->getOption('filepath'); diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodRegulationListController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodRegulationListController.php index 5ce844a90..3a12cc514 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodRegulationListController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodRegulationListController.php @@ -32,7 +32,7 @@ use Symfony\Component\Templating\EngineInterface; class AccompanyingPeriodRegulationListController { - public function __construct(private readonly AccompanyingPeriodACLAwareRepositoryInterface $accompanyingPeriodACLAwareRepository, private readonly EngineInterface $engine, private readonly FormFactoryInterface $formFactory, private readonly PaginatorFactory $paginatorFactory, private readonly Security $security, private readonly TranslatableStringHelperInterface $translatableStringHelper) + public function __construct(private readonly AccompanyingPeriodACLAwareRepositoryInterface $accompanyingPeriodACLAwareRepository, private readonly \Twig\Environment $engine, private readonly FormFactoryInterface $formFactory, private readonly PaginatorFactory $paginatorFactory, private readonly Security $security, private readonly TranslatableStringHelperInterface $translatableStringHelper) { } diff --git a/src/Bundle/ChillPersonBundle/Controller/HouseholdCompositionController.php b/src/Bundle/ChillPersonBundle/Controller/HouseholdCompositionController.php index 01810feeb..ad4743921 100644 --- a/src/Bundle/ChillPersonBundle/Controller/HouseholdCompositionController.php +++ b/src/Bundle/ChillPersonBundle/Controller/HouseholdCompositionController.php @@ -36,7 +36,7 @@ use Symfony\Contracts\Translation\TranslatorInterface; class HouseholdCompositionController extends AbstractController { - public function __construct(private readonly Security $security, private readonly HouseholdCompositionRepository $householdCompositionRepository, private readonly HouseholdRepository $householdRepository, private readonly PaginatorFactory $paginatorFactory, private readonly FormFactoryInterface $formFactory, private readonly EntityManagerInterface $entityManager, private readonly TranslatorInterface $translator, private readonly EngineInterface $engine, private readonly UrlGeneratorInterface $urlGenerator) + public function __construct(private readonly Security $security, private readonly HouseholdCompositionRepository $householdCompositionRepository, private readonly HouseholdRepository $householdRepository, private readonly PaginatorFactory $paginatorFactory, private readonly FormFactoryInterface $formFactory, private readonly EntityManagerInterface $entityManager, private readonly TranslatorInterface $translator, private readonly \Twig\Environment $engine, private readonly UrlGeneratorInterface $urlGenerator) { } diff --git a/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php b/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php index 6bfd7ac86..404082630 100644 --- a/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php +++ b/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php @@ -40,7 +40,7 @@ use function is_int; class ReassignAccompanyingPeriodController extends AbstractController { - public function __construct(private readonly AccompanyingPeriodACLAwareRepositoryInterface $accompanyingPeriodACLAwareRepository, private readonly UserRepository $userRepository, private readonly AccompanyingPeriodRepository $courseRepository, private readonly EngineInterface $engine, private readonly FormFactoryInterface $formFactory, private readonly PaginatorFactory $paginatorFactory, private readonly Security $security, private readonly UserRender $userRender, private readonly EntityManagerInterface $em) + public function __construct(private readonly AccompanyingPeriodACLAwareRepositoryInterface $accompanyingPeriodACLAwareRepository, private readonly UserRepository $userRepository, private readonly AccompanyingPeriodRepository $courseRepository, private readonly \Twig\Environment $engine, private readonly FormFactoryInterface $formFactory, private readonly PaginatorFactory $paginatorFactory, private readonly Security $security, private readonly UserRender $userRender, private readonly EntityManagerInterface $em) { } diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelationships.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelationships.php index 7024e732b..ddf6a7d9c 100644 --- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelationships.php +++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelationships.php @@ -42,7 +42,7 @@ class LoadRelationships extends Fixture implements DependentFixtureInterface public function load(ObjectManager $manager): void { - return; + /** @var array> $existing */ $existing = []; for ($i = 0; 20 > $i; ++$i) { @@ -60,15 +60,16 @@ class LoadRelationships extends Fixture implements DependentFixtureInterface ->setUpdatedAt($date); // remove the potential duplicates - $set = $relationship->getFromPerson()->getId() < $relationship->getToPerson()->getId() ? - [$relationship->getFromPerson()->getId(), $relationship->getToPerson()->getId()] : - [$relationship->getToPerson()->getId(), $relationship->getFromPerson()->getId()]; + $set = [ + min($relationship->getFromPerson()->getId(), $relationship->getToPerson()->getId()), + max($relationship->getFromPerson()->getId(), $relationship->getToPerson()->getId()), + ]; if (array_key_exists($set[0], $existing) && array_key_exists($set[1], $existing[$set[0]])) { continue; } + $existing[$set[0]][$set[1]] = 1; - $existing[$set[0]][$existing[$set[1]]] = 1; $manager->persist($relationship); } diff --git a/src/Bundle/ChillPersonBundle/Search/PersonSearch.php b/src/Bundle/ChillPersonBundle/Search/PersonSearch.php index 205023f19..c5a324855 100644 --- a/src/Bundle/ChillPersonBundle/Search/PersonSearch.php +++ b/src/Bundle/ChillPersonBundle/Search/PersonSearch.php @@ -45,7 +45,7 @@ class PersonSearch extends AbstractSearch implements HasAdvancedSearchFormInterf 'birthdate-after', 'gender', 'nationality', 'phonenumber', 'city', ]; - public function __construct(private readonly EngineInterface $templating, private readonly ExtractDateFromPattern $extractDateFromPattern, private readonly ExtractPhonenumberFromPattern $extractPhonenumberFromPattern, private readonly PaginatorFactory $paginatorFactory, private readonly PersonACLAwareRepositoryInterface $personACLAwareRepository) + public function __construct(private readonly \Twig\Environment $templating, private readonly ExtractDateFromPattern $extractDateFromPattern, private readonly ExtractPhonenumberFromPattern $extractPhonenumberFromPattern, private readonly PaginatorFactory $paginatorFactory, private readonly PersonACLAwareRepositoryInterface $personACLAwareRepository) { } diff --git a/src/Bundle/ChillPersonBundle/Templating/Entity/PersonRender.php b/src/Bundle/ChillPersonBundle/Templating/Entity/PersonRender.php index c41a94779..1c3ff56cd 100644 --- a/src/Bundle/ChillPersonBundle/Templating/Entity/PersonRender.php +++ b/src/Bundle/ChillPersonBundle/Templating/Entity/PersonRender.php @@ -28,7 +28,7 @@ class PersonRender implements PersonRenderInterface { use BoxUtilsChillEntityRenderTrait; - public function __construct(private readonly ConfigPersonAltNamesHelper $configAltNamesHelper, private readonly EngineInterface $engine, private readonly TranslatorInterface $translator) + public function __construct(private readonly ConfigPersonAltNamesHelper $configAltNamesHelper, private readonly \Twig\Environment $engine, private readonly TranslatorInterface $translator) { } diff --git a/src/Bundle/ChillPersonBundle/Templating/Entity/SocialActionRender.php b/src/Bundle/ChillPersonBundle/Templating/Entity/SocialActionRender.php index e4253f52e..c2d91483f 100644 --- a/src/Bundle/ChillPersonBundle/Templating/Entity/SocialActionRender.php +++ b/src/Bundle/ChillPersonBundle/Templating/Entity/SocialActionRender.php @@ -47,7 +47,7 @@ class SocialActionRender implements ChillEntityRenderInterface */ final public const SHOW_AND_CHILDREN = 'show_and_children'; - public function __construct(private readonly TranslatableStringHelper $translatableStringHelper, private readonly EngineInterface $engine, private readonly TranslatorInterface $translator) + public function __construct(private readonly TranslatableStringHelper $translatableStringHelper, private readonly \Twig\Environment $engine, private readonly TranslatorInterface $translator) { } diff --git a/src/Bundle/ChillPersonBundle/Templating/Entity/SocialIssueRender.php b/src/Bundle/ChillPersonBundle/Templating/Entity/SocialIssueRender.php index f815afc43..79a8c62c4 100644 --- a/src/Bundle/ChillPersonBundle/Templating/Entity/SocialIssueRender.php +++ b/src/Bundle/ChillPersonBundle/Templating/Entity/SocialIssueRender.php @@ -40,7 +40,7 @@ final readonly class SocialIssueRender implements ChillEntityRenderInterface */ public const SHOW_AND_CHILDREN = 'show_and_children'; - public function __construct(private TranslatableStringHelper $translatableStringHelper, private EngineInterface $engine, private TranslatorInterface $translator) + public function __construct(private TranslatableStringHelper $translatableStringHelper, private \Twig\Environment $engine, private TranslatorInterface $translator) { } diff --git a/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/Events/PersonMoveEventSubscriberTest.php b/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/Events/PersonMoveEventSubscriberTest.php index 4f9977b6d..e7fa379f6 100644 --- a/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/Events/PersonMoveEventSubscriberTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/Events/PersonMoveEventSubscriberTest.php @@ -247,7 +247,7 @@ final class PersonMoveEventSubscriberTest extends KernelTestCase } private function buildSubscriber( - ?EngineInterface $engine = null, + ?\Twig\Environment $engine = null, ?NotificationPersisterInterface $notificationPersister = null, ?Security $security = null, ?TranslatorInterface $translator = null @@ -264,7 +264,7 @@ final class PersonMoveEventSubscriberTest extends KernelTestCase } if (null === $engine) { - $double = $this->prophesize(EngineInterface::class); + $double = $this->prophesize(\Twig\Environment::class); $engine = $double->reveal(); } diff --git a/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReports.php b/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReports.php index 565266a5e..6dc3c9b8c 100644 --- a/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReports.php +++ b/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReports.php @@ -200,23 +200,21 @@ class LoadReports extends AbstractFixture implements ContainerAwareInterface, Or } return $picked; - } else { - $picked = $this->pickChoice($choices); + } + $picked = $this->pickChoice($choices); - if ($other) { - $result = ['_other' => null, '_choices' => $picked]; + if ($other) { + $result = ['_other' => null, '_choices' => $picked]; - if ('_other' === $picked) { - $result['_other'] = $this->faker->realText(70); - } - - return $result; + if ('_other' === $picked) { + $result['_other'] = $this->faker->realText(70); } - return $picked; + return $result; } - throw new \LogicException("should not happens"); + return $picked; + } /** @@ -231,10 +229,8 @@ class LoadReports extends AbstractFixture implements ContainerAwareInterface, Or /** * pick a choice within a 'choices' options (for choice type). - * - * @return the slug of the selected choice */ - private function pickChoice(array $choices) + private function pickChoice(array $choices): string { return $choices[array_rand($choices)]['slug']; } diff --git a/src/Bundle/ChillThirdPartyBundle/Templating/Entity/ThirdPartyRender.php b/src/Bundle/ChillThirdPartyBundle/Templating/Entity/ThirdPartyRender.php index 4432c5045..6e0e80093 100644 --- a/src/Bundle/ChillThirdPartyBundle/Templating/Entity/ThirdPartyRender.php +++ b/src/Bundle/ChillThirdPartyBundle/Templating/Entity/ThirdPartyRender.php @@ -25,7 +25,7 @@ class ThirdPartyRender implements ChillEntityRenderInterface { use BoxUtilsChillEntityRenderTrait; - public function __construct(protected EngineInterface $engine, protected TranslatableStringHelper $translatableStringHelper) + public function __construct(protected \Twig\Environment $engine, protected TranslatableStringHelper $translatableStringHelper) { } diff --git a/src/Bundle/ChillWopiBundle/src/Controller/Editor.php b/src/Bundle/ChillWopiBundle/src/Controller/Editor.php index 7280e7fca..dc3f32646 100644 --- a/src/Bundle/ChillWopiBundle/src/Controller/Editor.php +++ b/src/Bundle/ChillWopiBundle/src/Controller/Editor.php @@ -38,7 +38,7 @@ use Twig\Environment; */ final readonly class Editor { - public function __construct(private ConfigurationInterface $wopiConfiguration, private DiscoveryInterface $wopiDiscovery, private DocumentManagerInterface $documentManager, private EngineInterface $engine, private JWTTokenManagerInterface $JWTTokenManager, private NormalizerInterface $normalizer, private ResponderInterface $responder, private Security $security, private Psr17Interface $psr17, private RouterInterface $router) + public function __construct(private ConfigurationInterface $wopiConfiguration, private DiscoveryInterface $wopiDiscovery, private DocumentManagerInterface $documentManager, private \Twig\Environment $engine, private JWTTokenManagerInterface $JWTTokenManager, private NormalizerInterface $normalizer, private ResponderInterface $responder, private Security $security, private Psr17Interface $psr17, private RouterInterface $router) { } From 1abaf2acb024b12985825a96831b22a0fcf7045a Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Wed, 10 May 2023 10:28:36 +0200 Subject: [PATCH 065/724] DX: add help and description to use ImportSocialWorkMetadata command --- .../Command/ImportSocialWorkMetadata.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillPersonBundle/Command/ImportSocialWorkMetadata.php b/src/Bundle/ChillPersonBundle/Command/ImportSocialWorkMetadata.php index 91615935c..8085732ba 100644 --- a/src/Bundle/ChillPersonBundle/Command/ImportSocialWorkMetadata.php +++ b/src/Bundle/ChillPersonBundle/Command/ImportSocialWorkMetadata.php @@ -42,10 +42,18 @@ final class ImportSocialWorkMetadata extends Command protected function configure() { + $description = 'Imports a structured table containing social issues, social actions, objectives, results and evaluations.'; + $help = 'File to csv format, no headers, semi-colon as delimiter, datas sorted by alphabetical order, column after column.'. PHP_EOL + . 'Columns are: social issues parent, social issues child, social actions parent, social actions child, goals, results, evaluations.'. PHP_EOL + . PHP_EOL + . 'See social_work_metadata.csv as example.'. PHP_EOL; + $this ->setName('chill:person:import-socialwork') ->addOption('filepath', 'f', InputOption::VALUE_REQUIRED, 'The file to import.') - ->addOption('language', 'l', InputOption::VALUE_OPTIONAL, 'The default language'); + ->addOption('language', 'l', InputOption::VALUE_OPTIONAL, 'The default language') + ->setDescription($description) + ->setHelp($help); } protected function execute(InputInterface $input, OutputInterface $output) From 8a684734e740d02975b46b98f82a285a7d6ab8df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 16 May 2023 23:24:33 +0200 Subject: [PATCH 066/724] Fixed: fix docgen normalization on household with "old" members When a household had old members, the indexes of each "current" members should be numerical and contiguous, to be transformed in a list. If this is not the case, the members are mapped to an associative array. This commit alter the generic DocGenObjectNormalizer to ensure that the ReadableCollection are normalized using the CollectionDocGenNormalizer as default, which do not preserve keys. --- .../Normalizer/CollectionDocGenNormalizer.php | 7 ++- .../Normalizer/DocGenObjectNormalizer.php | 9 ++++ .../CollectionDocGenNormalizerTest.php | 52 +++++++++++++++++++ .../Normalizer/HouseholdNormalizerTest.php | 52 ++++++++++++++++++- 4 files changed, 117 insertions(+), 3 deletions(-) create mode 100644 src/Bundle/ChillDocGeneratorBundle/tests/Serializer/Normalizer/CollectionDocGenNormalizerTest.php diff --git a/src/Bundle/ChillDocGeneratorBundle/Serializer/Normalizer/CollectionDocGenNormalizer.php b/src/Bundle/ChillDocGeneratorBundle/Serializer/Normalizer/CollectionDocGenNormalizer.php index 196018a03..b4e99bb98 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Serializer/Normalizer/CollectionDocGenNormalizer.php +++ b/src/Bundle/ChillDocGeneratorBundle/Serializer/Normalizer/CollectionDocGenNormalizer.php @@ -13,6 +13,7 @@ namespace Chill\DocGeneratorBundle\Serializer\Normalizer; use ArrayObject; use Doctrine\Common\Collections\Collection; +use Doctrine\Common\Collections\ReadableCollection; use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface; use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface; use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait; @@ -51,7 +52,9 @@ class CollectionDocGenNormalizer implements ContextAwareNormalizerInterface, Nor return false; } - return $data instanceof Collection - || (null === $data && Collection::class === ($context['docgen:expects'] ?? null)); + return $data instanceof ReadableCollection + || (null === $data && Collection::class === ($context['docgen:expects'] ?? null)) + || (null === $data && ReadableCollection::class === ($context['docgen:expects'] ?? null)) + ; } } diff --git a/src/Bundle/ChillDocGeneratorBundle/Serializer/Normalizer/DocGenObjectNormalizer.php b/src/Bundle/ChillDocGeneratorBundle/Serializer/Normalizer/DocGenObjectNormalizer.php index 3807ee9ee..bbf12b0fd 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Serializer/Normalizer/DocGenObjectNormalizer.php +++ b/src/Bundle/ChillDocGeneratorBundle/Serializer/Normalizer/DocGenObjectNormalizer.php @@ -13,6 +13,7 @@ namespace Chill\DocGeneratorBundle\Serializer\Normalizer; use Chill\DocGeneratorBundle\Serializer\Helper\NormalizeNullValueHelper; use Chill\MainBundle\Templating\TranslatableStringHelperInterface; +use Doctrine\Common\Collections\ReadableCollection; use ReflectionClass; use RuntimeException; use Symfony\Component\PropertyAccess\PropertyAccess; @@ -271,6 +272,14 @@ class DocGenObjectNormalizer implements NormalizerAwareInterface, NormalizerInte if ($isTranslatable) { $data[$key] = $this->translatableStringHelper ->localize($value); + } elseif ($value instanceof ReadableCollection) { + // when normalizing collection, we should not preserve keys (to ensure that the result is a list) + // this is why we make call to the normalizer again to use the CollectionDocGenNormalizer + $data[$key] = + $this->normalizer->normalize($value, $format, array_merge( + $objectContext, + $attribute->getNormalizationContextForGroups($expectedGroups) + )); } elseif (is_iterable($value)) { $arr = []; diff --git a/src/Bundle/ChillDocGeneratorBundle/tests/Serializer/Normalizer/CollectionDocGenNormalizerTest.php b/src/Bundle/ChillDocGeneratorBundle/tests/Serializer/Normalizer/CollectionDocGenNormalizerTest.php new file mode 100644 index 000000000..7bfddadca --- /dev/null +++ b/src/Bundle/ChillDocGeneratorBundle/tests/Serializer/Normalizer/CollectionDocGenNormalizerTest.php @@ -0,0 +1,52 @@ +normalizer = self::$container->get(NormalizerInterface::class); + } + + public function testNormalizeFilteredArray(): void + { + $coll = new ArrayCollection([ + (object) ['v' => 'foo'], + (object) ['v' => 'bar'], + (object) ['v' => 'baz'], + ]); + + //filter to get non continuous indexes + $criteria = new Criteria(); + $criteria->where(Criteria::expr()->neq('v', 'bar')); + + $filtered = $coll->matching($criteria); + $normalized = $this->normalizer->normalize($filtered, 'docgen', []); + + self::assertIsArray($normalized); + self::assertArrayHasKey(0, $normalized); + self::assertArrayHasKey(1, $normalized); + } +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/HouseholdNormalizerTest.php b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/HouseholdNormalizerTest.php index acd4119a1..093b882ce 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/HouseholdNormalizerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/HouseholdNormalizerTest.php @@ -18,6 +18,7 @@ use Chill\PersonBundle\Entity\Person; use DateTimeImmutable; use Doctrine\ORM\EntityManagerInterface; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; +use Symfony\Component\Serializer\Normalizer\AbstractNormalizer; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; /** @@ -39,7 +40,7 @@ final class HouseholdNormalizerTest extends KernelTestCase $this->entityManager = self::$container->get(EntityManagerInterface::class); } - public function testNormalizationRecursive() + public function testNormalizationRecursive(): void { $person = new Person(); $person->setFirstName('ok')->setLastName('ok'); @@ -67,4 +68,53 @@ final class HouseholdNormalizerTest extends KernelTestCase $this->assertArrayHasKey('type', $normalized); $this->assertEquals('household', $normalized['type']); } + + /** + * When a household have old members (members which are not "current"), + * the indexes of the household must be reset to numerical and contiguous + * indexes. This ensure that it will be mapped as a list, not as an associative + * array. + */ + public function testHouseholdDocGenNormalizationWithOldMembers(): void + { + $previousPerson = new Person(); + $previousPerson->setFirstName('ok')->setLastName('ok'); + $this->entityManager->persist($previousPerson); + $member = new HouseholdMember(); + $household = new Household(); + $position = (new Position()) + ->setShareHousehold(true) + ->setAllowHolder(true); + + $member->setPerson($previousPerson) + ->setStartDate(new DateTimeImmutable('1 year ago')) + ->setEndDate(new DateTimeImmutable('1 month ago')) + ->setPosition($position); + + $household->addMember($member); + + $currentPerson1 = new Person(); + $currentPerson1->setFirstName('p1')->setLastName('p1'); + $this->entityManager->persist($currentPerson1); + $member = new HouseholdMember(); + $member->setPerson($currentPerson1) + ->setStartDate(new DateTimeImmutable('1 year ago')) + ->setPosition($position); + $household->addMember($member); + + $normalized = $this->normalizer->normalize( + $household, + 'docgen', + [ + AbstractNormalizer::GROUPS => ['docgen:read'], + 'docgen:expects' => Household::class, + 'docgen:person:with-household' => false, + 'docgen:person:with-relations' => false, + 'docgen:person:with-budget' => false, + ] + ); + + self::assertIsArray($normalized); + self::assertArrayHasKey(0, $normalized['currentMembers']); + } } From db9fef095ab4379b82a081011abcc90156aa42fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 17 May 2023 13:24:15 +0200 Subject: [PATCH 067/724] Fixed: force default values for cc users in workflow --- .../ChillMainBundle/Controller/WorkflowController.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Controller/WorkflowController.php b/src/Bundle/ChillMainBundle/Controller/WorkflowController.php index 36647612b..cfd28160c 100644 --- a/src/Bundle/ChillMainBundle/Controller/WorkflowController.php +++ b/src/Bundle/ChillMainBundle/Controller/WorkflowController.php @@ -359,9 +359,9 @@ class WorkflowController extends AbstractController } // TODO symfony 5: add those "future" on context ($workflow->apply($entityWorkflow, $transition, $context) - $entityWorkflow->futureCcUsers = $transitionForm['future_cc_users']->getData(); - $entityWorkflow->futureDestUsers = $transitionForm['future_dest_users']->getData(); - $entityWorkflow->futureDestEmails = $transitionForm['future_dest_emails']->getData(); + $entityWorkflow->futureCcUsers = $transitionForm['future_cc_users']->getData() ?? []; + $entityWorkflow->futureDestUsers = $transitionForm['future_dest_users']->getData() ?? []; + $entityWorkflow->futureDestEmails = $transitionForm['future_dest_emails']->getData() ?? []; $workflow->apply($entityWorkflow, $transition); From 8863e0a92efaadf6224c7d76341a12e94774025a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 17 May 2023 13:24:44 +0200 Subject: [PATCH 068/724] Fixed: force string on username --- src/Bundle/ChillMainBundle/Entity/User.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Entity/User.php b/src/Bundle/ChillMainBundle/Entity/User.php index a8ef88fbe..35b73786b 100644 --- a/src/Bundle/ChillMainBundle/Entity/User.php +++ b/src/Bundle/ChillMainBundle/Entity/User.php @@ -506,11 +506,11 @@ class User implements UserInterface * * @return User */ - public function setUsername($name) + public function setUsername(?string $name) { - $this->username = $name; + $this->username = (string) $name; - if (empty($this->getLabel())) { + if ("" === trim($this->getLabel())) { $this->setLabel($name); } From 66dc02735412e260dc1650214d3683d36e21042b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 17 May 2023 13:27:20 +0200 Subject: [PATCH 069/724] Fixed: fix first execution of accompanying period step change cronjob --- .../Lifecycle/AccompanyingPeriodStepChangeCronjob.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Lifecycle/AccompanyingPeriodStepChangeCronjob.php b/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Lifecycle/AccompanyingPeriodStepChangeCronjob.php index bec31d45d..f637e70b9 100644 --- a/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Lifecycle/AccompanyingPeriodStepChangeCronjob.php +++ b/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Lifecycle/AccompanyingPeriodStepChangeCronjob.php @@ -27,7 +27,7 @@ readonly class AccompanyingPeriodStepChangeCronjob implements CronJobInterface { $now = $this->clock->now(); - if ($now->sub(new \DateInterval('P1D')) < $cronJobExecution->getLastStart()) { + if (null !== $cronJobExecution && $now->sub(new \DateInterval('P1D')) < $cronJobExecution->getLastStart()) { return false; } From fbd555e89aba7230b691931988c709809f6e2118 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 17 May 2023 16:05:53 +0200 Subject: [PATCH 070/724] Feature: add Household composition on household in docgen --- src/Bundle/ChillPersonBundle/Entity/Household/Household.php | 4 ++++ .../Entity/Household/HouseholdComposition.php | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/Bundle/ChillPersonBundle/Entity/Household/Household.php b/src/Bundle/ChillPersonBundle/Entity/Household/Household.php index 8a99c7eb4..74b8ed5f8 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Household/Household.php +++ b/src/Bundle/ChillPersonBundle/Entity/Household/Household.php @@ -213,6 +213,10 @@ class Household return null; } + /** + * @Serializer\Groups({"docgen:read"}) + * @Serializer\SerializedName("current_composition") + */ public function getCurrentComposition(?DateTimeImmutable $at = null): ?HouseholdComposition { $at ??= new DateTimeImmutable('today'); diff --git a/src/Bundle/ChillPersonBundle/Entity/Household/HouseholdComposition.php b/src/Bundle/ChillPersonBundle/Entity/Household/HouseholdComposition.php index f11d1402b..65178c3ed 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Household/HouseholdComposition.php +++ b/src/Bundle/ChillPersonBundle/Entity/Household/HouseholdComposition.php @@ -44,6 +44,7 @@ class HouseholdComposition implements TrackCreationInterface, TrackUpdateInterfa /** * @ORM\Column(type="date_immutable", nullable=true, options={"default": null}) * @Assert\GreaterThanOrEqual(propertyPath="startDate", groups={"Default", "household_composition"}) + * @Serializer\Groups({"docgen:read"}) */ private ?DateTimeImmutable $endDate = null; @@ -56,6 +57,7 @@ class HouseholdComposition implements TrackCreationInterface, TrackUpdateInterfa /** * @ORM\ManyToOne(targetEntity=HouseholdCompositionType::class) * @ORM\JoinColumn(nullable=false) + * @Serializer\Groups({"docgen:read"}) */ private ?HouseholdCompositionType $householdCompositionType = null; @@ -71,12 +73,14 @@ class HouseholdComposition implements TrackCreationInterface, TrackUpdateInterfa * @ORM\Column(type="integer", nullable=true, options={"default": null}) * @Assert\NotNull * @Assert\GreaterThanOrEqual(0, groups={"Default", "household_composition"}) + * @Serializer\Groups({"docgen:read"}) */ private ?int $numberOfChildren = null; /** * @ORM\Column(type="date_immutable", nullable=false) * @Assert\NotNull(groups={"Default", "household_composition"}) + * @Serializer\Groups({"docgen:read"}) */ private ?DateTimeImmutable $startDate = null; From 8a35c2e2eeb6f6bde0cb966b5264b264f0d982c4 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Wed, 17 May 2023 16:28:51 +0200 Subject: [PATCH 071/724] Fix workflow regression with accompanying period work (introduced by commit 6b90a7d2a7 24/01/2023) --- .../views/Workflow/_accompanying_period_work.html.twig | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Workflow/_accompanying_period_work.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Workflow/_accompanying_period_work.html.twig index 49cd37180..9110bd212 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Workflow/_accompanying_period_work.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Workflow/_accompanying_period_work.html.twig @@ -3,6 +3,14 @@ {{ 'workflow.SocialAction deleted'|trans }} {% else %} +
    + {% include '@ChillPerson/AccompanyingCourseWork/_item.html.twig' with { + 'w': work, + 'displayAction': false, + 'displayContent': 'short', + 'itemBlocClass': 'bg-chill-llight-gray' + } %} +
    {% if display_action is defined and display_action == true %}
    diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/show.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/show.html.twig index 8d508539d..d32c1b700 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/show.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/show.html.twig @@ -35,6 +35,7 @@ {{ 'Back to the list'|trans }} +
  • {{ macro.workflowButton(work) }}
  • {% if accompanyingCourse.hasUser and accompanyingCourse.user is not same as(app.user) %} @@ -54,7 +55,6 @@ {% endif %}
  • -
  • {{ macro.workflowButton(work) }}
  • {% if is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_UPDATE', work) %}
  • Date: Tue, 23 May 2023 16:30:26 +0200 Subject: [PATCH 079/724] UX: [vue] Fix picto color in document actions dropdown --- .../public/vuejs/StoredObjectButton/ConvertButton.vue | 6 ++++++ .../public/vuejs/StoredObjectButton/DownloadButton.vue | 6 ++++++ .../public/vuejs/StoredObjectButton/WopiEditButton.vue | 3 +++ 3 files changed, 15 insertions(+) diff --git a/src/Bundle/ChillDocStoreBundle/Resources/public/vuejs/StoredObjectButton/ConvertButton.vue b/src/Bundle/ChillDocStoreBundle/Resources/public/vuejs/StoredObjectButton/ConvertButton.vue index aa99a223f..be482cf7e 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/public/vuejs/StoredObjectButton/ConvertButton.vue +++ b/src/Bundle/ChillDocStoreBundle/Resources/public/vuejs/StoredObjectButton/ConvertButton.vue @@ -44,3 +44,9 @@ async function download_and_open(event: Event): Promise { } + + diff --git a/src/Bundle/ChillDocStoreBundle/Resources/public/vuejs/StoredObjectButton/DownloadButton.vue b/src/Bundle/ChillDocStoreBundle/Resources/public/vuejs/StoredObjectButton/DownloadButton.vue index 98645873b..cbc314ff9 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/public/vuejs/StoredObjectButton/DownloadButton.vue +++ b/src/Bundle/ChillDocStoreBundle/Resources/public/vuejs/StoredObjectButton/DownloadButton.vue @@ -52,3 +52,9 @@ async function download_and_open(event: Event): Promise { } } + + diff --git a/src/Bundle/ChillDocStoreBundle/Resources/public/vuejs/StoredObjectButton/WopiEditButton.vue b/src/Bundle/ChillDocStoreBundle/Resources/public/vuejs/StoredObjectButton/WopiEditButton.vue index d68f60f86..ea244192e 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/public/vuejs/StoredObjectButton/WopiEditButton.vue +++ b/src/Bundle/ChillDocStoreBundle/Resources/public/vuejs/StoredObjectButton/WopiEditButton.vue @@ -40,5 +40,8 @@ async function beforeLeave(event: Event): Promise { From ef6a5e0b6bf320c155e3390769ecf50f4054128b Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Tue, 23 May 2023 16:32:08 +0200 Subject: [PATCH 080/724] UX: [vue] Change single button notification by dropdown button (edit workAction) --- .../vuejs/AccompanyingCourseWorkEdit/App.vue | 32 ++++++-- .../components/FormEvaluation.vue | 81 ++++++++++++------- 2 files changed, 77 insertions(+), 36 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue index e6ee7de79..128148f8a 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue @@ -296,13 +296,26 @@ @go-to-generate-workflow="goToGenerateWorkflow" >
  • +
  • + + @click="goToGenerateNotification(false)" + > +
  • +
  • -
  • -
  • - -
  • +
      +
    • + +
    • - - + + +
    • +
    • + + +
    • @@ -219,7 +232,10 @@ const i18n = { template_title: "Nom du template", browse: "Ajouter un document", replace: "Remplacer", - download: "Télécharger le fichier existant" + download: "Télécharger le fichier existant", + notification_notify_referrer: "Notifier le référent", + notification_notify_any: "Notifier d'autres utilisateurs", + notification_send: "Envoyer une notification", } } }; @@ -265,7 +281,8 @@ export default { }, computed: { ...mapState([ - 'isPosting' + 'isPosting', + 'work' ]), getTemplatesAvailables() { return this.$store.getters.getTemplatesAvailablesForEvaluation(this.evaluation.evaluation); @@ -395,10 +412,14 @@ export default { return this.$store.dispatch('submit', callback) .catch(e => { console.log(e); throw e; }); }, - goToGenerateDocumentNotification(document){ + goToGenerateDocumentNotification(document, tos){ const callback = (data) => { - let evaluation = data.accompanyingPeriodWorkEvaluations.find(e => e.key === this.evaluation.key); - window.location.assign(`/fr/notification/create?entityClass=Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluationDocument&entityId=${document.id}&returnPath=/fr/person/accompanying-period/work/${evaluation.id}/edit`) + let evaluation = data.accompanyingPeriodWorkEvaluations.find(e => e.key === this.evaluation.key); + if (tos === true) { + window.location.assign(`/fr/notification/create?entityClass=Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluationDocument&entityId=${document.id}&tos[0]=${this.$store.state.work.accompanyingPeriod.user.id}&returnPath=/fr/person/accompanying-period/work/${evaluation.id}/edit`) + } else { + window.location.assign(`/fr/notification/create?entityClass=Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluationDocument&entityId=${document.id}&returnPath=/fr/person/accompanying-period/work/${evaluation.id}/edit`) + } }; return this.$store.dispatch('submit', callback) .catch(e => {console.log(e); throw e}); From 53aa887da5c4168c1abe2f0ada16ee8fe009dc82 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Tue, 23 May 2023 18:10:29 +0200 Subject: [PATCH 081/724] Fixed: [vue] add condition to use dropdown or single button --- .../vuejs/AccompanyingCourseWorkEdit/App.vue | 12 ++++++------ .../components/FormEvaluation.vue | 13 +++++++------ .../vuejs/AccompanyingCourseWorkEdit/store.js | 18 ++++++++++++++++++ 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue index 128148f8a..072944192 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue @@ -298,12 +298,7 @@
    • - - @@ -463,6 +458,7 @@ export default { 'isPosting', 'errors', 'templatesAvailablesForAction', + 'me', ]), ...mapGetters([ 'hasResultsForAction', @@ -520,6 +516,10 @@ export default { this.$store.commit('setPersonsPickedIds', v); } }, + AmIRefferer() { + return (!(this.work.accompanyingPeriod.user && this.me + && (this.work.accompanyingPeriod.user.id !== this.me.id))); + } }, methods: { toggleSelect() { diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue index 1673c2f33..7d6678ec7 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue @@ -116,12 +116,8 @@ >
    • - @@ -282,8 +278,13 @@ export default { computed: { ...mapState([ 'isPosting', - 'work' + 'work', + 'me', ]), + AmIRefferer() { + return (!(this.$store.state.work.accompanyingPeriod.user && this.$store.state.me + && (this.$store.state.work.accompanyingPeriod.user.id !== this.$store.state.me.id))); + }, getTemplatesAvailables() { return this.$store.getters.getTemplatesAvailablesForEvaluation(this.evaluation.evaluation); }, diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js index 47e4b2d3f..9a46b741a 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js @@ -35,6 +35,7 @@ const store = createStore({ referrers: window.accompanyingCourseWork.referrers, isPosting: false, errors: [], + me: null }, getters: { socialAction(state) { @@ -130,6 +131,9 @@ const store = createStore({ } }, mutations: { + setWhoAmiI(state, me) { + state.me = me; + }, setEvaluationsPicked(state, evaluations) { state.evaluationsPicked = evaluations.map((e, index) => { var k = Object.assign(e, { @@ -385,6 +389,19 @@ const store = createStore({ }, }, actions: { + getWhoAmI({ commit }) { + let url = `/api/1.0/main/whoami.json`; + window.fetch(url) + .then(response => { + if (response.ok) { + return response.json(); + } + throw { m: 'Error while retriving results for goal', s: response.status, b: response.body }; + }) + .then(data => { + commit('setWhoAmiI', data); + }); + }, updateThirdParty({ commit }, payload) { commit('updateThirdParty', payload); }, @@ -514,6 +531,7 @@ store.commit('setEvaluationsPicked', window.accompanyingCourseWork.accompanyingP store.dispatch('getReachablesResultsForAction'); store.dispatch('getReachablesGoalsForAction'); store.dispatch('getReachablesEvaluationsForAction'); +store.dispatch('getWhoAmI'); store.state.evaluationsPicked.forEach(evaluation => { store.dispatch('fetchTemplatesAvailablesForEvaluation', evaluation.evaluation) From 5351223d44af43d2a063eea6b408749128e0b263 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 23 May 2023 18:12:26 +0200 Subject: [PATCH 082/724] FIX [duplicates] reinstate gestion des doublons --- .../Actions/Remove/PersonMove.php | 69 ++++++++++++++----- .../Controller/PersonDuplicateController.php | 6 +- .../Menu/PersonMenuBuilder.php | 25 ++++--- .../views/PersonDuplicate/_sidepane.html.twig | 2 +- .../views/PersonDuplicate/confirm.html.twig | 8 +-- 5 files changed, 75 insertions(+), 35 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Actions/Remove/PersonMove.php b/src/Bundle/ChillPersonBundle/Actions/Remove/PersonMove.php index 13a62094d..8363134fd 100644 --- a/src/Bundle/ChillPersonBundle/Actions/Remove/PersonMove.php +++ b/src/Bundle/ChillPersonBundle/Actions/Remove/PersonMove.php @@ -13,7 +13,11 @@ namespace Chill\PersonBundle\Actions\Remove; use Chill\PersonBundle\Actions\ActionEvent; use Chill\PersonBundle\Entity\AccompanyingPeriod; +use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation; +use Chill\PersonBundle\Entity\Household\HouseholdMember; +use Chill\PersonBundle\Entity\Household\PersonHouseholdAddress; use Chill\PersonBundle\Entity\Person; +use Chill\PersonBundle\Entity\Relationships\Relationship; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Mapping\ClassMetadata; use Symfony\Component\EventDispatcher\EventDispatcherInterface; @@ -42,9 +46,10 @@ class PersonMove protected $eventDispatcher; public function __construct( - EntityManagerInterface $em, + EntityManagerInterface $em, EventDispatcherInterface $eventDispatcher - ) { + ) + { $this->em = $em; $this->eventDispatcher = $eventDispatcher; } @@ -84,8 +89,11 @@ class PersonMove } foreach ($metadata->getAssociationMappings() as $field => $mapping) { - if (Person::class === $mapping['targetEntity']) { - if (in_array($metadata->getName(), $toDelete, true)) { + if (in_array($mapping['sourceEntity'], $this->getIgnoredEntities())) { + continue; + } + if (Person::class === $mapping['targetEntity'] and true === $mapping['isOwningSide']) { + if (in_array($mapping['sourceEntity'], $toDelete, true)) { $sql = $this->createDeleteSQL($metadata, $from, $field); $event = new ActionEvent( $from->getId(), @@ -117,10 +125,11 @@ class PersonMove $from->getId() ); + dump($sqls); return $sqls; } - protected function createDeleteSQL(ClassMetadata $metadata, Person $from, $field): string + private function createDeleteSQL(ClassMetadata $metadata, Person $from, $field): string { $mapping = $metadata->getAssociationMapping($field); @@ -137,26 +146,41 @@ class PersonMove ); } - protected function createMoveSQL(ClassMetadata $metadata, Person $from, Person $to, $field): string + private function createMoveSQL(ClassMetadata $metadata, Person $from, Person $to, $field): string { $mapping = $metadata->getAssociationMapping($field); // Set part of the query, aka in "UPDATE table SET " $sets = []; - - foreach ($mapping['joinColumns'] as $columns) { - $sets[] = sprintf('%s = %d', $columns['name'], $to->getId()); - } - $conditions = []; + dump($mapping); - foreach ($mapping['joinColumns'] as $columns) { - $conditions[] = sprintf('%s = %d', $columns['name'], $from->getId()); + if (array_key_exists('joinTable', $mapping)) { + $tableName = (null !== ($mapping['joinTable']['schema'] ?? null) ? $mapping['joinTable']['schema'] . '.' : '') + . $mapping['joinTable']['name']; + + foreach ($mapping['joinTable']['inverseJoinColumns'] as $columns) { + $sets[] = sprintf('%s = %d', $columns['name'], $to->getId()); + } + + foreach ($mapping['joinTable']['inverseJoinColumns'] as $columns) { + $conditions[] = sprintf('%s = %d', $columns['name'], $from->getId()); + } + } elseif (array_key_exists('joinColumns', $mapping)) { + $tableName = $this->getTableName($metadata); + foreach ($mapping['joinColumns'] as $columns) { + $sets[] = sprintf('%s = %d', $columns['name'], $to->getId()); + } + + + foreach ($mapping['joinColumns'] as $columns) { + $conditions[] = sprintf('%s = %d', $columns['name'], $from->getId()); + } } return sprintf( 'UPDATE %s SET %s WHERE %s', - $this->getTableName($metadata), + $tableName, implode(' ', $sets), implode(' AND ', $conditions) ); @@ -166,10 +190,23 @@ class PersonMove * return an array of classes where entities should be deleted * instead of moved. */ - protected function getDeleteEntities(): array + private function getDeleteEntities(): array { return [ - AccompanyingPeriod::class, + Person\PersonCenterHistory::class, + HouseholdMember::class, + AccompanyingPeriodParticipation::class, + AccompanyingPeriod\AccompanyingPeriodWork::class, + Relationship::class + ]; + } + + private function getIgnoredEntities(): array + { + return [ + Person\PersonCurrentAddress::class, + PersonHouseholdAddress::class, + Person\PersonCenterCurrent::class, ]; } diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php b/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php index 928112d2e..ab353c83e 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php @@ -247,7 +247,7 @@ class PersonDuplicateController extends Controller ); $duplicatePersons = $this->similarPersonMatcher-> - matchPerson($person, $personNotDuplicateRepository, 0.5, SimilarPersonMatcher::SIMILAR_SEARCH_ORDER_BY_ALPHABETICAL); + matchPerson($person, 0.5, SimilarPersonMatcher::SIMILAR_SEARCH_ORDER_BY_ALPHABETICAL, false, $personNotDuplicateRepository); $notDuplicatePersons = $personNotDuplicateRepository->findNotDuplicatePerson($person); @@ -264,14 +264,14 @@ class PersonDuplicateController extends Controller $nb_activity = $em->getRepository(Activity::class)->findBy(['person' => $id]); $nb_document = $em->getRepository(PersonDocument::class)->findBy(['person' => $id]); - $nb_event = $em->getRepository(Participation::class)->findBy(['person' => $id]); +// $nb_event = $em->getRepository(Participation::class)->findBy(['person' => $id]); $nb_task = $em->getRepository(SingleTask::class)->countByParameters(['person' => $id]); $person = $em->getRepository(Person::class)->findOneBy(['id' => $id]); return [ 'nb_activity' => count($nb_activity), 'nb_document' => count($nb_document), - 'nb_event' => count($nb_event), +// 'nb_event' => count($nb_event), 'nb_task' => $nb_task, 'nb_addresses' => count($person->getAddresses()), ]; diff --git a/src/Bundle/ChillPersonBundle/Menu/PersonMenuBuilder.php b/src/Bundle/ChillPersonBundle/Menu/PersonMenuBuilder.php index 39ac557fb..b7934c2b2 100644 --- a/src/Bundle/ChillPersonBundle/Menu/PersonMenuBuilder.php +++ b/src/Bundle/ChillPersonBundle/Menu/PersonMenuBuilder.php @@ -15,6 +15,7 @@ use Chill\MainBundle\Routing\LocalMenuBuilderInterface; use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Repository\ResidentialAddressRepository; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; +use Chill\PersonBundle\Security\Authorization\PersonVoter; use Knp\Menu\MenuItem; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\Security\Core\Security; @@ -106,17 +107,19 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface ->setExtras([ 'order' => 99999, ]); - /* - $menu->addChild($this->translator->trans('Person duplicate'), [ - 'route' => 'chill_person_duplicate_view', - 'routeParameters' => [ - 'person_id' => $parameters['person']->getId(), - ], - ]) - ->setExtras([ - 'order' => 99999, - ]); - */ + + if ($this->security->isGranted(PersonVoter::DUPLICATE, $parameters['person'])) { + $menu->addChild($this->translator->trans('Person duplicate'), [ + 'route' => 'chill_person_duplicate_view', + 'routeParameters' => [ + 'person_id' => $parameters['person']->getId(), + ], + ]) + ->setExtras([ + 'order' => 99999, + ]); + } + if ( 'visible' === $this->showAccompanyingPeriod && $this->security->isGranted(AccompanyingPeriodVoter::SEE, $parameters['person']) diff --git a/src/Bundle/ChillPersonBundle/Resources/views/PersonDuplicate/_sidepane.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/PersonDuplicate/_sidepane.html.twig index 660fff7a6..1e770062a 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/PersonDuplicate/_sidepane.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/PersonDuplicate/_sidepane.html.twig @@ -39,7 +39,7 @@
    • {{ person.counters.nb_activity }} {{ (person.counters.nb_activity > 1)? 'échanges' : 'échange' }}
    • {{ person.counters.nb_task }} {{ (person.counters.nb_task > 1)? 'tâches' : 'tâche' }}
    • {{ person.counters.nb_document }} {{ (person.counters.nb_document > 1)? 'documents' : 'document' }}
    • -
    • {{ person.counters.nb_event }} {{ (person.counters.nb_event > 1)? 'événements' : 'événement' }}
    • +{#
    • {{ person.counters.nb_event }} {{ (person.counters.nb_event > 1)? 'événements' : 'événement' }}
    • #}
    • {{ person.counters.nb_addresses }} {{ (person.counters.nb_addresses > 1)? 'adresses' : 'adresse' }}
    diff --git a/src/Bundle/ChillPersonBundle/Resources/views/PersonDuplicate/confirm.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/PersonDuplicate/confirm.html.twig index 304e78eb3..218b89f2a 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/PersonDuplicate/confirm.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/PersonDuplicate/confirm.html.twig @@ -25,7 +25,7 @@

    {{ 'Merge duplicate persons folders'|trans }}

    -
    +

    {{ 'Old person'|trans }}: {{ 'Old person explain'|trans }}

    @@ -43,7 +43,7 @@
    -
    +

    {{ 'New person'|trans }}: {{ 'New person explain'|trans }}

    @@ -63,10 +63,10 @@ {{ form_start(form) }} -
    +
    -
    +
    {{ form_widget(form.confirm) }}
    From 8b82e0c535c33616505ca5ed6e524864cfdc41c3 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 23 May 2023 18:19:31 +0200 Subject: [PATCH 083/724] FIX [rights] user shouldn't be allowed to see accompanyingperiods from within household --- .../Security/Authorization/AccompanyingPeriodVoter.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php index ea32326a4..709624b54 100644 --- a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php +++ b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php @@ -18,6 +18,7 @@ use Chill\MainBundle\Security\Authorization\VoterHelperFactoryInterface; use Chill\MainBundle\Security\Authorization\VoterHelperInterface; use Chill\MainBundle\Security\ProvideRoleHierarchyInterface; use Chill\PersonBundle\Entity\AccompanyingPeriod; +use Chill\PersonBundle\Entity\Household\Household; use Chill\PersonBundle\Entity\Person; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Security; @@ -119,6 +120,7 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH ->generate(self::class) ->addCheckFor(null, [self::CREATE, self::REASSIGN_BULK]) ->addCheckFor(AccompanyingPeriod::class, [self::TOGGLE_CONFIDENTIAL, ...self::ALL]) + ->addCheckFor(Household::class, [self::SEE]) ->addCheckFor(Person::class, [self::SEE, self::CREATE]) ->addCheckFor(Center::class, [self::STATS]) ->build(); From 5109490aad0a0c12db9a8f4c3729de11a131f6bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 24 May 2023 13:09:04 +0200 Subject: [PATCH 084/724] Revert "FIX [duplicates] reinstate gestion des doublons" This reverts commit 5351223d44af43d2a063eea6b408749128e0b263. --- .../Actions/Remove/PersonMove.php | 69 +++++-------------- .../Controller/PersonDuplicateController.php | 6 +- .../Menu/PersonMenuBuilder.php | 25 +++---- .../views/PersonDuplicate/_sidepane.html.twig | 2 +- .../views/PersonDuplicate/confirm.html.twig | 8 +-- 5 files changed, 35 insertions(+), 75 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Actions/Remove/PersonMove.php b/src/Bundle/ChillPersonBundle/Actions/Remove/PersonMove.php index 8363134fd..13a62094d 100644 --- a/src/Bundle/ChillPersonBundle/Actions/Remove/PersonMove.php +++ b/src/Bundle/ChillPersonBundle/Actions/Remove/PersonMove.php @@ -13,11 +13,7 @@ namespace Chill\PersonBundle\Actions\Remove; use Chill\PersonBundle\Actions\ActionEvent; use Chill\PersonBundle\Entity\AccompanyingPeriod; -use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation; -use Chill\PersonBundle\Entity\Household\HouseholdMember; -use Chill\PersonBundle\Entity\Household\PersonHouseholdAddress; use Chill\PersonBundle\Entity\Person; -use Chill\PersonBundle\Entity\Relationships\Relationship; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Mapping\ClassMetadata; use Symfony\Component\EventDispatcher\EventDispatcherInterface; @@ -46,10 +42,9 @@ class PersonMove protected $eventDispatcher; public function __construct( - EntityManagerInterface $em, + EntityManagerInterface $em, EventDispatcherInterface $eventDispatcher - ) - { + ) { $this->em = $em; $this->eventDispatcher = $eventDispatcher; } @@ -89,11 +84,8 @@ class PersonMove } foreach ($metadata->getAssociationMappings() as $field => $mapping) { - if (in_array($mapping['sourceEntity'], $this->getIgnoredEntities())) { - continue; - } - if (Person::class === $mapping['targetEntity'] and true === $mapping['isOwningSide']) { - if (in_array($mapping['sourceEntity'], $toDelete, true)) { + if (Person::class === $mapping['targetEntity']) { + if (in_array($metadata->getName(), $toDelete, true)) { $sql = $this->createDeleteSQL($metadata, $from, $field); $event = new ActionEvent( $from->getId(), @@ -125,11 +117,10 @@ class PersonMove $from->getId() ); - dump($sqls); return $sqls; } - private function createDeleteSQL(ClassMetadata $metadata, Person $from, $field): string + protected function createDeleteSQL(ClassMetadata $metadata, Person $from, $field): string { $mapping = $metadata->getAssociationMapping($field); @@ -146,41 +137,26 @@ class PersonMove ); } - private function createMoveSQL(ClassMetadata $metadata, Person $from, Person $to, $field): string + protected function createMoveSQL(ClassMetadata $metadata, Person $from, Person $to, $field): string { $mapping = $metadata->getAssociationMapping($field); // Set part of the query, aka in "UPDATE table SET " $sets = []; + + foreach ($mapping['joinColumns'] as $columns) { + $sets[] = sprintf('%s = %d', $columns['name'], $to->getId()); + } + $conditions = []; - dump($mapping); - if (array_key_exists('joinTable', $mapping)) { - $tableName = (null !== ($mapping['joinTable']['schema'] ?? null) ? $mapping['joinTable']['schema'] . '.' : '') - . $mapping['joinTable']['name']; - - foreach ($mapping['joinTable']['inverseJoinColumns'] as $columns) { - $sets[] = sprintf('%s = %d', $columns['name'], $to->getId()); - } - - foreach ($mapping['joinTable']['inverseJoinColumns'] as $columns) { - $conditions[] = sprintf('%s = %d', $columns['name'], $from->getId()); - } - } elseif (array_key_exists('joinColumns', $mapping)) { - $tableName = $this->getTableName($metadata); - foreach ($mapping['joinColumns'] as $columns) { - $sets[] = sprintf('%s = %d', $columns['name'], $to->getId()); - } - - - foreach ($mapping['joinColumns'] as $columns) { - $conditions[] = sprintf('%s = %d', $columns['name'], $from->getId()); - } + foreach ($mapping['joinColumns'] as $columns) { + $conditions[] = sprintf('%s = %d', $columns['name'], $from->getId()); } return sprintf( 'UPDATE %s SET %s WHERE %s', - $tableName, + $this->getTableName($metadata), implode(' ', $sets), implode(' AND ', $conditions) ); @@ -190,23 +166,10 @@ class PersonMove * return an array of classes where entities should be deleted * instead of moved. */ - private function getDeleteEntities(): array + protected function getDeleteEntities(): array { return [ - Person\PersonCenterHistory::class, - HouseholdMember::class, - AccompanyingPeriodParticipation::class, - AccompanyingPeriod\AccompanyingPeriodWork::class, - Relationship::class - ]; - } - - private function getIgnoredEntities(): array - { - return [ - Person\PersonCurrentAddress::class, - PersonHouseholdAddress::class, - Person\PersonCenterCurrent::class, + AccompanyingPeriod::class, ]; } diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php b/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php index ab353c83e..928112d2e 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php @@ -247,7 +247,7 @@ class PersonDuplicateController extends Controller ); $duplicatePersons = $this->similarPersonMatcher-> - matchPerson($person, 0.5, SimilarPersonMatcher::SIMILAR_SEARCH_ORDER_BY_ALPHABETICAL, false, $personNotDuplicateRepository); + matchPerson($person, $personNotDuplicateRepository, 0.5, SimilarPersonMatcher::SIMILAR_SEARCH_ORDER_BY_ALPHABETICAL); $notDuplicatePersons = $personNotDuplicateRepository->findNotDuplicatePerson($person); @@ -264,14 +264,14 @@ class PersonDuplicateController extends Controller $nb_activity = $em->getRepository(Activity::class)->findBy(['person' => $id]); $nb_document = $em->getRepository(PersonDocument::class)->findBy(['person' => $id]); -// $nb_event = $em->getRepository(Participation::class)->findBy(['person' => $id]); + $nb_event = $em->getRepository(Participation::class)->findBy(['person' => $id]); $nb_task = $em->getRepository(SingleTask::class)->countByParameters(['person' => $id]); $person = $em->getRepository(Person::class)->findOneBy(['id' => $id]); return [ 'nb_activity' => count($nb_activity), 'nb_document' => count($nb_document), -// 'nb_event' => count($nb_event), + 'nb_event' => count($nb_event), 'nb_task' => $nb_task, 'nb_addresses' => count($person->getAddresses()), ]; diff --git a/src/Bundle/ChillPersonBundle/Menu/PersonMenuBuilder.php b/src/Bundle/ChillPersonBundle/Menu/PersonMenuBuilder.php index b7934c2b2..39ac557fb 100644 --- a/src/Bundle/ChillPersonBundle/Menu/PersonMenuBuilder.php +++ b/src/Bundle/ChillPersonBundle/Menu/PersonMenuBuilder.php @@ -15,7 +15,6 @@ use Chill\MainBundle\Routing\LocalMenuBuilderInterface; use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Repository\ResidentialAddressRepository; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; -use Chill\PersonBundle\Security\Authorization\PersonVoter; use Knp\Menu\MenuItem; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\Security\Core\Security; @@ -107,19 +106,17 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface ->setExtras([ 'order' => 99999, ]); - - if ($this->security->isGranted(PersonVoter::DUPLICATE, $parameters['person'])) { - $menu->addChild($this->translator->trans('Person duplicate'), [ - 'route' => 'chill_person_duplicate_view', - 'routeParameters' => [ - 'person_id' => $parameters['person']->getId(), - ], - ]) - ->setExtras([ - 'order' => 99999, - ]); - } - + /* + $menu->addChild($this->translator->trans('Person duplicate'), [ + 'route' => 'chill_person_duplicate_view', + 'routeParameters' => [ + 'person_id' => $parameters['person']->getId(), + ], + ]) + ->setExtras([ + 'order' => 99999, + ]); + */ if ( 'visible' === $this->showAccompanyingPeriod && $this->security->isGranted(AccompanyingPeriodVoter::SEE, $parameters['person']) diff --git a/src/Bundle/ChillPersonBundle/Resources/views/PersonDuplicate/_sidepane.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/PersonDuplicate/_sidepane.html.twig index 1e770062a..660fff7a6 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/PersonDuplicate/_sidepane.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/PersonDuplicate/_sidepane.html.twig @@ -39,7 +39,7 @@
  • {{ person.counters.nb_activity }} {{ (person.counters.nb_activity > 1)? 'échanges' : 'échange' }}
  • {{ person.counters.nb_task }} {{ (person.counters.nb_task > 1)? 'tâches' : 'tâche' }}
  • {{ person.counters.nb_document }} {{ (person.counters.nb_document > 1)? 'documents' : 'document' }}
  • -{#
  • {{ person.counters.nb_event }} {{ (person.counters.nb_event > 1)? 'événements' : 'événement' }}
  • #} +
  • {{ person.counters.nb_event }} {{ (person.counters.nb_event > 1)? 'événements' : 'événement' }}
  • {{ person.counters.nb_addresses }} {{ (person.counters.nb_addresses > 1)? 'adresses' : 'adresse' }}
  • diff --git a/src/Bundle/ChillPersonBundle/Resources/views/PersonDuplicate/confirm.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/PersonDuplicate/confirm.html.twig index 218b89f2a..304e78eb3 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/PersonDuplicate/confirm.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/PersonDuplicate/confirm.html.twig @@ -25,7 +25,7 @@

    {{ 'Merge duplicate persons folders'|trans }}

    -
    +

    {{ 'Old person'|trans }}: {{ 'Old person explain'|trans }}

    @@ -43,7 +43,7 @@
    -
    +

    {{ 'New person'|trans }}: {{ 'New person explain'|trans }}

    @@ -63,10 +63,10 @@ {{ form_start(form) }} -
    +
    -
    +
    {{ form_widget(form.confirm) }}
    From 04359f27c6d1563b840980aae56be0ead9d271f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 24 May 2023 13:11:40 +0200 Subject: [PATCH 085/724] Revert "Revert "FIX [duplicates] reinstate gestion des doublons"" This reverts commit 5109490aad0a0c12db9a8f4c3729de11a131f6bd. --- .../Actions/Remove/PersonMove.php | 69 ++++++++++++++----- .../Controller/PersonDuplicateController.php | 6 +- .../Menu/PersonMenuBuilder.php | 25 ++++--- .../views/PersonDuplicate/_sidepane.html.twig | 2 +- .../views/PersonDuplicate/confirm.html.twig | 8 +-- 5 files changed, 75 insertions(+), 35 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Actions/Remove/PersonMove.php b/src/Bundle/ChillPersonBundle/Actions/Remove/PersonMove.php index 13a62094d..8363134fd 100644 --- a/src/Bundle/ChillPersonBundle/Actions/Remove/PersonMove.php +++ b/src/Bundle/ChillPersonBundle/Actions/Remove/PersonMove.php @@ -13,7 +13,11 @@ namespace Chill\PersonBundle\Actions\Remove; use Chill\PersonBundle\Actions\ActionEvent; use Chill\PersonBundle\Entity\AccompanyingPeriod; +use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation; +use Chill\PersonBundle\Entity\Household\HouseholdMember; +use Chill\PersonBundle\Entity\Household\PersonHouseholdAddress; use Chill\PersonBundle\Entity\Person; +use Chill\PersonBundle\Entity\Relationships\Relationship; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Mapping\ClassMetadata; use Symfony\Component\EventDispatcher\EventDispatcherInterface; @@ -42,9 +46,10 @@ class PersonMove protected $eventDispatcher; public function __construct( - EntityManagerInterface $em, + EntityManagerInterface $em, EventDispatcherInterface $eventDispatcher - ) { + ) + { $this->em = $em; $this->eventDispatcher = $eventDispatcher; } @@ -84,8 +89,11 @@ class PersonMove } foreach ($metadata->getAssociationMappings() as $field => $mapping) { - if (Person::class === $mapping['targetEntity']) { - if (in_array($metadata->getName(), $toDelete, true)) { + if (in_array($mapping['sourceEntity'], $this->getIgnoredEntities())) { + continue; + } + if (Person::class === $mapping['targetEntity'] and true === $mapping['isOwningSide']) { + if (in_array($mapping['sourceEntity'], $toDelete, true)) { $sql = $this->createDeleteSQL($metadata, $from, $field); $event = new ActionEvent( $from->getId(), @@ -117,10 +125,11 @@ class PersonMove $from->getId() ); + dump($sqls); return $sqls; } - protected function createDeleteSQL(ClassMetadata $metadata, Person $from, $field): string + private function createDeleteSQL(ClassMetadata $metadata, Person $from, $field): string { $mapping = $metadata->getAssociationMapping($field); @@ -137,26 +146,41 @@ class PersonMove ); } - protected function createMoveSQL(ClassMetadata $metadata, Person $from, Person $to, $field): string + private function createMoveSQL(ClassMetadata $metadata, Person $from, Person $to, $field): string { $mapping = $metadata->getAssociationMapping($field); // Set part of the query, aka in "UPDATE table SET " $sets = []; - - foreach ($mapping['joinColumns'] as $columns) { - $sets[] = sprintf('%s = %d', $columns['name'], $to->getId()); - } - $conditions = []; + dump($mapping); - foreach ($mapping['joinColumns'] as $columns) { - $conditions[] = sprintf('%s = %d', $columns['name'], $from->getId()); + if (array_key_exists('joinTable', $mapping)) { + $tableName = (null !== ($mapping['joinTable']['schema'] ?? null) ? $mapping['joinTable']['schema'] . '.' : '') + . $mapping['joinTable']['name']; + + foreach ($mapping['joinTable']['inverseJoinColumns'] as $columns) { + $sets[] = sprintf('%s = %d', $columns['name'], $to->getId()); + } + + foreach ($mapping['joinTable']['inverseJoinColumns'] as $columns) { + $conditions[] = sprintf('%s = %d', $columns['name'], $from->getId()); + } + } elseif (array_key_exists('joinColumns', $mapping)) { + $tableName = $this->getTableName($metadata); + foreach ($mapping['joinColumns'] as $columns) { + $sets[] = sprintf('%s = %d', $columns['name'], $to->getId()); + } + + + foreach ($mapping['joinColumns'] as $columns) { + $conditions[] = sprintf('%s = %d', $columns['name'], $from->getId()); + } } return sprintf( 'UPDATE %s SET %s WHERE %s', - $this->getTableName($metadata), + $tableName, implode(' ', $sets), implode(' AND ', $conditions) ); @@ -166,10 +190,23 @@ class PersonMove * return an array of classes where entities should be deleted * instead of moved. */ - protected function getDeleteEntities(): array + private function getDeleteEntities(): array { return [ - AccompanyingPeriod::class, + Person\PersonCenterHistory::class, + HouseholdMember::class, + AccompanyingPeriodParticipation::class, + AccompanyingPeriod\AccompanyingPeriodWork::class, + Relationship::class + ]; + } + + private function getIgnoredEntities(): array + { + return [ + Person\PersonCurrentAddress::class, + PersonHouseholdAddress::class, + Person\PersonCenterCurrent::class, ]; } diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php b/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php index 928112d2e..ab353c83e 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php @@ -247,7 +247,7 @@ class PersonDuplicateController extends Controller ); $duplicatePersons = $this->similarPersonMatcher-> - matchPerson($person, $personNotDuplicateRepository, 0.5, SimilarPersonMatcher::SIMILAR_SEARCH_ORDER_BY_ALPHABETICAL); + matchPerson($person, 0.5, SimilarPersonMatcher::SIMILAR_SEARCH_ORDER_BY_ALPHABETICAL, false, $personNotDuplicateRepository); $notDuplicatePersons = $personNotDuplicateRepository->findNotDuplicatePerson($person); @@ -264,14 +264,14 @@ class PersonDuplicateController extends Controller $nb_activity = $em->getRepository(Activity::class)->findBy(['person' => $id]); $nb_document = $em->getRepository(PersonDocument::class)->findBy(['person' => $id]); - $nb_event = $em->getRepository(Participation::class)->findBy(['person' => $id]); +// $nb_event = $em->getRepository(Participation::class)->findBy(['person' => $id]); $nb_task = $em->getRepository(SingleTask::class)->countByParameters(['person' => $id]); $person = $em->getRepository(Person::class)->findOneBy(['id' => $id]); return [ 'nb_activity' => count($nb_activity), 'nb_document' => count($nb_document), - 'nb_event' => count($nb_event), +// 'nb_event' => count($nb_event), 'nb_task' => $nb_task, 'nb_addresses' => count($person->getAddresses()), ]; diff --git a/src/Bundle/ChillPersonBundle/Menu/PersonMenuBuilder.php b/src/Bundle/ChillPersonBundle/Menu/PersonMenuBuilder.php index 39ac557fb..b7934c2b2 100644 --- a/src/Bundle/ChillPersonBundle/Menu/PersonMenuBuilder.php +++ b/src/Bundle/ChillPersonBundle/Menu/PersonMenuBuilder.php @@ -15,6 +15,7 @@ use Chill\MainBundle\Routing\LocalMenuBuilderInterface; use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Repository\ResidentialAddressRepository; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; +use Chill\PersonBundle\Security\Authorization\PersonVoter; use Knp\Menu\MenuItem; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\Security\Core\Security; @@ -106,17 +107,19 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface ->setExtras([ 'order' => 99999, ]); - /* - $menu->addChild($this->translator->trans('Person duplicate'), [ - 'route' => 'chill_person_duplicate_view', - 'routeParameters' => [ - 'person_id' => $parameters['person']->getId(), - ], - ]) - ->setExtras([ - 'order' => 99999, - ]); - */ + + if ($this->security->isGranted(PersonVoter::DUPLICATE, $parameters['person'])) { + $menu->addChild($this->translator->trans('Person duplicate'), [ + 'route' => 'chill_person_duplicate_view', + 'routeParameters' => [ + 'person_id' => $parameters['person']->getId(), + ], + ]) + ->setExtras([ + 'order' => 99999, + ]); + } + if ( 'visible' === $this->showAccompanyingPeriod && $this->security->isGranted(AccompanyingPeriodVoter::SEE, $parameters['person']) diff --git a/src/Bundle/ChillPersonBundle/Resources/views/PersonDuplicate/_sidepane.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/PersonDuplicate/_sidepane.html.twig index 660fff7a6..1e770062a 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/PersonDuplicate/_sidepane.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/PersonDuplicate/_sidepane.html.twig @@ -39,7 +39,7 @@
  • {{ person.counters.nb_activity }} {{ (person.counters.nb_activity > 1)? 'échanges' : 'échange' }}
  • {{ person.counters.nb_task }} {{ (person.counters.nb_task > 1)? 'tâches' : 'tâche' }}
  • {{ person.counters.nb_document }} {{ (person.counters.nb_document > 1)? 'documents' : 'document' }}
  • -
  • {{ person.counters.nb_event }} {{ (person.counters.nb_event > 1)? 'événements' : 'événement' }}
  • +{#
  • {{ person.counters.nb_event }} {{ (person.counters.nb_event > 1)? 'événements' : 'événement' }}
  • #}
  • {{ person.counters.nb_addresses }} {{ (person.counters.nb_addresses > 1)? 'adresses' : 'adresse' }}
  • diff --git a/src/Bundle/ChillPersonBundle/Resources/views/PersonDuplicate/confirm.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/PersonDuplicate/confirm.html.twig index 304e78eb3..218b89f2a 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/PersonDuplicate/confirm.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/PersonDuplicate/confirm.html.twig @@ -25,7 +25,7 @@

    {{ 'Merge duplicate persons folders'|trans }}

    -
    +

    {{ 'Old person'|trans }}: {{ 'Old person explain'|trans }}

    @@ -43,7 +43,7 @@
    -
    +

    {{ 'New person'|trans }}: {{ 'New person explain'|trans }}

    @@ -63,10 +63,10 @@ {{ form_start(form) }} -
    +
    -
    +
    {{ form_widget(form.confirm) }}
    From d82a3e0ff6e57ebb1a763d5aa2c995bda6b78797 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 24 May 2023 12:06:07 +0200 Subject: [PATCH 086/724] Fixed: [download document] add a target when downloading document --- .../public/vuejs/StoredObjectButton/DownloadButton.vue | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Bundle/ChillDocStoreBundle/Resources/public/vuejs/StoredObjectButton/DownloadButton.vue b/src/Bundle/ChillDocStoreBundle/Resources/public/vuejs/StoredObjectButton/DownloadButton.vue index 98645873b..b22035bee 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/public/vuejs/StoredObjectButton/DownloadButton.vue +++ b/src/Bundle/ChillDocStoreBundle/Resources/public/vuejs/StoredObjectButton/DownloadButton.vue @@ -34,6 +34,7 @@ async function download_and_open(event: Event): Promise { const raw = await download_and_decrypt_doc(urlInfo, props.storedObject.keyInfos, new Uint8Array(props.storedObject.iv)); button.href = window.URL.createObjectURL(raw); + button.target = '_blank'; button.type = props.storedObject.type; button.download = props.filename || 'document'; @@ -45,10 +46,7 @@ async function download_and_open(event: Event): Promise { state.is_ready = true; - // for fixing https://gitlab.com/Chill-Projet/chill-bundles/-/issues/98 - window.setTimeout(() => { - button.click() - }, 750); + button.click(); } } From 20023dff671ea7457a5c56c0f94f4e3b7b70d55e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 24 May 2023 13:35:35 +0200 Subject: [PATCH 087/724] DX: fix cs --- .../ChillActivityBundle/Controller/ActivityController.php | 4 ++-- src/Bundle/ChillActivityBundle/Menu/PersonMenuBuilder.php | 4 ++-- src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php index 97678af50..444c663fc 100644 --- a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php +++ b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php @@ -650,8 +650,8 @@ final class ActivityController extends AbstractController throw $this->createNotFoundException('Accompanying Period not found'); } - // TODO Add permission - // $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person); + // TODO Add permission + // $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person); } else { throw $this->createNotFoundException('Person or Accompanying Period not found'); } diff --git a/src/Bundle/ChillActivityBundle/Menu/PersonMenuBuilder.php b/src/Bundle/ChillActivityBundle/Menu/PersonMenuBuilder.php index 03a1b09ab..a3cebec38 100644 --- a/src/Bundle/ChillActivityBundle/Menu/PersonMenuBuilder.php +++ b/src/Bundle/ChillActivityBundle/Menu/PersonMenuBuilder.php @@ -26,12 +26,12 @@ final class PersonMenuBuilder implements LocalMenuBuilderInterface /** * @var AuthorizationCheckerInterface */ - protected $authorizationChecker; + private $authorizationChecker; /** * @var TranslatorInterface */ - protected $translator; + private $translator; public function __construct( AuthorizationCheckerInterface $authorizationChecker, diff --git a/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php b/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php index b1446a543..6c4984f33 100644 --- a/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php +++ b/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php @@ -117,7 +117,7 @@ class ThirdPartyType extends AbstractType 'label' => 'thirdparty.Contact data are confidential', ]); - // Institutional ThirdParty (parent) + // Institutional ThirdParty (parent) } else { $builder ->add('nameCompany', TextType::class, [ From a31c4063a19dfc27e3bb4f8502f05c06ed650b3e Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 24 May 2023 14:02:05 +0200 Subject: [PATCH 088/724] DX [cs-fixer] fixes --- .../Command/SynchronizeEntityInfoViewsCommand.php | 1 - .../Controller/PermissionsGroupController.php | 1 - .../ChillMainBundle/Controller/UserExportController.php | 1 - .../AccompanyingPeriodStepChangeMessageHandler.php | 1 - .../Lifecycle/AccompanyingPeriodStepChangeRequestor.php | 1 - .../Export/Export/ListHouseholdInPeriod.php | 1 - .../AccompanyingPeriod/AccompanyingPeriodInfoRepository.php | 1 - .../Lifecycle/AccompanyingPeriodStepChangeCronjobTest.php | 1 - .../Filter/SocialWorkFilters/SocialWorkTypeFilterTest.php | 6 +----- 9 files changed, 1 insertion(+), 13 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Command/SynchronizeEntityInfoViewsCommand.php b/src/Bundle/ChillMainBundle/Command/SynchronizeEntityInfoViewsCommand.php index c3dc8a87c..05fefe20f 100644 --- a/src/Bundle/ChillMainBundle/Command/SynchronizeEntityInfoViewsCommand.php +++ b/src/Bundle/ChillMainBundle/Command/SynchronizeEntityInfoViewsCommand.php @@ -36,5 +36,4 @@ class SynchronizeEntityInfoViewsCommand extends Command return 0; } - } diff --git a/src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php b/src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php index 488092931..97e80916c 100644 --- a/src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php +++ b/src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php @@ -163,7 +163,6 @@ final class PermissionsGroupController extends AbstractController */ public function deleteLinkRoleScopeAction(int $pgid, int $rsid): Response { - $permissionsGroup = $this->permissionsGroupRepository->find($pgid); $roleScope = $this->roleScopeRepository->find($rsid); diff --git a/src/Bundle/ChillMainBundle/Controller/UserExportController.php b/src/Bundle/ChillMainBundle/Controller/UserExportController.php index dc2674dbb..530ac19b7 100644 --- a/src/Bundle/ChillMainBundle/Controller/UserExportController.php +++ b/src/Bundle/ChillMainBundle/Controller/UserExportController.php @@ -141,5 +141,4 @@ final readonly class UserExportController ] ); } - } diff --git a/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Lifecycle/AccompanyingPeriodStepChangeMessageHandler.php b/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Lifecycle/AccompanyingPeriodStepChangeMessageHandler.php index 881b3999a..4a9873c6d 100644 --- a/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Lifecycle/AccompanyingPeriodStepChangeMessageHandler.php +++ b/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Lifecycle/AccompanyingPeriodStepChangeMessageHandler.php @@ -34,5 +34,4 @@ class AccompanyingPeriodStepChangeMessageHandler implements MessageHandlerInterf ($this->changer)($period, $message->getTransition()); } - } diff --git a/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Lifecycle/AccompanyingPeriodStepChangeRequestor.php b/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Lifecycle/AccompanyingPeriodStepChangeRequestor.php index 3d4979608..f1c3563fc 100644 --- a/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Lifecycle/AccompanyingPeriodStepChangeRequestor.php +++ b/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Lifecycle/AccompanyingPeriodStepChangeRequestor.php @@ -84,5 +84,4 @@ class AccompanyingPeriodStepChangeRequestor $this->messageBus->dispatch(new AccompanyingPeriodStepChangeRequestMessage($accompanyingPeriodId, 'mark_active')); } } - } diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListHouseholdInPeriod.php b/src/Bundle/ChillPersonBundle/Export/Export/ListHouseholdInPeriod.php index 24d929c00..8894d145d 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListHouseholdInPeriod.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListHouseholdInPeriod.php @@ -107,7 +107,6 @@ class ListHouseholdInPeriod implements ListInterface, GroupedExportInterface return $this->aggregateStringHelper->getLabelMulti($key, $values, 'export.list.household.' . $key); case 'compositionType': - //dump($values); return $this->translatableStringHelper->getLabel($key, $values, 'export.list.household.' . $key); default: diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodInfoRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodInfoRepository.php index 57925b131..0296d00f1 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodInfoRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodInfoRepository.php @@ -89,5 +89,4 @@ readonly class AccompanyingPeriodInfoRepository implements AccompanyingPeriodInf { return AccompanyingPeriodInfo::class; } - } diff --git a/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/Lifecycle/AccompanyingPeriodStepChangeCronjobTest.php b/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/Lifecycle/AccompanyingPeriodStepChangeCronjobTest.php index 5c3c29179..5a5b50dbb 100644 --- a/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/Lifecycle/AccompanyingPeriodStepChangeCronjobTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/Lifecycle/AccompanyingPeriodStepChangeCronjobTest.php @@ -51,5 +51,4 @@ class AccompanyingPeriodStepChangeCronjobTest extends TestCase // can not run: not enough elapsed time yield ['2023-01-15T01:00:00+02:00', new \DateTimeImmutable('2023-01-15T00:30:00+02:00'), false]; } - } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialWorkFilters/SocialWorkTypeFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialWorkFilters/SocialWorkTypeFilterTest.php index f462bc47e..5287ab844 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialWorkFilters/SocialWorkTypeFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialWorkFilters/SocialWorkTypeFilterTest.php @@ -78,17 +78,13 @@ final class SocialWorkTypeFilterTest extends AbstractFilterTest $goals = array_unique($goals); $results = array_unique($results); - $data = [ + return [ [ 'actionType' => implode(',', $actions), 'goal' => implode(',', $goals), 'result' => implode(',', $results), ], ]; - /// TODO ne fonctionne pas - var_dump($data); - - return $data; } public function getQueryBuilders(): array From f5448f9d95babf82d972d3ccc31eb0430cc4d9c7 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 24 May 2023 14:02:49 +0200 Subject: [PATCH 089/724] DX [phpstan] fixes --- .../ChillPersonBundle/Actions/Remove/PersonMove.php | 8 +++----- .../Controller/PersonDuplicateController.php | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Actions/Remove/PersonMove.php b/src/Bundle/ChillPersonBundle/Actions/Remove/PersonMove.php index 8363134fd..4e2f7468e 100644 --- a/src/Bundle/ChillPersonBundle/Actions/Remove/PersonMove.php +++ b/src/Bundle/ChillPersonBundle/Actions/Remove/PersonMove.php @@ -48,8 +48,7 @@ class PersonMove public function __construct( EntityManagerInterface $em, EventDispatcherInterface $eventDispatcher - ) - { + ) { $this->em = $em; $this->eventDispatcher = $eventDispatcher; } @@ -89,7 +88,7 @@ class PersonMove } foreach ($metadata->getAssociationMappings() as $field => $mapping) { - if (in_array($mapping['sourceEntity'], $this->getIgnoredEntities())) { + if (in_array($mapping['sourceEntity'], $this->getIgnoredEntities(), true)) { continue; } if (Person::class === $mapping['targetEntity'] and true === $mapping['isOwningSide']) { @@ -125,7 +124,6 @@ class PersonMove $from->getId() ); - dump($sqls); return $sqls; } @@ -153,7 +151,7 @@ class PersonMove // Set part of the query, aka in "UPDATE table SET " $sets = []; $conditions = []; - dump($mapping); + $tableName = ''; if (array_key_exists('joinTable', $mapping)) { $tableName = (null !== ($mapping['joinTable']['schema'] ?? null) ? $mapping['joinTable']['schema'] . '.' : '') diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php b/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php index ab353c83e..386e55039 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php @@ -247,7 +247,7 @@ class PersonDuplicateController extends Controller ); $duplicatePersons = $this->similarPersonMatcher-> - matchPerson($person, 0.5, SimilarPersonMatcher::SIMILAR_SEARCH_ORDER_BY_ALPHABETICAL, false, $personNotDuplicateRepository); + matchPerson($person, 0.5, SimilarPersonMatcher::SIMILAR_SEARCH_ORDER_BY_ALPHABETICAL, false); $notDuplicatePersons = $personNotDuplicateRepository->findNotDuplicatePerson($person); @@ -271,7 +271,7 @@ class PersonDuplicateController extends Controller return [ 'nb_activity' => count($nb_activity), 'nb_document' => count($nb_document), -// 'nb_event' => count($nb_event), + // 'nb_event' => count($nb_event), 'nb_task' => $nb_task, 'nb_addresses' => count($person->getAddresses()), ]; From 664bf743f933b50db3ded4ce281ff8c973ed8fb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 24 May 2023 15:08:59 +0200 Subject: [PATCH 090/724] Fix: force list of activities to be a list with incremental keys --- ...tActivitiesByAccompanyingPeriodContext.php | 34 ++++++++++++------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Service/DocGenerator/ListActivitiesByAccompanyingPeriodContext.php b/src/Bundle/ChillActivityBundle/Service/DocGenerator/ListActivitiesByAccompanyingPeriodContext.php index 3da451f2e..045d09beb 100644 --- a/src/Bundle/ChillActivityBundle/Service/DocGenerator/ListActivitiesByAccompanyingPeriodContext.php +++ b/src/Bundle/ChillActivityBundle/Service/DocGenerator/ListActivitiesByAccompanyingPeriodContext.php @@ -140,26 +140,36 @@ class ListActivitiesByAccompanyingPeriodContext implements return $normalized; } + /** + * @return list + */ private function filterActivitiesByUser(array $activities, User $user): array { - return array_filter( - $activities, - function ($activity) use ($user) { - $activityUsernames = array_map(static fn ($user) => $user['username'], $activity['users'] ?? []); - return in_array($user->getUsername(), $activityUsernames, true); - } + return array_values( + array_filter( + $activities, + function ($activity) use ($user) { + $activityUsernames = array_map(static fn ($user) => $user['username'], $activity['users'] ?? []); + return in_array($user->getUsername(), $activityUsernames, true); + } + ) ); } + /** + * @return list + */ private function filterWorksByUser(array $works, User $user): array { - return array_filter( - $works, - function ($work) use ($user) { - $workUsernames = array_map(static fn ($user) => $user['username'], $work['referrers'] ?? []); + return array_values( + array_filter( + $works, + function ($work) use ($user) { + $workUsernames = array_map(static fn ($user) => $user['username'], $work['referrers'] ?? []); - return in_array($user->getUsername(), $workUsernames, true); - } + return in_array($user->getUsername(), $workUsernames, true); + } + ) ); } From dad36927f31fd9e707e052ccba57366e5c01d29f Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 24 May 2023 15:34:39 +0200 Subject: [PATCH 091/724] FEATURE [export] uncheck all centers button --- .../views/Export/new_centers_step.html.twig | 17 +++++++++++++++++ .../translations/messages.fr.yml | 2 ++ 2 files changed, 19 insertions(+) diff --git a/src/Bundle/ChillMainBundle/Resources/views/Export/new_centers_step.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Export/new_centers_step.html.twig index 9e37dc2cd..40366669c 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Export/new_centers_step.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Export/new_centers_step.html.twig @@ -39,8 +39,13 @@ {{ 'This will eventually restrict your possibilities in filtering the data.'|trans }}

    {{ 'Center'|trans }}

    + {{ form_widget(form.centers.center) }} +
    + +
    + {% if form.centers.regroupment is defined %}

    {{ 'Pick aggregated centers'|trans }}

    {{ form_widget(form.centers.regroupment) }} @@ -53,3 +58,15 @@
    {% endblock content %} + +{% block js %} + + + +{% endblock js %} diff --git a/src/Bundle/ChillMainBundle/translations/messages.fr.yml b/src/Bundle/ChillMainBundle/translations/messages.fr.yml index 13c300fdd..fa28feef6 100644 --- a/src/Bundle/ChillMainBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillMainBundle/translations/messages.fr.yml @@ -285,6 +285,8 @@ The export will contains only data from the picked centers.: L'export ne contien This will eventually restrict your possibilities in filtering the data.: Les possibilités de filtrages seront adaptées aux droits de consultation pour les centres choisis. Go to export options: Vers la préparation de l'export Pick aggregated centers: Regroupement de centres +uncheck all: Désélectionner tout les centres +check all: Sélectionner tout les centres # export creation step 'export' : choose aggregators, filtering and formatter Formatter: Mise en forme Choose the formatter: Choisissez le format d'export voulu. From 6e618e688bf4b593702212559277a9aaed02bfcf Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 24 May 2023 15:50:25 +0200 Subject: [PATCH 092/724] DX [php-cs-fixer] --- .../ChillActivityBundle/Controller/ActivityController.php | 4 ++-- src/Bundle/ChillActivityBundle/Menu/PersonMenuBuilder.php | 4 ++-- .../Controller/PersonDuplicateController.php | 2 +- src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php index 97678af50..444c663fc 100644 --- a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php +++ b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php @@ -650,8 +650,8 @@ final class ActivityController extends AbstractController throw $this->createNotFoundException('Accompanying Period not found'); } - // TODO Add permission - // $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person); + // TODO Add permission + // $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person); } else { throw $this->createNotFoundException('Person or Accompanying Period not found'); } diff --git a/src/Bundle/ChillActivityBundle/Menu/PersonMenuBuilder.php b/src/Bundle/ChillActivityBundle/Menu/PersonMenuBuilder.php index 03a1b09ab..a3cebec38 100644 --- a/src/Bundle/ChillActivityBundle/Menu/PersonMenuBuilder.php +++ b/src/Bundle/ChillActivityBundle/Menu/PersonMenuBuilder.php @@ -26,12 +26,12 @@ final class PersonMenuBuilder implements LocalMenuBuilderInterface /** * @var AuthorizationCheckerInterface */ - protected $authorizationChecker; + private $authorizationChecker; /** * @var TranslatorInterface */ - protected $translator; + private $translator; public function __construct( AuthorizationCheckerInterface $authorizationChecker, diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php b/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php index 386e55039..7ade542e0 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php @@ -264,7 +264,7 @@ class PersonDuplicateController extends Controller $nb_activity = $em->getRepository(Activity::class)->findBy(['person' => $id]); $nb_document = $em->getRepository(PersonDocument::class)->findBy(['person' => $id]); -// $nb_event = $em->getRepository(Participation::class)->findBy(['person' => $id]); + // $nb_event = $em->getRepository(Participation::class)->findBy(['person' => $id]); $nb_task = $em->getRepository(SingleTask::class)->countByParameters(['person' => $id]); $person = $em->getRepository(Person::class)->findOneBy(['id' => $id]); diff --git a/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php b/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php index b1446a543..6c4984f33 100644 --- a/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php +++ b/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php @@ -117,7 +117,7 @@ class ThirdPartyType extends AbstractType 'label' => 'thirdparty.Contact data are confidential', ]); - // Institutional ThirdParty (parent) + // Institutional ThirdParty (parent) } else { $builder ->add('nameCompany', TextType::class, [ From 77997e2b6f9b6512e1dcb16c9baac9ff928fbd97 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 24 May 2023 16:24:58 +0200 Subject: [PATCH 093/724] FIX [review] fix review comments --- .../Resources/views/Export/new_centers_step.html.twig | 6 +++--- src/Bundle/ChillMainBundle/translations/messages.fr.yml | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Resources/views/Export/new_centers_step.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Export/new_centers_step.html.twig index 40366669c..2e2dc0ec6 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Export/new_centers_step.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Export/new_centers_step.html.twig @@ -43,7 +43,7 @@ {{ form_widget(form.centers.center) }}
    - +
    {% if form.centers.regroupment is defined %} @@ -63,9 +63,9 @@ diff --git a/src/Bundle/ChillMainBundle/translations/messages.fr.yml b/src/Bundle/ChillMainBundle/translations/messages.fr.yml index fa28feef6..78de523c4 100644 --- a/src/Bundle/ChillMainBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillMainBundle/translations/messages.fr.yml @@ -285,8 +285,8 @@ The export will contains only data from the picked centers.: L'export ne contien This will eventually restrict your possibilities in filtering the data.: Les possibilités de filtrages seront adaptées aux droits de consultation pour les centres choisis. Go to export options: Vers la préparation de l'export Pick aggregated centers: Regroupement de centres -uncheck all: Désélectionner tout les centres -check all: Sélectionner tout les centres +uncheck all centers: Désélectionner tous les centres +check all centers: Sélectionner tous les centres # export creation step 'export' : choose aggregators, filtering and formatter Formatter: Mise en forme Choose the formatter: Choisissez le format d'export voulu. From afcd6e0605674312c7b9ce557bed4b9330947ea7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 23 May 2023 22:12:18 +0200 Subject: [PATCH 094/724] bootstrap generic doc manager and associated services --- ...ericDocForAccompanyingPeriodController.php | 48 +++++ .../GenericDoc/FetchQuery.php | 168 ++++++++++++++++++ .../GenericDoc/FetchQueryInterface.php | 45 +++++ .../GenericDoc/FetchQueryToSqlBuilder.php | 48 +++++ .../GenericDoc/GenericDocDTO.php | 22 +++ .../GenericDoc/Manager.php | 102 +++++++++++ ...ProviderForAccompanyingPeriodInterface.php | 33 ++++ .../GenericDoc/FetchQueryToSqlBuilderTest.php | 57 ++++++ .../Tests/GenericDoc/ManagerTest.php | 56 ++++++ .../ChillDocStoreBundle/config/services.yaml | 6 + 10 files changed, 585 insertions(+) create mode 100644 src/Bundle/ChillDocStoreBundle/Controller/GenericDocForAccompanyingPeriodController.php create mode 100644 src/Bundle/ChillDocStoreBundle/GenericDoc/FetchQuery.php create mode 100644 src/Bundle/ChillDocStoreBundle/GenericDoc/FetchQueryInterface.php create mode 100644 src/Bundle/ChillDocStoreBundle/GenericDoc/FetchQueryToSqlBuilder.php create mode 100644 src/Bundle/ChillDocStoreBundle/GenericDoc/GenericDocDTO.php create mode 100644 src/Bundle/ChillDocStoreBundle/GenericDoc/Manager.php create mode 100644 src/Bundle/ChillDocStoreBundle/GenericDoc/ProviderForAccompanyingPeriodInterface.php create mode 100644 src/Bundle/ChillDocStoreBundle/Tests/GenericDoc/FetchQueryToSqlBuilderTest.php create mode 100644 src/Bundle/ChillDocStoreBundle/Tests/GenericDoc/ManagerTest.php diff --git a/src/Bundle/ChillDocStoreBundle/Controller/GenericDocForAccompanyingPeriodController.php b/src/Bundle/ChillDocStoreBundle/Controller/GenericDocForAccompanyingPeriodController.php new file mode 100644 index 000000000..32a7cc1c9 --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/Controller/GenericDocForAccompanyingPeriodController.php @@ -0,0 +1,48 @@ +security->isGranted(AccompanyingCourseDocumentVoter::SEE, $accompanyingPeriod)) { + throw new AccessDeniedHttpException("not allowed to see the documents for accompanying period"); + } + + $nb = $this->manager->countDocForAccompanyingPeriod($accompanyingPeriod); + + return new Response($nb); + } + +} diff --git a/src/Bundle/ChillDocStoreBundle/GenericDoc/FetchQuery.php b/src/Bundle/ChillDocStoreBundle/GenericDoc/FetchQuery.php new file mode 100644 index 000000000..42e0fd335 --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/GenericDoc/FetchQuery.php @@ -0,0 +1,168 @@ + + */ + private array $joins = []; + + /** + * @var list + */ + private array $joinParams = []; + + /** + * @var list + */ + private array $wheres = []; + + /** + * @var list + */ + private array $whereParams = []; + + public function __construct( + private readonly string $selectKeyString, + private readonly string $selectIdentifierJsonB, + private readonly string $selectDate, + private string $from = '', + private array $selectIdentifierParams = [], + private array $selectDateParams = [], + ) { + } + + public function addJoinClause(string $sql, array $params = []): int + { + $this->joins[] = $sql; + $this->joinParams[] = $params; + + return count($this->joins) - 1; + } + + public function addWhereClause(string $sql, array $params = []): int + { + $this->wheres[] = $sql; + $this->whereParams[] = $params; + + return count($this->wheres) - 1; + } + + public function removeWhereClause(int $index): void + { + if (!array_key_exists($index, $this->wheres)) { + throw new \UnexpectedValueException("this index does not exists"); + } + + unset($this->wheres[$index], $this->whereParams[$index]); + + } + + public function removeJoinClause(int $index): void + { + if (!array_key_exists($index, $this->joins)) { + throw new \UnexpectedValueException("this index does not exists"); + } + + unset($this->joins[$index], $this->joinParams[$index]); + + } + + public function getSelectKeyString(): string + { + return $this->selectKeyString; + } + + public function getSelectIdentifierJsonB(): string + { + return $this->selectIdentifierJsonB; + } + + /** + * @inheritDoc + */ + public function getSelectIdentifierParams(): array + { + return $this->selectIdentifierParams; + } + + public function getSelectDate(): string + { + return $this->selectDate; + } + + /** + * @inheritDoc + */ + public function getSelectDateParams(): array + { + return $this->selectDateParams; + } + + public function getFromQuery(): string + { + return $this->from . " " . implode(' ', $this->joins); + } + + /** + * @inheritDoc + */ + public function getFromQueryParams(): array + { + $result = []; + + foreach ($this->joinParams as $params) { + $result = [...$result, ...$params]; + } + + return $result; + } + + public function getWhereQuery(): string + { + return implode(' AND ', $this->wheres); + } + + /** + * @inheritDoc + */ + public function getWhereQueryParams(): array + { + $result = []; + + foreach ($this->whereParams as $params) { + $result = [...$result, ...$params]; + } + + return $result; + } + + /** + * @param array $selectIdentifierParams + */ + public function setSelectIdentifierParams(array $selectIdentifierParams): void + { + $this->selectIdentifierParams = $selectIdentifierParams; + } + + /** + * @param array $selectDateParams + */ + public function setSelectDateParams(array $selectDateParams): void + { + $this->selectDateParams = $selectDateParams; + } +} diff --git a/src/Bundle/ChillDocStoreBundle/GenericDoc/FetchQueryInterface.php b/src/Bundle/ChillDocStoreBundle/GenericDoc/FetchQueryInterface.php new file mode 100644 index 000000000..c262d2a5d --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/GenericDoc/FetchQueryInterface.php @@ -0,0 +1,45 @@ + + */ + public function getSelectIdentifierParams(): array; + + public function getSelectDate(): string; + + /** + * @return list + */ + public function getSelectDateParams(): array; + + public function getFromQuery(): string; + + /** + * @return list + */ + public function getFromQueryParams(): array; + + public function getWhereQuery(): string; + + /** + * @return list + */ + public function getWhereQueryParams(): array; +} diff --git a/src/Bundle/ChillDocStoreBundle/GenericDoc/FetchQueryToSqlBuilder.php b/src/Bundle/ChillDocStoreBundle/GenericDoc/FetchQueryToSqlBuilder.php new file mode 100644 index 000000000..881435da7 --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/GenericDoc/FetchQueryToSqlBuilder.php @@ -0,0 +1,48 @@ +} + */ + public function toSql(FetchQueryInterface $query): array + { + $sql = strtr(self::SQL, [ + '{{ key }}' => $query->getSelectKeyString(), + '{{ identifiers }}' => $query->getSelectIdentifierJsonB(), + '{{ date }}' => $query->getSelectDate(), + '{{ from }}' => $query->getFromQuery(), + '{{ where }}' => $query->getWhereQuery(), + ]); + + $params = [ + ...$query->getSelectIdentifierParams(), + ...$query->getSelectDateParams(), + ...$query->getFromQueryParams(), + ...$query->getWhereQueryParams() + ]; + + return ['sql' => $sql, 'params' => $params]; + } +} diff --git a/src/Bundle/ChillDocStoreBundle/GenericDoc/GenericDocDTO.php b/src/Bundle/ChillDocStoreBundle/GenericDoc/GenericDocDTO.php new file mode 100644 index 000000000..6fb6139aa --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/GenericDoc/GenericDocDTO.php @@ -0,0 +1,22 @@ + + */ + private readonly iterable $providersForAccompanyingPeriod, + private readonly Connection $connection, + ) { + $this->builder = new FetchQueryToSqlBuilder(); + } + + /** + * @throws Exception + */ + public function countDocForAccompanyingPeriod( + AccompanyingPeriod $accompanyingPeriod, + ?\DateTimeImmutable $startDate = null, + ?\DateTimeImmutable $endDate = null, + ?string $content = null, + ?string $origin = null + ): int { + ['sql' => $sql, 'params' => $params] = $this->buildUnionQuery($accompanyingPeriod, $startDate, $endDate, $content, $origin); + $countSql = "SELECT count(*) AS c FROM {$sql} AS sq"; + $result = $this->connection->executeQuery($countSql, $params); + + $number = $result->fetchOne(); + + if (false === $number) { + throw new \UnexpectedValueException("number of documents failed to load"); + } + + return $number['c']; + } + + /** + * @throws Exception + */ + public function findDocForAccompanyingPeriod( + AccompanyingPeriod $accompanyingPeriod, + int $offset = 0, + int $limit = 20, + ?\DateTimeImmutable $startDate = null, + ?\DateTimeImmutable $endDate = null, + ?string $content = null, + ?string $origin = null + ): iterable { + ['sql' => $sql, 'params' => $params] = $this->buildUnionQuery($accompanyingPeriod, $startDate, $endDate, $content, $origin); + + $runSql = "{$sql} LIMIT ? OFFSET ?"; + $runParams = [...$params, ...[$limit, $offset]]; + + foreach($this->connection->iterateAssociative($runSql, $runParams) as $row) { + yield new GenericDocDTO($row['key'], $row['identifiers'], $row['date_doc']); + } + } + + /** + */ + private function buildUnionQuery( + AccompanyingPeriod|Person $linked, + ?\DateTimeImmutable $startDate = null, + ?\DateTimeImmutable $endDate = null, + ?string $content = null, + ?string $origin = null + ): array { + $sql = []; + $params = []; + + if ($linked instanceof AccompanyingPeriod) { + foreach ($this->providersForAccompanyingPeriod as $provider) { + ['sql' => $q, 'params' => $p ] = $this->builder + ->toSql($provider->buildFetchQueryForAccompanyingPeriod($linked, $startDate, $endDate, $content, $origin)); + $params = [...$params, ...$p]; + $sql[] = $q; + } + } + + return ['sql' => implode(' UNION ', $sql), 'params' => $params]; + } + +} diff --git a/src/Bundle/ChillDocStoreBundle/GenericDoc/ProviderForAccompanyingPeriodInterface.php b/src/Bundle/ChillDocStoreBundle/GenericDoc/ProviderForAccompanyingPeriodInterface.php new file mode 100644 index 000000000..07ca83694 --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/GenericDoc/ProviderForAccompanyingPeriodInterface.php @@ -0,0 +1,33 @@ +addJoinClause('LEFT JOIN other b ON a.id = b.foreign_id', ['foo']); + $index = $query->addJoinClause('LEFT JOIN other c ON a.id = c.foreign_id', ['bar']); + $query->addJoinClause('LEFT JOIN other d ON a.id = d.foreign_id', ['bar_baz']); + $query->removeJoinClause($index); + $query->addWhereClause('b.item = ?', ['baz']); + $index = $query->addWhereClause('b.cancel', [ 'foz']); + $query->removeWhereClause($index); + + ['sql' => $sql, 'params' => $params] = (new FetchQueryToSqlBuilder())->toSql($query); + + $filteredSql = + implode(" ", array_filter( + explode(" ", str_replace("\n", "", $sql)), + fn (string $tok) => $tok !== "" + )) + ; + + self::assertEquals( + "SELECT 'test' AS key, jsonb_build_object('id', a.column) AS identifiers, ". + "a.datecolumn AS doc_date FROM my_table a LEFT JOIN other b ON a.id = b.foreign_id LEFT JOIN other d ON a.id = d.foreign_id WHERE b.item = ?", + $filteredSql + ); + self::assertEquals(['foo', 'bar_baz', 'baz'], $params); + } + +} diff --git a/src/Bundle/ChillDocStoreBundle/Tests/GenericDoc/ManagerTest.php b/src/Bundle/ChillDocStoreBundle/Tests/GenericDoc/ManagerTest.php new file mode 100644 index 000000000..523e08c40 --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/Tests/GenericDoc/ManagerTest.php @@ -0,0 +1,56 @@ +em = self::$container->get(EntityManagerInterface::class); + + if (null !== $manager = self::$container->get(Manager::class)) { + $this->manager = $manager; + } else { + throw new \UnexpectedValueException("the manager was not found in the kernel"); + } + } + + public function testCountByAccompanyingPeriod(): void + { + $period = $this->em->createQuery('SELECT a FROM '.AccompanyingPeriod::class.' a') + ->setMaxResults(1) + ->getSingleResult(); + + if (null === $period) { + throw new \UnexpectedValueException("period not found"); + } + + $nb = $this->manager->countDocForAccompanyingPeriod($period); + + self::assertIsInt($nb); + } +} diff --git a/src/Bundle/ChillDocStoreBundle/config/services.yaml b/src/Bundle/ChillDocStoreBundle/config/services.yaml index 860495677..22161d2f6 100644 --- a/src/Bundle/ChillDocStoreBundle/config/services.yaml +++ b/src/Bundle/ChillDocStoreBundle/config/services.yaml @@ -45,3 +45,9 @@ services: autoconfigure: true resource: '../Service/' + Chill\DocStoreBundle\GenericDoc\Manager: + autowire: true + autoconfigure: true + arguments: + $providersForAccompanyingPeriod: !tagged_iterator chill_doc_store.generic_doc_accompanying_period_provider + From 8dbe2d6ec20e166f3259f41e08798842b4c184bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 24 May 2023 11:42:30 +0200 Subject: [PATCH 095/724] GenericDoc: add provider for AccompanyingCourseDocument, without filtering --- .../ChillDocStoreBundle.php | 7 ++ ...ericDocForAccompanyingPeriodController.php | 4 + .../GenericDoc/FetchQuery.php | 99 +++++++++++++++---- .../GenericDoc/FetchQueryInterface.php | 22 +++++ .../GenericDoc/FetchQueryToSqlBuilder.php | 19 +++- .../GenericDoc/Manager.php | 32 ++++-- ...ProviderForAccompanyingPeriodInterface.php | 2 +- .../AccompanyingCourseDocumentProvider.php | 84 ++++++++++++++++ .../GenericDoc/FetchQueryToSqlBuilderTest.php | 46 +++++++-- .../Tests/GenericDoc/ManagerTest.php | 63 ++++++++++-- ...AccompanyingCourseDocumentProviderTest.php | 78 +++++++++++++++ .../ChillDocStoreBundle/config/services.yaml | 4 + 12 files changed, 414 insertions(+), 46 deletions(-) create mode 100644 src/Bundle/ChillDocStoreBundle/GenericDoc/Providers/AccompanyingCourseDocumentProvider.php create mode 100644 src/Bundle/ChillDocStoreBundle/Tests/GenericDoc/Providers/AccompanyingCourseDocumentProviderTest.php diff --git a/src/Bundle/ChillDocStoreBundle/ChillDocStoreBundle.php b/src/Bundle/ChillDocStoreBundle/ChillDocStoreBundle.php index 81c71f45f..44bc7d70d 100644 --- a/src/Bundle/ChillDocStoreBundle/ChillDocStoreBundle.php +++ b/src/Bundle/ChillDocStoreBundle/ChillDocStoreBundle.php @@ -11,8 +11,15 @@ declare(strict_types=1); namespace Chill\DocStoreBundle; +use Chill\DocStoreBundle\GenericDoc\ProviderForAccompanyingPeriodInterface; +use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Bundle\Bundle; class ChillDocStoreBundle extends Bundle { + public function build(ContainerBuilder $container) + { + $container->registerForAutoconfiguration(ProviderForAccompanyingPeriodInterface::class) + ->addTag('chill_doc_store.generic_doc_accompanying_period_provider'); + } } diff --git a/src/Bundle/ChillDocStoreBundle/Controller/GenericDocForAccompanyingPeriodController.php b/src/Bundle/ChillDocStoreBundle/Controller/GenericDocForAccompanyingPeriodController.php index 32a7cc1c9..0a9175087 100644 --- a/src/Bundle/ChillDocStoreBundle/Controller/GenericDocForAccompanyingPeriodController.php +++ b/src/Bundle/ChillDocStoreBundle/Controller/GenericDocForAccompanyingPeriodController.php @@ -42,6 +42,10 @@ final readonly class GenericDocForAccompanyingPeriodController $nb = $this->manager->countDocForAccompanyingPeriod($accompanyingPeriod); + foreach ($this->manager->findDocForAccompanyingPeriod($accompanyingPeriod) as $dto) { + dump($dto); + } + return new Response($nb); } diff --git a/src/Bundle/ChillDocStoreBundle/GenericDoc/FetchQuery.php b/src/Bundle/ChillDocStoreBundle/GenericDoc/FetchQuery.php index 42e0fd335..30e07a841 100644 --- a/src/Bundle/ChillDocStoreBundle/GenericDoc/FetchQuery.php +++ b/src/Bundle/ChillDocStoreBundle/GenericDoc/FetchQuery.php @@ -11,7 +11,7 @@ declare(strict_types=1); namespace Chill\DocStoreBundle\GenericDoc; -use Nelmio\Alice\Throwable\Exception\FixtureBuilder\Denormalizer\UnexpectedValueException; +use Doctrine\DBAL\Types\Types; class FetchQuery implements FetchQueryInterface { @@ -21,42 +21,56 @@ class FetchQuery implements FetchQueryInterface private array $joins = []; /** - * @var list + * @var list> */ private array $joinParams = []; /** - * @var list + * @var array> + */ + private array $joinTypes = []; + + /** + * @var array */ private array $wheres = []; /** - * @var list + * @var array> */ private array $whereParams = []; + /** + * @var array> + */ + private array $whereTypes = []; + public function __construct( private readonly string $selectKeyString, private readonly string $selectIdentifierJsonB, private readonly string $selectDate, private string $from = '', private array $selectIdentifierParams = [], + private array $selectIdentifierTypes = [], private array $selectDateParams = [], + private array $selectDateTypes = [], ) { } - public function addJoinClause(string $sql, array $params = []): int + public function addJoinClause(string $sql, array $params = [], array $types = []): int { $this->joins[] = $sql; $this->joinParams[] = $params; + $this->joinTypes[] = $types; return count($this->joins) - 1; } - public function addWhereClause(string $sql, array $params = []): int + public function addWhereClause(string $sql, array $params = [], array $types = []): int { $this->wheres[] = $sql; $this->whereParams[] = $params; + $this->whereTypes[] = $types; return count($this->wheres) - 1; } @@ -67,7 +81,7 @@ class FetchQuery implements FetchQueryInterface throw new \UnexpectedValueException("this index does not exists"); } - unset($this->wheres[$index], $this->whereParams[$index]); + unset($this->wheres[$index], $this->whereParams[$index], $this->whereTypes[$index]); } @@ -77,7 +91,7 @@ class FetchQuery implements FetchQueryInterface throw new \UnexpectedValueException("this index does not exists"); } - unset($this->joins[$index], $this->joinParams[$index]); + unset($this->joins[$index], $this->joinParams[$index], $this->joinTypes[$index]); } @@ -99,11 +113,21 @@ class FetchQuery implements FetchQueryInterface return $this->selectIdentifierParams; } + public function getSelectIdentifiersTypes(): array + { + return $this->selectIdentifierTypes; + } + public function getSelectDate(): string { return $this->selectDate; } + public function getSelectDateTypes(): array + { + return $this->selectDateTypes; + } + /** * @inheritDoc */ @@ -131,6 +155,17 @@ class FetchQuery implements FetchQueryInterface return $result; } + public function getFromQueryTypes(): array + { + $result = []; + + foreach ($this->joinTypes as $types) { + $result = [...$result, ...$types]; + } + + return $result; + } + public function getWhereQuery(): string { return implode(' AND ', $this->wheres); @@ -150,19 +185,49 @@ class FetchQuery implements FetchQueryInterface return $result; } - /** - * @param array $selectIdentifierParams - */ - public function setSelectIdentifierParams(array $selectIdentifierParams): void + public function getWhereQueryTypes(): array { - $this->selectIdentifierParams = $selectIdentifierParams; + $result = []; + + foreach ($this->whereTypes as $types) { + $result = [...$result, ...$types]; + } + + return $result; } - /** - * @param array $selectDateParams - */ - public function setSelectDateParams(array $selectDateParams): void + public function setSelectIdentifierParams(array $selectIdentifierParams): self + { + $this->selectIdentifierParams = $selectIdentifierParams; + + return $this; + } + + public function setSelectDateParams(array $selectDateParams): self { $this->selectDateParams = $selectDateParams; + + return $this; + } + + public function setFrom(string $from): self + { + $this->from = $from; + + return $this; + } + + public function setSelectIdentifierTypes(array $selectIdentifierTypes): self + { + $this->selectIdentifierTypes = $selectIdentifierTypes; + + return $this; + } + + public function setSelectDateTypes(array $selectDateTypes): self + { + $this->selectDateTypes = $selectDateTypes; + + return $this; } } diff --git a/src/Bundle/ChillDocStoreBundle/GenericDoc/FetchQueryInterface.php b/src/Bundle/ChillDocStoreBundle/GenericDoc/FetchQueryInterface.php index c262d2a5d..e46795457 100644 --- a/src/Bundle/ChillDocStoreBundle/GenericDoc/FetchQueryInterface.php +++ b/src/Bundle/ChillDocStoreBundle/GenericDoc/FetchQueryInterface.php @@ -11,6 +11,8 @@ declare(strict_types=1); namespace Chill\DocStoreBundle\GenericDoc; +use Doctrine\DBAL\Types\Types; + interface FetchQueryInterface { public function getSelectKeyString(): string; @@ -22,6 +24,11 @@ interface FetchQueryInterface */ public function getSelectIdentifierParams(): array; + /** + * @return list + */ + public function getSelectIdentifiersTypes(): array; + public function getSelectDate(): string; /** @@ -29,6 +36,11 @@ interface FetchQueryInterface */ public function getSelectDateParams(): array; + /** + * @return list + */ + public function getSelectDateTypes(): array; + public function getFromQuery(): string; /** @@ -36,10 +48,20 @@ interface FetchQueryInterface */ public function getFromQueryParams(): array; + /** + * @return list + */ + public function getFromQueryTypes(): array; + public function getWhereQuery(): string; /** * @return list */ public function getWhereQueryParams(): array; + + /** + * @return list + */ + public function getWhereQueryTypes(): array; } diff --git a/src/Bundle/ChillDocStoreBundle/GenericDoc/FetchQueryToSqlBuilder.php b/src/Bundle/ChillDocStoreBundle/GenericDoc/FetchQueryToSqlBuilder.php index 881435da7..2c0c59cff 100644 --- a/src/Bundle/ChillDocStoreBundle/GenericDoc/FetchQueryToSqlBuilder.php +++ b/src/Bundle/ChillDocStoreBundle/GenericDoc/FetchQueryToSqlBuilder.php @@ -11,20 +11,22 @@ declare(strict_types=1); namespace Chill\DocStoreBundle\GenericDoc; +use Doctrine\DBAL\Types\Types; + final readonly class FetchQueryToSqlBuilder { private const SQL = <<<'SQL' SELECT '{{ key }}' AS key, {{ identifiers }} AS identifiers, - {{ date }} AS doc_date + {{ date }}::date AS doc_date FROM {{ from }} - WHERE {{ where }} + {{ where }} SQL; /** * @param FetchQueryInterface $query - * @return array{sql: string, params: list} + * @return array{sql: string, params: list, types: list} */ public function toSql(FetchQueryInterface $query): array { @@ -33,7 +35,7 @@ final readonly class FetchQueryToSqlBuilder '{{ identifiers }}' => $query->getSelectIdentifierJsonB(), '{{ date }}' => $query->getSelectDate(), '{{ from }}' => $query->getFromQuery(), - '{{ where }}' => $query->getWhereQuery(), + '{{ where }}' => '' === ($w = $query->getWhereQuery()) ? '' : 'WHERE ' . $w, ]); $params = [ @@ -43,6 +45,13 @@ final readonly class FetchQueryToSqlBuilder ...$query->getWhereQueryParams() ]; - return ['sql' => $sql, 'params' => $params]; + $types = [ + ...$query->getSelectIdentifiersTypes(), + ...$query->getSelectDateTypes(), + ...$query->getFromQueryTypes(), + ...$query->getWhereQueryTypes(), + ]; + + return ['sql' => $sql, 'params' => $params, 'types' => $types]; } } diff --git a/src/Bundle/ChillDocStoreBundle/GenericDoc/Manager.php b/src/Bundle/ChillDocStoreBundle/GenericDoc/Manager.php index bbc46c367..d67ff6d0d 100644 --- a/src/Bundle/ChillDocStoreBundle/GenericDoc/Manager.php +++ b/src/Bundle/ChillDocStoreBundle/GenericDoc/Manager.php @@ -15,6 +15,7 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\Person; use Doctrine\DBAL\Connection; use Doctrine\DBAL\Exception; +use Doctrine\DBAL\Types\Types; class Manager { @@ -41,7 +42,12 @@ class Manager ?string $origin = null ): int { ['sql' => $sql, 'params' => $params] = $this->buildUnionQuery($accompanyingPeriod, $startDate, $endDate, $content, $origin); - $countSql = "SELECT count(*) AS c FROM {$sql} AS sq"; + + if ($sql === '') { + return 0; + } + + $countSql = "SELECT count(*) AS c FROM ({$sql}) AS sq"; $result = $this->connection->executeQuery($countSql, $params); $number = $result->fetchOne(); @@ -50,7 +56,7 @@ class Manager throw new \UnexpectedValueException("number of documents failed to load"); } - return $number['c']; + return $number; } /** @@ -65,13 +71,18 @@ class Manager ?string $content = null, ?string $origin = null ): iterable { - ['sql' => $sql, 'params' => $params] = $this->buildUnionQuery($accompanyingPeriod, $startDate, $endDate, $content, $origin); + ['sql' => $sql, 'params' => $params, 'types' => $types] = $this->buildUnionQuery($accompanyingPeriod, $startDate, $endDate, $content, $origin); $runSql = "{$sql} LIMIT ? OFFSET ?"; $runParams = [...$params, ...[$limit, $offset]]; + $runTypes = [...$types, ...[Types::INTEGER, Types::INTEGER]]; - foreach($this->connection->iterateAssociative($runSql, $runParams) as $row) { - yield new GenericDocDTO($row['key'], $row['identifiers'], $row['date_doc']); + foreach($this->connection->iterateAssociative($runSql, $runParams, $runTypes) as $row) { + yield new GenericDocDTO( + $row['key'], + json_decode($row['identifiers'], true, JSON_THROW_ON_ERROR), + new \DateTimeImmutable($row['doc_date']) + ); } } @@ -86,17 +97,24 @@ class Manager ): array { $sql = []; $params = []; + $types = []; if ($linked instanceof AccompanyingPeriod) { foreach ($this->providersForAccompanyingPeriod as $provider) { - ['sql' => $q, 'params' => $p ] = $this->builder + if (!$provider->isAllowedForAccompanyingPeriod($linked)) { + continue; + } + + ['sql' => $q, 'params' => $p, 'types' => $t ] = $this->builder ->toSql($provider->buildFetchQueryForAccompanyingPeriod($linked, $startDate, $endDate, $content, $origin)); $params = [...$params, ...$p]; + $types = [...$types, ...$t]; + $sql[] = $q; } } - return ['sql' => implode(' UNION ', $sql), 'params' => $params]; + return ['sql' => implode(' UNION ', $sql), 'params' => $params, 'types' => $types]; } } diff --git a/src/Bundle/ChillDocStoreBundle/GenericDoc/ProviderForAccompanyingPeriodInterface.php b/src/Bundle/ChillDocStoreBundle/GenericDoc/ProviderForAccompanyingPeriodInterface.php index 07ca83694..935fe48a9 100644 --- a/src/Bundle/ChillDocStoreBundle/GenericDoc/ProviderForAccompanyingPeriodInterface.php +++ b/src/Bundle/ChillDocStoreBundle/GenericDoc/ProviderForAccompanyingPeriodInterface.php @@ -28,6 +28,6 @@ interface ProviderForAccompanyingPeriodInterface * * @return bool */ - public function isAllowed(): bool; + public function isAllowedForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod): bool; } diff --git a/src/Bundle/ChillDocStoreBundle/GenericDoc/Providers/AccompanyingCourseDocumentProvider.php b/src/Bundle/ChillDocStoreBundle/GenericDoc/Providers/AccompanyingCourseDocumentProvider.php new file mode 100644 index 000000000..8f6a9fdad --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/GenericDoc/Providers/AccompanyingCourseDocumentProvider.php @@ -0,0 +1,84 @@ +entityManager->getClassMetadata(AccompanyingCourseDocument::class); + + $query = new FetchQuery( + 'accompanying_course_document', + sprintf('jsonb_build_object(\'id\', %s)', $classMetadata->getIdentifierColumnNames()[0]), + sprintf($classMetadata->getColumnName('date')), + $classMetadata->getSchemaName() . '.' . $classMetadata->getTableName() + ); + + $query->addWhereClause( + sprintf('%s = ?', $classMetadata->getSingleAssociationJoinColumnName('course')), + [$accompanyingPeriod->getId()], + [Types::INTEGER] + ); + + if (null !== $startDate) { + $query->addWhereClause( + sprintf('? >= %s', $classMetadata->getColumnName('date')), + [$startDate], + [Types::DATE_IMMUTABLE] + ); + } + + if (null !== $endDate) { + $query->addWhereClause( + sprintf('? < %s', $classMetadata->getColumnName('date')), + [$endDate], + [Types::DATE_IMMUTABLE] + ); + } + + if (null !== $content) { + $query->addWhereClause( + sprintf( + '(%s ilike ? OR %s ilike ?)', + $classMetadata->getColumnName('title'), + $classMetadata->getColumnName('description') + ), + [$content, $content], + [Types::STRING, Types::STRING] + ); + } + + return $query; + } + + public function isAllowedForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod): bool + { + return $this->security->isGranted(AccompanyingCourseDocumentVoter::SEE, $accompanyingPeriod); + } +} diff --git a/src/Bundle/ChillDocStoreBundle/Tests/GenericDoc/FetchQueryToSqlBuilderTest.php b/src/Bundle/ChillDocStoreBundle/Tests/GenericDoc/FetchQueryToSqlBuilderTest.php index c6db09513..02be9460f 100644 --- a/src/Bundle/ChillDocStoreBundle/Tests/GenericDoc/FetchQueryToSqlBuilderTest.php +++ b/src/Bundle/ChillDocStoreBundle/Tests/GenericDoc/FetchQueryToSqlBuilderTest.php @@ -13,6 +13,7 @@ namespace Chill\DocStoreBundle\Tests\GenericDoc; use Chill\DocStoreBundle\GenericDoc\FetchQueryToSqlBuilder; use Chill\DocStoreBundle\GenericDoc\FetchQuery; +use Doctrine\DBAL\Types\Types; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; /** @@ -29,15 +30,15 @@ class FetchQueryToSqlBuilderTest extends KernelTestCase 'a.datecolumn', 'my_table a' ); - $query->addJoinClause('LEFT JOIN other b ON a.id = b.foreign_id', ['foo']); - $index = $query->addJoinClause('LEFT JOIN other c ON a.id = c.foreign_id', ['bar']); - $query->addJoinClause('LEFT JOIN other d ON a.id = d.foreign_id', ['bar_baz']); + $query->addJoinClause('LEFT JOIN other b ON a.id = b.foreign_id', ['foo'], [Types::STRING]); + $index = $query->addJoinClause('LEFT JOIN other c ON a.id = c.foreign_id', ['bar'], [Types::STRING]); + $query->addJoinClause('LEFT JOIN other d ON a.id = d.foreign_id', ['bar_baz'], [Types::STRING]); $query->removeJoinClause($index); - $query->addWhereClause('b.item = ?', ['baz']); - $index = $query->addWhereClause('b.cancel', [ 'foz']); + $query->addWhereClause('b.item = ?', ['baz'], [Types::STRING]); + $index = $query->addWhereClause('b.cancel', [ 'foz'], [Types::STRING]); $query->removeWhereClause($index); - ['sql' => $sql, 'params' => $params] = (new FetchQueryToSqlBuilder())->toSql($query); + ['sql' => $sql, 'params' => $params, 'types' => $types] = (new FetchQueryToSqlBuilder())->toSql($query); $filteredSql = implode(" ", array_filter( @@ -48,10 +49,41 @@ class FetchQueryToSqlBuilderTest extends KernelTestCase self::assertEquals( "SELECT 'test' AS key, jsonb_build_object('id', a.column) AS identifiers, ". - "a.datecolumn AS doc_date FROM my_table a LEFT JOIN other b ON a.id = b.foreign_id LEFT JOIN other d ON a.id = d.foreign_id WHERE b.item = ?", + "a.datecolumn::date AS doc_date FROM my_table a LEFT JOIN other b ON a.id = b.foreign_id LEFT JOIN other d ON a.id = d.foreign_id WHERE b.item = ?", $filteredSql ); self::assertEquals(['foo', 'bar_baz', 'baz'], $params); + self::assertEquals([Types::STRING, Types::STRING, Types::STRING], $types); + + + + } + + public function testToSqlWithoutWhere(): void + { + $query = new FetchQuery( + 'test', + 'jsonb_build_object(\'id\', a.column)', + 'a.datecolumn', + 'my_table a' + ); + + ['sql' => $sql, 'params' => $params, 'types' => $types] = (new FetchQueryToSqlBuilder())->toSql($query); + + $filteredSql = + implode(" ", array_filter( + explode(" ", str_replace("\n", "", $sql)), + fn (string $tok) => $tok !== "" + )) + ; + + self::assertEquals( + "SELECT 'test' AS key, jsonb_build_object('id', a.column) AS identifiers, ". + "a.datecolumn::date AS doc_date FROM my_table a", + $filteredSql + ); + self::assertEquals([], $params); + self::assertEquals([], $types); } } diff --git a/src/Bundle/ChillDocStoreBundle/Tests/GenericDoc/ManagerTest.php b/src/Bundle/ChillDocStoreBundle/Tests/GenericDoc/ManagerTest.php index 523e08c40..59cc24bf2 100644 --- a/src/Bundle/ChillDocStoreBundle/Tests/GenericDoc/ManagerTest.php +++ b/src/Bundle/ChillDocStoreBundle/Tests/GenericDoc/ManagerTest.php @@ -11,9 +11,15 @@ declare(strict_types=1); namespace Chill\DocStoreBundle\Tests\GenericDoc; +use Chill\DocStoreBundle\GenericDoc\FetchQuery; +use Chill\DocStoreBundle\GenericDoc\FetchQueryInterface; +use Chill\DocStoreBundle\GenericDoc\GenericDocDTO; use Chill\DocStoreBundle\GenericDoc\Manager; +use Chill\DocStoreBundle\GenericDoc\ProviderForAccompanyingPeriodInterface; use Chill\PersonBundle\Entity\AccompanyingPeriod; +use Doctrine\DBAL\Connection; use Doctrine\ORM\EntityManagerInterface; +use Prophecy\PhpUnit\ProphecyTrait; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; /** @@ -22,21 +28,17 @@ use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; */ class ManagerTest extends KernelTestCase { - private Manager $manager; - + use ProphecyTrait; private EntityManagerInterface $em; + private Connection $connection; + protected function setUp(): void { self::bootKernel(); $this->em = self::$container->get(EntityManagerInterface::class); - - if (null !== $manager = self::$container->get(Manager::class)) { - $this->manager = $manager; - } else { - throw new \UnexpectedValueException("the manager was not found in the kernel"); - } + $this->connection = self::$container->get(Connection::class); } public function testCountByAccompanyingPeriod(): void @@ -49,8 +51,51 @@ class ManagerTest extends KernelTestCase throw new \UnexpectedValueException("period not found"); } - $nb = $this->manager->countDocForAccompanyingPeriod($period); + $manager = new Manager( + [new SimpleProvider()], + $this->connection, + ); + + $nb = $manager->countDocForAccompanyingPeriod($period); self::assertIsInt($nb); } + + public function testFindDocByAccompanyingPeriod(): void + { + $period = $this->em->createQuery('SELECT a FROM '.AccompanyingPeriod::class.' a') + ->setMaxResults(1) + ->getSingleResult(); + + if (null === $period) { + throw new \UnexpectedValueException("period not found"); + } + + $manager = new Manager( + [new SimpleProvider()], + $this->connection, + ); + + foreach ($manager->findDocForAccompanyingPeriod($period) as $doc) { + self::assertInstanceOf(GenericDocDTO::class, $doc); + } + } +} + +final readonly class SimpleProvider implements ProviderForAccompanyingPeriodInterface +{ + public function buildFetchQueryForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod, ?\DateTimeImmutable $startDate = null, ?\DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface + { + return new FetchQuery( + 'accompanying_course_document', + sprintf('jsonb_build_object(\'id\', %s)', 'id'), + 'd', + '(VALUES (1, \'2023-05-01\'::date), (2, \'2023-05-01\'::date)) AS sq (id, d)', + ); + } + + public function isAllowedForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod): bool + { + return true; + } } diff --git a/src/Bundle/ChillDocStoreBundle/Tests/GenericDoc/Providers/AccompanyingCourseDocumentProviderTest.php b/src/Bundle/ChillDocStoreBundle/Tests/GenericDoc/Providers/AccompanyingCourseDocumentProviderTest.php new file mode 100644 index 000000000..b88f8e36f --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/Tests/GenericDoc/Providers/AccompanyingCourseDocumentProviderTest.php @@ -0,0 +1,78 @@ +entityManager = self::$container->get(EntityManagerInterface::class); + } + + /** + * @dataProvider provideSearchArguments + */ + public function testWithoutAnyArgument(?\DateTimeImmutable $startDate, ?\DateTimeImmutable $endDate, ?string $content = null): void + { + $period = $this->entityManager->createQuery('SELECT a FROM '.AccompanyingPeriod::class.' a') + ->setMaxResults(1) + ->getSingleResult(); + + if (null === $period) { + throw new \UnexpectedValueException("period not found"); + } + + $security = $this->prophesize(Security::class); + $security->isGranted(AccompanyingCourseDocumentVoter::SEE, $period) + ->willReturn(true); + + $provider = new AccompanyingCourseDocumentProvider( + $security->reveal(), + $this->entityManager + ); + + $query = $provider->buildFetchQueryForAccompanyingPeriod($period, $startDate, $endDate, $content); + + ['sql' => $sql, 'params' => $params, 'types' => $types] = (new FetchQueryToSqlBuilder())->toSql($query); + + $this->entityManager->getConnection()->executeQuery($sql, $params, $types); + + self::assertTrue(true, "test that no errors occurs"); + } + + public function provideSearchArguments(): iterable + { + yield [null, null, null]; + yield [new \DateTimeImmutable('1 month ago'), null, null]; + yield [new \DateTimeImmutable('1 month ago'), new \DateTimeImmutable('now'), null]; + yield [null, null, 'test']; + } +} diff --git a/src/Bundle/ChillDocStoreBundle/config/services.yaml b/src/Bundle/ChillDocStoreBundle/config/services.yaml index 22161d2f6..16b0365d4 100644 --- a/src/Bundle/ChillDocStoreBundle/config/services.yaml +++ b/src/Bundle/ChillDocStoreBundle/config/services.yaml @@ -51,3 +51,7 @@ services: arguments: $providersForAccompanyingPeriod: !tagged_iterator chill_doc_store.generic_doc_accompanying_period_provider + Chill\DocStoreBundle\GenericDoc\Providers\: + autowire: true + autoconfigure: true + resource: '../GenericDoc/Providers/' From fec2dd0f74e852f48fd2bb4102eafc2147468a11 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Wed, 24 May 2023 19:51:52 +0200 Subject: [PATCH 096/724] enable debug --- .../public/vuejs/_components/Entity/PersonRenderBox.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonRenderBox.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonRenderBox.vue index 740eb0039..1833222e8 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonRenderBox.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonRenderBox.vue @@ -207,7 +207,7 @@ diff --git a/src/Bundle/ChillDocStoreBundle/Resources/public/vuejs/StoredObjectButton/helpers.ts b/src/Bundle/ChillDocStoreBundle/Resources/public/vuejs/StoredObjectButton/helpers.ts index 5b61a108d..c0b0fa940 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/public/vuejs/StoredObjectButton/helpers.ts +++ b/src/Bundle/ChillDocStoreBundle/Resources/public/vuejs/StoredObjectButton/helpers.ts @@ -149,16 +149,21 @@ async function download_and_decrypt_doc(urlGenerator: string, keyData: JsonWebKe } if (iv.length === 0) { + console.log('returning document immediatly'); return rawResponse.blob(); } + console.log('start decrypting doc'); + const rawBuffer = await rawResponse.arrayBuffer(); try { const key = await window.crypto.subtle .importKey('jwk', keyData, { name: algo }, false, ['decrypt']); + console.log('key created'); const decrypted = await window.crypto.subtle .decrypt({ name: algo, iv: iv }, key, rawBuffer); + console.log('doc decrypted'); return Promise.resolve(new Blob([decrypted])); } catch (e) { From 60aeb57c45d6d2e923fad9288d1a76c2730d7847 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 25 May 2023 12:43:09 +0200 Subject: [PATCH 110/724] FIX [filiation] change validator to allow delete and patch of relationship --- .../Relationship/RelationshipNoDuplicateValidator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bundle/ChillPersonBundle/Validator/Constraints/Relationship/RelationshipNoDuplicateValidator.php b/src/Bundle/ChillPersonBundle/Validator/Constraints/Relationship/RelationshipNoDuplicateValidator.php index 10e651b56..cb1e5395e 100644 --- a/src/Bundle/ChillPersonBundle/Validator/Constraints/Relationship/RelationshipNoDuplicateValidator.php +++ b/src/Bundle/ChillPersonBundle/Validator/Constraints/Relationship/RelationshipNoDuplicateValidator.php @@ -46,7 +46,7 @@ class RelationshipNoDuplicateValidator extends ConstraintValidator ]); foreach ($relationships as $r) { - if ( + if ( spl_object_hash($r) !== spl_object_hash($value) and $r->getFromPerson() === $fromPerson || $r->getFromPerson() === $toPerson || $r->getToPerson() === $fromPerson From 72f5b0b275b7fd4528fabe70eb516729c165c156 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 25 May 2023 12:52:23 +0200 Subject: [PATCH 111/724] DX [cs-fix] --- .../Relationship/RelationshipNoDuplicateValidator.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Validator/Constraints/Relationship/RelationshipNoDuplicateValidator.php b/src/Bundle/ChillPersonBundle/Validator/Constraints/Relationship/RelationshipNoDuplicateValidator.php index cb1e5395e..b44a966cc 100644 --- a/src/Bundle/ChillPersonBundle/Validator/Constraints/Relationship/RelationshipNoDuplicateValidator.php +++ b/src/Bundle/ChillPersonBundle/Validator/Constraints/Relationship/RelationshipNoDuplicateValidator.php @@ -46,8 +46,8 @@ class RelationshipNoDuplicateValidator extends ConstraintValidator ]); foreach ($relationships as $r) { - if ( spl_object_hash($r) !== spl_object_hash($value) and - $r->getFromPerson() === $fromPerson + if (spl_object_hash($r) !== spl_object_hash($value) + and $r->getFromPerson() === $fromPerson || $r->getFromPerson() === $toPerson || $r->getToPerson() === $fromPerson || $r->getToPerson() === $toPerson From 1b0569c9744ede4a7b430888ab87a5880afaf516 Mon Sep 17 00:00:00 2001 From: nobohan Date: Thu, 25 May 2023 13:58:46 +0200 Subject: [PATCH 112/724] Feature: add thirdParty choice in docgen context - use array_values --- .../AccompanyingPeriodContext.php | 14 ++++++----- ...ccompanyingPeriodWorkEvaluationContext.php | 16 +++++++------ .../Service/DocGenerator/PersonContext.php | 24 +++++++++++-------- 3 files changed, 31 insertions(+), 23 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php index d0ea59090..66be9aceb 100644 --- a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php +++ b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php @@ -214,13 +214,15 @@ class AccompanyingPeriodContext implements } $thirdParties = array_merge( - array_filter([$entity->getRequestorThirdParty()]), + array_filter(array_values([$entity->getRequestorThirdParty()])), array_filter( - array_map( - fn (Resource $r): ?ThirdParty => $r->getThirdParty(), - $entity->getResources()->filter( - static fn (Resource $r): bool => null !== $r->getThirdParty() - )->toArray() + array_values( + array_map( + fn (Resource $r): ?ThirdParty => $r->getThirdParty(), + $entity->getResources()->filter( + static fn (Resource $r): bool => null !== $r->getThirdParty() + )->toArray() + ) ) ) ); diff --git a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php index d7fff210b..62e13789f 100644 --- a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php +++ b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php @@ -117,14 +117,16 @@ class AccompanyingPeriodWorkEvaluationContext implements $this->accompanyingPeriodWorkContext->buildPublicForm($builder, $template, $entity->getAccompanyingPeriodWork()); $thirdParties = array_merge( - array_filter($entity->getAccompanyingPeriodWork()->getThirdParties()->toArray()), - array_filter([$entity->getAccompanyingPeriodWork()->getHandlingThierParty()]), + array_filter(array_values($entity->getAccompanyingPeriodWork()->getThirdParties()->toArray())), + array_filter(array_values([$entity->getAccompanyingPeriodWork()->getHandlingThierParty()])), array_filter( - array_map( - fn (Resource $r): ?ThirdParty => $r->getThirdParty(), - $entity->getAccompanyingPeriodWork()->getAccompanyingPeriod()->getResources()->filter( - static fn (Resource $r): bool => null !== $r->getThirdParty() - )->toArray() + array_values( + array_map( + fn (Resource $r): ?ThirdParty => $r->getThirdParty(), + $entity->getAccompanyingPeriodWork()->getAccompanyingPeriod()->getResources()->filter( + static fn (Resource $r): bool => null !== $r->getThirdParty() + )->toArray() + ) ) ) ); diff --git a/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php b/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php index 583ac189c..4d49bcfba 100644 --- a/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php +++ b/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php @@ -178,19 +178,23 @@ final class PersonContext implements PersonContextInterface $thirdParties = array_merge( array_filter( - array_map( - fn (ResidentialAddress $r): ?ThirdParty => $r->getHostThirdParty(), - $this - ->residentialAddressRepository - ->findCurrentResidentialAddressByPerson($entity) + array_values( + array_map( + fn (ResidentialAddress $r): ?ThirdParty => $r->getHostThirdParty(), + $this + ->residentialAddressRepository + ->findCurrentResidentialAddressByPerson($entity) + ) ) ), array_filter( - array_map( - fn (PersonResource $r): ?ThirdParty => $r->getThirdParty(), - $entity->getResources()->filter( - static fn (PersonResource $r): bool => null !== $r->getThirdParty() - )->toArray() + array_values( + array_map( + fn (PersonResource $r): ?ThirdParty => $r->getThirdParty(), + $entity->getResources()->filter( + static fn (PersonResource $r): bool => null !== $r->getThirdParty() + )->toArray() + ) ) ) ); From 6c3fa5cb98b2889e40f1d777f2edc4769ef39be1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 25 May 2023 15:22:52 +0200 Subject: [PATCH 113/724] Fixed: [UI] in designation and redispatch list, the period's statuses were'nt shown correctly --- .../views/AccompanyingPeriod/_list_item.html.twig | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/_list_item.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/_list_item.html.twig index 6c7fbf7c0..47b8c8a15 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/_list_item.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/_list_item.html.twig @@ -16,11 +16,13 @@
    {% if period.step == 'DRAFT' %} - {{- 'Draft'|trans|upper -}} - {% elseif period.step == 'CONFIRMED' %} - {{- 'Confirmed'|trans|upper -}} - {% else %} - {{- 'Closed'|trans|upper -}} + {{ 'course.draft'|trans }} + {% elseif period.step == 'CLOSED' %} + {{ 'course.closed'|trans }} + {% elseif period.step == 'CONFIRMED_INACTIVE_SHORT' %} + {{ 'course.inactive_short'|trans }} + {% elseif period.step == 'CONFIRMED_INACTIVE_LONG' %} + {{ 'course.inactive_long'|trans }} {% endif %}
    From b679dbe26ccf27a097dce62ae2590a6bfe5b1f64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 25 May 2023 15:24:14 +0200 Subject: [PATCH 114/724] Fixed: Do not send a confirmation message when period is mark_active back --- .../AccompanyingPeriod/Events/UserRefEventSubscriber.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Events/UserRefEventSubscriber.php b/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Events/UserRefEventSubscriber.php index 8d7249928..50e7dcabb 100644 --- a/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Events/UserRefEventSubscriber.php +++ b/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Events/UserRefEventSubscriber.php @@ -51,7 +51,10 @@ class UserRefEventSubscriber implements EventSubscriberInterface public function onStateEntered(EnteredEvent $enteredEvent): void { - if ($enteredEvent->getMarking()->has(AccompanyingPeriod::STEP_CONFIRMED)) { + if ( + $enteredEvent->getMarking()->has(AccompanyingPeriod::STEP_CONFIRMED) + and $enteredEvent->getTransition()->getName() === 'confirm' + ) { $this->onPeriodConfirmed($enteredEvent->getSubject()); } } From ff03299f80c2e2a24843a52dc23bd25789ddf2d0 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 25 May 2023 17:06:10 +0200 Subject: [PATCH 115/724] FEATURE [workflow][doc] scroll immediately to document in workflow and let background flash --- .../vuejs/AccompanyingCourseWorkEdit/App.vue | 21 ++++++++++++++++--- .../components/AddEvaluation.vue | 7 +++++-- .../components/FormEvaluation.vue | 20 +++++++++++++++--- .../Workflow/_evaluation_document.html.twig | 2 +- 4 files changed, 41 insertions(+), 9 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue index 755e4455c..adbcf1097 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue @@ -122,7 +122,8 @@ + v-bind:evaluation="e" + v-bind:docId="this.docId"> @@ -389,6 +390,7 @@ export default { i18n, data() { return { + docId: null, isExpanded: false, editor: ClassicEditor, showAddObjective: false, @@ -428,7 +430,14 @@ export default { }, }; }, - computed: { + beforeMount() { + const urlParams = new URLSearchParams(window.location.search); + this.docId = urlParams.get('doc_id'); + }, + mounted() { + this.scrollToElement(this.docId); + }, + computed: { ...mapState([ 'work', 'resultsForAction', @@ -559,7 +568,7 @@ export default { }); }, saveFormOnTheFly(payload) { - console.log('saveFormOnTheFly: type', payload.type, ', data', payload.data); + // console.log('saveFormOnTheFly: type', payload.type, ', data', payload.data); let body = { type: payload.type }; body.name = payload.data.text; @@ -581,6 +590,12 @@ export default { this.$toast.open({message: 'An error occurred'}); } }) + }, + scrollToElement(docId) { + const documentEl = document.getElementById(`document_${docId}`); + if (documentEl) { + documentEl.scrollIntoView({behavior: 'smooth'}); + } } } }; diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/AddEvaluation.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/AddEvaluation.vue index 411c386a8..215c5d6cc 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/AddEvaluation.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/AddEvaluation.vue @@ -11,7 +11,7 @@
    - +
    • @@ -85,7 +85,7 @@ export default { Modal, ListWorkflowModal, }, - props: ['evaluation'], + props: ['evaluation', 'docId'], i18n, data() { return { @@ -95,6 +95,9 @@ export default { } }; }, +/* mounted() { + console.log('docId is here', this.docId) + },*/ computed: { pickedEvaluations() { return this.$store.state.evaluationsPicked; diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue index 7dcb595a3..ff7597dec 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue @@ -80,7 +80,7 @@
      -
      +
      @@ -92,7 +92,7 @@ :data-key="i" @input="onInputDocumentTitle"/>
      -
      +
      @@ -221,7 +221,7 @@ const i18n = { export default { name: "FormEvaluation", - props: ['evaluation'], + props: ['evaluation', 'docId'], components: { ckeditor: CKEditor.component, PickTemplate, @@ -402,4 +402,18 @@ export default { ul.document-upload { justify-content: flex-start; } + + .bg-blink{ + color: #050000; + padding: 10px; + display: inline-block; + border-radius: 5px; + animation: blinkingBackground 2.2s infinite; + animation-iteration-count: 3; + } + @keyframes blinkingBackground{ + 0% { background-color: #fa8888;} + 50% { background-color: #ffffff;} + 100% { background-color: #fa8888;} + } diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Workflow/_evaluation_document.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Workflow/_evaluation_document.html.twig index 691a903ab..112d4089d 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Workflow/_evaluation_document.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Workflow/_evaluation_document.html.twig @@ -123,7 +123,7 @@
      • {{ doc.storedObject|chill_document_button_group(doc.title, is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_UPDATE', evaluation.accompanyingPeriodWork)) }}
      • - + {{ 'Show'|trans }}
      • From 08874d734ed08b6135fe91da1ad42e00e3e82f18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 26 May 2023 21:58:52 +0200 Subject: [PATCH 116/724] [generic doc] add doc provider and renderer for evaluation document --- .../GenericDoc/Manager.php | 2 +- ...AccompanyingCourseDocumentProviderTest.php | 5 +- .../GenericDoc/evaluation_document.html.twig | 75 +++++++++++++ ...PeriodWorkEvaluationGenericDocProvider.php | 105 ++++++++++++++++++ ...PeriodWorkEvaluationGenericDocRenderer.php | 42 +++++++ ...odWorkEvaluationGenericDocProviderTest.php | 79 +++++++++++++ 6 files changed, 305 insertions(+), 3 deletions(-) create mode 100644 src/Bundle/ChillPersonBundle/Resources/views/GenericDoc/evaluation_document.html.twig create mode 100644 src/Bundle/ChillPersonBundle/Service/GenericDoc/Providers/AccompanyingPeriodWorkEvaluationGenericDocProvider.php create mode 100644 src/Bundle/ChillPersonBundle/Service/GenericDoc/Renderer/AccompanyingPeriodWorkEvaluationGenericDocRenderer.php create mode 100644 src/Bundle/ChillPersonBundle/Tests/Service/GenericDoc/Providers/AccompanyingPeriodWorkEvaluationGenericDocProviderTest.php diff --git a/src/Bundle/ChillDocStoreBundle/GenericDoc/Manager.php b/src/Bundle/ChillDocStoreBundle/GenericDoc/Manager.php index 21189f55e..1a0287a71 100644 --- a/src/Bundle/ChillDocStoreBundle/GenericDoc/Manager.php +++ b/src/Bundle/ChillDocStoreBundle/GenericDoc/Manager.php @@ -73,7 +73,7 @@ class Manager ): iterable { ['sql' => $sql, 'params' => $params, 'types' => $types] = $this->buildUnionQuery($accompanyingPeriod, $startDate, $endDate, $content, $origin); - $runSql = "{$sql} LIMIT ? OFFSET ?"; + $runSql = "{$sql} ORDER BY doc_date DESC LIMIT ? OFFSET ?"; $runParams = [...$params, ...[$limit, $offset]]; $runTypes = [...$types, ...[Types::INTEGER, Types::INTEGER]]; diff --git a/src/Bundle/ChillDocStoreBundle/Tests/GenericDoc/Providers/AccompanyingCourseDocumentProviderTest.php b/src/Bundle/ChillDocStoreBundle/Tests/GenericDoc/Providers/AccompanyingCourseDocumentProviderTest.php index ee9978735..8c6bd524d 100644 --- a/src/Bundle/ChillDocStoreBundle/Tests/GenericDoc/Providers/AccompanyingCourseDocumentProviderTest.php +++ b/src/Bundle/ChillDocStoreBundle/Tests/GenericDoc/Providers/AccompanyingCourseDocumentProviderTest.php @@ -63,9 +63,10 @@ class AccompanyingCourseDocumentProviderTest extends KernelTestCase ['sql' => $sql, 'params' => $params, 'types' => $types] = (new FetchQueryToSqlBuilder())->toSql($query); - $this->entityManager->getConnection()->executeQuery($sql, $params, $types); + $nb = $this->entityManager->getConnection()->executeQuery('SELECT COUNT(*) FROM ('.$sql.') AS sq', $params, $types) + ->fetchOne(); - self::assertTrue(true, "test that no errors occurs"); + self::assertIsInt($nb); } public function provideSearchArguments(): iterable diff --git a/src/Bundle/ChillPersonBundle/Resources/views/GenericDoc/evaluation_document.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/GenericDoc/evaluation_document.html.twig new file mode 100644 index 000000000..255139bb4 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Resources/views/GenericDoc/evaluation_document.html.twig @@ -0,0 +1,75 @@ +{% import "@ChillDocStore/Macro/macro.html.twig" as m %} +{% import "@ChillDocStore/Macro/macro_mimeicon.html.twig" as mm %} +{% import '@ChillPerson/Macro/updatedBy.html.twig' as mmm %} + +{% set w = document.accompanyingPeriodWorkEvaluation.accompanyingPeriodWork %} + +
        +
        +
        + {% if document.storedObject.isPending %} +
        {{ 'docgen.Doc generation is pending'|trans }}
        + {% elseif document.storedObject.isFailure %} +
        {{ 'docgen.Doc generation failed'|trans }}
        + {% endif %} +
        + {{ document.title }} +
        + {% if document.storedObject.type is not empty %} +
        + {{ mm.mimeIcon(document.storedObject.type) }} +
        + {% endif %} + {% if document.storedObject.hasTemplate %} +
        +

        {{ document.storedObject.template.name|localize_translatable_string }}

        +
        + {% endif %} +
        + +
        +
        +
        + {{ document.storedObject.createdAt|format_date('short') }} +
        +
        +
        +
        + +
        +
        +

        + + {{ w.socialAction|chill_entity_render_string }} > {{ document.accompanyingPeriodWorkEvaluation.evaluation.title|localize_translatable_string }} + +

        +
        +
        + +
        +
        + {{ mmm.createdBy(document) }} +
        +
          +
        • + {{ chill_entity_workflow_list('Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluationDocument', document.id) }} +
        • + {% if is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_EVALUATION_DOCUMENT_SHOW', document) %} +
        • + {{ document.storedObject|chill_document_button_group(document.title, is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_UPDATE', document.accompanyingPeriodWorkEvaluation.accompanyingPeriodWork)) }} +
        • + {% endif %} + {% if is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_SEE', w)%} +
        • + +
        • + {% endif %} + {% if is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_UPDATE', w) %} +
        • + +
        • + {% endif %} +
        + +
        +
        diff --git a/src/Bundle/ChillPersonBundle/Service/GenericDoc/Providers/AccompanyingPeriodWorkEvaluationGenericDocProvider.php b/src/Bundle/ChillPersonBundle/Service/GenericDoc/Providers/AccompanyingPeriodWorkEvaluationGenericDocProvider.php new file mode 100644 index 000000000..834375bfc --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Service/GenericDoc/Providers/AccompanyingPeriodWorkEvaluationGenericDocProvider.php @@ -0,0 +1,105 @@ +entityManager->getClassMetadata(AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocument::class); + $storedObjectMetadata = $this->entityManager->getClassMetadata(StoredObject::class); + $evaluationMetadata = $this->entityManager->getClassMetadata(AccompanyingPeriod\AccompanyingPeriodWorkEvaluation::class); + $accompanyingPeriodWorkMetadata = $this->entityManager->getClassMetadata(AccompanyingPeriod\AccompanyingPeriodWork::class); + + $query = new FetchQuery( + self::KEY, + sprintf("jsonb_build_object('id', apwed.%s)", $classMetadata->getColumnName('id')), + sprintf('apwed.'.$storedObjectMetadata->getColumnName('createdAt')), + $classMetadata->getTableName().' AS apwed' + ); + $query->addJoinClause(sprintf( + 'JOIN %s doc_store ON doc_store.%s = apwed.%s', + $storedObjectMetadata->getSchemaName().'.'.$storedObjectMetadata->getTableName(), + $storedObjectMetadata->getColumnName('id'), + $classMetadata->getSingleAssociationJoinColumnName('storedObject') + )); + $query->addJoinClause(sprintf( + 'JOIN %s evaluation ON apwed.%s = evaluation.%s', + $evaluationMetadata->getTableName(), + $classMetadata->getAssociationMapping('accompanyingPeriodWorkEvaluation')['joinColumns'][0]['name'], + $evaluationMetadata->getColumnName('id') + )); + $query->addJoinClause(sprintf( + 'JOIN %s action ON evaluation.%s = action.%s', + $accompanyingPeriodWorkMetadata->getTableName(), + $evaluationMetadata->getAssociationMapping('accompanyingPeriodWork')['joinColumns'][0]['name'], + $accompanyingPeriodWorkMetadata->getColumnName('id') + )); + + $query->addWhereClause( + sprintf('action.%s = ?', $accompanyingPeriodWorkMetadata->getAssociationMapping('accompanyingPeriod')['joinColumns'][0]['name']), + [$accompanyingPeriod->getId()], + [Types::INTEGER] + ); + + if (null !== $startDate) { + $query->addWhereClause( + sprintf('doc_store.%s <= ?', $storedObjectMetadata->getColumnName('createdAt')), + [$startDate], + [Types::DATE_IMMUTABLE] + ); + } + + if (null !== $endDate) { + $query->addWhereClause( + sprintf('doc_store.%s > ?', $storedObjectMetadata->getColumnName('createdAt')), + [$endDate], + [Types::DATE_IMMUTABLE] + ); + } + + if (null !== $content) { + $query->addWhereClause( + sprintf('apwed.%s ilike ?', $classMetadata->getColumnName('title')), + ['%' . $content . '%'], + [Types::STRING] + ); + } + + return $query; + } + + public function isAllowedForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod): bool + { + return $this->security->isGranted(AccompanyingPeriodWorkVoter::SEE, $accompanyingPeriod); + } + + +} diff --git a/src/Bundle/ChillPersonBundle/Service/GenericDoc/Renderer/AccompanyingPeriodWorkEvaluationGenericDocRenderer.php b/src/Bundle/ChillPersonBundle/Service/GenericDoc/Renderer/AccompanyingPeriodWorkEvaluationGenericDocRenderer.php new file mode 100644 index 000000000..5da8297fb --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Service/GenericDoc/Renderer/AccompanyingPeriodWorkEvaluationGenericDocRenderer.php @@ -0,0 +1,42 @@ +key === AccompanyingPeriodWorkEvaluationGenericDocProvider::KEY; + } + + public function getTemplate(GenericDocDTO $genericDocDTO, $options = []): string + { + return '@ChillPerson/GenericDoc/evaluation_document.html.twig'; + } + + public function getTemplateData(GenericDocDTO $genericDocDTO, $options = []): array + { + return [ + 'document' => $this->accompanyingPeriodWorkEvaluationDocumentRepository->find($genericDocDTO->identifiers['id']) + ]; + } +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Service/GenericDoc/Providers/AccompanyingPeriodWorkEvaluationGenericDocProviderTest.php b/src/Bundle/ChillPersonBundle/Tests/Service/GenericDoc/Providers/AccompanyingPeriodWorkEvaluationGenericDocProviderTest.php new file mode 100644 index 000000000..c9ed96581 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Service/GenericDoc/Providers/AccompanyingPeriodWorkEvaluationGenericDocProviderTest.php @@ -0,0 +1,79 @@ +entityManager = self::$container->get(EntityManagerInterface::class); + } + + /** + * @dataProvider provideSearchArguments + */ + public function testBuildFetchQueryForAccompanyingPeriod( + ?\DateTimeImmutable $startDate = null, + ?\DateTimeImmutable $endDate = null, + ?string $content = null + ): void { + $period = $this->entityManager->createQuery("SELECT a FROM " . AccompanyingPeriod::class . ' a') + ->setMaxResults(1) + ->getSingleResult(); + + if (null === $period) { + throw new \RuntimeException('no accompanying period in databasee'); + } + + $security = $this->prophesize(Security::class); + + $provider = new AccompanyingPeriodWorkEvaluationGenericDocProvider( + $security->reveal(), + $this->entityManager + ); + + $query = $provider->buildFetchQueryForAccompanyingPeriod($period, $startDate, $endDate, $content); + ['sql' => $sql, 'params' => $params, 'types' => $types] = (new FetchQueryToSqlBuilder())->toSql($query); + + $nb = $this->entityManager->getConnection()->executeQuery( + 'SELECT COUNT(*) FROM ('.$sql.') AS sq', + $params, + $types + )->fetchOne(); + + self::assertIsInt($nb, "Test that there are no errors"); + } + + public function provideSearchArguments(): iterable + { + yield [null, null, null]; + yield [new \DateTimeImmutable('1 month ago'), null, null]; + yield [new \DateTimeImmutable('1 month ago'), new \DateTimeImmutable('now'), null]; + yield [null, null, 'test']; + } +} From a3d3588b75d37d7573ffe9626aa94ac7a6b57f54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 26 May 2023 22:01:02 +0200 Subject: [PATCH 117/724] DX: fix json_decode signature --- src/Bundle/ChillDocStoreBundle/GenericDoc/Manager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bundle/ChillDocStoreBundle/GenericDoc/Manager.php b/src/Bundle/ChillDocStoreBundle/GenericDoc/Manager.php index 1a0287a71..498693206 100644 --- a/src/Bundle/ChillDocStoreBundle/GenericDoc/Manager.php +++ b/src/Bundle/ChillDocStoreBundle/GenericDoc/Manager.php @@ -80,7 +80,7 @@ class Manager foreach($this->connection->iterateAssociative($runSql, $runParams, $runTypes) as $row) { yield new GenericDocDTO( $row['key'], - json_decode($row['identifiers'], true, JSON_THROW_ON_ERROR), + json_decode($row['identifiers'], true, 512, JSON_THROW_ON_ERROR), new \DateTimeImmutable($row['doc_date']), $accompanyingPeriod, ); From eb107f5a1506b60afeb28d535f0688b833ad6264 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 30 May 2023 12:46:05 +0200 Subject: [PATCH 118/724] add filter for generic doc + fix issues in filter --- ...ericDocForAccompanyingPeriodController.php | 38 +++++++++++-- .../GenericDoc/GenericDocDTO.php | 8 +-- .../GenericDoc/Manager.php | 53 ++++++++++++++----- ...anyingProviderCourseDocumentGenericDoc.php | 6 +-- .../accompanying_period_list.html.twig | 2 + .../Tests/GenericDoc/ManagerTest.php | 7 ++- .../translations/messages.fr.yml | 6 +++ .../Templating/Listing/FilterOrderHelper.php | 5 ++ ...PeriodWorkEvaluationGenericDocProvider.php | 4 +- .../translations/messages.fr.yml | 5 ++ 10 files changed, 109 insertions(+), 25 deletions(-) diff --git a/src/Bundle/ChillDocStoreBundle/Controller/GenericDocForAccompanyingPeriodController.php b/src/Bundle/ChillDocStoreBundle/Controller/GenericDocForAccompanyingPeriodController.php index 7403e2ebc..70c41db50 100644 --- a/src/Bundle/ChillDocStoreBundle/Controller/GenericDocForAccompanyingPeriodController.php +++ b/src/Bundle/ChillDocStoreBundle/Controller/GenericDocForAccompanyingPeriodController.php @@ -14,6 +14,7 @@ namespace Chill\DocStoreBundle\Controller; use Chill\DocStoreBundle\GenericDoc\Manager; use Chill\DocStoreBundle\Security\Authorization\AccompanyingCourseDocumentVoter; use Chill\MainBundle\Pagination\PaginatorFactory; +use Chill\MainBundle\Templating\Listing\FilterOrderHelperFactory; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Symfony\Bundle\TwigBundle\TwigEngine; use Symfony\Component\HttpFoundation\Response; @@ -25,9 +26,10 @@ use Symfony\Component\Templating\EngineInterface; final readonly class GenericDocForAccompanyingPeriodController { public function __construct( - private Security $security, + private FilterOrderHelperFactory $filterOrderHelperFactory, private Manager $manager, private PaginatorFactory $paginator, + private Security $security, private EngineInterface $twig, ) { } @@ -45,12 +47,41 @@ final readonly class GenericDocForAccompanyingPeriodController throw new AccessDeniedHttpException("not allowed to see the documents for accompanying period"); } - $nb = $this->manager->countDocForAccompanyingPeriod($accompanyingPeriod); + $filterBuilder = $this->filterOrderHelperFactory + ->create(self::class) + ->addSearchBox() + ->addDateRange('dateRange', 'generic_doc.filter.date-range'); + + if ([] !== $places = $this->manager->placesForAccompanyingPeriod($accompanyingPeriod)) { + $filterBuilder->addCheckbox('places', $places, [], array_map( + static fn (string $k) => 'generic_doc.filter.keys.' . $k, + $places + )); + } + + $filter = $filterBuilder + ->build(); + + ['to' => $endDate, 'from' => $startDate ] = $filter->getDateRangeData('dateRange'); + $content = $filter->getQueryString(); + + $nb = $this->manager->countDocForAccompanyingPeriod( + $accompanyingPeriod, + $startDate, + $endDate, + $content, + $filter->hasCheckBox('places') ? array_values($filter->getCheckboxData('places')) : [] + ); $paginator = $this->paginator->create($nb); + $documents = $this->manager->findDocForAccompanyingPeriod( $accompanyingPeriod, $paginator->getCurrentPageFirstItemNumber(), - $paginator->getItemsPerPage() + $paginator->getItemsPerPage(), + $startDate, + $endDate, + $content, + $filter->hasCheckBox('places') ? array_values($filter->getCheckboxData('places')) : [] ); return new Response($this->twig->render( @@ -59,6 +90,7 @@ final readonly class GenericDocForAccompanyingPeriodController 'accompanyingCourse' => $accompanyingPeriod, 'pagination' => $paginator, 'documents' => iterator_to_array($documents), + 'filter' => $filter, ] )); } diff --git a/src/Bundle/ChillDocStoreBundle/GenericDoc/GenericDocDTO.php b/src/Bundle/ChillDocStoreBundle/GenericDoc/GenericDocDTO.php index e47814685..25a96750c 100644 --- a/src/Bundle/ChillDocStoreBundle/GenericDoc/GenericDocDTO.php +++ b/src/Bundle/ChillDocStoreBundle/GenericDoc/GenericDocDTO.php @@ -14,12 +14,12 @@ namespace Chill\DocStoreBundle\GenericDoc; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\Person; -class GenericDocDTO +final readonly class GenericDocDTO { public function __construct( - public readonly string $key, - public readonly array $identifiers, - public readonly \DateTimeImmutable $docDate, + public string $key, + public array $identifiers, + public \DateTimeImmutable $docDate, public AccompanyingPeriod|Person $linked, ) { } diff --git a/src/Bundle/ChillDocStoreBundle/GenericDoc/Manager.php b/src/Bundle/ChillDocStoreBundle/GenericDoc/Manager.php index 498693206..dad432e3e 100644 --- a/src/Bundle/ChillDocStoreBundle/GenericDoc/Manager.php +++ b/src/Bundle/ChillDocStoreBundle/GenericDoc/Manager.php @@ -32,6 +32,7 @@ class Manager } /** + * @param list $places * @throws Exception */ public function countDocForAccompanyingPeriod( @@ -39,16 +40,16 @@ class Manager ?\DateTimeImmutable $startDate = null, ?\DateTimeImmutable $endDate = null, ?string $content = null, - ?string $origin = null + array $places = [] ): int { - ['sql' => $sql, 'params' => $params] = $this->buildUnionQuery($accompanyingPeriod, $startDate, $endDate, $content, $origin); + ['sql' => $sql, 'params' => $params, 'types' => $types] = $this->buildUnionQuery($accompanyingPeriod, $startDate, $endDate, $content, $places); if ($sql === '') { return 0; } $countSql = "SELECT count(*) AS c FROM ({$sql}) AS sq"; - $result = $this->connection->executeQuery($countSql, $params); + $result = $this->connection->executeQuery($countSql, $params, $types); $number = $result->fetchOne(); @@ -60,6 +61,7 @@ class Manager } /** + * @param list $places places to search. When empty, search in all places * @throws Exception */ public function findDocForAccompanyingPeriod( @@ -69,15 +71,19 @@ class Manager ?\DateTimeImmutable $startDate = null, ?\DateTimeImmutable $endDate = null, ?string $content = null, - ?string $origin = null + array $places = [] ): iterable { - ['sql' => $sql, 'params' => $params, 'types' => $types] = $this->buildUnionQuery($accompanyingPeriod, $startDate, $endDate, $content, $origin); + ['sql' => $sql, 'params' => $params, 'types' => $types] = $this->buildUnionQuery($accompanyingPeriod, $startDate, $endDate, $content, $places); + + if ($sql === '') { + return []; + } $runSql = "{$sql} ORDER BY doc_date DESC LIMIT ? OFFSET ?"; $runParams = [...$params, ...[$limit, $offset]]; $runTypes = [...$types, ...[Types::INTEGER, Types::INTEGER]]; - foreach($this->connection->iterateAssociative($runSql, $runParams, $runTypes) as $row) { + foreach ($this->connection->iterateAssociative($runSql, $runParams, $runTypes) as $row) { yield new GenericDocDTO( $row['key'], json_decode($row['identifiers'], true, 512, JSON_THROW_ON_ERROR), @@ -87,14 +93,34 @@ class Manager } } + public function placesForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod): array + { + ['sql' => $sql, 'params' => $params, 'types' => $types] = $this->buildUnionQuery($accompanyingPeriod); + + if ($sql === '') { + return []; + } + + $runSql = "SELECT DISTINCT key FROM ({$sql}) AS sq"; + + $keys = []; + + foreach ($this->connection->iterateAssociative($runSql, $params, $types) as $k) { + $keys[] = $k['key']; + } + + return $keys; + } + /** + * @param list $places places to search. When empty, search in all places */ private function buildUnionQuery( AccompanyingPeriod|Person $linked, ?\DateTimeImmutable $startDate = null, ?\DateTimeImmutable $endDate = null, ?string $content = null, - ?string $origin = null + array $places = [], ): array { $sql = []; $params = []; @@ -105,17 +131,20 @@ class Manager if (!$provider->isAllowedForAccompanyingPeriod($linked)) { continue; } + $query = $provider->buildFetchQueryForAccompanyingPeriod($linked, $startDate, $endDate, $content); - ['sql' => $q, 'params' => $p, 'types' => $t ] = $this->builder - ->toSql($provider->buildFetchQueryForAccompanyingPeriod($linked, $startDate, $endDate, $content, $origin)); - $params = [...$params, ...$p]; - $types = [...$types, ...$t]; + if ([] !== $places and !in_array($query->getSelectKeyString(), $places, true)) { + continue; + } + + ['sql' => $q, 'params' => $p, 'types' => $t ] = $this->builder->toSql($query); $sql[] = $q; + $params = [...$params, ...$p]; + $types = [...$types, ...$t]; } } return ['sql' => implode(' UNION ', $sql), 'params' => $params, 'types' => $types]; } - } diff --git a/src/Bundle/ChillDocStoreBundle/GenericDoc/Providers/AccompanyingProviderCourseDocumentGenericDoc.php b/src/Bundle/ChillDocStoreBundle/GenericDoc/Providers/AccompanyingProviderCourseDocumentGenericDoc.php index fc0eb3b5f..970ce646d 100644 --- a/src/Bundle/ChillDocStoreBundle/GenericDoc/Providers/AccompanyingProviderCourseDocumentGenericDoc.php +++ b/src/Bundle/ChillDocStoreBundle/GenericDoc/Providers/AccompanyingProviderCourseDocumentGenericDoc.php @@ -50,7 +50,7 @@ final readonly class AccompanyingProviderCourseDocumentGenericDoc implements Gen if (null !== $startDate) { $query->addWhereClause( - sprintf('? >= %s', $classMetadata->getColumnName('date')), + sprintf('? <= %s', $classMetadata->getColumnName('date')), [$startDate], [Types::DATE_IMMUTABLE] ); @@ -58,7 +58,7 @@ final readonly class AccompanyingProviderCourseDocumentGenericDoc implements Gen if (null !== $endDate) { $query->addWhereClause( - sprintf('? < %s', $classMetadata->getColumnName('date')), + sprintf('? >= %s', $classMetadata->getColumnName('date')), [$endDate], [Types::DATE_IMMUTABLE] ); @@ -71,7 +71,7 @@ final readonly class AccompanyingProviderCourseDocumentGenericDoc implements Gen $classMetadata->getColumnName('title'), $classMetadata->getColumnName('description') ), - [$content, $content], + ['%' . $content . '%', '%' . $content . '%'], [Types::STRING, Types::STRING] ); } diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/GenericDoc/accompanying_period_list.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/GenericDoc/accompanying_period_list.html.twig index b2967d2f0..f76e4b984 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/views/GenericDoc/accompanying_period_list.html.twig +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/GenericDoc/accompanying_period_list.html.twig @@ -22,6 +22,8 @@

        {{ 'Documents' }}

        + {{ filter|chill_render_filter_order_helper }} + {% if documents|length == 0 %}

        {{ 'No documents'|trans }}

        {% else %} diff --git a/src/Bundle/ChillDocStoreBundle/Tests/GenericDoc/ManagerTest.php b/src/Bundle/ChillDocStoreBundle/Tests/GenericDoc/ManagerTest.php index 2bda8e2ae..597aea84a 100644 --- a/src/Bundle/ChillDocStoreBundle/Tests/GenericDoc/ManagerTest.php +++ b/src/Bundle/ChillDocStoreBundle/Tests/GenericDoc/ManagerTest.php @@ -18,6 +18,7 @@ use Chill\DocStoreBundle\GenericDoc\Manager; use Chill\DocStoreBundle\GenericDoc\GenericDocForAccompanyingPeriodProviderInterface; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Doctrine\DBAL\Connection; +use Doctrine\DBAL\Types\Types; use Doctrine\ORM\EntityManagerInterface; use Prophecy\PhpUnit\ProphecyTrait; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; @@ -86,12 +87,16 @@ final readonly class SimpleGenericDocProvider implements GenericDocForAccompanyi { public function buildFetchQueryForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod, ?\DateTimeImmutable $startDate = null, ?\DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface { - return new FetchQuery( + $query = new FetchQuery( 'accompanying_course_document', sprintf('jsonb_build_object(\'id\', %s)', 'id'), 'd', '(VALUES (1, \'2023-05-01\'::date), (2, \'2023-05-01\'::date)) AS sq (id, d)', ); + + $query->addWhereClause('d > ?', [new \DateTimeImmutable('2023-01-01')], [Types::DATE_IMMUTABLE]); + + return $query; } public function isAllowedForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod): bool diff --git a/src/Bundle/ChillDocStoreBundle/translations/messages.fr.yml b/src/Bundle/ChillDocStoreBundle/translations/messages.fr.yml index 1d06c58e4..1dde57eee 100644 --- a/src/Bundle/ChillDocStoreBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillDocStoreBundle/translations/messages.fr.yml @@ -22,6 +22,12 @@ Any description: Aucune description document: Any title: Aucun titre +generic_doc: + filter: + keys: + accompanying_course_document: Document du parcours + date-range: Date du document + # delete Delete document ?: Supprimer le document ? Are you sure you want to remove this document ?: Êtes-vous sûr·e de vouloir supprimer ce document ? diff --git a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php index 367cc0861..94aa3c50b 100644 --- a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php +++ b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php @@ -91,6 +91,11 @@ class FilterOrderHelper return $this->checkboxes; } + public function hasCheckBox(string $name): bool + { + return array_key_exists($name, $this->checkboxes); + } + /** * @return array<'to': DateTimeImmutable, 'from': DateTimeImmutable> */ diff --git a/src/Bundle/ChillPersonBundle/Service/GenericDoc/Providers/AccompanyingPeriodWorkEvaluationGenericDocProvider.php b/src/Bundle/ChillPersonBundle/Service/GenericDoc/Providers/AccompanyingPeriodWorkEvaluationGenericDocProvider.php index 834375bfc..883836547 100644 --- a/src/Bundle/ChillPersonBundle/Service/GenericDoc/Providers/AccompanyingPeriodWorkEvaluationGenericDocProvider.php +++ b/src/Bundle/ChillPersonBundle/Service/GenericDoc/Providers/AccompanyingPeriodWorkEvaluationGenericDocProvider.php @@ -71,7 +71,7 @@ final readonly class AccompanyingPeriodWorkEvaluationGenericDocProvider implemen if (null !== $startDate) { $query->addWhereClause( - sprintf('doc_store.%s <= ?', $storedObjectMetadata->getColumnName('createdAt')), + sprintf('doc_store.%s >= ?', $storedObjectMetadata->getColumnName('createdAt')), [$startDate], [Types::DATE_IMMUTABLE] ); @@ -79,7 +79,7 @@ final readonly class AccompanyingPeriodWorkEvaluationGenericDocProvider implemen if (null !== $endDate) { $query->addWhereClause( - sprintf('doc_store.%s > ?', $storedObjectMetadata->getColumnName('createdAt')), + sprintf('doc_store.%s < ?', $storedObjectMetadata->getColumnName('createdAt')), [$endDate], [Types::DATE_IMMUTABLE] ); diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 341136f65..a344ac50d 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -1231,3 +1231,8 @@ social_action: social_issue: and children: et dérivés + +generic_doc: + filter: + keys: + accompanying_period_work_evaluation_document: Document des actions d'accompagnement From 90a5a735aafebb58ba16d8ea17e2383fe0d2f13f Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 30 May 2023 14:38:16 +0200 Subject: [PATCH 119/724] FIX [route] adjust to using new route name in redirect --- .../Controller/DocumentAccompanyingCourseController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseController.php b/src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseController.php index 8762050aa..384eeb510 100644 --- a/src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseController.php +++ b/src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseController.php @@ -160,7 +160,7 @@ class DocumentAccompanyingCourseController extends AbstractController $this->addFlash('success', $this->translator->trans('The document is successfully registered')); - return $this->redirectToRoute('accompanying_course_document_index', ['course' => $course->getId()]); + return $this->redirectToRoute('chill_docstore_generic-doc_by-period_index', ['id' => $course->getId()]); } if ($form->isSubmitted() && !$form->isValid()) { From 101cca8662e0aef2444cfd189975cec118fd98da Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 30 May 2023 16:56:20 +0200 Subject: [PATCH 120/724] FEATURE [genericDoc] generic doc interface implemented for rendez-vous --- .../GenericDoc/calendar_document.html.twig | 72 +++++++++++++ ...anyingPeriodCalendarGenericDocProvider.php | 101 ++++++++++++++++++ ...anyingPeriodCalendarGenericDocRenderer.php | 44 ++++++++ .../translations/messages.fr.yml | 2 + .../translations/messages.fr.yml | 1 + 5 files changed, 220 insertions(+) create mode 100644 src/Bundle/ChillCalendarBundle/Resources/views/GenericDoc/calendar_document.html.twig create mode 100644 src/Bundle/ChillCalendarBundle/Service/GenericDoc/Providers/AccompanyingPeriodCalendarGenericDocProvider.php create mode 100644 src/Bundle/ChillCalendarBundle/Service/GenericDoc/Renderers/AccompanyingPeriodCalendarGenericDocRenderer.php diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/GenericDoc/calendar_document.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/GenericDoc/calendar_document.html.twig new file mode 100644 index 000000000..712b362f5 --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/Resources/views/GenericDoc/calendar_document.html.twig @@ -0,0 +1,72 @@ +{% import "@ChillDocStore/Macro/macro.html.twig" as m %} +{% import "@ChillDocStore/Macro/macro_mimeicon.html.twig" as mm %} +{% import '@ChillPerson/Macro/updatedBy.html.twig' as mmm %} + +{% set c = document.calendar %} + +
        +
        +
        + {% if document.storedObject.isPending %} +
        {{ 'docgen.Doc generation is pending'|trans }}
        + {% elseif document.storedObject.isFailure %} +
        {{ 'docgen.Doc generation failed'|trans }}
        + {% endif %} +
        + {{ document.storedObject.title }} +
        +
        + {{ 'chill_calendar.Document'|trans }} +
        + {% if document.storedObject.hasTemplate %} +
        +

        {{ document.storedObject.template.name|localize_translatable_string }}

        +
        + {% endif %} +
        + +
        +
        +
        + {{ document.storedObject.createdAt|format_date('short') }} +
        +
        +
        +
        + +
        +
        +

        + {% if c.endDate.diff(c.startDate).days >= 1 %} + {{ c.startDate|format_datetime('short', 'short') }} + - {{ c.endDate|format_datetime('short', 'short') }} + {% else %} + {{ c.startDate|format_datetime('short', 'short') }} + - {{ c.endDate|format_datetime('none', 'short') }} + {% endif %} +

        +
        +
        + +
        +
        + {{ mmm.createdBy(document) }} +
        +
          +
        • + {{ chill_entity_workflow_list('Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluationDocument', document.id) }} +
        • + {% if is_granted('CHILL_CALENDAR_DOC_SEE', document) %} +
        • + {{ document.storedObject|chill_document_button_group(document.storedObject.title, is_granted('CHILL_CALENDAR_CALENDAR_EDIT', c)) }} +
        • + {% endif %} + {% if is_granted('CHILL_CALENDAR_CALENDAR_EDIT', c) %} +
        • + +
        • + {% endif %} +
        + +
        +
        diff --git a/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Providers/AccompanyingPeriodCalendarGenericDocProvider.php b/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Providers/AccompanyingPeriodCalendarGenericDocProvider.php new file mode 100644 index 000000000..ff2cdbcf5 --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Providers/AccompanyingPeriodCalendarGenericDocProvider.php @@ -0,0 +1,101 @@ +security = $security; + $this->em = $entityManager; + } + + public function buildFetchQueryForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod, ?\DateTimeImmutable $startDate = null, ?\DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface + { + $classMetadata = $this->em->getClassMetadata(CalendarDoc::class); + $storedObjectMetadata = $this->em->getClassMetadata(StoredObject::class); + $calendarMetadata = $this->em->getClassMetadata(Calendar::class); + + $query = new FetchQuery( + self::KEY, + sprintf("jsonb_build_object('id', cd.%s)", $classMetadata->getColumnName('id')), + 'cd.'.$storedObjectMetadata->getColumnName('createdAt'), + $classMetadata->getSchemaName().'.'.$classMetadata->getTableName().' AS cd' + ); + $query->addJoinClause( + 'JOIN chill_doc.stored_object doc_store ON doc_store.id = cd.storedobject_id' + ); + + $query->addJoinClause( + 'JOIN chill_calendar.calendar calendar ON calendar.id = cd.calendar_id' + ); + + $query->addWhereClause( + 'calendar.accompanyingperiod_id = ?', + [$accompanyingPeriod->getId()], + [Types::INTEGER] + ); + + if (null !== $startDate) { + $query->addWhereClause( + sprintf('doc_store.%s >= ?', $storedObjectMetadata->getColumnName('createdAt')), + [$startDate], + [Types::DATE_IMMUTABLE] + ); + } + + if (null !== $endDate) { + $query->addWhereClause( + sprintf('doc_store.%s < ?', $storedObjectMetadata->getColumnName('createdAt')), + [$endDate], + [Types::DATE_IMMUTABLE] + ); + } + + if (null !== $content) { + $query->addWhereClause( + 'doc_store.title ilike ?', + ['%' . $content . '%'], + [Types::STRING] + ); + } + + return $query; + } + + public function isAllowedForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod): bool + { + return $this->security->isGranted(CalendarVoter::SEE, $accompanyingPeriod); + } + + +} diff --git a/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Renderers/AccompanyingPeriodCalendarGenericDocRenderer.php b/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Renderers/AccompanyingPeriodCalendarGenericDocRenderer.php new file mode 100644 index 000000000..0f680797c --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Renderers/AccompanyingPeriodCalendarGenericDocRenderer.php @@ -0,0 +1,44 @@ +repository = $calendarDocRepository; + } + + public function supports(GenericDocDTO $genericDocDTO, $options = []): bool + { + return $genericDocDTO->key === AccompanyingPeriodCalendarGenericDocProvider::KEY; + } + + public function getTemplate(GenericDocDTO $genericDocDTO, $options = []): string + { + return '@ChillCalendar/GenericDoc/calendar_document.html.twig'; + } + + public function getTemplateData(GenericDocDTO $genericDocDTO, $options = []): array + { + return [ + 'document' => $this->repository->find($genericDocDTO->identifiers['id']) + ]; + } +} diff --git a/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml b/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml index eb02be280..5e1fc971a 100644 --- a/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml @@ -43,6 +43,7 @@ crud: title_edit: Modifier le motif d'annulation chill_calendar: + Document: Document d'un rendez-vous form: The main user is mandatory. He will organize the appointment.: L'utilisateur principal est obligatoire. Il est l'organisateur de l'événement. Create for referrer: Créer pour le référent @@ -65,6 +66,7 @@ chill_calendar: Document outdated: La date et l'heure du rendez-vous ont été modifiés après la création du document + remote_ms_graph: freebusy_statuses: busy: Occupé diff --git a/src/Bundle/ChillDocStoreBundle/translations/messages.fr.yml b/src/Bundle/ChillDocStoreBundle/translations/messages.fr.yml index 1dde57eee..4fa41f180 100644 --- a/src/Bundle/ChillDocStoreBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillDocStoreBundle/translations/messages.fr.yml @@ -26,6 +26,7 @@ generic_doc: filter: keys: accompanying_course_document: Document du parcours + accompanying_period_calendar_document: Document des rendez-vous date-range: Date du document # delete From d09e5d33db2b3d2001208d1097b0915412b9137f Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 30 May 2023 16:59:16 +0200 Subject: [PATCH 121/724] WIP [genericDoc][activity] implementing generic doc for activities --- ...anyingPeriodActivityGenericDocProvider.php | 110 ++++++++++++++++++ ...anyingPeriodActivityGenericDocRenderer.php | 45 +++++++ 2 files changed, 155 insertions(+) create mode 100644 src/Bundle/ChillActivityBundle/Service/GenericDoc/Providers/AccompanyingPeriodActivityGenericDocProvider.php create mode 100644 src/Bundle/ChillActivityBundle/Service/GenericDoc/Renderers/AccompanyingPeriodActivityGenericDocRenderer.php diff --git a/src/Bundle/ChillActivityBundle/Service/GenericDoc/Providers/AccompanyingPeriodActivityGenericDocProvider.php b/src/Bundle/ChillActivityBundle/Service/GenericDoc/Providers/AccompanyingPeriodActivityGenericDocProvider.php new file mode 100644 index 000000000..fc7484edf --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Service/GenericDoc/Providers/AccompanyingPeriodActivityGenericDocProvider.php @@ -0,0 +1,110 @@ +em = $entityManager; + $this->security = $security; + } + + /** + * @param AccompanyingPeriod $accompanyingPeriod + * @param DateTimeImmutable|null $startDate + * @param DateTimeImmutable|null $endDate + * @param string|null $content + * @param string|null $origin + * @return FetchQueryInterface + * @throws MappingException + */ + public function buildFetchQueryForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface + { + $storedObjectMetadata = $this->em->getClassMetadata(StoredObject::class); +// $activityMetadata = $this->em->getClassMetadata(Activity::class); + + $query = new FetchQuery( + self::KEY, + "jsonb_build_object('id', doc_obj.id)", + 'doc_obj.'.$storedObjectMetadata->getColumnName('createdAt'), + $storedObjectMetadata->getSchemaName().'.'.$storedObjectMetadata->getTableName().' AS doc_obj' + ); + + $query->addJoinClause( + 'JOIN public.activity_storedobject activity_doc ON activity_doc.storedobject_id = doc_obj.id' + ); + + $query->addJoinClause( + 'JOIN public.activity activity ON activity.id = activity_doc.activity_id' + ); + + $query->addWhereClause( + 'activity.accompanyingperiod_id = ?', + [$accompanyingPeriod->getId()], + [Types::INTEGER] + ); + + if (null !== $startDate) { + $query->addWhereClause( + sprintf('doc_obj.%s >= ?', $storedObjectMetadata->getColumnName('createdAt')), + [$startDate], + [Types::DATE_IMMUTABLE] + ); + } + + if (null !== $endDate) { + $query->addWhereClause( + sprintf('doc_obj.%s < ?', $storedObjectMetadata->getColumnName('createdAt')), + [$endDate], + [Types::DATE_IMMUTABLE] + ); + } + + if (null !== $content) { + $query->addWhereClause( + 'doc_obj.title ilike ?', + ['%' . $content . '%'], + [Types::STRING] + ); + } + + return $query; + } + + /** + * @param AccompanyingPeriod $accompanyingPeriod + * @return bool + */ + public function isAllowedForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod): bool + { + return $this->security->isGranted(ActivityVoter::SEE, $accompanyingPeriod); + } +} diff --git a/src/Bundle/ChillActivityBundle/Service/GenericDoc/Renderers/AccompanyingPeriodActivityGenericDocRenderer.php b/src/Bundle/ChillActivityBundle/Service/GenericDoc/Renderers/AccompanyingPeriodActivityGenericDocRenderer.php new file mode 100644 index 000000000..eddcc6828 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Service/GenericDoc/Renderers/AccompanyingPeriodActivityGenericDocRenderer.php @@ -0,0 +1,45 @@ +repository = $storedObjectRepository; + } + + public function supports(GenericDocDTO $genericDocDTO, $options = []): bool + { + return $genericDocDTO->key === AccompanyingPeriodActivityGenericDocProvider::KEY; + } + + public function getTemplate(GenericDocDTO $genericDocDTO, $options = []): string + { + return '@ChillCalendar/GenericDoc/activity_document.html.twig'; + } + + public function getTemplateData(GenericDocDTO $genericDocDTO, $options = []): array + { + return [ + 'document' => $this->repository->find($genericDocDTO->identifiers['id']) + ]; + } +} + From bd074ebade229eaf747dd9be8f914e0f09f883a9 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 30 May 2023 17:50:32 +0200 Subject: [PATCH 122/724] FEATURE [genericDoc][calendar] use metadatas --- ...anyingPeriodCalendarGenericDocProvider.php | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Providers/AccompanyingPeriodCalendarGenericDocProvider.php b/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Providers/AccompanyingPeriodCalendarGenericDocProvider.php index ff2cdbcf5..e653cfc25 100644 --- a/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Providers/AccompanyingPeriodCalendarGenericDocProvider.php +++ b/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Providers/AccompanyingPeriodCalendarGenericDocProvider.php @@ -21,6 +21,7 @@ use Chill\DocStoreBundle\GenericDoc\GenericDocForAccompanyingPeriodProviderInter use Chill\PersonBundle\Entity\AccompanyingPeriod; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\EntityManagerInterface; +use Doctrine\ORM\Mapping\MappingException; use Symfony\Component\Security\Core\Security; final class AccompanyingPeriodCalendarGenericDocProvider implements GenericDocForAccompanyingPeriodProviderInterface @@ -39,6 +40,9 @@ final class AccompanyingPeriodCalendarGenericDocProvider implements GenericDocFo $this->em = $entityManager; } + /** + * @throws MappingException + */ public function buildFetchQueryForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod, ?\DateTimeImmutable $startDate = null, ?\DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface { $classMetadata = $this->em->getClassMetadata(CalendarDoc::class); @@ -52,15 +56,23 @@ final class AccompanyingPeriodCalendarGenericDocProvider implements GenericDocFo $classMetadata->getSchemaName().'.'.$classMetadata->getTableName().' AS cd' ); $query->addJoinClause( - 'JOIN chill_doc.stored_object doc_store ON doc_store.id = cd.storedobject_id' - ); + sprintf('JOIN %s doc_store ON doc_store.%s = cd.%s', + $storedObjectMetadata->getSchemaName().'.'.$storedObjectMetadata->getTableName(), + $storedObjectMetadata->getColumnName('id'), + $classMetadata->getSingleAssociationJoinColumnName('storedObject') + )); $query->addJoinClause( - 'JOIN chill_calendar.calendar calendar ON calendar.id = cd.calendar_id' + sprintf('JOIN %s calendar ON calendar.%s = cd.%s', + $calendarMetadata->getSchemaName().'.'.$calendarMetadata->getTableName(), + $calendarMetadata->getColumnName('id'), + $classMetadata->getSingleAssociationJoinColumnName('calendar') + ) ); $query->addWhereClause( - 'calendar.accompanyingperiod_id = ?', + sprintf('calendar.%s = ?', + $calendarMetadata->getAssociationMapping('accompanyingPeriod')['joinColumns'][0]['name']), [$accompanyingPeriod->getId()], [Types::INTEGER] ); @@ -83,7 +95,7 @@ final class AccompanyingPeriodCalendarGenericDocProvider implements GenericDocFo if (null !== $content) { $query->addWhereClause( - 'doc_store.title ilike ?', + sprintf('doc_store.%s ilike ?', $storedObjectMetadata->getColumnName('title')), ['%' . $content . '%'], [Types::STRING] ); From c245ffe559196e37eb38dd5aeb41f83fa13212a7 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 30 May 2023 18:14:32 +0200 Subject: [PATCH 123/724] WIP [genericDoc][activity] add repository method to get activity linked to storedObject --- .../Repository/ActivityRepository.php | 12 ++++ .../GenericDoc/activity_document.html.twig | 72 +++++++++++++++++++ ...anyingPeriodActivityGenericDocProvider.php | 3 +- ...anyingPeriodActivityGenericDocRenderer.php | 13 ++-- 4 files changed, 94 insertions(+), 6 deletions(-) create mode 100644 src/Bundle/ChillActivityBundle/Resources/views/GenericDoc/activity_document.html.twig diff --git a/src/Bundle/ChillActivityBundle/Repository/ActivityRepository.php b/src/Bundle/ChillActivityBundle/Repository/ActivityRepository.php index 5a6e16cd5..02658b03d 100644 --- a/src/Bundle/ChillActivityBundle/Repository/ActivityRepository.php +++ b/src/Bundle/ChillActivityBundle/Repository/ActivityRepository.php @@ -15,6 +15,7 @@ use Chill\ActivityBundle\Entity\Activity; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\Person; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; +use Doctrine\ORM\Query\Expr; use Doctrine\Persistence\ManagerRegistry; /** @@ -97,4 +98,15 @@ class ActivityRepository extends ServiceEntityRepository return $qb->getQuery()->getResult(); } + + public function findOneByDocument(int $documentId): Activity + { + $qb = $this->createQueryBuilder('a'); + $qb->select('a'); + + $qb->innerJoin('a.documents', 'd', Expr\Join::WITH, 'd.storedobject_id = :documentId'); + $qb->setParameter('documentId', $documentId); + + return $qb->getQuery()->getResult(); + } } diff --git a/src/Bundle/ChillActivityBundle/Resources/views/GenericDoc/activity_document.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/GenericDoc/activity_document.html.twig new file mode 100644 index 000000000..aeaea0872 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Resources/views/GenericDoc/activity_document.html.twig @@ -0,0 +1,72 @@ +{% import "@ChillDocStore/Macro/macro.html.twig" as m %} +{% import "@ChillDocStore/Macro/macro_mimeicon.html.twig" as mm %} +{% import '@ChillPerson/Macro/updatedBy.html.twig' as mmm %} + +{% set a = document.calendar %} + +
        +
        +
        + {% if document.storedObject.isPending %} +
        {{ 'docgen.Doc generation is pending'|trans }}
        + {% elseif document.storedObject.isFailure %} +
        {{ 'docgen.Doc generation failed'|trans }}
        + {% endif %} +
        + {{ document.storedObject.title }} +
        +
        + {{ 'chill_calendar.Document'|trans }} +
        + {% if document.storedObject.hasTemplate %} +
        +

        {{ document.storedObject.template.name|localize_translatable_string }}

        +
        + {% endif %} +
        + +
        +
        +
        + {{ document.storedObject.createdAt|format_date('short') }} +
        +
        +
        +
        + +
        +
        +

        + {% if c.endDate.diff(c.startDate).days >= 1 %} + {{ c.startDate|format_datetime('short', 'short') }} + - {{ c.endDate|format_datetime('short', 'short') }} + {% else %} + {{ c.startDate|format_datetime('short', 'short') }} + - {{ c.endDate|format_datetime('none', 'short') }} + {% endif %} +

        +
        +
        + +
        +
        + {{ mmm.createdBy(document) }} +
        +
          +
        • + {{ chill_entity_workflow_list('Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluationDocument', document.id) }} +
        • + {% if is_granted('CHILL_CALENDAR_DOC_SEE', document) %} +
        • + {{ document.storedObject|chill_document_button_group(document.storedObject.title, is_granted('CHILL_CALENDAR_CALENDAR_EDIT', c)) }} +
        • + {% endif %} + {% if is_granted('CHILL_CALENDAR_CALENDAR_EDIT', c) %} +
        • + +
        • + {% endif %} +
        + +
        +
        diff --git a/src/Bundle/ChillActivityBundle/Service/GenericDoc/Providers/AccompanyingPeriodActivityGenericDocProvider.php b/src/Bundle/ChillActivityBundle/Service/GenericDoc/Providers/AccompanyingPeriodActivityGenericDocProvider.php index fc7484edf..bf7a022f1 100644 --- a/src/Bundle/ChillActivityBundle/Service/GenericDoc/Providers/AccompanyingPeriodActivityGenericDocProvider.php +++ b/src/Bundle/ChillActivityBundle/Service/GenericDoc/Providers/AccompanyingPeriodActivityGenericDocProvider.php @@ -27,7 +27,7 @@ final class AccompanyingPeriodActivityGenericDocProvider implements GenericDocFo { public const KEY = 'accompanying_period_activity_document'; - private EntityManagerInterface $em; + private EntityManagerInterface $em; private Security $security; @@ -49,7 +49,6 @@ final class AccompanyingPeriodActivityGenericDocProvider implements GenericDocFo public function buildFetchQueryForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface { $storedObjectMetadata = $this->em->getClassMetadata(StoredObject::class); -// $activityMetadata = $this->em->getClassMetadata(Activity::class); $query = new FetchQuery( self::KEY, diff --git a/src/Bundle/ChillActivityBundle/Service/GenericDoc/Renderers/AccompanyingPeriodActivityGenericDocRenderer.php b/src/Bundle/ChillActivityBundle/Service/GenericDoc/Renderers/AccompanyingPeriodActivityGenericDocRenderer.php index eddcc6828..f243fb941 100644 --- a/src/Bundle/ChillActivityBundle/Service/GenericDoc/Renderers/AccompanyingPeriodActivityGenericDocRenderer.php +++ b/src/Bundle/ChillActivityBundle/Service/GenericDoc/Renderers/AccompanyingPeriodActivityGenericDocRenderer.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\ActivityBundle\Service\GenericDoc\Renderers; +use Chill\ActivityBundle\Repository\ActivityRepository; use Chill\ActivityBundle\Service\GenericDoc\Providers\AccompanyingPeriodActivityGenericDocProvider; use Chill\DocStoreBundle\GenericDoc\GenericDocDTO; use Chill\DocStoreBundle\GenericDoc\Twig\GenericDocRendererInterface; @@ -18,11 +19,14 @@ use Chill\DocStoreBundle\Repository\StoredObjectRepository; final class AccompanyingPeriodActivityGenericDocRenderer implements GenericDocRendererInterface { - private StoredObjectRepository $repository; + private StoredObjectRepository $objectRepository; - public function __construct(StoredObjectRepository $storedObjectRepository) + private ActivityRepository $activityRepository; + + public function __construct(StoredObjectRepository $storedObjectRepository, ActivityRepository $activityRepository) { - $this->repository = $storedObjectRepository; + $this->objectRepository = $storedObjectRepository; + $this->activityRepository = $activityRepository; } public function supports(GenericDocDTO $genericDocDTO, $options = []): bool @@ -38,7 +42,8 @@ final class AccompanyingPeriodActivityGenericDocRenderer implements GenericDocRe public function getTemplateData(GenericDocDTO $genericDocDTO, $options = []): array { return [ - 'document' => $this->repository->find($genericDocDTO->identifiers['id']) + 'activity' => $this->activityRepository->findOneByDocument($genericDocDTO->identifiers['id']), + 'document' => $this->objectRepository->find($genericDocDTO->identifiers['id']) ]; } } From 40af1e64ac5dc612833b95752e86244cf616a84a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 30 May 2023 20:48:35 +0200 Subject: [PATCH 124/724] [generic doc] listing generic doc for person --- .../ChillDocStoreBundle.php | 3 + .../Controller/GenericDocForPerson.php | 95 +++++++++++++ ...ForAccompanyingPeriodProviderInterface.php | 2 - .../GenericDocForPersonProviderInterface.php | 31 ++++ .../GenericDoc/Manager.php | 108 +++++++++++--- .../PersonDocumentGenericDocProvider.php | 51 +++++++ ...anyingCourseDocumentGenericDocRenderer.php | 20 ++- .../PersonDocumentACLAwareRepository.php | 134 ++++++++++++++++-- ...sonDocumentACLAwareRepositoryInterface.php | 14 ++ .../Repository/PersonDocumentRepository.php | 49 +++++++ .../views/GenericDoc/person_list.html.twig | 74 ++++++++++ .../Tests/GenericDoc/ManagerTest.php | 119 +++++++++++++++- .../PersonDocumentGenericDocProviderTest.php | 84 +++++++++++ .../PersonDocumentACLAwareRepositoryTest.php | 99 +++++++++++++ .../ChillDocStoreBundle/config/services.yaml | 1 + 15 files changed, 842 insertions(+), 42 deletions(-) create mode 100644 src/Bundle/ChillDocStoreBundle/Controller/GenericDocForPerson.php create mode 100644 src/Bundle/ChillDocStoreBundle/GenericDoc/GenericDocForPersonProviderInterface.php create mode 100644 src/Bundle/ChillDocStoreBundle/GenericDoc/Providers/PersonDocumentGenericDocProvider.php create mode 100644 src/Bundle/ChillDocStoreBundle/Repository/PersonDocumentRepository.php create mode 100644 src/Bundle/ChillDocStoreBundle/Resources/views/GenericDoc/person_list.html.twig create mode 100644 src/Bundle/ChillDocStoreBundle/Tests/GenericDoc/Providers/PersonDocumentGenericDocProviderTest.php create mode 100644 src/Bundle/ChillDocStoreBundle/Tests/Repository/PersonDocumentACLAwareRepositoryTest.php diff --git a/src/Bundle/ChillDocStoreBundle/ChillDocStoreBundle.php b/src/Bundle/ChillDocStoreBundle/ChillDocStoreBundle.php index bc659d146..8dcbe72c3 100644 --- a/src/Bundle/ChillDocStoreBundle/ChillDocStoreBundle.php +++ b/src/Bundle/ChillDocStoreBundle/ChillDocStoreBundle.php @@ -12,6 +12,7 @@ declare(strict_types=1); namespace Chill\DocStoreBundle; use Chill\DocStoreBundle\GenericDoc\GenericDocForAccompanyingPeriodProviderInterface; +use Chill\DocStoreBundle\GenericDoc\GenericDocForPersonProviderInterface; use Chill\DocStoreBundle\GenericDoc\Twig\GenericDocRendererInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Bundle\Bundle; @@ -22,6 +23,8 @@ class ChillDocStoreBundle extends Bundle { $container->registerForAutoconfiguration(GenericDocForAccompanyingPeriodProviderInterface::class) ->addTag('chill_doc_store.generic_doc_accompanying_period_provider'); + $container->registerForAutoconfiguration(GenericDocForPersonProviderInterface::class) + ->addTag('chill_doc_store.generic_doc_person_provider'); $container->registerForAutoconfiguration(GenericDocRendererInterface::class) ->addTag('chill_doc_store.generic_doc_renderer'); } diff --git a/src/Bundle/ChillDocStoreBundle/Controller/GenericDocForPerson.php b/src/Bundle/ChillDocStoreBundle/Controller/GenericDocForPerson.php new file mode 100644 index 000000000..3484e0904 --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/Controller/GenericDocForPerson.php @@ -0,0 +1,95 @@ +security->isGranted(PersonDocumentVoter::SEE, $person)) { + throw new AccessDeniedHttpException("not allowed to see the documents for person"); + } + + $filterBuilder = $this->filterOrderHelperFactory + ->create(self::class) + ->addSearchBox() + ->addDateRange('dateRange', 'generic_doc.filter.date-range'); + + if ([] !== $places = $this->manager->placesForPerson($person)) { + $filterBuilder->addCheckbox('places', $places, [], array_map( + static fn (string $k) => 'generic_doc.filter.keys.' . $k, + $places + )); + } + + $filter = $filterBuilder + ->build(); + + ['to' => $endDate, 'from' => $startDate ] = $filter->getDateRangeData('dateRange'); + $content = $filter->getQueryString(); + + $nb = $this->manager->countDocForPerson( + $person, + $startDate, + $endDate, + $content, + $filter->hasCheckBox('places') ? array_values($filter->getCheckboxData('places')) : [] + ); + $paginator = $this->paginator->create($nb); + + $documents = $this->manager->findDocForPerson( + $person, + $paginator->getCurrentPageFirstItemNumber(), + $paginator->getItemsPerPage(), + $startDate, + $endDate, + $content, + $filter->hasCheckBox('places') ? array_values($filter->getCheckboxData('places')) : [] + ); + + return new Response($this->twig->render( + '@ChillDocStore/GenericDoc/person_list.html.twig', + [ + 'person' => $person, + 'pagination' => $paginator, + 'documents' => iterator_to_array($documents), + 'filter' => $filter, + ] + )); + } + +} diff --git a/src/Bundle/ChillDocStoreBundle/GenericDoc/GenericDocForAccompanyingPeriodProviderInterface.php b/src/Bundle/ChillDocStoreBundle/GenericDoc/GenericDocForAccompanyingPeriodProviderInterface.php index 4702e74c7..0d3cb1c32 100644 --- a/src/Bundle/ChillDocStoreBundle/GenericDoc/GenericDocForAccompanyingPeriodProviderInterface.php +++ b/src/Bundle/ChillDocStoreBundle/GenericDoc/GenericDocForAccompanyingPeriodProviderInterface.php @@ -25,8 +25,6 @@ interface GenericDocForAccompanyingPeriodProviderInterface /** * Return true if the user is allowed to see some documents for this provider. - * - * @return bool */ public function isAllowedForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod): bool; diff --git a/src/Bundle/ChillDocStoreBundle/GenericDoc/GenericDocForPersonProviderInterface.php b/src/Bundle/ChillDocStoreBundle/GenericDoc/GenericDocForPersonProviderInterface.php new file mode 100644 index 000000000..027afe834 --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/GenericDoc/GenericDocForPersonProviderInterface.php @@ -0,0 +1,31 @@ + */ - private readonly iterable $providersForAccompanyingPeriod, - private readonly Connection $connection, + private iterable $providersForAccompanyingPeriod, + + /** + * @var iterable + */ + private iterable $providersForPerson, + private Connection $connection, ) { $this->builder = new FetchQueryToSqlBuilder(); } @@ -44,6 +49,11 @@ class Manager ): int { ['sql' => $sql, 'params' => $params, 'types' => $types] = $this->buildUnionQuery($accompanyingPeriod, $startDate, $endDate, $content, $places); + return $this->countDoc($sql, $params, $types); + } + + private function countDoc(string $sql, array $params, array $types): int + { if ($sql === '') { return 0; } @@ -60,8 +70,21 @@ class Manager return $number; } + public function countDocForPerson( + Person $person, + ?\DateTimeImmutable $startDate = null, + ?\DateTimeImmutable $endDate = null, + ?string $content = null, + array $places = [] + ): int { + ['sql' => $sql, 'params' => $params, 'types' => $types] = $this->buildUnionQuery($person, $startDate, $endDate, $content, $places); + + return $this->countDoc($sql, $params, $types); + } + /** * @param list $places places to search. When empty, search in all places + * @return iterable * @throws Exception */ public function findDocForAccompanyingPeriod( @@ -75,6 +98,15 @@ class Manager ): iterable { ['sql' => $sql, 'params' => $params, 'types' => $types] = $this->buildUnionQuery($accompanyingPeriod, $startDate, $endDate, $content, $places); + return $this->findDocs($accompanyingPeriod, $sql, $params, $types, $offset, $limit); + } + + /** + * @throws \JsonException + * @throws Exception + */ + private function findDocs(AccompanyingPeriod|Person $linked, string $sql, array $params, array $types, int $offset, int $limit): iterable + { if ($sql === '') { return []; } @@ -88,20 +120,50 @@ class Manager $row['key'], json_decode($row['identifiers'], true, 512, JSON_THROW_ON_ERROR), new \DateTimeImmutable($row['doc_date']), - $accompanyingPeriod, + $linked, ); } } + /** + * @param list $places places to search. When empty, search in all places + * @return iterable + */ + public function findDocForPerson( + Person $person, + int $offset = 0, + int $limit = 20, + ?\DateTimeImmutable $startDate = null, + ?\DateTimeImmutable $endDate = null, + ?string $content = null, + array $places = [] + ): iterable { + ['sql' => $sql, 'params' => $params, 'types' => $types] = $this->buildUnionQuery($person, $startDate, $endDate, $content, $places); + + return $this->findDocs($person, $sql, $params, $types, $offset, $limit); + } + + public function placesForPerson(Person $person): array + { + ['sql' => $sql, 'params' => $params, 'types' => $types] = $this->buildUnionQuery($person); + + return $this->places($sql, $params, $types); + } + public function placesForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod): array { ['sql' => $sql, 'params' => $params, 'types' => $types] = $this->buildUnionQuery($accompanyingPeriod); + return $this->places($sql, $params, $types); + } + + private function places(string $sql, array $params, array $types): array + { if ($sql === '') { return []; } - $runSql = "SELECT DISTINCT key FROM ({$sql}) AS sq"; + $runSql = "SELECT DISTINCT key FROM ({$sql}) AS sq ORDER BY key"; $keys = []; @@ -122,28 +184,38 @@ class Manager ?string $content = null, array $places = [], ): array { - $sql = []; - $params = []; - $types = []; + $queries = []; if ($linked instanceof AccompanyingPeriod) { foreach ($this->providersForAccompanyingPeriod as $provider) { if (!$provider->isAllowedForAccompanyingPeriod($linked)) { continue; } - $query = $provider->buildFetchQueryForAccompanyingPeriod($linked, $startDate, $endDate, $content); - - if ([] !== $places and !in_array($query->getSelectKeyString(), $places, true)) { + $queries[] = $provider->buildFetchQueryForAccompanyingPeriod($linked, $startDate, $endDate, $content); + } + } else { + foreach ($this->providersForPerson as $provider) { + if (!$provider->isAllowedForPerson($linked)) { continue; } - - ['sql' => $q, 'params' => $p, 'types' => $t ] = $this->builder->toSql($query); - - $sql[] = $q; - $params = [...$params, ...$p]; - $types = [...$types, ...$t]; + $queries[] = $provider->buildFetchQueryForPerson($linked, $startDate, $endDate, $content); } } + $sql = []; + $params = []; + $types = []; + + foreach ($queries as $query) { + if ([] !== $places and !in_array($query->getSelectKeyString(), $places, true)) { + continue; + } + + ['sql' => $q, 'params' => $p, 'types' => $t ] = $this->builder->toSql($query); + + $sql[] = $q; + $params = [...$params, ...$p]; + $types = [...$types, ...$t]; + } return ['sql' => implode(' UNION ', $sql), 'params' => $params, 'types' => $types]; } diff --git a/src/Bundle/ChillDocStoreBundle/GenericDoc/Providers/PersonDocumentGenericDocProvider.php b/src/Bundle/ChillDocStoreBundle/GenericDoc/Providers/PersonDocumentGenericDocProvider.php new file mode 100644 index 000000000..08a0df960 --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/GenericDoc/Providers/PersonDocumentGenericDocProvider.php @@ -0,0 +1,51 @@ +personDocumentACLAwareRepository->buildFetchQueryForPerson( + $person, + $startDate, + $endDate, + $content + ); + } + + public function isAllowedForPerson(Person $person): bool + { + return $this->security->isGranted(PersonDocumentVoter::SEE, $person); + } +} diff --git a/src/Bundle/ChillDocStoreBundle/GenericDoc/Renderer/AccompanyingCourseDocumentGenericDocRenderer.php b/src/Bundle/ChillDocStoreBundle/GenericDoc/Renderer/AccompanyingCourseDocumentGenericDocRenderer.php index 4e27f6335..a533b577a 100644 --- a/src/Bundle/ChillDocStoreBundle/GenericDoc/Renderer/AccompanyingCourseDocumentGenericDocRenderer.php +++ b/src/Bundle/ChillDocStoreBundle/GenericDoc/Renderer/AccompanyingCourseDocumentGenericDocRenderer.php @@ -12,20 +12,25 @@ declare(strict_types=1); namespace Chill\DocStoreBundle\GenericDoc\Renderer; use Chill\DocStoreBundle\GenericDoc\GenericDocDTO; +use Chill\DocStoreBundle\GenericDoc\Providers\PersonDocumentGenericDocProvider; use Chill\DocStoreBundle\GenericDoc\Twig\GenericDocRendererInterface; use Chill\DocStoreBundle\GenericDoc\Providers\AccompanyingProviderCourseDocumentGenericDoc; use Chill\DocStoreBundle\Repository\AccompanyingCourseDocumentRepository; +use Chill\DocStoreBundle\Repository\PersonDocumentRepository; +use Chill\PersonBundle\Entity\AccompanyingPeriod; final readonly class AccompanyingCourseDocumentGenericDocRenderer implements GenericDocRendererInterface { public function __construct( private AccompanyingCourseDocumentRepository $accompanyingCourseDocumentRepository, + private PersonDocumentRepository $personDocumentRepository, ) { } public function supports(GenericDocDTO $genericDocDTO, $options = []): bool { - return $genericDocDTO->key === AccompanyingProviderCourseDocumentGenericDoc::KEY; + return $genericDocDTO->key === AccompanyingProviderCourseDocumentGenericDoc::KEY + || $genericDocDTO->key === PersonDocumentGenericDocProvider::KEY; } public function getTemplate(GenericDocDTO $genericDocDTO, $options = []): string @@ -35,9 +40,18 @@ final readonly class AccompanyingCourseDocumentGenericDocRenderer implements Gen public function getTemplateData(GenericDocDTO $genericDocDTO, $options = []): array { + if ($genericDocDTO->linked instanceof AccompanyingPeriod) { + return [ + 'document' => $this->accompanyingCourseDocumentRepository->find($genericDocDTO->identifiers['id']), + 'accompanyingCourse' => $genericDocDTO->linked, + 'options' => $options, + ]; + } + + // this is a person return [ - 'document' => $this->accompanyingCourseDocumentRepository->find($genericDocDTO->identifiers['id']), - 'accompanyingCourse' => $genericDocDTO->linked, + 'document' => $this->personDocumentRepository->find($genericDocDTO->identifiers['id']), + 'person' => $genericDocDTO->linked, 'options' => $options, ]; } diff --git a/src/Bundle/ChillDocStoreBundle/Repository/PersonDocumentACLAwareRepository.php b/src/Bundle/ChillDocStoreBundle/Repository/PersonDocumentACLAwareRepository.php index 23dcc4e0b..5d85541aa 100644 --- a/src/Bundle/ChillDocStoreBundle/Repository/PersonDocumentACLAwareRepository.php +++ b/src/Bundle/ChillDocStoreBundle/Repository/PersonDocumentACLAwareRepository.php @@ -12,30 +12,36 @@ declare(strict_types=1); namespace Chill\DocStoreBundle\Repository; use Chill\DocStoreBundle\Entity\PersonDocument; +use Chill\DocStoreBundle\GenericDoc\FetchQuery; +use Chill\DocStoreBundle\GenericDoc\FetchQueryInterface; +use Chill\DocStoreBundle\GenericDoc\Providers\PersonDocumentGenericDocProvider; use Chill\DocStoreBundle\Security\Authorization\PersonDocumentVoter; +use Chill\MainBundle\Entity\Scope; +use Chill\MainBundle\Security\Authorization\AuthorizationHelperForCurrentUserInterface; use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface; use Chill\MainBundle\Security\Resolver\CenterResolverDispatcher; +use Chill\MainBundle\Security\Resolver\CenterResolverDispatcherInterface; +use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface; use Chill\PersonBundle\Entity\Person; +use DateTimeImmutable; +use Doctrine\DBAL\Types\Types; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Security\Core\Security; class PersonDocumentACLAwareRepository implements PersonDocumentACLAwareRepositoryInterface { - private AuthorizationHelperInterface $authorizationHelper; + private AuthorizationHelperForCurrentUserInterface $authorizationHelperForCurrentUser; - private CenterResolverDispatcher $centerResolverDispatcher; + private CenterResolverManagerInterface $centerResolverManager; private EntityManagerInterface $em; - private Security $security; - - public function __construct(EntityManagerInterface $em, AuthorizationHelperInterface $authorizationHelper, CenterResolverDispatcher $centerResolverDispatcher, Security $security) + public function __construct(EntityManagerInterface $em, CenterResolverManagerInterface $centerResolverManager, AuthorizationHelperForCurrentUserInterface $authorizationHelperForCurrentUser) { $this->em = $em; - $this->authorizationHelper = $authorizationHelper; - $this->centerResolverDispatcher = $centerResolverDispatcher; - $this->security = $security; + $this->centerResolverManager = $centerResolverManager; + $this->authorizationHelperForCurrentUser = $authorizationHelperForCurrentUser; } public function buildQueryByPerson(Person $person): QueryBuilder @@ -49,6 +55,62 @@ class PersonDocumentACLAwareRepository implements PersonDocumentACLAwareReposito return $qb; } + + public function buildFetchQueryForPerson(Person $person, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null): FetchQueryInterface + { + $query = $this->buildBaseFetchQueryForPerson($person, $startDate, $endDate, $content); + + return $this->addFetchQueryByPersonACL($query, $person); + } + + public function buildBaseFetchQueryForPerson(Person $person, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null): FetchQuery + { + $personDocMetadata = $this->em->getClassMetadata(PersonDocument::class); + + $query = new FetchQuery( + PersonDocumentGenericDocProvider::KEY, + sprintf('jsonb_build_object(\'id\', person_document.%s)', $personDocMetadata->getSingleIdentifierColumnName()), + sprintf('person_document.%s', $personDocMetadata->getColumnName('date')), + sprintf('%s AS person_document', $personDocMetadata->getSchemaName().'.'.$personDocMetadata->getTableName()) + ); + + $query->addWhereClause( + sprintf('person_document.%s = ?', $personDocMetadata->getSingleAssociationJoinColumnName('person')), + [$person->getId()], + [Types::INTEGER] + ); + + if (null !== $startDate) { + $query->addWhereClause( + sprintf('? <= %s', $personDocMetadata->getColumnName('date')), + [$startDate], + [Types::DATE_IMMUTABLE] + ); + } + + if (null !== $endDate) { + $query->addWhereClause( + sprintf('? >= %s', $personDocMetadata->getColumnName('date')), + [$endDate], + [Types::DATE_IMMUTABLE] + ); + } + + if (null !== $content and '' !== $content) { + $query->addWhereClause( + sprintf( + '(%s ilike ? OR %s ilike ?)', + $personDocMetadata->getColumnName('title'), + $personDocMetadata->getColumnName('description') + ), + ['%' . $content . '%', '%' . $content . '%'], + [Types::STRING, Types::STRING] + ); + } + + return $query; + } + public function countByPerson(Person $person): int { $qb = $this->buildQueryByPerson($person)->select('COUNT(d)'); @@ -75,16 +137,58 @@ class PersonDocumentACLAwareRepository implements PersonDocumentACLAwareReposito private function addACL(QueryBuilder $qb, Person $person): void { - $center = $this->centerResolverDispatcher->resolveCenter($person); + $reachableScopes = []; - $reachableScopes = $this->authorizationHelper - ->getReachableScopes( - $this->security->getUser(), - PersonDocumentVoter::SEE, - $center - ); + foreach ($this->centerResolverManager->resolveCenters($person) as $center) { + $reachableScopes = [ + ...$reachableScopes, + ...$this->authorizationHelperForCurrentUser + ->getReachableScopes( + PersonDocumentVoter::SEE, + $center + ) + ]; + } + + if ([] === $reachableScopes) { + $qb->andWhere("'FALSE' = 'TRUE'"); + + return; + } $qb->andWhere($qb->expr()->in('d.scope', ':scopes')) ->setParameter('scopes', $reachableScopes); } + + private function addFetchQueryByPersonACL(FetchQuery $fetchQuery, Person $person): FetchQuery + { + $personDocMetadata = $this->em->getClassMetadata(PersonDocument::class); + + $reachableScopes = []; + + foreach ($this->centerResolverManager->resolveCenters($person) as $center) { + $reachableScopes = [ + ...$reachableScopes, + ...$this->authorizationHelperForCurrentUser->getReachableScopes(PersonDocumentVoter::SEE, $center) + ]; + } + + if ([] === $reachableScopes) { + $fetchQuery->addWhereClause('FALSE = TRUE'); + + return $fetchQuery; + } + + $fetchQuery->addWhereClause( + sprintf( + 'person_document.%s IN (%s)', + $personDocMetadata->getSingleAssociationJoinColumnName('scope'), + implode(', ', array_fill(0, count($reachableScopes), '?')) + ), + array_map(static fn (Scope $s) => $s->getId(), $reachableScopes), + array_fill(0, count($reachableScopes), Types::INTEGER) + ); + + return $fetchQuery; + } } diff --git a/src/Bundle/ChillDocStoreBundle/Repository/PersonDocumentACLAwareRepositoryInterface.php b/src/Bundle/ChillDocStoreBundle/Repository/PersonDocumentACLAwareRepositoryInterface.php index 6c4bd2e9a..0b5e26792 100644 --- a/src/Bundle/ChillDocStoreBundle/Repository/PersonDocumentACLAwareRepositoryInterface.php +++ b/src/Bundle/ChillDocStoreBundle/Repository/PersonDocumentACLAwareRepositoryInterface.php @@ -11,11 +11,25 @@ declare(strict_types=1); namespace Chill\DocStoreBundle\Repository; +use Chill\DocStoreBundle\GenericDoc\FetchQueryInterface; use Chill\PersonBundle\Entity\Person; interface PersonDocumentACLAwareRepositoryInterface { + /** + * @deprecated use fetch query for listing and counting person documents + */ public function countByPerson(Person $person): int; + /** + * @deprecated use fetch query for listing and counting person documents + */ public function findByPerson(Person $person, array $orderBy = [], int $limit = 20, int $offset = 0): array; + + public function buildFetchQueryForPerson( + Person $person, + ?\DateTimeImmutable $startDate = null, + ?\DateTimeImmutable $endDate = null, + ?string $content = null + ): FetchQueryInterface; } diff --git a/src/Bundle/ChillDocStoreBundle/Repository/PersonDocumentRepository.php b/src/Bundle/ChillDocStoreBundle/Repository/PersonDocumentRepository.php new file mode 100644 index 000000000..62a3bbcec --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/Repository/PersonDocumentRepository.php @@ -0,0 +1,49 @@ + + */ +readonly class PersonDocumentRepository implements ObjectRepository +{ + private EntityRepository $repository; + + public function __construct( + private EntityManagerInterface $entityManager + ) + { + $this->repository = $this->entityManager->getRepository($this->getClassName()); + } + + public function find($id): ?PersonDocument + { + return $this->repository->find($id); + } + + public function findAll() + { + return $this->repository->findAll(); + } + + public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null) + { + return $this->repository->findBy($criteria, $orderBy, $limit, $offset); + } + + public function findOneBy(array $criteria): ?PersonDocument + { + return $this->repository->findOneBy($criteria); + } + + public function getClassName(): string + { + return PersonDocument::class; + } +} diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/GenericDoc/person_list.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/GenericDoc/person_list.html.twig new file mode 100644 index 000000000..a4aa4fbbc --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/GenericDoc/person_list.html.twig @@ -0,0 +1,74 @@ +{# + * Copyright (C) 2018, Champs Libres Cooperative SCRLFS, + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . +#} + +{% extends "@ChillPerson/Person/layout.html.twig" %} + +{% set activeRouteKey = '' %} + +{% import "@ChillDocStore/Macro/macro.html.twig" as m %} + +{% block title %} + {{ 'Documents for %name%'|trans({ '%name%': person|chill_entity_render_string } ) }} +{% endblock %} + +{% block js %} + {{ parent() }} + {{ encore_entry_script_tags('mod_docgen_picktemplate') }} + {{ encore_entry_script_tags('mod_entity_workflow_pick') }} + {{ encore_entry_script_tags('mod_document_action_buttons_group') }} +{% endblock %} + +{% block css %} + {{ parent() }} + {{ encore_entry_link_tags('mod_docgen_picktemplate') }} + {{ encore_entry_link_tags('mod_entity_workflow_pick') }} + {{ encore_entry_link_tags('mod_document_action_buttons_group') }} +{% endblock %} + +{% block content %} + +
        +

        {{ 'Documents for %name%'|trans({ '%name%': person|chill_entity_render_string } ) }}

        + + {{ filter|chill_render_filter_order_helper }} + + {% if documents|length == 0 %} +

        {{ 'No documents'|trans }}

        + {% else %} +
        + {% for document in documents %} + {{ document|chill_generic_doc_render }} + {% endfor %} +
        + {% endif %} + + {{ chill_pagination(pagination) }} + +
        + + {% if is_granted('CHILL_PERSON_DOCUMENT_CREATE', person) %} + + {% endif %} + +
        +{% endblock %} diff --git a/src/Bundle/ChillDocStoreBundle/Tests/GenericDoc/ManagerTest.php b/src/Bundle/ChillDocStoreBundle/Tests/GenericDoc/ManagerTest.php index 597aea84a..f59779374 100644 --- a/src/Bundle/ChillDocStoreBundle/Tests/GenericDoc/ManagerTest.php +++ b/src/Bundle/ChillDocStoreBundle/Tests/GenericDoc/ManagerTest.php @@ -14,9 +14,12 @@ namespace Chill\DocStoreBundle\Tests\GenericDoc; use Chill\DocStoreBundle\GenericDoc\FetchQuery; use Chill\DocStoreBundle\GenericDoc\FetchQueryInterface; use Chill\DocStoreBundle\GenericDoc\GenericDocDTO; +use Chill\DocStoreBundle\GenericDoc\GenericDocForPersonProviderInterface; use Chill\DocStoreBundle\GenericDoc\Manager; use Chill\DocStoreBundle\GenericDoc\GenericDocForAccompanyingPeriodProviderInterface; use Chill\PersonBundle\Entity\AccompanyingPeriod; +use Chill\PersonBundle\Entity\Person; +use DateTimeImmutable; use Doctrine\DBAL\Connection; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\EntityManagerInterface; @@ -53,7 +56,8 @@ class ManagerTest extends KernelTestCase } $manager = new Manager( - [new SimpleGenericDocProvider()], + [new SimpleGenericDocAccompanyingPeriodProvider()], + [new SimpleGenericDocPersonProvider()], $this->connection, ); @@ -62,6 +66,27 @@ class ManagerTest extends KernelTestCase self::assertIsInt($nb); } + public function testCountByPerson(): void + { + $person = $this->em->createQuery('SELECT a FROM '.Person::class.' a') + ->setMaxResults(1) + ->getSingleResult(); + + if (null === $person) { + throw new \UnexpectedValueException("person found"); + } + + $manager = new Manager( + [new SimpleGenericDocAccompanyingPeriodProvider()], + [new SimpleGenericDocPersonProvider()], + $this->connection, + ); + + $nb = $manager->countDocForPerson($person); + + self::assertIsInt($nb); + } + public function testFindDocByAccompanyingPeriod(): void { $period = $this->em->createQuery('SELECT a FROM '.AccompanyingPeriod::class.' a') @@ -73,7 +98,8 @@ class ManagerTest extends KernelTestCase } $manager = new Manager( - [new SimpleGenericDocProvider()], + [new SimpleGenericDocAccompanyingPeriodProvider()], + [new SimpleGenericDocPersonProvider()], $this->connection, ); @@ -81,14 +107,77 @@ class ManagerTest extends KernelTestCase self::assertInstanceOf(GenericDocDTO::class, $doc); } } + + public function testFindDocByPerson(): void + { + $person = $this->em->createQuery('SELECT a FROM '.Person::class.' a') + ->setMaxResults(1) + ->getSingleResult(); + + if (null === $person) { + throw new \UnexpectedValueException("person not found"); + } + + $manager = new Manager( + [new SimpleGenericDocAccompanyingPeriodProvider()], + [new SimpleGenericDocPersonProvider()], + $this->connection, + ); + + foreach ($manager->findDocForPerson($person) as $doc) { + self::assertInstanceOf(GenericDocDTO::class, $doc); + } + } + + public function testPlacesForPerson(): void + { + $person = $this->em->createQuery('SELECT a FROM '.Person::class.' a') + ->setMaxResults(1) + ->getSingleResult(); + + if (null === $person) { + throw new \UnexpectedValueException("person not found"); + } + + $manager = new Manager( + [new SimpleGenericDocAccompanyingPeriodProvider()], + [new SimpleGenericDocPersonProvider()], + $this->connection, + ); + + $places = $manager->placesForPerson($person); + + self::assertEquals(['dummy_person_doc'], $places); + } + + public function testPlacesForAccompanyingPeriod(): void + { + $period = $this->em->createQuery('SELECT a FROM '.AccompanyingPeriod::class.' a') + ->setMaxResults(1) + ->getSingleResult(); + + if (null === $period) { + throw new \UnexpectedValueException("period not found"); + } + + $manager = new Manager( + [new SimpleGenericDocAccompanyingPeriodProvider()], + [new SimpleGenericDocPersonProvider()], + $this->connection, + ); + + $places = $manager->placesForAccompanyingPeriod($period); + + self::assertEquals(['accompanying_course_document_dummy'], $places); + } } -final readonly class SimpleGenericDocProvider implements GenericDocForAccompanyingPeriodProviderInterface +final readonly class SimpleGenericDocAccompanyingPeriodProvider implements GenericDocForAccompanyingPeriodProviderInterface { public function buildFetchQueryForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod, ?\DateTimeImmutable $startDate = null, ?\DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface { $query = new FetchQuery( - 'accompanying_course_document', + 'accompanying_course_document_dummy', sprintf('jsonb_build_object(\'id\', %s)', 'id'), 'd', '(VALUES (1, \'2023-05-01\'::date), (2, \'2023-05-01\'::date)) AS sq (id, d)', @@ -104,3 +193,25 @@ final readonly class SimpleGenericDocProvider implements GenericDocForAccompanyi return true; } } + +final readonly class SimpleGenericDocPersonProvider implements GenericDocForPersonProviderInterface +{ + public function buildFetchQueryForPerson(Person $person, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface + { + $query = new FetchQuery( + 'dummy_person_doc', + sprintf('jsonb_build_object(\'id\', %s)', 'id'), + 'd', + '(VALUES (1, \'2023-05-01\'::date), (2, \'2023-05-01\'::date)) AS sq (id, d)', + ); + + $query->addWhereClause('d > ?', [new \DateTimeImmutable('2023-01-01')], [Types::DATE_IMMUTABLE]); + + return $query; + } + + public function isAllowedForPerson(Person $person): bool + { + return true; + } +} diff --git a/src/Bundle/ChillDocStoreBundle/Tests/GenericDoc/Providers/PersonDocumentGenericDocProviderTest.php b/src/Bundle/ChillDocStoreBundle/Tests/GenericDoc/Providers/PersonDocumentGenericDocProviderTest.php new file mode 100644 index 000000000..577357820 --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/Tests/GenericDoc/Providers/PersonDocumentGenericDocProviderTest.php @@ -0,0 +1,84 @@ +entityManager = self::$container->get(EntityManagerInterface::class); + $this->personDocumentACLAwareRepository = self::$container->get(PersonDocumentACLAwareRepositoryInterface::class); + } + + /** + * @dataProvider provideDataBuildFetchQueryForPerson + * @throws \Doctrine\DBAL\Exception + * @throws \Doctrine\ORM\NoResultException + * @throws \Doctrine\ORM\NonUniqueResultException + */ + public function testBuildFetchQueryForPerson(?DateTimeImmutable $startDate, ?DateTimeImmutable $endDate, ?string $content): void + { + $security = $this->prophesize(Security::class); + $person = $this->entityManager->createQuery('SELECT a FROM '.Person::class.' a') + ->setMaxResults(1) + ->getSingleResult(); + + if (null === $person) { + throw new \UnexpectedValueException("person found"); + } + + $provider = new PersonDocumentGenericDocProvider( + $security->reveal(), + $this->personDocumentACLAwareRepository + ); + + $query = $provider->buildFetchQueryForPerson($person, $startDate, $endDate, $content); + + ['sql' => $sql, 'params' => $params, 'types' => $types] = (new FetchQueryToSqlBuilder())->toSql($query); + + $nb = $this->entityManager->getConnection() + ->fetchOne("SELECT COUNT(*) AS nb FROM (${sql}) AS sq", $params, $types); + + self::assertIsInt($nb, "Test that the query is syntactically correct"); + } + + public function provideDataBuildFetchQueryForPerson(): iterable + { + yield [null, null, null]; + yield [new DateTimeImmutable('1 year ago'), null, null]; + yield [null, new DateTimeImmutable('1 year ago'), null]; + yield [new DateTimeImmutable('2 years ago'), new DateTimeImmutable('1 year ago'), null]; + yield [null, null, 'test']; + yield [new DateTimeImmutable('2 years ago'), new DateTimeImmutable('1 year ago'), 'test']; + } +} diff --git a/src/Bundle/ChillDocStoreBundle/Tests/Repository/PersonDocumentACLAwareRepositoryTest.php b/src/Bundle/ChillDocStoreBundle/Tests/Repository/PersonDocumentACLAwareRepositoryTest.php new file mode 100644 index 000000000..98fca5622 --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/Tests/Repository/PersonDocumentACLAwareRepositoryTest.php @@ -0,0 +1,99 @@ +entityManager = self::$container->get(EntityManagerInterface::class); + $this->scopeRepository = self::$container->get(ScopeRepositoryInterface::class); + } + + /** + * @dataProvider provideDataBuildFetchQueryForPerson + * @throws \Doctrine\DBAL\Exception + * @throws \Doctrine\ORM\NoResultException + * @throws \Doctrine\ORM\NonUniqueResultException + */ + public function testBuildFetchQueryForPerson(?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null): void + { + $centerManager = $this->prophesize(CenterResolverManagerInterface::class); + $centerManager->resolveCenters(Argument::type(Person::class)) + ->willReturn([new Center()]); + + $scopes = $this->scopeRepository->findAll(); + $authorizationHelper = $this->prophesize(AuthorizationHelperForCurrentUserInterface::class); + $authorizationHelper->getReachableScopes(PersonDocumentVoter::SEE, Argument::any())->willReturn($scopes); + + $repository = new PersonDocumentACLAwareRepository( + $this->entityManager, + $centerManager->reveal(), + $authorizationHelper->reveal() + ); + + $person = $this->entityManager->createQuery("SELECT p FROM " . Person::class . " p") + ->setMaxResults(1) + ->getSingleResult(); + + if (null === $person) { + throw new \RuntimeException("person not exists in database"); + } + + $query = $repository->buildFetchQueryForPerson($person, $startDate, $endDate, $content); + ['sql' => $sql, 'params' => $params, 'types' => $types] = (new FetchQueryToSqlBuilder())->toSql($query); + + $nb = $this->entityManager->getConnection() + ->fetchOne("SELECT COUNT(*) FROM ({$sql}) AS sq", $params, $types); + + self::assertIsInt($nb, "test that the query could be executed"); + } + + public function provideDataBuildFetchQueryForPerson(): iterable + { + yield [null, null, null]; + yield [new DateTimeImmutable('1 year ago'), null, null]; + yield [null, new DateTimeImmutable('1 year ago'), null]; + yield [new DateTimeImmutable('2 years ago'), new DateTimeImmutable('1 year ago'), null]; + yield [null, null, 'test']; + yield [new DateTimeImmutable('2 years ago'), new DateTimeImmutable('1 year ago'), 'test']; + } + +} diff --git a/src/Bundle/ChillDocStoreBundle/config/services.yaml b/src/Bundle/ChillDocStoreBundle/config/services.yaml index f242acc1c..04fc3ace3 100644 --- a/src/Bundle/ChillDocStoreBundle/config/services.yaml +++ b/src/Bundle/ChillDocStoreBundle/config/services.yaml @@ -50,6 +50,7 @@ services: autoconfigure: true arguments: $providersForAccompanyingPeriod: !tagged_iterator chill_doc_store.generic_doc_accompanying_period_provider + $providersForPerson: !tagged_iterator chill_doc_store.generic_doc_person_provider Chill\DocStoreBundle\GenericDoc\Twig\GenericDocExtension: autoconfigure: true From e9fdabf93166f01f2a157f7d89f0ec4cd2792565 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 30 May 2023 21:24:22 +0200 Subject: [PATCH 125/724] Remove old list for person document --- .../Controller/DocumentPersonController.php | 51 +------------ .../ChillDocStoreBundle/Menu/MenuBuilder.php | 4 +- .../views/PersonDocument/delete.html.twig | 4 +- .../views/PersonDocument/edit.html.twig | 2 +- .../views/PersonDocument/index.html.twig | 72 ------------------- .../views/PersonDocument/new.html.twig | 2 +- .../views/PersonDocument/show.html.twig | 2 +- 7 files changed, 9 insertions(+), 128 deletions(-) delete mode 100644 src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/index.html.twig diff --git a/src/Bundle/ChillDocStoreBundle/Controller/DocumentPersonController.php b/src/Bundle/ChillDocStoreBundle/Controller/DocumentPersonController.php index 6fcb6a8e5..20e8e9b03 100644 --- a/src/Bundle/ChillDocStoreBundle/Controller/DocumentPersonController.php +++ b/src/Bundle/ChillDocStoreBundle/Controller/DocumentPersonController.php @@ -45,10 +45,6 @@ class DocumentPersonController extends AbstractController protected TranslatorInterface $translator; - private PaginatorFactory $paginatorFactory; - - private PersonDocumentACLAwareRepositoryInterface $personDocumentACLAwareRepository; - /** * DocumentPersonController constructor. */ @@ -56,14 +52,10 @@ class DocumentPersonController extends AbstractController TranslatorInterface $translator, EventDispatcherInterface $eventDispatcher, AuthorizationHelper $authorizationHelper, - PaginatorFactory $paginatorFactory, - PersonDocumentACLAwareRepositoryInterface $personDocumentACLAwareRepository ) { $this->translator = $translator; $this->eventDispatcher = $eventDispatcher; $this->authorizationHelper = $authorizationHelper; - $this->paginatorFactory = $paginatorFactory; - $this->personDocumentACLAwareRepository = $personDocumentACLAwareRepository; } /** @@ -88,7 +80,7 @@ class DocumentPersonController extends AbstractController return $this->redirect($request->query->get('returnPath')); } - return $this->redirectToRoute('person_document_index', ['person' => $person->getId()]); + return $this->redirectToRoute('chill_docstore_generic-doc_by-person_index', ['id' => $person->getId()]); } return $this->render( @@ -160,45 +152,6 @@ class DocumentPersonController extends AbstractController ); } - /** - * @Route("/", name="person_document_index", methods="GET") - */ - public function index(Person $person): Response - { - $em = $this->getDoctrine()->getManager(); - - if (null === $person) { - throw $this->createNotFoundException('Person not found'); - } - - $this->denyAccessUnlessGranted(PersonVoter::SEE, $person); - - $total = $this->personDocumentACLAwareRepository->countByPerson($person); - $pagination = $this->paginatorFactory->create($total); - - $documents = $this->personDocumentACLAwareRepository->findByPerson( - $person, - ['date' => 'DESC', 'id' => 'DESC'], - $pagination->getItemsPerPage(), - $pagination->getCurrentPageFirstItemNumber() - ); - - $event = new PrivacyEvent($person, [ - 'element_class' => PersonDocument::class, - 'action' => 'index', - ]); - $this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event); - - return $this->render( - 'ChillDocStoreBundle:PersonDocument:index.html.twig', - [ - 'documents' => $documents, - 'person' => $person, - 'pagination' => $pagination, - ] - ); - } - /** * @Route("/new", name="person_document_new", methods="GET|POST") */ @@ -233,7 +186,7 @@ class DocumentPersonController extends AbstractController $this->addFlash('success', $this->translator->trans('The document is successfully registered')); - return $this->redirectToRoute('person_document_index', ['person' => $person->getId()]); + return $this->redirectToRoute('chill_docstore_generic-doc_by-person_index', ['id' => $person->getId()]); } if ($form->isSubmitted() && !$form->isValid()) { diff --git a/src/Bundle/ChillDocStoreBundle/Menu/MenuBuilder.php b/src/Bundle/ChillDocStoreBundle/Menu/MenuBuilder.php index 95b23904a..4288dc821 100644 --- a/src/Bundle/ChillDocStoreBundle/Menu/MenuBuilder.php +++ b/src/Bundle/ChillDocStoreBundle/Menu/MenuBuilder.php @@ -80,9 +80,9 @@ final class MenuBuilder implements LocalMenuBuilderInterface if ($this->security->isGranted(PersonDocumentVoter::SEE, $person)) { $menu->addChild($this->translator->trans('Documents'), [ - 'route' => 'person_document_index', + 'route' => 'chill_docstore_generic-doc_by-person_index', 'routeParameters' => [ - 'person' => $person->getId(), + 'id' => $person->getId(), ], ]) ->setExtras([ diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/delete.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/delete.html.twig index bfdd87dc3..41c229faa 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/delete.html.twig +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/delete.html.twig @@ -36,8 +36,8 @@ 'title' : 'Delete document ?'|trans, 'display_content' : block('docdescription'), 'confirm_question' : 'Are you sure you want to remove this document ?'|trans, - 'cancel_route' : 'person_document_index', - 'cancel_parameters' : {'person' : person.id, 'id': document.id}, + 'cancel_route' : 'chill_docstore_generic-doc_by-person_index', + 'cancel_parameters' : {'id' : person.id}, 'form' : delete_form } ) }} {% endblock %} diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/edit.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/edit.html.twig index 416a35e35..17ce9d774 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/edit.html.twig +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/edit.html.twig @@ -38,7 +38,7 @@
        • - + {{ 'Back to the list' | trans }}
        • diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/index.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/index.html.twig deleted file mode 100644 index 8d201605e..000000000 --- a/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/index.html.twig +++ /dev/null @@ -1,72 +0,0 @@ -{# - * Copyright (C) 2018, Champs Libres Cooperative SCRLFS, - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . -#} - -{% extends "@ChillPerson/Person/layout.html.twig" %} - -{% set activeRouteKey = '' %} - -{% import "@ChillDocStore/Macro/macro.html.twig" as m %} - -{% block title %} - {{ 'Documents for %name%'|trans({ '%name%': person|chill_entity_render_string } ) }} -{% endblock %} - -{% block js %} - {{ parent() }} - {{ encore_entry_script_tags('mod_docgen_picktemplate') }} - {{ encore_entry_script_tags('mod_entity_workflow_pick') }} - {{ encore_entry_script_tags('mod_document_action_buttons_group') }} -{% endblock %} - -{% block css %} - {{ parent() }} - {{ encore_entry_link_tags('mod_docgen_picktemplate') }} - {{ encore_entry_link_tags('mod_entity_workflow_pick') }} - {{ encore_entry_link_tags('mod_document_action_buttons_group') }} -{% endblock %} - -{% block content %} - -
          -

          {{ 'Documents for %name%'|trans({ '%name%': person|chill_entity_render_string } ) }}

          - - {% if documents|length == 0 %} -

          {{ 'No documents'|trans }}

          - {% else %} -
          - {% for document in documents %} - {% include 'ChillDocStoreBundle:List:list_item.html.twig' %} - {% endfor %} -
          - {% endif %} - - {{ chill_pagination(pagination) }} - -
          - - {% if is_granted('CHILL_PERSON_DOCUMENT_CREATE', person) %} - - {% endif %} - -
          -{% endblock %} diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/new.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/new.html.twig index 3187714a6..faf8895e7 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/new.html.twig +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/new.html.twig @@ -42,7 +42,7 @@
          • - + {{ 'Back to the list' | trans }}
          • diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/show.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/show.html.twig index c276e067e..1c0aa5e64 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/show.html.twig +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/show.html.twig @@ -63,7 +63,7 @@
            • - + {{ 'Back to the list' | trans }}
            • From 40ddd1f1ee3787656dc944785e493c56be5d6718 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 30 May 2023 21:25:33 +0200 Subject: [PATCH 126/724] Add license --- .../Repository/PersonDocumentRepository.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillDocStoreBundle/Repository/PersonDocumentRepository.php b/src/Bundle/ChillDocStoreBundle/Repository/PersonDocumentRepository.php index 62a3bbcec..40afdc220 100644 --- a/src/Bundle/ChillDocStoreBundle/Repository/PersonDocumentRepository.php +++ b/src/Bundle/ChillDocStoreBundle/Repository/PersonDocumentRepository.php @@ -1,5 +1,14 @@ repository = $this->entityManager->getRepository($this->getClassName()); } From da36c59616379c77119d7fe9ff2e56275e003b68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 30 May 2023 21:52:36 +0200 Subject: [PATCH 127/724] refactor: rename class providing AccompanyingCourseDocument Generic doc --- ...php => AccompanyingCourseDocumentGenericDocProvider.php} | 2 +- .../AccompanyingCourseDocumentGenericDocRenderer.php | 4 ++-- ...=> AccompanyingCourseDocumentGenericDocProviderTest.php} | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) rename src/Bundle/ChillDocStoreBundle/GenericDoc/Providers/{AccompanyingProviderCourseDocumentGenericDoc.php => AccompanyingCourseDocumentGenericDocProvider.php} (95%) rename src/Bundle/ChillDocStoreBundle/Tests/GenericDoc/Providers/{AccompanyingCourseDocumentProviderTest.php => AccompanyingCourseDocumentGenericDocProviderTest.php} (90%) diff --git a/src/Bundle/ChillDocStoreBundle/GenericDoc/Providers/AccompanyingProviderCourseDocumentGenericDoc.php b/src/Bundle/ChillDocStoreBundle/GenericDoc/Providers/AccompanyingCourseDocumentGenericDocProvider.php similarity index 95% rename from src/Bundle/ChillDocStoreBundle/GenericDoc/Providers/AccompanyingProviderCourseDocumentGenericDoc.php rename to src/Bundle/ChillDocStoreBundle/GenericDoc/Providers/AccompanyingCourseDocumentGenericDocProvider.php index 970ce646d..439f6a511 100644 --- a/src/Bundle/ChillDocStoreBundle/GenericDoc/Providers/AccompanyingProviderCourseDocumentGenericDoc.php +++ b/src/Bundle/ChillDocStoreBundle/GenericDoc/Providers/AccompanyingCourseDocumentGenericDocProvider.php @@ -21,7 +21,7 @@ use Doctrine\DBAL\Types\Types; use Doctrine\ORM\EntityManagerInterface; use Symfony\Component\Security\Core\Security; -final readonly class AccompanyingProviderCourseDocumentGenericDoc implements GenericDocForAccompanyingPeriodProviderInterface +final readonly class AccompanyingCourseDocumentGenericDocProvider implements GenericDocForAccompanyingPeriodProviderInterface { public const KEY = 'accompanying_course_document'; diff --git a/src/Bundle/ChillDocStoreBundle/GenericDoc/Renderer/AccompanyingCourseDocumentGenericDocRenderer.php b/src/Bundle/ChillDocStoreBundle/GenericDoc/Renderer/AccompanyingCourseDocumentGenericDocRenderer.php index a533b577a..ffa158aca 100644 --- a/src/Bundle/ChillDocStoreBundle/GenericDoc/Renderer/AccompanyingCourseDocumentGenericDocRenderer.php +++ b/src/Bundle/ChillDocStoreBundle/GenericDoc/Renderer/AccompanyingCourseDocumentGenericDocRenderer.php @@ -14,7 +14,7 @@ namespace Chill\DocStoreBundle\GenericDoc\Renderer; use Chill\DocStoreBundle\GenericDoc\GenericDocDTO; use Chill\DocStoreBundle\GenericDoc\Providers\PersonDocumentGenericDocProvider; use Chill\DocStoreBundle\GenericDoc\Twig\GenericDocRendererInterface; -use Chill\DocStoreBundle\GenericDoc\Providers\AccompanyingProviderCourseDocumentGenericDoc; +use Chill\DocStoreBundle\GenericDoc\Providers\AccompanyingCourseDocumentGenericDocProvider; use Chill\DocStoreBundle\Repository\AccompanyingCourseDocumentRepository; use Chill\DocStoreBundle\Repository\PersonDocumentRepository; use Chill\PersonBundle\Entity\AccompanyingPeriod; @@ -29,7 +29,7 @@ final readonly class AccompanyingCourseDocumentGenericDocRenderer implements Gen public function supports(GenericDocDTO $genericDocDTO, $options = []): bool { - return $genericDocDTO->key === AccompanyingProviderCourseDocumentGenericDoc::KEY + return $genericDocDTO->key === AccompanyingCourseDocumentGenericDocProvider::KEY || $genericDocDTO->key === PersonDocumentGenericDocProvider::KEY; } diff --git a/src/Bundle/ChillDocStoreBundle/Tests/GenericDoc/Providers/AccompanyingCourseDocumentProviderTest.php b/src/Bundle/ChillDocStoreBundle/Tests/GenericDoc/Providers/AccompanyingCourseDocumentGenericDocProviderTest.php similarity index 90% rename from src/Bundle/ChillDocStoreBundle/Tests/GenericDoc/Providers/AccompanyingCourseDocumentProviderTest.php rename to src/Bundle/ChillDocStoreBundle/Tests/GenericDoc/Providers/AccompanyingCourseDocumentGenericDocProviderTest.php index 8c6bd524d..79ced9258 100644 --- a/src/Bundle/ChillDocStoreBundle/Tests/GenericDoc/Providers/AccompanyingCourseDocumentProviderTest.php +++ b/src/Bundle/ChillDocStoreBundle/Tests/GenericDoc/Providers/AccompanyingCourseDocumentGenericDocProviderTest.php @@ -12,7 +12,7 @@ declare(strict_types=1); namespace Chill\DocStoreBundle\Tests\GenericDoc\Providers; use Chill\DocStoreBundle\GenericDoc\FetchQueryToSqlBuilder; -use Chill\DocStoreBundle\GenericDoc\Providers\AccompanyingProviderCourseDocumentGenericDoc; +use Chill\DocStoreBundle\GenericDoc\Providers\AccompanyingCourseDocumentGenericDocProvider; use Chill\DocStoreBundle\Security\Authorization\AccompanyingCourseDocumentVoter; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Doctrine\DBAL\Types\Types; @@ -25,7 +25,7 @@ use Symfony\Component\Security\Core\Security; * @internal * @coversNothing */ -class AccompanyingCourseDocumentProviderTest extends KernelTestCase +class AccompanyingCourseDocumentGenericDocProviderTest extends KernelTestCase { use ProphecyTrait; private EntityManagerInterface $entityManager; @@ -54,7 +54,7 @@ class AccompanyingCourseDocumentProviderTest extends KernelTestCase $security->isGranted(AccompanyingCourseDocumentVoter::SEE, $period) ->willReturn(true); - $provider = new AccompanyingProviderCourseDocumentGenericDoc( + $provider = new AccompanyingCourseDocumentGenericDocProvider( $security->reveal(), $this->entityManager ); From 2b57807565a335e6d81a761bd11d490cc9fa7de0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 30 May 2023 22:14:13 +0200 Subject: [PATCH 128/724] show generic doc accompanying course document in person generic doc list --- ...anyingCourseDocumentGenericDocProvider.php | 75 +++++++++++++++++-- ...anyingCourseDocumentGenericDocRenderer.php | 10 +-- 2 files changed, 73 insertions(+), 12 deletions(-) diff --git a/src/Bundle/ChillDocStoreBundle/GenericDoc/Providers/AccompanyingCourseDocumentGenericDocProvider.php b/src/Bundle/ChillDocStoreBundle/GenericDoc/Providers/AccompanyingCourseDocumentGenericDocProvider.php index 439f6a511..054e6a6d8 100644 --- a/src/Bundle/ChillDocStoreBundle/GenericDoc/Providers/AccompanyingCourseDocumentGenericDocProvider.php +++ b/src/Bundle/ChillDocStoreBundle/GenericDoc/Providers/AccompanyingCourseDocumentGenericDocProvider.php @@ -15,13 +15,17 @@ use Chill\DocStoreBundle\Entity\AccompanyingCourseDocument; use Chill\DocStoreBundle\GenericDoc\FetchQuery; use Chill\DocStoreBundle\GenericDoc\FetchQueryInterface; use Chill\DocStoreBundle\GenericDoc\GenericDocForAccompanyingPeriodProviderInterface; +use Chill\DocStoreBundle\GenericDoc\GenericDocForPersonProviderInterface; use Chill\DocStoreBundle\Security\Authorization\AccompanyingCourseDocumentVoter; use Chill\PersonBundle\Entity\AccompanyingPeriod; +use Chill\PersonBundle\Entity\Person; +use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; +use DateTimeImmutable; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\EntityManagerInterface; use Symfony\Component\Security\Core\Security; -final readonly class AccompanyingCourseDocumentGenericDocProvider implements GenericDocForAccompanyingPeriodProviderInterface +final readonly class AccompanyingCourseDocumentGenericDocProvider implements GenericDocForAccompanyingPeriodProviderInterface, GenericDocForPersonProviderInterface { public const KEY = 'accompanying_course_document'; @@ -38,7 +42,7 @@ final readonly class AccompanyingCourseDocumentGenericDocProvider implements Gen $query = new FetchQuery( self::KEY, sprintf('jsonb_build_object(\'id\', %s)', $classMetadata->getIdentifierColumnNames()[0]), - sprintf($classMetadata->getColumnName('date')), + $classMetadata->getColumnName('date'), $classMetadata->getSchemaName() . '.' . $classMetadata->getTableName() ); @@ -48,6 +52,67 @@ final readonly class AccompanyingCourseDocumentGenericDocProvider implements Gen [Types::INTEGER] ); + return $this->addWhereClause($query, $startDate, $endDate, $content); + } + + public function isAllowedForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod): bool + { + return $this->security->isGranted(AccompanyingCourseDocumentVoter::SEE, $accompanyingPeriod); + } + + public function buildFetchQueryForPerson(Person $person, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface + { + $classMetadata = $this->entityManager->getClassMetadata(AccompanyingCourseDocument::class); + + $query = new FetchQuery( + self::KEY, + sprintf('jsonb_build_object(\'id\', %s)', $classMetadata->getIdentifierColumnNames()[0]), + $classMetadata->getColumnName('date'), + $classMetadata->getSchemaName() . '.' . $classMetadata->getTableName() . ' AS acc_course_document' + ); + + $atLeastOne = false; + $or = []; + $orParams = []; + $orTypes = []; + + foreach ($person->getAccompanyingPeriodParticipations() as $participation) { + if (!$this->security->isGranted(AccompanyingCourseDocumentVoter::SEE, $participation->getAccompanyingPeriod())) { + continue; + } + + $atLeastOne = true; + + $or[] = sprintf( + "(acc_course_document.%s = ? AND acc_course_document.%s BETWEEN ? AND COALESCE(?, 'infinity'::date))", + $classMetadata->getSingleAssociationJoinColumnName('course'), + $classMetadata->getColumnName('date') + ); + $orParams = [...$orParams, $participation->getAccompanyingPeriod()->getId(), $participation->getStartDate(), $participation->getEndDate()]; + $orTypes = [...$orTypes, Types::INTEGER, Types::DATE_MUTABLE, Types::DATE_MUTABLE]; + } + + if (!$atLeastOne) { + // there aren't any period allowed to be seen. Add an unreachable condition + $query->addWhereClause('TRUE = FALSE'); + + return $query; + } + + $query->addWhereClause(implode(' OR ', $or), $orParams, $orTypes); + + return $this->addWhereClause($query, $startDate, $endDate, $content); + } + + public function isAllowedForPerson(Person $person): bool + { + return $this->security->isGranted(AccompanyingPeriodVoter::SEE, $person); + } + + private function addWhereClause(FetchQuery $query, ?\DateTimeImmutable $startDate = null, ?\DateTimeImmutable $endDate = null, ?string $content = null): FetchQuery + { + $classMetadata = $this->entityManager->getClassMetadata(AccompanyingCourseDocument::class); + if (null !== $startDate) { $query->addWhereClause( sprintf('? <= %s', $classMetadata->getColumnName('date')), @@ -64,7 +129,7 @@ final readonly class AccompanyingCourseDocumentGenericDocProvider implements Gen ); } - if (null !== $content) { + if (null !== $content and '' !== $content) { $query->addWhereClause( sprintf( '(%s ilike ? OR %s ilike ?)', @@ -79,8 +144,4 @@ final readonly class AccompanyingCourseDocumentGenericDocProvider implements Gen return $query; } - public function isAllowedForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod): bool - { - return $this->security->isGranted(AccompanyingCourseDocumentVoter::SEE, $accompanyingPeriod); - } } diff --git a/src/Bundle/ChillDocStoreBundle/GenericDoc/Renderer/AccompanyingCourseDocumentGenericDocRenderer.php b/src/Bundle/ChillDocStoreBundle/GenericDoc/Renderer/AccompanyingCourseDocumentGenericDocRenderer.php index ffa158aca..052153be8 100644 --- a/src/Bundle/ChillDocStoreBundle/GenericDoc/Renderer/AccompanyingCourseDocumentGenericDocRenderer.php +++ b/src/Bundle/ChillDocStoreBundle/GenericDoc/Renderer/AccompanyingCourseDocumentGenericDocRenderer.php @@ -40,18 +40,18 @@ final readonly class AccompanyingCourseDocumentGenericDocRenderer implements Gen public function getTemplateData(GenericDocDTO $genericDocDTO, $options = []): array { - if ($genericDocDTO->linked instanceof AccompanyingPeriod) { + if (AccompanyingCourseDocumentGenericDocProvider::KEY === $genericDocDTO->key) { return [ - 'document' => $this->accompanyingCourseDocumentRepository->find($genericDocDTO->identifiers['id']), - 'accompanyingCourse' => $genericDocDTO->linked, + 'document' => $doc = $this->accompanyingCourseDocumentRepository->find($genericDocDTO->identifiers['id']), + 'accompanyingCourse' => $doc->getCourse(), 'options' => $options, ]; } // this is a person return [ - 'document' => $this->personDocumentRepository->find($genericDocDTO->identifiers['id']), - 'person' => $genericDocDTO->linked, + 'document' => $doc = $this->personDocumentRepository->find($genericDocDTO->identifiers['id']), + 'person' => $doc->getPerson(), 'options' => $options, ]; } From ed556d9ee8dd52bd6d076fee7e26b9818b2f3f0e Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 31 May 2023 09:47:48 +0200 Subject: [PATCH 129/724] FIX [review] process review and make minor visual changes --- .../public/vuejs/AccompanyingCourseWorkEdit/App.vue | 12 ++++++------ .../components/AddEvaluation.vue | 7 ++----- .../components/FormEvaluation.vue | 12 +++++++----- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue index adbcf1097..1c9c2fd6d 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue @@ -123,7 +123,7 @@ v-for="e in pickedEvaluations" v-bind:key="e.key" v-bind:evaluation="e" - v-bind:docId="this.docId"> + v-bind:docAnchorId="this.docAnchorId"> @@ -390,7 +390,7 @@ export default { i18n, data() { return { - docId: null, + docAnchorId: null, isExpanded: false, editor: ClassicEditor, showAddObjective: false, @@ -432,10 +432,10 @@ export default { }, beforeMount() { const urlParams = new URLSearchParams(window.location.search); - this.docId = urlParams.get('doc_id'); + this.docAnchorId = urlParams.get('doc_id'); }, mounted() { - this.scrollToElement(this.docId); + this.scrollToElement(this.docAnchorId); }, computed: { ...mapState([ @@ -591,8 +591,8 @@ export default { } }) }, - scrollToElement(docId) { - const documentEl = document.getElementById(`document_${docId}`); + scrollToElement(docAnchorId) { + const documentEl = document.getElementById(`document_${docAnchorId}`); if (documentEl) { documentEl.scrollIntoView({behavior: 'smooth'}); } diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/AddEvaluation.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/AddEvaluation.vue index 215c5d6cc..baa3fa798 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/AddEvaluation.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/AddEvaluation.vue @@ -11,7 +11,7 @@
        - +
        • @@ -85,7 +85,7 @@ export default { Modal, ListWorkflowModal, }, - props: ['evaluation', 'docId'], + props: ['evaluation', 'docAnchorId'], i18n, data() { return { @@ -95,9 +95,6 @@ export default { } }; }, -/* mounted() { - console.log('docId is here', this.docId) - },*/ computed: { pickedEvaluations() { return this.$store.state.evaluationsPicked; diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue index ff7597dec..10bac43b3 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue @@ -80,12 +80,13 @@
          -
          +
          From cb718a80dece206e020c4cac7e86aa2e0b735172 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 31 May 2023 12:23:34 +0200 Subject: [PATCH 130/724] Add accompanying period work evaluation documents to the list of documents for person --- ...anyingCourseDocumentGenericDocProvider.php | 2 +- ...PeriodWorkEvaluationGenericDocProvider.php | 136 +++++++++++++----- 2 files changed, 99 insertions(+), 39 deletions(-) diff --git a/src/Bundle/ChillDocStoreBundle/GenericDoc/Providers/AccompanyingCourseDocumentGenericDocProvider.php b/src/Bundle/ChillDocStoreBundle/GenericDoc/Providers/AccompanyingCourseDocumentGenericDocProvider.php index 054e6a6d8..fd36f7976 100644 --- a/src/Bundle/ChillDocStoreBundle/GenericDoc/Providers/AccompanyingCourseDocumentGenericDocProvider.php +++ b/src/Bundle/ChillDocStoreBundle/GenericDoc/Providers/AccompanyingCourseDocumentGenericDocProvider.php @@ -99,7 +99,7 @@ final readonly class AccompanyingCourseDocumentGenericDocProvider implements Gen return $query; } - $query->addWhereClause(implode(' OR ', $or), $orParams, $orTypes); + $query->addWhereClause('(' . implode(' OR ', $or) . ')', $orParams, $orTypes); return $this->addWhereClause($query, $startDate, $endDate, $content); } diff --git a/src/Bundle/ChillPersonBundle/Service/GenericDoc/Providers/AccompanyingPeriodWorkEvaluationGenericDocProvider.php b/src/Bundle/ChillPersonBundle/Service/GenericDoc/Providers/AccompanyingPeriodWorkEvaluationGenericDocProvider.php index 883836547..f8b99a048 100644 --- a/src/Bundle/ChillPersonBundle/Service/GenericDoc/Providers/AccompanyingPeriodWorkEvaluationGenericDocProvider.php +++ b/src/Bundle/ChillPersonBundle/Service/GenericDoc/Providers/AccompanyingPeriodWorkEvaluationGenericDocProvider.php @@ -15,13 +15,16 @@ use Chill\DocStoreBundle\Entity\StoredObject; use Chill\DocStoreBundle\GenericDoc\FetchQuery; use Chill\DocStoreBundle\GenericDoc\FetchQueryInterface; use Chill\DocStoreBundle\GenericDoc\GenericDocForAccompanyingPeriodProviderInterface; +use Chill\DocStoreBundle\GenericDoc\GenericDocForPersonProviderInterface; use Chill\PersonBundle\Entity\AccompanyingPeriod; +use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodWorkVoter; +use DateTimeImmutable; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\EntityManagerInterface; use Symfony\Component\Security\Core\Security; -final readonly class AccompanyingPeriodWorkEvaluationGenericDocProvider implements GenericDocForAccompanyingPeriodProviderInterface +final readonly class AccompanyingPeriodWorkEvaluationGenericDocProvider implements GenericDocForAccompanyingPeriodProviderInterface, GenericDocForPersonProviderInterface { public const KEY = 'accompanying_period_work_evaluation_document'; @@ -32,6 +35,100 @@ final readonly class AccompanyingPeriodWorkEvaluationGenericDocProvider implemen } public function buildFetchQueryForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod, ?\DateTimeImmutable $startDate = null, ?\DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface + { + $accompanyingPeriodWorkMetadata = $this->entityManager->getClassMetadata(AccompanyingPeriod\AccompanyingPeriodWork::class); + $query = $this->buildBaseQuery(); + + $query->addWhereClause( + sprintf('action.%s = ?', $accompanyingPeriodWorkMetadata->getAssociationMapping('accompanyingPeriod')['joinColumns'][0]['name']), + [$accompanyingPeriod->getId()], + [Types::INTEGER] + ); + + return $this->addWhereClausesToQuery($query, $startDate, $endDate, $content); + } + + public function isAllowedForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod): bool + { + return $this->security->isGranted(AccompanyingPeriodWorkVoter::SEE, $accompanyingPeriod); + } + + private function addWhereClausesToQuery(FetchQuery $query, ?\DateTimeImmutable $startDate = null, ?\DateTimeImmutable $endDate = null, ?string $content = null): FetchQuery + { + $classMetadata = $this->entityManager->getClassMetadata(AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocument::class); + $storedObjectMetadata = $this->entityManager->getClassMetadata(StoredObject::class); + + if (null !== $startDate) { + $query->addWhereClause( + sprintf('doc_store.%s >= ?', $storedObjectMetadata->getColumnName('createdAt')), + [$startDate], + [Types::DATE_IMMUTABLE] + ); + } + + if (null !== $endDate) { + $query->addWhereClause( + sprintf('doc_store.%s < ?', $storedObjectMetadata->getColumnName('createdAt')), + [$endDate], + [Types::DATE_IMMUTABLE] + ); + } + + if (null !== $content) { + $query->addWhereClause( + sprintf('apwed.%s ilike ?', $classMetadata->getColumnName('title')), + ['%' . $content . '%'], + [Types::STRING] + ); + } + + return $query; + } + + public function buildFetchQueryForPerson(Person $person, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface + { + $storedObjectMetadata = $this->entityManager->getClassMetadata(StoredObject::class); + $accompanyingPeriodWorkMetadata = $this->entityManager->getClassMetadata(AccompanyingPeriod\AccompanyingPeriodWork::class); + $query = $this->buildBaseQuery(); + + // we loop over each accompanying period participation, to check of the user is allowed to see them + $or = []; + $orParams = []; + $orTypes = []; + foreach ($person->getAccompanyingPeriodParticipations() as $participation) { + if (!$this->security->isGranted(AccompanyingPeriodWorkVoter::SEE, $participation->getAccompanyingPeriod())) { + continue; + } + + $or[] = sprintf( + '(action.%s = ? AND apwed.%s BETWEEN ?::date AND COALESCE(?::date, \'infinity\'::date))', + $accompanyingPeriodWorkMetadata->getSingleAssociationJoinColumnName('accompanyingPeriod'), + $storedObjectMetadata->getColumnName('createdAt') + ); + $orParams = [...$orParams, $participation->getAccompanyingPeriod()->getId(), + DateTimeImmutable::createFromInterface($participation->getStartDate()), + null === $participation->getEndDate() ? null : DateTimeImmutable::createFromInterface($participation->getEndDate())]; + $orTypes = [...$orTypes, Types::INTEGER, Types::DATE_IMMUTABLE, Types::DATE_IMMUTABLE]; + } + + if ([] === $or) { + $query->addWhereClause('TRUE = FALSE'); + + return $query; + } + + $query->addWhereClause(sprintf('(%s)', implode(' OR ', $or)), $orParams, $orTypes); + + return $this->addWhereClausesToQuery($query, $startDate, $endDate, $content); + } + + public function isAllowedForPerson(Person $person): bool + { + // this will be filtered during query + return true; + } + + private function buildBaseQuery(): FetchQuery { $classMetadata = $this->entityManager->getClassMetadata(AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocument::class); $storedObjectMetadata = $this->entityManager->getClassMetadata(StoredObject::class); @@ -63,43 +160,6 @@ final readonly class AccompanyingPeriodWorkEvaluationGenericDocProvider implemen $accompanyingPeriodWorkMetadata->getColumnName('id') )); - $query->addWhereClause( - sprintf('action.%s = ?', $accompanyingPeriodWorkMetadata->getAssociationMapping('accompanyingPeriod')['joinColumns'][0]['name']), - [$accompanyingPeriod->getId()], - [Types::INTEGER] - ); - - if (null !== $startDate) { - $query->addWhereClause( - sprintf('doc_store.%s >= ?', $storedObjectMetadata->getColumnName('createdAt')), - [$startDate], - [Types::DATE_IMMUTABLE] - ); - } - - if (null !== $endDate) { - $query->addWhereClause( - sprintf('doc_store.%s < ?', $storedObjectMetadata->getColumnName('createdAt')), - [$endDate], - [Types::DATE_IMMUTABLE] - ); - } - - if (null !== $content) { - $query->addWhereClause( - sprintf('apwed.%s ilike ?', $classMetadata->getColumnName('title')), - ['%' . $content . '%'], - [Types::STRING] - ); - } - return $query; } - - public function isAllowedForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod): bool - { - return $this->security->isGranted(AccompanyingPeriodWorkVoter::SEE, $accompanyingPeriod); - } - - } From 4489098addd0d202a84d999d43c37d4494a421bf Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 31 May 2023 14:20:54 +0200 Subject: [PATCH 131/724] FIX [calculator] type cast result to a float --- src/Bundle/ChillBudgetBundle/Calculator/CalculatorResult.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bundle/ChillBudgetBundle/Calculator/CalculatorResult.php b/src/Bundle/ChillBudgetBundle/Calculator/CalculatorResult.php index 380e641a6..2a67486f0 100644 --- a/src/Bundle/ChillBudgetBundle/Calculator/CalculatorResult.php +++ b/src/Bundle/ChillBudgetBundle/Calculator/CalculatorResult.php @@ -21,7 +21,7 @@ class CalculatorResult public $label; - public $result; + public float $result; public $type; } From 20489813f068c6147976ee1e6ed50b1b5dc2c66c Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 30 May 2023 14:38:16 +0200 Subject: [PATCH 132/724] FIX [route] adjust to using new route name in redirect --- .../Controller/DocumentAccompanyingCourseController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseController.php b/src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseController.php index 8762050aa..384eeb510 100644 --- a/src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseController.php +++ b/src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseController.php @@ -160,7 +160,7 @@ class DocumentAccompanyingCourseController extends AbstractController $this->addFlash('success', $this->translator->trans('The document is successfully registered')); - return $this->redirectToRoute('accompanying_course_document_index', ['course' => $course->getId()]); + return $this->redirectToRoute('chill_docstore_generic-doc_by-period_index', ['id' => $course->getId()]); } if ($form->isSubmitted() && !$form->isValid()) { From 47a3e30ec532e6cf27ba00e049a2e90c6ea7bd9b Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 30 May 2023 16:56:20 +0200 Subject: [PATCH 133/724] FEATURE [genericDoc] generic doc interface implemented for rendez-vous --- .../GenericDoc/calendar_document.html.twig | 72 +++++++++++++ ...anyingPeriodCalendarGenericDocProvider.php | 101 ++++++++++++++++++ ...anyingPeriodCalendarGenericDocRenderer.php | 44 ++++++++ .../translations/messages.fr.yml | 2 + .../translations/messages.fr.yml | 1 + 5 files changed, 220 insertions(+) create mode 100644 src/Bundle/ChillCalendarBundle/Resources/views/GenericDoc/calendar_document.html.twig create mode 100644 src/Bundle/ChillCalendarBundle/Service/GenericDoc/Providers/AccompanyingPeriodCalendarGenericDocProvider.php create mode 100644 src/Bundle/ChillCalendarBundle/Service/GenericDoc/Renderers/AccompanyingPeriodCalendarGenericDocRenderer.php diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/GenericDoc/calendar_document.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/GenericDoc/calendar_document.html.twig new file mode 100644 index 000000000..712b362f5 --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/Resources/views/GenericDoc/calendar_document.html.twig @@ -0,0 +1,72 @@ +{% import "@ChillDocStore/Macro/macro.html.twig" as m %} +{% import "@ChillDocStore/Macro/macro_mimeicon.html.twig" as mm %} +{% import '@ChillPerson/Macro/updatedBy.html.twig' as mmm %} + +{% set c = document.calendar %} + +
          +
          +
          + {% if document.storedObject.isPending %} +
          {{ 'docgen.Doc generation is pending'|trans }}
          + {% elseif document.storedObject.isFailure %} +
          {{ 'docgen.Doc generation failed'|trans }}
          + {% endif %} +
          + {{ document.storedObject.title }} +
          +
          + {{ 'chill_calendar.Document'|trans }} +
          + {% if document.storedObject.hasTemplate %} +
          +

          {{ document.storedObject.template.name|localize_translatable_string }}

          +
          + {% endif %} +
          + +
          +
          +
          + {{ document.storedObject.createdAt|format_date('short') }} +
          +
          +
          +
          + +
          +
          +

          + {% if c.endDate.diff(c.startDate).days >= 1 %} + {{ c.startDate|format_datetime('short', 'short') }} + - {{ c.endDate|format_datetime('short', 'short') }} + {% else %} + {{ c.startDate|format_datetime('short', 'short') }} + - {{ c.endDate|format_datetime('none', 'short') }} + {% endif %} +

          +
          +
          + +
          +
          + {{ mmm.createdBy(document) }} +
          +
            +
          • + {{ chill_entity_workflow_list('Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluationDocument', document.id) }} +
          • + {% if is_granted('CHILL_CALENDAR_DOC_SEE', document) %} +
          • + {{ document.storedObject|chill_document_button_group(document.storedObject.title, is_granted('CHILL_CALENDAR_CALENDAR_EDIT', c)) }} +
          • + {% endif %} + {% if is_granted('CHILL_CALENDAR_CALENDAR_EDIT', c) %} +
          • + +
          • + {% endif %} +
          + +
          +
          diff --git a/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Providers/AccompanyingPeriodCalendarGenericDocProvider.php b/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Providers/AccompanyingPeriodCalendarGenericDocProvider.php new file mode 100644 index 000000000..ff2cdbcf5 --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Providers/AccompanyingPeriodCalendarGenericDocProvider.php @@ -0,0 +1,101 @@ +security = $security; + $this->em = $entityManager; + } + + public function buildFetchQueryForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod, ?\DateTimeImmutable $startDate = null, ?\DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface + { + $classMetadata = $this->em->getClassMetadata(CalendarDoc::class); + $storedObjectMetadata = $this->em->getClassMetadata(StoredObject::class); + $calendarMetadata = $this->em->getClassMetadata(Calendar::class); + + $query = new FetchQuery( + self::KEY, + sprintf("jsonb_build_object('id', cd.%s)", $classMetadata->getColumnName('id')), + 'cd.'.$storedObjectMetadata->getColumnName('createdAt'), + $classMetadata->getSchemaName().'.'.$classMetadata->getTableName().' AS cd' + ); + $query->addJoinClause( + 'JOIN chill_doc.stored_object doc_store ON doc_store.id = cd.storedobject_id' + ); + + $query->addJoinClause( + 'JOIN chill_calendar.calendar calendar ON calendar.id = cd.calendar_id' + ); + + $query->addWhereClause( + 'calendar.accompanyingperiod_id = ?', + [$accompanyingPeriod->getId()], + [Types::INTEGER] + ); + + if (null !== $startDate) { + $query->addWhereClause( + sprintf('doc_store.%s >= ?', $storedObjectMetadata->getColumnName('createdAt')), + [$startDate], + [Types::DATE_IMMUTABLE] + ); + } + + if (null !== $endDate) { + $query->addWhereClause( + sprintf('doc_store.%s < ?', $storedObjectMetadata->getColumnName('createdAt')), + [$endDate], + [Types::DATE_IMMUTABLE] + ); + } + + if (null !== $content) { + $query->addWhereClause( + 'doc_store.title ilike ?', + ['%' . $content . '%'], + [Types::STRING] + ); + } + + return $query; + } + + public function isAllowedForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod): bool + { + return $this->security->isGranted(CalendarVoter::SEE, $accompanyingPeriod); + } + + +} diff --git a/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Renderers/AccompanyingPeriodCalendarGenericDocRenderer.php b/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Renderers/AccompanyingPeriodCalendarGenericDocRenderer.php new file mode 100644 index 000000000..0f680797c --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Renderers/AccompanyingPeriodCalendarGenericDocRenderer.php @@ -0,0 +1,44 @@ +repository = $calendarDocRepository; + } + + public function supports(GenericDocDTO $genericDocDTO, $options = []): bool + { + return $genericDocDTO->key === AccompanyingPeriodCalendarGenericDocProvider::KEY; + } + + public function getTemplate(GenericDocDTO $genericDocDTO, $options = []): string + { + return '@ChillCalendar/GenericDoc/calendar_document.html.twig'; + } + + public function getTemplateData(GenericDocDTO $genericDocDTO, $options = []): array + { + return [ + 'document' => $this->repository->find($genericDocDTO->identifiers['id']) + ]; + } +} diff --git a/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml b/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml index eb02be280..5e1fc971a 100644 --- a/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml @@ -43,6 +43,7 @@ crud: title_edit: Modifier le motif d'annulation chill_calendar: + Document: Document d'un rendez-vous form: The main user is mandatory. He will organize the appointment.: L'utilisateur principal est obligatoire. Il est l'organisateur de l'événement. Create for referrer: Créer pour le référent @@ -65,6 +66,7 @@ chill_calendar: Document outdated: La date et l'heure du rendez-vous ont été modifiés après la création du document + remote_ms_graph: freebusy_statuses: busy: Occupé diff --git a/src/Bundle/ChillDocStoreBundle/translations/messages.fr.yml b/src/Bundle/ChillDocStoreBundle/translations/messages.fr.yml index 1dde57eee..4fa41f180 100644 --- a/src/Bundle/ChillDocStoreBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillDocStoreBundle/translations/messages.fr.yml @@ -26,6 +26,7 @@ generic_doc: filter: keys: accompanying_course_document: Document du parcours + accompanying_period_calendar_document: Document des rendez-vous date-range: Date du document # delete From 9eb9a9a214d9801fa5fa87ae10449b1068a16576 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 30 May 2023 16:59:16 +0200 Subject: [PATCH 134/724] WIP [genericDoc][activity] implementing generic doc for activities --- ...anyingPeriodActivityGenericDocProvider.php | 110 ++++++++++++++++++ ...anyingPeriodActivityGenericDocRenderer.php | 45 +++++++ 2 files changed, 155 insertions(+) create mode 100644 src/Bundle/ChillActivityBundle/Service/GenericDoc/Providers/AccompanyingPeriodActivityGenericDocProvider.php create mode 100644 src/Bundle/ChillActivityBundle/Service/GenericDoc/Renderers/AccompanyingPeriodActivityGenericDocRenderer.php diff --git a/src/Bundle/ChillActivityBundle/Service/GenericDoc/Providers/AccompanyingPeriodActivityGenericDocProvider.php b/src/Bundle/ChillActivityBundle/Service/GenericDoc/Providers/AccompanyingPeriodActivityGenericDocProvider.php new file mode 100644 index 000000000..fc7484edf --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Service/GenericDoc/Providers/AccompanyingPeriodActivityGenericDocProvider.php @@ -0,0 +1,110 @@ +em = $entityManager; + $this->security = $security; + } + + /** + * @param AccompanyingPeriod $accompanyingPeriod + * @param DateTimeImmutable|null $startDate + * @param DateTimeImmutable|null $endDate + * @param string|null $content + * @param string|null $origin + * @return FetchQueryInterface + * @throws MappingException + */ + public function buildFetchQueryForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface + { + $storedObjectMetadata = $this->em->getClassMetadata(StoredObject::class); +// $activityMetadata = $this->em->getClassMetadata(Activity::class); + + $query = new FetchQuery( + self::KEY, + "jsonb_build_object('id', doc_obj.id)", + 'doc_obj.'.$storedObjectMetadata->getColumnName('createdAt'), + $storedObjectMetadata->getSchemaName().'.'.$storedObjectMetadata->getTableName().' AS doc_obj' + ); + + $query->addJoinClause( + 'JOIN public.activity_storedobject activity_doc ON activity_doc.storedobject_id = doc_obj.id' + ); + + $query->addJoinClause( + 'JOIN public.activity activity ON activity.id = activity_doc.activity_id' + ); + + $query->addWhereClause( + 'activity.accompanyingperiod_id = ?', + [$accompanyingPeriod->getId()], + [Types::INTEGER] + ); + + if (null !== $startDate) { + $query->addWhereClause( + sprintf('doc_obj.%s >= ?', $storedObjectMetadata->getColumnName('createdAt')), + [$startDate], + [Types::DATE_IMMUTABLE] + ); + } + + if (null !== $endDate) { + $query->addWhereClause( + sprintf('doc_obj.%s < ?', $storedObjectMetadata->getColumnName('createdAt')), + [$endDate], + [Types::DATE_IMMUTABLE] + ); + } + + if (null !== $content) { + $query->addWhereClause( + 'doc_obj.title ilike ?', + ['%' . $content . '%'], + [Types::STRING] + ); + } + + return $query; + } + + /** + * @param AccompanyingPeriod $accompanyingPeriod + * @return bool + */ + public function isAllowedForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod): bool + { + return $this->security->isGranted(ActivityVoter::SEE, $accompanyingPeriod); + } +} diff --git a/src/Bundle/ChillActivityBundle/Service/GenericDoc/Renderers/AccompanyingPeriodActivityGenericDocRenderer.php b/src/Bundle/ChillActivityBundle/Service/GenericDoc/Renderers/AccompanyingPeriodActivityGenericDocRenderer.php new file mode 100644 index 000000000..eddcc6828 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Service/GenericDoc/Renderers/AccompanyingPeriodActivityGenericDocRenderer.php @@ -0,0 +1,45 @@ +repository = $storedObjectRepository; + } + + public function supports(GenericDocDTO $genericDocDTO, $options = []): bool + { + return $genericDocDTO->key === AccompanyingPeriodActivityGenericDocProvider::KEY; + } + + public function getTemplate(GenericDocDTO $genericDocDTO, $options = []): string + { + return '@ChillCalendar/GenericDoc/activity_document.html.twig'; + } + + public function getTemplateData(GenericDocDTO $genericDocDTO, $options = []): array + { + return [ + 'document' => $this->repository->find($genericDocDTO->identifiers['id']) + ]; + } +} + From 4155af6686cd173c8689b5d9bff52b3996963644 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 30 May 2023 17:50:32 +0200 Subject: [PATCH 135/724] FEATURE [genericDoc][calendar] use metadatas --- ...anyingPeriodCalendarGenericDocProvider.php | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Providers/AccompanyingPeriodCalendarGenericDocProvider.php b/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Providers/AccompanyingPeriodCalendarGenericDocProvider.php index ff2cdbcf5..e653cfc25 100644 --- a/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Providers/AccompanyingPeriodCalendarGenericDocProvider.php +++ b/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Providers/AccompanyingPeriodCalendarGenericDocProvider.php @@ -21,6 +21,7 @@ use Chill\DocStoreBundle\GenericDoc\GenericDocForAccompanyingPeriodProviderInter use Chill\PersonBundle\Entity\AccompanyingPeriod; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\EntityManagerInterface; +use Doctrine\ORM\Mapping\MappingException; use Symfony\Component\Security\Core\Security; final class AccompanyingPeriodCalendarGenericDocProvider implements GenericDocForAccompanyingPeriodProviderInterface @@ -39,6 +40,9 @@ final class AccompanyingPeriodCalendarGenericDocProvider implements GenericDocFo $this->em = $entityManager; } + /** + * @throws MappingException + */ public function buildFetchQueryForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod, ?\DateTimeImmutable $startDate = null, ?\DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface { $classMetadata = $this->em->getClassMetadata(CalendarDoc::class); @@ -52,15 +56,23 @@ final class AccompanyingPeriodCalendarGenericDocProvider implements GenericDocFo $classMetadata->getSchemaName().'.'.$classMetadata->getTableName().' AS cd' ); $query->addJoinClause( - 'JOIN chill_doc.stored_object doc_store ON doc_store.id = cd.storedobject_id' - ); + sprintf('JOIN %s doc_store ON doc_store.%s = cd.%s', + $storedObjectMetadata->getSchemaName().'.'.$storedObjectMetadata->getTableName(), + $storedObjectMetadata->getColumnName('id'), + $classMetadata->getSingleAssociationJoinColumnName('storedObject') + )); $query->addJoinClause( - 'JOIN chill_calendar.calendar calendar ON calendar.id = cd.calendar_id' + sprintf('JOIN %s calendar ON calendar.%s = cd.%s', + $calendarMetadata->getSchemaName().'.'.$calendarMetadata->getTableName(), + $calendarMetadata->getColumnName('id'), + $classMetadata->getSingleAssociationJoinColumnName('calendar') + ) ); $query->addWhereClause( - 'calendar.accompanyingperiod_id = ?', + sprintf('calendar.%s = ?', + $calendarMetadata->getAssociationMapping('accompanyingPeriod')['joinColumns'][0]['name']), [$accompanyingPeriod->getId()], [Types::INTEGER] ); @@ -83,7 +95,7 @@ final class AccompanyingPeriodCalendarGenericDocProvider implements GenericDocFo if (null !== $content) { $query->addWhereClause( - 'doc_store.title ilike ?', + sprintf('doc_store.%s ilike ?', $storedObjectMetadata->getColumnName('title')), ['%' . $content . '%'], [Types::STRING] ); From c07e26785e5b73e810b50bb41be02d2ad424e01c Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 30 May 2023 18:14:32 +0200 Subject: [PATCH 136/724] WIP [genericDoc][activity] add repository method to get activity linked to storedObject --- .../Repository/ActivityRepository.php | 12 ++++ .../GenericDoc/activity_document.html.twig | 72 +++++++++++++++++++ ...anyingPeriodActivityGenericDocProvider.php | 3 +- ...anyingPeriodActivityGenericDocRenderer.php | 13 ++-- 4 files changed, 94 insertions(+), 6 deletions(-) create mode 100644 src/Bundle/ChillActivityBundle/Resources/views/GenericDoc/activity_document.html.twig diff --git a/src/Bundle/ChillActivityBundle/Repository/ActivityRepository.php b/src/Bundle/ChillActivityBundle/Repository/ActivityRepository.php index 5a6e16cd5..02658b03d 100644 --- a/src/Bundle/ChillActivityBundle/Repository/ActivityRepository.php +++ b/src/Bundle/ChillActivityBundle/Repository/ActivityRepository.php @@ -15,6 +15,7 @@ use Chill\ActivityBundle\Entity\Activity; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\Person; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; +use Doctrine\ORM\Query\Expr; use Doctrine\Persistence\ManagerRegistry; /** @@ -97,4 +98,15 @@ class ActivityRepository extends ServiceEntityRepository return $qb->getQuery()->getResult(); } + + public function findOneByDocument(int $documentId): Activity + { + $qb = $this->createQueryBuilder('a'); + $qb->select('a'); + + $qb->innerJoin('a.documents', 'd', Expr\Join::WITH, 'd.storedobject_id = :documentId'); + $qb->setParameter('documentId', $documentId); + + return $qb->getQuery()->getResult(); + } } diff --git a/src/Bundle/ChillActivityBundle/Resources/views/GenericDoc/activity_document.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/GenericDoc/activity_document.html.twig new file mode 100644 index 000000000..aeaea0872 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Resources/views/GenericDoc/activity_document.html.twig @@ -0,0 +1,72 @@ +{% import "@ChillDocStore/Macro/macro.html.twig" as m %} +{% import "@ChillDocStore/Macro/macro_mimeicon.html.twig" as mm %} +{% import '@ChillPerson/Macro/updatedBy.html.twig' as mmm %} + +{% set a = document.calendar %} + +
          +
          +
          + {% if document.storedObject.isPending %} +
          {{ 'docgen.Doc generation is pending'|trans }}
          + {% elseif document.storedObject.isFailure %} +
          {{ 'docgen.Doc generation failed'|trans }}
          + {% endif %} +
          + {{ document.storedObject.title }} +
          +
          + {{ 'chill_calendar.Document'|trans }} +
          + {% if document.storedObject.hasTemplate %} +
          +

          {{ document.storedObject.template.name|localize_translatable_string }}

          +
          + {% endif %} +
          + +
          +
          +
          + {{ document.storedObject.createdAt|format_date('short') }} +
          +
          +
          +
          + +
          +
          +

          + {% if c.endDate.diff(c.startDate).days >= 1 %} + {{ c.startDate|format_datetime('short', 'short') }} + - {{ c.endDate|format_datetime('short', 'short') }} + {% else %} + {{ c.startDate|format_datetime('short', 'short') }} + - {{ c.endDate|format_datetime('none', 'short') }} + {% endif %} +

          +
          +
          + +
          +
          + {{ mmm.createdBy(document) }} +
          +
            +
          • + {{ chill_entity_workflow_list('Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluationDocument', document.id) }} +
          • + {% if is_granted('CHILL_CALENDAR_DOC_SEE', document) %} +
          • + {{ document.storedObject|chill_document_button_group(document.storedObject.title, is_granted('CHILL_CALENDAR_CALENDAR_EDIT', c)) }} +
          • + {% endif %} + {% if is_granted('CHILL_CALENDAR_CALENDAR_EDIT', c) %} +
          • + +
          • + {% endif %} +
          + +
          +
          diff --git a/src/Bundle/ChillActivityBundle/Service/GenericDoc/Providers/AccompanyingPeriodActivityGenericDocProvider.php b/src/Bundle/ChillActivityBundle/Service/GenericDoc/Providers/AccompanyingPeriodActivityGenericDocProvider.php index fc7484edf..bf7a022f1 100644 --- a/src/Bundle/ChillActivityBundle/Service/GenericDoc/Providers/AccompanyingPeriodActivityGenericDocProvider.php +++ b/src/Bundle/ChillActivityBundle/Service/GenericDoc/Providers/AccompanyingPeriodActivityGenericDocProvider.php @@ -27,7 +27,7 @@ final class AccompanyingPeriodActivityGenericDocProvider implements GenericDocFo { public const KEY = 'accompanying_period_activity_document'; - private EntityManagerInterface $em; + private EntityManagerInterface $em; private Security $security; @@ -49,7 +49,6 @@ final class AccompanyingPeriodActivityGenericDocProvider implements GenericDocFo public function buildFetchQueryForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface { $storedObjectMetadata = $this->em->getClassMetadata(StoredObject::class); -// $activityMetadata = $this->em->getClassMetadata(Activity::class); $query = new FetchQuery( self::KEY, diff --git a/src/Bundle/ChillActivityBundle/Service/GenericDoc/Renderers/AccompanyingPeriodActivityGenericDocRenderer.php b/src/Bundle/ChillActivityBundle/Service/GenericDoc/Renderers/AccompanyingPeriodActivityGenericDocRenderer.php index eddcc6828..f243fb941 100644 --- a/src/Bundle/ChillActivityBundle/Service/GenericDoc/Renderers/AccompanyingPeriodActivityGenericDocRenderer.php +++ b/src/Bundle/ChillActivityBundle/Service/GenericDoc/Renderers/AccompanyingPeriodActivityGenericDocRenderer.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\ActivityBundle\Service\GenericDoc\Renderers; +use Chill\ActivityBundle\Repository\ActivityRepository; use Chill\ActivityBundle\Service\GenericDoc\Providers\AccompanyingPeriodActivityGenericDocProvider; use Chill\DocStoreBundle\GenericDoc\GenericDocDTO; use Chill\DocStoreBundle\GenericDoc\Twig\GenericDocRendererInterface; @@ -18,11 +19,14 @@ use Chill\DocStoreBundle\Repository\StoredObjectRepository; final class AccompanyingPeriodActivityGenericDocRenderer implements GenericDocRendererInterface { - private StoredObjectRepository $repository; + private StoredObjectRepository $objectRepository; - public function __construct(StoredObjectRepository $storedObjectRepository) + private ActivityRepository $activityRepository; + + public function __construct(StoredObjectRepository $storedObjectRepository, ActivityRepository $activityRepository) { - $this->repository = $storedObjectRepository; + $this->objectRepository = $storedObjectRepository; + $this->activityRepository = $activityRepository; } public function supports(GenericDocDTO $genericDocDTO, $options = []): bool @@ -38,7 +42,8 @@ final class AccompanyingPeriodActivityGenericDocRenderer implements GenericDocRe public function getTemplateData(GenericDocDTO $genericDocDTO, $options = []): array { return [ - 'document' => $this->repository->find($genericDocDTO->identifiers['id']) + 'activity' => $this->activityRepository->findOneByDocument($genericDocDTO->identifiers['id']), + 'document' => $this->objectRepository->find($genericDocDTO->identifiers['id']) ]; } } From ba55fa349baa108487af2b5eef9737196aa6c022 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 31 May 2023 16:53:38 +0200 Subject: [PATCH 137/724] FEATURE [genericDoc][activity] finalize implementation --- .../Repository/ActivityRepository.php | 11 ---- .../GenericDoc/activity_document.html.twig | 63 ++++++++++--------- ...anyingPeriodActivityGenericDocProvider.php | 23 ++----- ...anyingPeriodActivityGenericDocRenderer.php | 4 +- .../ChillActivityBundle/config/services.yaml | 3 + 5 files changed, 45 insertions(+), 59 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Repository/ActivityRepository.php b/src/Bundle/ChillActivityBundle/Repository/ActivityRepository.php index 02658b03d..a3bfb5942 100644 --- a/src/Bundle/ChillActivityBundle/Repository/ActivityRepository.php +++ b/src/Bundle/ChillActivityBundle/Repository/ActivityRepository.php @@ -98,15 +98,4 @@ class ActivityRepository extends ServiceEntityRepository return $qb->getQuery()->getResult(); } - - public function findOneByDocument(int $documentId): Activity - { - $qb = $this->createQueryBuilder('a'); - $qb->select('a'); - - $qb->innerJoin('a.documents', 'd', Expr\Join::WITH, 'd.storedobject_id = :documentId'); - $qb->setParameter('documentId', $documentId); - - return $qb->getQuery()->getResult(); - } } diff --git a/src/Bundle/ChillActivityBundle/Resources/views/GenericDoc/activity_document.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/GenericDoc/activity_document.html.twig index aeaea0872..11aeeeca1 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/GenericDoc/activity_document.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/GenericDoc/activity_document.html.twig @@ -2,25 +2,30 @@ {% import "@ChillDocStore/Macro/macro_mimeicon.html.twig" as mm %} {% import '@ChillPerson/Macro/updatedBy.html.twig' as mmm %} -{% set a = document.calendar %} +{% set person_id = null %} +{% if activity.person %} + {% set person_id = activity.person.id %} +{% endif %} -
          +{% set accompanying_course_id = null %} +{% if activity.accompanyingPeriod %} + {% set accompanying_course_id = activity.accompanyingPeriod.id %} +{% endif %} + +
          - {% if document.storedObject.isPending %} -
          {{ 'docgen.Doc generation is pending'|trans }}
          - {% elseif document.storedObject.isFailure %} + {% if document.isPending %} +
          {{ 'docgen.Doc generation is pending'|trans }}
          + {% elseif document.isFailure %}
          {{ 'docgen.Doc generation failed'|trans }}
          {% endif %}
          - {{ document.storedObject.title }} + {{ document.title }}
          -
          - {{ 'chill_calendar.Document'|trans }} -
          - {% if document.storedObject.hasTemplate %} + {% if document.hasTemplate %}
          -

          {{ document.storedObject.template.name|localize_translatable_string }}

          +

          {{ document.template.name|localize_translatable_string }}

          {% endif %}
          @@ -28,7 +33,7 @@
          - {{ document.storedObject.createdAt|format_date('short') }} + {{ document.createdAt|format_date('short') }}
          @@ -36,15 +41,15 @@
          -

          - {% if c.endDate.diff(c.startDate).days >= 1 %} - {{ c.startDate|format_datetime('short', 'short') }} - - {{ c.endDate|format_datetime('short', 'short') }} - {% else %} - {{ c.startDate|format_datetime('short', 'short') }} - - {{ c.endDate|format_datetime('none', 'short') }} - {% endif %} -

          +

          + + + {{ activity.type.name | localize_translatable_string }} + {% if activity.emergency %} + {{ 'Emergency'|trans|upper }} + {% endif %} + +

          @@ -53,17 +58,19 @@ {{ mmm.createdBy(document) }}
            -
          • - {{ chill_entity_workflow_list('Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluationDocument', document.id) }} -
          • - {% if is_granted('CHILL_CALENDAR_DOC_SEE', document) %} + {% if is_granted('CHILL_ACTIVITY_SEE_DETAILS', activity) %}
          • - {{ document.storedObject|chill_document_button_group(document.storedObject.title, is_granted('CHILL_CALENDAR_CALENDAR_EDIT', c)) }} + {{ document|chill_document_button_group(document.title, is_granted('CHILL_ACTIVITY_UPDATE', activity), {small: false}) }}
          • {% endif %} - {% if is_granted('CHILL_CALENDAR_CALENDAR_EDIT', c) %} + {% if is_granted('CHILL_ACTIVITY_SEE', activity)%}
          • - + +
          • + {% endif %} + {% if is_granted('CHILL_ACTIVITY_UPDATE', activity) %} +
          • +
          • {% endif %}
          diff --git a/src/Bundle/ChillActivityBundle/Service/GenericDoc/Providers/AccompanyingPeriodActivityGenericDocProvider.php b/src/Bundle/ChillActivityBundle/Service/GenericDoc/Providers/AccompanyingPeriodActivityGenericDocProvider.php index bf7a022f1..8c787fd3a 100644 --- a/src/Bundle/ChillActivityBundle/Service/GenericDoc/Providers/AccompanyingPeriodActivityGenericDocProvider.php +++ b/src/Bundle/ChillActivityBundle/Service/GenericDoc/Providers/AccompanyingPeriodActivityGenericDocProvider.php @@ -27,32 +27,19 @@ final class AccompanyingPeriodActivityGenericDocProvider implements GenericDocFo { public const KEY = 'accompanying_period_activity_document'; - private EntityManagerInterface $em; - - private Security $security; - - public function __construct(Security $security, EntityManagerInterface $entityManager) - { - $this->em = $entityManager; - $this->security = $security; + public function __construct( + private EntityManagerInterface $em, + private Security $security + ){ } - /** - * @param AccompanyingPeriod $accompanyingPeriod - * @param DateTimeImmutable|null $startDate - * @param DateTimeImmutable|null $endDate - * @param string|null $content - * @param string|null $origin - * @return FetchQueryInterface - * @throws MappingException - */ public function buildFetchQueryForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface { $storedObjectMetadata = $this->em->getClassMetadata(StoredObject::class); $query = new FetchQuery( self::KEY, - "jsonb_build_object('id', doc_obj.id)", + "jsonb_build_object('id', doc_obj.id, 'activity_id', activity.id)", 'doc_obj.'.$storedObjectMetadata->getColumnName('createdAt'), $storedObjectMetadata->getSchemaName().'.'.$storedObjectMetadata->getTableName().' AS doc_obj' ); diff --git a/src/Bundle/ChillActivityBundle/Service/GenericDoc/Renderers/AccompanyingPeriodActivityGenericDocRenderer.php b/src/Bundle/ChillActivityBundle/Service/GenericDoc/Renderers/AccompanyingPeriodActivityGenericDocRenderer.php index f243fb941..f3b70dac2 100644 --- a/src/Bundle/ChillActivityBundle/Service/GenericDoc/Renderers/AccompanyingPeriodActivityGenericDocRenderer.php +++ b/src/Bundle/ChillActivityBundle/Service/GenericDoc/Renderers/AccompanyingPeriodActivityGenericDocRenderer.php @@ -36,13 +36,13 @@ final class AccompanyingPeriodActivityGenericDocRenderer implements GenericDocRe public function getTemplate(GenericDocDTO $genericDocDTO, $options = []): string { - return '@ChillCalendar/GenericDoc/activity_document.html.twig'; + return '@ChillActivity/GenericDoc/activity_document.html.twig'; } public function getTemplateData(GenericDocDTO $genericDocDTO, $options = []): array { return [ - 'activity' => $this->activityRepository->findOneByDocument($genericDocDTO->identifiers['id']), + 'activity' => $this->activityRepository->find($genericDocDTO->identifiers['activity_id']), 'document' => $this->objectRepository->find($genericDocDTO->identifiers['id']) ]; } diff --git a/src/Bundle/ChillActivityBundle/config/services.yaml b/src/Bundle/ChillActivityBundle/config/services.yaml index d55f86d4f..18be76ec9 100644 --- a/src/Bundle/ChillActivityBundle/config/services.yaml +++ b/src/Bundle/ChillActivityBundle/config/services.yaml @@ -38,3 +38,6 @@ services: Chill\ActivityBundle\Service\EntityInfo\: resource: '../Service/EntityInfo/' + + Chill\ActivityBundle\Service\GenericDoc\: + resource: '../Service/GenericDoc/' From ef04a0405645fc5a38396e8f88486928a40be697 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 31 May 2023 16:54:21 +0200 Subject: [PATCH 138/724] FEATURE [genericDoc][calendar] minor changes to template and provider --- .../views/GenericDoc/calendar_document.html.twig | 3 --- .../AccompanyingPeriodCalendarGenericDocProvider.php | 10 ++-------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/GenericDoc/calendar_document.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/GenericDoc/calendar_document.html.twig index 712b362f5..4cd369366 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/views/GenericDoc/calendar_document.html.twig +++ b/src/Bundle/ChillCalendarBundle/Resources/views/GenericDoc/calendar_document.html.twig @@ -53,9 +53,6 @@ {{ mmm.createdBy(document) }}
            -
          • - {{ chill_entity_workflow_list('Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluationDocument', document.id) }} -
          • {% if is_granted('CHILL_CALENDAR_DOC_SEE', document) %}
          • {{ document.storedObject|chill_document_button_group(document.storedObject.title, is_granted('CHILL_CALENDAR_CALENDAR_EDIT', c)) }} diff --git a/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Providers/AccompanyingPeriodCalendarGenericDocProvider.php b/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Providers/AccompanyingPeriodCalendarGenericDocProvider.php index e653cfc25..7efc1589d 100644 --- a/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Providers/AccompanyingPeriodCalendarGenericDocProvider.php +++ b/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Providers/AccompanyingPeriodCalendarGenericDocProvider.php @@ -28,16 +28,10 @@ final class AccompanyingPeriodCalendarGenericDocProvider implements GenericDocFo { public const KEY = 'accompanying_period_calendar_document'; - private EntityManagerInterface $em; - - private Security $security; - public function __construct( - Security $security, - EntityManagerInterface $entityManager + private Security $security, + private EntityManagerInterface $em ) { - $this->security = $security; - $this->em = $entityManager; } /** From 9a3fcf081ecb5d3d7449878c7562d4528df167b6 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 31 May 2023 17:10:38 +0200 Subject: [PATCH 139/724] FEATURE [personCalendar][genericDoc] implement genericDoc for calendar objects linked to a person --- .../PersonCalendarGenericDocProvider.php | 112 ++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 src/Bundle/ChillCalendarBundle/Service/GenericDoc/Providers/PersonCalendarGenericDocProvider.php diff --git a/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Providers/PersonCalendarGenericDocProvider.php b/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Providers/PersonCalendarGenericDocProvider.php new file mode 100644 index 000000000..12235f10a --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Providers/PersonCalendarGenericDocProvider.php @@ -0,0 +1,112 @@ +em->getClassMetadata(CalendarDoc::class); + $storedObjectMetadata = $this->em->getClassMetadata(StoredObject::class); + $calendarMetadata = $this->em->getClassMetadata(Calendar::class); + + $query = new FetchQuery( + self::KEY, + sprintf("jsonb_build_object('id', cd.%s)", $classMetadata->getColumnName('id')), + 'cd.'.$storedObjectMetadata->getColumnName('createdAt'), + $classMetadata->getSchemaName().'.'.$classMetadata->getTableName().' AS cd' + ); + $query->addJoinClause( + sprintf('JOIN %s doc_store ON doc_store.%s = cd.%s', + $storedObjectMetadata->getSchemaName().'.'.$storedObjectMetadata->getTableName(), + $storedObjectMetadata->getColumnName('id'), + $classMetadata->getSingleAssociationJoinColumnName('storedObject') + )); + + $query->addJoinClause( + sprintf('JOIN %s calendar ON calendar.%s = cd.%s', + $calendarMetadata->getSchemaName().'.'.$calendarMetadata->getTableName(), + $calendarMetadata->getColumnName('id'), + $classMetadata->getSingleAssociationJoinColumnName('calendar') + ) + ); + + $query->addWhereClause( + sprintf('calendar.%s = ?', + $calendarMetadata->getAssociationMapping('person')['joinColumns'][0]['name']), + [$person->getId()], + [Types::INTEGER] + ); + + if (null !== $startDate) { + $query->addWhereClause( + sprintf('doc_store.%s >= ?', $storedObjectMetadata->getColumnName('createdAt')), + [$startDate], + [Types::DATE_IMMUTABLE] + ); + } + + if (null !== $endDate) { + $query->addWhereClause( + sprintf('doc_store.%s < ?', $storedObjectMetadata->getColumnName('createdAt')), + [$endDate], + [Types::DATE_IMMUTABLE] + ); + } + + if (null !== $content) { + $query->addWhereClause( + sprintf('doc_store.%s ilike ?', $storedObjectMetadata->getColumnName('title')), + ['%' . $content . '%'], + [Types::STRING] + ); + } + + dump($query); + + return $query; + } + + /** + * @param Person $person + * @return bool + */ + public function isAllowedForPerson(Person $person): bool + { + return $this->security->isGranted(CalendarVoter::SEE, $person); + } +} From 80dfa092db2c1e51f6fa33a1f843d785edc7e0d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 31 May 2023 23:29:34 +0200 Subject: [PATCH 140/724] fixes: add tests for generation and fix some situation --- .../Service/DocGenerator/ActivityContext.php | 4 +- .../AccompanyingPeriodContext.php | 26 +- ...ccompanyingPeriodWorkEvaluationContext.php | 8 +- .../Service/DocGenerator/PersonContext.php | 23 +- .../DocGenerator/PersonContextInterface.php | 3 +- .../AccompanyingPeriodContextTest.php | 291 ++++++++++++++++++ .../DocGenerator/PersonContextTest.php | 183 ++++++++++- .../Repository/ThirdPartyRepository.php | 2 +- 8 files changed, 503 insertions(+), 37 deletions(-) create mode 100644 src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/AccompanyingPeriodContextTest.php diff --git a/src/Bundle/ChillActivityBundle/Service/DocGenerator/ActivityContext.php b/src/Bundle/ChillActivityBundle/Service/DocGenerator/ActivityContext.php index 91827267c..a20ca365b 100644 --- a/src/Bundle/ChillActivityBundle/Service/DocGenerator/ActivityContext.php +++ b/src/Bundle/ChillActivityBundle/Service/DocGenerator/ActivityContext.php @@ -206,10 +206,10 @@ class ActivityContext implements $normalized = []; foreach (['mainPerson', 'person1', 'person2'] as $k) { - $normalized[$k] = null === $data[$k] ? null : $data[$k]->getId(); + $normalized[$k] = ($data[$k] ?? null)?->getId(); } - $normalized['thirdParty'] = null === $data['thirdParty'] ? null : $data['thirdParty']->getId(); + $normalized['thirdParty'] = ($data['thirdParty'] ?? null)?->getId(); return $normalized; } diff --git a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php index 66be9aceb..0db54a47a 100644 --- a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php +++ b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php @@ -44,6 +44,7 @@ use Symfony\Contracts\Translation\TranslatorInterface; use function array_key_exists; /** + * @see AccompanyingPeriodContextTest * @template-implements DocGeneratorContextWithPublicFormInterface */ class AccompanyingPeriodContext implements @@ -116,12 +117,11 @@ class AccompanyingPeriodContext implements 'person2' => $data['person2'] ?? false, 'person2Label' => $data['person2Label'] ?? $this->translator->trans('docgen.person 2'), 'thirdParty' => $data['thirdParty'] ?? false, - 'thirdPartyLabel' => $data['thirdPartyLabel'] ?? $this->translator->trans('thirdParty'), + 'thirdPartyLabel' => $data['thirdPartyLabel'] ?? $this->translator->trans('Third party'), ]; if (array_key_exists('category', $data)) { - $r['category'] = array_key_exists('category', $data) ? - $this->documentCategoryRepository->find($data['category']) : null; + $r['category'] = $this->documentCategoryRepository->find($data['category']); } return $r; @@ -214,17 +214,15 @@ class AccompanyingPeriodContext implements } $thirdParties = array_merge( - array_filter(array_values([$entity->getRequestorThirdParty()])), - array_filter( - array_values( - array_map( - fn (Resource $r): ?ThirdParty => $r->getThirdParty(), - $entity->getResources()->filter( - static fn (Resource $r): bool => null !== $r->getThirdParty() - )->toArray() - ) + array_values(array_filter([$entity->getRequestorThirdParty()])), + array_values(array_filter( + array_map( + fn (Resource $r): ?ThirdParty => $r->getThirdParty(), + $entity->getResources()->filter( + static fn (Resource $r): bool => null !== $r->getThirdParty() + )->toArray() ) - ) + )) ); if ($options['thirdParty'] ?? false) { @@ -320,7 +318,7 @@ class AccompanyingPeriodContext implements $normalized[$k] = null !== ($data[$k] ?? null) ? $data[$k]->getId() : null; } - $normalized['thirdParty'] = null === $data['thirdParty'] ? null : $data['thirdParty']->getId(); + $normalized['thirdParty'] = ($data['thirdParty'] ?? null)?->getId(); return $normalized; } diff --git a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php index 62e13789f..ee746a034 100644 --- a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php +++ b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php @@ -117,10 +117,10 @@ class AccompanyingPeriodWorkEvaluationContext implements $this->accompanyingPeriodWorkContext->buildPublicForm($builder, $template, $entity->getAccompanyingPeriodWork()); $thirdParties = array_merge( - array_filter(array_values($entity->getAccompanyingPeriodWork()->getThirdParties()->toArray())), - array_filter(array_values([$entity->getAccompanyingPeriodWork()->getHandlingThierParty()])), - array_filter( - array_values( + array_values(array_filter($entity->getAccompanyingPeriodWork()->getThirdParties()->toArray())), + array_values(array_filter([$entity->getAccompanyingPeriodWork()->getHandlingThierParty()])), + array_values( + array_filter( array_map( fn (Resource $r): ?ThirdParty => $r->getThirdParty(), $entity->getAccompanyingPeriodWork()->getAccompanyingPeriod()->getResources()->filter( diff --git a/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php b/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php index 4d49bcfba..1ced31121 100644 --- a/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php +++ b/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php @@ -38,6 +38,7 @@ use DateTime; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; use LogicException; +use Service\DocGenerator\PersonContextTest; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\Form\Extension\Core\Type\CheckboxType; @@ -50,6 +51,9 @@ use Symfony\Contracts\Translation\TranslatorInterface; use function array_key_exists; use function count; +/** + * @see PersonContextTest + */ final class PersonContext implements PersonContextInterface { private AuthorizationHelperInterface $authorizationHelper; @@ -130,12 +134,11 @@ final class PersonContext implements PersonContextInterface 'mainPerson' => $data['mainPerson'] ?? false, 'mainPersonLabel' => $data['mainPersonLabel'] ?? $this->translator->trans('docgen.Main person'), 'thirdParty' => $data['thirdParty'] ?? false, - 'thirdPartyLabel' => $data['thirdPartyLabel'] ?? $this->translator->trans('thirdParty'), + 'thirdPartyLabel' => $data['thirdPartyLabel'] ?? $this->translator->trans('Third party'), ]; if (array_key_exists('category', $data)) { - $r['category'] = array_key_exists('category', $data) ? - $this->documentCategoryRepository->find($data['category']) : null; + $r['category'] = $this->documentCategoryRepository->find($data['category']); } return $r; @@ -177,8 +180,8 @@ final class PersonContext implements PersonContextInterface ]); $thirdParties = array_merge( - array_filter( - array_values( + array_values( + array_filter( array_map( fn (ResidentialAddress $r): ?ThirdParty => $r->getHostThirdParty(), $this @@ -187,8 +190,8 @@ final class PersonContext implements PersonContextInterface ) ) ), - array_filter( - array_values( + array_values( + array_filter( array_map( fn (PersonResource $r): ?ThirdParty => $r->getThirdParty(), $entity->getResources()->filter( @@ -223,10 +226,6 @@ final class PersonContext implements PersonContextInterface public function getData(DocGeneratorTemplate $template, $entity, array $contextGenerationData = []): array { - if (!$entity instanceof Person) { - throw new UnexpectedTypeException($entity, Person::class); - } - $data = []; $data = array_merge($data, $this->baseContextData->getData($contextGenerationData['creator'] ?? null)); $data['person'] = $this->normalizer->normalize($entity, 'docgen', [ @@ -297,7 +296,7 @@ final class PersonContext implements PersonContextInterface return [ 'title' => $data['title'] ?? '', 'scope_id' => $scope instanceof Scope ? $scope->getId() : null, - 'thirdParty' => null === $data['thirdParty'] ? null : $data['thirdParty']->getId(), + 'thirdParty' => ($data['thirdParty'] ?? null)?->getId(), ]; } diff --git a/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContextInterface.php b/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContextInterface.php index 6de8c1c50..53e241292 100644 --- a/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContextInterface.php +++ b/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContextInterface.php @@ -19,7 +19,8 @@ use Chill\PersonBundle\Entity\Person; use Symfony\Component\Form\FormBuilderInterface; /** - * @template-extends DocGeneratorContextWithPublicFormInterface + * @template-extends DocGeneratorContextWithPublicFormInterface + * @template-extends DocGeneratorContextWithAdminFormInterface */ interface PersonContextInterface extends DocGeneratorContextWithAdminFormInterface, DocGeneratorContextWithPublicFormInterface { diff --git a/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/AccompanyingPeriodContextTest.php b/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/AccompanyingPeriodContextTest.php new file mode 100644 index 000000000..f9f888999 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/AccompanyingPeriodContextTest.php @@ -0,0 +1,291 @@ +baseContextData = self::$container->get(BaseContextData::class); + $this->documentCategoryRepository = self::$container->get(DocumentCategoryRepository::class); + $this->em = self::$container->get(EntityManagerInterface::class); + $this->normalizer = self::$container->get(NormalizerInterface::class); + $this->personRender = self::$container->get(PersonRenderInterface::class); + $this->personRepository = self::$container->get(PersonRepository::class); + $this->translatableStringHelper = self::$container->get(TranslatableStringHelperInterface::class); + $this->translator = self::$container->get(TranslatorInterface::class); + $this->thirdPartyRender = self::$container->get(ThirdPartyRender::class); + $this->thirdPartyRepository = self::$container->get(ThirdPartyRepository::class); + } + + private function buildContext(): AccompanyingPeriodContext + { + return new AccompanyingPeriodContext( + $this->documentCategoryRepository, + $this->normalizer, + $this->translatableStringHelper, + $this->em, + $this->personRender, + $this->personRepository, + $this->translator, + $this->baseContextData, + $this->thirdPartyRender, + $this->thirdPartyRepository, + ); + } + + /** + * This test run the methods executed when a document is generated: + * + * - normalized data from the form in a way that they are stored in message queue; + * - denormalize the data from the message queue, + * - and get the data, as they will be transmitted to the GeneratorDriver + * + * @param array $options the options, as they are stored in the DocGeneratorTemplate (the admin form data) + * @param AccompanyingPeriod $entity The entity from which the data will be extracted + * @param array $data The data, from the public form + * @param array $expectedNormalized, how the normalized data are expected (allow to check that this data will be compliant with the storage in messenger queue) + * @param callable $assertionsOnData some test that will be executed on the normalized data + * @dataProvider provideNormalizedData + */ + public function testContextGenerationDataNormalizeDenormalizeGetData( + array $options, + AccompanyingPeriod $entity, + array $data, + array $expectedNormalized, + callable $assertionsOnData + ): void { + $context = $this->buildContext(); + $template = new DocGeneratorTemplate(); + $template->setName(["fr" =>"test"])->setContext(AccompanyingPeriodContext::class) + ->setDescription("description")->setActive(true) + ->setOptions($options); + + $normalized = $context->contextGenerationDataNormalize($template, $entity, $data); + + self::assertEquals($expectedNormalized, $normalized); + + $denormalized = $context->contextGenerationDataDenormalize($template, $entity, $normalized); + + $data = $context->getData($template, $entity, $denormalized); + + call_user_func($assertionsOnData, $data); + } + + public function provideNormalizedData(): iterable + { + self::bootKernel(); + $em = self::$container->get(EntityManagerInterface::class); + + $thirdParty = $em->createQuery("SELECT t FROM " . ThirdParty::class . " t") + ->setMaxResults(1) + ->getSingleResult(); + + if (null === $thirdParty) { + throw new \RuntimeException("No thirdparty in database"); + } + + $period = $em->createQuery("SELECT a FROM " . AccompanyingPeriod::class . " a WHERE a.step = 'CONFIRMED'") + ->setMaxResults(1) + ->getSingleResult(); + + if (null === $period) { + throw new \RuntimeException("No confirmed period in database"); + } + + $person = $em->createQuery("SELECT p FROM " . Person::class . " p") + ->setMaxResults(1) + ->getSingleResult(); + + if (null === $person) { + throw new \RuntimeException("No confirmed period in database"); + } + + yield [ + // test with only thirdParty + [ + 'mainPerson' => false, + 'mainPersonLabel' => 'person', + 'person1' => false, + 'person1Label' => 'person2', + 'person2' => false, + 'person2Label' => 'person2', + 'thirdParty' => true, + 'thirdPartyLabel' => '3party' + ], + $period, + [ + 'thirdParty' => $thirdParty + ], + [ + 'thirdParty' => $thirdParty->getId(), + 'mainPerson' => null, + 'person1' => null, + 'person2' => null, + ], + function (array $data) use ($thirdParty, $period) { + self::assertArrayHasKey('thirdParty', $data); + self::assertEquals($thirdParty->getId(), $data['thirdParty']['id']); + + self::assertArrayHasKey('course', $data); + self::assertEquals($period->getId(), $data['course']['id']); + }, + ]; + + yield [ + // test with only mainPerson + [ + 'mainPerson' => true, + 'mainPersonLabel' => 'person', + 'person1' => false, + 'person1Label' => 'person2', + 'person2' => false, + 'person2Label' => 'person2', + 'thirdParty' => false, + 'thirdPartyLabel' => '3party' + ], + $period, + [ + 'mainPerson' => $person, + ], + [ + 'thirdParty' => null, + 'mainPerson' => $person->getId(), + 'person1' => null, + 'person2' => null, + ], + function (array $data) use ($person, $period) { + self::assertArrayHasKey('mainPerson', $data); + self::assertEquals($person->getId(), $data['mainPerson']['id']); + + self::assertArrayHasKey('course', $data); + self::assertEquals($period->getId(), $data['course']['id']); + }, + ]; + + yield [ + // test with every options activated + [ + 'mainPerson' => true, + 'mainPersonLabel' => 'person', + 'person1' => true, + 'person1Label' => 'person2', + 'person2' => true, + 'person2Label' => 'person2', + 'thirdParty' => true, + 'thirdPartyLabel' => '3party' + ], + $period, + [ + 'mainPerson' => $person, + 'person1' => $person, + 'person2' => $person, + 'thirdParty' => $thirdParty, + ], + [ + 'thirdParty' => $thirdParty->getId(), + 'mainPerson' => $person->getId(), + 'person1' => $person->getId(), + 'person2' => $person->getId(), + ], + function (array $data) use ($person, $thirdParty, $period) { + self::assertArrayHasKey('mainPerson', $data); + self::assertEquals($person->getId(), $data['mainPerson']['id']); + + self::assertArrayHasKey('person1', $data); + self::assertEquals($person->getId(), $data['person1']['id']); + + self::assertArrayHasKey('person2', $data); + self::assertEquals($person->getId(), $data['person2']['id']); + + self::assertArrayHasKey('thirdParty', $data); + self::assertEquals($thirdParty->getId(), $data['thirdParty']['id']); + + self::assertArrayHasKey('course', $data); + self::assertEquals($period->getId(), $data['course']['id']); + }, + ]; + + yield [ + // test with any option activated + [ + 'mainPerson' => false, + 'mainPersonLabel' => 'person', + 'person1' => false, + 'person1Label' => 'person2', + 'person2' => false, + 'person2Label' => 'person2', + 'thirdParty' => false, + 'thirdPartyLabel' => '3party' + ], + $period, + [ + 'mainPerson' => null, + 'person1' => null, + 'person2' => null, + 'thirdParty' => null, + ], + [ + 'thirdParty' => null, + 'mainPerson' => null, + 'person1' => null, + 'person2' => null, + ], + function (array $data) use ($period) { + self::assertArrayHasKey('course', $data); + self::assertEquals($period->getId(), $data['course']['id']); + }, + ]; + } +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextTest.php b/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextTest.php index d0138dc30..71fce8c92 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextTest.php @@ -18,20 +18,30 @@ use Chill\DocStoreBundle\Entity\PersonDocument; use Chill\DocStoreBundle\Entity\StoredObject; use Chill\DocStoreBundle\Repository\DocumentCategoryRepository; use Chill\DocStoreBundle\Security\Authorization\PersonDocumentVoter; +use Chill\MainBundle\Entity\Address; use Chill\MainBundle\Entity\Center; +use Chill\MainBundle\Entity\PostalCode; use Chill\MainBundle\Entity\Scope; use Chill\MainBundle\Entity\User; use Chill\MainBundle\Form\Type\ScopePickerType; +use Chill\MainBundle\Repository\ScopeRepositoryInterface; use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface; use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface; use Chill\MainBundle\Templating\TranslatableStringHelperInterface; +use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\Person; +use Chill\PersonBundle\Repository\ResidentialAddressRepository; +use Chill\PersonBundle\Service\DocGenerator\AccompanyingPeriodContext; use Chill\PersonBundle\Service\DocGenerator\PersonContext; +use Chill\ThirdPartyBundle\Entity\ThirdParty; +use Chill\ThirdPartyBundle\Repository\ThirdPartyRepository; +use Chill\ThirdPartyBundle\Templating\Entity\ThirdPartyRender; use Doctrine\ORM\EntityManagerInterface; use PHPUnit\Framework\TestCase; use Prophecy\Argument; use Prophecy\Exception\Prediction\FailedPredictionException; use Prophecy\PhpUnit\ProphecyTrait; +use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\Form\Extension\Core\Type\TextType; @@ -46,10 +56,142 @@ use function count; * @internal * @coversNothing */ -final class PersonContextTest extends TestCase +final class PersonContextTest extends KernelTestCase { use ProphecyTrait; + /** + * This test run the methods executed when a document is generated: + * + * - normalized data from the form in a way that they are stored in message queue; + * - denormalize the data from the message queue, + * - and get the data, as they will be transmitted to the GeneratorDriver + * + * @param array $options the options, as they are stored in the DocGeneratorTemplate (the admin form data) + * @param Person $entity The entity from which the data will be extracted + * @param array $data The data, from the public form + * @param array $expectedNormalized, how the normalized data are expected (allow to check that this data will be compliant with the storage in messenger queue) + * @param callable $assertionsOnData some test that will be executed on the normalized data + * @dataProvider provideNormalizedData + */ + public function testContextGenerationDataNormalizeDenormalizeGetData( + array $options, + Person $entity, + array $data, + array $expectedNormalized, + callable $assertionsOnData + ): void { + // we boot kernel only for this test + self::bootKernel(); + + // we create a PersonContext with the minimal dependency injection needed (relying on + // prophecy for other dependencies) + $context = $this->buildPersonContext( + null, + self::$container->get(BaseContextData::class), + self::$container->get(CenterResolverManagerInterface::class), + self::$container->get(DocumentCategoryRepository::class), + self::$container->get(EntityManagerInterface::class), + self::$container->get(NormalizerInterface::class), + (new ParameterBag(['chill_main' => ['acl' => ['form_show_scopes' => false]]])), + null, + self::$container->get(Security::class), + null, + null, + null, + self::$container->get(ThirdPartyRepository::class) + ); + $template = new DocGeneratorTemplate(); + $template->setName(["fr" =>"test"])->setContext(AccompanyingPeriodContext::class) + ->setDescription("description")->setActive(true) + ->setOptions($options); + + $normalized = $context->contextGenerationDataNormalize($template, $entity, $data); + + self::assertEquals($expectedNormalized, $normalized); + + $denormalized = $context->contextGenerationDataDenormalize($template, $entity, $normalized); + + $data = $context->getData($template, $entity, $denormalized); + + call_user_func($assertionsOnData, $data); + } + + public function provideNormalizedData(): iterable + { + self::bootKernel(); + $em = self::$container->get(EntityManagerInterface::class); + + $thirdParty = $em->createQuery("SELECT t FROM " . ThirdParty::class . " t") + ->setMaxResults(1) + ->getSingleResult(); + + if (null === $thirdParty) { + throw new \RuntimeException("No thirdparty in database"); + } + + $person = $em->createQuery("SELECT p FROM " . Person::class . " p") + ->setMaxResults(1) + ->getSingleResult(); + + if (null === $person) { + throw new \RuntimeException("No confirmed period in database"); + } + + $category = self::$container->get(DocumentCategoryRepository::class) + ->findAll()[0]; + + if (null === $category) { + throw new \RuntimeException("no document category in database"); + } + + yield [ + [ + 'thirdParty' => true, + 'thirdPartyLabel' => '3party', + 'category' => $category, + ], + $person, + [ + 'title' => 'test', + 'thirdParty' => $thirdParty, + ], + [ + 'thirdParty' => $thirdParty->getId(), + 'title' => 'test', + 'scope_id' => null, + ], + function ($data) use ($person, $thirdParty) { + self::assertArrayHasKey('person', $data); + self::assertEquals($person->getId(), $data['person']['id']); + + self::assertArrayHasKey('thirdParty', $data); + self::assertEquals($thirdParty->getId(), $data['thirdParty']['id']); + } + ]; + + yield [ + [ + 'thirdParty' => false, + 'thirdPartyLabel' => '3party', + 'category' => $category, + ], + $person, + [ + 'title' => 'test', + ], + [ + 'title' => 'test', + 'scope_id' => null, + 'thirdParty' => null, + ], + function ($data) use ($person, $thirdParty) { + self::assertArrayHasKey('person', $data); + self::assertEquals($person->getId(), $data['person']['id']); + } + ]; + } + /** * Test that the build person context works in the case when 'form_show_scope' is false. */ @@ -208,9 +350,13 @@ final class PersonContextTest extends TestCase ?EntityManagerInterface $em = null, ?NormalizerInterface $normalizer = null, ?ParameterBagInterface $parameterBag = null, + ?ScopeRepositoryInterface $scopeRepository = null, ?Security $security = null, ?TranslatorInterface $translator = null, - ?TranslatableStringHelperInterface $translatableStringHelper = null + ?TranslatableStringHelperInterface $translatableStringHelper = null, + ?ThirdPartyRender $thirdPartyRender = null, + ?ThirdPartyRepository $thirdPartyRepository = null, + ?ResidentialAddressRepository $residentialAddressRepository = null ): PersonContext { if (null === $authorizationHelper) { $authorizationHelper = $this->prophesize(AuthorizationHelperInterface::class)->reveal(); @@ -250,6 +396,11 @@ final class PersonContextTest extends TestCase $parameterBag = new ParameterBag(['chill_main' => ['acl' => ['form_show_scopes' => true]]]); } + if (null === $scopeRepository) { + $scopeRepository = $this->prophesize(ScopeRepositoryInterface::class); + $scopeRepository = $scopeRepository->reveal(); + } + if (null === $security) { $security = $this->prophesize(Security::class); $security->getUser()->willReturn(new User()); @@ -267,6 +418,28 @@ final class PersonContextTest extends TestCase $translatableStringHelper = $translatableStringHelper->reveal(); } + if (null === $thirdPartyRender) { + $thirdPartyRender = $this->prophesize(ThirdPartyRender::class); + $thirdPartyRender = $thirdPartyRender->reveal(); + } + + if (null === $thirdPartyRepository) { + $thirdPartyRepository = $this->prophesize(ThirdPartyRepository::class); + $thirdPartyRepository = $thirdPartyRepository->reveal(); + } + + if (null === $residentialAddressRepository) { + $residentialAddressRepository = $this->prophesize(ResidentialAddressRepository::class); + $residentialAddressRepository->findCurrentResidentialAddressByPerson(Argument::type(Person::class), Argument::any()) + ->willReturn([ + (new Person\ResidentialAddress()) + ->setAddress((new Address()) + ->setStreet('test street') + ->setPostcode(new PostalCode())) + ]); + $residentialAddressRepository = $residentialAddressRepository->reveal(); + } + return new PersonContext( $authorizationHelper, $baseContextData, @@ -275,9 +448,13 @@ final class PersonContextTest extends TestCase $em, $normalizer, $parameterBag, + $scopeRepository, $security, $translator, - $translatableStringHelper + $translatableStringHelper, + $thirdPartyRender, + $thirdPartyRepository, + $residentialAddressRepository ); } } diff --git a/src/Bundle/ChillThirdPartyBundle/Repository/ThirdPartyRepository.php b/src/Bundle/ChillThirdPartyBundle/Repository/ThirdPartyRepository.php index 76e15ef17..f9893b9d9 100644 --- a/src/Bundle/ChillThirdPartyBundle/Repository/ThirdPartyRepository.php +++ b/src/Bundle/ChillThirdPartyBundle/Repository/ThirdPartyRepository.php @@ -21,7 +21,7 @@ use DomainException; use function array_key_exists; -final class ThirdPartyRepository implements ObjectRepository +class ThirdPartyRepository implements ObjectRepository { private EntityRepository $repository; From 9c109d2efdbe78d99d813b3a35abf9c532cf8fa9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 31 May 2023 23:47:02 +0200 Subject: [PATCH 141/724] DX: use array spred instead of array_merge --- .../AccompanyingPeriodContext.php | 19 ++++------ ...ccompanyingPeriodWorkEvaluationContext.php | 20 ++++------ .../Service/DocGenerator/PersonContext.php | 37 +++++++++---------- 3 files changed, 33 insertions(+), 43 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php index 0db54a47a..4f6235930 100644 --- a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php +++ b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php @@ -213,17 +213,14 @@ class AccompanyingPeriodContext implements } } - $thirdParties = array_merge( - array_values(array_filter([$entity->getRequestorThirdParty()])), - array_values(array_filter( - array_map( - fn (Resource $r): ?ThirdParty => $r->getThirdParty(), - $entity->getResources()->filter( - static fn (Resource $r): bool => null !== $r->getThirdParty() - )->toArray() - ) - )) - ); + $thirdParties = [...array_values(array_filter([$entity->getRequestorThirdParty()])), ...array_values(array_filter( + array_map( + fn (Resource $r): ?ThirdParty => $r->getThirdParty(), + $entity->getResources()->filter( + static fn (Resource $r): bool => null !== $r->getThirdParty() + )->toArray() + ) + ))]; if ($options['thirdParty'] ?? false) { $builder->add('thirdParty', EntityType::class, [ diff --git a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php index ee746a034..f58788120 100644 --- a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php +++ b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php @@ -116,20 +116,16 @@ class AccompanyingPeriodWorkEvaluationContext implements { $this->accompanyingPeriodWorkContext->buildPublicForm($builder, $template, $entity->getAccompanyingPeriodWork()); - $thirdParties = array_merge( - array_values(array_filter($entity->getAccompanyingPeriodWork()->getThirdParties()->toArray())), - array_values(array_filter([$entity->getAccompanyingPeriodWork()->getHandlingThierParty()])), - array_values( - array_filter( - array_map( - fn (Resource $r): ?ThirdParty => $r->getThirdParty(), - $entity->getAccompanyingPeriodWork()->getAccompanyingPeriod()->getResources()->filter( - static fn (Resource $r): bool => null !== $r->getThirdParty() - )->toArray() - ) + $thirdParties = [...array_values(array_filter($entity->getAccompanyingPeriodWork()->getThirdParties()->toArray())), ...array_values(array_filter([$entity->getAccompanyingPeriodWork()->getHandlingThierParty()])), ...array_values( + array_filter( + array_map( + fn (Resource $r): ?ThirdParty => $r->getThirdParty(), + $entity->getAccompanyingPeriodWork()->getAccompanyingPeriod()->getResources()->filter( + static fn (Resource $r): bool => null !== $r->getThirdParty() + )->toArray() ) ) - ); + )]; $options = $template->getOptions(); if ($options['thirdParty'] ?? false) { diff --git a/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php b/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php index 1ced31121..9d7f1cdd5 100644 --- a/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php +++ b/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php @@ -179,28 +179,25 @@ final class PersonContext implements PersonContextInterface 'data' => $this->translatableStringHelper->localize($template->getName()), ]); - $thirdParties = array_merge( - array_values( - array_filter( - array_map( - fn (ResidentialAddress $r): ?ThirdParty => $r->getHostThirdParty(), - $this - ->residentialAddressRepository - ->findCurrentResidentialAddressByPerson($entity) - ) - ) - ), - array_values( - array_filter( - array_map( - fn (PersonResource $r): ?ThirdParty => $r->getThirdParty(), - $entity->getResources()->filter( - static fn (PersonResource $r): bool => null !== $r->getThirdParty() - )->toArray() - ) + $thirdParties = [...array_values( + array_filter( + array_map( + fn (ResidentialAddress $r): ?ThirdParty => $r->getHostThirdParty(), + $this + ->residentialAddressRepository + ->findCurrentResidentialAddressByPerson($entity) ) ) - ); + ), ...array_values( + array_filter( + array_map( + fn (PersonResource $r): ?ThirdParty => $r->getThirdParty(), + $entity->getResources()->filter( + static fn (PersonResource $r): bool => null !== $r->getThirdParty() + )->toArray() + ) + ) + )]; if ($options['thirdParty'] ?? false) { $builder->add('thirdParty', EntityType::class, [ From 07ff425bfcdc26dc512cadd999e7bcf8fc2d5893 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 1 Jun 2023 09:39:40 +0200 Subject: [PATCH 142/724] initialize .changie and backup previous changelog --- .changes/header.tpl.md | 6 + .changes/unreleased/.gitkeep | 0 .changes/v2.0.0.md | 677 +++++++++++++++++++++++++++++++++++ .changie.yaml | 31 ++ CHANGELOG.md | 18 +- 5 files changed, 723 insertions(+), 9 deletions(-) create mode 100644 .changes/header.tpl.md create mode 100644 .changes/unreleased/.gitkeep create mode 100644 .changes/v2.0.0.md create mode 100644 .changie.yaml diff --git a/.changes/header.tpl.md b/.changes/header.tpl.md new file mode 100644 index 000000000..df8faa7b2 --- /dev/null +++ b/.changes/header.tpl.md @@ -0,0 +1,6 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html), +and is generated by [Changie](https://github.com/miniscruff/changie). diff --git a/.changes/unreleased/.gitkeep b/.changes/unreleased/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/.changes/v2.0.0.md b/.changes/v2.0.0.md new file mode 100644 index 000000000..8d70ecba6 --- /dev/null +++ b/.changes/v2.0.0.md @@ -0,0 +1,677 @@ +## 2.0.0 + +* this is a release to relaunch our proceess of release with semantic versioning + +## Test releases + +### 2.0.0-beta3 + +* [person][export] Fixed: rename the alias for `accompanying_period` to `acp` in filter associated with person +* [activity][export] Feature: improve label for aliases in "Filter by activity type" +* [activity][export] DX/Feature: use of an `ActivityTypeRepositoryInterface` instead of the old-style EntityRepository +* [person][export] Fixed: some inconsistency with date filter on accompanying courses +* [person][export] Fixed: use left join for related entities in accompanying course aggregators +* [workflow] Feature: allow user to copy and send manually the access link for the workflow +* [workflow] Feature: show the email addresses that received an access link for the workflow +### 2.0.0-beta2 + +* [workflow]: Fixed: the notification is sent when the user is added to the first step. +* [budget] Feature: allow to desactivate some charges and resources, adding an `active` key in the configuration +* [person] Feature: on Evaluation, allow to configure an URL from the admin + +### 2022-06 + +* [workflow]: added pagination to workflow list page +* [homepage_widget]: null error on tasks widget fixed +* [person-thirdparty]: fix quick-add of names that consist of multiple parts (eg. De Vlieger) within onthefly modal person/thirdparty +* [search]: Order of birthdate fields changed in advanced search to avoid confusion. +* [workflow]: Constraint added to workflow (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/675) +* [social_action]: only show active objectives (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/625) +* [household]: Reposition and cut button for enfant hors menage have been deleted (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/620) +* [admin]: Add crud for composition type in admin (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/611) +* [social_action]: only show active objectives (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/625) + +## Test releases + +### 2022-05-30 + +* fix creating a new AccompanyingPeriodWorkEvaluationDocument when replacing the document (the workflow was lost) + +### 2022-05-27 + +* [storedobject] add title field on StoredObject entity + use it in activity documents (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/604) +* [main] add a "read more..." on comment embeddable when overflown (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/604) +* [person] add closing motive to closed acc course (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/603) +* [person] household filiation: fetch person info when unfolding person (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/586) +* [admin] repair edit of social action in the admin (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/601) +* [admin]: add select2 to Goal form type entity fields (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/702) +* [main] allow hide permissions group list menu (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/577) +* [main] allow hide change user password menu (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/577) +* [main] filter user jobs by active jobs (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/577) +* [main] add civility to User (entity, migration and form type) (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/577) +* [admin] refactorisation of the admin section: reorganisation of the menu, translations, form types, new entities (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/592) +* [admin] add admin section for languages and countries (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/596) +* [activity] activity admin: translations + remove label field for comment on admin activity type (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/587) +* [main] admin user_job: improvements (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/588) +* [address] can add extra address info even if noAddress (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/576) + + +### 2022-05-06 + +* [person] add civility when creating a person (with the on-the-fly component or in the php form) (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/557) +* [person] add address when creating a person (with the on-the-fly component or in the php form) (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/557) +* [person] add household creation API point (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/557) + +### 2021-04-29 + +* [person] prevent circular references in PersonDocGenNormalizer (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/527) +* [person] add maritalStatusComment to PersonDocGenNormalizer (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/582) +* Load relationships without gender in french fixtures +* Add command to remove old draft accompanying periods +* [parcours]: If users assings him/herself as referrer and job is not null. Update parcours job (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/578) + +### 2021-04-28 + +* [address] fix bug when editing address: update location and addressreferenceId + better update of the map in edition (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/593) +* [main] avoid address reference search on undefined post code (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/561) +* [person] prevent duplicate relationship in filiation/household graph (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/560) +* [Documents] Validate storedObject and allow for null data (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/565) +* [parcours]: Comments can be unpinned + edit/delete for all users that are allowed to edit parcours (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/566) + +### 2021-04-26 + +* [Datepickers] datepickers fixed when using keyboard to enter date (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/545) +* [social_action] Display 'agents traitants' in parcours resumé and social action list (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/568) +* [Person_search] Closed parcours shown within an accordeon that can be opened/closed (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/574) + +### 2021-04-24 + +* [notification email on course designation] allow raw string in email content generation +* [Accompanying period work] list evaluations associated to a work by startDate, and then by id, from the most recent to older +* [Documents] Change wording 'créer' to 'enregistrer' (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/634) +* [Parcours]: The number of 'mes parcours' displayed (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/572) +* [Hompage_widget]: Renaming of tabs and removal of social actions tab (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/570) +* [activity]: Ignore thirdparties when creating a social action via an activity (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/573) +* [parcours]: change wording of warning message and button when user is not associated to a household yet (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/590#note_918370943) +* [Accompanying period work evaluations] list documents associated to a work by creation date, and then by id, from the most recent to older +* [Course comment] add validationConstraint NotNull and NotBlank on comment content, to avoid sql error +* [Notifications] delay the sending of notificaiton to kernel.terminate +* [Notifications / Period user change] fix the sending of notification when user changes +* [Activity form] invert 'incoming' and 'receiving' in Activity form +* [Activity form] keep the same order for 'attendee' field in new and edit form +* [list with period] use "sameas" test operator to introduce requestor in list +* [notification email on course designation] allow raw string in email content generation +* [Accompanying period work] list evaluations associated to a work by startDate, and then by id, from the most recent to older +* [evaluation_document] changing date to datetime in order to display the time at which document was created (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/569) + + +### 2021-04-13 + +* [person] household address: add a form for editing the validFrom date (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/541) +* [person] householdmemberseditor: fix composition type bug in select form (vuejs) (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/543) +* [docgen] add more persons choices in docgen for course: amongst requestor (if person), resources of course (if person), and PersonResource (if person); +* [docgen] add a new context with a list of activities in course +* [docgen] add a comment in budget lines +* [notifications] allow to send a notification to an email address. The address receive an access link +* [adresses] add constraints in database to avoid errors later: postcode not null, and validfrom <= validto +* [accompanying work editor] add a label on document title input + +### 2021-04-07 + +* notification list: move action buttons outside of the toggle +* fix detecting of non-read notification +* filter users which are disabled in search user api +* order query for location and add pagination in list +* allow every person which has part for a workflow to see the workflow page +* able to see the workflow if the evaluation document has been deleted +* hardcode the list of supported mime types for edition with collabora +* list of accompanying course: allow to see the pinned comment in list_item + +### 2021-04-06 + +* [main] notification toggle read: correct js syntax for compilation in production (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/548) +* [parcours] Display of interlocuteurs changed to flex-table in parcours edit page to prevent cut-off of information (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/535) +* [activity] espace entre les boutons pour supprimer les documents + + +### continuous release in February and March + +* Creation of PickCivilityType, and implementation in PersonType and ThirdpartyType +* [person] Accompanying course evaluation documents: disable the WOPI edit link if mimetype not supported and if no keyInfos +(https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/585) +* [activity] display error messages above the form in creating a new location (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/481) +* [activity] show required field in activity edit/new by an asterix in the vuejs fields (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/494) +* [ACL] fix allow to see the course, event if the scope'course does not contains the scope's user +* [search] enforce limit of results for fetching rsults by search api https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/576 +* [activity] Fix delete button for document (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/554) +* [activity] Add return path the document generation (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/553) +* [person] add person ressource to person docgen normaliser (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/517) +* [person] AccompanyingCourseWorkEdit: fix deleting evaluation documents (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/546) +* [person] AccompanyingCourseWorkEdit: download existing documents (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/512) +* [person] AccompanyingCourseWorkEdit: replace document by a new one (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/511) +* [person] AccompanyingPeriodWork: add referrers to work, add doctrine event listener to add logged user to referrers collection and display a referrers list in work list (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/502) +* [person] AccompanyingPeriodWorkEvaluation: fix circular reference when serialising (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/495) +* [person] order accompanying period by opening date in search persons, person and household period lists (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/493) +* [parcours] autosave of the pinned comment for draft accompanying course (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/477) +* [main] filter user job in undispatch acc period to assign (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/472) +* [main] filter user job in undispatch acc period to assign (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/472) +* [person] Add url in accompanying period work evaluations entity and form (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/476) +* [person] Add document generation in admin and in person/{id}/document (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/464) +* [activity] do not override location if already exist (when validating new activity) (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/470) +* [parcours] Toggle emergency/intensity only by referrer (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/442) +* [docstore] Add an API entrypoint for StoredObject (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/466) +* [person] Add the possibility of uploading existing documents to AccPeriodWorkEvaluationDocument (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/466) +* [person] Add title to AccPeriodWorkEvaluationDocument (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/466) +* [person] Order social issues by the field "ordering" (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/388) +* [Person/Household list] when listing other simultaneous members of an household, exclude the members on person, not on members (avoid to show two membersship with the same person) +* [draft periods] add a delete button (if acl granted) on each draft period listed on draft period page (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/463) +* [Person] Display suffixText in RenderPerson, PersonText.vue, RenderPersonBox.vue (was made for displaying "enfant confie") (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/441) +* [budget]: budget enabled for persons and households (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/469) +* [person] residential address: show residential address or info in PersonRenderBox, refactor Residential Address (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/439) +* [thirdparty] Add a contact to a thirdparty from within onTheFly (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/345) +* [documents] Improve flex-table item-col placement when long buttons and long metadata +* [thirdparty] Fix display of multiple contact badges so they wrap onto next line (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/482) +* [confidential] Fix position of toggle button so it does not cover text nor fall outside of box (no issue) +* [parcours] Fix edit of both thirdparty and contact name (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/474) +* [template] do not list inactive templates (for doc generator) +* [household] bugfix if position of member is null, renderbox no longer throws an error (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/480) +* [parcours] location cannot be removed if linked to a user (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/478) +* [person] email added to twig personRenderbox (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/490) +* [activity] Only youngest descendant is kept for social issues and actions (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/471) +* [person] Add link to current household in person banner (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/484) +* [address] person badge in address history changed to open OnTheFly with all person info (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/489) +* [person] Change 'personne' with 'usager' and '&' with 'ET' (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/499) +* [thirdparty] Add parameter condition to display centers or not (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/500) +* [phonenumber] Remove placeholder in phonenumber field (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/496) +* [person_resource] separate create page created to avoid confusion (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/504) +* [contact] add contact button color changed plus the pipe at the side removed (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/506) +* [thirdparty] For contacts show current civility/profession in edit form + fix saving of edited information (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/491) +* [household] create-edit household composition placed in separate page to avoid confusion (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/505) +* [blur] Improved positioning of toggle icon (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/486) +* [thirdparty] add firstname field to thirdparty 'child' or 'contact' types (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/508) +* [household] create-edit household composition placed in separate page to avoid confusion (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/505) +* [blur] Improved positioning of toggle icon (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/486) +* [parcours] List of parcours for a specific user so they can be reassigned in case of absence (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/509) +* [thirdparty] Thirdparty view page, english text translated (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/534) +* [social_action] Translation changed in evaluation section (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/512) +* [filiation] Possible to add person (or create onthefly) to add to filiation graph + add relation (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/519) +* [household] Within parcours listing page of household add create button (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/560) +* [person_resource] bugfix when adding thirdparty or freetext resource + prevent personOwner themselves to be added. (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/526) +* [aside_activity] style correction + sticky-form create button (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/529) +* [budget] order within the menu adjusted (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/592) +* [onthefly] fix create person. Bug was noticed in filiation (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/591) +* [parcours] Create document buttons made sticky (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/532) +* [person] Trailing guillemet removed (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/530) +* [notification] Display of social action within workflow notification set to display block (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/537) +* [onthefly] trim trailing whitespace in email of person and thirdparty (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/542) + +* [action] Only youngest descendant is kept for social issues and actions (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/471) +## Test releases + +### test release 2022-02-21 + +* [notifications] Word 'un' changed to number '1' for notifications in user menu (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/483) +* [documents] 'gabarit' changed to 'modèle' (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/405) +* [person_resources] Menu name and order changed (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/460) +* workflow: fix sending notifications +* [thirdparty] Extend the thirdparty search to thirdparty children (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/448) +* [person]: AddPersons: allow creation of person or thirdparty only (no users) (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/422) +* [person]: AddPersons: allow creation of person or thirdparty depending on allowed types (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/422) +* [person]: AddPersons: add suggestion of name when creating new person or thirdparty (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/422) +* [main] Address: fix small bug: when modifying an address without street (isNoAddress), also check errors if street is an empty string as back-end change null value to empty string for street (and streetNumber) +* [main] Address: stronger client-side validation of addresses (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/449) +* [person] accompanying course: filter suggested entities by open participations (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/415) +[activity] can click through the cross icon for removing person in concerned group (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/476) +[activity] correct associated persons by considering only open participations (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/476) +* [person_resources]: Renderboxes used to display person/thirdparty info (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/465) +* [Household]: Add end date in HouseholdMember form for 'enfant hors menage' (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/434) +* [homepage_widget]: If no sender then display as 'notification automatique' (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/435) +* [parcours]: Order social activities and only display most recent three in parcours resumé (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/481) +* [3party]: 3party: redirect to parent when contact (child) is opened in view page +* [parcours / addresses]: launch an event when a person change address (either through changing household or because the household is associated to a new address). If the person is localising a course, the course location go back to a temporarily address. +* [thirdparty]: address/phonenumber/email/fonction displayed in thirdpartyrenderbox (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/401) +* [thirdparty_contact]: in search results the 'qualité' is displayed (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/465) +* [bug]: fix confidential toggle of address in thirdpartyrenderbox (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/460) + + + +### test release 2022-02-14 + +* AddPersons: remove ul-li html tags from AddPersons (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/419) +* [doc-generator] do not set required fields for mainPerson, person1, person2 (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement#456) +* [doc-generation] add age and obele in the mainPerson, person1 and person2 list + add obele in person renderString if addAge (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/370) +* [person] accompanying course work: fix on-the-fly update of thirdParty +* fix normalisation of accompanying course requestor api (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/378) +* [person] add a returnPath when clicking on some Person or ThirdParty badge (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/427) +* [person] accompanying course work: fix on-the-fly update of thirdParty +* [on-the-fly] close modal only after validation +* [person] correct thirdparty PATCH url + add email and altnames in AddPerson and serializer (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/433) +* change order for accompanying course work list +* [parcours]: Mes parcours brouillon added to user menu (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/440) +* [Documents]: List view adapted to display more information (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/414) +* [person]: style fix in parcours listing per person. (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/432) +* [parcours]: Only the referrer can toggle the intensity of the parcours (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/442) +* [household]: display address of current household (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/415) +* ajoute un ordre dans les localisation (api) +* [pick entity]: fix translations in modal (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/419) +* [homepage_widget]: fix translation on emergency badge (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/440) +* [person]: create person and household added to button dropdown (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/454) +* display full address in address.text in normalization. Adapt AddressRenderBox +* [address]: Correction residential address 'depuis le' (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/459) +* [Documents]: List view adapted to display more information (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/414) +* [Thirdparty_contact]: address blurred if confidential in view page (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/450) +* [thirdparty] Add a contact to a thirdparty from within onTheFly (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/345) + + +### test release 2021-02-01 + +* renommer "dossier numéro" en "parcours numéro" dans les résultats de recherche +* renomme date de début en date d'ouverture dans le formulaire parcours +* [homepage widget] improve content tables, improve counter pluralization with style on number +* [notification lists] add comments counter information +* [workflows] fix popover header with previous transition +* [parcours]: validation + message for closing parcours adjusted. +* [household]: household composition double edit button replaced by a delete action (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/426) +[fast_actions] improve fast-actions buttons override mechanism, fix https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/413 +[homepage widget] add vue homepage_widget with asynchone loading, give a global view resume of the user concerned actions, notifications, etc. +* [person]: Comment on marital status is possible even if marital status is not defined (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/421) +* [parcours]: In the list of person results the requestor is not displayed if defined as anonymous (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/424) +* [bugfix]: modal closes and newly created person/thirdparty is selected when multiple persons/thirdparties are created through the modal (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/429) +* [person_resource]: Onthefly button added to view person/thirdparty and badge differentiation for a contact-thirdparty (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/428) +* [workflow][notification] improve how notifications and workflows are 'attached' to entities: contextual list, counter, buttons and vue modal +* [AddAddress] disable multiselect search, and rely only on most pertinent Cities and Street computed backend +* [fast_actions] improve fast-actions buttons override mechanism, fix https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/413 +* [homepage widget] add vue homepage_widget with asynchone loading, give a global view resume of the user concerned actions, notifications, etc. +* [thirdparty] Add a contact to a thirdparty from within onTheFly (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/345) +* [homepage widget] add vue homepage_widget with asynchone loading, give a global view resume of the user concerned actions, notifications, etc. + + +### test release 2021-01-31 + +* [person] accompanying course: optimisation: do not fetch some resources for the banner (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/409) +* [person] accompanying course: close modal when edit participation (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/420) +* [person] accompanying course: treat validation error when editing on-the-fly entities (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/420) +* [activity] show activity attendee (présence) in the activity list (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/412) +* [activity] admin: change validation rule for social action visible field (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/413) +* [parcours]: component added to change the opening date of a parcours (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/411) +* [search]: listing of parcours display changed (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/410) +* [user]: page with accompanying periods to which is user is referent (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/408) +* [person] age added to renderstring + renderbox/ vue component created to display person text (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/389) +* [household member editor] allow to push to existing household + + +### test release 2021-01-28 + +* [person] improve filiations vis graph: disable physics, use chill colors for persons-households-course, increase label of relations, remove labels on household arrows and other improvements (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/286, https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/362) +* [activity] Order activity by date and by id (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/364) +* [main] increase length of 4 Address fields (change to TEXT, no size limits) (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/277) +* [main] Add confidential option for address, in edit and view (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/165) +* [person] name suggestions within create person form when person is created departing from a search input (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/377) +* [person] Add residential address entity, form and list for each person +* [aside_activity]: dynamicUserPickerType used (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/399) +* dispatching list + + +### test release 2021-01-26 + +* [parcours] comments truncated if too long + link added (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/406) +* [person]: possibility to add person resources (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/382) +* [person ressources]: module added + + +### test release 2022-01-24 + +* [person] name suggestions within create person form when person is created departing from a search input (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/377) +* [notification: formulaire création] descend la box avec la description dans le bas du formulaire +* [notification for activity]: fix link to activity +* [notification] add "URGENT" before accompanying course with emergency = true +* [notification] add a "read more" button on system notification +* [notification] add `[Chill]` in the subject of each notification, automatically +* [notification] add a counter for notification in activity list and accompanying period list, and search results +* [parcours] bugfix if deathdate is not defined (eg. for a thirdparty) parcours is still displayed. Gave error before. +* [workflow] add breadcrumb to show steps +* [popover] add popover html popup mechanism (used by workflow breadcrumb) +* [templates] improve updatedBy macro in item metadatas +* [parcours]: bug fix when comment is pinned all other comments remain in the collection (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/385) +* [workflow] + * add My workflow section with my opened subscriptions + * apply workflow on documents, accompanyingCourseWork and Evaluations +* [wopi-link] a new vue component allow to open wopi link in a fullscreen chill-themed modal + +### test release 2022-01-19 +* vuejs: add dead information on all on-the-fly person render boxes, in vis graph and other templates (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/271) +* [thirdparty] fix bug in 3rd party view: types was replaced by thirdPartyTypes +* [main] location form type: fix unmapped address field (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/246) +* [activity] fix wrong import of js assets for adding and viewing documents in activity (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/83 & https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/176) +* [person]: space added between deathdate and age in twig renderbox (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/380) +* [forms] dynamic picker types for user/person/thirdparty types created (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/386) + +### test release 2022-01-17 + +* [main] Add editableByUser field to locationType entity, adapt the admin template and add this condition in the location-type endpoint (see https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/297) +* [main] Add mainLocation field to User entity and add it in user form type +* rewrite page which allow to select activity +* [main] Add mainLocation field to User entity and add it in user form type +* [course list in person context] show full username/label for ref +* [accompanying period work] remove the possibility to generate document from an accompanying period work +* vuejs: add validation on required fields for AddPerson, Address and Location components +* vuejs: treat 422 validation errors in locations and AddPerson components +* [person]: space added between deathdate and age in twig renderbox (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/380) + +## Test releases +* vuejs: add validation on required fields for AddPerson, Address and Location components +* vuejs: treat 422 validation errors in locations and AddPerson components +* [person]: space added between deathdate and age in twig renderbox (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/380) + +### test release 2022-01-12 + +* fix thirdparty normalizer on telephone field: https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/322 + +### test release 2022-01-11 + +* vuejs: translate in French all multiselect widgets +* [address] define address lines according postal standards for France and Belgium (default) and change AddressRender, chill_entity_render_box and AddressRenderBox.vue +* [household] change translations (champs-libres/departement-de-la-vendee/accent-suivi-developpement#109) +* [household] add address i18n in household component (champs-libres/departement-de-la-vendee/accent-suivi-developpement#158) +* [household] add on the fly i18n in household component +* [household] redirect to the household page when a household is created from a person (champs-libres/departement-de-la-vendee/accent-suivi-developpement#175) +* [household] household member editor: display alert if some members have already an household (champs-libres/departement-de-la-vendee/accent-suivi-developpement#172) +* [household] household member editor: do not add in new members if the member is included in the members of household (champs-libres/departement-de-la-vendee/accent-suivi-developpement#123) +* [household] household member editor: remove markNoAddress button (champs-libres/departement-de-la-vendee/accent-suivi-developpement#109) +* [person]: ordering fields in add person (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/61) +* [person]: Add email and alt names in add person (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/61) +* [accompanyingCourse] Add a delete action and delete buttons to delete a accompanying course when step = DRAFT (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/64) +* [accompanyingCourse] Add a administrative location in the accompanying course, set the user current location as default, allow to select a location in a select field and do not allow to confirm the accompanying course if location is empty. +* [accompanyingCourse] Add the administrative location in the available variables for document generation +* AddAddress: optimize loading: wait for the user finish typing; +* UserPicker: fix bug with deprecated role +* docgen: add base context + tests +* docgen: add age for person +* [household menu] fix filiation order https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/265 +* [AddAddress]: optimize loading: wait for the user finish typing; +* [UserPicker]: fix bug with deprecated role +* [docgen]: add base context + tests +* [docgen]: add age for person +* [task]: fix dropdown menu style + fix bug in singleTaskController (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/338) +* Household: fix bug when moving person on the same day (see https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/281) +* Household: show date validFrom and validTo when moving +* address reference: add index for refid +* [accompanyingCourse_work] fix styles conflicts + fix bug with remove goal (remove goals one at a time) +* [accompanyingCourse] improve masonry on resume page, add origin +* [notification] new notification interface, can be associated to AccompanyingCourse/Period, Activities. + * List notifications, show, and comment in User section + * Notify button and contextual notification box on associated objects pages +* [accompanyingCourse] add a comment for each resource associated. A modal allow to save comment. Comment is displayed in on-the-fly show modal of the accompanyingCourse context (edit page + resume page). + +### test release 2021-12-14 + +* [asideactivity] creation of aside activity category fixed (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/262) +* [vendee/person] fix typo "situation professionelle" => "situation professionnelle" +* [main] add availableForUsers condition from locationType in the location API endpoint (champs-libres/departement-de-la-vendee/accent-suivi-developpement#248) +* [main] add the current location of the user as API point + add it in the activity location list (champs-libres/departement-de-la-vendee/accent-suivi-developpement#247) +* [activity] improve show/new/edit templates, fix SEE and SEE_DETAILS acl +* [badges] create specific badge for TMS, and make person/thirdparty badges clickable with on-the-fly modal in : + * concerned groups items (activity, calendar) + * accompanyingCourseWork lists + * accompanyingCourse lists +* [acompanyingCourse] add initial comment on Resume page +* [person] create button full width (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/330) + +### test release 2021-12-11 + +* [main] add order field to civility +* [main] change address format in case the country is France, in Address render box and address normalizer +* [person] add validator for accompanying period with a test on social issues (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/76) +* [activity] fix visibility for location +* [origin] fix origin: use correctly the translatable strings + * /!\ everyone must update the origin table. As there is only one row, execute `update chill_person_accompanying_period_origin set label = jsonb_build_object('fr', 'appel téléphonique');` +* [person] redirect bug fixed. +* [action] add an unrelated issue within action creation. +* [origin] fix origin: use correctly the translatable strings + * /!\ everyone must update the origin table. As there is only one row, execute `update chill_person_accompanying_period_origin set label = jsonb_build_object('fr', 'appel téléphonique');` +* [main] change order of civilities in civility fixtures (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/191) +* [person] set min attr in the minimum of children field (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/191) +* [person] add marital status date in person view (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/191) +* [person] show number of children + allow set number of children to null (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/191) +* [person] show acceptSMS option (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/191) +* [person] add death information in person render box in twig and vue render boxes (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/191) +* [asideactivity] creation of aside activity category fixed (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/262) +* [vendee/person] fix typo "situation professionelle" => "situation professionnelle" +* [accompanyingcourse_work] Changes in layout/behavior of edit form (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/321) +* [badge-entity] design coherency between pills badge-person and 3 kinds of badge-thirdparty +* [AddPersons] suggestions row are clickable, not only checkbox + +### test release 2021-12-06 + +* [main] address: use search API end points for getting postal code and reference address (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/316) +* [main] address: in edit mode, select the encoded values in multiselect for address reference and city (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/316) +* [person search] fix bug when using birthdate after and birthdate before +* [person search] increase pertinence when lastname begins with search pattern +* [activity/actions] Améliore la cohérence du design entre + * la page résumé d'un parcours (liste d'actions récentes et liste d'activités récentes) + * la page liste des actions + * la page liste des activités (contexte personne / contexte parcours) +* [household] field to edit wheter person is titulaire of household or not removed (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/322) +* [activity] create work if a work with same social action is not associated to the activity +* [visgraph] improve and fix bugs on vis-network relationship graph +* [bugfix] posting of birth- and deathdate through api fixed. +* [suggestions] improve suggestions lists + +### Test release 2021-11-19 - bis + +* [household] do not allow to create two addresses on the same date +* [activity] handle case when there is no social action associated to social issue +* [activity] layout for issues / actions +* [activity][bugfix] in edit mode, the form will now load the social action list + + +### Test release 2021-11-29 + +* [person] suggest entities (person | thirdparty) when creating/editing the accompanying course (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/119) +* [activity] add custom validation on the Activity class, based on what is required from the ActivityType (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/188) +* [main] translate multiselect messages when selecting/creating address +* [main] set the coordinates of the city when creating a new address OR choosing "pas d'adresse complète" +* Use the user.label in accompanying course banner, instead of username; +* fix: show validation message when closing accompanying course; +* [thirdparty] link from modal to thirdparty detail page fixed (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/228) +* [assets] new asset to style suggestions lists (with add/remove item link) (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/258) +* [accompanyingCourseWorkEdit] improves hyphenation and line breaks for long badges +* [acompanyingCourse] improve Resume page + * complete all needed informations, + * actions and activities are clickables, + * better placement with js masonry blocks on top of content area, + * https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/101 + * https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/295 +* [activity/calendar] on show page, concerned groups of persons table adapt itself to isVisibles options +* [activity] remove the "plus" button in activity list +* [activity] check ACL on activity list in person context +* [list for accompanying course in person] filter list using ACL +* [validation] toasts are displayed for errors when modifying accompanying course (generalization required). +* [period] only the user can enable confidentiality +* add an endpoint for checking permissions. See https://gitlab.com/Chill-Projet/chill-bundles/-/merge_requests/232 +* [activity] for a new activity: suggest and create on-the-fly locations based on the accompanying course location + location of the suggested parties +* [calendar] for a new rdv: suggest and create on-the-fly locations based on the accompanying course location + location of the suggested parties +* [period] Validation added when period is confidential and confirmed -> user cannot be null. + + +## Test releases + +### Test release 2021-11-22 + +* [activity] delete admin_user_show in twig template because this route is not defined and should be defined +* [activity] suggest requestor, user and ressources for adding persons|user|3rdparty +* [calendar] suggest persons, professionals and invites for adding persons|3rdparty|user +* [activity] take into account the restrictions on person|thirdparties|users visibilities defined in ActivityType +* [main] Add currentLocation to the User entity + add a page for selecting this location + add in the user menu (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/133) +* [activity] add user current location as default location for a new activity (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/133) +* [task] Select2 field in task form to allow search for a user (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/167) +* remove "search by phone configuration option": search by phone is now executed by default +* remplacer le classement par ordre alphabétique par un classement par ordre de pertinence, qui tient compte: + * de la présence d'une string avec le nom de la ville; + * de la similarité; + * du fait que la recherche commence par une partie du mot recherché +* ajouter la recherche par numéro de téléphone directement dans la barre de recherche et dans le formulaire recherche avancée; +* ajouter la recherche par date de naissance directement dans la barre de recherche; +* ajouter la recherche par ville dans la recherche avancée +* ajouter un lien vers le ménage dans les résultats de recherche +* ajouter l'id du parcours dans les résultats de recherche +* ajouter le demandeur dans les résultats de recherche +* ajout d'un bouton "recherche avancée" sur la page d'accueil +* [person] create an accompanying course: add client-side validation if no origin (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/210) +* [person] fix bounds for computing current person address: the new address appears immediatly +* [docgen] create a normalizer and serializer for normalization on doc format +* [person normalization] the key center is now "centers" and is an array. Empty array if no center +* [accompanyingCourse] Ability to close accompanying course (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/296) +* [task] Select2 field in task form to allow search for a user (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/167) +* [list result] show all courses, except ones with period closed +* [accompanyingCourse] improve banner with small carousel to display slide social-issues or slide associated persons (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/69) + +### Test release 2021-11-15 + +* [main] fix adding multiple AddresseDeRelais (combine PickAddressType with ChillCollection) +* [person]: do not suggest the current household of the person (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/51) +* [person]: display other phone numbers in view + add message in case no others phone numbers (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/184) +* unnecessary whitespace removed from person banner after person-id + double parentheses removed (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/290) +* [person]: delete accompanying period work, including related objects (cascade) (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/36) +* [address]: Display of incomplete address adjusted. +* [household]: improve relationship graph + * add form to create/edit/delete relationship link, + * improve graph refresh mechanism + * add feature to export canvas as image (png) +* [person suggest] In widget "add person", improve the pertinence of persons when one of the names starts with the pattern; +* [person] do not ask for center any more on person creation +* [3party] do not ask for center any more on 3party creation + +## Test releases + +### Test release 2021-11-08 + +* [person]: Display the name of a user when searching after a User (TMS) +* [person]: Add civility to the person +* [person]: Various improvements on the edit person form +* [person]: Set available_languages and available_countries as parameters for use in the edit person form +* [activity] Bugfix: documents can now be added to an activity. +* [tasks] improve tasks with filter order +* [tasks] refactor singleControllerTasks: limit the number of conditions from the context +* [validations] validation of accompanying period added: no duplicate participations or resources (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/60). +* [renderbox] If gender of person is not defined, no icon is displayed instead of neuter-icon (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/129). +* [confidential information] module added to blur confidential information (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/248). +* refactor `AuthorizationHelper` and `UserACLAwareRepository` to fix constructor, and separate logic for parent role helper into `ParentRoleHelper` +* [main]: filter location and locationType in backend: exclude NULL names, only active and availableToUsers +* [activity]: perform client-side validation & show/hide fields in the "new location" modal +* [person]: normalize person with CenterResolverDispatcher and handle case where center is null or multiple in PersonRenderBox +* [docstore] voter for PersonDocument and AccompanyingCourseDocument on the 2.0 way (using VoterHelperFactory) +* [docstore] add authorization check inside controller and menu +* [activity]: fix inheritance for role `ACTIVITY FULL` and add missing acl in menu +* [person] show current address in search results +* [person] show alt names in search results +* [admin]: links to activity admin section added again. +* [household]: endDate field deleted from household edit form. +* [household]: View accompanying periods of current and old household members. +* [tasks]: different layout for task list / my tasks, and fix link to tasks in alert or in warning +* [admin]: links to activity admin section added again. +* [household]: household addresses ordered by ValidFrom date and by id to show the last created address on top. +* [socialWorkAction]: display of social issue and parent issues + banner context added. +* [DBAL dependencies] Upgrade to DBAL 3.1 + +### Test release 2021-10-27 + +* [person]: delete double actions buttons on search person page +* [person]: accompanying course work: remove creation date display the list of work + handle case when end date is null +* [main]: Add new pages with a menu for managing location and location type in the admin +* [main]: Add some fixtures for location type +* [calendar]: Pass the location when transforming a calendar item (rdv) into an activity +* [calendar]: Add a user menu for "my calendar" + +### Test release 2021-10-18 + +* [3party]: french translation of contact and company +* [3party]: show parent in list +* [3party]: change color for badge "child" +* [3party]: fix address creation +* [household members editor] finalisation of editor +* [AccompanyingCourse banner]: replace translation referrer (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/70) +* [Location]: add location system in activity and RV (calendar). User can choose in location list or create a new location. +* [household]: add relationship page with dynamic data visualisation graph + +## Test releases + +### Test release 2021-10-11 + +* Address: zoom on postal code geometry + fix origin of manually entered postal code + +* in the Address vue component, order the postal code and street address by alphabetic and numeric order + +* add 3 new fields to PostalCode and adapt postal code command and fixtures + +* [Aside activity] Fixes for aside activity + + * categories with child + * fast creation buttons + * add ordering for types + +* [AccompanyingCourse Resume page] dashboard for AccompanyingCourseWork and for Activities; +* Improve badges behaviour with small screens; + +* [ThirdParty]: + + * third party list + * create a kind contact/institution when create a new thirdparty, and set contact embedded as kind=child; + * filter thirdparties in list + +* [FilterOrder]: add development kit for generating filter and ordering in list +* [Capitalization of names] person names are capitalized on creation, on prePersist event +* [On-The-Fly] modale works for showing, editing and creating person or thirdparty ; +* [AccompanyingCourse Resume page] associated persons list, can see household when hover, and with show on-the-fly modale when clicking person ; + +### test release 2021-10-04 + +* [Household editor][UI] Update how household suggestion and addresses are picked; + + See https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/80 +* [AddAddress] Handle address suggestion; +* [CenterType][Create a person] when overriding the ACL rules, allow to show a PickCenterType + when no centers are reachable by the default ACL. +* [Household] Show comment event if no address are associated with the household; +* [Person results] Add requestor into search results: + + * a badge "requestor" is shown into search results; + * periods where the person is only requestor (without participating) are also shown; + + Issues: + + * https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/13 + * https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/199 +* [Person form] "accept sms" not required: + + https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/37 + https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/221 + +* [Household editor] suggest only temporarily addresses; + See https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/82 +* On-The-Fly modale works for showing, editing and creating person and thirdparty ; +* AccompanyingCourse Resume page: list associated persons by household, see household when hover, and show on-the-fly modale when clicking on person ; +* [AddAddress] Handle address suggestion; +* [AddAddress][Entity address]: add a link between address and address reference; +* [Household editor] suggest household by comparing the temporary addresses from courses; + + See https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/81 +* On-The-Fly modale works for showing, editing and creating person and thirdparty + + +## Test released + + + +## Stable releases + +No stable releases for v2+ + diff --git a/.changie.yaml b/.changie.yaml new file mode 100644 index 000000000..e77a5ecf3 --- /dev/null +++ b/.changie.yaml @@ -0,0 +1,31 @@ +changesDir: .changes +unreleasedDir: unreleased +headerPath: header.tpl.md +changelogPath: CHANGELOG.md +versionExt: md +versionFormat: '## {{.Version}} - {{.Time.Format "2006-01-02"}}' +kindFormat: '### {{.Kind}}' +changeFormat: >- + '* {{- if not (eq .Custom.Issue "") }}([#{{ .Custom.Issue }}](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/{{ .Custom.Issue }})){{- end }} {{.Body}}' +custom: + - key: Issue + label: Issue number (on chill-bundles repository) (optional) + optional: true + type: int + minInt: 1 +kinds: + - label: Feature + auto: minor + - label: Deprecated + auto: minor + - label: Fixed + auto: patch + - label: Security + auto: patch + - label: DX + auto: patch +newlines: + afterChangelogHeader: 1 + beforeChangelogVersion: 1 + endOfVersion: 1 +envPrefix: CHANGIE_ diff --git a/CHANGELOG.md b/CHANGELOG.md index b2f951479..5475b20b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,16 +1,19 @@ # Changelog - All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), -and this project adheres to +adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html), +and is generated by [Changie](https://github.com/miniscruff/changie). -* [Semantic Versioning](https://semver.org/spec/v2.0.0.html) for stable releases; -* date versioning for test releases -## Unreleased +## 2.0.0 + +* this is a release to relaunch our proceess of release with semantic versioning + +## Test releases + +### 2.0.0-beta3 - * [person][export] Fixed: rename the alias for `accompanying_period` to `acp` in filter associated with person * [activity][export] Feature: improve label for aliases in "Filter by activity type" * [activity][export] DX/Feature: use of an `ActivityTypeRepositoryInterface` instead of the old-style EntityRepository @@ -18,9 +21,6 @@ and this project adheres to * [person][export] Fixed: use left join for related entities in accompanying course aggregators * [workflow] Feature: allow user to copy and send manually the access link for the workflow * [workflow] Feature: show the email addresses that received an access link for the workflow - -## Test releases - ### 2.0.0-beta2 * [workflow]: Fixed: the notification is sent when the user is added to the first step. From 1b9fea04ce209046b43ac6e59209c7c05a28eb8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 1 Jun 2023 10:26:35 +0200 Subject: [PATCH 143/724] [changies] fixes and allow multiline messages --- .changie.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.changie.yaml b/.changie.yaml index e77a5ecf3..83fd9770a 100644 --- a/.changie.yaml +++ b/.changie.yaml @@ -6,13 +6,16 @@ versionExt: md versionFormat: '## {{.Version}} - {{.Time.Format "2006-01-02"}}' kindFormat: '### {{.Kind}}' changeFormat: >- - '* {{- if not (eq .Custom.Issue "") }}([#{{ .Custom.Issue }}](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/{{ .Custom.Issue }})){{- end }} {{.Body}}' + * {{ if not (eq .Custom.Issue "") }}([#{{ .Custom.Issue }}](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/{{ .Custom.Issue }})) {{- end }}{{.Body}} custom: - key: Issue label: Issue number (on chill-bundles repository) (optional) optional: true type: int minInt: 1 +body: + # allow multiline messages + block: true kinds: - label: Feature auto: minor From 5196d26a3ea7ccac135fdda0f4f5fc93a2d70bf3 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 1 Jun 2023 10:44:14 +0200 Subject: [PATCH 144/724] FEATURE [translations] add translations --- src/Bundle/ChillCalendarBundle/translations/messages.fr.yml | 6 ++++++ src/Bundle/ChillDocStoreBundle/translations/messages.fr.yml | 1 - src/Bundle/ChillPersonBundle/translations/messages.fr.yml | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml b/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml index 5e1fc971a..99aae1082 100644 --- a/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml @@ -147,3 +147,9 @@ CHILL_CALENDAR_CALENDAR_EDIT: Modifier les rendez-vous CHILL_CALENDAR_CALENDAR_DELETE: Supprimer les rendez-vous CHILL_CALENDAR_CALENDAR_SEE: Voir les rendez-vous + +generic_doc: + filter: + keys: + accompanying_period_calendar_document: Document des rendez-vous + person_calendar_document: Document des rendez-vous de la personne diff --git a/src/Bundle/ChillDocStoreBundle/translations/messages.fr.yml b/src/Bundle/ChillDocStoreBundle/translations/messages.fr.yml index 4fa41f180..1dde57eee 100644 --- a/src/Bundle/ChillDocStoreBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillDocStoreBundle/translations/messages.fr.yml @@ -26,7 +26,6 @@ generic_doc: filter: keys: accompanying_course_document: Document du parcours - accompanying_period_calendar_document: Document des rendez-vous date-range: Date du document # delete diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index a344ac50d..9b30e3a0b 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -1236,3 +1236,4 @@ generic_doc: filter: keys: accompanying_period_work_evaluation_document: Document des actions d'accompagnement + person_document: Documents de la personne From 59e1e02b92b3bc66a0dfb607c9455284138541f3 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 1 Jun 2023 10:45:55 +0200 Subject: [PATCH 145/724] FEATURE [calendar][docs] try to implement showing calendar docs from parcours context in person context --- .../PersonCalendarGenericDocProvider.php | 76 ++++++++++++++----- ...anyingPeriodCalendarGenericDocRenderer.php | 3 +- 2 files changed, 58 insertions(+), 21 deletions(-) diff --git a/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Providers/PersonCalendarGenericDocProvider.php b/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Providers/PersonCalendarGenericDocProvider.php index 12235f10a..bed04414c 100644 --- a/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Providers/PersonCalendarGenericDocProvider.php +++ b/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Providers/PersonCalendarGenericDocProvider.php @@ -19,6 +19,7 @@ use Chill\DocStoreBundle\GenericDoc\FetchQuery; use Chill\DocStoreBundle\GenericDoc\FetchQueryInterface; use Chill\DocStoreBundle\GenericDoc\GenericDocForPersonProviderInterface; use Chill\PersonBundle\Entity\Person; +use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodWorkVoter; use DateTimeImmutable; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\EntityManagerInterface; @@ -35,6 +36,38 @@ final class PersonCalendarGenericDocProvider implements GenericDocForPersonProvi ) { } + + private function addWhereClausesToQuery(FetchQuery $query, ?\DateTimeImmutable $startDate = null, ?\DateTimeImmutable $endDate = null, ?string $content = null): FetchQuery + { + $storedObjectMetadata = $this->em->getClassMetadata(StoredObject::class); + + if (null !== $startDate) { + $query->addWhereClause( + sprintf('doc_store.%s >= ?', $storedObjectMetadata->getColumnName('createdAt')), + [$startDate], + [Types::DATE_IMMUTABLE] + ); + } + + if (null !== $endDate) { + $query->addWhereClause( + sprintf('doc_store.%s < ?', $storedObjectMetadata->getColumnName('createdAt')), + [$endDate], + [Types::DATE_IMMUTABLE] + ); + } + + if (null !== $content) { + $query->addWhereClause( + sprintf('doc_store.%s ilike ?', $storedObjectMetadata->getColumnName('title')), + ['%' . $content . '%'], + [Types::STRING] + ); + } + + return $query; + } + /** * @throws MappingException */ @@ -72,33 +105,36 @@ final class PersonCalendarGenericDocProvider implements GenericDocForPersonProvi [Types::INTEGER] ); - if (null !== $startDate) { - $query->addWhereClause( - sprintf('doc_store.%s >= ?', $storedObjectMetadata->getColumnName('createdAt')), - [$startDate], - [Types::DATE_IMMUTABLE] + // get the documents associated with accompanying periods in which person participates + $or = []; + $orParams = []; + $orTypes = []; + foreach ($person->getAccompanyingPeriodParticipations() as $participation) { + if (!$this->security->isGranted(CalendarVoter::SEE, $participation->getAccompanyingPeriod())) { + continue; + } + + $or[] = sprintf( + '(calendar.%s = ? AND cd.%s BETWEEN ?::date AND COALESCE(?::date, \'infinity\'::date))', + $calendarMetadata->getSingleAssociationJoinColumnName('accompanyingPeriod'), + $storedObjectMetadata->getColumnName('createdAt') ); + $orParams = [...$orParams, $participation->getAccompanyingPeriod()->getId(), + DateTimeImmutable::createFromInterface($participation->getStartDate()), + null === $participation->getEndDate() ? null : DateTimeImmutable::createFromInterface($participation->getEndDate())]; + $orTypes = [...$orTypes, Types::INTEGER, Types::DATE_IMMUTABLE, Types::DATE_IMMUTABLE]; } - if (null !== $endDate) { - $query->addWhereClause( - sprintf('doc_store.%s < ?', $storedObjectMetadata->getColumnName('createdAt')), - [$endDate], - [Types::DATE_IMMUTABLE] - ); + if ([] === $or) { + $query->addWhereClause('TRUE = FALSE'); + + return $query; } - if (null !== $content) { - $query->addWhereClause( - sprintf('doc_store.%s ilike ?', $storedObjectMetadata->getColumnName('title')), - ['%' . $content . '%'], - [Types::STRING] - ); - } +// $query->addWhereClause(sprintf('(%s)', implode(' OR ', $or)), $orParams, $orTypes); - dump($query); + return $this->addWhereClausesToQuery($query, $startDate, $endDate, $content); - return $query; } /** diff --git a/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Renderers/AccompanyingPeriodCalendarGenericDocRenderer.php b/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Renderers/AccompanyingPeriodCalendarGenericDocRenderer.php index 0f680797c..d9636d99d 100644 --- a/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Renderers/AccompanyingPeriodCalendarGenericDocRenderer.php +++ b/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Renderers/AccompanyingPeriodCalendarGenericDocRenderer.php @@ -13,6 +13,7 @@ namespace Chill\CalendarBundle\Service\GenericDoc\Renderers; use Chill\CalendarBundle\Repository\CalendarDocRepository; use Chill\CalendarBundle\Service\GenericDoc\Providers\AccompanyingPeriodCalendarGenericDocProvider; +use Chill\CalendarBundle\Service\GenericDoc\Providers\PersonCalendarGenericDocProvider; use Chill\DocStoreBundle\GenericDoc\GenericDocDTO; use Chill\DocStoreBundle\GenericDoc\Twig\GenericDocRendererInterface; @@ -27,7 +28,7 @@ final class AccompanyingPeriodCalendarGenericDocRenderer implements GenericDocRe public function supports(GenericDocDTO $genericDocDTO, $options = []): bool { - return $genericDocDTO->key === AccompanyingPeriodCalendarGenericDocProvider::KEY; + return $genericDocDTO->key === AccompanyingPeriodCalendarGenericDocProvider::KEY || $genericDocDTO->key === PersonCalendarGenericDocProvider::KEY; } public function getTemplate(GenericDocDTO $genericDocDTO, $options = []): string From 5dc1cbce487fc0ea1ef96365271c89e11c383a60 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 1 Jun 2023 11:01:29 +0200 Subject: [PATCH 146/724] FEATURE [activity][docs] generic doc for activity documents in person context --- ...rsonActivityDocumentACLAwareRepository.php | 197 ++++++++++++++++++ .../PersonActivityGenericDocProvider.php | 57 +++++ 2 files changed, 254 insertions(+) create mode 100644 src/Bundle/ChillActivityBundle/Repository/PersonActivityDocumentACLAwareRepository.php create mode 100644 src/Bundle/ChillActivityBundle/Service/GenericDoc/Providers/PersonActivityGenericDocProvider.php diff --git a/src/Bundle/ChillActivityBundle/Repository/PersonActivityDocumentACLAwareRepository.php b/src/Bundle/ChillActivityBundle/Repository/PersonActivityDocumentACLAwareRepository.php new file mode 100644 index 000000000..862deb1ab --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Repository/PersonActivityDocumentACLAwareRepository.php @@ -0,0 +1,197 @@ +em = $em; + $this->centerResolverManager = $centerResolverManager; + $this->authorizationHelperForCurrentUser = $authorizationHelperForCurrentUser; + } + + public function buildQueryByPerson(Person $person): QueryBuilder + { + $qb = $this->em->getRepository(PersonDocument::class)->createQueryBuilder('d'); + + $qb + ->where($qb->expr()->eq('d.person', ':person')) + ->setParameter('person', $person); + + return $qb; + } + + + public function buildFetchQueryForPerson(Person $person, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null): FetchQueryInterface + { + $query = $this->buildBaseFetchQueryForPerson($person, $startDate, $endDate, $content); + + return $this->addFetchQueryByPersonACL($query, $person); + } + + public function buildBaseFetchQueryForPerson(Person $person, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null): FetchQuery + { + $storedObjectMetadata = $this->em->getClassMetadata(StoredObject::class); + + $query = new FetchQuery( + PersonDocumentGenericDocProvider::KEY, + sprintf('jsonb_build_object(\'id\', stored_obj.%s)', $storedObjectMetadata->getSingleIdentifierColumnName()), + sprintf('stored_obj.%s', $storedObjectMetadata->getColumnName('createdAt')), + sprintf('%s AS stored_obj', $storedObjectMetadata->getSchemaName().'.'.$storedObjectMetadata->getTableName()) + ); + + $query->addJoinClause( + 'JOIN public.activity_storedobject activity_doc ON activity_doc.storedobject_id = stored_obj.id' + ); + + $query->addJoinClause( + 'JOIN public.activity activity ON activity.id = activity_doc.activity_id' + ); + + $query->addWhereClause( + 'activity.person_id = ?', + [$person->getId()], + [Types::INTEGER] + ); + + if (null !== $startDate) { + $query->addWhereClause( + sprintf('stored_obj.%s >= ?', $storedObjectMetadata->getColumnName('createdAt')), + [$startDate], + [Types::DATE_IMMUTABLE] + ); + } + + if (null !== $endDate) { + $query->addWhereClause( + sprintf('stored_obj.%s < ?', $storedObjectMetadata->getColumnName('createdAt')), + [$endDate], + [Types::DATE_IMMUTABLE] + ); + } + + if (null !== $content) { + $query->addWhereClause( + 'stored_obj.title ilike ?', + ['%' . $content . '%'], + [Types::STRING] + ); + } + + return $query; + } + + public function countByPerson(Person $person): int + { + $qb = $this->buildQueryByPerson($person)->select('COUNT(d)'); + + $this->addACL($qb, $person); + + return $qb->getQuery()->getSingleScalarResult(); + } + + public function findByPerson(Person $person, array $orderBy = [], int $limit = 20, int $offset = 0): array + { + $qb = $this->buildQueryByPerson($person)->select('d'); + + $this->addACL($qb, $person); + + foreach ($orderBy as $field => $order) { + $qb->addOrderBy('d.' . $field, $order); + } + + $qb->setFirstResult($offset)->setMaxResults($limit); + + return $qb->getQuery()->getResult(); + } + + private function addACL(QueryBuilder $qb, Person $person): void + { + $reachableScopes = []; + + foreach ($this->centerResolverManager->resolveCenters($person) as $center) { + $reachableScopes = [ + ...$reachableScopes, + ...$this->authorizationHelperForCurrentUser + ->getReachableScopes( + PersonDocumentVoter::SEE, + $center + ) + ]; + } + + if ([] === $reachableScopes) { + $qb->andWhere("'FALSE' = 'TRUE'"); + + return; + } + + $qb->andWhere($qb->expr()->in('d.scope', ':scopes')) + ->setParameter('scopes', $reachableScopes); + } + + private function addFetchQueryByPersonACL(FetchQuery $fetchQuery, Person $person): FetchQuery + { + $personDocMetadata = $this->em->getClassMetadata(PersonDocument::class); + + $reachableScopes = []; + + foreach ($this->centerResolverManager->resolveCenters($person) as $center) { + $reachableScopes = [ + ...$reachableScopes, + ...$this->authorizationHelperForCurrentUser->getReachableScopes(PersonDocumentVoter::SEE, $center) + ]; + } + + if ([] === $reachableScopes) { + $fetchQuery->addWhereClause('FALSE = TRUE'); + + return $fetchQuery; + } + + $fetchQuery->addWhereClause( + sprintf( + 'person_document.%s IN (%s)', + $personDocMetadata->getSingleAssociationJoinColumnName('scope'), + implode(', ', array_fill(0, count($reachableScopes), '?')) + ), + array_map(static fn (Scope $s) => $s->getId(), $reachableScopes), + array_fill(0, count($reachableScopes), Types::INTEGER) + ); + + return $fetchQuery; + } +} diff --git a/src/Bundle/ChillActivityBundle/Service/GenericDoc/Providers/PersonActivityGenericDocProvider.php b/src/Bundle/ChillActivityBundle/Service/GenericDoc/Providers/PersonActivityGenericDocProvider.php new file mode 100644 index 000000000..d00a23e79 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Service/GenericDoc/Providers/PersonActivityGenericDocProvider.php @@ -0,0 +1,57 @@ +security = $security; + $this->personActivityDocumentACLAwareRepository = $personActivityDocumentACLAwareRepository; + } + + public function buildFetchQueryForPerson(Person $person, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface + { + return $this->personActivityDocumentACLAwareRepository->buildFetchQueryForPerson( + $person, + $startDate, + $endDate, + $content + ); + } + + /** + * @param Person $person + * @return bool + */ + public function isAllowedForPerson(Person $person): bool + { + return $this->security->isGranted(ActivityVoter::SEE, $person); + } +} From 7eb4fb4e563d618b562786e9d36c1c6aa820ea58 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 1 Jun 2023 13:09:51 +0200 Subject: [PATCH 147/724] FEATURE [calendar][docs] fix query to display rendez-vous documents from person and parcours contexts --- .../Providers/PersonCalendarGenericDocProvider.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Providers/PersonCalendarGenericDocProvider.php b/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Providers/PersonCalendarGenericDocProvider.php index bed04414c..640f0d197 100644 --- a/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Providers/PersonCalendarGenericDocProvider.php +++ b/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Providers/PersonCalendarGenericDocProvider.php @@ -98,13 +98,6 @@ final class PersonCalendarGenericDocProvider implements GenericDocForPersonProvi ) ); - $query->addWhereClause( - sprintf('calendar.%s = ?', - $calendarMetadata->getAssociationMapping('person')['joinColumns'][0]['name']), - [$person->getId()], - [Types::INTEGER] - ); - // get the documents associated with accompanying periods in which person participates $or = []; $orParams = []; From 2aeb72811a68f51dfc2c1ff300c34c7aa28a62ae Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 1 Jun 2023 13:31:35 +0200 Subject: [PATCH 148/724] [activity][docs] attempt to implement generic doc for activity documents in person context --- ...rsonActivityDocumentACLAwareRepository.php | 64 +++++++++++++------ ...anyingPeriodActivityGenericDocProvider.php | 4 +- ...anyingPeriodActivityGenericDocRenderer.php | 3 +- 3 files changed, 51 insertions(+), 20 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Repository/PersonActivityDocumentACLAwareRepository.php b/src/Bundle/ChillActivityBundle/Repository/PersonActivityDocumentACLAwareRepository.php index 862deb1ab..84bb08fb4 100644 --- a/src/Bundle/ChillActivityBundle/Repository/PersonActivityDocumentACLAwareRepository.php +++ b/src/Bundle/ChillActivityBundle/Repository/PersonActivityDocumentACLAwareRepository.php @@ -11,6 +11,8 @@ declare(strict_types=1); namespace Chill\ActivityBundle\Repository; +use Chill\ActivityBundle\Entity\Activity; +use Chill\ActivityBundle\Security\Authorization\ActivityVoter; use Chill\DocStoreBundle\Entity\PersonDocument; use Chill\DocStoreBundle\Entity\StoredObject; use Chill\DocStoreBundle\GenericDoc\FetchQuery; @@ -22,25 +24,22 @@ use Chill\MainBundle\Entity\Scope; use Chill\MainBundle\Security\Authorization\AuthorizationHelperForCurrentUserInterface; use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface; use Chill\PersonBundle\Entity\Person; +use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodWorkVoter; use DateTimeImmutable; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\QueryBuilder; use Symfony\Component\HttpKernel\HttpCache\Store; +use Symfony\Component\Security\Core\Security; class PersonActivityDocumentACLAwareRepository implements PersonDocumentACLAwareRepositoryInterface { - private AuthorizationHelperForCurrentUserInterface $authorizationHelperForCurrentUser; - - private CenterResolverManagerInterface $centerResolverManager; - - private EntityManagerInterface $em; - - public function __construct(EntityManagerInterface $em, CenterResolverManagerInterface $centerResolverManager, AuthorizationHelperForCurrentUserInterface $authorizationHelperForCurrentUser) + public function __construct( + private EntityManagerInterface $em, + private CenterResolverManagerInterface $centerResolverManager, + private AuthorizationHelperForCurrentUserInterface $authorizationHelperForCurrentUser, + private Security $security) { - $this->em = $em; - $this->centerResolverManager = $centerResolverManager; - $this->authorizationHelperForCurrentUser = $authorizationHelperForCurrentUser; } public function buildQueryByPerson(Person $person): QueryBuilder @@ -65,10 +64,11 @@ class PersonActivityDocumentACLAwareRepository implements PersonDocumentACLAware public function buildBaseFetchQueryForPerson(Person $person, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null): FetchQuery { $storedObjectMetadata = $this->em->getClassMetadata(StoredObject::class); + $activityMetadata = $this->em->getClassMetadata(Activity::class); $query = new FetchQuery( PersonDocumentGenericDocProvider::KEY, - sprintf('jsonb_build_object(\'id\', stored_obj.%s)', $storedObjectMetadata->getSingleIdentifierColumnName()), + sprintf('jsonb_build_object(\'id\', stored_obj.%s, \'activity_id\', activity.%s)', $storedObjectMetadata->getSingleIdentifierColumnName(), $activityMetadata->getSingleIdentifierColumnName()), sprintf('stored_obj.%s', $storedObjectMetadata->getColumnName('createdAt')), sprintf('%s AS stored_obj', $storedObjectMetadata->getSchemaName().'.'.$storedObjectMetadata->getTableName()) ); @@ -81,11 +81,39 @@ class PersonActivityDocumentACLAwareRepository implements PersonDocumentACLAware 'JOIN public.activity activity ON activity.id = activity_doc.activity_id' ); - $query->addWhereClause( + // add documents of activities from parcours context + $or = []; + $orParams = []; + $orTypes = []; + foreach ($person->getAccompanyingPeriodParticipations() as $participation) { + if (!$this->security->isGranted(ActivityVoter::SEE, $participation->getAccompanyingPeriod())) { + continue; + } + + $or[] = sprintf( + '(activity.%s = ? AND stored_obj.%s BETWEEN ?::date AND COALESCE(?::date, \'infinity\'::date))', + $activityMetadata->getSingleAssociationJoinColumnName('accompanyingPeriod'), + $storedObjectMetadata->getColumnName('createdAt') + ); + $orParams = [...$orParams, $participation->getAccompanyingPeriod()->getId(), + DateTimeImmutable::createFromInterface($participation->getStartDate()), + null === $participation->getEndDate() ? null : DateTimeImmutable::createFromInterface($participation->getEndDate())]; + $orTypes = [...$orTypes, Types::INTEGER, Types::DATE_IMMUTABLE, Types::DATE_IMMUTABLE]; + } + + if ([] === $or) { + $query->addWhereClause('TRUE = FALSE'); + + return $query; + } + + $query->addWhereClause(sprintf('(%s)', implode(' OR ', $or)), $orParams, $orTypes); + +/* $query->addWhereClause( 'activity.person_id = ?', [$person->getId()], [Types::INTEGER] - ); + );*/ if (null !== $startDate) { $query->addWhereClause( @@ -147,7 +175,7 @@ class PersonActivityDocumentACLAwareRepository implements PersonDocumentACLAware ...$reachableScopes, ...$this->authorizationHelperForCurrentUser ->getReachableScopes( - PersonDocumentVoter::SEE, + ActivityVoter::SEE, $center ) ]; @@ -165,14 +193,14 @@ class PersonActivityDocumentACLAwareRepository implements PersonDocumentACLAware private function addFetchQueryByPersonACL(FetchQuery $fetchQuery, Person $person): FetchQuery { - $personDocMetadata = $this->em->getClassMetadata(PersonDocument::class); + $activityMetadata = $this->em->getClassMetadata(Activity::class); $reachableScopes = []; foreach ($this->centerResolverManager->resolveCenters($person) as $center) { $reachableScopes = [ ...$reachableScopes, - ...$this->authorizationHelperForCurrentUser->getReachableScopes(PersonDocumentVoter::SEE, $center) + ...$this->authorizationHelperForCurrentUser->getReachableScopes(ActivityVoter::SEE, $center) ]; } @@ -184,8 +212,8 @@ class PersonActivityDocumentACLAwareRepository implements PersonDocumentACLAware $fetchQuery->addWhereClause( sprintf( - 'person_document.%s IN (%s)', - $personDocMetadata->getSingleAssociationJoinColumnName('scope'), + 'activity.%s IN (%s)', + $activityMetadata->getSingleAssociationJoinColumnName('scope'), implode(', ', array_fill(0, count($reachableScopes), '?')) ), array_map(static fn (Scope $s) => $s->getId(), $reachableScopes), diff --git a/src/Bundle/ChillActivityBundle/Service/GenericDoc/Providers/AccompanyingPeriodActivityGenericDocProvider.php b/src/Bundle/ChillActivityBundle/Service/GenericDoc/Providers/AccompanyingPeriodActivityGenericDocProvider.php index 8c787fd3a..284182cfb 100644 --- a/src/Bundle/ChillActivityBundle/Service/GenericDoc/Providers/AccompanyingPeriodActivityGenericDocProvider.php +++ b/src/Bundle/ChillActivityBundle/Service/GenericDoc/Providers/AccompanyingPeriodActivityGenericDocProvider.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\ActivityBundle\Service\GenericDoc\Providers; +use Chill\ActivityBundle\Entity\Activity; use Chill\ActivityBundle\Security\Authorization\ActivityVoter; use Chill\DocStoreBundle\Entity\StoredObject; use Chill\DocStoreBundle\GenericDoc\FetchQuery; @@ -36,10 +37,11 @@ final class AccompanyingPeriodActivityGenericDocProvider implements GenericDocFo public function buildFetchQueryForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface { $storedObjectMetadata = $this->em->getClassMetadata(StoredObject::class); + $activityMetadata = $this->em->getClassMetadata(Activity::class); $query = new FetchQuery( self::KEY, - "jsonb_build_object('id', doc_obj.id, 'activity_id', activity.id)", + sprintf("jsonb_build_object('id', doc_obj.%s, 'activity_id', activity.%s)", $storedObjectMetadata->getSingleIdentifierColumnName(), $activityMetadata->getSingleIdentifierColumnName()), 'doc_obj.'.$storedObjectMetadata->getColumnName('createdAt'), $storedObjectMetadata->getSchemaName().'.'.$storedObjectMetadata->getTableName().' AS doc_obj' ); diff --git a/src/Bundle/ChillActivityBundle/Service/GenericDoc/Renderers/AccompanyingPeriodActivityGenericDocRenderer.php b/src/Bundle/ChillActivityBundle/Service/GenericDoc/Renderers/AccompanyingPeriodActivityGenericDocRenderer.php index f3b70dac2..9f9a4bec8 100644 --- a/src/Bundle/ChillActivityBundle/Service/GenericDoc/Renderers/AccompanyingPeriodActivityGenericDocRenderer.php +++ b/src/Bundle/ChillActivityBundle/Service/GenericDoc/Renderers/AccompanyingPeriodActivityGenericDocRenderer.php @@ -13,6 +13,7 @@ namespace Chill\ActivityBundle\Service\GenericDoc\Renderers; use Chill\ActivityBundle\Repository\ActivityRepository; use Chill\ActivityBundle\Service\GenericDoc\Providers\AccompanyingPeriodActivityGenericDocProvider; +use Chill\ActivityBundle\Service\GenericDoc\Providers\PersonActivityGenericDocProvider; use Chill\DocStoreBundle\GenericDoc\GenericDocDTO; use Chill\DocStoreBundle\GenericDoc\Twig\GenericDocRendererInterface; use Chill\DocStoreBundle\Repository\StoredObjectRepository; @@ -31,7 +32,7 @@ final class AccompanyingPeriodActivityGenericDocRenderer implements GenericDocRe public function supports(GenericDocDTO $genericDocDTO, $options = []): bool { - return $genericDocDTO->key === AccompanyingPeriodActivityGenericDocProvider::KEY; + return $genericDocDTO->key === AccompanyingPeriodActivityGenericDocProvider::KEY || $genericDocDTO->key === PersonActivityGenericDocProvider::KEY; } public function getTemplate(GenericDocDTO $genericDocDTO, $options = []): string From d1e1b1c4cee1f3be8d045977e4c6c838a0bf0188 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 1 Jun 2023 14:02:48 +0200 Subject: [PATCH 149/724] [export form] decouple data from PickCenter form --- .../Controller/ExportController.php | 27 +++++++++----- .../Export/ExportFormHelper.php | 37 +++++++++++++++++++ .../DataMapper/ExportPickCenterDataMapper.php | 11 ++++-- .../Form/Type/Export/PickCenterType.php | 15 +++----- .../config/services/export.yaml | 2 + 5 files changed, 68 insertions(+), 24 deletions(-) create mode 100644 src/Bundle/ChillMainBundle/Export/ExportFormHelper.php diff --git a/src/Bundle/ChillMainBundle/Controller/ExportController.php b/src/Bundle/ChillMainBundle/Controller/ExportController.php index 6c4ea0269..a327b536a 100644 --- a/src/Bundle/ChillMainBundle/Controller/ExportController.php +++ b/src/Bundle/ChillMainBundle/Controller/ExportController.php @@ -13,6 +13,7 @@ namespace Chill\MainBundle\Controller; use Chill\MainBundle\Entity\SavedExport; use Chill\MainBundle\Entity\User; +use Chill\MainBundle\Export\ExportFormHelper; use Chill\MainBundle\Export\ExportManager; use Chill\MainBundle\Form\SavedExportType; use Chill\MainBundle\Form\Type\Export\ExportType; @@ -86,7 +87,8 @@ class ExportController extends AbstractController LoggerInterface $logger, SessionInterface $session, TranslatorInterface $translator, - EntityManagerInterface $entityManager + EntityManagerInterface $entityManager, + private readonly ExportFormHelper $exportFormHelper, ) { $this->entityManager = $entityManager; $this->redis = $chillRedis; @@ -293,10 +295,15 @@ class ExportController extends AbstractController $isGenerate = strpos($step, 'generate_') === 0; $builder = $this->formFactory - ->createNamedBuilder(null, FormType::class, [], [ - 'method' => $isGenerate ? 'GET' : 'POST', - 'csrf_protection' => $isGenerate ? false : true, - ]); + ->createNamedBuilder( + null, + FormType::class, + $this->exportFormHelper->getDefaultData($step, $exportManager->getExport($alias)), + [ + 'method' => $isGenerate ? 'GET' : 'POST', + 'csrf_protection' => $isGenerate ? false : true, + ] + ); // TODO: add a condition to be able to select a regroupment of centers? @@ -341,7 +348,7 @@ class ExportController extends AbstractController * * @return \Symfony\Component\HttpFoundation\Response */ - protected function exportFormStep(Request $request, $export, $alias) + private function exportFormStep(Request $request, $export, $alias) { $exportManager = $this->exportManager; @@ -405,7 +412,7 @@ class ExportController extends AbstractController * * @return \Symfony\Component\HttpFoundation\Response */ - protected function formatterFormStep(Request $request, $export, $alias) + private function formatterFormStep(Request $request, $export, $alias) { // check we have data from the previous step (export step) $data = $this->session->get('export_step', null); @@ -462,7 +469,7 @@ class ExportController extends AbstractController * * @return \Symfony\Component\HttpFoundation\RedirectResponse */ - protected function forwardToGenerate(Request $request, $export, $alias) + private function forwardToGenerate(Request $request, $export, $alias) { $dataCenters = $this->session->get('centers_step_raw', null); $dataFormatter = $this->session->get('formatter_step_raw', null); @@ -494,7 +501,7 @@ class ExportController extends AbstractController return $this->redirectToRoute('chill_main_export_download', ['key' => $key, 'alias' => $alias]); } - protected function rebuildData($key) + private function rebuildData($key) { $rawData = $this->rebuildRawData($key); @@ -527,7 +534,7 @@ class ExportController extends AbstractController * * @return Response */ - protected function selectCentersStep(Request $request, $export, $alias) + private function selectCentersStep(Request $request, $export, $alias) { /** @var \Chill\MainBundle\Export\ExportManager $exportManager */ $exportManager = $this->exportManager; diff --git a/src/Bundle/ChillMainBundle/Export/ExportFormHelper.php b/src/Bundle/ChillMainBundle/Export/ExportFormHelper.php new file mode 100644 index 000000000..1105217c8 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Export/ExportFormHelper.php @@ -0,0 +1,37 @@ + $steps + */ + public function getDefaultData(string $step, ExportInterface $export): array + { + $data = []; + + if ($step === 'centers') { + $data['centers'] = $this->authorizationHelper->getReachableCenters($export->requiredRole()); + } + + return $data; + } +} diff --git a/src/Bundle/ChillMainBundle/Form/DataMapper/ExportPickCenterDataMapper.php b/src/Bundle/ChillMainBundle/Form/DataMapper/ExportPickCenterDataMapper.php index 01303bfbb..c88f1dfe3 100644 --- a/src/Bundle/ChillMainBundle/Form/DataMapper/ExportPickCenterDataMapper.php +++ b/src/Bundle/ChillMainBundle/Form/DataMapper/ExportPickCenterDataMapper.php @@ -22,7 +22,10 @@ use function count; class ExportPickCenterDataMapper implements DataMapperInterface { - protected RegroupmentRepository $regroupmentRepository; + public function __construct( + private RegroupmentRepository $regroupmentRepository, + ) { + } public function mapDataToForms($data, $forms): void { @@ -37,15 +40,15 @@ class ExportPickCenterDataMapper implements DataMapperInterface foreach ($this->regroupmentRepository->findAll() as $regroupment) { /** @phpstan-ignore-next-line */ - [$contained, $notContained] = $regroupment->getCenters()->partition(static fn (Center $center): bool => false); + [$contained, $notContained] = $regroupment->getCenters()->partition(static fn (int $id, Center $center): bool => false); if (0 === count($notContained)) { $pickedRegroupment[] = $regroupment; } } - $form['regroupment']->setData($pickedRegroupment); - $form['centers']->setData($data); + $form['regroupment']->setData([]); + $form['center']->setData($data); } public function mapFormsToData($forms, &$data): void diff --git a/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php b/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php index c89907cf3..b2d903909 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php @@ -16,6 +16,7 @@ use Chill\MainBundle\Entity\Regroupment; use Chill\MainBundle\Export\ExportManager; use Chill\MainBundle\Form\DataMapper\ExportPickCenterDataMapper; use Chill\MainBundle\Repository\RegroupmentRepository; +use Chill\MainBundle\Security\Authorization\AuthorizationHelperForCurrentUserInterface; use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; @@ -33,22 +34,18 @@ final class PickCenterType extends AbstractType { public const CENTERS_IDENTIFIERS = 'c'; - private AuthorizationHelperInterface $authorizationHelper; + private AuthorizationHelperForCurrentUserInterface $authorizationHelper; private ExportManager $exportManager; private RegroupmentRepository $regroupmentRepository; - private UserInterface $user; - public function __construct( - TokenStorageInterface $tokenStorage, ExportManager $exportManager, RegroupmentRepository $regroupmentRepository, - AuthorizationHelperInterface $authorizationHelper + AuthorizationHelperForCurrentUserInterface $authorizationHelper ) { $this->exportManager = $exportManager; - $this->user = $tokenStorage->getToken()->getUser(); $this->authorizationHelper = $authorizationHelper; $this->regroupmentRepository = $regroupmentRepository; } @@ -57,18 +54,16 @@ final class PickCenterType extends AbstractType { $export = $this->exportManager->getExport($options['export_alias']); $centers = $this->authorizationHelper->getReachableCenters( - $this->user, $export->requiredRole() ); $builder->add('center', EntityType::class, [ 'class' => Center::class, - 'label' => 'center', 'choices' => $centers, + 'label' => 'center', 'multiple' => true, 'expanded' => true, 'choice_label' => static fn (Center $c) => $c->getName(), - 'data' => $centers, ]); if (count($this->regroupmentRepository->findAllActive()) > 0) { @@ -82,7 +77,7 @@ final class PickCenterType extends AbstractType ]); } - $builder->setDataMapper(new ExportPickCenterDataMapper()); + $builder->setDataMapper(new ExportPickCenterDataMapper($this->regroupmentRepository)); } public function configureOptions(OptionsResolver $resolver) diff --git a/src/Bundle/ChillMainBundle/config/services/export.yaml b/src/Bundle/ChillMainBundle/config/services/export.yaml index ea7328839..b0dbf934d 100644 --- a/src/Bundle/ChillMainBundle/config/services/export.yaml +++ b/src/Bundle/ChillMainBundle/config/services/export.yaml @@ -6,6 +6,8 @@ services: Chill\MainBundle\Export\Helper\: resource: '../../Export/Helper' + Chill\MainBundle\Export\ExportFormHelper: ~ + chill.main.export_element_validator: class: Chill\MainBundle\Validator\Constraints\Export\ExportElementConstraintValidator tags: From fb0afc7e0aa78b44894bde5814aefd5264c85769 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 2 Jun 2023 15:32:38 +0200 Subject: [PATCH 150/724] [WIP] get default data from saved exports for center and export steps --- .../Controller/ExportController.php | 100 ++++++++------- .../Export/ExportFormHelper.php | 116 ++++++++++++++++-- .../ChillMainBundle/Export/ExportManager.php | 75 +++++------ .../Form/Type/Export/AggregatorType.php | 1 - .../Form/Type/Export/FilterType.php | 1 - .../Form/Type/Export/PickFormatterType.php | 2 - .../MaritalStatusAggregator.php | 6 + .../Export/Export/CountPerson.php | 11 +- .../Export/Filter/PersonFilters/AgeFilter.php | 10 ++ 9 files changed, 225 insertions(+), 97 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Controller/ExportController.php b/src/Bundle/ChillMainBundle/Controller/ExportController.php index a327b536a..41237b21e 100644 --- a/src/Bundle/ChillMainBundle/Controller/ExportController.php +++ b/src/Bundle/ChillMainBundle/Controller/ExportController.php @@ -13,13 +13,16 @@ namespace Chill\MainBundle\Controller; use Chill\MainBundle\Entity\SavedExport; use Chill\MainBundle\Entity\User; +use Chill\MainBundle\Export\DirectExportInterface; use Chill\MainBundle\Export\ExportFormHelper; +use Chill\MainBundle\Export\ExportInterface; use Chill\MainBundle\Export\ExportManager; use Chill\MainBundle\Form\SavedExportType; use Chill\MainBundle\Form\Type\Export\ExportType; use Chill\MainBundle\Form\Type\Export\FormatterType; use Chill\MainBundle\Form\Type\Export\PickCenterType; use Chill\MainBundle\Redis\ChillRedis; +use Chill\MainBundle\Repository\SavedExportRepositoryInterface; use Chill\MainBundle\Security\Authorization\SavedExportVoter; use Doctrine\ORM\EntityManagerInterface; use LogicException; @@ -37,6 +40,7 @@ use Symfony\Component\HttpFoundation\Session\SessionInterface; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\Routing\Annotation\Route; +use Symfony\Component\Security\Core\Security; use Symfony\Contracts\Translation\TranslatorInterface; use function count; use function serialize; @@ -89,6 +93,8 @@ class ExportController extends AbstractController TranslatorInterface $translator, EntityManagerInterface $entityManager, private readonly ExportFormHelper $exportFormHelper, + private readonly SavedExportRepositoryInterface $savedExportRepository, + private readonly Security $security, ) { $this->entityManager = $entityManager; $this->redis = $chillRedis; @@ -103,12 +109,11 @@ class ExportController extends AbstractController { /** @var \Chill\MainBundle\Export\ExportManager $exportManager */ $exportManager = $this->exportManager; - $export = $exportManager->getExport($alias); - $key = $request->query->get('key', null); + $savedExport = $this->getSavedExportFromRequest($request); - [$dataCenters, $dataExport, $dataFormatter] = $this->rebuildData($key); + [$dataCenters, $dataExport, $dataFormatter] = $this->rebuildData($key, $savedExport); $formatterAlias = $exportManager->getFormatterAlias($dataExport['export']); @@ -146,8 +151,9 @@ class ExportController extends AbstractController /** @var \Chill\MainBundle\Export\ExportManager $exportManager */ $exportManager = $this->exportManager; $key = $request->query->get('key', null); + $savedExport = $this->getSavedExportFromRequest($request); - [$dataCenters, $dataExport, $dataFormatter] = $this->rebuildData($key); + [$dataCenters, $dataExport, $dataFormatter] = $this->rebuildData($key, $savedExport); return $exportManager->generate( $alias, @@ -206,12 +212,8 @@ class ExportController extends AbstractController * 3. 'generate': gather data from session from the previous steps, and * make a redirection to the "generate" action with data in query (HTTP GET) * - * @param string $request - * @param Request $alias - * - * @return \Symfony\Component\HttpFoundation\Response */ - public function newAction(Request $request, $alias) + public function newAction(Request $request, string $alias): Response { // first check for ACL $exportManager = $this->exportManager; @@ -221,20 +223,22 @@ class ExportController extends AbstractController throw $this->createAccessDeniedException('The user does not have access to this export'); } + $savedExport = $this->getSavedExportFromRequest($request); + $step = $request->query->getAlpha('step', 'centers'); switch ($step) { case 'centers': - return $this->selectCentersStep($request, $export, $alias); + return $this->selectCentersStep($request, $export, $alias, $savedExport); case 'export': - return $this->exportFormStep($request, $export, $alias); + return $this->exportFormStep($request, $export, $alias, $savedExport); case 'formatter': - return $this->formatterFormStep($request, $export, $alias); + return $this->formatterFormStep($request, $export, $alias, $savedExport); case 'generate': - return $this->forwardToGenerate($request, $export, $alias); + return $this->forwardToGenerate($request, $export, $alias, $savedExport); default: throw $this->createNotFoundException("The given step '{$step}' is invalid"); @@ -284,29 +288,35 @@ class ExportController extends AbstractController /** * create a form to show on different steps. * - * @param string $alias * @param array $data the data from previous step. Required for steps 'formatter' and 'generate_formatter' - * @param mixed $step */ - protected function createCreateFormExport($alias, $step, $data = []): FormInterface + protected function createCreateFormExport(string $alias, string $step, array $data, ?SavedExport $savedExport): FormInterface { /** @var \Chill\MainBundle\Export\ExportManager $exportManager */ $exportManager = $this->exportManager; $isGenerate = strpos($step, 'generate_') === 0; + $options = match ($step) { + 'export', 'generate_export' => ['picked_centers' => $exportManager->getPickedCenters($data['centers'])], + default => [], + }; + + $defaultFormData = match ($savedExport) { + null => $this->exportFormHelper->getDefaultData($step, $exportManager->getExport($alias), $options), + default => $this->exportFormHelper->savedExportDataToFormData($savedExport, $step, $options), + }; + $builder = $this->formFactory ->createNamedBuilder( null, FormType::class, - $this->exportFormHelper->getDefaultData($step, $exportManager->getExport($alias)), + $defaultFormData, [ 'method' => $isGenerate ? 'GET' : 'POST', - 'csrf_protection' => $isGenerate ? false : true, + 'csrf_protection' => !$isGenerate, ] ); - // TODO: add a condition to be able to select a regroupment of centers? - if ('centers' === $step || 'generate_centers' === $step) { $builder->add('centers', PickCenterType::class, [ 'export_alias' => $alias, @@ -342,13 +352,8 @@ class ExportController extends AbstractController * * When the method is POST, the form is stored if valid, and a redirection * is done to next step. - * - * @param string $alias - * @param \Chill\MainBundle\Export\DirectExportInterface|\Chill\MainBundle\Export\ExportInterface $export - * - * @return \Symfony\Component\HttpFoundation\Response */ - private function exportFormStep(Request $request, $export, $alias) + private function exportFormStep(Request $request, DirectExportInterface|ExportInterface $export, string $alias, ?SavedExport $savedExport = null): Response { $exportManager = $this->exportManager; @@ -364,7 +369,7 @@ class ExportController extends AbstractController $export = $exportManager->getExport($alias); - $form = $this->createCreateFormExport($alias, 'export', $data); + $form = $this->createCreateFormExport($alias, 'export', $data, $savedExport); if ($request->getMethod() === 'POST') { $form->handleRequest($request); @@ -386,6 +391,7 @@ class ExportController extends AbstractController $this->generateUrl('chill_main_export_new', [ 'step' => $this->getNextStep('export', $export), 'alias' => $alias, + 'from_saved' => $request->get('from_saved', '') ]) ); } @@ -406,13 +412,8 @@ class ExportController extends AbstractController * * If the form is posted and valid, store the data in session and * redirect to the next step. - * - * @param \Chill\MainBundle\Export\DirectExportInterface|\Chill\MainBundle\Export\ExportInterface $export - * @param string $alias - * - * @return \Symfony\Component\HttpFoundation\Response */ - private function formatterFormStep(Request $request, $export, $alias) + private function formatterFormStep(Request $request, DirectExportInterface|ExportInterface $export, string $alias, ?SavedExport $savedExport = null): Response { // check we have data from the previous step (export step) $data = $this->session->get('export_step', null); @@ -424,7 +425,7 @@ class ExportController extends AbstractController ]); } - $form = $this->createCreateFormExport($alias, 'formatter', $data); + $form = $this->createCreateFormExport($alias, 'formatter', $data, $savedExport); if ($request->getMethod() === 'POST') { $form->handleRequest($request); @@ -443,6 +444,7 @@ class ExportController extends AbstractController [ 'alias' => $alias, 'step' => $this->getNextStep('formatter', $export), + 'from_saved' => $request->get('from_saved', ''), ] )); } @@ -469,7 +471,7 @@ class ExportController extends AbstractController * * @return \Symfony\Component\HttpFoundation\RedirectResponse */ - private function forwardToGenerate(Request $request, $export, $alias) + private function forwardToGenerate(Request $request, $export, $alias, ?SavedExport $savedExport) { $dataCenters = $this->session->get('centers_step_raw', null); $dataFormatter = $this->session->get('formatter_step_raw', null); @@ -501,17 +503,17 @@ class ExportController extends AbstractController return $this->redirectToRoute('chill_main_export_download', ['key' => $key, 'alias' => $alias]); } - private function rebuildData($key) + private function rebuildData($key, ?SavedExport $savedExport) { $rawData = $this->rebuildRawData($key); $alias = $rawData['alias']; - $formCenters = $this->createCreateFormExport($alias, 'generate_centers'); + $formCenters = $this->createCreateFormExport($alias, 'generate_centers', [], $savedExport); $formCenters->submit($rawData['centers']); $dataCenters = $formCenters->getData(); - $formExport = $this->createCreateFormExport($alias, 'generate_export', $dataCenters); + $formExport = $this->createCreateFormExport($alias, 'generate_export', $dataCenters, $savedExport); $formExport->submit($rawData['export']); $dataExport = $formExport->getData(); @@ -519,7 +521,8 @@ class ExportController extends AbstractController $formFormatter = $this->createCreateFormExport( $alias, 'generate_formatter', - $dataExport + $dataExport, + $savedExport ); $formFormatter->submit($rawData['formatter']); $dataFormatter = $formFormatter->getData(); @@ -534,12 +537,12 @@ class ExportController extends AbstractController * * @return Response */ - private function selectCentersStep(Request $request, $export, $alias) + private function selectCentersStep(Request $request, $export, $alias, ?SavedExport $savedExport = null) { /** @var \Chill\MainBundle\Export\ExportManager $exportManager */ $exportManager = $this->exportManager; - $form = $this->createCreateFormExport($alias, 'centers'); + $form = $this->createCreateFormExport($alias, 'centers', [], $savedExport); if ($request->getMethod() === 'POST') { $form->handleRequest($request); @@ -571,6 +574,7 @@ class ExportController extends AbstractController return $this->redirectToRoute('chill_main_export_new', [ 'step' => $this->getNextStep('centers', $export), 'alias' => $alias, + 'from_saved' => $request->get('from_saved', ''), ]); } } @@ -677,4 +681,18 @@ class ExportController extends AbstractController return $rawData; } + + private function getSavedExportFromRequest(Request $request): ?SavedExport + { + $savedExport = match ($savedExportId = $request->query->get('from_saved', '')) { + '' => null, + default => $this->savedExportRepository->find($savedExportId), + }; + + if (null !== $savedExport && !$this->security->isGranted(SavedExportVoter::EDIT, $savedExport)) { + throw new AccessDeniedHttpException("saved export edition not allowed"); + } + + return $savedExport; + } } diff --git a/src/Bundle/ChillMainBundle/Export/ExportFormHelper.php b/src/Bundle/ChillMainBundle/Export/ExportFormHelper.php index 1105217c8..6f00c91da 100644 --- a/src/Bundle/ChillMainBundle/Export/ExportFormHelper.php +++ b/src/Bundle/ChillMainBundle/Export/ExportFormHelper.php @@ -11,27 +11,127 @@ declare(strict_types=1); namespace Chill\MainBundle\Export; +use Chill\MainBundle\Entity\SavedExport; +use Chill\MainBundle\Form\Type\Export\ExportType; +use Chill\MainBundle\Form\Type\Export\FilterType; +use Chill\MainBundle\Form\Type\Export\PickCenterType; use Chill\MainBundle\Security\Authorization\AuthorizationHelperForCurrentUserInterface; +use Symfony\Component\Form\Extension\Core\Type\FormType; +use Symfony\Component\Form\FormFactoryInterface; final readonly class ExportFormHelper { public function __construct( - private ExportManager $exportManager, private AuthorizationHelperForCurrentUserInterface $authorizationHelper, + private ExportManager $exportManager, + private FormFactoryInterface $formFactory, ) { } - /** - * @param list<"centers"> $steps - */ - public function getDefaultData(string $step, ExportInterface $export): array + public function getDefaultData(string $step, ExportInterface|DirectExportInterface $export, array $options = []): array { - $data = []; + return match ($step) { + 'centers', 'generate_centers' => ['centers' => $this->authorizationHelper->getReachableCenters($export->requiredRole())], + 'export', 'generate_export' => ['export' => $this->getDefaultDataStepExport($export, $options)], + 'formatter', 'generate_formatter' => [], + default => throw new \LogicException("step not allowed : " . $step), + }; + } - if ($step === 'centers') { - $data['centers'] = $this->authorizationHelper->getReachableCenters($export->requiredRole()); + private function getDefaultDataStepExport(ExportInterface|DirectExportInterface $export, array $options): array + { + $data = [ + ExportType::EXPORT_KEY => $export->getFormDefaultData(), + ExportType::FILTER_KEY => [], + ExportType::AGGREGATOR_KEY => [], + ExportType::PICK_FORMATTER_KEY => [], + ]; + + $filters = $this->exportManager->getFiltersApplyingOn($export, $options['picked_centers']); + foreach ($filters as $alias => $filter) { + $data[ExportType::FILTER_KEY][$alias] = [ + FilterType::ENABLED_FIELD => false, + 'form' => $filter->getFormDefaultData() + ]; } + $aggregators = $this->exportManager + ->getAggregatorsApplyingOn($export, $options['picked_centers']); + foreach ($aggregators as $alias => $aggregator) { + $data[ExportType::AGGREGATOR_KEY][$alias] = [ + 'enabled' => false, + 'form' => $aggregator->getFormDefaultData(), + ]; + } + + $allowedFormatters = $this->exportManager + ->getFormattersByTypes($export->getAllowedFormattersTypes()); + $choices = []; + foreach (array_keys(iterator_to_array($allowedFormatters)) as $alias) { + $choices[] = $alias; + } + + $data[ExportType::PICK_FORMATTER_KEY]['alias'] = match (count($choices)) { + 1 => $choices[0], + default => null, + }; + return $data; } + + public function savedExportDataToFormData( + SavedExport $savedExport, + string $step, + array $formOptions = [], + ): array { + return match ($step) { + 'centers', 'generate_centers' => $this->savedExportDataToFormDataStepCenter($savedExport), + 'export', 'generate_export' => $this->savedExportDataToFormDataStepExport($savedExport, $formOptions), + 'formatter', 'generate_formatter' => [], + default => throw new \LogicException("this step is not allowed: " . $step), + }; + } + + private function savedExportDataToFormDataStepCenter( + SavedExport $savedExport, + ): array { + $builder = $this->formFactory + ->createBuilder( + FormType::class, + [], + [ + 'csrf_protection' => false, + ] + ); + + $builder->add('centers', PickCenterType::class, [ + 'export_alias' => $savedExport->getExportAlias(), + ]); + $form = $builder->getForm(); + $form->submit($savedExport->getOptions()['centers']); + + return $form->getData(); + } + + private function savedExportDataToFormDataStepExport( + SavedExport $savedExport, + array $formOptions + ): array { + $builder = $this->formFactory + ->createBuilder( + FormType::class, + [], + [ + 'csrf_protection' => false, + ] + ); + + $builder->add('export', ExportType::class, [ + 'export_alias' => $savedExport->getExportAlias(), ...$formOptions + ]); + $form = $builder->getForm(); + $form->submit($savedExport->getOptions()['export']); + + return $form->getData(); + } } diff --git a/src/Bundle/ChillMainBundle/Export/ExportManager.php b/src/Bundle/ChillMainBundle/Export/ExportManager.php index f39926083..7ad880642 100644 --- a/src/Bundle/ChillMainBundle/Export/ExportManager.php +++ b/src/Bundle/ChillMainBundle/Export/ExportManager.php @@ -12,7 +12,6 @@ declare(strict_types=1); namespace Chill\MainBundle\Export; use Chill\MainBundle\Form\Type\Export\ExportType; -use Chill\MainBundle\Form\Type\Export\PickCenterType; use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface; use Doctrine\ORM\QueryBuilder; use Generator; @@ -131,9 +130,9 @@ class ExportManager * * @internal This class check the interface implemented by export, and, if ´ListInterface´ is used, return an empty array * - * @return AggregatorInterface[] a \Generator that contains aggretagors. The key is the filter's alias + * @return null|iterable a \Generator that contains aggretagors. The key is the filter's alias */ - public function &getAggregatorsApplyingOn(ExportInterface $export, ?array $centers = null) + public function &getAggregatorsApplyingOn(ExportInterface $export, ?array $centers = null): ?iterable { if ($export instanceof ListInterface) { return; @@ -149,7 +148,7 @@ class ExportManager } } - public function addExportElementsProvider(ExportElementsProviderInterface $provider, $prefix) + public function addExportElementsProvider(ExportElementsProviderInterface $provider, string $prefix): void { foreach ($provider->getExportElements() as $suffix => $element) { $alias = $prefix . '_' . $suffix; @@ -173,23 +172,16 @@ class ExportManager * add a formatter. * * @internal used by DI - * - * @param string $alias */ - public function addFormatter(FormatterInterface $formatter, $alias) + public function addFormatter(FormatterInterface $formatter, string $alias) { $this->formatters[$alias] = $formatter; } /** * Generate a response which contains the requested data. - * - * @param string $exportAlias - * @param mixed[] $data - * - * @return Response */ - public function generate($exportAlias, array $pickedCentersData, array $data, array $formatterData) + public function generate(string $exportAlias, array $pickedCentersData, array $data, array $formatterData): Response { $export = $this->getExport($exportAlias); $centers = $this->getPickedCenters($pickedCentersData); @@ -288,7 +280,11 @@ class ExportManager return $this->aggregators[$alias]; } - public function getAggregators(array $aliases) + /** + * @param array $aliases + * @return iterable + */ + public function getAggregators(array $aliases): iterable { foreach ($aliases as $alias) { yield $alias => $this->getAggregator($alias); @@ -296,9 +292,11 @@ class ExportManager } /** - * @return string[] the existing type for known exports + * Get the types for known exports + * + * @return list the existing type for known exports */ - public function getExistingExportsTypes() + public function getExistingExportsTypes(): array { $existingTypes = []; @@ -317,10 +315,8 @@ class ExportManager * @param string $alias * * @throws RuntimeException - * - * @return ExportInterface */ - public function getExport($alias) + public function getExport($alias): ExportInterface|DirectExportInterface { if (!array_key_exists($alias, $this->exports)) { throw new RuntimeException("The export with alias {$alias} is not known."); @@ -334,9 +330,9 @@ class ExportManager * * @param bool $whereUserIsGranted if true (default), restrict to user which are granted the right to execute the export * - * @return ExportInterface[] an array where export's alias are keys + * @return iterable an array where export's alias are keys */ - public function getExports($whereUserIsGranted = true) + public function getExports($whereUserIsGranted = true): iterable { foreach ($this->exports as $alias => $export) { if ($whereUserIsGranted) { @@ -354,9 +350,9 @@ class ExportManager * * @param bool $whereUserIsGranted * - * @return array where keys are the groups's name and value is an array of exports + * @return array> where keys are the groups's name and value is an array of exports */ - public function getExportsGrouped($whereUserIsGranted = true): array + public function getExportsGrouped(bool $whereUserIsGranted = true): array { $groups = ['_' => []]; @@ -375,10 +371,8 @@ class ExportManager * @param string $alias * * @throws RuntimeException if the filter is not known - * - * @return FilterInterface */ - public function getFilter($alias) + public function getFilter(string $alias): FilterInterface { if (!array_key_exists($alias, $this->filters)) { throw new RuntimeException("The filter with alias {$alias} is not known."); @@ -390,16 +384,17 @@ class ExportManager /** * get all filters. * - * @param Generator $aliases + * @param array $aliases + * @return iterable $aliases */ - public function getFilters(array $aliases) + public function getFilters(array $aliases): iterable { foreach ($aliases as $alias) { yield $alias => $this->getFilter($alias); } } - public function getFormatter($alias) + public function getFormatter(string $alias): FormatterInterface { if (!array_key_exists($alias, $this->formatters)) { throw new RuntimeException("The formatter with alias {$alias} is not known."); @@ -414,7 +409,7 @@ class ExportManager * @param array $data the data from the export form * @string the formatter alias|null */ - public function getFormatterAlias(array $data) + public function getFormatterAlias(array $data): ?string { if (array_key_exists(ExportType::PICK_FORMATTER_KEY, $data)) { return $data[ExportType::PICK_FORMATTER_KEY]['alias']; @@ -426,9 +421,9 @@ class ExportManager /** * Get all formatters which supports one of the given types. * - * @return Generator + * @return iterable */ - public function getFormattersByTypes(array $types) + public function getFormattersByTypes(array $types): iterable { foreach ($this->formatters as $alias => $formatter) { if (in_array($formatter->getType(), $types, true)) { @@ -445,7 +440,7 @@ class ExportManager * * @return \Chill\MainBundle\Entity\Center[] the picked center */ - public function getPickedCenters(array $data) + public function getPickedCenters(array $data): array { return $data; } @@ -455,9 +450,9 @@ class ExportManager * * @param array $data the data from the export form * - * @return string[] + * @return list */ - public function getUsedAggregatorsAliases(array $data) + public function getUsedAggregatorsAliases(array $data): array { $aggregators = $this->retrieveUsedAggregators($data[ExportType::AGGREGATOR_KEY]); @@ -471,9 +466,8 @@ class ExportManager * @param \Chill\MainBundle\Export\ExportElementInterface $element * @param DirectExportInterface|ExportInterface $export * - * @return bool */ - public function isGrantedForElement(ExportElementInterface $element, ?ExportElementInterface $export = null, ?array $centers = null) + public function isGrantedForElement(ExportElementInterface $element, ?ExportElementInterface $export = null, ?array $centers = null): bool { if ($element instanceof ExportInterface || $element instanceof DirectExportInterface) { $role = $element->requiredRole(); @@ -548,13 +542,12 @@ class ExportManager * Check for acl. If an user is not authorized to see an aggregator, throw an * UnauthorizedException. * - * @param type $data * @throw UnauthorizedHttpException if the user is not authorized */ private function handleAggregators( ExportInterface $export, QueryBuilder $qb, - $data, + array $data, array $center ) { $aggregators = $this->retrieveUsedAggregators($data); @@ -600,9 +593,9 @@ class ExportManager /** * @param mixed $data * - * @return AggregatorInterface[] + * @return iterable */ - private function retrieveUsedAggregators($data) + private function retrieveUsedAggregators($data): iterable { if (null === $data) { return []; diff --git a/src/Bundle/ChillMainBundle/Form/Type/Export/AggregatorType.php b/src/Bundle/ChillMainBundle/Form/Type/Export/AggregatorType.php index eff303573..1ea01d5f8 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/Export/AggregatorType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/Export/AggregatorType.php @@ -32,7 +32,6 @@ class AggregatorType extends AbstractType ->add('enabled', CheckboxType::class, [ 'value' => true, 'required' => false, - 'data' => false, ]); $filterFormBuilder = $builder->create('form', FormType::class, [ diff --git a/src/Bundle/ChillMainBundle/Form/Type/Export/FilterType.php b/src/Bundle/ChillMainBundle/Form/Type/Export/FilterType.php index 153f8946b..7994881d5 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/Export/FilterType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/Export/FilterType.php @@ -33,7 +33,6 @@ class FilterType extends AbstractType $builder ->add(self::ENABLED_FIELD, CheckboxType::class, [ 'value' => true, - 'data' => false, 'required' => false, ]); diff --git a/src/Bundle/ChillMainBundle/Form/Type/Export/PickFormatterType.php b/src/Bundle/ChillMainBundle/Form/Type/Export/PickFormatterType.php index ce442231e..b3253ec42 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/Export/PickFormatterType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/Export/PickFormatterType.php @@ -47,8 +47,6 @@ class PickFormatterType extends AbstractType 'multiple' => false, 'placeholder' => 'Choose a format', ]); - - //$builder->get('type')->addModelTransformer($transformer); } public function configureOptions(OptionsResolver $resolver) diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/MaritalStatusAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/MaritalStatusAggregator.php index 08bde4bda..c311aadf3 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/MaritalStatusAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/MaritalStatusAggregator.php @@ -48,6 +48,7 @@ final class MaritalStatusAggregator implements AggregatorInterface public function applyOn() { + return 'abcde'; return Declarations::PERSON_TYPE; } @@ -56,6 +57,11 @@ final class MaritalStatusAggregator implements AggregatorInterface // no form } + public function getFormDefaultData(): array + { + return []; + } + public function getLabels($key, array $values, $data) { return function ($value): string { diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountPerson.php b/src/Bundle/ChillPersonBundle/Export/Export/CountPerson.php index 60429ae55..c1800395c 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountPerson.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountPerson.php @@ -38,6 +38,11 @@ class CountPerson implements ExportInterface, GroupedExportInterface // No form necessary } + public function getFormDefaultData(): array + { + return []; + } + public function getAllowedFormattersTypes() { return [FormatterInterface::TYPE_TABULAR]; @@ -115,9 +120,9 @@ class CountPerson implements ExportInterface, GroupedExportInterface public function supportsModifiers() { return [ - Declarations::PERSON_TYPE, - Declarations::PERSON_IMPLIED_IN, - //Declarations::ACP_TYPE + 'abcde', + //Declarations::PERSON_TYPE, + //Declarations::PERSON_IMPLIED_IN, ]; } } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AgeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AgeFilter.php index c05f97ca8..66db7e95b 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AgeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AgeFilter.php @@ -73,6 +73,7 @@ class AgeFilter implements ExportElementValidatedInterface, FilterInterface public function applyOn() { + return 'abcde'; return Declarations::PERSON_TYPE; } @@ -92,6 +93,15 @@ class AgeFilter implements ExportElementValidatedInterface, FilterInterface ]); } + public function getFormDefaultData(): array + { + return [ + 'min_age' => 0, + 'max_age' => 120, + 'date_calc' => new RollingDate(RollingDate::T_TODAY), + ]; + } + public function describeAction($data, $format = 'string') { return ['Filtered by person\'s age: ' From cb0a6bbd21403a8de3be1af05cac7fe1094f9bf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sun, 4 Jun 2023 01:10:50 +0200 Subject: [PATCH 151/724] Regenerate data from saved export on formatter test [ci-skip] --- .../Controller/ExportController.php | 31 ++++++++-------- .../Export/ExportFormHelper.php | 35 +++++++++++++++++-- .../Export/Formatter/SpreadSheetFormatter.php | 20 ++++++++--- .../NationalityAggregator.php | 8 +++++ 4 files changed, 71 insertions(+), 23 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Controller/ExportController.php b/src/Bundle/ChillMainBundle/Controller/ExportController.php index 41237b21e..2ad6377a6 100644 --- a/src/Bundle/ChillMainBundle/Controller/ExportController.php +++ b/src/Bundle/ChillMainBundle/Controller/ExportController.php @@ -297,8 +297,18 @@ class ExportController extends AbstractController $isGenerate = strpos($step, 'generate_') === 0; $options = match ($step) { - 'export', 'generate_export' => ['picked_centers' => $exportManager->getPickedCenters($data['centers'])], - default => [], + 'export', 'generate_export' => [ + 'export_alias' => $alias, + 'picked_centers' => $exportManager->getPickedCenters($data['centers']) + ], + 'formatter', 'generate_formatter' => [ + 'export_alias' => $alias, + 'formatter_alias' => $exportManager->getFormatterAlias($data['export']), + 'aggregator_aliases' => $exportManager->getUsedAggregatorsAliases($data['export']), + ], + default => [ + 'export_alias' => $alias, + ], }; $defaultFormData = match ($savedExport) { @@ -318,26 +328,15 @@ class ExportController extends AbstractController ); if ('centers' === $step || 'generate_centers' === $step) { - $builder->add('centers', PickCenterType::class, [ - 'export_alias' => $alias, - ]); + $builder->add('centers', PickCenterType::class, $options); } if ('export' === $step || 'generate_export' === $step) { - $builder->add('export', ExportType::class, [ - 'export_alias' => $alias, - 'picked_centers' => $exportManager->getPickedCenters($data['centers']), - ]); + $builder->add('export', ExportType::class, $options); } if ('formatter' === $step || 'generate_formatter' === $step) { - $builder->add('formatter', FormatterType::class, [ - 'formatter_alias' => $exportManager - ->getFormatterAlias($data['export']), - 'export_alias' => $alias, - 'aggregator_aliases' => $exportManager - ->getUsedAggregatorsAliases($data['export']), - ]); + $builder->add('formatter', FormatterType::class, $options); } $builder->add('submit', SubmitType::class, [ diff --git a/src/Bundle/ChillMainBundle/Export/ExportFormHelper.php b/src/Bundle/ChillMainBundle/Export/ExportFormHelper.php index 6f00c91da..3deb2acbc 100644 --- a/src/Bundle/ChillMainBundle/Export/ExportFormHelper.php +++ b/src/Bundle/ChillMainBundle/Export/ExportFormHelper.php @@ -14,6 +14,7 @@ namespace Chill\MainBundle\Export; use Chill\MainBundle\Entity\SavedExport; use Chill\MainBundle\Form\Type\Export\ExportType; use Chill\MainBundle\Form\Type\Export\FilterType; +use Chill\MainBundle\Form\Type\Export\FormatterType; use Chill\MainBundle\Form\Type\Export\PickCenterType; use Chill\MainBundle\Security\Authorization\AuthorizationHelperForCurrentUserInterface; use Symfony\Component\Form\Extension\Core\Type\FormType; @@ -33,11 +34,18 @@ final readonly class ExportFormHelper return match ($step) { 'centers', 'generate_centers' => ['centers' => $this->authorizationHelper->getReachableCenters($export->requiredRole())], 'export', 'generate_export' => ['export' => $this->getDefaultDataStepExport($export, $options)], - 'formatter', 'generate_formatter' => [], + 'formatter', 'generate_formatter' => ['formatter' => $this->getDefaultDataStepFormatter($options)], default => throw new \LogicException("step not allowed : " . $step), }; } + private function getDefaultDataStepFormatter(array $options): array + { + $formatter = $this->exportManager->getFormatter($options['formatter_alias']); + + return $formatter->getFormDefaultData($options['aggregator_aliases']); + } + private function getDefaultDataStepExport(ExportInterface|DirectExportInterface $export, array $options): array { $data = [ @@ -87,7 +95,7 @@ final readonly class ExportFormHelper return match ($step) { 'centers', 'generate_centers' => $this->savedExportDataToFormDataStepCenter($savedExport), 'export', 'generate_export' => $this->savedExportDataToFormDataStepExport($savedExport, $formOptions), - 'formatter', 'generate_formatter' => [], + 'formatter', 'generate_formatter' => $this->savedExportDataToFormDataStepFormatter($savedExport, $formOptions), default => throw new \LogicException("this step is not allowed: " . $step), }; } @@ -134,4 +142,27 @@ final readonly class ExportFormHelper return $form->getData(); } + + private function savedExportDataToFormDataStepFormatter( + SavedExport $savedExport, + array $formOptions + ): array { + dump(__METHOD__); + $builder = $this->formFactory + ->createBuilder( + FormType::class, + [], + [ + 'csrf_protection' => false, + ] + ); + + $builder->add('formatter', FormatterType::class, [ + 'export_alias' => $savedExport->getExportAlias(), ...$formOptions + ]); + $form = $builder->getForm(); + $form->submit($savedExport->getOptions()['formatter']); + + return $form->getData(); + } } diff --git a/src/Bundle/ChillMainBundle/Export/Formatter/SpreadSheetFormatter.php b/src/Bundle/ChillMainBundle/Export/Formatter/SpreadSheetFormatter.php index dc09c55a1..6a4b38e84 100644 --- a/src/Bundle/ChillMainBundle/Export/Formatter/SpreadSheetFormatter.php +++ b/src/Bundle/ChillMainBundle/Export/Formatter/SpreadSheetFormatter.php @@ -173,7 +173,19 @@ class SpreadSheetFormatter implements FormatterInterface } } - public function getName() + public function getFormDefaultData(array $aggregatorAliases): array + { + $data = ['format' => 'xlsx']; + + $aggregators = iterator_to_array($this->exportManager->getAggregators($aggregatorAliases)); + foreach (array_keys($aggregators) as $index => $alias) { + $data[$alias] = ['order' => $index + 1]; + } + + return $data; + } + + public function getName(): string { return 'SpreadSheet (xlsx, ods)'; } @@ -185,7 +197,7 @@ class SpreadSheetFormatter implements FormatterInterface array $exportData, array $filtersData, array $aggregatorsData - ) { + ): Response { // store all data when the process is initiated $this->result = $result; $this->formatterData = $formatterData; @@ -574,10 +586,8 @@ class SpreadSheetFormatter implements FormatterInterface * * This form allow to choose the aggregator position (row or column) and * the ordering - * - * @param string $nbAggregators */ - private function appendAggregatorForm(FormBuilderInterface $builder, $nbAggregators) + private function appendAggregatorForm(FormBuilderInterface $builder, int $nbAggregators): void { $builder->add('order', ChoiceType::class, [ 'choices' => array_combine( diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/NationalityAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/NationalityAggregator.php index d7c4097af..b1bd7a085 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/NationalityAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/NationalityAggregator.php @@ -88,6 +88,7 @@ final class NationalityAggregator implements AggregatorInterface, ExportElementV public function applyOn() { + return 'abcde'; return 'person'; } @@ -103,6 +104,13 @@ final class NationalityAggregator implements AggregatorInterface, ExportElementV ]); } + public function getFormDefaultData(): array + { + return [ + 'group_by_level' => 'country', + ]; + } + public function getLabels($key, array $values, $data) { $labels = []; From 02afcb30d488f66e1cfe30eb0e90e5e5b730c667 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sun, 4 Jun 2023 01:11:38 +0200 Subject: [PATCH 152/724] [export][rector] first rector rule to add new method to filters --- .php-cs-fixer.dist.php | 1 + composer.json | 5 +- phpstan.neon.dist | 1 + phpunit.rector.xml | 29 +++ ...aultDataOnExportFilterAggregatorRector.php | 170 ++++++++++++++++++ ...DataOnExportFilterAggregatorRectorTest.php | 40 +++++ ...le-reuse-data-on-form-default-data.php.inc | 107 +++++++++++ .../Fixture/filter-no-data-on-builder.php.inc | 105 +++++++++++ ...er-reuse-data-on-form-default-data.php.inc | 96 ++++++++++ ...th-no-method-get-form-default-data.php.inc | 87 +++++++++ ...sting-get-form-default-data-method.php.inc | 46 +++++ .../config/config.php | 14 ++ 12 files changed, 700 insertions(+), 1 deletion(-) create mode 100644 phpunit.rector.xml create mode 100644 utils/rector/src/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector.php create mode 100644 utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRectorTest.php create mode 100644 utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/Fixture/filter-multiple-reuse-data-on-form-default-data.php.inc create mode 100644 utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/Fixture/filter-no-data-on-builder.php.inc create mode 100644 utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/Fixture/filter-reuse-data-on-form-default-data.php.inc create mode 100644 utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/Fixture/filter-with-no-method-get-form-default-data.php.inc create mode 100644 utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/Fixture/skip-filter-existing-get-form-default-data-method.php.inc create mode 100644 utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/config/config.php diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 4b5bf98ee..31d64e600 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -13,6 +13,7 @@ $finder = PhpCsFixer\Finder::create(); $finder ->in(__DIR__.'/src') + ->in(__DIR__.'/utils') ->append([__FILE__]) ->exclude(['docs/', 'tests/app']) ->notPath('tests/app') diff --git a/composer.json b/composer.json index f6d3eb27a..d3567bca0 100644 --- a/composer.json +++ b/composer.json @@ -67,6 +67,7 @@ "fakerphp/faker": "^1.13", "jangregor/phpstan-prophecy": "^1.0", "nelmio/alice": "^3.8", + "nikic/php-parser": "^4.15", "phpspec/prophecy-phpunit": "^2.0", "phpstan/extension-installer": "^1.2", "phpstan/phpstan": "^1.9", @@ -110,7 +111,9 @@ "psr-4": { "App\\": "tests/app/src/", "Chill\\DocGeneratorBundle\\Tests\\": "src/Bundle/ChillDocGeneratorBundle/tests", - "Chill\\WopiBundle\\Tests\\": "src/Bundle/ChillDocGeneratorBundle/tests" + "Chill\\WopiBundle\\Tests\\": "src/Bundle/ChillDocGeneratorBundle/tests", + "Utils\\Rector\\": "utils/rector/src", + "Utils\\Rector\\Tests\\": "utils/rector/tests" } }, "config": { diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 56b7c2228..62dbe0468 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -2,6 +2,7 @@ parameters: level: 5 paths: - src/ + - utils/ tmpDir: .cache/ reportUnmatchedIgnoredErrors: false excludePaths: diff --git a/phpunit.rector.xml b/phpunit.rector.xml new file mode 100644 index 000000000..f8d9d3a11 --- /dev/null +++ b/phpunit.rector.xml @@ -0,0 +1,29 @@ + + + + + utils/rector/tests + + + + + + utils/rector/src + + + diff --git a/utils/rector/src/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector.php b/utils/rector/src/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector.php new file mode 100644 index 000000000..c41ecfa91 --- /dev/null +++ b/utils/rector/src/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector.php @@ -0,0 +1,170 @@ +classAnalyzer->hasImplements($node, FilterInterface::class)) { + return null; + } + + $buildFormStmtIndex = null; + $hasGetFormDefaultDataMethod = false; + foreach ($node->stmts as $k => $stmt) { + if (!$stmt instanceof Node\Stmt\ClassMethod) { + continue; + } + + if ('buildForm' === $stmt->name->name) { + $buildFormStmtIndex = $k; + } + + if ('getFormDefaultData' === $stmt->name->name) { + $hasGetFormDefaultDataMethod = true; + } + } + + if ($hasGetFormDefaultDataMethod || null === $buildFormStmtIndex) { + return null; + } + + $stmtBefore = array_slice($node->stmts, 0, $buildFormStmtIndex, false); + $stmtAfter = array_slice($node->stmts, $buildFormStmtIndex + 1); + + // lines to satisfay phpstan parser + if (!$node->stmts[$buildFormStmtIndex] instanceof Node\Stmt\ClassMethod) { + throw new \LogicException(); + } + + ['build_form_method' => $buildFormMethod, 'empty_to_replace' => $emptyToReplace] + = $this->filterBuildFormMethod($node->stmts[$buildFormStmtIndex]); + + $node->stmts = [ + ...$stmtBefore, + $buildFormMethod, + $this->makeGetFormDefaultData($node->stmts[$buildFormStmtIndex], $emptyToReplace), + ...$stmtAfter, + ]; + + return $node; + } + + private function makeGetFormDefaultData(Node\Stmt\ClassMethod $buildFormMethod, array $emptyToReplace): Node\Stmt\ClassMethod + { + $method = new Node\Stmt\ClassMethod('getFormDefaultData'); + $method->flags = Node\Stmt\Class_::MODIFIER_PUBLIC; + $method->returnType = new Node\Identifier('array'); + + $data = new Node\Expr\Array_([]); + + foreach ($emptyToReplace as $key => $value) { + $item = new Node\Expr\ArrayItem($value, new Node\Scalar\String_($key)); + $data->items[] = $item; + } + + $method->stmts[] = new Node\Stmt\Return_($data); + + return $method; + } + + /** + * @param Node\Stmt\ClassMethod $buildFormMethod + * @return array{"build_form_method": Node\Stmt\ClassMethod, "empty_to_replace": array} + */ + private function filterBuildFormMethod(Node\Stmt\ClassMethod $buildFormMethod): array + { + $builderName = $buildFormMethod->params[0]->var->name; + + $newStmts = []; + $emptyDataToReplace = []; + + foreach ($buildFormMethod->stmts as $stmt) { + if ($stmt instanceof Node\Stmt\Expression + // it must be a method call + && $stmt->expr instanceof Node\Expr\MethodCall + // the method call must be "add" + && $stmt->expr->name instanceof Node\Identifier + && $stmt->expr->name->name === 'add' + // and the method call must apply on the builder (compare with builderName) + && $stmt->expr->var instanceof Node\Expr\Variable + && $stmt->expr->var->name === $builderName + // it must have a first argument, a string + // TODO what happens if a value, or a const ? + && ($stmt->expr->args[0] ?? null) instanceof Node\Arg + && $stmt->expr->args[0]->value instanceof Node\Scalar\String_ + // and a third argument, an array + && ($stmt->expr->args[2] ?? null) instanceof Node\Arg + && $stmt->expr->args[2]->value instanceof Node\Expr\Array_ + ) { + + // we parse on the 3rd argument, to find if there is an 'empty_data' key + $emptyDataIndex = null; + foreach ($stmt->expr->args[2]->value->items as $arrayItemIndex => $item) { + /* @phpstan-ignore-next-line */ + if ($item->key->value === 'data') { + $k = $stmt->expr->args[0]->value->value; + $emptyDataToReplace[$k] = $item->value; + $emptyDataIndex = $arrayItemIndex; + } + } + + if (null !== $emptyDataIndex) { + $stmt->expr->args[2]->value->items = array_values( + array_filter( + $stmt->expr->args[2]->value->items, + /* @phpstan-ignore-next-line */ + fn (Node\Expr\ArrayItem $item) => $item->key->value !== 'data' + ) + ); + } + + $newStmts[] = $stmt; + } else { + $newStmts[] = $stmt; + } + } + + $buildFormMethod->stmts = $newStmts; + + return ['build_form_method' => $buildFormMethod, "empty_to_replace" => $emptyDataToReplace]; + } +} diff --git a/utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRectorTest.php b/utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRectorTest.php new file mode 100644 index 000000000..800d2876f --- /dev/null +++ b/utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRectorTest.php @@ -0,0 +1,40 @@ +doTestFile($file); + } + + public function provideData(): \Iterator + { + return self::yieldFilesFromDirectory(__DIR__.'/Fixture'); + } + + public function provideConfigFilePath(): string + { + return __DIR__.'/config/config.php'; + } +} diff --git a/utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/Fixture/filter-multiple-reuse-data-on-form-default-data.php.inc b/utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/Fixture/filter-multiple-reuse-data-on-form-default-data.php.inc new file mode 100644 index 000000000..5429d3c82 --- /dev/null +++ b/utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/Fixture/filter-multiple-reuse-data-on-form-default-data.php.inc @@ -0,0 +1,107 @@ +add('foo', PickRollingDateType::class, [ + 'label' => 'Test thing', + 'data' => new RollingDate(RollingDate::T_TODAY) + ]); + + $builder->add('baz', TextType::class, [ + 'label' => 'OrNiCar', + 'data' => 'Castor' + ]); + } + + public function getTitle() + { + // TODO: Implement getTitle() method. + } + + public function addRole(): ?string + { + // TODO: Implement addRole() method. + } + + public function alterQuery(QueryBuilder $qb, $data) + { + // TODO: Implement alterQuery() method. + } + + public function applyOn() + { + // TODO: Implement applyOn() method. + } +} +?> +----- +add('foo', PickRollingDateType::class, [ + 'label' => 'Test thing' + ]); + + $builder->add('baz', TextType::class, [ + 'label' => 'OrNiCar' + ]); + } + public function getFormDefaultData(): array + { + return ['foo' => new RollingDate(RollingDate::T_TODAY), 'baz' => 'Castor']; + } + + public function getTitle() + { + // TODO: Implement getTitle() method. + } + + public function addRole(): ?string + { + // TODO: Implement addRole() method. + } + + public function alterQuery(QueryBuilder $qb, $data) + { + // TODO: Implement alterQuery() method. + } + + public function applyOn() + { + // TODO: Implement applyOn() method. + } +} +?> diff --git a/utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/Fixture/filter-no-data-on-builder.php.inc b/utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/Fixture/filter-no-data-on-builder.php.inc new file mode 100644 index 000000000..285c16b50 --- /dev/null +++ b/utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/Fixture/filter-no-data-on-builder.php.inc @@ -0,0 +1,105 @@ +add('foo', PickRollingDateType::class, [ + 'label' => 'Test thing', + ]); + + $builder->add('baz', TextType::class, [ + 'label' => 'OrNiCar', + ]); + } + + public function getTitle() + { + // TODO: Implement getTitle() method. + } + + public function addRole(): ?string + { + // TODO: Implement addRole() method. + } + + public function alterQuery(QueryBuilder $qb, $data) + { + // TODO: Implement alterQuery() method. + } + + public function applyOn() + { + // TODO: Implement applyOn() method. + } +} +?> +----- +add('foo', PickRollingDateType::class, [ + 'label' => 'Test thing', + ]); + + $builder->add('baz', TextType::class, [ + 'label' => 'OrNiCar', + ]); + } + public function getFormDefaultData(): array + { + return []; + } + + public function getTitle() + { + // TODO: Implement getTitle() method. + } + + public function addRole(): ?string + { + // TODO: Implement addRole() method. + } + + public function alterQuery(QueryBuilder $qb, $data) + { + // TODO: Implement alterQuery() method. + } + + public function applyOn() + { + // TODO: Implement applyOn() method. + } +} +?> diff --git a/utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/Fixture/filter-reuse-data-on-form-default-data.php.inc b/utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/Fixture/filter-reuse-data-on-form-default-data.php.inc new file mode 100644 index 000000000..b2e78e49c --- /dev/null +++ b/utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/Fixture/filter-reuse-data-on-form-default-data.php.inc @@ -0,0 +1,96 @@ +add('test', PickRollingDateType::class, [ + 'label' => 'Test thing', + 'data' => new RollingDate(RollingDate::T_TODAY) + ]); + } + + public function getTitle() + { + // TODO: Implement getTitle() method. + } + + public function addRole(): ?string + { + // TODO: Implement addRole() method. + } + + public function alterQuery(QueryBuilder $qb, $data) + { + // TODO: Implement alterQuery() method. + } + + public function applyOn() + { + // TODO: Implement applyOn() method. + } +} +?> +----- +add('test', PickRollingDateType::class, [ + 'label' => 'Test thing' + ]); + } + public function getFormDefaultData(): array + { + return ['test' => new RollingDate(RollingDate::T_TODAY)]; + } + + public function getTitle() + { + // TODO: Implement getTitle() method. + } + + public function addRole(): ?string + { + // TODO: Implement addRole() method. + } + + public function alterQuery(QueryBuilder $qb, $data) + { + // TODO: Implement alterQuery() method. + } + + public function applyOn() + { + // TODO: Implement applyOn() method. + } +} +?> diff --git a/utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/Fixture/filter-with-no-method-get-form-default-data.php.inc b/utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/Fixture/filter-with-no-method-get-form-default-data.php.inc new file mode 100644 index 000000000..687bd9d0c --- /dev/null +++ b/utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/Fixture/filter-with-no-method-get-form-default-data.php.inc @@ -0,0 +1,87 @@ + +----- + diff --git a/utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/Fixture/skip-filter-existing-get-form-default-data-method.php.inc b/utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/Fixture/skip-filter-existing-get-form-default-data-method.php.inc new file mode 100644 index 000000000..2fefc908d --- /dev/null +++ b/utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/Fixture/skip-filter-existing-get-form-default-data-method.php.inc @@ -0,0 +1,46 @@ +rule(\Utils\Rector\Rector\ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector::class); +}; From c8bab1218f04e58f3eb20c19ef9a4e61e9f6c88c Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Mon, 5 Jun 2023 10:01:35 +0200 Subject: [PATCH 153/724] FIX [filiation][validator] adjust validation condition --- .../Relationship/RelationshipNoDuplicateValidator.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Validator/Constraints/Relationship/RelationshipNoDuplicateValidator.php b/src/Bundle/ChillPersonBundle/Validator/Constraints/Relationship/RelationshipNoDuplicateValidator.php index b44a966cc..5b1038287 100644 --- a/src/Bundle/ChillPersonBundle/Validator/Constraints/Relationship/RelationshipNoDuplicateValidator.php +++ b/src/Bundle/ChillPersonBundle/Validator/Constraints/Relationship/RelationshipNoDuplicateValidator.php @@ -47,10 +47,12 @@ class RelationshipNoDuplicateValidator extends ConstraintValidator foreach ($relationships as $r) { if (spl_object_hash($r) !== spl_object_hash($value) - and $r->getFromPerson() === $fromPerson - || $r->getFromPerson() === $toPerson - || $r->getToPerson() === $fromPerson - || $r->getToPerson() === $toPerson + and + ( + ($r->getFromPerson() === $fromPerson and $r->getToPerson() === $toPerson) + || + ($r->getFromPerson() === $toPerson and $r->getToPerson() === $fromPerson) + ) ) { $this->context->buildViolation($constraint->message) ->addViolation(); From d5ee158caa43639f853b13d2d68368c9b90cf731 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 5 Jun 2023 16:41:55 +0200 Subject: [PATCH 154/724] [export][rector] rector rules to add get form default data on export, aggregator, direct export --- ...aultDataOnExportFilterAggregatorRector.php | 10 +- ...th-no-method-get-form-default-data.php.inc | 133 ++++++++++++++++++ ...th-no-method-get-form-default-data.php.inc | 77 ++++++++++ ...th-no-method-get-form-default-data.php.inc | 95 +++++++++++++ 4 files changed, 314 insertions(+), 1 deletion(-) create mode 100644 utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/Fixture/aggregator-with-no-method-get-form-default-data.php.inc create mode 100644 utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/Fixture/direct-export-with-no-method-get-form-default-data.php.inc create mode 100644 utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/Fixture/export-with-no-method-get-form-default-data.php.inc diff --git a/utils/rector/src/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector.php b/utils/rector/src/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector.php index c41ecfa91..5fe993180 100644 --- a/utils/rector/src/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector.php +++ b/utils/rector/src/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector.php @@ -11,6 +11,9 @@ declare(strict_types=1); namespace Utils\Rector\Rector; +use Chill\MainBundle\Export\AggregatorInterface; +use Chill\MainBundle\Export\DirectExportInterface; +use Chill\MainBundle\Export\ExportInterface; use Chill\MainBundle\Export\FilterInterface; use PhpParser\Node; use Rector\Core\Rector\AbstractRector; @@ -43,7 +46,12 @@ class ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector extends Abstra return null; } - if (!$this->classAnalyzer->hasImplements($node, FilterInterface::class)) { + if ( + !$this->classAnalyzer->hasImplements($node, FilterInterface::class) + && !$this->classAnalyzer->hasImplements($node, AggregatorInterface::class) + && !$this->classAnalyzer->hasImplements($node, ExportInterface::class) + && !$this->classAnalyzer->hasImplements($node, DirectExportInterface::class) + ) { return null; } diff --git a/utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/Fixture/aggregator-with-no-method-get-form-default-data.php.inc b/utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/Fixture/aggregator-with-no-method-get-form-default-data.php.inc new file mode 100644 index 000000000..aa373e629 --- /dev/null +++ b/utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/Fixture/aggregator-with-no-method-get-form-default-data.php.inc @@ -0,0 +1,133 @@ + +----- + diff --git a/utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/Fixture/direct-export-with-no-method-get-form-default-data.php.inc b/utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/Fixture/direct-export-with-no-method-get-form-default-data.php.inc new file mode 100644 index 000000000..d60f62dcb --- /dev/null +++ b/utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/Fixture/direct-export-with-no-method-get-form-default-data.php.inc @@ -0,0 +1,77 @@ + +----- + diff --git a/utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/Fixture/export-with-no-method-get-form-default-data.php.inc b/utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/Fixture/export-with-no-method-get-form-default-data.php.inc new file mode 100644 index 000000000..ba5a6d4ec --- /dev/null +++ b/utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/Fixture/export-with-no-method-get-form-default-data.php.inc @@ -0,0 +1,95 @@ + +----- + From ea77adc64043d1bc1581662e4aff8738139ab640 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 5 Jun 2023 16:47:45 +0200 Subject: [PATCH 155/724] [edit export] add required method on export's interface The method "getFormDefaultData" is applyied on every interface which will use it: - ExportInterface - AggregatorInterface - DirectExportInterface - FilterInterface The method buildForm is moved to those interfaces. [ci-skip] --- .../ChillMainBundle/Export/AggregatorInterface.php | 11 +++++++++++ .../ChillMainBundle/Export/DirectExportInterface.php | 11 +++++++++++ .../Export/ExportElementInterface.php | 4 ---- .../ChillMainBundle/Export/ExportInterface.php | 11 +++++++++++ .../ChillMainBundle/Export/FilterInterface.php | 12 ++++++++++++ .../ChillMainBundle/Export/FormatterInterface.php | 5 +++++ 6 files changed, 50 insertions(+), 4 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Export/AggregatorInterface.php b/src/Bundle/ChillMainBundle/Export/AggregatorInterface.php index 850d29838..8d805f612 100644 --- a/src/Bundle/ChillMainBundle/Export/AggregatorInterface.php +++ b/src/Bundle/ChillMainBundle/Export/AggregatorInterface.php @@ -12,6 +12,7 @@ declare(strict_types=1); namespace Chill\MainBundle\Export; use Closure; +use Symfony\Component\Form\FormBuilderInterface; /** * Interface for Aggregators. @@ -21,6 +22,16 @@ use Closure; */ interface AggregatorInterface extends ModifierInterface { + /** + * Add a form to collect data from the user. + */ + public function buildForm(FormBuilderInterface $builder); + + /** + * Get the default data, that can be use as "data" for the form + */ + public function getFormDefaultData(): array; + /** * get a callable which will be able to transform the results into * viewable and understable string. diff --git a/src/Bundle/ChillMainBundle/Export/DirectExportInterface.php b/src/Bundle/ChillMainBundle/Export/DirectExportInterface.php index 9703a42de..5bad5bb42 100644 --- a/src/Bundle/ChillMainBundle/Export/DirectExportInterface.php +++ b/src/Bundle/ChillMainBundle/Export/DirectExportInterface.php @@ -11,10 +11,21 @@ declare(strict_types=1); namespace Chill\MainBundle\Export; +use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\HttpFoundation\Response; interface DirectExportInterface extends ExportElementInterface { + /** + * Add a form to collect data from the user. + */ + public function buildForm(FormBuilderInterface $builder); + + /** + * Get the default data, that can be use as "data" for the form + */ + public function getFormDefaultData(): array; + /** * Generate the export. */ diff --git a/src/Bundle/ChillMainBundle/Export/ExportElementInterface.php b/src/Bundle/ChillMainBundle/Export/ExportElementInterface.php index 3b0402f42..b0441c829 100644 --- a/src/Bundle/ChillMainBundle/Export/ExportElementInterface.php +++ b/src/Bundle/ChillMainBundle/Export/ExportElementInterface.php @@ -19,10 +19,6 @@ use Symfony\Component\Form\FormBuilderInterface; */ interface ExportElementInterface { - /** - * Add a form to collect data from the user. - */ - public function buildForm(FormBuilderInterface $builder); /** * get a title, which will be used in UI (and translated). diff --git a/src/Bundle/ChillMainBundle/Export/ExportInterface.php b/src/Bundle/ChillMainBundle/Export/ExportInterface.php index d4e456ca6..f357a9fdb 100644 --- a/src/Bundle/ChillMainBundle/Export/ExportInterface.php +++ b/src/Bundle/ChillMainBundle/Export/ExportInterface.php @@ -13,6 +13,7 @@ namespace Chill\MainBundle\Export; use Doctrine\ORM\NativeQuery; use Doctrine\ORM\QueryBuilder; +use Symfony\Component\Form\FormBuilderInterface; /** * Interface for Export. @@ -28,6 +29,16 @@ use Doctrine\ORM\QueryBuilder; */ interface ExportInterface extends ExportElementInterface { + /** + * Add a form to collect data from the user. + */ + public function buildForm(FormBuilderInterface $builder); + + /** + * Get the default data, that can be use as "data" for the form + */ + public function getFormDefaultData(): array; + /** * Return which formatter type is allowed for this report. * diff --git a/src/Bundle/ChillMainBundle/Export/FilterInterface.php b/src/Bundle/ChillMainBundle/Export/FilterInterface.php index 5e398c30d..7db850108 100644 --- a/src/Bundle/ChillMainBundle/Export/FilterInterface.php +++ b/src/Bundle/ChillMainBundle/Export/FilterInterface.php @@ -11,6 +11,8 @@ declare(strict_types=1); namespace Chill\MainBundle\Export; +use Symfony\Component\Form\FormBuilderInterface; + /** * Interface for filters. * @@ -23,6 +25,16 @@ interface FilterInterface extends ModifierInterface { public const STRING_FORMAT = 'string'; + /** + * Add a form to collect data from the user. + */ + public function buildForm(FormBuilderInterface $builder); + + /** + * Get the default data, that can be use as "data" for the form + */ + public function getFormDefaultData(): array; + /** * Describe the filtering action. * diff --git a/src/Bundle/ChillMainBundle/Export/FormatterInterface.php b/src/Bundle/ChillMainBundle/Export/FormatterInterface.php index 1f9df225a..e939c47f2 100644 --- a/src/Bundle/ChillMainBundle/Export/FormatterInterface.php +++ b/src/Bundle/ChillMainBundle/Export/FormatterInterface.php @@ -34,6 +34,11 @@ interface FormatterInterface array $aggregatorAliases ); + /** + * get the default data for the form build by buildForm + */ + public function getFormDefaultData(array $aggregatorAliases): array; + public function getName(); /** From 3adf3625dc3cff44513eb08ab0b42804c0f4dfd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 5 Jun 2023 17:21:21 +0200 Subject: [PATCH 156/724] apply rector rules for exports --- docs/source/_static/code/exports/BirthdateFilter.php | 6 ++++-- docs/source/_static/code/exports/CountPerson.php | 4 ++++ rector.php | 3 +++ .../ACPAggregators/ByActivityNumberAggregator.php | 4 ++++ .../Aggregator/ACPAggregators/ByCreatorAggregator.php | 4 ++++ .../ACPAggregators/BySocialActionAggregator.php | 4 ++++ .../Aggregator/ACPAggregators/BySocialIssueAggregator.php | 4 ++++ .../Aggregator/ACPAggregators/ByThirdpartyAggregator.php | 4 ++++ .../Aggregator/ACPAggregators/CreatorScopeAggregator.php | 4 ++++ .../Export/Aggregator/ACPAggregators/DateAggregator.php | 5 ++++- .../Aggregator/ACPAggregators/LocationTypeAggregator.php | 4 ++++ .../Export/Aggregator/ActivityTypeAggregator.php | 4 ++++ .../Export/Aggregator/ActivityUserAggregator.php | 4 ++++ .../Export/Aggregator/ActivityUsersAggregator.php | 4 ++++ .../Export/Aggregator/ActivityUsersJobAggregator.php | 4 ++++ .../Export/Aggregator/ActivityUsersScopeAggregator.php | 4 ++++ .../PersonAggregators/ActivityReasonAggregator.php | 4 ++++ .../Export/Aggregator/SentReceivedAggregator.php | 4 ++++ .../Export/Export/LinkedToACP/AvgActivityDuration.php | 4 ++++ .../Export/LinkedToACP/AvgActivityVisitDuration.php | 4 ++++ .../Export/Export/LinkedToACP/CountActivity.php | 4 ++++ .../Export/Export/LinkedToACP/SumActivityDuration.php | 4 ++++ .../Export/LinkedToACP/SumActivityVisitDuration.php | 4 ++++ .../Export/Export/LinkedToPerson/CountActivity.php | 4 ++++ .../Export/Export/LinkedToPerson/StatActivityDuration.php | 4 ++++ .../Export/Filter/ACPFilters/ActivityTypeFilter.php | 4 ++++ .../Export/Filter/ACPFilters/ByCreatorFilter.php | 4 ++++ .../Export/Filter/ACPFilters/BySocialActionFilter.php | 4 ++++ .../Export/Filter/ACPFilters/BySocialIssueFilter.php | 4 ++++ .../Export/Filter/ACPFilters/EmergencyFilter.php | 5 ++++- .../Export/Filter/ACPFilters/HasNoActivityFilter.php | 4 ++++ .../Export/Filter/ACPFilters/LocationFilter.php | 4 ++++ .../Export/Filter/ACPFilters/LocationTypeFilter.php | 4 ++++ .../Export/Filter/ACPFilters/SentReceivedFilter.php | 5 ++++- .../Export/Filter/ACPFilters/UserFilter.php | 4 ++++ .../Export/Filter/ACPFilters/UserScopeFilter.php | 4 ++++ .../Export/Filter/ActivityDateFilter.php | 4 ++++ .../Export/Filter/ActivityTypeFilter.php | 4 ++++ .../Export/Filter/ActivityUsersFilter.php | 4 ++++ .../Export/Filter/PersonFilters/ActivityReasonFilter.php | 4 ++++ .../PersonHavingActivityBetweenDateFilter.php | 7 ++++--- .../ChillActivityBundle/Export/Filter/UsersJobFilter.php | 4 ++++ .../Export/Filter/UsersScopeFilter.php | 4 ++++ .../src/Export/Aggregator/ByActivityTypeAggregator.php | 4 ++++ .../src/Export/Aggregator/ByUserJobAggregator.php | 4 ++++ .../src/Export/Aggregator/ByUserScopeAggregator.php | 4 ++++ .../src/Export/Export/AvgAsideActivityDuration.php | 4 ++++ .../src/Export/Export/CountAsideActivity.php | 4 ++++ .../src/Export/Export/SumAsideActivityDuration.php | 4 ++++ .../src/Export/Filter/ByActivityTypeFilter.php | 4 ++++ .../src/Export/Filter/ByDateFilter.php | 4 ++++ .../src/Export/Filter/ByUserFilter.php | 4 ++++ .../src/Export/Filter/ByUserJobFilter.php | 4 ++++ .../src/Export/Filter/ByUserScopeFilter.php | 4 ++++ .../Export/Aggregator/AgentAggregator.php | 4 ++++ .../Export/Aggregator/CancelReasonAggregator.php | 4 ++++ .../Export/Aggregator/JobAggregator.php | 4 ++++ .../Export/Aggregator/LocationAggregator.php | 4 ++++ .../Export/Aggregator/LocationTypeAggregator.php | 4 ++++ .../Export/Aggregator/MonthYearAggregator.php | 4 ++++ .../Export/Aggregator/ScopeAggregator.php | 4 ++++ .../Export/Aggregator/UrgencyAggregator.php | 4 ++++ .../ChillCalendarBundle/Export/Export/CountCalendars.php | 4 ++++ .../Export/Export/StatCalendarAvgDuration.php | 4 ++++ .../Export/Export/StatCalendarSumDuration.php | 4 ++++ .../ChillCalendarBundle/Export/Filter/AgentFilter.php | 4 ++++ .../Export/Filter/BetweenDatesFilter.php | 4 ++++ .../Export/Filter/CalendarRangeFilter.php | 5 ++++- .../ChillCalendarBundle/Export/Filter/JobFilter.php | 4 ++++ .../ChillCalendarBundle/Export/Filter/ScopeFilter.php | 4 ++++ .../AdministrativeLocationAggregator.php | 4 ++++ .../ByActionNumberAggregator.php | 4 ++++ .../ClosingMotiveAggregator.php | 4 ++++ .../ConfidentialAggregator.php | 4 ++++ .../CreatorJobAggregator.php | 4 ++++ .../AccompanyingCourseAggregators/DurationAggregator.php | 4 ++++ .../AccompanyingCourseAggregators/EmergencyAggregator.php | 4 ++++ .../EvaluationAggregator.php | 4 ++++ .../GeographicalUnitStatAggregator.php | 4 ++++ .../AccompanyingCourseAggregators/IntensityAggregator.php | 4 ++++ .../AccompanyingCourseAggregators/OriginAggregator.php | 4 ++++ .../AccompanyingCourseAggregators/ReferrerAggregator.php | 5 ++++- .../ReferrerScopeAggregator.php | 5 ++++- .../AccompanyingCourseAggregators/RequestorAggregator.php | 4 ++++ .../AccompanyingCourseAggregators/ScopeAggregator.php | 4 ++++ .../SocialActionAggregator.php | 4 ++++ .../SocialIssueAggregator.php | 4 ++++ .../AccompanyingCourseAggregators/StepAggregator.php | 8 +++++--- .../AccompanyingCourseAggregators/UserJobAggregator.php | 4 ++++ .../EvaluationAggregators/ByEndDateAggregator.php | 5 ++++- .../EvaluationAggregators/ByMaxDateAggregator.php | 5 ++++- .../EvaluationAggregators/ByStartDateAggregator.php | 5 ++++- .../EvaluationAggregators/EvaluationTypeAggregator.php | 4 ++++ .../EvaluationAggregators/HavingEndDateAggregator.php | 4 ++++ .../HouseholdAggregators/ChildrenNumberAggregator.php | 8 +++++--- .../HouseholdAggregators/CompositionAggregator.php | 8 +++++--- .../Export/Aggregator/PersonAggregators/AgeAggregator.php | 5 ++++- .../ByHouseholdCompositionAggregator.php | 5 ++++- .../PersonAggregators/CountryOfBirthAggregator.php | 4 ++++ .../Aggregator/PersonAggregators/GenderAggregator.php | 4 ++++ .../PersonAggregators/GeographicalUnitAggregator.php | 4 ++++ .../PersonAggregators/HouseholdPositionAggregator.php | 5 ++++- .../SocialWorkAggregators/ActionTypeAggregator.php | 4 ++++ .../SocialWorkAggregators/CurrentActionAggregator.php | 4 ++++ .../Aggregator/SocialWorkAggregators/GoalAggregator.php | 4 ++++ .../SocialWorkAggregators/GoalResultAggregator.php | 4 ++++ .../Aggregator/SocialWorkAggregators/JobAggregator.php | 4 ++++ .../SocialWorkAggregators/ReferrerAggregator.php | 4 ++++ .../Aggregator/SocialWorkAggregators/ResultAggregator.php | 4 ++++ .../Aggregator/SocialWorkAggregators/ScopeAggregator.php | 4 ++++ .../Export/Export/CountAccompanyingCourse.php | 4 ++++ .../Export/Export/CountAccompanyingPeriodWork.php | 4 ++++ .../ChillPersonBundle/Export/Export/CountEvaluation.php | 4 ++++ .../ChillPersonBundle/Export/Export/CountHousehold.php | 5 ++++- .../Export/Export/CountPersonWithAccompanyingCourse.php | 4 ++++ .../Export/Export/ListPersonDuplicate.php | 5 ++++- .../Export/Export/StatAccompanyingCourseDuration.php | 5 ++++- .../AccompanyingCourseFilters/ActiveOnDateFilter.php | 8 +++++--- .../ActiveOneDayBetweenDatesFilter.php | 4 ++++ .../AdministrativeLocationFilter.php | 4 ++++ .../AccompanyingCourseFilters/ClosingMotiveFilter.php | 4 ++++ .../AccompanyingCourseFilters/ConfidentialFilter.php | 5 ++++- .../Filter/AccompanyingCourseFilters/CreatorFilter.php | 4 ++++ .../Filter/AccompanyingCourseFilters/CreatorJobFilter.php | 4 ++++ .../Filter/AccompanyingCourseFilters/EmergencyFilter.php | 5 ++++- .../Filter/AccompanyingCourseFilters/EvaluationFilter.php | 4 ++++ .../GeographicalUnitStatFilter.php | 4 ++++ .../AccompanyingCourseFilters/HasNoActionFilter.php | 4 ++++ .../AccompanyingCourseFilters/HasNoReferrerFilter.php | 5 ++++- .../HasTemporaryLocationFilter.php | 4 ++++ .../HavingAnAccompanyingPeriodInfoWithinDatesFilter.php | 4 ++++ .../Filter/AccompanyingCourseFilters/IntensityFilter.php | 5 ++++- .../AccompanyingCourseFilters/OpenBetweenDatesFilter.php | 4 ++++ .../Filter/AccompanyingCourseFilters/OriginFilter.php | 4 ++++ .../Filter/AccompanyingCourseFilters/ReferrerFilter.php | 4 ++++ .../Filter/AccompanyingCourseFilters/RequestorFilter.php | 5 ++++- .../AccompanyingCourseFilters/SocialActionFilter.php | 4 ++++ .../AccompanyingCourseFilters/SocialIssueFilter.php | 4 ++++ .../Filter/AccompanyingCourseFilters/StepFilter.php | 4 ++++ .../Filter/AccompanyingCourseFilters/UserJobFilter.php | 4 ++++ .../Filter/AccompanyingCourseFilters/UserScopeFilter.php | 4 ++++ .../UserWorkingOnCourseFilter.php | 4 ++++ .../Export/Filter/EvaluationFilters/ByEndDateFilter.php | 4 ++++ .../Export/Filter/EvaluationFilters/ByStartDateFilter.php | 4 ++++ .../Filter/EvaluationFilters/CurrentEvaluationsFilter.php | 4 ++++ .../Filter/EvaluationFilters/EvaluationTypeFilter.php | 4 ++++ .../Export/Filter/EvaluationFilters/MaxDateFilter.php | 4 ++++ .../Export/Filter/HouseholdFilters/CompositionFilter.php | 4 ++++ .../Filter/PersonFilters/AddressRefStatusFilter.php | 4 ++++ .../Export/Filter/PersonFilters/BirthdateFilter.php | 6 ++++-- .../Filter/PersonFilters/ByHouseholdCompositionFilter.php | 4 ++++ .../Export/Filter/PersonFilters/DeadOrAliveFilter.php | 5 ++++- .../Export/Filter/PersonFilters/DeathdateFilter.php | 6 ++++-- .../Export/Filter/PersonFilters/GenderFilter.php | 4 ++++ .../Filter/PersonFilters/GeographicalUnitFilter.php | 4 ++++ .../Export/Filter/PersonFilters/MaritalStatusFilter.php | 4 ++++ .../Export/Filter/PersonFilters/NationalityFilter.php | 4 ++++ .../ResidentialAddressAtThirdpartyFilter.php | 5 ++++- .../PersonFilters/ResidentialAddressAtUserFilter.php | 5 ++++- .../Filter/PersonFilters/WithoutHouseholdComposition.php | 5 ++++- .../AccompanyingPeriodWorkEndDateBetweenDateFilter.php | 4 ++++ .../AccompanyingPeriodWorkStartDateBetweenDateFilter.php | 4 ++++ .../Filter/SocialWorkFilters/CurrentActionFilter.php | 4 ++++ .../Export/Filter/SocialWorkFilters/JobFilter.php | 4 ++++ .../Export/Filter/SocialWorkFilters/ReferrerFilter.php | 4 ++++ .../Export/Filter/SocialWorkFilters/ScopeFilter.php | 4 ++++ .../Filter/SocialWorkFilters/SocialWorkTypeFilter.php | 4 ++++ .../ChillReportBundle/Export/Filter/ReportDateFilter.php | 6 ++++-- 168 files changed, 675 insertions(+), 47 deletions(-) diff --git a/docs/source/_static/code/exports/BirthdateFilter.php b/docs/source/_static/code/exports/BirthdateFilter.php index 64c1d53a9..e25d8b42f 100644 --- a/docs/source/_static/code/exports/BirthdateFilter.php +++ b/docs/source/_static/code/exports/BirthdateFilter.php @@ -62,7 +62,6 @@ class BirthdateFilter implements ExportElementValidatedInterface, FilterInterfac { $builder->add('date_from', DateType::class, [ 'label' => 'Born after this date', - 'data' => new DateTime(), 'attr' => ['class' => 'datepicker'], 'widget' => 'single_text', 'format' => 'dd-MM-yyyy', @@ -70,12 +69,15 @@ class BirthdateFilter implements ExportElementValidatedInterface, FilterInterfac $builder->add('date_to', DateType::class, [ 'label' => 'Born before this date', - 'data' => new DateTime(), 'attr' => ['class' => 'datepicker'], 'widget' => 'single_text', 'format' => 'dd-MM-yyyy', ]); } + public function getFormDefaultData(): array + { + return ['date_from' => new DateTime(), 'date_to' => new DateTime()]; + } // here, we create a simple string which will describe the action of // the filter in the Response diff --git a/docs/source/_static/code/exports/CountPerson.php b/docs/source/_static/code/exports/CountPerson.php index afe19c73b..be800e52c 100644 --- a/docs/source/_static/code/exports/CountPerson.php +++ b/docs/source/_static/code/exports/CountPerson.php @@ -36,6 +36,10 @@ class CountPerson implements ExportInterface { // this export does not add any form } + public function getFormDefaultData(): array + { + return []; + } public function getAllowedFormattersTypes() { diff --git a/rector.php b/rector.php index ec9a0c684..b65dc2a59 100644 --- a/rector.php +++ b/rector.php @@ -24,6 +24,9 @@ return static function (RectorConfig $rectorConfig): void { LevelSetList::UP_TO_PHP_74 ]); + // chill rules + $rectorConfig->rule(\Utils\Rector\Rector\ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector::class); + // skip some path... $rectorConfig->skip([ // make rector stuck for some files diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByActivityNumberAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByActivityNumberAggregator.php index 5c6656009..c23db738e 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByActivityNumberAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByActivityNumberAggregator.php @@ -40,6 +40,10 @@ class ByActivityNumberAggregator implements AggregatorInterface { // No form needed } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByCreatorAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByCreatorAggregator.php index 69149737b..917459de3 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByCreatorAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByCreatorAggregator.php @@ -52,6 +52,10 @@ class ByCreatorAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialActionAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialActionAggregator.php index 89732412d..1a75357ae 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialActionAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialActionAggregator.php @@ -57,6 +57,10 @@ class BySocialActionAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialIssueAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialIssueAggregator.php index 158e87664..9100a8c8f 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialIssueAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialIssueAggregator.php @@ -57,6 +57,10 @@ class BySocialIssueAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByThirdpartyAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByThirdpartyAggregator.php index c3ca6d59c..ac05b153c 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByThirdpartyAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByThirdpartyAggregator.php @@ -57,6 +57,10 @@ class ByThirdpartyAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/CreatorScopeAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/CreatorScopeAggregator.php index 2c7ec1483..a4b5258e2 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/CreatorScopeAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/CreatorScopeAggregator.php @@ -57,6 +57,10 @@ class CreatorScopeAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/DateAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/DateAggregator.php index b4b23dc0b..ea2fa5ee4 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/DateAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/DateAggregator.php @@ -84,9 +84,12 @@ class DateAggregator implements AggregatorInterface 'multiple' => false, 'expanded' => true, 'empty_data' => self::DEFAULT_CHOICE, - 'data' => self::DEFAULT_CHOICE, ]); } + public function getFormDefaultData(): array + { + return ['frequency' => self::DEFAULT_CHOICE]; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/LocationTypeAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/LocationTypeAggregator.php index ec4ce6315..c72609e2c 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/LocationTypeAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/LocationTypeAggregator.php @@ -57,6 +57,10 @@ class LocationTypeAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php index 7cd16718e..a74428b4a 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php @@ -60,6 +60,10 @@ class ActivityTypeAggregator implements AggregatorInterface { // no form required for this aggregator } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data): Closure { diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUserAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUserAggregator.php index 9bde692c6..2fab2af83 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUserAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUserAggregator.php @@ -58,6 +58,10 @@ class ActivityUserAggregator implements AggregatorInterface { // nothing to add } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, $values, $data): Closure { diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersAggregator.php index 139f2743e..e1e9f161d 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersAggregator.php @@ -56,6 +56,10 @@ class ActivityUsersAggregator implements AggregatorInterface { // nothing to add on the form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersJobAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersJobAggregator.php index 5741a0e58..721078989 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersJobAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersJobAggregator.php @@ -55,6 +55,10 @@ class ActivityUsersJobAggregator implements \Chill\MainBundle\Export\AggregatorI { // nothing to add in the form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersScopeAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersScopeAggregator.php index 15da300be..d7932e9e8 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersScopeAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersScopeAggregator.php @@ -55,6 +55,10 @@ class ActivityUsersScopeAggregator implements \Chill\MainBundle\Export\Aggregato { // nothing to add in the form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/PersonAggregators/ActivityReasonAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/PersonAggregators/ActivityReasonAggregator.php index eaccf95cb..2537f2cf6 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/PersonAggregators/ActivityReasonAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/PersonAggregators/ActivityReasonAggregator.php @@ -110,6 +110,10 @@ class ActivityReasonAggregator implements AggregatorInterface, ExportElementVali ] ); } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/SentReceivedAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/SentReceivedAggregator.php index 5f772e156..ae1dae375 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/SentReceivedAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/SentReceivedAggregator.php @@ -47,6 +47,10 @@ class SentReceivedAggregator implements AggregatorInterface { // No form needed } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data): callable { diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php index 34771d077..6930784d3 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php @@ -39,6 +39,10 @@ class AvgActivityDuration implements ExportInterface, GroupedExportInterface public function buildForm(FormBuilderInterface $builder) { } + public function getFormDefaultData(): array + { + return []; + } public function getAllowedFormattersTypes(): array { diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php index df21362cd..f1e926c64 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php @@ -40,6 +40,10 @@ class AvgActivityVisitDuration implements ExportInterface, GroupedExportInterfac { // TODO: Implement buildForm() method. } + public function getFormDefaultData(): array + { + return []; + } public function getAllowedFormattersTypes(): array { diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php index 6b7b1562d..d473a925a 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php @@ -39,6 +39,10 @@ class CountActivity implements ExportInterface, GroupedExportInterface public function buildForm(FormBuilderInterface $builder) { } + public function getFormDefaultData(): array + { + return []; + } public function getAllowedFormattersTypes(): array { diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php index e916cab54..8adb3b77f 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php @@ -40,6 +40,10 @@ class SumActivityDuration implements ExportInterface, GroupedExportInterface { // TODO: Implement buildForm() method. } + public function getFormDefaultData(): array + { + return []; + } public function getAllowedFormattersTypes(): array { diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php index 18a47289c..cc424e68b 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php @@ -40,6 +40,10 @@ class SumActivityVisitDuration implements ExportInterface, GroupedExportInterfac { // TODO: Implement buildForm() method. } + public function getFormDefaultData(): array + { + return []; + } public function getAllowedFormattersTypes(): array { diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/CountActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/CountActivity.php index 4246df173..6360251b3 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/CountActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/CountActivity.php @@ -35,6 +35,10 @@ class CountActivity implements ExportInterface, GroupedExportInterface public function buildForm(FormBuilderInterface $builder) { } + public function getFormDefaultData(): array + { + return []; + } public function getAllowedFormattersTypes() { diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/StatActivityDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/StatActivityDuration.php index 050034954..e68d47cd3 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/StatActivityDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/StatActivityDuration.php @@ -53,6 +53,10 @@ class StatActivityDuration implements ExportInterface, GroupedExportInterface public function buildForm(FormBuilderInterface $builder) { } + public function getFormDefaultData(): array + { + return []; + } public function getAllowedFormattersTypes() { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php index c6616a4c6..4ffc3b38c 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php @@ -68,6 +68,10 @@ class ActivityTypeFilter implements FilterInterface 'expanded' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ByCreatorFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ByCreatorFilter.php index 322393f32..add9c7c3d 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ByCreatorFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ByCreatorFilter.php @@ -52,6 +52,10 @@ class ByCreatorFilter implements FilterInterface 'multiple' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialActionFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialActionFilter.php index d0c1b0fc7..08f6bbbc3 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialActionFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialActionFilter.php @@ -60,6 +60,10 @@ class BySocialActionFilter implements FilterInterface 'multiple' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialIssueFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialIssueFilter.php index bbb882a65..bd6e2ef4a 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialIssueFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialIssueFilter.php @@ -60,6 +60,10 @@ class BySocialIssueFilter implements FilterInterface 'multiple' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/EmergencyFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/EmergencyFilter.php index b79c2ca10..807ba3903 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/EmergencyFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/EmergencyFilter.php @@ -68,9 +68,12 @@ class EmergencyFilter implements FilterInterface 'multiple' => false, 'expanded' => true, 'empty_data' => self::DEFAULT_CHOICE, - 'data' => self::DEFAULT_CHOICE, ]); } + public function getFormDefaultData(): array + { + return ['accepted_emergency' => self::DEFAULT_CHOICE]; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/HasNoActivityFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/HasNoActivityFilter.php index 570f42ae0..b5dab4009 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/HasNoActivityFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/HasNoActivityFilter.php @@ -44,6 +44,10 @@ class HasNoActivityFilter implements FilterInterface { //no form needed } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationFilter.php index 3d69d1633..312f3a6a0 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationFilter.php @@ -46,6 +46,10 @@ class LocationFilter implements FilterInterface 'label' => 'pick location', ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationTypeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationTypeFilter.php index 5fe928b6c..1c3415460 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationTypeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationTypeFilter.php @@ -65,6 +65,10 @@ class LocationTypeFilter implements FilterInterface //'label' => false, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/SentReceivedFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/SentReceivedFilter.php index 8daa7a781..0f2a1c7e4 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/SentReceivedFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/SentReceivedFilter.php @@ -69,9 +69,12 @@ class SentReceivedFilter implements FilterInterface 'multiple' => false, 'expanded' => true, 'empty_data' => self::DEFAULT_CHOICE, - 'data' => self::DEFAULT_CHOICE, ]); } + public function getFormDefaultData(): array + { + return ['accepted_sentreceived' => self::DEFAULT_CHOICE]; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserFilter.php index 6350f3ace..9ae988579 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserFilter.php @@ -61,6 +61,10 @@ class UserFilter implements FilterInterface 'label' => 'Creators', ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserScopeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserScopeFilter.php index 4319c100a..adb1e94f1 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserScopeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserScopeFilter.php @@ -71,6 +71,10 @@ class UserScopeFilter implements FilterInterface 'expanded' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityDateFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityDateFilter.php index f2216c929..d1e69fe28 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityDateFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityDateFilter.php @@ -127,6 +127,10 @@ class ActivityDateFilter implements FilterInterface } }); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php index b9d39c3ce..8dfcb543c 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php @@ -78,6 +78,10 @@ class ActivityTypeFilter implements ExportElementValidatedInterface, FilterInter ], ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityUsersFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityUsersFilter.php index 2f6cd8462..a63ca2629 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityUsersFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityUsersFilter.php @@ -56,6 +56,10 @@ class ActivityUsersFilter implements FilterInterface 'label' => 'Users', ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/ActivityReasonFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/ActivityReasonFilter.php index c55d579e4..31cfde6b6 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/ActivityReasonFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/ActivityReasonFilter.php @@ -82,6 +82,10 @@ class ActivityReasonFilter implements ExportElementValidatedInterface, FilterInt 'expanded' => false, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/PersonHavingActivityBetweenDateFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/PersonHavingActivityBetweenDateFilter.php index e3c85fe9c..490b5fd0c 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/PersonHavingActivityBetweenDateFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/PersonHavingActivityBetweenDateFilter.php @@ -112,7 +112,6 @@ class PersonHavingActivityBetweenDateFilter implements ExportElementValidatedInt { $builder->add('date_from', DateType::class, [ 'label' => 'Implied in an activity after this date', - 'data' => new DateTime(), 'attr' => ['class' => 'datepicker'], 'widget' => 'single_text', 'format' => 'dd-MM-yyyy', @@ -120,7 +119,6 @@ class PersonHavingActivityBetweenDateFilter implements ExportElementValidatedInt $builder->add('date_to', DateType::class, [ 'label' => 'Implied in an activity before this date', - 'data' => new DateTime(), 'attr' => ['class' => 'datepicker'], 'widget' => 'single_text', 'format' => 'dd-MM-yyyy', @@ -130,7 +128,6 @@ class PersonHavingActivityBetweenDateFilter implements ExportElementValidatedInt 'class' => ActivityReason::class, 'choice_label' => fn (ActivityReason $reason): ?string => $this->translatableStringHelper->localize($reason->getName()), 'group_by' => fn (ActivityReason $reason): ?string => $this->translatableStringHelper->localize($reason->getCategory()->getName()), - 'data' => $this->activityReasonRepository->findAll(), 'multiple' => true, 'expanded' => false, 'label' => 'Activity reasons for those activities', @@ -176,6 +173,10 @@ class PersonHavingActivityBetweenDateFilter implements ExportElementValidatedInt } }); } + public function getFormDefaultData(): array + { + return ['date_from' => new DateTime(), 'date_to' => new DateTime(), 'reasons' => $this->activityReasonRepository->findAll()]; + } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/UsersJobFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/UsersJobFilter.php index b52ef441c..e85b2d247 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/UsersJobFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/UsersJobFilter.php @@ -60,6 +60,10 @@ class UsersJobFilter implements FilterInterface 'expanded' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/UsersScopeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/UsersScopeFilter.php index 61b12264e..07ff509ce 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/UsersScopeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/UsersScopeFilter.php @@ -67,6 +67,10 @@ class UsersScopeFilter implements FilterInterface 'expanded' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByActivityTypeAggregator.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByActivityTypeAggregator.php index 32418e3c3..8ae43534d 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByActivityTypeAggregator.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByActivityTypeAggregator.php @@ -50,6 +50,10 @@ class ByActivityTypeAggregator implements AggregatorInterface { // No form needed } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserJobAggregator.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserJobAggregator.php index d2fe7c2f2..f09a704e2 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserJobAggregator.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserJobAggregator.php @@ -57,6 +57,10 @@ class ByUserJobAggregator implements AggregatorInterface { // nothing to add in the form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserScopeAggregator.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserScopeAggregator.php index 6c06ee756..3dd465db2 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserScopeAggregator.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserScopeAggregator.php @@ -57,6 +57,10 @@ class ByUserScopeAggregator implements AggregatorInterface { // nothing to add in the form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/AvgAsideActivityDuration.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/AvgAsideActivityDuration.php index f3db629cb..2b28062f6 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/AvgAsideActivityDuration.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/AvgAsideActivityDuration.php @@ -34,6 +34,10 @@ class AvgAsideActivityDuration implements ExportInterface, GroupedExportInterfac public function buildForm(FormBuilderInterface $builder) { } + public function getFormDefaultData(): array + { + return []; + } public function getAllowedFormattersTypes(): array { diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/CountAsideActivity.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/CountAsideActivity.php index 9204fad4b..91210f764 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/CountAsideActivity.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/CountAsideActivity.php @@ -34,6 +34,10 @@ class CountAsideActivity implements ExportInterface, GroupedExportInterface public function buildForm(FormBuilderInterface $builder) { } + public function getFormDefaultData(): array + { + return []; + } public function getAllowedFormattersTypes(): array { diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/SumAsideActivityDuration.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/SumAsideActivityDuration.php index af17a2591..741f129f1 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/SumAsideActivityDuration.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/SumAsideActivityDuration.php @@ -34,6 +34,10 @@ class SumAsideActivityDuration implements ExportInterface, GroupedExportInterfac public function buildForm(FormBuilderInterface $builder) { } + public function getFormDefaultData(): array + { + return []; + } public function getAllowedFormattersTypes(): array { diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByActivityTypeFilter.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByActivityTypeFilter.php index 3ad8e0e93..3d389f5b3 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByActivityTypeFilter.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByActivityTypeFilter.php @@ -76,6 +76,10 @@ class ByActivityTypeFilter implements FilterInterface }, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByDateFilter.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByDateFilter.php index 7a1b6f4dc..5019c3597 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByDateFilter.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByDateFilter.php @@ -119,6 +119,10 @@ class ByDateFilter implements FilterInterface } }); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserFilter.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserFilter.php index 795c813cd..2858d3417 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserFilter.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserFilter.php @@ -53,6 +53,10 @@ class ByUserFilter implements FilterInterface 'label' => 'Creators', ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserJobFilter.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserJobFilter.php index 86194b123..55f477768 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserJobFilter.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserJobFilter.php @@ -60,6 +60,10 @@ class ByUserJobFilter implements FilterInterface 'expanded' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserScopeFilter.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserScopeFilter.php index 4342e11eb..8fa51866d 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserScopeFilter.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserScopeFilter.php @@ -67,6 +67,10 @@ class ByUserScopeFilter implements FilterInterface 'expanded' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/AgentAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/AgentAggregator.php index e1de9f399..1b1b170b8 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/AgentAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/AgentAggregator.php @@ -58,6 +58,10 @@ final class AgentAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data): Closure { diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/CancelReasonAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/CancelReasonAggregator.php index 611cb6d79..a9967c470 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/CancelReasonAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/CancelReasonAggregator.php @@ -59,6 +59,10 @@ class CancelReasonAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data): Closure { diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/JobAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/JobAggregator.php index 23292a5b0..51291b49e 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/JobAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/JobAggregator.php @@ -58,6 +58,10 @@ final class JobAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data): Closure { diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationAggregator.php index 940000f47..952d0c5d5 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationAggregator.php @@ -52,6 +52,10 @@ final class LocationAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data): Closure { diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationTypeAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationTypeAggregator.php index 6574e3934..a9b369af0 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationTypeAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationTypeAggregator.php @@ -58,6 +58,10 @@ final class LocationTypeAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data): Closure { diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/MonthYearAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/MonthYearAggregator.php index 7b2a5e898..b3c2aaf19 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/MonthYearAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/MonthYearAggregator.php @@ -40,6 +40,10 @@ class MonthYearAggregator implements AggregatorInterface { // No form needed } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data): Closure { diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/ScopeAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/ScopeAggregator.php index 3aff3e0d8..01874b0e2 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/ScopeAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/ScopeAggregator.php @@ -58,6 +58,10 @@ final class ScopeAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data): Closure { diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/UrgencyAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/UrgencyAggregator.php index ad5910461..66ab8b42e 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/UrgencyAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/UrgencyAggregator.php @@ -56,6 +56,10 @@ class UrgencyAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data): Closure { diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php b/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php index 9d3f00f99..e0391948e 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php @@ -36,6 +36,10 @@ class CountCalendars implements ExportInterface, GroupedExportInterface { // No form necessary } + public function getFormDefaultData(): array + { + return []; + } public function getAllowedFormattersTypes(): array { diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php index 14dd42d6b..dcbfb695b 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php @@ -36,6 +36,10 @@ class StatCalendarAvgDuration implements ExportInterface, GroupedExportInterface { // no form needed } + public function getFormDefaultData(): array + { + return []; + } public function getAllowedFormattersTypes(): array { diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php index 1d31bfa26..7f509a896 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php @@ -36,6 +36,10 @@ class StatCalendarSumDuration implements ExportInterface, GroupedExportInterface { // no form needed } + public function getFormDefaultData(): array + { + return []; + } public function getAllowedFormattersTypes(): array { diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php index b58cee594..0cef89c20 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php @@ -63,6 +63,10 @@ class AgentFilter implements FilterInterface 'expanded' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/BetweenDatesFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/BetweenDatesFilter.php index 59019ac03..71dc95e60 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/BetweenDatesFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/BetweenDatesFilter.php @@ -67,6 +67,10 @@ class BetweenDatesFilter implements FilterInterface 'data' => new RollingDate(RollingDate::T_TODAY), ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/CalendarRangeFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/CalendarRangeFilter.php index d6c38e163..5ffb7c01f 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/CalendarRangeFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/CalendarRangeFilter.php @@ -69,9 +69,12 @@ class CalendarRangeFilter implements FilterInterface 'multiple' => false, 'expanded' => true, 'empty_data' => self::DEFAULT_CHOICE, - 'data' => self::DEFAULT_CHOICE, ]); } + public function getFormDefaultData(): array + { + return ['hasCalendarRange' => self::DEFAULT_CHOICE]; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php index 69fb24447..d02bb8e9d 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php @@ -76,6 +76,10 @@ class JobFilter implements FilterInterface 'expanded' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php index 08d9ae023..d8a40da72 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php @@ -76,6 +76,10 @@ class ScopeFilter implements FilterInterface 'expanded' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/AdministrativeLocationAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/AdministrativeLocationAggregator.php index 96deac574..56fdc07d7 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/AdministrativeLocationAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/AdministrativeLocationAggregator.php @@ -57,6 +57,10 @@ class AdministrativeLocationAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ByActionNumberAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ByActionNumberAggregator.php index 2dffccbbb..104b934ca 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ByActionNumberAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ByActionNumberAggregator.php @@ -39,6 +39,10 @@ class ByActionNumberAggregator implements AggregatorInterface { // No form needed } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregator.php index 342958361..73cfdc7b9 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregator.php @@ -52,6 +52,10 @@ class ClosingMotiveAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ConfidentialAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ConfidentialAggregator.php index e9b9e28fa..4ad18030e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ConfidentialAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ConfidentialAggregator.php @@ -48,6 +48,10 @@ class ConfidentialAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/CreatorJobAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/CreatorJobAggregator.php index c336a8887..5a060bcd7 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/CreatorJobAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/CreatorJobAggregator.php @@ -57,6 +57,10 @@ class CreatorJobAggregator implements AggregatorInterface { // No form needed } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/DurationAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/DurationAggregator.php index 0dc66e81e..581c7d6e5 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/DurationAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/DurationAggregator.php @@ -84,6 +84,10 @@ final class DurationAggregator implements AggregatorInterface 'expanded' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EmergencyAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EmergencyAggregator.php index 02f9f5cd9..4429c7b62 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EmergencyAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EmergencyAggregator.php @@ -48,6 +48,10 @@ class EmergencyAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EvaluationAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EvaluationAggregator.php index b6436efc0..119fa50b7 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EvaluationAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EvaluationAggregator.php @@ -61,6 +61,10 @@ final class EvaluationAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php index d001cbef7..22b21d352 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php @@ -133,6 +133,10 @@ final class GeographicalUnitStatAggregator implements AggregatorInterface 'expanded' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/IntensityAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/IntensityAggregator.php index a3618f40f..ac55d7734 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/IntensityAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/IntensityAggregator.php @@ -48,6 +48,10 @@ class IntensityAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/OriginAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/OriginAggregator.php index 37d0c7b20..1d01920d5 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/OriginAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/OriginAggregator.php @@ -59,6 +59,10 @@ final class OriginAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerAggregator.php index a09097fd2..7b826600a 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerAggregator.php @@ -81,11 +81,14 @@ final class ReferrerAggregator implements AggregatorInterface { $builder ->add('date_calc', PickRollingDateType::class, [ - 'data' => new RollingDate(RollingDate::T_TODAY), 'label' => 'export.aggregator.course.by_referrer.Computation date for referrer', 'required' => true, ]); } + public function getFormDefaultData(): array + { + return ['date_calc' => new RollingDate(RollingDate::T_TODAY)]; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerScopeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerScopeAggregator.php index ccbd21da1..adfd9b489 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerScopeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerScopeAggregator.php @@ -88,11 +88,14 @@ class ReferrerScopeAggregator implements AggregatorInterface public function buildForm(FormBuilderInterface $builder) { $builder->add('date_calc', PickRollingDateType::class, [ - 'data' => new RollingDate(RollingDate::T_TODAY), 'label' => 'export.aggregator.course.by_user_scope.Computation date for referrer', 'required' => true, ]); } + public function getFormDefaultData(): array + { + return ['date_calc' => new RollingDate(RollingDate::T_TODAY)]; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/RequestorAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/RequestorAggregator.php index 7b5cf0edd..3baf9bd33 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/RequestorAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/RequestorAggregator.php @@ -69,6 +69,10 @@ final class RequestorAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ScopeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ScopeAggregator.php index 8f34661bb..253727c89 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ScopeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ScopeAggregator.php @@ -57,6 +57,10 @@ final class ScopeAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialActionAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialActionAggregator.php index 3bdd6549e..b82b47ad0 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialActionAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialActionAggregator.php @@ -58,6 +58,10 @@ final class SocialActionAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialIssueAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialIssueAggregator.php index 12fa5a454..29fcba4a2 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialIssueAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialIssueAggregator.php @@ -58,6 +58,10 @@ final class SocialIssueAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/StepAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/StepAggregator.php index 85cfc3190..7632f72f0 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/StepAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/StepAggregator.php @@ -76,9 +76,11 @@ final class StepAggregator implements AggregatorInterface public function buildForm(FormBuilderInterface $builder) { - $builder->add('on_date', PickRollingDateType::class, [ - 'data' => new RollingDate(RollingDate::T_TODAY), - ]); + $builder->add('on_date', PickRollingDateType::class, []); + } + public function getFormDefaultData(): array + { + return ['on_date' => new RollingDate(RollingDate::T_TODAY)]; } public function getLabels($key, array $values, $data) diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/UserJobAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/UserJobAggregator.php index a8acdcf12..13d1e3f83 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/UserJobAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/UserJobAggregator.php @@ -57,6 +57,10 @@ final class UserJobAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByEndDateAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByEndDateAggregator.php index 2f4275c49..cb66fa600 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByEndDateAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByEndDateAggregator.php @@ -75,9 +75,12 @@ class ByEndDateAggregator implements AggregatorInterface 'multiple' => false, 'expanded' => true, 'empty_data' => self::DEFAULT_CHOICE, - 'data' => self::DEFAULT_CHOICE, ]); } + public function getFormDefaultData(): array + { + return ['frequency' => self::DEFAULT_CHOICE]; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByMaxDateAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByMaxDateAggregator.php index 9283fd9dc..af6dfc465 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByMaxDateAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByMaxDateAggregator.php @@ -75,9 +75,12 @@ class ByMaxDateAggregator implements AggregatorInterface 'multiple' => false, 'expanded' => true, 'empty_data' => self::DEFAULT_CHOICE, - 'data' => self::DEFAULT_CHOICE, ]); } + public function getFormDefaultData(): array + { + return ['frequency' => self::DEFAULT_CHOICE]; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByStartDateAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByStartDateAggregator.php index cd183b25e..87a6a672b 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByStartDateAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByStartDateAggregator.php @@ -75,9 +75,12 @@ class ByStartDateAggregator implements AggregatorInterface 'multiple' => false, 'expanded' => true, 'empty_data' => self::DEFAULT_CHOICE, - 'data' => self::DEFAULT_CHOICE, ]); } + public function getFormDefaultData(): array + { + return ['frequency' => self::DEFAULT_CHOICE]; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/EvaluationTypeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/EvaluationTypeAggregator.php index 0c13611cb..a48ed763d 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/EvaluationTypeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/EvaluationTypeAggregator.php @@ -52,6 +52,10 @@ class EvaluationTypeAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/HavingEndDateAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/HavingEndDateAggregator.php index e33bb326f..e710949fd 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/HavingEndDateAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/HavingEndDateAggregator.php @@ -48,6 +48,10 @@ class HavingEndDateAggregator implements AggregatorInterface { // No form needed } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/ChildrenNumberAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/ChildrenNumberAggregator.php index 0c9bc623f..1c5b3dc2c 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/ChildrenNumberAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/ChildrenNumberAggregator.php @@ -72,9 +72,11 @@ class ChildrenNumberAggregator implements AggregatorInterface public function buildForm(FormBuilderInterface $builder) { - $builder->add('on_date', PickRollingDateType::class, [ - 'data' => new RollingDate(RollingDate::T_TODAY), - ]); + $builder->add('on_date', PickRollingDateType::class, []); + } + public function getFormDefaultData(): array + { + return ['on_date' => new RollingDate(RollingDate::T_TODAY)]; } public function getLabels($key, array $values, $data) diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/CompositionAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/CompositionAggregator.php index 52bcd88e5..62fc20173 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/CompositionAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/CompositionAggregator.php @@ -77,9 +77,11 @@ class CompositionAggregator implements AggregatorInterface public function buildForm(FormBuilderInterface $builder) { - $builder->add('on_date', PickRollingDateType::class, [ - 'data' => new RollingDate(RollingDate::T_TODAY), - ]); + $builder->add('on_date', PickRollingDateType::class, []); + } + public function getFormDefaultData(): array + { + return ['on_date' => new RollingDate(RollingDate::T_TODAY)]; } public function getLabels($key, array $values, $data) diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/AgeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/AgeAggregator.php index 365a73704..2a63e475a 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/AgeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/AgeAggregator.php @@ -50,12 +50,15 @@ final class AgeAggregator implements AggregatorInterface, ExportElementValidated { $builder->add('date_age_calculation', DateType::class, [ 'label' => 'Calculate age in relation to this date', - 'data' => new DateTime(), 'attr' => ['class' => 'datepicker'], 'widget' => 'single_text', 'format' => 'dd-MM-yyyy', ]); } + public function getFormDefaultData(): array + { + return ['date_age_calculation' => new DateTime()]; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/ByHouseholdCompositionAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/ByHouseholdCompositionAggregator.php index 80f0faa17..16b62c2b5 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/ByHouseholdCompositionAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/ByHouseholdCompositionAggregator.php @@ -94,9 +94,12 @@ class ByHouseholdCompositionAggregator implements AggregatorInterface { $builder->add('date_calc', PickRollingDateType::class, [ 'label' => 'export.aggregator.person.by_household_composition.Calc date', - 'data' => new RollingDate(RollingDate::T_TODAY), ]); } + public function getFormDefaultData(): array + { + return ['date_calc' => new RollingDate(RollingDate::T_TODAY)]; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/CountryOfBirthAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/CountryOfBirthAggregator.php index 3d785b586..90882245e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/CountryOfBirthAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/CountryOfBirthAggregator.php @@ -108,6 +108,10 @@ final class CountryOfBirthAggregator implements AggregatorInterface, ExportEleme 'multiple' => false, ]); } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GenderAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GenderAggregator.php index f76420047..dbe3d19d3 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GenderAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GenderAggregator.php @@ -48,6 +48,10 @@ final class GenderAggregator implements AggregatorInterface public function buildForm(FormBuilderInterface $builder) { } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GeographicalUnitAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GeographicalUnitAggregator.php index 5d73c1fdd..6c6ed340f 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GeographicalUnitAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GeographicalUnitAggregator.php @@ -105,6 +105,10 @@ class GeographicalUnitAggregator implements AggregatorInterface 'expanded' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public static function getDefaultAlias(): string { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/HouseholdPositionAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/HouseholdPositionAggregator.php index 107634803..63d84d4da 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/HouseholdPositionAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/HouseholdPositionAggregator.php @@ -90,9 +90,12 @@ final class HouseholdPositionAggregator implements AggregatorInterface, ExportEl { $builder->add('date_position', PickRollingDateType::class, [ 'label' => 'Household position in relation to this date', - 'data' => new RollingDate(RollingDate::T_TODAY), ]); } + public function getFormDefaultData(): array + { + return ['date_position' => new RollingDate(RollingDate::T_TODAY)]; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregator.php index c1fccb968..66c87d94f 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregator.php @@ -75,6 +75,10 @@ final class ActionTypeAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CurrentActionAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CurrentActionAggregator.php index 58fcb2874..539c9f286 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CurrentActionAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CurrentActionAggregator.php @@ -51,6 +51,10 @@ class CurrentActionAggregator implements AggregatorInterface { // No form needed } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalAggregator.php index 8cc6a25da..4c0e8b393 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalAggregator.php @@ -55,6 +55,10 @@ final class GoalAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalResultAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalResultAggregator.php index 17b263d7e..c99ee85ea 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalResultAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalResultAggregator.php @@ -68,6 +68,10 @@ class GoalResultAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/JobAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/JobAggregator.php index cbf07091f..8271c90e3 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/JobAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/JobAggregator.php @@ -57,6 +57,10 @@ final class JobAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ReferrerAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ReferrerAggregator.php index 0fe53b707..047504224 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ReferrerAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ReferrerAggregator.php @@ -57,6 +57,10 @@ final class ReferrerAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ResultAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ResultAggregator.php index 2e46673da..3cce7b283 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ResultAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ResultAggregator.php @@ -55,6 +55,10 @@ final class ResultAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ScopeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ScopeAggregator.php index 243263b83..0828b5d0d 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ScopeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ScopeAggregator.php @@ -57,6 +57,10 @@ final class ScopeAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php b/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php index 978f88a10..75583dfa0 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php @@ -39,6 +39,10 @@ class CountAccompanyingCourse implements ExportInterface, GroupedExportInterface { // Nothing to add here } + public function getFormDefaultData(): array + { + return []; + } public function getAllowedFormattersTypes(): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingPeriodWork.php b/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingPeriodWork.php index 122ee14d9..8a035bdcd 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingPeriodWork.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingPeriodWork.php @@ -38,6 +38,10 @@ class CountAccompanyingPeriodWork implements ExportInterface, GroupedExportInter { // No form necessary? } + public function getFormDefaultData(): array + { + return []; + } public function getAllowedFormattersTypes(): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php b/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php index 1613b63d3..3de433e2e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php @@ -37,6 +37,10 @@ class CountEvaluation implements ExportInterface, GroupedExportInterface { // TODO: Implement buildForm() method. } + public function getFormDefaultData(): array + { + return []; + } public function getAllowedFormattersTypes(): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php b/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php index 0b693b9d8..05e32fde6 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php @@ -46,11 +46,14 @@ class CountHousehold implements ExportInterface, GroupedExportInterface { $builder ->add('calc_date', PickRollingDateType::class, [ - 'data' => new RollingDate(RollingDate::T_TODAY), 'label' => self::TR_PREFIX . 'Date of calculation of household members', 'required' => false, ]); } + public function getFormDefaultData(): array + { + return ['calc_date' => new RollingDate(RollingDate::T_TODAY)]; + } public function getAllowedFormattersTypes(): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountPersonWithAccompanyingCourse.php b/src/Bundle/ChillPersonBundle/Export/Export/CountPersonWithAccompanyingCourse.php index e52cc83b1..ae7238d4e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountPersonWithAccompanyingCourse.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountPersonWithAccompanyingCourse.php @@ -39,6 +39,10 @@ class CountPersonWithAccompanyingCourse implements ExportInterface, GroupedExpor { // TODO: Implement buildForm() method. } + public function getFormDefaultData(): array + { + return []; + } public function getAllowedFormattersTypes(): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListPersonDuplicate.php b/src/Bundle/ChillPersonBundle/Export/Export/ListPersonDuplicate.php index e40ffccce..e7c105604 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListPersonDuplicate.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListPersonDuplicate.php @@ -74,9 +74,12 @@ class ListPersonDuplicate implements DirectExportInterface, ExportElementValidat { $builder->add('precision', NumberType::class, [ 'label' => 'Precision', - 'data' => self::PRECISION_DEFAULT_VALUE, ]); } + public function getFormDefaultData(): array + { + return ['precision' => self::PRECISION_DEFAULT_VALUE]; + } public function generate(array $acl, array $data = []): Response { diff --git a/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php b/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php index 31ca41cbb..66b47131d 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php @@ -41,9 +41,12 @@ class StatAccompanyingCourseDuration implements ExportInterface, GroupedExportIn { $builder->add('closingdate', ChillDateType::class, [ 'label' => 'Closingdate to apply', - 'data' => new DateTime('now'), ]); } + public function getFormDefaultData(): array + { + return ['closingdate' => new DateTime('now')]; + } public function getAllowedFormattersTypes(): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOnDateFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOnDateFilter.php index 3fa8d711f..fcb4d67fb 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOnDateFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOnDateFilter.php @@ -67,9 +67,11 @@ class ActiveOnDateFilter implements FilterInterface public function buildForm(FormBuilderInterface $builder) { $builder - ->add('on_date', PickRollingDateType::class, [ - 'data' => new RollingDate(RollingDate::T_TODAY), - ]); + ->add('on_date', PickRollingDateType::class, []); + } + public function getFormDefaultData(): array + { + return ['on_date' => new RollingDate(RollingDate::T_TODAY)]; } public function describeAction($data, $format = 'string'): array diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOneDayBetweenDatesFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOneDayBetweenDatesFilter.php index f713e8a97..f693a6d04 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOneDayBetweenDatesFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOneDayBetweenDatesFilter.php @@ -63,6 +63,10 @@ class ActiveOneDayBetweenDatesFilter implements FilterInterface 'data' => new RollingDate(RollingDate::T_TODAY), ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/AdministrativeLocationFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/AdministrativeLocationFilter.php index c74e309b2..aa1abb36e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/AdministrativeLocationFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/AdministrativeLocationFilter.php @@ -53,6 +53,10 @@ class AdministrativeLocationFilter implements FilterInterface 'multiple' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ClosingMotiveFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ClosingMotiveFilter.php index e57370f30..153b2ecbd 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ClosingMotiveFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ClosingMotiveFilter.php @@ -64,6 +64,10 @@ class ClosingMotiveFilter implements FilterInterface 'expanded' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ConfidentialFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ConfidentialFilter.php index 8fcd874fe..b9db9f439 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ConfidentialFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ConfidentialFilter.php @@ -67,9 +67,12 @@ class ConfidentialFilter implements FilterInterface 'multiple' => false, 'expanded' => true, 'empty_data' => self::DEFAULT_CHOICE, - 'data' => self::DEFAULT_CHOICE, ]); } + public function getFormDefaultData(): array + { + return ['accepted_confidentials' => self::DEFAULT_CHOICE]; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorFilter.php index b13947e60..8a8a24013 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorFilter.php @@ -50,6 +50,10 @@ class CreatorFilter implements FilterInterface 'label' => false, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorJobFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorJobFilter.php index f585cfafb..5faeb850f 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorJobFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorJobFilter.php @@ -69,6 +69,10 @@ class CreatorJobFilter implements FilterInterface 'label' => 'Job', ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EmergencyFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EmergencyFilter.php index afdb717f0..6fc60f6e9 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EmergencyFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EmergencyFilter.php @@ -67,9 +67,12 @@ class EmergencyFilter implements FilterInterface 'multiple' => false, 'expanded' => true, 'empty_data' => self::DEFAULT_CHOICE, - 'data' => self::DEFAULT_CHOICE, ]); } + public function getFormDefaultData(): array + { + return ['accepted_emergency' => self::DEFAULT_CHOICE]; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EvaluationFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EvaluationFilter.php index ab7f4257e..a6fb3583d 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EvaluationFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EvaluationFilter.php @@ -75,6 +75,10 @@ class EvaluationFilter implements FilterInterface 'attr' => ['class' => 'select2'], ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php index d35565c80..b4ffed280 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php @@ -114,6 +114,10 @@ class GeographicalUnitStatFilter implements FilterInterface 'multiple' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasNoActionFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasNoActionFilter.php index 54c28d027..4820116c0 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasNoActionFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasNoActionFilter.php @@ -38,6 +38,10 @@ class HasNoActionFilter implements FilterInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasNoReferrerFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasNoReferrerFilter.php index 4c682a56a..6d01ea7c2 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasNoReferrerFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasNoReferrerFilter.php @@ -65,9 +65,12 @@ class HasNoReferrerFilter implements FilterInterface $builder ->add('calc_date', PickRollingDateType::class, [ 'label' => 'Has no referrer on this date', - 'data' => new RollingDate(RollingDate::T_TODAY), ]); } + public function getFormDefaultData(): array + { + return ['calc_date' => new RollingDate(RollingDate::T_TODAY)]; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasTemporaryLocationFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasTemporaryLocationFilter.php index 615ace4c6..f9b2f2bd6 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasTemporaryLocationFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasTemporaryLocationFilter.php @@ -95,6 +95,10 @@ class HasTemporaryLocationFilter implements FilterInterface 'data' => new RollingDate(RollingDate::T_TODAY), ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HavingAnAccompanyingPeriodInfoWithinDatesFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HavingAnAccompanyingPeriodInfoWithinDatesFilter.php index 7069a1d80..cdc771b19 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HavingAnAccompanyingPeriodInfoWithinDatesFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HavingAnAccompanyingPeriodInfoWithinDatesFilter.php @@ -46,6 +46,10 @@ final readonly class HavingAnAccompanyingPeriodInfoWithinDatesFilter implements ]) ; } + public function getFormDefaultData(): array + { + return []; + } public function getTitle(): string { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/IntensityFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/IntensityFilter.php index b0c2205a0..1fd05d2b4 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/IntensityFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/IntensityFilter.php @@ -67,9 +67,12 @@ class IntensityFilter implements FilterInterface 'multiple' => false, 'expanded' => true, 'empty_data' => self::DEFAULT_CHOICE, - 'data' => self::DEFAULT_CHOICE, ]); } + public function getFormDefaultData(): array + { + return ['accepted_intensities' => self::DEFAULT_CHOICE]; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OpenBetweenDatesFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OpenBetweenDatesFilter.php index 07ca1de75..ebbec06a4 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OpenBetweenDatesFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OpenBetweenDatesFilter.php @@ -61,6 +61,10 @@ class OpenBetweenDatesFilter implements FilterInterface 'data' => new RollingDate(RollingDate::T_TODAY), ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OriginFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OriginFilter.php index 00febc640..8395c79f8 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OriginFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OriginFilter.php @@ -64,6 +64,10 @@ class OriginFilter implements FilterInterface 'expanded' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ReferrerFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ReferrerFilter.php index 2a3e5d17e..daf0d83a4 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ReferrerFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ReferrerFilter.php @@ -82,6 +82,10 @@ class ReferrerFilter implements FilterInterface 'required' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/RequestorFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/RequestorFilter.php index 3295a5b57..614889c27 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/RequestorFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/RequestorFilter.php @@ -126,9 +126,12 @@ final class RequestorFilter implements FilterInterface 'multiple' => false, 'expanded' => true, 'empty_data' => self::DEFAULT_CHOICE, - 'data' => self::DEFAULT_CHOICE, ]); } + public function getFormDefaultData(): array + { + return ['accepted_choices' => self::DEFAULT_CHOICE]; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php index bc1f368da..0c14ba73a 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php @@ -70,6 +70,10 @@ class SocialActionFilter implements FilterInterface 'multiple' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php index 917e129bf..a793bc548 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php @@ -69,6 +69,10 @@ class SocialIssueFilter implements FilterInterface 'multiple' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/StepFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/StepFilter.php index 8ee798c07..993ebe301 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/StepFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/StepFilter.php @@ -102,6 +102,10 @@ class StepFilter implements FilterInterface 'data' => new RollingDate(RollingDate::T_TODAY), ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserJobFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserJobFilter.php index 05d84d7b2..cb70fb78b 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserJobFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserJobFilter.php @@ -101,6 +101,10 @@ class UserJobFilter implements FilterInterface 'required' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserScopeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserScopeFilter.php index bbffa4bca..580c8e334 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserScopeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserScopeFilter.php @@ -105,6 +105,10 @@ class UserScopeFilter implements FilterInterface 'required' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserWorkingOnCourseFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserWorkingOnCourseFilter.php index 586bb645d..d078443af 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserWorkingOnCourseFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserWorkingOnCourseFilter.php @@ -42,6 +42,10 @@ readonly class UserWorkingOnCourseFilter implements FilterInterface 'multiple' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function getTitle(): string { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/ByEndDateFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/ByEndDateFilter.php index de86604e6..c0e9c4a99 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/ByEndDateFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/ByEndDateFilter.php @@ -64,6 +64,10 @@ class ByEndDateFilter implements FilterInterface 'data' => new RollingDate(RollingDate::T_TODAY), ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/ByStartDateFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/ByStartDateFilter.php index 27518599c..a40becbad 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/ByStartDateFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/ByStartDateFilter.php @@ -64,6 +64,10 @@ class ByStartDateFilter implements FilterInterface 'data' => new RollingDate(RollingDate::T_TODAY), ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/CurrentEvaluationsFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/CurrentEvaluationsFilter.php index 140f6c3cb..8841c7b9e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/CurrentEvaluationsFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/CurrentEvaluationsFilter.php @@ -37,6 +37,10 @@ class CurrentEvaluationsFilter implements FilterInterface { //no form needed } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/EvaluationTypeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/EvaluationTypeFilter.php index 6a0c71d55..77bae1b56 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/EvaluationTypeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/EvaluationTypeFilter.php @@ -64,6 +64,10 @@ final class EvaluationTypeFilter implements FilterInterface 'expanded' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/MaxDateFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/MaxDateFilter.php index 4a65452a1..daa7d1954 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/MaxDateFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/MaxDateFilter.php @@ -61,6 +61,10 @@ class MaxDateFilter implements FilterInterface 'expanded' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/HouseholdFilters/CompositionFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/HouseholdFilters/CompositionFilter.php index 22761c158..a89236159 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/HouseholdFilters/CompositionFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/HouseholdFilters/CompositionFilter.php @@ -88,6 +88,10 @@ class CompositionFilter implements FilterInterface 'data' => new RollingDate(RollingDate::T_TODAY), ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AddressRefStatusFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AddressRefStatusFilter.php index 7580a37a3..cf777e08d 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AddressRefStatusFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AddressRefStatusFilter.php @@ -87,6 +87,10 @@ class AddressRefStatusFilter implements \Chill\MainBundle\Export\FilterInterface 'data' => [Address::ADDR_REFERENCE_STATUS_TO_REVIEW] ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/BirthdateFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/BirthdateFilter.php index 7ae22ddd8..9a0478b6c 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/BirthdateFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/BirthdateFilter.php @@ -71,14 +71,16 @@ class BirthdateFilter implements ExportElementValidatedInterface, FilterInterfac { $builder->add('date_from', PickRollingDateType::class, [ 'label' => 'Born after this date', - 'data' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START), ]); $builder->add('date_to', PickRollingDateType::class, [ 'label' => 'Born before this date', - 'data' => new RollingDate(RollingDate::T_TODAY), ]); } + public function getFormDefaultData(): array + { + return ['date_from' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START), 'date_to' => new RollingDate(RollingDate::T_TODAY)]; + } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ByHouseholdCompositionFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ByHouseholdCompositionFilter.php index 9b59549f1..d7adb5cd9 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ByHouseholdCompositionFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ByHouseholdCompositionFilter.php @@ -89,6 +89,10 @@ class ByHouseholdCompositionFilter implements FilterInterface 'data' => new RollingDate(RollingDate::T_TODAY), ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/DeadOrAliveFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/DeadOrAliveFilter.php index 384d6698a..8b2444ca2 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/DeadOrAliveFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/DeadOrAliveFilter.php @@ -102,9 +102,12 @@ class DeadOrAliveFilter implements FilterInterface $builder->add('date_calc', PickRollingDateType::class, [ 'label' => 'Filter in relation to this date', - 'data' => new RollingDate(RollingDate::T_TODAY), ]); } + public function getFormDefaultData(): array + { + return ['date_calc' => new RollingDate(RollingDate::T_TODAY)]; + } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/DeathdateFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/DeathdateFilter.php index 0ac4b3173..7805331a5 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/DeathdateFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/DeathdateFilter.php @@ -72,14 +72,16 @@ class DeathdateFilter implements ExportElementValidatedInterface, FilterInterfac { $builder->add('date_from', PickRollingDateType::class, [ 'label' => 'Death after this date', - 'data' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START), ]); $builder->add('date_to', PickRollingDateType::class, [ 'label' => 'Deathdate before', - 'data' => new RollingDate(RollingDate::T_TODAY), ]); } + public function getFormDefaultData(): array + { + return ['date_from' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START), 'date_to' => new RollingDate(RollingDate::T_TODAY)]; + } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GenderFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GenderFilter.php index 739945b98..182006bbc 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GenderFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GenderFilter.php @@ -89,6 +89,10 @@ class GenderFilter implements 'expanded' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GeographicalUnitFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GeographicalUnitFilter.php index 79f5cb2d4..7efeca49e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GeographicalUnitFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GeographicalUnitFilter.php @@ -105,6 +105,10 @@ class GeographicalUnitFilter implements \Chill\MainBundle\Export\FilterInterface 'multiple' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/MaritalStatusFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/MaritalStatusFilter.php index 47a75871c..021c22fc6 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/MaritalStatusFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/MaritalStatusFilter.php @@ -56,6 +56,10 @@ class MaritalStatusFilter implements FilterInterface 'expanded' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/NationalityFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/NationalityFilter.php index b1d77d60e..e5102128b 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/NationalityFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/NationalityFilter.php @@ -67,6 +67,10 @@ class NationalityFilter implements 'placeholder' => 'Choose countries', ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php index 21bb40947..8f22750a5 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php @@ -107,9 +107,12 @@ class ResidentialAddressAtThirdpartyFilter implements FilterInterface $builder->add('date_calc', PickRollingDateType::class, [ 'label' => 'Date during which residential address was valid', - 'data' => new RollingDate(RollingDate::T_TODAY), ]); } + public function getFormDefaultData(): array + { + return ['date_calc' => new RollingDate(RollingDate::T_TODAY)]; + } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtUserFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtUserFilter.php index bd55c5b80..62b142420 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtUserFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtUserFilter.php @@ -82,9 +82,12 @@ class ResidentialAddressAtUserFilter implements FilterInterface { $builder->add('date_calc', PickRollingDateType::class, [ 'label' => 'Date during which residential address was valid', - 'data' => new RollingDate(RollingDate::T_TODAY), ]); } + public function getFormDefaultData(): array + { + return ['date_calc' => new RollingDate(RollingDate::T_TODAY)]; + } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/WithoutHouseholdComposition.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/WithoutHouseholdComposition.php index c4644fc11..9f5ed90b5 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/WithoutHouseholdComposition.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/WithoutHouseholdComposition.php @@ -66,9 +66,12 @@ class WithoutHouseholdComposition implements FilterInterface $builder ->add('calc_date', PickRollingDateType::class, [ 'label' => 'export.filter.person.by_no_composition.Date calc', - 'data' => new RollingDate(RollingDate::T_TODAY), ]); } + public function getFormDefaultData(): array + { + return ['calc_date' => new RollingDate(RollingDate::T_TODAY)]; + } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/AccompanyingPeriodWorkEndDateBetweenDateFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/AccompanyingPeriodWorkEndDateBetweenDateFilter.php index b13c49e9a..45d86bc97 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/AccompanyingPeriodWorkEndDateBetweenDateFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/AccompanyingPeriodWorkEndDateBetweenDateFilter.php @@ -44,6 +44,10 @@ final readonly class AccompanyingPeriodWorkEndDateBetweenDateFilter implements F ]) ; } + public function getFormDefaultData(): array + { + return []; + } public function getTitle(): string { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/AccompanyingPeriodWorkStartDateBetweenDateFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/AccompanyingPeriodWorkStartDateBetweenDateFilter.php index e9526a9a5..f4a914203 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/AccompanyingPeriodWorkStartDateBetweenDateFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/AccompanyingPeriodWorkStartDateBetweenDateFilter.php @@ -44,6 +44,10 @@ final readonly class AccompanyingPeriodWorkStartDateBetweenDateFilter implements ]) ; } + public function getFormDefaultData(): array + { + return []; + } public function getTitle(): string { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CurrentActionFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CurrentActionFilter.php index cbdb64d8d..e99590025 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CurrentActionFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CurrentActionFilter.php @@ -37,6 +37,10 @@ class CurrentActionFilter implements FilterInterface { //no form } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/JobFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/JobFilter.php index 144bf3260..265c8e24d 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/JobFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/JobFilter.php @@ -76,6 +76,10 @@ class JobFilter implements FilterInterface 'expanded' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ReferrerFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ReferrerFilter.php index 8d0da32fb..bddcfbf9b 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ReferrerFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ReferrerFilter.php @@ -57,6 +57,10 @@ class ReferrerFilter implements FilterInterface 'multiple' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ScopeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ScopeFilter.php index 315025722..737759c3e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ScopeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ScopeFilter.php @@ -76,6 +76,10 @@ class ScopeFilter implements FilterInterface 'expanded' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/SocialWorkTypeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/SocialWorkTypeFilter.php index 11fd0ed9d..25bfc17a0 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/SocialWorkTypeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/SocialWorkTypeFilter.php @@ -110,6 +110,10 @@ class SocialWorkTypeFilter implements FilterInterface $this->iterableToIdTransformer(Result::class) ); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillReportBundle/Export/Filter/ReportDateFilter.php b/src/Bundle/ChillReportBundle/Export/Filter/ReportDateFilter.php index 79bad4f52..cb8e7d1d0 100644 --- a/src/Bundle/ChillReportBundle/Export/Filter/ReportDateFilter.php +++ b/src/Bundle/ChillReportBundle/Export/Filter/ReportDateFilter.php @@ -67,14 +67,16 @@ class ReportDateFilter implements FilterInterface { $builder->add('date_from', PickRollingDateType::class, [ 'label' => 'Report is after this date', - 'data' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START), ]); $builder->add('date_to', PickRollingDateType::class, [ 'label' => 'Report is before this date', - 'data' => new RollingDate(RollingDate::T_TODAY), ]); } + public function getFormDefaultData(): array + { + return ['date_from' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START), 'date_to' => new RollingDate(RollingDate::T_TODAY)]; + } public function describeAction($data, $format = 'string') { From 933e9f75b3035bc575f6d2fbd6246f064af977cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 5 Jun 2023 17:21:43 +0200 Subject: [PATCH 157/724] publish namespace to every app using this package --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index d3567bca0..4ff7349d7 100644 --- a/composer.json +++ b/composer.json @@ -104,7 +104,8 @@ "Chill\\ReportBundle\\": "src/Bundle/ChillReportBundle", "Chill\\TaskBundle\\": "src/Bundle/ChillTaskBundle", "Chill\\ThirdPartyBundle\\": "src/Bundle/ChillThirdPartyBundle", - "Chill\\WopiBundle\\": "src/Bundle/ChillWopiBundle/src" + "Chill\\WopiBundle\\": "src/Bundle/ChillWopiBundle/src", + "Utils\\Rector\\": "utils/rector/src" } }, "autoload-dev": { @@ -112,7 +113,6 @@ "App\\": "tests/app/src/", "Chill\\DocGeneratorBundle\\Tests\\": "src/Bundle/ChillDocGeneratorBundle/tests", "Chill\\WopiBundle\\Tests\\": "src/Bundle/ChillDocGeneratorBundle/tests", - "Utils\\Rector\\": "utils/rector/src", "Utils\\Rector\\Tests\\": "utils/rector/tests" } }, From 73bc95306ec7d1bee95fb5985fd292755d543dc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 5 Jun 2023 17:29:37 +0200 Subject: [PATCH 158/724] move rector rules to a shareable namespace --- composer.json | 4 ++-- ...BundleAddFormDefaultDataOnExportFilterAggregatorRector.php | 2 +- ...leAddFormDefaultDataOnExportFilterAggregatorRectorTest.php | 2 +- .../config/config.php | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 4ff7349d7..a128b1b77 100644 --- a/composer.json +++ b/composer.json @@ -105,7 +105,7 @@ "Chill\\TaskBundle\\": "src/Bundle/ChillTaskBundle", "Chill\\ThirdPartyBundle\\": "src/Bundle/ChillThirdPartyBundle", "Chill\\WopiBundle\\": "src/Bundle/ChillWopiBundle/src", - "Utils\\Rector\\": "utils/rector/src" + "Chill\\Utils\\Rector\\": "utils/rector/src" } }, "autoload-dev": { @@ -113,7 +113,7 @@ "App\\": "tests/app/src/", "Chill\\DocGeneratorBundle\\Tests\\": "src/Bundle/ChillDocGeneratorBundle/tests", "Chill\\WopiBundle\\Tests\\": "src/Bundle/ChillDocGeneratorBundle/tests", - "Utils\\Rector\\Tests\\": "utils/rector/tests" + "Chill\\Utils\\Rector\\Tests\\": "utils/rector/tests" } }, "config": { diff --git a/utils/rector/src/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector.php b/utils/rector/src/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector.php index 5fe993180..a6a375088 100644 --- a/utils/rector/src/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector.php +++ b/utils/rector/src/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector.php @@ -9,7 +9,7 @@ declare(strict_types=1); * the LICENSE file that was distributed with this source code. */ -namespace Utils\Rector\Rector; +namespace Chill\Utils\Rector\Rector; use Chill\MainBundle\Export\AggregatorInterface; use Chill\MainBundle\Export\DirectExportInterface; diff --git a/utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRectorTest.php b/utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRectorTest.php index 800d2876f..89606e970 100644 --- a/utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRectorTest.php +++ b/utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRectorTest.php @@ -9,7 +9,7 @@ declare(strict_types=1); * the LICENSE file that was distributed with this source code. */ -namespace Utils\Rector\Tests\ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector; +namespace Chill\Utils\Rector\Tests\ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; diff --git a/utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/config/config.php b/utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/config/config.php index d8b63bfd5..b59504c84 100644 --- a/utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/config/config.php +++ b/utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/config/config.php @@ -10,5 +10,5 @@ declare(strict_types=1); */ return static function (\Rector\Config\RectorConfig $rectorConfig): void { - $rectorConfig->rule(\Utils\Rector\Rector\ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector::class); + $rectorConfig->rule(\Chill\Utils\Rector\Rector\ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector::class); }; From f10c50231fa8a6a1f0c5f8f1d04902fa0db3ac1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 5 Jun 2023 17:40:19 +0200 Subject: [PATCH 159/724] apply rector rules on list interfaces --- ...aultDataOnExportFilterAggregatorRector.php | 2 + ...th-no-method-get-form-default-data.php.inc | 135 ++++++++++++++++++ 2 files changed, 137 insertions(+) create mode 100644 utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/Fixture/list-with-no-method-get-form-default-data.php.inc diff --git a/utils/rector/src/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector.php b/utils/rector/src/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector.php index a6a375088..237aa17b8 100644 --- a/utils/rector/src/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector.php +++ b/utils/rector/src/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector.php @@ -15,6 +15,7 @@ use Chill\MainBundle\Export\AggregatorInterface; use Chill\MainBundle\Export\DirectExportInterface; use Chill\MainBundle\Export\ExportInterface; use Chill\MainBundle\Export\FilterInterface; +use Chill\MainBundle\Export\ListInterface; use PhpParser\Node; use Rector\Core\Rector\AbstractRector; use Rector\Symfony\NodeAnalyzer\ClassAnalyzer; @@ -51,6 +52,7 @@ class ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector extends Abstra && !$this->classAnalyzer->hasImplements($node, AggregatorInterface::class) && !$this->classAnalyzer->hasImplements($node, ExportInterface::class) && !$this->classAnalyzer->hasImplements($node, DirectExportInterface::class) + && !$this->classAnalyzer->hasImplements($node, ListInterface::class) ) { return null; } diff --git a/utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/Fixture/list-with-no-method-get-form-default-data.php.inc b/utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/Fixture/list-with-no-method-get-form-default-data.php.inc new file mode 100644 index 000000000..99cea7155 --- /dev/null +++ b/utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/Fixture/list-with-no-method-get-form-default-data.php.inc @@ -0,0 +1,135 @@ + +----- + From db142217293430bdf4a19e6f11b07ad71de7c02f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 5 Jun 2023 17:42:37 +0200 Subject: [PATCH 160/724] fix cs --- src/Bundle/ChillMainBundle/Export/ExportElementInterface.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Bundle/ChillMainBundle/Export/ExportElementInterface.php b/src/Bundle/ChillMainBundle/Export/ExportElementInterface.php index b0441c829..b8cca4ed0 100644 --- a/src/Bundle/ChillMainBundle/Export/ExportElementInterface.php +++ b/src/Bundle/ChillMainBundle/Export/ExportElementInterface.php @@ -19,7 +19,6 @@ use Symfony\Component\Form\FormBuilderInterface; */ interface ExportElementInterface { - /** * get a title, which will be used in UI (and translated). * From 938027cc1e7fbd3f0f2268fb98a8975f23046b5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 5 Jun 2023 17:54:00 +0200 Subject: [PATCH 161/724] apply fixes for list --- .../Export/Export/LinkedToACP/ListActivity.php | 4 ++++ .../Export/Export/LinkedToPerson/ListActivity.php | 4 ++++ .../src/Export/Export/ListAsideActivity.php | 4 ++++ .../ChillMainBundle/Export/Formatter/CSVListFormatter.php | 8 +++++++- .../Export/Formatter/CSVPivotedListFormatter.php | 6 +++++- .../Export/Formatter/SpreadsheetListFormatter.php | 6 +++++- .../Export/Export/ListAccompanyingPeriod.php | 4 ++++ .../Export/Export/ListAccompanyingPeriodWork.php | 5 ++++- .../ChillPersonBundle/Export/Export/ListEvaluation.php | 5 ++++- .../Export/Export/ListHouseholdInPeriod.php | 5 ++++- src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php | 6 ++++-- .../Export/Export/ListPersonWithAccompanyingPeriod.php | 6 ++++-- src/Bundle/ChillReportBundle/Export/Export/ReportList.php | 5 ++++- 13 files changed, 57 insertions(+), 11 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php index 026e16f90..9ed6bcda2 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php @@ -44,6 +44,10 @@ class ListActivity implements ListInterface, GroupedExportInterface { $this->helper->buildForm($builder); } + public function getFormDefaultData(): array + { + return []; + } public function getAllowedFormattersTypes() { diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php index 60110c9a8..d14111ba7 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php @@ -88,6 +88,10 @@ class ListActivity implements ListInterface, GroupedExportInterface ])], ]); } + public function getFormDefaultData(): array + { + return []; + } public function getAllowedFormattersTypes() { diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/ListAsideActivity.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/ListAsideActivity.php index aee168174..b46e120b5 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/ListAsideActivity.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/ListAsideActivity.php @@ -73,6 +73,10 @@ final class ListAsideActivity implements ListInterface, GroupedExportInterface public function buildForm(FormBuilderInterface $builder) { } + public function getFormDefaultData(): array + { + return []; + } public function getAllowedFormattersTypes() { diff --git a/src/Bundle/ChillMainBundle/Export/Formatter/CSVListFormatter.php b/src/Bundle/ChillMainBundle/Export/Formatter/CSVListFormatter.php index b84c80118..70d80b74b 100644 --- a/src/Bundle/ChillMainBundle/Export/Formatter/CSVListFormatter.php +++ b/src/Bundle/ChillMainBundle/Export/Formatter/CSVListFormatter.php @@ -85,10 +85,16 @@ class CSVListFormatter implements FormatterInterface 'expanded' => true, 'multiple' => false, 'label' => 'Add a number on first column', - 'data' => true, ]); } + public function getFormDefaultData(array $aggregatorAliases): array + { + return ['numerotation' => true]; + } + + + public function getName() { return 'CSV vertical list'; diff --git a/src/Bundle/ChillMainBundle/Export/Formatter/CSVPivotedListFormatter.php b/src/Bundle/ChillMainBundle/Export/Formatter/CSVPivotedListFormatter.php index 63d691443..cce0fa1e4 100644 --- a/src/Bundle/ChillMainBundle/Export/Formatter/CSVPivotedListFormatter.php +++ b/src/Bundle/ChillMainBundle/Export/Formatter/CSVPivotedListFormatter.php @@ -80,10 +80,14 @@ class CSVPivotedListFormatter implements FormatterInterface 'expanded' => true, 'multiple' => false, 'label' => 'Add a number on first column', - 'data' => true, ]); } + public function getFormDefaultData(array $aggregatorAliases): array + { + return ['numerotation' => true]; + } + public function getName() { return 'CSV horizontal list'; diff --git a/src/Bundle/ChillMainBundle/Export/Formatter/SpreadsheetListFormatter.php b/src/Bundle/ChillMainBundle/Export/Formatter/SpreadsheetListFormatter.php index 0e5e339ea..34960d8d2 100644 --- a/src/Bundle/ChillMainBundle/Export/Formatter/SpreadsheetListFormatter.php +++ b/src/Bundle/ChillMainBundle/Export/Formatter/SpreadsheetListFormatter.php @@ -104,10 +104,14 @@ class SpreadsheetListFormatter implements FormatterInterface 'expanded' => true, 'multiple' => false, 'label' => 'Add a number on first column', - 'data' => true, ]); } + public function getFormDefaultData(array $aggregatorAliases): array + { + return ['format' => 'xlsx', 'numerotation' => true]; + } + public function getName() { return 'Spreadsheet list formatter (.xlsx, .ods)'; diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php index 0647460dd..e5e724b6c 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php @@ -144,6 +144,10 @@ class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface 'required' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function getAllowedFormattersTypes() { diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriodWork.php b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriodWork.php index 00fa8adb1..c437454c2 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriodWork.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriodWork.php @@ -135,9 +135,12 @@ class ListAccompanyingPeriodWork implements ListInterface, GroupedExportInterfac 'label' => 'export.list.acpw.Date of calculation for associated elements', 'help' => 'export.list.acpw.help_description', 'required' => true, - 'data' => new RollingDate(RollingDate::T_TODAY), ]); } + public function getFormDefaultData(): array + { + return ['calc_date' => new RollingDate(RollingDate::T_TODAY)]; + } public function getAllowedFormattersTypes() { diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListEvaluation.php b/src/Bundle/ChillPersonBundle/Export/Export/ListEvaluation.php index f0985436b..c3e273733 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListEvaluation.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListEvaluation.php @@ -123,9 +123,12 @@ class ListEvaluation implements ListInterface, GroupedExportInterface 'label' => 'export.list.eval.Date of calculation for associated elements', 'help' => 'export.list.eval.help_description', 'required' => true, - 'data' => new RollingDate(RollingDate::T_TODAY), ]); } + public function getFormDefaultData(): array + { + return ['calc_date' => new RollingDate(RollingDate::T_TODAY)]; + } public function getAllowedFormattersTypes() { diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListHouseholdInPeriod.php b/src/Bundle/ChillPersonBundle/Export/Export/ListHouseholdInPeriod.php index 8894d145d..4dcc89495 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListHouseholdInPeriod.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListHouseholdInPeriod.php @@ -75,10 +75,13 @@ class ListHouseholdInPeriod implements ListInterface, GroupedExportInterface ->add('calc_date', PickRollingDateType::class, [ 'label' => 'export.list.household.Date of calculation for associated elements', 'help' => 'export.list.household.help_description', - 'data' => new RollingDate(RollingDate::T_TODAY), 'required' => true, ]); } + public function getFormDefaultData(): array + { + return ['calc_date' => new RollingDate(RollingDate::T_TODAY)]; + } public function getAllowedFormattersTypes() { diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php b/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php index 8145fd658..12fb0ce5d 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php @@ -107,17 +107,19 @@ class ListPerson implements ExportElementValidatedInterface, ListInterface, Grou } }, ])], - 'data' => array_values($choices), ]); // add a date field for addresses $builder->add('address_date', ChillDateType::class, [ 'label' => 'Data valid at this date', 'help' => 'Data regarding center, addresses, and so on will be computed at this date', - 'data' => new DateTimeImmutable(), 'input' => 'datetime_immutable', ]); } + public function getFormDefaultData(): array + { + return ['fields' => array_values($choices), 'address_date' => new DateTimeImmutable()]; + } public function getAllowedFormattersTypes() { diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriod.php index 7cb066e87..fbdc7f391 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriod.php @@ -80,17 +80,19 @@ class ListPersonWithAccompanyingPeriod implements ExportElementValidatedInterfac } }, ])], - 'data' => array_values($choices), ]); // add a date field for addresses $builder->add('address_date', ChillDateType::class, [ 'label' => 'Data valid at this date', 'help' => 'Data regarding center, addresses, and so on will be computed at this date', - 'data' => new DateTimeImmutable(), 'input' => 'datetime_immutable', ]); } + public function getFormDefaultData(): array + { + return ['fields' => array_values($choices), 'address_date' => new DateTimeImmutable()]; + } public function getAllowedFormattersTypes() { diff --git a/src/Bundle/ChillReportBundle/Export/Export/ReportList.php b/src/Bundle/ChillReportBundle/Export/Export/ReportList.php index 9adae0097..c551bfb11 100644 --- a/src/Bundle/ChillReportBundle/Export/Export/ReportList.php +++ b/src/Bundle/ChillReportBundle/Export/Export/ReportList.php @@ -137,11 +137,14 @@ class ReportList implements ExportElementValidatedInterface, ListInterface // add a date field for addresses $builder->add('address_date', ChillDateType::class, [ 'label' => 'Address valid at this date', - 'data' => new DateTime(), 'required' => false, 'block_name' => 'list_export_form_address_date', ]); } + public function getFormDefaultData(): array + { + return ['address_date' => new DateTime()]; + } public function getAllowedFormattersTypes() { From cc30c81fd7eb18e7258b95dc7adfef14f78b6a73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 5 Jun 2023 17:54:25 +0200 Subject: [PATCH 162/724] change chill rule namespace --- rector.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rector.php b/rector.php index b65dc2a59..c2e752c32 100644 --- a/rector.php +++ b/rector.php @@ -25,7 +25,7 @@ return static function (RectorConfig $rectorConfig): void { ]); // chill rules - $rectorConfig->rule(\Utils\Rector\Rector\ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector::class); + $rectorConfig->rule(\Chill\Utils\Rector\Rector\ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector::class); // skip some path... $rectorConfig->skip([ From fb1b28407a190b3b743622357348e5937693adef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 5 Jun 2023 17:21:43 +0200 Subject: [PATCH 163/724] publish namespace to every app using this package --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index d3567bca0..4ff7349d7 100644 --- a/composer.json +++ b/composer.json @@ -104,7 +104,8 @@ "Chill\\ReportBundle\\": "src/Bundle/ChillReportBundle", "Chill\\TaskBundle\\": "src/Bundle/ChillTaskBundle", "Chill\\ThirdPartyBundle\\": "src/Bundle/ChillThirdPartyBundle", - "Chill\\WopiBundle\\": "src/Bundle/ChillWopiBundle/src" + "Chill\\WopiBundle\\": "src/Bundle/ChillWopiBundle/src", + "Utils\\Rector\\": "utils/rector/src" } }, "autoload-dev": { @@ -112,7 +113,6 @@ "App\\": "tests/app/src/", "Chill\\DocGeneratorBundle\\Tests\\": "src/Bundle/ChillDocGeneratorBundle/tests", "Chill\\WopiBundle\\Tests\\": "src/Bundle/ChillDocGeneratorBundle/tests", - "Utils\\Rector\\": "utils/rector/src", "Utils\\Rector\\Tests\\": "utils/rector/tests" } }, From 1e8fec5cbd67fc1dd7d7970d5041f079651a49e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 5 Jun 2023 17:29:37 +0200 Subject: [PATCH 164/724] move rector rules to a shareable namespace --- composer.json | 4 ++-- ...BundleAddFormDefaultDataOnExportFilterAggregatorRector.php | 2 +- ...leAddFormDefaultDataOnExportFilterAggregatorRectorTest.php | 2 +- .../config/config.php | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 4ff7349d7..a128b1b77 100644 --- a/composer.json +++ b/composer.json @@ -105,7 +105,7 @@ "Chill\\TaskBundle\\": "src/Bundle/ChillTaskBundle", "Chill\\ThirdPartyBundle\\": "src/Bundle/ChillThirdPartyBundle", "Chill\\WopiBundle\\": "src/Bundle/ChillWopiBundle/src", - "Utils\\Rector\\": "utils/rector/src" + "Chill\\Utils\\Rector\\": "utils/rector/src" } }, "autoload-dev": { @@ -113,7 +113,7 @@ "App\\": "tests/app/src/", "Chill\\DocGeneratorBundle\\Tests\\": "src/Bundle/ChillDocGeneratorBundle/tests", "Chill\\WopiBundle\\Tests\\": "src/Bundle/ChillDocGeneratorBundle/tests", - "Utils\\Rector\\Tests\\": "utils/rector/tests" + "Chill\\Utils\\Rector\\Tests\\": "utils/rector/tests" } }, "config": { diff --git a/utils/rector/src/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector.php b/utils/rector/src/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector.php index 5fe993180..a6a375088 100644 --- a/utils/rector/src/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector.php +++ b/utils/rector/src/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector.php @@ -9,7 +9,7 @@ declare(strict_types=1); * the LICENSE file that was distributed with this source code. */ -namespace Utils\Rector\Rector; +namespace Chill\Utils\Rector\Rector; use Chill\MainBundle\Export\AggregatorInterface; use Chill\MainBundle\Export\DirectExportInterface; diff --git a/utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRectorTest.php b/utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRectorTest.php index 800d2876f..89606e970 100644 --- a/utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRectorTest.php +++ b/utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRectorTest.php @@ -9,7 +9,7 @@ declare(strict_types=1); * the LICENSE file that was distributed with this source code. */ -namespace Utils\Rector\Tests\ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector; +namespace Chill\Utils\Rector\Tests\ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector; use Rector\Testing\PHPUnit\AbstractRectorTestCase; use Symplify\SmartFileSystem\SmartFileInfo; diff --git a/utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/config/config.php b/utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/config/config.php index d8b63bfd5..b59504c84 100644 --- a/utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/config/config.php +++ b/utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/config/config.php @@ -10,5 +10,5 @@ declare(strict_types=1); */ return static function (\Rector\Config\RectorConfig $rectorConfig): void { - $rectorConfig->rule(\Utils\Rector\Rector\ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector::class); + $rectorConfig->rule(\Chill\Utils\Rector\Rector\ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector::class); }; From 1a037180143db51be3d72caa483e9cc029415c38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 5 Jun 2023 17:42:37 +0200 Subject: [PATCH 165/724] fix cs --- src/Bundle/ChillMainBundle/Export/ExportElementInterface.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Bundle/ChillMainBundle/Export/ExportElementInterface.php b/src/Bundle/ChillMainBundle/Export/ExportElementInterface.php index b0441c829..b8cca4ed0 100644 --- a/src/Bundle/ChillMainBundle/Export/ExportElementInterface.php +++ b/src/Bundle/ChillMainBundle/Export/ExportElementInterface.php @@ -19,7 +19,6 @@ use Symfony\Component\Form\FormBuilderInterface; */ interface ExportElementInterface { - /** * get a title, which will be used in UI (and translated). * From a28740c46c537596955b9e0517b49691d37d68e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 5 Jun 2023 17:54:25 +0200 Subject: [PATCH 166/724] change chill rule namespace --- rector.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rector.php b/rector.php index ec9a0c684..c2e752c32 100644 --- a/rector.php +++ b/rector.php @@ -24,6 +24,9 @@ return static function (RectorConfig $rectorConfig): void { LevelSetList::UP_TO_PHP_74 ]); + // chill rules + $rectorConfig->rule(\Chill\Utils\Rector\Rector\ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector::class); + // skip some path... $rectorConfig->skip([ // make rector stuck for some files From 88d363fc0c7cf54d31e37744d0ed7613e01e76ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 5 Jun 2023 17:40:19 +0200 Subject: [PATCH 167/724] apply rector rules on list interfaces --- ...aultDataOnExportFilterAggregatorRector.php | 2 + ...th-no-method-get-form-default-data.php.inc | 135 ++++++++++++++++++ 2 files changed, 137 insertions(+) create mode 100644 utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/Fixture/list-with-no-method-get-form-default-data.php.inc diff --git a/utils/rector/src/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector.php b/utils/rector/src/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector.php index a6a375088..237aa17b8 100644 --- a/utils/rector/src/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector.php +++ b/utils/rector/src/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector.php @@ -15,6 +15,7 @@ use Chill\MainBundle\Export\AggregatorInterface; use Chill\MainBundle\Export\DirectExportInterface; use Chill\MainBundle\Export\ExportInterface; use Chill\MainBundle\Export\FilterInterface; +use Chill\MainBundle\Export\ListInterface; use PhpParser\Node; use Rector\Core\Rector\AbstractRector; use Rector\Symfony\NodeAnalyzer\ClassAnalyzer; @@ -51,6 +52,7 @@ class ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector extends Abstra && !$this->classAnalyzer->hasImplements($node, AggregatorInterface::class) && !$this->classAnalyzer->hasImplements($node, ExportInterface::class) && !$this->classAnalyzer->hasImplements($node, DirectExportInterface::class) + && !$this->classAnalyzer->hasImplements($node, ListInterface::class) ) { return null; } diff --git a/utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/Fixture/list-with-no-method-get-form-default-data.php.inc b/utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/Fixture/list-with-no-method-get-form-default-data.php.inc new file mode 100644 index 000000000..99cea7155 --- /dev/null +++ b/utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/Fixture/list-with-no-method-get-form-default-data.php.inc @@ -0,0 +1,135 @@ + +----- + From 7fab411b96c23687eaa96e7a6726a2233fd31ecc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 5 Jun 2023 18:10:55 +0200 Subject: [PATCH 168/724] remove stubs --- .../Aggregator/PersonAggregators/MaritalStatusAggregator.php | 1 - .../Aggregator/PersonAggregators/NationalityAggregator.php | 1 - .../ChillPersonBundle/Export/Filter/PersonFilters/AgeFilter.php | 1 - 3 files changed, 3 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/MaritalStatusAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/MaritalStatusAggregator.php index c311aadf3..508efd3ad 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/MaritalStatusAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/MaritalStatusAggregator.php @@ -48,7 +48,6 @@ final class MaritalStatusAggregator implements AggregatorInterface public function applyOn() { - return 'abcde'; return Declarations::PERSON_TYPE; } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/NationalityAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/NationalityAggregator.php index b1bd7a085..57721f55c 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/NationalityAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/NationalityAggregator.php @@ -88,7 +88,6 @@ final class NationalityAggregator implements AggregatorInterface, ExportElementV public function applyOn() { - return 'abcde'; return 'person'; } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AgeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AgeFilter.php index 66db7e95b..f06e42c1f 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AgeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AgeFilter.php @@ -73,7 +73,6 @@ class AgeFilter implements ExportElementValidatedInterface, FilterInterface public function applyOn() { - return 'abcde'; return Declarations::PERSON_TYPE; } From cf576dca7bf2d622665efd68eb2fd0061c9a9b4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 5 Jun 2023 18:16:32 +0200 Subject: [PATCH 169/724] fix missing choices in getFormDefaultData with automatic generation --- .../ChillMainBundle/Export/Formatter/CSVFormatter.php | 5 +++++ src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php | 8 ++++++++ .../Export/Export/ListPersonWithAccompanyingPeriod.php | 2 ++ 3 files changed, 15 insertions(+) diff --git a/src/Bundle/ChillMainBundle/Export/Formatter/CSVFormatter.php b/src/Bundle/ChillMainBundle/Export/Formatter/CSVFormatter.php index c8b20a88b..0e4114849 100644 --- a/src/Bundle/ChillMainBundle/Export/Formatter/CSVFormatter.php +++ b/src/Bundle/ChillMainBundle/Export/Formatter/CSVFormatter.php @@ -86,6 +86,11 @@ class CSVFormatter implements FormatterInterface } } + public function getFormDefaultData(array $aggregatorAliases): array + { + return []; + } + public function gatherFiltersDescriptions() { $descriptions = []; diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php b/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php index 12fb0ce5d..467bc02ea 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php @@ -118,6 +118,14 @@ class ListPerson implements ExportElementValidatedInterface, ListInterface, Grou } public function getFormDefaultData(): array { + $choices = array_combine(ListPersonHelper::FIELDS, ListPersonHelper::FIELDS); + + foreach ($this->getCustomFields() as $cf) { + $choices[$this->translatableStringHelper->localize($cf->getName())] + = + $cf->getSlug(); + } + return ['fields' => array_values($choices), 'address_date' => new DateTimeImmutable()]; } diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriod.php index fbdc7f391..e8e495cc7 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriod.php @@ -91,6 +91,8 @@ class ListPersonWithAccompanyingPeriod implements ExportElementValidatedInterfac } public function getFormDefaultData(): array { + $choices = array_combine(ListPersonHelper::FIELDS, ListPersonHelper::FIELDS); + return ['fields' => array_values($choices), 'address_date' => new DateTimeImmutable()]; } From 12fdfd81c4a9214af763e5b0279856549cacf0d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 6 Jun 2023 09:37:43 +0200 Subject: [PATCH 170/724] remove empty data which sparkle a bug in RadioListMapper --- .../Export/Aggregator/ACPAggregators/DateAggregator.php | 9 --------- .../Export/Filter/ACPFilters/EmergencyFilter.php | 1 - .../AccompanyingCourseFilters/ConfidentialFilter.php | 3 +-- .../Filter/AccompanyingCourseFilters/EmergencyFilter.php | 3 +-- 4 files changed, 2 insertions(+), 14 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/DateAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/DateAggregator.php index ea2fa5ee4..e0fa215f3 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/DateAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/DateAggregator.php @@ -29,14 +29,6 @@ class DateAggregator implements AggregatorInterface private const DEFAULT_CHOICE = 'year'; - private TranslatorInterface $translator; - - public function __construct( - TranslatorInterface $translator - ) { - $this->translator = $translator; - } - public function addRole(): ?string { return null; @@ -83,7 +75,6 @@ class DateAggregator implements AggregatorInterface 'choices' => self::CHOICES, 'multiple' => false, 'expanded' => true, - 'empty_data' => self::DEFAULT_CHOICE, ]); } public function getFormDefaultData(): array diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/EmergencyFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/EmergencyFilter.php index 807ba3903..d5792d6d5 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/EmergencyFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/EmergencyFilter.php @@ -67,7 +67,6 @@ class EmergencyFilter implements FilterInterface 'choices' => self::CHOICES, 'multiple' => false, 'expanded' => true, - 'empty_data' => self::DEFAULT_CHOICE, ]); } public function getFormDefaultData(): array diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ConfidentialFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ConfidentialFilter.php index b9db9f439..58085f762 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ConfidentialFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ConfidentialFilter.php @@ -26,7 +26,7 @@ class ConfidentialFilter implements FilterInterface 'is confidential' => true, ]; - private const DEFAULT_CHOICE = false; + private const DEFAULT_CHOICE = 'false'; private TranslatorInterface $translator; @@ -66,7 +66,6 @@ class ConfidentialFilter implements FilterInterface 'choices' => self::CHOICES, 'multiple' => false, 'expanded' => true, - 'empty_data' => self::DEFAULT_CHOICE, ]); } public function getFormDefaultData(): array diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EmergencyFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EmergencyFilter.php index 6fc60f6e9..897a4db2d 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EmergencyFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EmergencyFilter.php @@ -26,7 +26,7 @@ class EmergencyFilter implements FilterInterface 'is not emergency' => false, ]; - private const DEFAULT_CHOICE = false; + private const DEFAULT_CHOICE = 'false'; private TranslatorInterface $translator; @@ -66,7 +66,6 @@ class EmergencyFilter implements FilterInterface 'choices' => self::CHOICES, 'multiple' => false, 'expanded' => true, - 'empty_data' => self::DEFAULT_CHOICE, ]); } public function getFormDefaultData(): array From 7e8dbbe873154666717b77bf1dde9ec0decbbae3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 6 Jun 2023 09:57:06 +0200 Subject: [PATCH 171/724] link to update aggregator and filters from saved export and then execute --- .../views/SavedExport/index.html.twig | 28 +++++++++++++------ .../translations/messages.fr.yml | 4 ++- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Resources/views/SavedExport/index.html.twig b/src/Bundle/ChillMainBundle/Resources/views/SavedExport/index.html.twig index fd0cda2a7..7e0517e31 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/SavedExport/index.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/SavedExport/index.html.twig @@ -22,18 +22,28 @@

            {{ s.export.title|trans }}

            {{ s.saved.title }}

            - +
            {{ 'saved_export.Created on %date%'|trans({'%date%': s.saved.createdAt|format_datetime('long', 'short')}) }}
            - +
            {{ s.saved.description|chill_markdown_to_html }}
            - +
            @@ -54,13 +64,13 @@

            {{ s.export.title|trans }}

            {{ s.saved.title }}

            - +
            {{ 'saved_export.Created on %date%'|trans({'%date%': s.saved.createdAt|format_datetime('long', 'short')}) }}
            - +
            {{ s.saved.description|chill_markdown_to_html }}
            - +
            • diff --git a/src/Bundle/ChillMainBundle/translations/messages.fr.yml b/src/Bundle/ChillMainBundle/translations/messages.fr.yml index 78de523c4..4a85db149 100644 --- a/src/Bundle/ChillMainBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillMainBundle/translations/messages.fr.yml @@ -598,7 +598,9 @@ saved_export: Export is deleted: L'export est supprimé Saved export is saved!: L'export est enregistré Created on %date%: Créé le %date% - + update_title_and_description: Modifier le titre et la description + update_filters_aggregators_and_execute: Modifier les filtres et regroupements et télécharger + execute: Télécharger absence: # single letter for absence From ad82685c02b56e848b3ace2581ebd52239d43a86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 6 Jun 2023 10:49:00 +0200 Subject: [PATCH 172/724] allow to edit existing saved export with new export options --- .../Controller/ExportController.php | 33 +++++++++++++++++-- .../Export/ExportFormHelper.php | 1 - .../Resources/views/Export/download.html.twig | 32 +++++++++++++----- .../translations/messages.fr.yml | 1 + 4 files changed, 55 insertions(+), 12 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Controller/ExportController.php b/src/Bundle/ChillMainBundle/Controller/ExportController.php index 2ad6377a6..e8ee9b97b 100644 --- a/src/Bundle/ChillMainBundle/Controller/ExportController.php +++ b/src/Bundle/ChillMainBundle/Controller/ExportController.php @@ -127,6 +127,7 @@ class ExportController extends AbstractController 'alias' => $alias, 'export' => $export, 'export_group' => $this->getExportGroup($export), + 'saved_export' => $savedExport, ]; if ($formater instanceof \Chill\MainBundle\Export\Formatter\CSVListFormatter) { @@ -245,6 +246,28 @@ class ExportController extends AbstractController } } + /** + * @Route("/{_locale}/export/saved/update-from-key/{id}/{key}", name="chill_main_export_saved_edit_options_from_key") + */ + public function editSavedExportOptionsFromKey(SavedExport $savedExport, string $key): Response + { + $this->denyAccessUnlessGranted('ROLE_USER'); + $user = $this->getUser(); + + if (!$user instanceof User) { + throw new AccessDeniedHttpException(); + } + + $data = $this->rebuildRawData($key); + + $savedExport + ->setOptions($data); + + $this->entityManager->flush(); + + return $this->redirectToRoute('chill_main_export_saved_edit', ['id' => $savedExport->getId()]); + } + /** * @Route("/{_locale}/export/save-from-key/{alias}/{key}", name="chill_main_export_save_from_key") */ @@ -478,7 +501,9 @@ class ExportController extends AbstractController if (null === $dataFormatter && $export instanceof \Chill\MainBundle\Export\ExportInterface) { return $this->redirectToRoute('chill_main_export_new', [ - 'alias' => $alias, 'step' => $this->getNextStep('generate', $export, true), + 'alias' => $alias, + 'step' => $this->getNextStep('generate', $export, true), + 'from_saved' => $savedExport?->getId() ?? '', ]); } @@ -499,7 +524,11 @@ class ExportController extends AbstractController $this->session->remove('formatter_step_raw'); $this->session->remove('formatter_step'); - return $this->redirectToRoute('chill_main_export_download', ['key' => $key, 'alias' => $alias]); + return $this->redirectToRoute('chill_main_export_download', [ + 'key' => $key, + 'alias' => $alias, + 'from_saved' => $savedExport?->getId(), + ]); } private function rebuildData($key, ?SavedExport $savedExport) diff --git a/src/Bundle/ChillMainBundle/Export/ExportFormHelper.php b/src/Bundle/ChillMainBundle/Export/ExportFormHelper.php index 3deb2acbc..c2127fb36 100644 --- a/src/Bundle/ChillMainBundle/Export/ExportFormHelper.php +++ b/src/Bundle/ChillMainBundle/Export/ExportFormHelper.php @@ -147,7 +147,6 @@ final readonly class ExportFormHelper SavedExport $savedExport, array $formOptions ): array { - dump(__METHOD__); $builder = $this->formFactory ->createBuilder( FormType::class, diff --git a/src/Bundle/ChillMainBundle/Resources/views/Export/download.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Export/download.html.twig index 1e69c5a49..bd7dbf7e9 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Export/download.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Export/download.html.twig @@ -1,5 +1,5 @@ {# - * Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS, + * Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS, / * * This program is free software: you can redistribute it and/or modify @@ -19,7 +19,7 @@ {% extends "@ChillMain/layout.html.twig" %} {% block title "Download export"|trans ~ export.title|trans %} - + {% block js %} {% endblock %} - + {% block content %}
              - + {{ include('@ChillMain/Export/_breadcrumb.html.twig') }} - +

              {{ export.title|trans }}

              {{ "Download export"|trans }}

              - +
              {{ 'Back to the list'|trans }} {% if not app.request.query.has('prevent_save') %} + {% if saved_export is null %}
            • {{ 'Save'|trans }}
            • + {% else %} +
            • + +
            • + {% endif %} {% endif %}
            -{% endblock content %} \ No newline at end of file +{% endblock content %} diff --git a/src/Bundle/ChillMainBundle/translations/messages.fr.yml b/src/Bundle/ChillMainBundle/translations/messages.fr.yml index 4a85db149..bbe3d23fb 100644 --- a/src/Bundle/ChillMainBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillMainBundle/translations/messages.fr.yml @@ -601,6 +601,7 @@ saved_export: update_title_and_description: Modifier le titre et la description update_filters_aggregators_and_execute: Modifier les filtres et regroupements et télécharger execute: Télécharger + Update existing: Mettre à jour le rapport enregistré existant absence: # single letter for absence From c3ac3827117f44cda4e2d33c9e03979a787045fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 6 Jun 2023 09:57:06 +0200 Subject: [PATCH 173/724] link to update aggregator and filters from saved export and then execute --- .../views/SavedExport/index.html.twig | 28 +++++++++++++------ .../translations/messages.fr.yml | 4 ++- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Resources/views/SavedExport/index.html.twig b/src/Bundle/ChillMainBundle/Resources/views/SavedExport/index.html.twig index fd0cda2a7..7e0517e31 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/SavedExport/index.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/SavedExport/index.html.twig @@ -22,18 +22,28 @@

            {{ s.export.title|trans }}

            {{ s.saved.title }}

            - +
            {{ 'saved_export.Created on %date%'|trans({'%date%': s.saved.createdAt|format_datetime('long', 'short')}) }}
            - +
            {{ s.saved.description|chill_markdown_to_html }}
            - +
            @@ -54,13 +64,13 @@

            {{ s.export.title|trans }}

            {{ s.saved.title }}

            - +
            {{ 'saved_export.Created on %date%'|trans({'%date%': s.saved.createdAt|format_datetime('long', 'short')}) }}
            - +
            {{ s.saved.description|chill_markdown_to_html }}
            - +
            • diff --git a/src/Bundle/ChillMainBundle/translations/messages.fr.yml b/src/Bundle/ChillMainBundle/translations/messages.fr.yml index 78de523c4..4a85db149 100644 --- a/src/Bundle/ChillMainBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillMainBundle/translations/messages.fr.yml @@ -598,7 +598,9 @@ saved_export: Export is deleted: L'export est supprimé Saved export is saved!: L'export est enregistré Created on %date%: Créé le %date% - + update_title_and_description: Modifier le titre et la description + update_filters_aggregators_and_execute: Modifier les filtres et regroupements et télécharger + execute: Télécharger absence: # single letter for absence From b4614974c0ba7d95fc3814d249dad7a35d3e508f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 6 Jun 2023 10:49:00 +0200 Subject: [PATCH 174/724] allow to edit existing saved export with new export options --- .../Controller/ExportController.php | 33 +++++++++++++++++-- .../Export/ExportFormHelper.php | 1 - .../Resources/views/Export/download.html.twig | 32 +++++++++++++----- .../translations/messages.fr.yml | 1 + 4 files changed, 55 insertions(+), 12 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Controller/ExportController.php b/src/Bundle/ChillMainBundle/Controller/ExportController.php index 2ad6377a6..e8ee9b97b 100644 --- a/src/Bundle/ChillMainBundle/Controller/ExportController.php +++ b/src/Bundle/ChillMainBundle/Controller/ExportController.php @@ -127,6 +127,7 @@ class ExportController extends AbstractController 'alias' => $alias, 'export' => $export, 'export_group' => $this->getExportGroup($export), + 'saved_export' => $savedExport, ]; if ($formater instanceof \Chill\MainBundle\Export\Formatter\CSVListFormatter) { @@ -245,6 +246,28 @@ class ExportController extends AbstractController } } + /** + * @Route("/{_locale}/export/saved/update-from-key/{id}/{key}", name="chill_main_export_saved_edit_options_from_key") + */ + public function editSavedExportOptionsFromKey(SavedExport $savedExport, string $key): Response + { + $this->denyAccessUnlessGranted('ROLE_USER'); + $user = $this->getUser(); + + if (!$user instanceof User) { + throw new AccessDeniedHttpException(); + } + + $data = $this->rebuildRawData($key); + + $savedExport + ->setOptions($data); + + $this->entityManager->flush(); + + return $this->redirectToRoute('chill_main_export_saved_edit', ['id' => $savedExport->getId()]); + } + /** * @Route("/{_locale}/export/save-from-key/{alias}/{key}", name="chill_main_export_save_from_key") */ @@ -478,7 +501,9 @@ class ExportController extends AbstractController if (null === $dataFormatter && $export instanceof \Chill\MainBundle\Export\ExportInterface) { return $this->redirectToRoute('chill_main_export_new', [ - 'alias' => $alias, 'step' => $this->getNextStep('generate', $export, true), + 'alias' => $alias, + 'step' => $this->getNextStep('generate', $export, true), + 'from_saved' => $savedExport?->getId() ?? '', ]); } @@ -499,7 +524,11 @@ class ExportController extends AbstractController $this->session->remove('formatter_step_raw'); $this->session->remove('formatter_step'); - return $this->redirectToRoute('chill_main_export_download', ['key' => $key, 'alias' => $alias]); + return $this->redirectToRoute('chill_main_export_download', [ + 'key' => $key, + 'alias' => $alias, + 'from_saved' => $savedExport?->getId(), + ]); } private function rebuildData($key, ?SavedExport $savedExport) diff --git a/src/Bundle/ChillMainBundle/Export/ExportFormHelper.php b/src/Bundle/ChillMainBundle/Export/ExportFormHelper.php index 3deb2acbc..c2127fb36 100644 --- a/src/Bundle/ChillMainBundle/Export/ExportFormHelper.php +++ b/src/Bundle/ChillMainBundle/Export/ExportFormHelper.php @@ -147,7 +147,6 @@ final readonly class ExportFormHelper SavedExport $savedExport, array $formOptions ): array { - dump(__METHOD__); $builder = $this->formFactory ->createBuilder( FormType::class, diff --git a/src/Bundle/ChillMainBundle/Resources/views/Export/download.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Export/download.html.twig index 1e69c5a49..bd7dbf7e9 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Export/download.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Export/download.html.twig @@ -1,5 +1,5 @@ {# - * Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS, + * Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS, / * * This program is free software: you can redistribute it and/or modify @@ -19,7 +19,7 @@ {% extends "@ChillMain/layout.html.twig" %} {% block title "Download export"|trans ~ export.title|trans %} - + {% block js %} {% endblock %} - + {% block content %}
              - + {{ include('@ChillMain/Export/_breadcrumb.html.twig') }} - +

              {{ export.title|trans }}

              {{ "Download export"|trans }}

              - +
              {{ 'Back to the list'|trans }} {% if not app.request.query.has('prevent_save') %} + {% if saved_export is null %}
            • {{ 'Save'|trans }}
            • + {% else %} +
            • + +
            • + {% endif %} {% endif %}
            -{% endblock content %} \ No newline at end of file +{% endblock content %} diff --git a/src/Bundle/ChillMainBundle/translations/messages.fr.yml b/src/Bundle/ChillMainBundle/translations/messages.fr.yml index 4a85db149..bbe3d23fb 100644 --- a/src/Bundle/ChillMainBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillMainBundle/translations/messages.fr.yml @@ -601,6 +601,7 @@ saved_export: update_title_and_description: Modifier le titre et la description update_filters_aggregators_and_execute: Modifier les filtres et regroupements et télécharger execute: Télécharger + Update existing: Mettre à jour le rapport enregistré existant absence: # single letter for absence From 05822e7e4af50bec73888ff61adf189519929c5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 6 Jun 2023 10:52:12 +0200 Subject: [PATCH 175/724] add changelog --- .changes/unreleased/Feature-20230606-105153.yaml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changes/unreleased/Feature-20230606-105153.yaml diff --git a/.changes/unreleased/Feature-20230606-105153.yaml b/.changes/unreleased/Feature-20230606-105153.yaml new file mode 100644 index 000000000..00c3ab1da --- /dev/null +++ b/.changes/unreleased/Feature-20230606-105153.yaml @@ -0,0 +1,6 @@ +kind: Feature +body: 'Edit saved exports options: the saved exports options (forms, filters, aggregators) + are now editable.' +time: 2023-06-06T10:51:53.331701352+02:00 +custom: + Issue: "110" From aa6479fbf93757b0a594d8de5b748cabf1b31593 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 6 Jun 2023 11:14:14 +0200 Subject: [PATCH 176/724] doc for rector rule [ci-skip] --- ...aultDataOnExportFilterAggregatorRector.php | 54 ++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/utils/rector/src/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector.php b/utils/rector/src/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector.php index 237aa17b8..e6bf4a75a 100644 --- a/utils/rector/src/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector.php +++ b/utils/rector/src/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector.php @@ -32,7 +32,59 @@ class ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector extends Abstra { return new RuleDefinition( 'Add a getFormDefault data method on exports, filters and aggregators, filled with default data', - [] + [ + <<add('foo', PickRollingDateType::class, [ + 'label' => 'Test thing', + 'data' => new RollingDate(RollingDate::T_TODAY) + ]); + + $builder->add('baz', TextType::class, [ + 'label' => 'OrNiCar', + 'data' => 'Castor' + ]); + } +} +PHP, +<<add('foo', PickRollingDateType::class, [ + 'label' => 'Test thing', + 'data' => new RollingDate(RollingDate::T_TODAY) + ]); + + $builder->add('baz', TextType::class, [ + 'label' => 'OrNiCar', + 'data' => 'Castor' + ]); + } + public function getFormDefaultData(): array + { + return ['foo' => new RollingDate(RollingDate::T_TODAY), 'baz' => 'Castor']; + } +} +PHP + ] ); } From 0fd36a319633ced130f21b2e33a0f44ff7cee34d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 6 Jun 2023 14:40:24 +0200 Subject: [PATCH 177/724] fix list of "my accompanying periods" --- .../unreleased/Fixed-20230606-143955.yaml | 6 +++++ .../UserAccompanyingPeriodController.php | 23 +++++++++++++++---- .../user_periods_list.html.twig | 9 ++++++++ 3 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 .changes/unreleased/Fixed-20230606-143955.yaml diff --git a/.changes/unreleased/Fixed-20230606-143955.yaml b/.changes/unreleased/Fixed-20230606-143955.yaml new file mode 100644 index 000000000..a7ab6b6a1 --- /dev/null +++ b/.changes/unreleased/Fixed-20230606-143955.yaml @@ -0,0 +1,6 @@ +kind: Fixed +body: 'List of "my accompanying periods": separate the active and closed periods in + two different lists, and show the inactive_long and inactive_short periods' +time: 2023-06-06T14:39:55.68417576+02:00 +custom: + Issue: "111" diff --git a/src/Bundle/ChillPersonBundle/Controller/UserAccompanyingPeriodController.php b/src/Bundle/ChillPersonBundle/Controller/UserAccompanyingPeriodController.php index 658fdb7be..1b67014b3 100644 --- a/src/Bundle/ChillPersonBundle/Controller/UserAccompanyingPeriodController.php +++ b/src/Bundle/ChillPersonBundle/Controller/UserAccompanyingPeriodController.php @@ -12,9 +12,11 @@ declare(strict_types=1); namespace Chill\PersonBundle\Controller; use Chill\MainBundle\Pagination\PaginatorFactory; +use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Repository\AccompanyingPeriodRepository; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; class UserAccompanyingPeriodController extends AbstractController @@ -32,12 +34,24 @@ class UserAccompanyingPeriodController extends AbstractController /** * @Route("/{_locale}/person/accompanying-periods/my", name="chill_person_accompanying_period_user") */ - public function listAction(Request $request) + public function listAction(Request $request): Response { - $total = $this->accompanyingPeriodRepository->countBy(['user' => $this->getUser(), 'step' => ['CONFIRMED', 'CLOSED']]); + $active = $request->query->getBoolean('active', true); + $steps = match ($active) { + true => [ + AccompanyingPeriod::STEP_CONFIRMED, + AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_LONG, + AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_SHORT, + ], + false => [ + AccompanyingPeriod::STEP_CLOSED, + ] + }; + + $total = $this->accompanyingPeriodRepository->countBy(['user' => $this->getUser(), 'step' => $steps]); $pagination = $this->paginatorFactory->create($total); $accompanyingPeriods = $this->accompanyingPeriodRepository->findBy( - ['user' => $this->getUser(), 'step' => ['CONFIRMED', 'CLOSED']], + ['user' => $this->getUser(), 'step' => $steps], ['openingDate' => 'DESC'], $pagination->getItemsPerPage(), $pagination->getCurrentPageFirstItemNumber() @@ -46,13 +60,14 @@ class UserAccompanyingPeriodController extends AbstractController return $this->render('@ChillPerson/AccompanyingPeriod/user_periods_list.html.twig', [ 'accompanyingPeriods' => $accompanyingPeriods, 'pagination' => $pagination, + 'active' => $active, ]); } /** * @Route("/{_locale}/person/accompanying-periods/my/drafts", name="chill_person_accompanying_period_draft_user") */ - public function listDraftsAction(Request $request) + public function listDraftsAction(): Response { $total = $this->accompanyingPeriodRepository->countBy(['user' => $this->getUser(), 'step' => 'DRAFT']); $pagination = $this->paginatorFactory->create($total); diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/user_periods_list.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/user_periods_list.html.twig index 031e0728c..38e055378 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/user_periods_list.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/user_periods_list.html.twig @@ -17,6 +17,15 @@

            {{ 'My accompanying periods'|trans }}

            + +

            {{ 'Number of periods'|trans }}: {{ pagination.totalItems }}

            From 88f48d474fd33a06887083e666c4f26caf93b5af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 6 Jun 2023 17:08:38 +0200 Subject: [PATCH 178/724] fix association's annotation between PersonCenterCurrent and Person entities --- .changes/unreleased/Fixed-20230606-170742.yaml | 6 ++++++ .../ChillPersonBundle/Entity/Person/PersonCenterCurrent.php | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 .changes/unreleased/Fixed-20230606-170742.yaml diff --git a/.changes/unreleased/Fixed-20230606-170742.yaml b/.changes/unreleased/Fixed-20230606-170742.yaml new file mode 100644 index 000000000..0bd65b6cf --- /dev/null +++ b/.changes/unreleased/Fixed-20230606-170742.yaml @@ -0,0 +1,6 @@ +kind: Fixed +body: use the correct annotation for the association between PersonCurrentCenter and + Person +time: 2023-06-06T17:07:42.060486553+02:00 +custom: + Issue: "" diff --git a/src/Bundle/ChillPersonBundle/Entity/Person/PersonCenterCurrent.php b/src/Bundle/ChillPersonBundle/Entity/Person/PersonCenterCurrent.php index 6d67fbbbb..6de73de0d 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person/PersonCenterCurrent.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person/PersonCenterCurrent.php @@ -45,7 +45,7 @@ class PersonCenterCurrent private ?int $id = null; /** - * @ORM\ManyToOne(targetEntity=Person::class, inversedBy="centerCurrent") + * @ORM\OneToOne(targetEntity=Person::class, inversedBy="centerCurrent") */ private Person $person; From 73b95732db02d9ff6095cdb05d19e09051af5655 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 7 Jun 2023 13:06:10 +0200 Subject: [PATCH 179/724] Add new methods to RegroupmentRepository and fix association Regroupment/Center --- .changes/unreleased/DX-20230607-130344.yaml | 6 +++++ src/Bundle/ChillMainBundle/Entity/Center.php | 17 +++++++++++- .../ChillMainBundle/Entity/Regroupment.php | 25 ++++++++++++++++-- .../ChillMainBundle/Form/RegroupmentType.php | 2 +- .../Repository/RegroupmentRepository.php | 26 +++++++++++++++++++ 5 files changed, 72 insertions(+), 4 deletions(-) create mode 100644 .changes/unreleased/DX-20230607-130344.yaml diff --git a/.changes/unreleased/DX-20230607-130344.yaml b/.changes/unreleased/DX-20230607-130344.yaml new file mode 100644 index 000000000..c7774c395 --- /dev/null +++ b/.changes/unreleased/DX-20230607-130344.yaml @@ -0,0 +1,6 @@ +kind: DX +body: Add methods to RegroupmentRepository and fullfill Center / Regroupment Doctrine + mapping +time: 2023-06-07T13:03:44.177864269+02:00 +custom: + Issue: "" diff --git a/src/Bundle/ChillMainBundle/Entity/Center.php b/src/Bundle/ChillMainBundle/Entity/Center.php index 5ca051ec0..0d5402409 100644 --- a/src/Bundle/ChillMainBundle/Entity/Center.php +++ b/src/Bundle/ChillMainBundle/Entity/Center.php @@ -48,12 +48,19 @@ class Center implements HasCenterInterface */ private string $name = ''; + /** + * @var Collection + * @ORM\ManyToMany(targetEntity=Regroupment::class, mappedBy="centers") + */ + private Collection $regroupments; + /** * Center constructor. */ public function __construct() { - $this->groupCenters = new \Doctrine\Common\Collections\ArrayCollection(); + $this->groupCenters = new ArrayCollection(); + $this->regroupments = new ArrayCollection(); } /** @@ -106,6 +113,14 @@ class Center implements HasCenterInterface return $this->name; } + /** + * @return Collection + */ + public function getRegroupments(): Collection + { + return $this->regroupments; + } + /** * @param $name * diff --git a/src/Bundle/ChillMainBundle/Entity/Regroupment.php b/src/Bundle/ChillMainBundle/Entity/Regroupment.php index 96953abf5..c5d9525cf 100644 --- a/src/Bundle/ChillMainBundle/Entity/Regroupment.php +++ b/src/Bundle/ChillMainBundle/Entity/Regroupment.php @@ -22,11 +22,12 @@ use Doctrine\ORM\Mapping as ORM; class Regroupment { /** - * @var Center * @ORM\ManyToMany( - * targetEntity=Center::class + * targetEntity=Center::class, + * inversedBy="regroupments" * ) * @ORM\Id + * @var Collection
            */ private Collection $centers; @@ -52,6 +53,26 @@ class Regroupment $this->centers = new ArrayCollection(); } + public function addCenter(Center $center): self + { + if (!$this->centers->contains($center)) { + $this->centers->add($center); + $center->getRegroupments()->add($this); + } + + return $this; + } + + public function removeCenter(Center $center): self + { + if ($this->centers->contains($center)) { + $this->centers->removeElement($center); + $center->getRegroupments()->removeElement($this); + } + + return $this; + } + public function getCenters(): Collection { return $this->centers; diff --git a/src/Bundle/ChillMainBundle/Form/RegroupmentType.php b/src/Bundle/ChillMainBundle/Form/RegroupmentType.php index bc8e6684f..22814598a 100644 --- a/src/Bundle/ChillMainBundle/Form/RegroupmentType.php +++ b/src/Bundle/ChillMainBundle/Form/RegroupmentType.php @@ -31,7 +31,7 @@ class RegroupmentType extends AbstractType ->add('centers', EntityType::class, [ 'class' => Center::class, 'multiple' => true, - 'attr' => ['class' => 'select2'], + 'expanded' => true, ]) ->add('isActive', CheckboxType::class, [ 'label' => 'Actif ?', diff --git a/src/Bundle/ChillMainBundle/Repository/RegroupmentRepository.php b/src/Bundle/ChillMainBundle/Repository/RegroupmentRepository.php index a28f2f341..84e2efe81 100644 --- a/src/Bundle/ChillMainBundle/Repository/RegroupmentRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/RegroupmentRepository.php @@ -14,6 +14,8 @@ namespace Chill\MainBundle\Repository; use Chill\MainBundle\Entity\Regroupment; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; +use Doctrine\ORM\NonUniqueResultException; +use Doctrine\ORM\NoResultException; use Doctrine\Persistence\ObjectRepository; final class RegroupmentRepository implements ObjectRepository @@ -59,6 +61,30 @@ final class RegroupmentRepository implements ObjectRepository return $this->repository->findOneBy($criteria, $orderBy); } + /** + * @throws NonUniqueResultException + * @throws NoResultException + */ + public function findOneByName(string $name): ?Regroupment + { + return $this->repository->createQueryBuilder('r') + ->where('LOWER(r.name) = LOWER(:searched)') + ->setParameter('searched', $name) + ->getQuery() + ->getSingleResult(); + } + + /** + * @return array + */ + public function findRegroupmentAssociatedToAnyCenter(): array + { + return $this->repository->createQueryBuilder('r') + ->where('SIZE(r.centers) = 0') + ->getQuery() + ->getResult(); + } + public function getClassName() { return Regroupment::class; From c73beef3aff5d73111f675b19dc13e0fbeb20909 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 7 Jun 2023 13:25:48 +0200 Subject: [PATCH 180/724] FIX [rights][household] check rights to be able to create a parcours from within household --- .../views/Household/accompanying_period.html.twig | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Household/accompanying_period.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Household/accompanying_period.html.twig index acd251735..e71559585 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Household/accompanying_period.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Household/accompanying_period.html.twig @@ -41,12 +41,14 @@
          • {# TODO: add ACL to check if user is allowed to edit household? #} -
          • - - {{ 'Create an accompanying period'|trans }} - -
          • + {% if is_granted('CHILL_PERSON_HOUSEHOLD_EDIT', household) %} +
          • + + {{ 'Create an accompanying period'|trans }} + +
          • + {% endif %}
          From 520d5ab6d4698874bfae1d78510fb4ef735b152c Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 7 Jun 2023 13:30:53 +0200 Subject: [PATCH 181/724] FIX [rights][menu] dont show menu item parcours if user doesn't have the proper rights --- .../Menu/HouseholdMenuBuilder.php | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Menu/HouseholdMenuBuilder.php b/src/Bundle/ChillPersonBundle/Menu/HouseholdMenuBuilder.php index 074c27027..65b751bc2 100644 --- a/src/Bundle/ChillPersonBundle/Menu/HouseholdMenuBuilder.php +++ b/src/Bundle/ChillPersonBundle/Menu/HouseholdMenuBuilder.php @@ -12,7 +12,9 @@ declare(strict_types=1); namespace Chill\PersonBundle\Menu; use Chill\MainBundle\Routing\LocalMenuBuilderInterface; +use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; use Knp\Menu\MenuItem; +use Symfony\Component\Security\Core\Security; use Symfony\Contracts\Translation\TranslatorInterface; class HouseholdMenuBuilder implements LocalMenuBuilderInterface @@ -22,9 +24,12 @@ class HouseholdMenuBuilder implements LocalMenuBuilderInterface */ protected $translator; - public function __construct(TranslatorInterface $translator) + private Security $security; + + public function __construct(TranslatorInterface $translator, Security $security) { $this->translator = $translator; + $this->security = $security; } public function buildMenu($menuId, MenuItem $menu, array $parameters): void @@ -53,12 +58,15 @@ class HouseholdMenuBuilder implements LocalMenuBuilderInterface ], ]) ->setExtras(['order' => 17]); - $menu->addChild($this->translator->trans('household.Accompanying period'), [ - 'route' => 'chill_person_household_accompanying_period', - 'routeParameters' => [ - 'household_id' => $household->getId(), - ], ]) - ->setExtras(['order' => 20]); + if ($this->security->isGranted(AccompanyingPeriodVoter::SEE, $parameters['household'])) + { + $menu->addChild($this->translator->trans('household.Accompanying period'), [ + 'route' => 'chill_person_household_accompanying_period', + 'routeParameters' => [ + 'household_id' => $household->getId(), + ],]) + ->setExtras(['order' => 20]); + } $menu->addChild($this->translator->trans('household.Addresses'), [ 'route' => 'chill_person_household_addresses', From 199223293e6b1f9b7da78649a670d18dad63b596 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 7 Jun 2023 13:36:26 +0200 Subject: [PATCH 182/724] rename method --- src/Bundle/ChillMainBundle/Repository/RegroupmentRepository.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bundle/ChillMainBundle/Repository/RegroupmentRepository.php b/src/Bundle/ChillMainBundle/Repository/RegroupmentRepository.php index 84e2efe81..c115d5d98 100644 --- a/src/Bundle/ChillMainBundle/Repository/RegroupmentRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/RegroupmentRepository.php @@ -77,7 +77,7 @@ final class RegroupmentRepository implements ObjectRepository /** * @return array */ - public function findRegroupmentAssociatedToAnyCenter(): array + public function findRegroupmentAssociatedToNoCenter(): array { return $this->repository->createQueryBuilder('r') ->where('SIZE(r.centers) = 0') From 23ee29ab0de50ed8447d2cceb812b0d83fcabb90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 7 Jun 2023 11:39:19 +0000 Subject: [PATCH 183/724] Apply 1 suggestion(s) to 1 file(s) --- .../Resources/views/Household/accompanying_period.html.twig | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Household/accompanying_period.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Household/accompanying_period.html.twig index e71559585..c734eee8e 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Household/accompanying_period.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Household/accompanying_period.html.twig @@ -40,7 +40,6 @@ {{ 'Household summary'|trans }}
        • - {# TODO: add ACL to check if user is allowed to edit household? #} {% if is_granted('CHILL_PERSON_HOUSEHOLD_EDIT', household) %}
        • Date: Wed, 7 Jun 2023 17:39:28 +0200 Subject: [PATCH 184/724] FIX [php-cs-fixer] --- src/Bundle/ChillPersonBundle/Menu/HouseholdMenuBuilder.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Menu/HouseholdMenuBuilder.php b/src/Bundle/ChillPersonBundle/Menu/HouseholdMenuBuilder.php index 65b751bc2..13291bdd1 100644 --- a/src/Bundle/ChillPersonBundle/Menu/HouseholdMenuBuilder.php +++ b/src/Bundle/ChillPersonBundle/Menu/HouseholdMenuBuilder.php @@ -58,8 +58,7 @@ class HouseholdMenuBuilder implements LocalMenuBuilderInterface ], ]) ->setExtras(['order' => 17]); - if ($this->security->isGranted(AccompanyingPeriodVoter::SEE, $parameters['household'])) - { + if ($this->security->isGranted(AccompanyingPeriodVoter::SEE, $parameters['household'])) { $menu->addChild($this->translator->trans('household.Accompanying period'), [ 'route' => 'chill_person_household_accompanying_period', 'routeParameters' => [ From f5b71a0c413a92a76081c49b9023c97231bbf46e Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 7 Jun 2023 17:47:23 +0200 Subject: [PATCH 185/724] DX [changie] entry added --- .changes/unreleased/Security-20230607-174702.yaml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .changes/unreleased/Security-20230607-174702.yaml diff --git a/.changes/unreleased/Security-20230607-174702.yaml b/.changes/unreleased/Security-20230607-174702.yaml new file mode 100644 index 000000000..ecdc1d191 --- /dev/null +++ b/.changes/unreleased/Security-20230607-174702.yaml @@ -0,0 +1,7 @@ +kind: Security +body: Rights are checked for display of 'accompanying period' tab in household menu. + Rights are also checked for creation of 'accompanying period' from within household + context +time: 2023-06-07T17:47:02.488819553+02:00 +custom: + Issue: "105" From ad72192e2431bf7abeeceb7c8e824b11bf124b91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 8 Jun 2023 11:24:01 +0200 Subject: [PATCH 186/724] doc: for database printciples --- .changes/unreleased/DX-20230608-112417.yaml | 5 + .../development/database-principles.rst | 84 ++++++++++ .../development/database/table_list.csv | 155 ++++++++++++++++++ docs/source/development/index.rst | 1 + 4 files changed, 245 insertions(+) create mode 100644 .changes/unreleased/DX-20230608-112417.yaml create mode 100644 docs/source/development/database-principles.rst create mode 100644 docs/source/development/database/table_list.csv diff --git a/.changes/unreleased/DX-20230608-112417.yaml b/.changes/unreleased/DX-20230608-112417.yaml new file mode 100644 index 000000000..7091808ec --- /dev/null +++ b/.changes/unreleased/DX-20230608-112417.yaml @@ -0,0 +1,5 @@ +kind: DX +body: Documentation for database principles +time: 2023-06-08T11:24:17.701892874+02:00 +custom: + Issue: "" diff --git a/docs/source/development/database-principles.rst b/docs/source/development/database-principles.rst new file mode 100644 index 000000000..0b4a33f04 --- /dev/null +++ b/docs/source/development/database-principles.rst @@ -0,0 +1,84 @@ + +.. database-principles: + +Principes de la base de données +############################### + +Cette page donne une compréhension globale de la base de donnée de Chill, et explique quelques détails d'implémentations qui permettent d'accélérer les traitements à partir de la base de donnée, ou de l'exploiter plus aisément. + +Cette page est rédigée en français. + +.. note:: + + La stabilité du schéma de la base de donnée n'est pas garantie. + + Toutefois, ce dernier évolue relativement peu. Il est rare que des tables ou des colonnes soient supprimées ou renommées. Mais il n'est pas garanti que cela puisse arriver. + +Généralités +=========== + +Une liste commentée de toutes les tables :download:`est disponible au format CSV <./database/table_list.csv`. + +Schéma et conventions de nommage +-------------------------------- + +Au début de l'histoire de Chill, les schémas postgresql n'étaient pas exploités. Les données étaient stockées dans le schéma :code:`public`. + +Par la suite, des nouveaux bundles sont apparus, et les tables ont été classées dans des schémas dédiés. + +A l'heure actuelle: + +- pour les anciens bundle, ceux qui ont déjà des tables dans le schéma public, les nouvelles tables sont ajoutées à ce schéma. Elles sont préfixées par :code:`chill__`; +- pour les bundles plus récents, les tables sont créées dans le schéma dédié + +Données avec de l'historicité +----------------------------- + +Certaines données sont historisées: + +- les référents d'un parcours; +- les statuts d'un parcours; +- la liaison entre les centres et les usagers; +- etc. + +Dans ces cas-là, Chill crée généralement deux colonnes, qui sont habituellement nommées :code:`startDate` et :code:`endDate`. Lorsque la colonne :code:`endDate` est à :code:`NULL`, cela signifie que la période n'est pas "fermée". La colonne :code:`startDate` n'est pas nullable. + +Dans certains cas, la donnée actuelle (référent d'un parcours, par exemple) est également répétée au niveau de la table en elle-même. Par exemple, la table des parcours :code:`chill_person_accompanying_period` comporte une colonne :code:`step` (le statut du parcours) et :code:`user_id` (id du référent) en plus de l'historique. Bien que redondant, cela simplifie les traitements. + +Relations particulières +======================= + +Usagers, ménages, adresses +-------------------------- + +Les usagers ont une adresse au travers des ménages: dans l'interface, l'adresse est inscrite dans le dossier du ménage, et elle est "donnée" aux usagers membres du ménage, **et** qui partagent l'adresse de ce ménage. En effet, il est possible que des usagers "appartiennent" à un ménage sans y être domicilié: c'est le cas, par exemple, des enfants en garde alternée. + +L'historique de l'appartenance des usagers au ménage est conservée, de même que l'historique des adresses pour un même ménage. + +Les tables en jeu sont les suivantes: + +- la table :code:`chill_person_person` liste les usagers; +- la table :code:`chill_person_household_members` liste les appartenances au ménage: il s'agit de la jointure entre les usagers et les ménages: + - les colonnes :code:`startDate` et :code:`endDate` indiquent la date de début et la date de fin de l'appartenance; + - la colonne :code:`shareHousehold` indique si l'utilisateur partage l'adresse du ménage (si oui, sa valeur est :code:`TRUE`) +- la table :code:`chill_person_household` liste les ménages +- la table :code:`chill_person_household_to_addresses` associe les ménages aux adresses; +- la table :code:`chill_main_address` contient les adresses, en indiquant la date de début de validité (:code:`validFrom`) et la fin de validité (:code:`validTo`). + +Pour simplifier la résolution des adresses et des usagers, deux vues ont été mises en œuvre: + +- la vue :code:`view_chill_person_household_address` reprend, pour chaque usager, l'historique des appartenances au ménage découpée par l'historique des adresses d'un ménage. + Autrement dit, une ligne est créée à chaque fois qu'un usager change de ménage, ou qu'un ménage change d'adresse. Il est donc possible de retrouver l'historique complet des adresses pour un usager donné via cette table. +- la vue :code:`view_chill_person_current_address` reprend l'adresse actuelle des usagers. + +Adresses et unités géographiques +-------------------------------- + +Chill propose des statistiques sur la localisation des adresses par rapport à des zones géographiques (:code:`chill_main_geographical_unit`). + +Comme la résolution géographique des adresses est coûteuse en CPU et en temps de traitement, une vue matérialisée a été créée: :code:`view_chill_main_address_geographical_unit`. Elle est rafraichie quotidiennement dans la base de donnée de production. + +Liste des tables et commentaires +================================ + + diff --git a/docs/source/development/database/table_list.csv b/docs/source/development/database/table_list.csv new file mode 100644 index 000000000..fe688318d --- /dev/null +++ b/docs/source/development/database/table_list.csv @@ -0,0 +1,155 @@ +order,table_schema,table_name,commentaire +1,chill_3party,party_category,Catégorie de tiers +2,chill_3party,party_center,Association entre les tiers et les centres (déprécié) +3,chill_3party,party_profession,Profession du tiers (déprécié) +4,chill_3party,third_party,Tiers +5,chill_3party,thirdparty_category,association tiers - catégories +6,chill_asideactivity,asideactivity,Activités annexes +7,chill_asideactivity,asideactivitycategory,Catégories d'activités annexes +8,chill_budget,charge,Charges du budget +9,chill_budget,charge_type,Types de charges +10,chill_budget,resource,Ressources du budget +11,chill_budget,resource_type,Types de ressources +12,chill_calendar,calendar,Rendez-vous +13,chill_calendar,calendar_doc,Document du rendez-vous +14,chill_calendar,calendar_range,Plage de disponibilité +15,chill_calendar,calendar_to_persons,association rendez-vous - usagers +16,chill_calendar,calendar_to_thirdparties,association rendez-vous - tiers +17,chill_calendar,cancel_reason,Motifs d'annulations +18,chill_calendar,invite,Invitation aux rendez-vous +19,chill_doc,accompanyingcourse_document,Documents associés aux parcours +20,chill_doc,document_category,Catégories de documents +21,chill_doc,person_document,Documents associés à l'usagers +22,chill_doc,stored_object,Documents +23,chill_task,recurring_task,Tâches récurrentes (non utilisé) +24,chill_task,single_task,Tâches +25,chill_task,single_task_place_event,Historique des transitions des tâches +26,chill_vendee,adressederelais, +27,chill_vendee,center_polygon +28,chill_vendee,entourage, +29,chill_vendee,geographical_unit +30,chill_vendee,geographical_unit_association +31,chill_vendee,mobilite +32,chill_vendee,niveauetude +33,chill_vendee,security_profile +34,chill_vendee,security_profile_action +35,chill_vendee,security_profile_jobs +36,chill_vendee,situationprofessionelle +37,chill_vendee,statutlogement +38,chill_vendee,tempsdetravail +39,chill_vendee,titredesejour +40,chill_vendee,vendee_person +41,chill_vendee,vendee_person_mineur +42,chill_vendee,vendeeperson_entourage +43,chill_vendee,vendeepersonmineur_adressederelais +44,public,accompanying_periods_scopes,Services associés aux parcours +45,public,activity,Échanges +46,public,activity_activityreason,s +47,public,activity_person, +48,public,activity_storedobject, +49,public,activity_thirdparty, +50,public,activity_user, +51,public,activityreason,Sujets d'échange +52,public,activityreasoncategory,Catégories de sujets +53,public,activitytpresence,Présence aux échanges +54,public,activitytype,Types d'échanges +55,public,activitytypecategory,Catégories de types d'échanges +56,public,centers,"Centres (territoires, agences, etc.)" +57,public,chill_activity_activity_chill_person_socialaction, +58,public,chill_activity_activity_chill_person_socialissue +59,public,chill_docgen_template,Gabarits de documents +60,public,chill_main_address,Adresses +61,public,chill_main_address_legacy,Anciennes adresses (dépréciés) +62,public,chill_main_address_reference,Adresses de référence +63,public,chill_main_civility,Civilités +64,public,chill_main_cronjob_execution,Dernière exécution des tâche cron +65,public,chill_main_geographical_unit,Unités géographiques +66,public,chill_main_geographical_unit_layer,Couches d'unités géographiques +67,public,chill_main_location,Localisations +68,public,chill_main_location_type,Types de localisations +69,public,chill_main_notification,Notifications +70,public,chill_main_notification_addresses_unread +71,public,chill_main_notification_addresses_user +72,public,chill_main_notification_comment, +73,public,chill_main_postal_code,Code postaux +74,public,chill_main_saved_export,Exports enregistrés +75,public,chill_main_user_job,Métiers +76,public,chill_main_workflow_entity,Workflows +77,public,chill_main_workflow_entity_comment +78,public,chill_main_workflow_entity_step,Etapes du workflow +79,public,chill_main_workflow_entity_step_cc_user, +80,public,chill_main_workflow_entity_step_user +81,public,chill_main_workflow_entity_step_user_by_accesskey, +82,public,chill_main_workflow_entity_subscriber_to_final, +83,public,chill_main_workflow_entity_subscriber_to_step +84,public,chill_person_accompanying_period,Parcours d'accompagnement +85,public,chill_person_accompanying_period_closingmotive,Motifs de cloture des parcours +86,public,chill_person_accompanying_period_comment,Commentaires des parcours +87,public,chill_person_accompanying_period_location_history,Historique de la localisatio ndes parcours +88,public,chill_person_accompanying_period_origin,Origine des parcours +89,public,chill_person_accompanying_period_participation,Appartenance des usagers au parcours +90,public,chill_person_accompanying_period_resource,Personnes ressources d'un parcours +91,public,chill_person_accompanying_period_social_issues, +92,public,chill_person_accompanying_period_step_history +93,public,chill_person_accompanying_period_user_history +94,public,chill_person_accompanying_period_work,Actions d'accompagnements +95,public,chill_person_accompanying_period_work_evaluation,Évaluations (dans les actions d'accompagnements) +96,public,chill_person_accompanying_period_work_evaluation_document,Documents des évaluations +97,public,chill_person_accompanying_period_work_goal,Objectifs d'une actions +98,public,chill_person_accompanying_period_work_goal_result,Objectifs et résultats d'une action +99,public,chill_person_accompanying_period_work_person,Usagers associés à une actions +100,public,chill_person_accompanying_period_work_referrer,Référents d'une actions +101,public,chill_person_accompanying_period_work_result,Résultats d'une action +102,public,chill_person_accompanying_period_work_third_party,Tiers traitants d'une action +103,public,chill_person_alt_name,"Noms supplémentaires d'un usager (nom marital, etc.)" +104,public,chill_person_household,Ménages +105,public,chill_person_household_composition, +106,public,chill_person_household_composition_type,Types de composition de ménage +107,public,chill_person_household_members,Membres du ménages +108,public,chill_person_household_position,Positions dans le ménage +109,public,chill_person_household_to_addresses,Association adresses - ménages +110,public,chill_person_marital_status,Etats civils +111,public,chill_person_not_duplicate, +112,public,chill_person_person,Usagers +113,public,chill_person_person_center_history,Historique des centres d'un usagers +114,public,chill_person_persons_to_addresses,Déprécié +115,public,chill_person_phone,Numéros d etéléphone supplémentaires d'un usager +116,public,chill_person_relations,Types de relations de filiation +117,public,chill_person_relationships,Relations de filiations +118,public,chill_person_residential_address,Adresses de résidences +119,public,chill_person_resource,Personnes ressources (pour les personnes) +120,public,chill_person_resource_kind,Type de personnes ressources +121,public,chill_person_social_action,Liste des actions d'accompagnement +122,public,chill_person_social_action_goal,Objectifs associés à une action +123,public,chill_person_social_action_result,Résultats associés à une action +124,public,chill_person_social_issue,Problématiques sociales +125,public,chill_person_social_work_evaluation,Evaluations disponibles +126,public,chill_person_social_work_evaluation_action,Associations entre les évaluations et les actions +127,public,chill_person_social_work_goal,Objectifs disponibles pour une actions +128,public,chill_person_social_work_goal_result,Objectifs et résultats disponible pour une action +129,public,chill_person_social_work_result,Résultats disponibles pour une action +130,public,country,Pays +131,public,custom_field_long_choice_options, +132,public,customfield +133,public,customfieldsdefaultgroup +134,public,customfieldsgroup +135,public,geography_columns,Table liée à postgis +136,public,geometry_columns,Table liée à postgis +137,public,group_centers, +138,public,language,Langues +139,public,messenger_messages,Table système +140,public,migration_versions,Table système +141,public,permission_groups +142,public,permissionsgroup_rolescope +143,public,persons_spoken_languages +144,public,regroupment,Regroupement de centres +145,public,regroupment_center, +146,public,role_scopes, +147,public,scopes,Services +148,public,spatial_ref_sys,Table système (postgis) +149,public,user_groupcenter, +150,public,users,Utilisateurs +151,public,view_chill_person_accompanying_period_info, +152,public,view_chill_person_current_address +153,public,view_chill_person_household_address +154,public,view_chill_person_person_center_history_current diff --git a/docs/source/development/index.rst b/docs/source/development/index.rst index fd9ae43ba..768d29ce0 100644 --- a/docs/source/development/index.rst +++ b/docs/source/development/index.rst @@ -36,6 +36,7 @@ As Chill rely on the `symfony `_ framework, reading the fram Assets Cron Jobs Info about entities + Info about database (in French) Layout and UI ************** From 727e9d0f74fa53818ca0cadd2f9da1470e1e91b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 12 Jun 2023 17:58:27 +0200 Subject: [PATCH 187/724] WIP: fix loading of activity document --- ...=> ActivityDocumentACLAwareRepository.php} | 113 +++++++----------- ...ityDocumentACLAwareRepositoryInterface.php | 28 +++++ .../Repository/ActivityRepository.php | 1 - ...anyingPeriodActivityGenericDocProvider.php | 20 +++- .../PersonActivityGenericDocProvider.php | 19 ++- ...ActivityDocumentACLAwareRepositoryTest.php | 113 ++++++++++++++++++ 6 files changed, 209 insertions(+), 85 deletions(-) rename src/Bundle/ChillActivityBundle/Repository/{PersonActivityDocumentACLAwareRepository.php => ActivityDocumentACLAwareRepository.php} (69%) create mode 100644 src/Bundle/ChillActivityBundle/Repository/ActivityDocumentACLAwareRepositoryInterface.php create mode 100644 src/Bundle/ChillActivityBundle/Tests/Repository/ActivityDocumentACLAwareRepositoryTest.php diff --git a/src/Bundle/ChillActivityBundle/Repository/PersonActivityDocumentACLAwareRepository.php b/src/Bundle/ChillActivityBundle/Repository/ActivityDocumentACLAwareRepository.php similarity index 69% rename from src/Bundle/ChillActivityBundle/Repository/PersonActivityDocumentACLAwareRepository.php rename to src/Bundle/ChillActivityBundle/Repository/ActivityDocumentACLAwareRepository.php index 84bb08fb4..f3f61ad3d 100644 --- a/src/Bundle/ChillActivityBundle/Repository/PersonActivityDocumentACLAwareRepository.php +++ b/src/Bundle/ChillActivityBundle/Repository/ActivityDocumentACLAwareRepository.php @@ -23,16 +23,18 @@ use Chill\DocStoreBundle\Security\Authorization\PersonDocumentVoter; use Chill\MainBundle\Entity\Scope; use Chill\MainBundle\Security\Authorization\AuthorizationHelperForCurrentUserInterface; use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface; +use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodWorkVoter; use DateTimeImmutable; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\EntityManagerInterface; +use Doctrine\ORM\Mapping\MappingException; use Doctrine\ORM\QueryBuilder; use Symfony\Component\HttpKernel\HttpCache\Store; use Symfony\Component\Security\Core\Security; -class PersonActivityDocumentACLAwareRepository implements PersonDocumentACLAwareRepositoryInterface +final readonly class ActivityDocumentACLAwareRepository implements ActivityDocumentACLAwareRepositoryInterface { public function __construct( private EntityManagerInterface $em, @@ -42,26 +44,43 @@ class PersonActivityDocumentACLAwareRepository implements PersonDocumentACLAware { } - public function buildQueryByPerson(Person $person): QueryBuilder + public function buildFetchQueryActivityDocumentLinkedToPersonFromPersonContext(Person $person, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null): FetchQueryInterface { - $qb = $this->em->getRepository(PersonDocument::class)->createQueryBuilder('d'); - - $qb - ->where($qb->expr()->eq('d.person', ':person')) - ->setParameter('person', $person); - - return $qb; - } - - - public function buildFetchQueryForPerson(Person $person, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null): FetchQueryInterface - { - $query = $this->buildBaseFetchQueryForPerson($person, $startDate, $endDate, $content); + $query = $this->buildBaseFetchQueryActivityDocumentLinkedToPersonFromPersonContext($person, $startDate, $endDate, $content); return $this->addFetchQueryByPersonACL($query, $person); } - public function buildBaseFetchQueryForPerson(Person $person, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null): FetchQuery + public function buildBaseFetchQueryActivityDocumentLinkedToPersonFromPersonContext(Person $person, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null): FetchQuery + { + $storedObjectMetadata = $this->em->getClassMetadata(StoredObject::class); + $activityMetadata = $this->em->getClassMetadata(Activity::class); + + $query = new FetchQuery( + PersonDocumentGenericDocProvider::KEY, + sprintf('jsonb_build_object(\'id\', stored_obj.%s, \'activity_id\', activity.%s)', $storedObjectMetadata->getSingleIdentifierColumnName(), $activityMetadata->getSingleIdentifierColumnName()), + sprintf('stored_obj.%s', $storedObjectMetadata->getColumnName('createdAt')), + sprintf('%s AS stored_obj', $storedObjectMetadata->getSchemaName().'.'.$storedObjectMetadata->getTableName()) + ); + + $query->addJoinClause( + 'JOIN public.activity_storedobject activity_doc ON activity_doc.storedobject_id = stored_obj.id' + ); + + $query->addJoinClause( + 'JOIN public.activity activity ON activity.id = activity_doc.activity_id' + ); + + $query->addWhereClause( + sprintf('activity.%s = ?', $activityMetadata->getSingleAssociationJoinColumnName('person')), + [$person->getId()], + [Types::INTEGER] + ); + + return $this->addWhereClauses($query, $startDate, $endDate, $content); + } + + public function buildFetchQueryActivityDocumentLinkedToAccompanyingPeriodFromPersonContext(Person $person, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null): FetchQuery { $storedObjectMetadata = $this->em->getClassMetadata(StoredObject::class); $activityMetadata = $this->em->getClassMetadata(Activity::class); @@ -109,11 +128,12 @@ class PersonActivityDocumentACLAwareRepository implements PersonDocumentACLAware $query->addWhereClause(sprintf('(%s)', implode(' OR ', $or)), $orParams, $orTypes); -/* $query->addWhereClause( - 'activity.person_id = ?', - [$person->getId()], - [Types::INTEGER] - );*/ + return $this->addWhereClauses($query, $startDate, $endDate, $content); + } + + private function addWhereClauses(FetchQuery $query, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null): FetchQuery + { + $storedObjectMetadata = $this->em->getClassMetadata(StoredObject::class); if (null !== $startDate) { $query->addWhereClause( @@ -131,7 +151,7 @@ class PersonActivityDocumentACLAwareRepository implements PersonDocumentACLAware ); } - if (null !== $content) { + if (null !== $content or '' !== $content) { $query->addWhereClause( 'stored_obj.title ilike ?', ['%' . $content . '%'], @@ -142,55 +162,6 @@ class PersonActivityDocumentACLAwareRepository implements PersonDocumentACLAware return $query; } - public function countByPerson(Person $person): int - { - $qb = $this->buildQueryByPerson($person)->select('COUNT(d)'); - - $this->addACL($qb, $person); - - return $qb->getQuery()->getSingleScalarResult(); - } - - public function findByPerson(Person $person, array $orderBy = [], int $limit = 20, int $offset = 0): array - { - $qb = $this->buildQueryByPerson($person)->select('d'); - - $this->addACL($qb, $person); - - foreach ($orderBy as $field => $order) { - $qb->addOrderBy('d.' . $field, $order); - } - - $qb->setFirstResult($offset)->setMaxResults($limit); - - return $qb->getQuery()->getResult(); - } - - private function addACL(QueryBuilder $qb, Person $person): void - { - $reachableScopes = []; - - foreach ($this->centerResolverManager->resolveCenters($person) as $center) { - $reachableScopes = [ - ...$reachableScopes, - ...$this->authorizationHelperForCurrentUser - ->getReachableScopes( - ActivityVoter::SEE, - $center - ) - ]; - } - - if ([] === $reachableScopes) { - $qb->andWhere("'FALSE' = 'TRUE'"); - - return; - } - - $qb->andWhere($qb->expr()->in('d.scope', ':scopes')) - ->setParameter('scopes', $reachableScopes); - } - private function addFetchQueryByPersonACL(FetchQuery $fetchQuery, Person $person): FetchQuery { $activityMetadata = $this->em->getClassMetadata(Activity::class); diff --git a/src/Bundle/ChillActivityBundle/Repository/ActivityDocumentACLAwareRepositoryInterface.php b/src/Bundle/ChillActivityBundle/Repository/ActivityDocumentACLAwareRepositoryInterface.php new file mode 100644 index 000000000..eb9e82cbe --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Repository/ActivityDocumentACLAwareRepositoryInterface.php @@ -0,0 +1,28 @@ +security->isGranted(ActivityVoter::SEE, $accompanyingPeriod); } + + public function isAllowedForPerson(Person $person): bool + { + return $this->security->isGranted(AccompanyingPeriodVoter::SEE, $person); + } + + public function buildFetchQueryForPerson(Person $person, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface + { + return $this->activityDocumentACLAwareRepository + ->buildFetchQueryActivityDocumentLinkedToAccompanyingPeriodFromPersonContext($person, $startDate, $endDate, $content); + } } diff --git a/src/Bundle/ChillActivityBundle/Service/GenericDoc/Providers/PersonActivityGenericDocProvider.php b/src/Bundle/ChillActivityBundle/Service/GenericDoc/Providers/PersonActivityGenericDocProvider.php index d00a23e79..b1bd1d712 100644 --- a/src/Bundle/ChillActivityBundle/Service/GenericDoc/Providers/PersonActivityGenericDocProvider.php +++ b/src/Bundle/ChillActivityBundle/Service/GenericDoc/Providers/PersonActivityGenericDocProvider.php @@ -11,7 +11,8 @@ declare(strict_types=1); namespace Chill\ActivityBundle\Service\GenericDoc\Providers; -use Chill\ActivityBundle\Repository\PersonActivityDocumentACLAwareRepository; +use Chill\ActivityBundle\Repository\ActivityDocumentACLAwareRepository; +use Chill\ActivityBundle\Repository\ActivityDocumentACLAwareRepositoryInterface; use Chill\ActivityBundle\Security\Authorization\ActivityVoter; use Chill\DocStoreBundle\GenericDoc\FetchQueryInterface; use Chill\DocStoreBundle\GenericDoc\GenericDocForPersonProviderInterface; @@ -21,24 +22,20 @@ use DateTimeImmutable; use Doctrine\ORM\EntityManagerInterface; use Symfony\Component\Security\Core\Security; -final class PersonActivityGenericDocProvider implements GenericDocForPersonProviderInterface +final readonly class PersonActivityGenericDocProvider implements GenericDocForPersonProviderInterface { public const KEY = 'person_activity_document'; - private Security $security; - - private PersonActivityDocumentACLAwareRepository $personActivityDocumentACLAwareRepository; - - public function __construct(Security $security, PersonActivityDocumentACLAwareRepository $personActivityDocumentACLAwareRepository -) + public function __construct( + private Security $security, + private ActivityDocumentACLAwareRepositoryInterface $personActivityDocumentACLAwareRepository, + ) { - $this->security = $security; - $this->personActivityDocumentACLAwareRepository = $personActivityDocumentACLAwareRepository; } public function buildFetchQueryForPerson(Person $person, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface { - return $this->personActivityDocumentACLAwareRepository->buildFetchQueryForPerson( + return $this->personActivityDocumentACLAwareRepository->buildFetchQueryActivityDocumentLinkedToPersonFromPersonContext( $person, $startDate, $endDate, diff --git a/src/Bundle/ChillActivityBundle/Tests/Repository/ActivityDocumentACLAwareRepositoryTest.php b/src/Bundle/ChillActivityBundle/Tests/Repository/ActivityDocumentACLAwareRepositoryTest.php new file mode 100644 index 000000000..7390963fc --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Tests/Repository/ActivityDocumentACLAwareRepositoryTest.php @@ -0,0 +1,113 @@ +entityManager = self::$container->get(EntityManagerInterface::class); + $this->centerResolverManager = self::$container->get(CenterResolverManagerInterface::class); + $this->authorizationHelperForCurrentUser = self::$container->get(AuthorizationHelperForCurrentUserInterface::class); + $this->security = self::$container->get(Security::class); + } + + /** + * @dataProvider provideDataForPerson + */ + public function testBuildFetchQueryActivityDocumentLinkedToPersonFromPersonContext(Person $person, array $reachableScopes, bool $_unused, ?\DateTimeImmutable $startDate, ?\DateTimeImmutable $endDate, ?string $content): void + { + $authorizationHelper = $this->prophesize(AuthorizationHelperForCurrentUserInterface::class); + $authorizationHelper->getReachableScopes(ActivityVoter::SEE, Argument::any()) + ->willReturn($reachableScopes); + + $repository = new ActivityDocumentACLAwareRepository( + $this->entityManager, + $this->centerResolverManager, + $authorizationHelper->reveal(), + $this->security + ); + + $query = $repository->buildFetchQueryActivityDocumentLinkedToPersonFromPersonContext($person, $startDate, $endDate, $content); + ['sql' => $sql, 'params' => $params, 'types' => $types] = (new FetchQueryToSqlBuilder())->toSql($query); + + $nb = $this->entityManager->getConnection()->fetchOne("SELECT COUNT(*) FROM ({$sql}) sq", $params, $types); + + self::assertIsInt($nb); + } + + /** + * @dataProvider provideDataForPerson + */ + public function testBuildFetchQueryActivityDocumentLinkedToAccompanyingPeriodFromPersonContext(Person $person, array $_unused, bool $canSeePeriod, ?\DateTimeImmutable $startDate, ?\DateTimeImmutable $endDate, ?string $content): void + { + $security = $this->prophesize(Security::class); + $security->isGranted(ActivityVoter::SEE, Argument::type(AccompanyingPeriod::class)) + ->willReturn($canSeePeriod); + + $repository = new ActivityDocumentACLAwareRepository( + $this->entityManager, + $this->centerResolverManager, + $this->authorizationHelperForCurrentUser, + $security->reveal() + ); + + $query = $repository->buildFetchQueryActivityDocumentLinkedToAccompanyingPeriodFromPersonContext($person, $startDate, $endDate, $content); + + ['sql' => $sql, 'params' => $params, 'types' => $types] = (new FetchQueryToSqlBuilder())->toSql($query); + + $nb = $this->entityManager->getConnection()->fetchOne("SELECT COUNT(*) FROM ({$sql}) sq", $params, $types); + + self::assertIsInt($nb); + } + + public function provideDataForPerson(): iterable + { + $this->setUp(); + + if (null === $person = $this->entityManager->createQuery("SELECT p FROM " . Person::class . " p WHERE SIZE(p.accompanyingPeriodParticipations) > 0 ") + ->setMaxResults(1) + ->getSingleResult()) { + throw new \RuntimeException("no person in dtabase"); + } + + if ([] === $scopes = $this->entityManager->createQuery("SELECT s FROM " . Scope::class . " s ")->setMaxResults(5)->getResult()) { + throw new \RuntimeException("no scopes in database"); + } + + yield [$person, [], true, null, null, null]; + yield [$person, $scopes, true, null, null, null]; + yield [$person, $scopes, true, new \DateTimeImmutable("1 month ago"), null, null]; + yield [$person, $scopes, true, new \DateTimeImmutable("1 month ago"), new \DateTimeImmutable("1 week ago"), null]; + yield [$person, $scopes, true, new \DateTimeImmutable("1 month ago"), new \DateTimeImmutable("1 week ago"), "content"]; + yield [$person, $scopes, true, null, new \DateTimeImmutable("1 week ago"), "content"]; + yield [$person, [], true, new \DateTimeImmutable("1 month ago"), new \DateTimeImmutable("1 week ago"), "content"]; + } + +} From 1d7279c022041a9d13a520f849a640325e1d61bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 12 Jun 2023 18:03:39 +0200 Subject: [PATCH 188/724] release v2.1.0 --- .changes/unreleased/DX-20230607-130344.yaml | 6 ------ .changes/unreleased/Fixed-20230606-143955.yaml | 6 ------ .../unreleased/Security-20230607-174702.yaml | 7 ------- .changes/v2.1.0.md | 17 +++++++++++++++++ CHANGELOG.md | 18 ++++++++++++++++++ 5 files changed, 35 insertions(+), 19 deletions(-) delete mode 100644 .changes/unreleased/DX-20230607-130344.yaml delete mode 100644 .changes/unreleased/Fixed-20230606-143955.yaml delete mode 100644 .changes/unreleased/Security-20230607-174702.yaml create mode 100644 .changes/v2.1.0.md diff --git a/.changes/unreleased/DX-20230607-130344.yaml b/.changes/unreleased/DX-20230607-130344.yaml deleted file mode 100644 index c7774c395..000000000 --- a/.changes/unreleased/DX-20230607-130344.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: DX -body: Add methods to RegroupmentRepository and fullfill Center / Regroupment Doctrine - mapping -time: 2023-06-07T13:03:44.177864269+02:00 -custom: - Issue: "" diff --git a/.changes/unreleased/Fixed-20230606-143955.yaml b/.changes/unreleased/Fixed-20230606-143955.yaml deleted file mode 100644 index a7ab6b6a1..000000000 --- a/.changes/unreleased/Fixed-20230606-143955.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: Fixed -body: 'List of "my accompanying periods": separate the active and closed periods in - two different lists, and show the inactive_long and inactive_short periods' -time: 2023-06-06T14:39:55.68417576+02:00 -custom: - Issue: "111" diff --git a/.changes/unreleased/Security-20230607-174702.yaml b/.changes/unreleased/Security-20230607-174702.yaml deleted file mode 100644 index ecdc1d191..000000000 --- a/.changes/unreleased/Security-20230607-174702.yaml +++ /dev/null @@ -1,7 +0,0 @@ -kind: Security -body: Rights are checked for display of 'accompanying period' tab in household menu. - Rights are also checked for creation of 'accompanying period' from within household - context -time: 2023-06-07T17:47:02.488819553+02:00 -custom: - Issue: "105" diff --git a/.changes/v2.1.0.md b/.changes/v2.1.0.md new file mode 100644 index 000000000..ade83aee0 --- /dev/null +++ b/.changes/v2.1.0.md @@ -0,0 +1,17 @@ +## v2.1.0 - 2023-06-12 + +### Feature + +* [docgen] allow to pick a third party when generating a document in context Activity, AccompanyingPeriod + +### Fixed + +* ([#111](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/111)) List of "my accompanying periods": separate the active and closed periods in two different lists, and show the inactive_long and inactive_short periods + +### Security + +* ([#105](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/105)) Rights are checked for display of 'accompanying period' tab in household menu. Rights are also checked for creation of 'accompanying period' from within household context + +### DX + +* Add methods to RegroupmentRepository and fullfill Center / Regroupment Doctrine mapping diff --git a/CHANGELOG.md b/CHANGELOG.md index 5475b20b8..f10f12f9b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,24 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html), and is generated by [Changie](https://github.com/miniscruff/changie). +## v2.1.0 - 2023-06-12 + +### Feature + +* [docgen] allow to pick a third party when generating a document in context Activity, AccompanyingPeriod + +### Fixed + +* ([#111](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/111)) List of "my accompanying periods": separate the active and closed periods in two different lists, and show the inactive_long and inactive_short periods + +### Security + +* ([#105](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/105)) Rights are checked for display of 'accompanying period' tab in household menu. Rights are also checked for creation of 'accompanying period' from within household context + +### DX + +* Add methods to RegroupmentRepository and fullfill Center / Regroupment Doctrine mapping + ## 2.0.0 * this is a release to relaunch our proceess of release with semantic versioning From 4456fb3749a78544451f6561605dd6db5a3b26c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 13 Jun 2023 11:01:40 +0200 Subject: [PATCH 189/724] Fixing generic doc providers from calendar + fix cs --- .../ActivityDocumentACLAwareRepository.php | 4 +- ...ityDocumentACLAwareRepositoryInterface.php | 9 ++ ...anyingPeriodActivityGenericDocProvider.php | 2 +- .../PersonActivityGenericDocProvider.php | 3 +- ...anyingPeriodActivityGenericDocRenderer.php | 1 - ...ActivityDocumentACLAwareRepositoryTest.php | 13 ++ ...anyingPeriodCalendarGenericDocProvider.php | 113 +++++++++++++-- .../PersonCalendarGenericDocProvider.php | 51 +++---- .../AccompanyingCourseDocumentProvider.php | 54 +++++++ ...ngPeriodCalendarGenericDocProviderTest.php | 134 ++++++++++++++++++ .../PersonCalendarGenericDocProviderTest.php | 70 +++++++++ 11 files changed, 401 insertions(+), 53 deletions(-) create mode 100644 src/Bundle/ChillDocStoreBundle/GenericDoc/Providers/AccompanyingCourseDocumentProvider.php create mode 100644 src/Bundle/ChillPersonBundle/Tests/Service/GenericDoc/Providers/AccompanyingPeriodCalendarGenericDocProviderTest.php create mode 100644 src/Bundle/ChillPersonBundle/Tests/Service/GenericDoc/Providers/PersonCalendarGenericDocProviderTest.php diff --git a/src/Bundle/ChillActivityBundle/Repository/ActivityDocumentACLAwareRepository.php b/src/Bundle/ChillActivityBundle/Repository/ActivityDocumentACLAwareRepository.php index f3f61ad3d..180d7fc4a 100644 --- a/src/Bundle/ChillActivityBundle/Repository/ActivityDocumentACLAwareRepository.php +++ b/src/Bundle/ChillActivityBundle/Repository/ActivityDocumentACLAwareRepository.php @@ -40,8 +40,8 @@ final readonly class ActivityDocumentACLAwareRepository implements ActivityDocum private EntityManagerInterface $em, private CenterResolverManagerInterface $centerResolverManager, private AuthorizationHelperForCurrentUserInterface $authorizationHelperForCurrentUser, - private Security $security) - { + private Security $security + ) { } public function buildFetchQueryActivityDocumentLinkedToPersonFromPersonContext(Person $person, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null): FetchQueryInterface diff --git a/src/Bundle/ChillActivityBundle/Repository/ActivityDocumentACLAwareRepositoryInterface.php b/src/Bundle/ChillActivityBundle/Repository/ActivityDocumentACLAwareRepositoryInterface.php index eb9e82cbe..9f4a9c0f8 100644 --- a/src/Bundle/ChillActivityBundle/Repository/ActivityDocumentACLAwareRepositoryInterface.php +++ b/src/Bundle/ChillActivityBundle/Repository/ActivityDocumentACLAwareRepositoryInterface.php @@ -1,5 +1,14 @@ getSchemaName().'.'.$classMetadata->getTableName().' AS cd' ); $query->addJoinClause( - sprintf('JOIN %s doc_store ON doc_store.%s = cd.%s', - $storedObjectMetadata->getSchemaName().'.'.$storedObjectMetadata->getTableName(), - $storedObjectMetadata->getColumnName('id'), - $classMetadata->getSingleAssociationJoinColumnName('storedObject') - )); + sprintf( + 'JOIN %s doc_store ON doc_store.%s = cd.%s', + $storedObjectMetadata->getSchemaName().'.'.$storedObjectMetadata->getTableName(), + $storedObjectMetadata->getColumnName('id'), + $classMetadata->getSingleAssociationJoinColumnName('storedObject') + ) + ); $query->addJoinClause( - sprintf('JOIN %s calendar ON calendar.%s = cd.%s', + sprintf( + 'JOIN %s calendar ON calendar.%s = cd.%s', $calendarMetadata->getSchemaName().'.'.$calendarMetadata->getTableName(), $calendarMetadata->getColumnName('id'), $classMetadata->getSingleAssociationJoinColumnName('calendar') @@ -65,12 +76,91 @@ final class AccompanyingPeriodCalendarGenericDocProvider implements GenericDocFo ); $query->addWhereClause( - sprintf('calendar.%s = ?', - $calendarMetadata->getAssociationMapping('accompanyingPeriod')['joinColumns'][0]['name']), + sprintf( + 'calendar.%s = ?', + $calendarMetadata->getAssociationMapping('accompanyingPeriod')['joinColumns'][0]['name'] + ), [$accompanyingPeriod->getId()], [Types::INTEGER] ); + return $query; + } + + public function isAllowedForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod): bool + { + return $this->security->isGranted(CalendarVoter::SEE, $accompanyingPeriod); + } + + public function buildFetchQueryForPerson(Person $person, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface + { + $classMetadata = $this->em->getClassMetadata(CalendarDoc::class); + $storedObjectMetadata = $this->em->getClassMetadata(StoredObject::class); + $calendarMetadata = $this->em->getClassMetadata(Calendar::class); + + $query = new FetchQuery( + self::KEY, + sprintf("jsonb_build_object('id', cd.%s)", $classMetadata->getColumnName('id')), + 'cd.'.$storedObjectMetadata->getColumnName('createdAt'), + $classMetadata->getSchemaName().'.'.$classMetadata->getTableName().' AS cd' + ); + $query->addJoinClause( + sprintf( + 'JOIN %s doc_store ON doc_store.%s = cd.%s', + $storedObjectMetadata->getSchemaName().'.'.$storedObjectMetadata->getTableName(), + $storedObjectMetadata->getColumnName('id'), + $classMetadata->getSingleAssociationJoinColumnName('storedObject') + ) + ); + + $query->addJoinClause( + sprintf( + 'JOIN %s calendar ON calendar.%s = cd.%s', + $calendarMetadata->getSchemaName().'.'.$calendarMetadata->getTableName(), + $calendarMetadata->getColumnName('id'), + $classMetadata->getSingleAssociationJoinColumnName('calendar') + ) + ); + + // get the documents associated with accompanying periods in which person participates + $or = []; + $orParams = []; + $orTypes = []; + foreach ($person->getAccompanyingPeriodParticipations() as $participation) { + if (!$this->security->isGranted(CalendarVoter::SEE, $participation->getAccompanyingPeriod())) { + continue; + } + + $or[] = sprintf( + '(calendar.%s = ? AND cd.%s BETWEEN ?::date AND COALESCE(?::date, \'infinity\'::date))', + $calendarMetadata->getSingleAssociationJoinColumnName('accompanyingPeriod'), + $storedObjectMetadata->getColumnName('createdAt') + ); + $orParams = [...$orParams, $participation->getAccompanyingPeriod()->getId(), + DateTimeImmutable::createFromInterface($participation->getStartDate()), + null === $participation->getEndDate() ? null : DateTimeImmutable::createFromInterface($participation->getEndDate())]; + $orTypes = [...$orTypes, Types::INTEGER, Types::DATE_IMMUTABLE, Types::DATE_IMMUTABLE]; + } + + if ([] === $or) { + $query->addWhereClause('TRUE = FALSE'); + + return $query; + } + return $this->addWhereClausesToQuery($query, $startDate, $endDate, $content); + } + + public function isAllowedForPerson(Person $person): bool + { + // check that the person is allowed to see an accompanying period. If yes, the + // ACL on each accompanying period will be checked when the query is build + return $this->security->isGranted(AccompanyingPeriodVoter::SEE, $person); + } + + private function addWhereClausesToQuery(FetchQuery $query, ?DateTimeImmutable $startDate, ?DateTimeImmutable $endDate, ?string $content): FetchQuery + { + $storedObjectMetadata = $this->em->getClassMetadata(StoredObject::class); + if (null !== $startDate) { $query->addWhereClause( sprintf('doc_store.%s >= ?', $storedObjectMetadata->getColumnName('createdAt')), @@ -98,10 +188,5 @@ final class AccompanyingPeriodCalendarGenericDocProvider implements GenericDocFo return $query; } - public function isAllowedForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod): bool - { - return $this->security->isGranted(CalendarVoter::SEE, $accompanyingPeriod); - } - } diff --git a/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Providers/PersonCalendarGenericDocProvider.php b/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Providers/PersonCalendarGenericDocProvider.php index 640f0d197..f5d4b3cbb 100644 --- a/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Providers/PersonCalendarGenericDocProvider.php +++ b/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Providers/PersonCalendarGenericDocProvider.php @@ -24,9 +24,15 @@ use DateTimeImmutable; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Mapping\MappingException; +use Service\GenericDoc\Providers\PersonCalendarGenericDocProviderTest; use Symfony\Component\Security\Core\Security; -final class PersonCalendarGenericDocProvider implements GenericDocForPersonProviderInterface +/** + * Provide calendar documents for calendar associated to persons + * + * @see PersonCalendarGenericDocProviderTest + */ +final readonly class PersonCalendarGenericDocProvider implements GenericDocForPersonProviderInterface { public const KEY = 'person_calendar_document'; @@ -36,7 +42,6 @@ final class PersonCalendarGenericDocProvider implements GenericDocForPersonProvi ) { } - private function addWhereClausesToQuery(FetchQuery $query, ?\DateTimeImmutable $startDate = null, ?\DateTimeImmutable $endDate = null, ?string $content = null): FetchQuery { $storedObjectMetadata = $this->em->getClassMetadata(StoredObject::class); @@ -84,50 +89,30 @@ final class PersonCalendarGenericDocProvider implements GenericDocForPersonProvi $classMetadata->getSchemaName().'.'.$classMetadata->getTableName().' AS cd' ); $query->addJoinClause( - sprintf('JOIN %s doc_store ON doc_store.%s = cd.%s', + sprintf( + 'JOIN %s doc_store ON doc_store.%s = cd.%s', $storedObjectMetadata->getSchemaName().'.'.$storedObjectMetadata->getTableName(), $storedObjectMetadata->getColumnName('id'), $classMetadata->getSingleAssociationJoinColumnName('storedObject') - )); + ) + ); $query->addJoinClause( - sprintf('JOIN %s calendar ON calendar.%s = cd.%s', + sprintf( + 'JOIN %s calendar ON calendar.%s = cd.%s', $calendarMetadata->getSchemaName().'.'.$calendarMetadata->getTableName(), $calendarMetadata->getColumnName('id'), $classMetadata->getSingleAssociationJoinColumnName('calendar') ) ); - // get the documents associated with accompanying periods in which person participates - $or = []; - $orParams = []; - $orTypes = []; - foreach ($person->getAccompanyingPeriodParticipations() as $participation) { - if (!$this->security->isGranted(CalendarVoter::SEE, $participation->getAccompanyingPeriod())) { - continue; - } - - $or[] = sprintf( - '(calendar.%s = ? AND cd.%s BETWEEN ?::date AND COALESCE(?::date, \'infinity\'::date))', - $calendarMetadata->getSingleAssociationJoinColumnName('accompanyingPeriod'), - $storedObjectMetadata->getColumnName('createdAt') - ); - $orParams = [...$orParams, $participation->getAccompanyingPeriod()->getId(), - DateTimeImmutable::createFromInterface($participation->getStartDate()), - null === $participation->getEndDate() ? null : DateTimeImmutable::createFromInterface($participation->getEndDate())]; - $orTypes = [...$orTypes, Types::INTEGER, Types::DATE_IMMUTABLE, Types::DATE_IMMUTABLE]; - } - - if ([] === $or) { - $query->addWhereClause('TRUE = FALSE'); - - return $query; - } - -// $query->addWhereClause(sprintf('(%s)', implode(' OR ', $or)), $orParams, $orTypes); + $query->addWhereClause( + sprintf('calendar.%s = ?', $calendarMetadata->getSingleAssociationJoinColumnName('person')), + [$person->getId()], + [Types::INTEGER] + ); return $this->addWhereClausesToQuery($query, $startDate, $endDate, $content); - } /** diff --git a/src/Bundle/ChillDocStoreBundle/GenericDoc/Providers/AccompanyingCourseDocumentProvider.php b/src/Bundle/ChillDocStoreBundle/GenericDoc/Providers/AccompanyingCourseDocumentProvider.php new file mode 100644 index 000000000..163d17458 --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/GenericDoc/Providers/AccompanyingCourseDocumentProvider.php @@ -0,0 +1,54 @@ +entityManager->getClassMetadata(AccompanyingCourseDocument::class); + + $query = new FetchQuery( + 'accompanying_course_document', + sprintf('jsonb_build_object(\'id\', %s)', $classMetadata->getIdentifierColumnNames()[0]), + sprintf($classMetadata->getColumnName('date')), + $classMetadata->getSchemaName() . '.' . $classMetadata->getTableName() + ); + + $query->addWhereClause( + sprintf('%s = ?', $classMetadata->getSingleAssociationJoinColumnName('course')), + [$accompanyingPeriod->getId()] + ); + + return $query; + } + + public function isAllowedForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod): bool + { + return $this->security->isGranted(AccompanyingCourseDocumentVoter::SEE, $accompanyingPeriod); + } +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Service/GenericDoc/Providers/AccompanyingPeriodCalendarGenericDocProviderTest.php b/src/Bundle/ChillPersonBundle/Tests/Service/GenericDoc/Providers/AccompanyingPeriodCalendarGenericDocProviderTest.php new file mode 100644 index 000000000..8aff23673 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Service/GenericDoc/Providers/AccompanyingPeriodCalendarGenericDocProviderTest.php @@ -0,0 +1,134 @@ +security = self::$container->get(Security::class); + $this->entityManager = self::$container->get(EntityManagerInterface::class); + } + + /** + * @dataProvider provideDataForAccompanyingPeriod + */ + public function testBuildFetchQueryForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod, ?\DateTimeImmutable $startDate, ?\DateTimeImmutable $endDate, ?string $content): void + { + $provider = new AccompanyingPeriodCalendarGenericDocProvider($this->security, $this->entityManager); + + $query = $provider->buildFetchQueryForAccompanyingPeriod($accompanyingPeriod, $startDate, $endDate, $content); + + ['sql' => $sql, 'params' => $params, 'types' => $types] = (new FetchQueryToSqlBuilder())->toSql($query); + + $nb = $this->entityManager->getConnection()->fetchOne("SELECT COUNT(*) FROM ({$sql}) AS sq", $params, $types); + + self::assertIsInt($nb); + } + + /** + * @dataProvider provideDataForPerson + */ + public function testBuildFetchQueryForPerson(Person $person, ?\DateTimeImmutable $startDate, ?\DateTimeImmutable $endDate, ?string $content): void + { + $security = $this->prophesize(Security::class); + $security->isGranted(CalendarVoter::SEE, Argument::any())->willReturn(true); + + $provider = new AccompanyingPeriodCalendarGenericDocProvider($security->reveal(), $this->entityManager); + + $query = $provider->buildFetchQueryForPerson($person, $startDate, $endDate, $content); + + ['sql' => $sql, 'params' => $params, 'types' => $types] = (new FetchQueryToSqlBuilder())->toSql($query); + + $nb = $this->entityManager->getConnection()->fetchOne("SELECT COUNT(*) FROM ({$sql}) AS sq", $params, $types); + + self::assertIsInt($nb); + self::assertStringNotContainsStringIgnoringCase('FALSE = TRUE', $sql); + self::assertStringNotContainsStringIgnoringCase('TRUE = FALSE', $sql); + } + + /** + * @dataProvider provideDataForPerson + */ + public function testBuildFetchQueryForPersonWithoutAnyRight(Person $person, ?\DateTimeImmutable $startDate, ?\DateTimeImmutable $endDate, ?string $content): void + { + $security = $this->prophesize(Security::class); + $security->isGranted(CalendarVoter::SEE, Argument::any())->willReturn(false); + + $provider = new AccompanyingPeriodCalendarGenericDocProvider($security->reveal(), $this->entityManager); + + $query = $provider->buildFetchQueryForPerson($person, $startDate, $endDate, $content); + + ['sql' => $sql, 'params' => $params, 'types' => $types] = (new FetchQueryToSqlBuilder())->toSql($query); + + $nb = $this->entityManager->getConnection()->fetchOne("SELECT COUNT(*) FROM ({$sql}) AS sq", $params, $types); + + self::assertIsInt($nb); + self::assertStringContainsStringIgnoringCase('TRUE = FALSE', $sql); + } + + public function provideDataForPerson(): iterable + { + $this->setUp(); + + if (null === $person = $this->entityManager->createQuery("SELECT p FROM " . Person::class . " p WHERE SIZE(p.accompanyingPeriodParticipations) > 0") + ->setMaxResults(1)->getSingleResult()) { + throw new \RuntimeException("There is no person"); + } + + yield [$person, null, null, null]; + yield [$person, new \DateTimeImmutable("1 year ago"), null, null]; + yield [$person, new \DateTimeImmutable("1 year ago"), new \DateTimeImmutable("6 month ago"), null]; + yield [$person, new \DateTimeImmutable("1 year ago"), new \DateTimeImmutable("6 month ago"), "text"]; + yield [$person, null, null, "text"]; + yield [$person, null, new \DateTimeImmutable("6 month ago"), null]; + } + + public function provideDataForAccompanyingPeriod(): iterable + { + $this->setUp(); + + if (null === $period = $this->entityManager->createQuery("SELECT p FROM " . AccompanyingPeriod::class . " p ") + ->setMaxResults(1)->getSingleResult()) { + throw new \RuntimeException("There is no accompanying period"); + } + + yield [$period, null, null, null]; + yield [$period, new \DateTimeImmutable("1 year ago"), null, null]; + yield [$period, new \DateTimeImmutable("1 year ago"), new \DateTimeImmutable("6 month ago"), null]; + yield [$period, new \DateTimeImmutable("1 year ago"), new \DateTimeImmutable("6 month ago"), "text"]; + yield [$period, null, null, "text"]; + yield [$period, null, new \DateTimeImmutable("6 month ago"), null]; + } +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Service/GenericDoc/Providers/PersonCalendarGenericDocProviderTest.php b/src/Bundle/ChillPersonBundle/Tests/Service/GenericDoc/Providers/PersonCalendarGenericDocProviderTest.php new file mode 100644 index 000000000..dbad052ca --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Service/GenericDoc/Providers/PersonCalendarGenericDocProviderTest.php @@ -0,0 +1,70 @@ +security = self::$container->get(Security::class); + $this->entityManager = self::$container->get(EntityManagerInterface::class); + } + + /** + * @dataProvider provideDataForPerson + */ + public function testBuildFetchQueryForPerson(Person $person, ?\DateTimeImmutable $startDate, ?\DateTimeImmutable $endDate, ?string $content): void + { + $provider = new PersonCalendarGenericDocProvider($this->security, $this->entityManager); + + $query = $provider->buildFetchQueryForPerson($person, $startDate, $endDate, $content); + + ['sql' => $sql, 'params' => $params, 'types' => $types] = (new FetchQueryToSqlBuilder())->toSql($query); + + $nb = $this->entityManager->getConnection()->fetchOne("SELECT COUNT(*) FROM ({$sql}) AS sq", $params, $types); + + self::assertIsInt($nb); + } + + public function provideDataForPerson(): iterable + { + $this->setUp(); + + if (null === $person = $this->entityManager->createQuery("SELECT p FROM " . Person::class . " p ") + ->setMaxResults(1)->getSingleResult()) { + throw new \RuntimeException("There is no person"); + } + + yield [$person, null, null, null]; + yield [$person, new \DateTimeImmutable("1 year ago"), null, null]; + yield [$person, new \DateTimeImmutable("1 year ago"), new \DateTimeImmutable("6 month ago"), null]; + yield [$person, new \DateTimeImmutable("1 year ago"), new \DateTimeImmutable("6 month ago"), "text"]; + yield [$person, null, null, "text"]; + yield [$person, null, new \DateTimeImmutable("6 month ago"), null]; + } +} From 1f1ebb6adb0f4c3c823ed803dd745848bc9aad75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 13 Jun 2023 11:30:00 +0200 Subject: [PATCH 190/724] fix mismatch for key in different providers --- .../Repository/ActivityDocumentACLAwareRepository.php | 6 ++++-- .../AccompanyingCourseDocumentGenericDocRenderer.php | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Repository/ActivityDocumentACLAwareRepository.php b/src/Bundle/ChillActivityBundle/Repository/ActivityDocumentACLAwareRepository.php index 180d7fc4a..3ca9281af 100644 --- a/src/Bundle/ChillActivityBundle/Repository/ActivityDocumentACLAwareRepository.php +++ b/src/Bundle/ChillActivityBundle/Repository/ActivityDocumentACLAwareRepository.php @@ -13,6 +13,8 @@ namespace Chill\ActivityBundle\Repository; use Chill\ActivityBundle\Entity\Activity; use Chill\ActivityBundle\Security\Authorization\ActivityVoter; +use Chill\ActivityBundle\Service\GenericDoc\Providers\AccompanyingPeriodActivityGenericDocProvider; +use Chill\ActivityBundle\Service\GenericDoc\Providers\PersonActivityGenericDocProvider; use Chill\DocStoreBundle\Entity\PersonDocument; use Chill\DocStoreBundle\Entity\StoredObject; use Chill\DocStoreBundle\GenericDoc\FetchQuery; @@ -57,7 +59,7 @@ final readonly class ActivityDocumentACLAwareRepository implements ActivityDocum $activityMetadata = $this->em->getClassMetadata(Activity::class); $query = new FetchQuery( - PersonDocumentGenericDocProvider::KEY, + PersonActivityGenericDocProvider::KEY, sprintf('jsonb_build_object(\'id\', stored_obj.%s, \'activity_id\', activity.%s)', $storedObjectMetadata->getSingleIdentifierColumnName(), $activityMetadata->getSingleIdentifierColumnName()), sprintf('stored_obj.%s', $storedObjectMetadata->getColumnName('createdAt')), sprintf('%s AS stored_obj', $storedObjectMetadata->getSchemaName().'.'.$storedObjectMetadata->getTableName()) @@ -86,7 +88,7 @@ final readonly class ActivityDocumentACLAwareRepository implements ActivityDocum $activityMetadata = $this->em->getClassMetadata(Activity::class); $query = new FetchQuery( - PersonDocumentGenericDocProvider::KEY, + AccompanyingPeriodActivityGenericDocProvider::KEY, sprintf('jsonb_build_object(\'id\', stored_obj.%s, \'activity_id\', activity.%s)', $storedObjectMetadata->getSingleIdentifierColumnName(), $activityMetadata->getSingleIdentifierColumnName()), sprintf('stored_obj.%s', $storedObjectMetadata->getColumnName('createdAt')), sprintf('%s AS stored_obj', $storedObjectMetadata->getSchemaName().'.'.$storedObjectMetadata->getTableName()) diff --git a/src/Bundle/ChillDocStoreBundle/GenericDoc/Renderer/AccompanyingCourseDocumentGenericDocRenderer.php b/src/Bundle/ChillDocStoreBundle/GenericDoc/Renderer/AccompanyingCourseDocumentGenericDocRenderer.php index 052153be8..d9c33373e 100644 --- a/src/Bundle/ChillDocStoreBundle/GenericDoc/Renderer/AccompanyingCourseDocumentGenericDocRenderer.php +++ b/src/Bundle/ChillDocStoreBundle/GenericDoc/Renderer/AccompanyingCourseDocumentGenericDocRenderer.php @@ -40,6 +40,7 @@ final readonly class AccompanyingCourseDocumentGenericDocRenderer implements Gen public function getTemplateData(GenericDocDTO $genericDocDTO, $options = []): array { + dump($genericDocDTO); if (AccompanyingCourseDocumentGenericDocProvider::KEY === $genericDocDTO->key) { return [ 'document' => $doc = $this->accompanyingCourseDocumentRepository->find($genericDocDTO->identifiers['id']), @@ -47,10 +48,9 @@ final readonly class AccompanyingCourseDocumentGenericDocRenderer implements Gen 'options' => $options, ]; } - // this is a person return [ - 'document' => $doc = $this->personDocumentRepository->find($genericDocDTO->identifiers['id']), + 'document' => $doc = dump($this->personDocumentRepository->find($genericDocDTO->identifiers['id'])), 'person' => $doc->getPerson(), 'options' => $options, ]; From 909d2dfb60de67059d1391409ba5a42c2bdd754d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 13 Jun 2023 15:00:16 +0200 Subject: [PATCH 191/724] layout for rendering list --- .../Resources/public/chill/chillactivity.scss | 24 +++++++++++ .../GenericDoc/activity_document.html.twig | 32 +++++++------- ...anyingPeriodActivityGenericDocRenderer.php | 4 +- .../translations/messages.fr.yml | 5 +++ .../Resources/public/chill/chill.js | 1 + .../Resources/public/chill/scss/badge.scss | 25 +++++++++++ .../Resources/public/chill/scss/calendar.scss | 2 +- .../GenericDoc/calendar_document.html.twig | 42 +++++++++++-------- ...anyingPeriodCalendarGenericDocRenderer.php | 3 +- .../chill.webpack.config.js | 2 + .../translations/messages.fr.yml | 4 +- .../GenericDoc/GenericDocDTO.php | 5 +++ ...anyingCourseDocumentGenericDocRenderer.php | 5 ++- .../Resources/views/List/list_item.html.twig | 10 ++++- .../translations/messages.fr.yml | 1 + .../chill/scss/accompanying_period_work.scss | 22 ++++++++++ .../GenericDoc/evaluation_document.html.twig | 23 +++++----- ...PeriodWorkEvaluationGenericDocRenderer.php | 4 +- 18 files changed, 162 insertions(+), 52 deletions(-) create mode 100644 src/Bundle/ChillCalendarBundle/Resources/public/chill/chill.js create mode 100644 src/Bundle/ChillCalendarBundle/Resources/public/chill/scss/badge.scss diff --git a/src/Bundle/ChillActivityBundle/Resources/public/chill/chillactivity.scss b/src/Bundle/ChillActivityBundle/Resources/public/chill/chillactivity.scss index d70bd28c3..13de8dfc0 100644 --- a/src/Bundle/ChillActivityBundle/Resources/public/chill/chillactivity.scss +++ b/src/Bundle/ChillActivityBundle/Resources/public/chill/chillactivity.scss @@ -1,5 +1,7 @@ // Access to Bootstrap variables and mixins @import '~ChillMainAssets/module/bootstrap/shared'; +@import '~ChillPersonAssets/chill/scss/mixins.scss'; +@import 'bootstrap/scss/_badge.scss'; //// ACTIVITY CREATION // first step: select type page @@ -96,3 +98,25 @@ li.document-list-item { justify-content: space-between; margin-bottom: 0.3rem; } + +.badge-activity-type { + display: inline-block; + background-color: #f3f3f3; + + .title_label { + @include chill_badge(#9acd32); + } + + .title_action { + padding: var(--bs-badge-padding-y) var(--bs-badge-padding-x); + margin-right: 1rem; + + font-size: var(--bs-badge-font-size); + font-weight: var(--bs-badge-font-weight); + line-height: 1; + color: var(--bs-badge-color); + text-align: center; + white-space: nowrap; + vertical-align: baseline; + } +} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/GenericDoc/activity_document.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/GenericDoc/activity_document.html.twig index 11aeeeca1..5b9547675 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/GenericDoc/activity_document.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/GenericDoc/activity_document.html.twig @@ -20,8 +20,25 @@ {% elseif document.isFailure %}
          {{ 'docgen.Doc generation failed'|trans }}
          {% endif %} + +
          + {% if activity.accompanyingPeriod is not null and context == 'person' %} + + {{ activity.accompanyingPeriod.id }} +   + {% endif %} +
          + + + {{ activity.type.name | localize_translatable_string }} + {% if activity.emergency %} + {{ 'Emergency'|trans|upper }} + {% endif %} + +
          +
          - {{ document.title }} + {{ document.title|chill_print_or_message("No title") }}
          {% if document.hasTemplate %}
          @@ -39,19 +56,6 @@
        -
        -
        -

        - - - {{ activity.type.name | localize_translatable_string }} - {% if activity.emergency %} - {{ 'Emergency'|trans|upper }} - {% endif %} - -

        -
        -
        diff --git a/src/Bundle/ChillActivityBundle/Service/GenericDoc/Renderers/AccompanyingPeriodActivityGenericDocRenderer.php b/src/Bundle/ChillActivityBundle/Service/GenericDoc/Renderers/AccompanyingPeriodActivityGenericDocRenderer.php index a07137206..c465dbca1 100644 --- a/src/Bundle/ChillActivityBundle/Service/GenericDoc/Renderers/AccompanyingPeriodActivityGenericDocRenderer.php +++ b/src/Bundle/ChillActivityBundle/Service/GenericDoc/Renderers/AccompanyingPeriodActivityGenericDocRenderer.php @@ -17,6 +17,7 @@ use Chill\ActivityBundle\Service\GenericDoc\Providers\PersonActivityGenericDocPr use Chill\DocStoreBundle\GenericDoc\GenericDocDTO; use Chill\DocStoreBundle\GenericDoc\Twig\GenericDocRendererInterface; use Chill\DocStoreBundle\Repository\StoredObjectRepository; +use Chill\PersonBundle\Entity\AccompanyingPeriod; final class AccompanyingPeriodActivityGenericDocRenderer implements GenericDocRendererInterface { @@ -44,7 +45,8 @@ final class AccompanyingPeriodActivityGenericDocRenderer implements GenericDocRe { return [ 'activity' => $this->activityRepository->find($genericDocDTO->identifiers['activity_id']), - 'document' => $this->objectRepository->find($genericDocDTO->identifiers['id']) + 'document' => $this->objectRepository->find($genericDocDTO->identifiers['id']), + 'context' => $genericDocDTO->getContext(), ]; } } diff --git a/src/Bundle/ChillActivityBundle/translations/messages.fr.yml b/src/Bundle/ChillActivityBundle/translations/messages.fr.yml index 042fccc69..abef160d3 100644 --- a/src/Bundle/ChillActivityBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillActivityBundle/translations/messages.fr.yml @@ -372,3 +372,8 @@ export: is sent: envoyé is received: reçu Group activity by sentreceived: Grouper les échanges par envoyé / reçu + +generic_doc: + filter: + keys: + accompanying_period_activity_document: Document des échanges des parcours diff --git a/src/Bundle/ChillCalendarBundle/Resources/public/chill/chill.js b/src/Bundle/ChillCalendarBundle/Resources/public/chill/chill.js new file mode 100644 index 000000000..56a8ce563 --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/Resources/public/chill/chill.js @@ -0,0 +1 @@ +import './scss/badge.scss'; diff --git a/src/Bundle/ChillCalendarBundle/Resources/public/chill/scss/badge.scss b/src/Bundle/ChillCalendarBundle/Resources/public/chill/scss/badge.scss new file mode 100644 index 000000000..ffcda8f0f --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/Resources/public/chill/scss/badge.scss @@ -0,0 +1,25 @@ +@import '~ChillPersonAssets/chill/scss/mixins.scss'; +@import '~ChillMainAssets/module/bootstrap/shared'; + +.badge-calendar { + display: inline-block; + background-color: #f3f3f3; + + .title_label { + @include chill_badge($chill-l-gray); + } + + .title_action { + padding: var(--bs-badge-padding-y) var(--bs-badge-padding-x); + margin-right: 1rem; + + font-size: var(--bs-badge-font-size); + font-weight: var(--bs-badge-font-weight); + line-height: 1; + color: var(--bs-badge-color); + text-align: center; + white-space: nowrap; + vertical-align: baseline; + } +} + diff --git a/src/Bundle/ChillCalendarBundle/Resources/public/chill/scss/calendar.scss b/src/Bundle/ChillCalendarBundle/Resources/public/chill/scss/calendar.scss index a2c0c4b89..ce54b0fa8 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/public/chill/scss/calendar.scss +++ b/src/Bundle/ChillCalendarBundle/Resources/public/chill/scss/calendar.scss @@ -17,4 +17,4 @@ span.calendarRangeItems { text-decoration: none; padding: 3px; } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/GenericDoc/calendar_document.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/GenericDoc/calendar_document.html.twig index 4cd369366..facf5be50 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/views/GenericDoc/calendar_document.html.twig +++ b/src/Bundle/ChillCalendarBundle/Resources/views/GenericDoc/calendar_document.html.twig @@ -12,11 +12,31 @@ {% elseif document.storedObject.isFailure %}
        {{ 'docgen.Doc generation failed'|trans }}
        {% endif %} -
        - {{ document.storedObject.title }} -
        +
        - {{ 'chill_calendar.Document'|trans }} + {% if c.accompanyingPeriod is not null and context == 'person' %} + + {{ c.accompanyingPeriod.id }} +   + {% endif %} + + + + + {{ 'Calendar'|trans }} + {% if c.endDate.diff(c.startDate).days >= 1 %} + {{ c.startDate|format_datetime('short', 'short') }} + - {{ c.endDate|format_datetime('short', 'short') }} + {% else %} + {{ c.startDate|format_datetime('short', 'short') }} + - {{ c.endDate|format_datetime('none', 'short') }} + {% endif %} + + +
        + +
        + {{ document.storedObject.title|chill_print_or_message("No title") }}
        {% if document.storedObject.hasTemplate %}
        @@ -34,20 +54,6 @@
        -
        -
        -

        - {% if c.endDate.diff(c.startDate).days >= 1 %} - {{ c.startDate|format_datetime('short', 'short') }} - - {{ c.endDate|format_datetime('short', 'short') }} - {% else %} - {{ c.startDate|format_datetime('short', 'short') }} - - {{ c.endDate|format_datetime('none', 'short') }} - {% endif %} -

        -
        -
        -
        {{ mmm.createdBy(document) }} diff --git a/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Renderers/AccompanyingPeriodCalendarGenericDocRenderer.php b/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Renderers/AccompanyingPeriodCalendarGenericDocRenderer.php index d9636d99d..b15c091c6 100644 --- a/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Renderers/AccompanyingPeriodCalendarGenericDocRenderer.php +++ b/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Renderers/AccompanyingPeriodCalendarGenericDocRenderer.php @@ -39,7 +39,8 @@ final class AccompanyingPeriodCalendarGenericDocRenderer implements GenericDocRe public function getTemplateData(GenericDocDTO $genericDocDTO, $options = []): array { return [ - 'document' => $this->repository->find($genericDocDTO->identifiers['id']) + 'document' => $this->repository->find($genericDocDTO->identifiers['id']), + 'context' => $genericDocDTO->getContext(), ]; } } diff --git a/src/Bundle/ChillCalendarBundle/chill.webpack.config.js b/src/Bundle/ChillCalendarBundle/chill.webpack.config.js index e82210087..9d45a3142 100644 --- a/src/Bundle/ChillCalendarBundle/chill.webpack.config.js +++ b/src/Bundle/ChillCalendarBundle/chill.webpack.config.js @@ -1,6 +1,8 @@ // this file loads all assets from the Chill calendar bundle module.exports = function(encore, entries) { + entries.push(__dirname + '/Resources/public/chill/chill.js'); + encore.addAliases({ ChillCalendarAssets: __dirname + '/Resources/public' }); diff --git a/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml b/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml index 99aae1082..c56d7835f 100644 --- a/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml @@ -151,5 +151,5 @@ CHILL_CALENDAR_CALENDAR_SEE: Voir les rendez-vous generic_doc: filter: keys: - accompanying_period_calendar_document: Document des rendez-vous - person_calendar_document: Document des rendez-vous de la personne + accompanying_period_calendar_document: Document des rendez-vous des parcours + person_calendar_document: Document des rendez-vous de l'usager diff --git a/src/Bundle/ChillDocStoreBundle/GenericDoc/GenericDocDTO.php b/src/Bundle/ChillDocStoreBundle/GenericDoc/GenericDocDTO.php index 25a96750c..fe9bf7e4f 100644 --- a/src/Bundle/ChillDocStoreBundle/GenericDoc/GenericDocDTO.php +++ b/src/Bundle/ChillDocStoreBundle/GenericDoc/GenericDocDTO.php @@ -23,4 +23,9 @@ final readonly class GenericDocDTO public AccompanyingPeriod|Person $linked, ) { } + + public function getContext(): string + { + return $this->linked instanceof AccompanyingPeriod ? 'accompanying-period' : 'person'; + } } diff --git a/src/Bundle/ChillDocStoreBundle/GenericDoc/Renderer/AccompanyingCourseDocumentGenericDocRenderer.php b/src/Bundle/ChillDocStoreBundle/GenericDoc/Renderer/AccompanyingCourseDocumentGenericDocRenderer.php index d9c33373e..c32620030 100644 --- a/src/Bundle/ChillDocStoreBundle/GenericDoc/Renderer/AccompanyingCourseDocumentGenericDocRenderer.php +++ b/src/Bundle/ChillDocStoreBundle/GenericDoc/Renderer/AccompanyingCourseDocumentGenericDocRenderer.php @@ -40,19 +40,20 @@ final readonly class AccompanyingCourseDocumentGenericDocRenderer implements Gen public function getTemplateData(GenericDocDTO $genericDocDTO, $options = []): array { - dump($genericDocDTO); if (AccompanyingCourseDocumentGenericDocProvider::KEY === $genericDocDTO->key) { return [ 'document' => $doc = $this->accompanyingCourseDocumentRepository->find($genericDocDTO->identifiers['id']), 'accompanyingCourse' => $doc->getCourse(), 'options' => $options, + 'context' => $genericDocDTO->getContext(), ]; } // this is a person return [ - 'document' => $doc = dump($this->personDocumentRepository->find($genericDocDTO->identifiers['id'])), + 'document' => $doc = $this->personDocumentRepository->find($genericDocDTO->identifiers['id']), 'person' => $doc->getPerson(), 'options' => $options, + 'context' => $genericDocDTO->getContext(), ]; } } diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/List/list_item.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/List/list_item.html.twig index 8dea4bbe7..9be38074d 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/views/List/list_item.html.twig +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/List/list_item.html.twig @@ -10,8 +10,16 @@ {% elseif document.object.isFailure %}
        {{ 'docgen.Doc generation failed'|trans }}
        {% endif %} + + {% if context == 'person' and accompanyingCourse is defined %} +
        + + {{ accompanyingCourse.id }} +   +
        + {% endif %}
        - {{ document.title }} + {{ document.title|chill_print_or_message("No title") }}
        {% if document.object.type is not empty %}
        diff --git a/src/Bundle/ChillMainBundle/translations/messages.fr.yml b/src/Bundle/ChillMainBundle/translations/messages.fr.yml index 78de523c4..f8f231a7c 100644 --- a/src/Bundle/ChillMainBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillMainBundle/translations/messages.fr.yml @@ -42,6 +42,7 @@ by_user: "par " lifecycleUpdate: Evenements de création et mise à jour address_fields: Données liées à l'adresse Datas: Données +No title: Aucun titre inactive: inactif diff --git a/src/Bundle/ChillPersonBundle/Resources/public/chill/scss/accompanying_period_work.scss b/src/Bundle/ChillPersonBundle/Resources/public/chill/scss/accompanying_period_work.scss index a12f1554c..e82029a1f 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/chill/scss/accompanying_period_work.scss +++ b/src/Bundle/ChillPersonBundle/Resources/public/chill/scss/accompanying_period_work.scss @@ -1,3 +1,25 @@ +.badge-accompanying-work-type { + display: inline-block; + background-color: #f3f3f3; + + .title_label { + @include chill_badge(#e2793d); + } + + .title_action { + padding: var(--bs-badge-padding-y) var(--bs-badge-padding-x); + margin-right: 1rem; + + font-size: var(--bs-badge-font-size); + font-weight: var(--bs-badge-font-weight); + line-height: 1; + color: var(--bs-badge-color); + text-align: center; + white-space: nowrap; + vertical-align: baseline; + } +} + /// AccompanyingCourse Work Pages div.accompanying-course-work { diff --git a/src/Bundle/ChillPersonBundle/Resources/views/GenericDoc/evaluation_document.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/GenericDoc/evaluation_document.html.twig index 255139bb4..ae54d077b 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/GenericDoc/evaluation_document.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/GenericDoc/evaluation_document.html.twig @@ -12,8 +12,19 @@ {% elseif document.storedObject.isFailure %}
        {{ 'docgen.Doc generation failed'|trans }}
        {% endif %} +
        + {% if context == 'person' %} + + {{ w.accompanyingPeriod.id }} +   + {% endif %} +
        + + {{ w.socialAction|chill_entity_render_string }} > {{ document.accompanyingPeriodWorkEvaluation.evaluation.title|localize_translatable_string }} +
        +
        - {{ document.title }} + {{ document.title|chill_print_or_message("No title") }}
        {% if document.storedObject.type is not empty %}
        @@ -36,16 +47,6 @@
        -
        -
        -

        - - {{ w.socialAction|chill_entity_render_string }} > {{ document.accompanyingPeriodWorkEvaluation.evaluation.title|localize_translatable_string }} - -

        -
        -
        -
        {{ mmm.createdBy(document) }} diff --git a/src/Bundle/ChillPersonBundle/Service/GenericDoc/Renderer/AccompanyingPeriodWorkEvaluationGenericDocRenderer.php b/src/Bundle/ChillPersonBundle/Service/GenericDoc/Renderer/AccompanyingPeriodWorkEvaluationGenericDocRenderer.php index 5da8297fb..9810fe7a1 100644 --- a/src/Bundle/ChillPersonBundle/Service/GenericDoc/Renderer/AccompanyingPeriodWorkEvaluationGenericDocRenderer.php +++ b/src/Bundle/ChillPersonBundle/Service/GenericDoc/Renderer/AccompanyingPeriodWorkEvaluationGenericDocRenderer.php @@ -13,6 +13,7 @@ namespace Chill\PersonBundle\Service\GenericDoc\Renderer; use Chill\DocStoreBundle\GenericDoc\GenericDocDTO; use Chill\DocStoreBundle\GenericDoc\Twig\GenericDocRendererInterface; +use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocumentRepository; use Chill\PersonBundle\Service\GenericDoc\Providers\AccompanyingPeriodWorkEvaluationGenericDocProvider; @@ -36,7 +37,8 @@ final readonly class AccompanyingPeriodWorkEvaluationGenericDocRenderer implemen public function getTemplateData(GenericDocDTO $genericDocDTO, $options = []): array { return [ - 'document' => $this->accompanyingPeriodWorkEvaluationDocumentRepository->find($genericDocDTO->identifiers['id']) + 'document' => $this->accompanyingPeriodWorkEvaluationDocumentRepository->find($genericDocDTO->identifiers['id']), + 'context' => $genericDocDTO->getContext(), ]; } } From 29140d9374f534f7d21f29000948f0d36d5610c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 13 Jun 2023 15:16:03 +0200 Subject: [PATCH 192/724] add changelog entry --- .changes/unreleased/Feature-20230613-151546.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changes/unreleased/Feature-20230613-151546.yaml diff --git a/.changes/unreleased/Feature-20230613-151546.yaml b/.changes/unreleased/Feature-20230613-151546.yaml new file mode 100644 index 000000000..e66076aa5 --- /dev/null +++ b/.changes/unreleased/Feature-20230613-151546.yaml @@ -0,0 +1,5 @@ +kind: Feature +body: Get an unified list of document in person and accompanying period context +time: 2023-06-13T15:15:46.146899906+02:00 +custom: + Issue: "103" From c4dd46a03c8e10020adc8186deea894617b2a2ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 13 Jun 2023 15:26:21 +0200 Subject: [PATCH 193/724] fix phpstan issues --- .../ChillReportBundle/DataFixtures/ORM/LoadReports.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReports.php b/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReports.php index db4646eed..30477f269 100644 --- a/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReports.php +++ b/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReports.php @@ -166,7 +166,7 @@ class LoadReports extends AbstractFixture implements ContainerAwareInterface, Or /** * pick a random choice. * - * @return string|string[] the array of slug if multiple, a single slug otherwise + * @return string|string[] */ private function getRandomChoice(CustomField $field) { @@ -211,6 +211,8 @@ class LoadReports extends AbstractFixture implements ContainerAwareInterface, Or return $result; } } + + return $picked; } /** @@ -226,7 +228,7 @@ class LoadReports extends AbstractFixture implements ContainerAwareInterface, Or /** * pick a choice within a 'choices' options (for choice type). * - * @return the slug of the selected choice + * @return string the slug of the selected choice */ private function pickChoice(array $choices) { From 24049b9dfcceb83764d0cbc044de18268caf9dbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 13 Jun 2023 15:33:03 +0200 Subject: [PATCH 194/724] remove unused file --- .../AccompanyingCourseDocumentProvider.php | 54 ------------------- 1 file changed, 54 deletions(-) delete mode 100644 src/Bundle/ChillDocStoreBundle/GenericDoc/Providers/AccompanyingCourseDocumentProvider.php diff --git a/src/Bundle/ChillDocStoreBundle/GenericDoc/Providers/AccompanyingCourseDocumentProvider.php b/src/Bundle/ChillDocStoreBundle/GenericDoc/Providers/AccompanyingCourseDocumentProvider.php deleted file mode 100644 index 163d17458..000000000 --- a/src/Bundle/ChillDocStoreBundle/GenericDoc/Providers/AccompanyingCourseDocumentProvider.php +++ /dev/null @@ -1,54 +0,0 @@ -entityManager->getClassMetadata(AccompanyingCourseDocument::class); - - $query = new FetchQuery( - 'accompanying_course_document', - sprintf('jsonb_build_object(\'id\', %s)', $classMetadata->getIdentifierColumnNames()[0]), - sprintf($classMetadata->getColumnName('date')), - $classMetadata->getSchemaName() . '.' . $classMetadata->getTableName() - ); - - $query->addWhereClause( - sprintf('%s = ?', $classMetadata->getSingleAssociationJoinColumnName('course')), - [$accompanyingPeriod->getId()] - ); - - return $query; - } - - public function isAllowedForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod): bool - { - return $this->security->isGranted(AccompanyingCourseDocumentVoter::SEE, $accompanyingPeriod); - } -} From 5495b1cb447b2763948776dd3fc4440d9a73e485 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 13 Jun 2023 15:33:10 +0200 Subject: [PATCH 195/724] fix condition --- .../Repository/ActivityDocumentACLAwareRepository.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bundle/ChillActivityBundle/Repository/ActivityDocumentACLAwareRepository.php b/src/Bundle/ChillActivityBundle/Repository/ActivityDocumentACLAwareRepository.php index 3ca9281af..ce70409ba 100644 --- a/src/Bundle/ChillActivityBundle/Repository/ActivityDocumentACLAwareRepository.php +++ b/src/Bundle/ChillActivityBundle/Repository/ActivityDocumentACLAwareRepository.php @@ -153,7 +153,7 @@ final readonly class ActivityDocumentACLAwareRepository implements ActivityDocum ); } - if (null !== $content or '' !== $content) { + if (null !== $content and '' !== $content) { $query->addWhereClause( 'stored_obj.title ilike ?', ['%' . $content . '%'], From c683123ecaf9efb4b65ad6a616115eea7796f151 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 13 Jun 2023 15:47:06 +0200 Subject: [PATCH 196/724] set blinking animation on item-row, not just on the input --- .../AccompanyingCourseWorkEdit/components/FormEvaluation.vue | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue index 10bac43b3..3788c3454 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue @@ -79,14 +79,13 @@
        {{ $t('Documents') }} :
        -
        +
        Date: Tue, 13 Jun 2023 15:49:16 +0200 Subject: [PATCH 197/724] add changelog entry --- .changes/unreleased/Feature-20230613-154903.yaml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .changes/unreleased/Feature-20230613-154903.yaml diff --git a/.changes/unreleased/Feature-20230613-154903.yaml b/.changes/unreleased/Feature-20230613-154903.yaml new file mode 100644 index 000000000..7506bf473 --- /dev/null +++ b/.changes/unreleased/Feature-20230613-154903.yaml @@ -0,0 +1,7 @@ +kind: Feature +body: When navigating from a workflow regarding to an evaluation's document to an + accompanying course, scroll directly to the document, and blink to highlight this + document +time: 2023-06-13T15:49:03.663438985+02:00 +custom: + Issue: "" From a136a278daa4e10dd30be72b1bfbcc5142252fc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 13 Jun 2023 15:53:50 +0200 Subject: [PATCH 198/724] remove console.log --- .../public/vuejs/_components/Entity/PersonRenderBox.vue | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonRenderBox.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonRenderBox.vue index 809859114..2576efd35 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonRenderBox.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonRenderBox.vue @@ -261,7 +261,6 @@ export default { return this.person.gender === 'woman' ? 'person.gender.woman' : this.person.gender === 'man' ? 'person.gender.man' : this.person.gender === 'neuter' ? 'person.gender.neuter' : 'person.gender.undefined'; }, birthdate: function () { - console.log('debug birthdate', this.person.birthdate.datetime, ISOToDate(this.person.birthdate.datetime), new Date(this.person.birthdate.datetime)); if (this.person.birthdate !== null || this.person.birthdate === "undefined") { return ISOToDate(this.person.birthdate.datetime); } else { From fadc007bfe6c6cd19d4b5acf3046d1cac286b93d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 13 Jun 2023 15:55:05 +0200 Subject: [PATCH 199/724] add changelog entry --- .changes/unreleased/Fixed-20230613-155453.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changes/unreleased/Fixed-20230613-155453.yaml diff --git a/.changes/unreleased/Fixed-20230613-155453.yaml b/.changes/unreleased/Fixed-20230613-155453.yaml new file mode 100644 index 000000000..f183c3a17 --- /dev/null +++ b/.changes/unreleased/Fixed-20230613-155453.yaml @@ -0,0 +1,5 @@ +kind: Fixed +body: Fix birthdate timezone in PersonRenderBox +time: 2023-06-13T15:54:53.125120559+02:00 +custom: + Issue: "58" From cb4de1f3d2666af9f29143661cb092425a0777ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 13 Jun 2023 22:58:08 +0200 Subject: [PATCH 200/724] Fixes for work rendering without "onlyone" parameter --- .../_objectifs_results_evaluations.html.twig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_objectifs_results_evaluations.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_objectifs_results_evaluations.html.twig index 51621f432..da6ec6e32 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_objectifs_results_evaluations.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_objectifs_results_evaluations.html.twig @@ -65,7 +65,7 @@
    - {% if onlyone %} + {% if onlyone|default(false) %} {% for e in w.accompanyingPeriodWorkEvaluations %} {% if evalId is defined and evalId == e.id %} @@ -275,7 +275,7 @@ 'entityClass': 'Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluationDocument', 'entityId': d.id }) }}"> {% endif %} - + {{ d.storedObject|chill_document_button_group(d.title, is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_UPDATE', w), {'small': true}) }} From 3879e5cd9bc1c554a551fe519598eb48d111dcf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 13 Jun 2023 23:03:15 +0200 Subject: [PATCH 201/724] Notification: fix counter, and allow to add more related entity in a single query Sometimes, there are entities which embed other entities, which in turn have notification. This more parameter allow to fetch notification and counter for those embedded entities in a single query. --- .../Notification/NotificationPresence.php | 23 ++-- .../NotificationTwigExtensionRuntime.php | 18 ++- .../Repository/NotificationRepository.php | 104 +++++++++++++----- ...ension_counter_notifications_for.html.twig | 2 +- 4 files changed, 105 insertions(+), 42 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Notification/NotificationPresence.php b/src/Bundle/ChillMainBundle/Notification/NotificationPresence.php index c09b845d7..a6e02c4ea 100644 --- a/src/Bundle/ChillMainBundle/Notification/NotificationPresence.php +++ b/src/Bundle/ChillMainBundle/Notification/NotificationPresence.php @@ -34,9 +34,13 @@ class NotificationPresence $this->notificationRepository = $notificationRepository; } - public function countNotificationsForClassAndEntity(string $relatedEntityClass, int $relatedEntityId): array + /** + * @param list $more + * @return array{unread: int, sent: int, total: int} + */ + public function countNotificationsForClassAndEntity(string $relatedEntityClass, int $relatedEntityId, array $more = [], array $options = []): array { - if (array_key_exists($relatedEntityClass, $this->cache) && array_key_exists($relatedEntityId, $this->cache[$relatedEntityClass])) { + if ([] === $more && array_key_exists($relatedEntityClass, $this->cache) && array_key_exists($relatedEntityId, $this->cache[$relatedEntityClass])) { return $this->cache[$relatedEntityClass][$relatedEntityId]; } @@ -46,21 +50,25 @@ class NotificationPresence $counter = $this->notificationRepository->countNotificationByRelatedEntityAndUserAssociated( $relatedEntityClass, $relatedEntityId, - $user + $user, + $more ); - $this->cache[$relatedEntityClass][$relatedEntityId] = $counter; + if ([] === $more) { + $this->cache[$relatedEntityClass][$relatedEntityId] = $counter; + } return $counter; } - return ['unread' => 0, 'read' => 0]; + return ['unread' => 0, 'sent' => 0, 'total' => 0]; } /** + * @param list $more * @return array|Notification[] */ - public function getNotificationsForClassAndEntity(string $relatedEntityClass, int $relatedEntityId): array + public function getNotificationsForClassAndEntity(string $relatedEntityClass, int $relatedEntityId, array $more = []): array { $user = $this->security->getUser(); @@ -68,7 +76,8 @@ class NotificationPresence return $this->notificationRepository->findNotificationByRelatedEntityAndUserAssociated( $relatedEntityClass, $relatedEntityId, - $user + $user, + $more ); } diff --git a/src/Bundle/ChillMainBundle/Notification/Templating/NotificationTwigExtensionRuntime.php b/src/Bundle/ChillMainBundle/Notification/Templating/NotificationTwigExtensionRuntime.php index 0720c6da6..a8751374e 100644 --- a/src/Bundle/ChillMainBundle/Notification/Templating/NotificationTwigExtensionRuntime.php +++ b/src/Bundle/ChillMainBundle/Notification/Templating/NotificationTwigExtensionRuntime.php @@ -34,24 +34,30 @@ class NotificationTwigExtensionRuntime implements RuntimeExtensionInterface $this->urlGenerator = $urlGenerator; } - public function counterNotificationFor(Environment $environment, string $relatedEntityClass, int $relatedEntityId, array $options = []): string + public function counterNotificationFor(Environment $environment, string $relatedEntityClass, int $relatedEntityId, array $more = [], array $options = []): string { return $environment->render( '@ChillMain/Notification/extension_counter_notifications_for.html.twig', [ - 'counter' => $this->notificationPresence->countNotificationsForClassAndEntity($relatedEntityClass, $relatedEntityId), + 'counter' => $this->notificationPresence->countNotificationsForClassAndEntity($relatedEntityClass, $relatedEntityId, $more), ] ); } - public function countNotificationsFor(string $relatedEntityClass, int $relatedEntityId, array $options = []): array + /** + * @param list $more + */ + public function countNotificationsFor(string $relatedEntityClass, int $relatedEntityId, array $more = [], array $options = []): array { - return $this->notificationPresence->countNotificationsForClassAndEntity($relatedEntityClass, $relatedEntityId); + return $this->notificationPresence->countNotificationsForClassAndEntity($relatedEntityClass, $relatedEntityId, $more); } - public function listNotificationsFor(Environment $environment, string $relatedEntityClass, int $relatedEntityId, array $options = []): string + /** + * @param list $more + */ + public function listNotificationsFor(Environment $environment, string $relatedEntityClass, int $relatedEntityId, array $more = [], array $options = []): string { - $notifications = $this->notificationPresence->getNotificationsForClassAndEntity($relatedEntityClass, $relatedEntityId); + $notifications = $this->notificationPresence->getNotificationsForClassAndEntity($relatedEntityClass, $relatedEntityId, $more); if ([] === $notifications) { return ''; diff --git a/src/Bundle/ChillMainBundle/Repository/NotificationRepository.php b/src/Bundle/ChillMainBundle/Repository/NotificationRepository.php index 72f9ea5d1..fe42578d9 100644 --- a/src/Bundle/ChillMainBundle/Repository/NotificationRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/NotificationRepository.php @@ -29,6 +29,15 @@ final class NotificationRepository implements ObjectRepository private EntityRepository $repository; + private const BASE_COUNTER_SQL = <<<'SQL' + SELECT + SUM((EXISTS (SELECT 1 AS c FROM chill_main_notification_addresses_unread cmnau WHERE user_id = :userid and cmnau.notification_id = cmn.id))::int) AS unread, + SUM((cmn.sender_id = :userid)::int) AS sent, + SUM((EXISTS (SELECT 1 AS c FROM chill_main_notification_addresses_user cmnau_all WHERE user_id = :userid and cmnau_all.notification_id = cmn.id))::int) + SUM((cmn.sender_id = :userid)::int) AS total + FROM chill_main_notification cmn + SQL; + + public function __construct(EntityManagerInterface $entityManager) { $this->em = $entityManager; @@ -51,29 +60,45 @@ final class NotificationRepository implements ObjectRepository ->getSingleScalarResult(); } - public function countNotificationByRelatedEntityAndUserAssociated(string $relatedEntityClass, int $relatedEntityId, User $user): array + /** + * @param list $more + * @return array{unread: int, sent: int, total: int} + */ + public function countNotificationByRelatedEntityAndUserAssociated(string $relatedEntityClass, int $relatedEntityId, User $user, array $more = []): array { - if (null === $this->notificationByRelatedEntityAndUserAssociatedStatement) { - $sql = - 'SELECT - SUM((EXISTS (SELECT 1 AS c FROM chill_main_notification_addresses_unread cmnau WHERE user_id = :userid and cmnau.notification_id = cmn.id))::int) AS unread, - SUM((cmn.sender_id = :userid)::int) AS sent, - COUNT(cmn.*) AS total - FROM chill_main_notification cmn - WHERE relatedentityclass = :relatedEntityClass AND relatedentityid = :relatedEntityId AND sender_id IS NOT NULL'; + $sqlParams = ['relatedEntityClass' => $relatedEntityClass, 'relatedEntityId' => $relatedEntityId, 'userid' => $user->getId()]; - $this->notificationByRelatedEntityAndUserAssociatedStatement = - $this->em->getConnection()->prepare($sql); + if ([] === $more) { + if (null === $this->notificationByRelatedEntityAndUserAssociatedStatement) { + $sql = self::BASE_COUNTER_SQL . ' WHERE relatedentityclass = :relatedEntityClass AND relatedentityid = :relatedEntityId AND sender_id IS NOT NULL'; + + $this->notificationByRelatedEntityAndUserAssociatedStatement = + $this->em->getConnection()->prepare($sql); + } + + $results = $this->notificationByRelatedEntityAndUserAssociatedStatement + ->executeQuery($sqlParams); + + $result = $results->fetchAssociative(); + + $results->free(); + } else { + $wheres = []; + foreach ([ + ['relatedEntityClass' => $relatedEntityClass, 'relatedEntityId' => $relatedEntityId], + ...$more + ] as $k => ['relatedEntityClass' => $relClass, 'relatedEntityId' => $relId]) { + $wheres[] = "(relatedEntityClass = :relatedEntityClass_{$k} AND relatedEntityId = :relatedEntityId_{$k})"; + $sqlParams["relatedEntityClass_{$k}"] = $relClass; + $sqlParams["relatedEntityId_{$k}"] = $relId; + } + + $sql = self::BASE_COUNTER_SQL . ' WHERE sender_id IS NOT NULL AND (' . implode(' OR ', $wheres) . ')'; + + $result = $this->em->getConnection()->fetchAssociative($sql, $sqlParams); } - $results = $this->notificationByRelatedEntityAndUserAssociatedStatement - ->executeQuery(['relatedEntityClass' => $relatedEntityClass, 'relatedEntityId' => $relatedEntityId, 'userid' => $user->getId()]); - - $result = $results->fetchAssociative(); - - $results->free(); - - return $result; + return array_map(fn (?int $number) => $number ?? 0, $result); } public function countUnreadByUser(User $user): int @@ -167,8 +192,8 @@ final class NotificationRepository implements ObjectRepository } /** - * @param mixed|null $limit - * @param mixed|null $offset + * @param int|null $limit + * @param int|null $offset * * @return Notification[] */ @@ -178,13 +203,15 @@ final class NotificationRepository implements ObjectRepository } /** + * @param list $more * @return array|Notification[] */ - public function findNotificationByRelatedEntityAndUserAssociated(string $relatedEntityClass, int $relatedEntityId, User $user): array + public function findNotificationByRelatedEntityAndUserAssociated(string $relatedEntityClass, int $relatedEntityId, User $user, array $more): array { return - $this->buildQueryNotificationByRelatedEntityAndUserAssociated($relatedEntityClass, $relatedEntityId, $user) + $this->buildQueryNotificationByRelatedEntityAndUserAssociated($relatedEntityClass, $relatedEntityId, $user, $more) ->select('n') + ->addOrderBy('n.date', 'DESC') ->getQuery() ->getResult(); } @@ -222,13 +249,36 @@ final class NotificationRepository implements ObjectRepository return Notification::class; } - private function buildQueryNotificationByRelatedEntityAndUserAssociated(string $relatedEntityClass, int $relatedEntityId, User $user): QueryBuilder + /** + * @param list $more + */ + private function buildQueryNotificationByRelatedEntityAndUserAssociated(string $relatedEntityClass, int $relatedEntityId, User $user, array $more = []): QueryBuilder { $qb = $this->repository->createQueryBuilder('n'); + // add condition for related entity (in main arguments, and in more) + $or = $qb->expr()->orX($qb->expr()->andX( + $qb->expr()->eq('n.relatedEntityClass', ':relatedEntityClass'), + $qb->expr()->eq('n.relatedEntityId', ':relatedEntityId') + )); $qb - ->where($qb->expr()->eq('n.relatedEntityClass', ':relatedEntityClass')) - ->andWhere($qb->expr()->eq('n.relatedEntityId', ':relatedEntityId')) + ->setParameter('relatedEntityClass', $relatedEntityClass) + ->setParameter('relatedEntityId', $relatedEntityId); + + foreach ($more as $k => ['relatedEntityClass' => $relatedClass, 'relatedEntityId' => $relatedId]) { + $or->add( + $qb->expr()->andX( + $qb->expr()->eq('n.relatedEntityClass', ':relatedEntityClass_'.$k), + $qb->expr()->eq('n.relatedEntityId', ':relatedEntityId_'.$k) + ) + ); + $qb + ->setParameter('relatedEntityClass_'.$k, $relatedClass) + ->setParameter('relatedEntityId_'.$k, $relatedId); + } + + $qb + ->andWhere($or) ->andWhere($qb->expr()->isNotNull('n.sender')) ->andWhere( $qb->expr()->orX( @@ -236,8 +286,6 @@ final class NotificationRepository implements ObjectRepository $qb->expr()->eq('n.sender', ':user') ) ) - ->setParameter('relatedEntityClass', $relatedEntityClass) - ->setParameter('relatedEntityId', $relatedEntityId) ->setParameter('user', $user); return $qb; diff --git a/src/Bundle/ChillMainBundle/Resources/views/Notification/extension_counter_notifications_for.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Notification/extension_counter_notifications_for.html.twig index d92e4230e..0e64e9f6a 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Notification/extension_counter_notifications_for.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Notification/extension_counter_notifications_for.html.twig @@ -9,4 +9,4 @@ {{ 'notification.counter unread notifications'|trans({'unread': counter.unread }) }} {% endif %} - \ No newline at end of file + From a6b451df98e60e3b7e9b56c85dd8e13194f58619 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 13 Jun 2023 23:04:41 +0200 Subject: [PATCH 202/724] Fix counter on notification for document, using "more" parameter The counter now show results for embedded document, in the accompanying period work list. --- .../AccompanyingCourseWork/_macros.html.twig | 20 ++++++++++++++----- .../AccompanyingCourseWork/show.html.twig | 15 +++++++++++++- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_macros.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_macros.html.twig index 10a0f94c7..b04e9483a 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_macros.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_macros.html.twig @@ -1,7 +1,17 @@ -{% macro metadata(w) %} - {% set notif_counter = chill_count_notifications('Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWork', w.id) %} - {% if notif_counter.total > 0 %} - {{ chill_counter_notifications('Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWork', w.id) }} +{% macro metadata(w, include_notif_counter = true) %} + {% if include_notif_counter == true %} + {% set more = [] %} + {% for e in w.accompanyingPeriodWorkEvaluations %} + {% for d in e.documents %} + {% set more = more|merge([{'relatedEntityClass': 'Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluationDocument', 'relatedEntityId': d.id}]) %} + {% endfor %} + {% endfor %} + + {% set notif_counter = chill_count_notifications('Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWork', w.id, more) %} + + {% if notif_counter.total > 0 %} + {{ chill_counter_notifications('Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWork', w.id, more) }} + {% endif %} {% endif %} {% import '@ChillPerson/Macro/updatedBy.html.twig' as macro %} {{ macro.updatedBy(w) }} @@ -20,4 +30,4 @@ {% endfor %} {% endfor %} {{ chill_entity_workflow_list('Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWork', w.id, [], suppEvaluations) }} -{% endmacro %} \ No newline at end of file +{% endmacro %} diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/show.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/show.html.twig index d32c1b700..438a6fb7f 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/show.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/show.html.twig @@ -27,7 +27,20 @@ 'displayContent': 'long', 'itemBlocClass': 'uniq extended', } %} -
    {{ macro.metadata(work) }}
    +
    {{ macro.metadata(work, false) }}
    + + +
    + {% set more = [] %} + {% for e in work.accompanyingPeriodWorkEvaluations %} + {% for d in e.documents %} + {% set more = more|merge([{'relatedEntityClass': 'Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluationDocument', 'relatedEntityId': d.id}]) %} + {% endfor %} + {% endfor %} + {% set notifications = chill_list_notifications('Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWork', work.id, more) %} + {% if notifications is not empty %} + {{ notifications|raw }} + {% endif %}
      From 56957250bad8f21e63d928f6d8db7c63ec0965d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 13 Jun 2023 23:05:09 +0200 Subject: [PATCH 203/724] re-use the display of workflow for the notification on evaluation document --- ...kEvaluationDocumentNotificationHandler.php | 3 +- ...EvaluationDocumentInNotification.html.twig | 143 ++++++++++++++---- 2 files changed, 119 insertions(+), 27 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodWorkEvaluationDocumentNotificationHandler.php b/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodWorkEvaluationDocumentNotificationHandler.php index f5ce07c8e..4dcb03489 100644 --- a/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodWorkEvaluationDocumentNotificationHandler.php +++ b/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodWorkEvaluationDocumentNotificationHandler.php @@ -35,7 +35,8 @@ final class AccompanyingPeriodWorkEvaluationDocumentNotificationHandler implemen { return [ 'notification' => $notification, - 'document' => $this->accompanyingPeriodWorkEvaluationDocumentRepository->find($notification->getRelatedEntityId()), + 'document' => $doc = $this->accompanyingPeriodWorkEvaluationDocumentRepository->find($notification->getRelatedEntityId()), + 'evaluation' => $doc?->getAccompanyingPeriodWorkEvaluation(), ]; } diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showEvaluationDocumentInNotification.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showEvaluationDocumentInNotification.html.twig index b4df52254..0341e42e5 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showEvaluationDocumentInNotification.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showEvaluationDocumentInNotification.html.twig @@ -1,32 +1,123 @@ -{% macro recordAction(document) %} - {% import "@ChillDocStore/Macro/macro_mimeicon.html.twig" as mm %} -
      -
    {{ 'Budget element type'|trans }} @@ -80,10 +80,9 @@ {% set result = (totalResources - totalCharges) %} - +
    - @@ -91,7 +90,6 @@ - diff --git a/src/Bundle/ChillBudgetBundle/Resources/views/Person/index.html.twig b/src/Bundle/ChillBudgetBundle/Resources/views/Person/index.html.twig index 959df3d62..18d04b889 100644 --- a/src/Bundle/ChillBudgetBundle/Resources/views/Person/index.html.twig +++ b/src/Bundle/ChillBudgetBundle/Resources/views/Person/index.html.twig @@ -17,17 +17,15 @@ {% block content %}

    {{ title }}

    -{% include 'ChillBudgetBundle:Budget:_budget.html.twig' with { +{% include '@ChillBudget/Budget/_budget.html.twig' with { 'resources': resources, 'charges': charges, 'person': person } %} -
    -

    {{ 'Budget calculator'|trans }}

    -
    - {{ table_results(charges, resources) }} -
    +
    +

    {{ 'Budget calculator'|trans }}

    + {{ table_results(charges, resources) }}
    {% if is_granted('CHILL_BUDGET_ELEMENT_CREATE', person) %} From e84a93bd0c7f0c236145f7794ee70eba7ea081c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 30 Mar 2023 11:49:04 +0200 Subject: [PATCH 009/724] wip prepare rector config for up to PHP74 ruleset --- rector.php | 47 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 6 deletions(-) diff --git a/rector.php b/rector.php index 2c5b08bec..ec9a0c684 100644 --- a/rector.php +++ b/rector.php @@ -12,14 +12,49 @@ return static function (RectorConfig $rectorConfig): void { __DIR__ . '/src', ]); - $rectorConfig->cacheClass(\Rector\Caching\ValueObject\Storage\FileCacheStorage::class); - $rectorConfig->cacheDirectory(__DIR__.'/.cache/rector'); + //$rectorConfig->cacheClass(\Rector\Caching\ValueObject\Storage\FileCacheStorage::class); + //$rectorConfig->cacheDirectory(__DIR__ . '/.cache/rector'); // register a single rule $rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class); + $rectorConfig->disableParallel(); - // define sets of rules - // $rectorConfig->sets([ - // LevelSetList::UP_TO_PHP_74 - // ]); + //define sets of rules + $rectorConfig->sets([ + LevelSetList::UP_TO_PHP_74 + ]); + + // skip some path... + $rectorConfig->skip([ + // make rector stuck for some files + \Rector\Php56\Rector\FunctionLike\AddDefaultValueForUndefinedVariableRector::class, + + // we need to discuss this: are we going to have FALSE in tests instead of an error ? + \Rector\Php71\Rector\FuncCall\CountOnNullRector::class, + + // must merge MR500 and review a typing of "ArrayCollection" in entities + \Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector::class, + + // remove all PHP80 rules, in order to activate them one by one + \Rector\Php80\Rector\ClassMethod\AddParamBasedOnParentClassMethodRector::class, + \Rector\Php80\Rector\Class_\AnnotationToAttributeRector::class, + \Rector\Php80\Rector\Switch_\ChangeSwitchToMatchRector::class, + \Rector\Php80\Rector\FuncCall\ClassOnObjectRector::class, + \Rector\Php80\Rector\ClassConstFetch\ClassOnThisVariableObjectRector::class, + \Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector::class, + \Rector\Php80\Rector\Class_\DoctrineAnnotationClassToAttributeRector::class, + \Rector\Php80\Rector\ClassMethod\FinalPrivateToPrivateVisibilityRector::class, + \Rector\Php80\Rector\Ternary\GetDebugTypeRector::class, + \Rector\Php80\Rector\FunctionLike\MixedTypeRector::class, + \Rector\Php80\Rector\Property\NestedAnnotationToAttributeRector::class, + \Rector\Php80\Rector\FuncCall\Php8ResourceReturnToObjectRector::class, + \Rector\Php80\Rector\Catch_\RemoveUnusedVariableInCatchRector::class, + \Rector\Php80\Rector\ClassMethod\SetStateToStaticRector::class, + \Rector\Php80\Rector\NotIdentical\StrContainsRector::class, + \Rector\Php80\Rector\Identical\StrEndsWithRector::class, + \Rector\Php80\Rector\Identical\StrStartsWithRector::class, + \Rector\Php80\Rector\Class_\StringableForToStringRector::class, + \Rector\Php80\Rector\FuncCall\TokenGetAllToObjectRector::class, + \Rector\Php80\Rector\FunctionLike\UnionTypesRector::class + ]); }; From d8d517017ddcd03bd85ecc0a21f73f94076384f1 Mon Sep 17 00:00:00 2001 From: Lucas Silva Date: Thu, 30 Mar 2023 14:31:02 +0200 Subject: [PATCH 010/724] switching to new syntax --- .../AccompanyingPeriodNotificationHandler.php | 2 +- ...dWorkEvaluationDocumentNotificationHandler.php | 2 +- .../AccompanyingPeriodWorkNotificationHandler.php | 2 +- ...showEvaluationDocumentInNotification.html.twig | 15 ++++++++++----- .../showInNotification.html.twig | 2 +- .../showInNotification.html.twig | 3 +-- 6 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodNotificationHandler.php b/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodNotificationHandler.php index 486209453..2492e9a41 100644 --- a/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodNotificationHandler.php +++ b/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodNotificationHandler.php @@ -27,7 +27,7 @@ final class AccompanyingPeriodNotificationHandler implements NotificationHandler public function getTemplate(Notification $notification, array $options = []): string { - return 'ChillPersonBundle:AccompanyingPeriod:showInNotification.html.twig'; + return '@ChillPerson/AccompanyingPeriod/showInNotification.html.twig'; } public function getTemplateData(Notification $notification, array $options = []): array diff --git a/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodWorkEvaluationDocumentNotificationHandler.php b/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodWorkEvaluationDocumentNotificationHandler.php index 1f3ed0fb6..f5ce07c8e 100644 --- a/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodWorkEvaluationDocumentNotificationHandler.php +++ b/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodWorkEvaluationDocumentNotificationHandler.php @@ -28,7 +28,7 @@ final class AccompanyingPeriodWorkEvaluationDocumentNotificationHandler implemen public function getTemplate(Notification $notification, array $options = []): string { - return 'ChillPersonBundle:AccompanyingCourseWork:showEvaluationDocumentInNotification.html.twig'; + return '@ChillPerson/AccompanyingCourseWork/showEvaluationDocumentInNotification.html.twig'; } public function getTemplateData(Notification $notification, array $options = []): array diff --git a/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodWorkNotificationHandler.php b/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodWorkNotificationHandler.php index dbb30e983..b111c131f 100644 --- a/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodWorkNotificationHandler.php +++ b/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodWorkNotificationHandler.php @@ -28,7 +28,7 @@ final class AccompanyingPeriodWorkNotificationHandler implements NotificationHan public function getTemplate(Notification $notification, array $options = []): string { - return 'ChillPersonBundle:AccompanyingCourseWork:showInNotification.html.twig'; + return '@ChillPerson/AccompanyingCourseWork/showInNotification.html.twig'; } public function getTemplateData(Notification $notification, array $options = []): array diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showEvaluationDocumentInNotification.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showEvaluationDocumentInNotification.html.twig index 83ba7bf91..f4c9c1bf7 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showEvaluationDocumentInNotification.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showEvaluationDocumentInNotification.html.twig @@ -5,13 +5,18 @@ {% endmacro %} {% if document is not null %} +
    {% if is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_EVALUATION_DOCUMENT_SHOW', document) %} - {% include 'ChillPersonBundle:AccompanyingCourseWork:_objectifs_results_evaluations.html.twig' with { - 'w': document.accompanyingPeriodWorkEvaluation.accompanyingPeriodWork, - 'd': document.storedObject, - 'displayContent': 'long', - } %} +
    + {% include '@ChillPerson/AccompanyingCourseWork/_objectifs_results_evaluations.html.twig' with { + 'w': document.accompanyingPeriodWorkEvaluation.accompanyingPeriodWork, + 'd': document.storedObject, + 'displayContent': 'short', + 'recordAction': _self.recordAction(document) + } %} +
    + {% else %}
    {{ 'This is the minimal period details'|trans ~ ': ' ~ document.id }}
    diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showInNotification.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showInNotification.html.twig index 311692030..4ee561381 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showInNotification.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showInNotification.html.twig @@ -7,7 +7,7 @@ {% if work is not null %}
    {% if is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_SEE', work) %} - {% include 'ChillPersonBundle:AccompanyingCourseWork:_item.html.twig' with { + {% include "@ChillPerson/AccompanyingCourseWork/_item.html.twig" with { 'itemBlocClass': 'bg-chill-llight-gray', 'displayAction': true, 'displayContent': 'short', diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/showInNotification.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/showInNotification.html.twig index d6d13cd17..37563c947 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/showInNotification.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/showInNotification.html.twig @@ -6,10 +6,9 @@ {% endmacro %} {% if period is not null %} - {{ dump(period) }}
    {% if is_granted('CHILL_PERSON_ACCOMPANYING_PERIOD_SEE', period) %} - {% include 'ChillPersonBundle:AccompanyingPeriod:_list_item.html.twig' with { + {% include "@ChillPerson/AccompanyingPeriod/_list_item.html.twig" with { 'recordAction': _self.recordAction(notification.relatedEntityId), 'itemBlocClass': 'bg-chill-llight-gray' } %} From 3576f7f14f415c7ce3d1706ac8940a2a9723134a Mon Sep 17 00:00:00 2001 From: Lucas Silva Date: Thu, 30 Mar 2023 14:32:00 +0200 Subject: [PATCH 011/724] Finishing evaluation document view and fixing dropdown in show --- .../AccompanyingCourseWork/_item.html.twig | 134 +++++++++--------- .../_objectifs_results_evaluations.html.twig | 12 +- .../AccompanyingCourseWork/index.html.twig | 3 +- .../AccompanyingCourseWork/show.html.twig | 4 +- ...EvaluationDocumentInNotification.html.twig | 17 ++- .../showInNotification.html.twig | 6 +- 6 files changed, 100 insertions(+), 76 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_item.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_item.html.twig index 76c61407d..2a6dea8a1 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_item.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_item.html.twig @@ -5,7 +5,8 @@ # - displayAction: [true|false] default: false # - displayFontSmall: [true|false] default: false #} -
    +

    @@ -111,8 +112,9 @@

    {% if displayContent is not defined or displayContent == 'short' %} -
    - {% include 'ChillPersonBundle:AccompanyingCourseWork:_objectifs_results_evaluations.html.twig' with { +
    + {% include '@ChillPerson/AccompanyingCourseWork/_objectifs_results_evaluations.html.twig' with { 'displayContent': displayContent } %}
    @@ -121,42 +123,43 @@ {% if displayContent is not defined or displayContent == 'short' %}
    - {% import '@ChillPerson/AccompanyingCourseWork/_macros.html.twig' as macro %} + {% import '@ChillPerson/AccompanyingCourseWork/_macros.html.twig' as macro %}
    {{ macro.metadata(w) }}
    {% if displayAction is defined and displayAction == true %} -
      +
        + {% if displayNotification is defined and displayNotification == true %} +
      • + -
      • - - - -
      • -
      • {{ macro.workflowButton(w) }}
      • -
      • - -
      • - {% if is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_UPDATE', w) %} + + + {% endif %} +
      • {{ macro.workflowButton(w) }}
      • -
      • - {% endif %} - {% if is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_DELETE', w) %} -
      • - -
      • - {% endif %} -
      + {% if is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_UPDATE', w) %} +
    • + +
    • + {% endif %} + {% if is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_DELETE', w) %} +
    • + +
    • + {% endif %} +
    {% endif %}
    {% endif %} @@ -164,47 +167,50 @@
    {# - # This is for 'long' version of content - # Note: this include is wrapped in a flex-table container. - # We start by closing the flex-table so we can add more. - # At the end we leave the last flex-table open, as it will be closed in the container. +# This is for 'long' version of content +# Note: this include is wrapped in a flex-table container. +# We start by closing the flex-table so we can add more. +# At the end we leave the last flex-table open, as it will be closed in the container. #} {% if displayContent is defined and displayContent == 'long' %} +
    + +{% if w.results|length > 0 or w.goals|length > 0 or w.accompanyingPeriodWorkEvaluations|length > 0 %} +

    {{ 'Dispositifs' }}

    + +
    {# new flex-table wrapper #} +
    + {% include 'ChillPersonBundle:AccompanyingCourseWork:_objectifs_results_evaluations.html.twig' with { + 'displayContent': displayContent + } %} +
    +{% endif %} - {% if w.results|length > 0 or w.goals|length > 0 or w.accompanyingPeriodWorkEvaluations|length > 0 %} -

    {{ 'Dispositifs' }}

    +

    {{ 'Comments'|trans }}

    -
    {# new flex-table wrapper #} -
    - {% include 'ChillPersonBundle:AccompanyingCourseWork:_objectifs_results_evaluations.html.twig' with { - 'displayContent': displayContent - } %} -
    +
    +
    +

    Public

    + {% if w.note is not empty %} +
    + {{ w.note|chill_entity_render_box({'metadata': true }) }} +
    + {% else %} + {{ 'No comment associated'|trans }} + {% endif %} +
    + {% if w.privateComment.hasCommentForUser(app.user) %} +
    +

    Privé

    +
    + {{ w.privateComment.commentForUser(app.user)|chill_markdown_to_html }} +
    {% endif %} - -

    {{ 'Comments'|trans }}

    - -
    -
    -

    Public

    - {% if w.note is not empty %} -
    - {{ w.note|chill_entity_render_box({'metadata': true }) }} -
    - {% else %} - {{ 'No comment associated'|trans }} - {% endif %} -
    - {% if w.privateComment.hasCommentForUser(app.user) %} -
    -

    Privé

    -
    - {{ w.privateComment.commentForUser(app.user)|chill_markdown_to_html }} -
    -
    - {% endif %} {# Here flex-table stay open ! read above #} -{% endif %} + {% endif %} diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_objectifs_results_evaluations.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_objectifs_results_evaluations.html.twig index 4f5d36230..e66dde463 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_objectifs_results_evaluations.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_objectifs_results_evaluations.html.twig @@ -118,9 +118,15 @@ {% endif %} {% endif %} + + + {% if recordAction is defined %} + {{ recordAction }} + {% endif %} + {% if displayContent is defined and displayContent == 'long' %} {% if e.comment is not empty %} @@ -136,9 +142,9 @@
    - + {% endfor %} diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/index.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/index.html.twig index 9214bd30d..ab1989f63 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/index.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/index.html.twig @@ -26,7 +26,8 @@ 'displayAction': true, 'displayContent': 'short', 'displayFontSmall': true, - 'itemBlocClass': '' + 'itemBlocClass': '', + 'displayNotification': true } %} {% endfor %} diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/show.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/show.html.twig index 73b871260..96b47e6c9 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/show.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/show.html.twig @@ -43,10 +43,10 @@ {% else %} diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showEvaluationDocumentInNotification.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showEvaluationDocumentInNotification.html.twig index f4c9c1bf7..6d5d22a7d 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showEvaluationDocumentInNotification.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showEvaluationDocumentInNotification.html.twig @@ -1,8 +1,17 @@ {% macro recordAction(document) %} -
  • - -
  • + {% import "@ChillDocStore/Macro/macro_mimeicon.html.twig" as mm %} +
    + +
        {{ 'Budget calculator result'|trans }}
    {{ 'The balance'|trans }}  {{ result|format_currency('EUR') }}
    {{ d.title }} {{ mm.mimeIcon(d.storedObject.type) }} - - + + {{ d.storedObject|chill_document_button_group(d.title, is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_UPDATE', w), {'small': true}) }}
    + + + + + +
    {{ document.title }}{{ mm.mimeIcon(document.storedObject.type) }}
    + {% endmacro %} {% if document is not null %} diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showInNotification.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showInNotification.html.twig index 4ee561381..9b06e306c 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showInNotification.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showInNotification.html.twig @@ -1,7 +1,8 @@ {% macro recordAction(work) %}
  • - +
  • {% endmacro %} {% if work is not null %} @@ -12,6 +13,7 @@ 'displayAction': true, 'displayContent': 'short', 'displayFontSmall': true, + 'displayNotification:':true, 'w': work } %} {% else %} From 4c2e78ada7fe57c1d5da67a2b9974ebe8011b71e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sat, 15 Apr 2023 00:02:39 +0200 Subject: [PATCH 012/724] DX: set rector back to php73 --- rector.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rector.php b/rector.php index ec9a0c684..23494ad88 100644 --- a/rector.php +++ b/rector.php @@ -21,7 +21,7 @@ return static function (RectorConfig $rectorConfig): void { //define sets of rules $rectorConfig->sets([ - LevelSetList::UP_TO_PHP_74 + LevelSetList::UP_TO_PHP_73 ]); // skip some path... From 459b91001f642d12bb62bb8e71374b8a7d7b5889 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sat, 15 Apr 2023 00:08:04 +0200 Subject: [PATCH 013/724] fix rector issues --- .../Controller/AddressToReferenceMatcherControllerTest.php | 4 ++-- .../Controller/GeographicalUnitByAddressApiControllerTest.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Tests/Controller/AddressToReferenceMatcherControllerTest.php b/src/Bundle/ChillMainBundle/Tests/Controller/AddressToReferenceMatcherControllerTest.php index 7bcbe9889..4a65883e2 100644 --- a/src/Bundle/ChillMainBundle/Tests/Controller/AddressToReferenceMatcherControllerTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Controller/AddressToReferenceMatcherControllerTest.php @@ -84,7 +84,7 @@ class AddressToReferenceMatcherControllerTest extends WebTestCase /** @var Address $address */ $address = $em->createQuery('SELECT a FROM '.Address::class.' a') - ->setFirstResult(rand(0, $nb)) + ->setFirstResult(random_int(0, $nb)) ->setMaxResults(1) ->getSingleResult(); @@ -108,7 +108,7 @@ class AddressToReferenceMatcherControllerTest extends WebTestCase $ref = $em->createQuery('SELECT a FROM '.AddressReference::class.' a') ->setMaxResults(1) - ->setFirstResult(rand(0, $nb)) + ->setFirstResult(random_int(0, $nb)) ->getSingleResult(); $address = Address::createFromAddressReference($ref); diff --git a/src/Bundle/ChillMainBundle/Tests/Controller/GeographicalUnitByAddressApiControllerTest.php b/src/Bundle/ChillMainBundle/Tests/Controller/GeographicalUnitByAddressApiControllerTest.php index a320bb073..60273a8c9 100644 --- a/src/Bundle/ChillMainBundle/Tests/Controller/GeographicalUnitByAddressApiControllerTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Controller/GeographicalUnitByAddressApiControllerTest.php @@ -44,7 +44,7 @@ class GeographicalUnitByAddressApiControllerTest extends WebTestCase $nb = $em->createQuery('SELECT COUNT(a) FROM '.Address::class.' a')->getSingleScalarResult(); /** @var \Chill\MainBundle\Entity\Address $random */ $random = $em->createQuery('SELECT a FROM '.Address::class.' a') - ->setFirstResult(rand(0, $nb)) + ->setFirstResult(random_int(0, $nb)) ->setMaxResults(1) ->getSingleResult(); From a68190f0c65d26f193b7ce7c327a9aaa6f877104 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sat, 15 Apr 2023 00:19:57 +0200 Subject: [PATCH 014/724] DX: set rector config: rules up to PHP74 --- rector.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rector.php b/rector.php index 23494ad88..ec9a0c684 100644 --- a/rector.php +++ b/rector.php @@ -21,7 +21,7 @@ return static function (RectorConfig $rectorConfig): void { //define sets of rules $rectorConfig->sets([ - LevelSetList::UP_TO_PHP_73 + LevelSetList::UP_TO_PHP_74 ]); // skip some path... From 858ade467ca40693daccf91575b4bfb3624a75da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sat, 15 Apr 2023 00:20:19 +0200 Subject: [PATCH 015/724] DX: rector rules upt to PHP 74 --- .../DependencyInjection/Configuration.php | 4 +- .../ChillActivityBundle/Entity/Activity.php | 2 +- .../Entity/ActivityPresence.php | 2 +- .../Entity/ActivityType.php | 2 +- .../LinkedToACP/AvgActivityDuration.php | 4 +- .../LinkedToACP/AvgActivityVisitDuration.php | 4 +- .../Export/LinkedToACP/CountActivity.php | 4 +- .../Export/LinkedToACP/ListActivity.php | 4 +- .../LinkedToACP/SumActivityDuration.php | 4 +- .../LinkedToACP/SumActivityVisitDuration.php | 4 +- .../Export/LinkedToPerson/ListActivity.php | 16 +++--- .../Filter/ACPFilters/ActivityTypeFilter.php | 9 ++-- .../Filter/ACPFilters/UserScopeFilter.php | 8 ++- .../Export/Filter/ActivityTypeFilter.php | 9 ++-- .../ChillActivityBundle/Form/ActivityType.php | 14 ++--- .../Form/ActivityTypeType.php | 4 +- .../Form/Type/PickActivityReasonType.php | 4 +- ...TranslatableActivityReasonCategoryType.php | 6 +-- .../Form/Type/TranslatableActivityType.php | 4 +- .../Repository/ActivityACLAwareRepository.php | 4 +- .../Service/DocGenerator/ActivityContext.php | 4 +- ...tActivitiesByAccompanyingPeriodContext.php | 8 +-- .../Controller/ActivityControllerTest.php | 8 +-- .../Tests/Form/ActivityTypeTest.php | 4 +- .../Type/TranslatableActivityReasonTest.php | 4 +- .../src/DependencyInjection/Configuration.php | 4 +- .../src/Entity/AsideActivity.php | 2 +- .../src/Export/Export/CountAsideActivity.php | 4 +- .../Entity/AbstractElement.php | 4 +- .../ChillBudgetBundle/Form/ChargeType.php | 4 +- .../ChillBudgetBundle/Form/ResourceType.php | 4 +- .../Service/Summary/SummaryBudget.php | 12 ++--- .../Service/Summary/SummaryBudgetTest.php | 12 ++--- .../ChillCalendarBundle/Entity/Calendar.php | 8 +-- .../Entity/CalendarRange.php | 2 +- .../Export/Export/CountCalendars.php | 8 +-- .../Export/Export/StatCalendarAvgDuration.php | 4 +- .../Export/Export/StatCalendarSumDuration.php | 4 +- .../Export/Filter/AgentFilter.php | 4 +- .../Export/Filter/JobFilter.php | 8 ++- .../Export/Filter/ScopeFilter.php | 8 ++- .../Handler/CalendarToRemoteHandler.php | 8 +-- .../Messenger/Message/CalendarMessage.php | 14 +++-- .../MSGraph/RemoteEventConverter.php | 8 +-- .../MSGraphRemoteCalendarConnector.php | 16 ++---- .../Tests/Form/CalendarTypeTest.php | 36 ++++--------- .../MSGraph/AddressConverterTest.php | 4 +- .../CalendarForShortMessageProviderTest.php | 16 ++---- .../CustomFields/CustomFieldLongChoice.php | 4 +- .../OptionRepository.php | 4 +- .../Form/CustomFieldType.php | 4 +- .../JsonCustomFieldToArrayTransformer.php | 4 +- .../Form/DocGeneratorTemplateType.php | 8 +-- .../Generator/ObjectReadyException.php | 2 +- .../RelatedEntityNotFoundException.php | 2 +- .../Entity/StoredObject.php | 4 +- .../Form/AccompanyingCourseDocumentType.php | 12 ++--- .../Form/PersonDocumentType.php | 12 ++--- ...ompanyingCourseDocumentWorkflowHandler.php | 4 +- .../Controller/ParticipationController.php | 17 ++---- src/Bundle/ChillEventBundle/Entity/Event.php | 4 +- .../Form/ChoiceLoader/EventChoiceLoader.php | 4 +- src/Bundle/ChillEventBundle/Form/RoleType.php | 4 +- .../Form/Type/PickEventType.php | 20 +++---- .../Form/Type/PickEventTypeType.php | 14 ++--- .../Form/Type/PickRoleType.php | 22 +++----- .../Form/Type/PickStatusType.php | 22 +++----- .../ParticipationControllerTest.php | 16 ++---- .../Timeline/TimelineEventProvider.php | 4 +- .../CRUD/Controller/CRUDController.php | 2 +- .../CRUD/Routing/CRUDRoutesLoader.php | 4 +- .../Controller/NotificationController.php | 4 +- .../Controller/PermissionsGroupController.php | 16 ++---- .../Controller/UserController.php | 4 +- .../Controller/WorkflowController.php | 10 ++-- .../CompilerPass/MenuCompilerPass.php | 4 +- .../ChillMainBundle/Doctrine/DQL/Greatest.php | 4 +- .../ChillMainBundle/Doctrine/DQL/Least.php | 4 +- src/Bundle/ChillMainBundle/Entity/Address.php | 2 +- .../Entity/AddressReference.php | 4 +- .../Entity/GeographicalUnit.php | 2 +- .../ChillMainBundle/Entity/Notification.php | 4 +- .../Entity/PermissionsGroup.php | 4 +- .../Entity/Workflow/EntityWorkflowStep.php | 4 +- .../Export/Formatter/CSVListFormatter.php | 4 +- .../Formatter/CSVPivotedListFormatter.php | 4 +- .../Export/Formatter/SpreadSheetFormatter.php | 2 +- .../Export/Helper/ExportAddressHelper.php | 6 +-- .../ChoiceLoader/PostalCodeChoiceLoader.php | 4 +- .../DataMapper/ExportPickCenterDataMapper.php | 4 +- .../IdToEntityDataTransformer.php | 4 +- .../ChillMainBundle/Form/LocationFormType.php | 14 ++--- .../Form/Type/ComposedGroupCenterType.php | 8 +-- .../Form/Type/ComposedRoleScopeType.php | 8 +-- .../EntityToJsonTransformer.php | 4 +- .../Form/Type/Export/PickCenterType.php | 8 +-- .../Form/Type/PickCenterType.php | 4 +- .../Form/Type/PickCivilityType.php | 12 ++--- .../Form/Type/PickLocationTypeType.php | 4 +- .../Form/Type/PickUserLocationType.php | 8 ++- .../Form/Type/PostalCodeType.php | 6 +-- .../Form/Type/ScopePickerType.php | 8 +-- .../Form/Type/UserPickerType.php | 4 +- src/Bundle/ChillMainBundle/Form/UserType.php | 12 ++--- .../ChillMainBundle/Form/WorkflowStepType.php | 16 ++---- .../Routing/MenuBuilder/UserMenuBuilder.php | 8 +-- .../ChillMainBundle/Search/SearchProvider.php | 8 +-- .../AddressReferenceBEFromBestAddress.php | 4 +- .../Import/PostalCodeBEFromBestAddress.php | 4 +- .../Service/Mailer/ChillMailer.php | 4 +- .../Tests/Entity/NotificationTest.php | 4 +- .../Tests/Form/Type/ScopePickerTypeTest.php | 4 +- .../Utils/ExtractDateFromPatternTest.php | 4 +- .../Authorization/AuthorizationHelperTest.php | 4 +- ...ntityWorkflowTransitionEventSubscriber.php | 4 +- .../NotificationOnTransition.php | 4 +- .../EntityWorkflowCreationValidator.php | 4 +- .../AccompanyingCourseApiController.php | 4 +- .../AccompanyingPeriodController.php | 12 ++--- ...mpanyingPeriodRegulationListController.php | 16 ++---- .../HouseholdCompositionController.php | 4 +- .../Controller/HouseholdController.php | 4 +- .../Controller/PersonApiController.php | 8 +-- .../SocialWorkSocialActionApiController.php | 4 +- .../DataFixtures/ORM/LoadCustomFields.php | 4 +- .../Entity/AccompanyingPeriod.php | 8 +-- .../Entity/AccompanyingPeriod/Comment.php | 12 ++--- .../Entity/Household/Household.php | 22 +++----- .../Entity/Household/HouseholdMember.php | 2 +- .../ChillPersonBundle/Entity/Person.php | 8 +-- .../Entity/Person/PersonCurrentAddress.php | 2 +- .../Entity/Person/PersonResource.php | 2 +- .../ChillPersonBundle/Entity/PersonPhone.php | 4 +- .../Entity/SocialWork/Result.php | 2 +- .../GeographicalUnitStatAggregator.php | 4 +- .../CountryOfBirthAggregator.php | 4 +- .../GeographicalUnitAggregator.php | 4 +- .../NationalityAggregator.php | 4 +- .../Export/Export/CountAccompanyingCourse.php | 8 +-- .../Export/CountAccompanyingPeriodWork.php | 8 +-- .../Export/Export/CountEvaluation.php | 8 +-- .../Export/Export/CountHousehold.php | 4 +- .../Export/Export/CountPerson.php | 8 +-- .../CountPersonWithAccompanyingCourse.php | 8 +-- .../Export/Export/ListAccompanyingPeriod.php | 4 +- .../Export/ListAccompanyingPeriodWork.php | 4 +- .../Export/Export/ListEvaluation.php | 4 +- .../Export/Export/ListHouseholdInPeriod.php | 4 +- .../Export/Export/ListPerson.php | 4 +- .../ListPersonWithAccompanyingPeriod.php | 4 +- .../Export/StatAccompanyingCourseDuration.php | 4 +- .../ClosingMotiveFilter.php | 4 +- .../CreatorJobFilter.php | 8 ++- .../EvaluationFilter.php | 4 +- .../GeographicalUnitStatFilter.php | 8 +-- .../OriginFilter.php | 4 +- .../EvaluationTypeFilter.php | 4 +- .../HouseholdFilters/CompositionFilter.php | 8 ++- .../PersonFilters/AddressRefStatusFilter.php | 8 +-- .../Filter/PersonFilters/GenderFilter.php | 4 +- .../PersonFilters/GeographicalUnitFilter.php | 8 +-- .../PersonFilters/MaritalStatusFilter.php | 8 ++- .../PersonFilters/NationalityFilter.php | 4 +- .../ResidentialAddressAtThirdpartyFilter.php | 4 +- .../Filter/SocialWorkFilters/JobFilter.php | 8 ++- .../Filter/SocialWorkFilters/ScopeFilter.php | 8 ++- .../SocialWorkTypeFilter.php | 2 +- .../Form/ChoiceLoader/PersonChoiceLoader.php | 4 +- .../Form/HouseholdCompositionType.php | 4 +- .../ChillPersonBundle/Form/PersonType.php | 12 ++--- .../Form/SocialWork/GoalType.php | 4 +- .../Form/SocialWork/SocialActionType.php | 20 ++----- .../Form/Type/ClosingMotivePickerType.php | 10 ++-- .../Form/Type/PickPersonType.php | 20 +++---- .../Form/Type/PickSocialActionType.php | 4 +- .../Form/Type/PickSocialIssueType.php | 4 +- .../Privacy/PrivacyEventSubscriber.php | 8 +-- .../Repository/PersonACLAwareRepository.php | 4 +- .../Security/Authorization/HouseholdVoter.php | 4 +- .../AccompanyingPeriodDocGenNormalizer.php | 8 +-- ...mpanyingPeriodWorkEvaluationNormalizer.php | 4 +- .../Normalizer/PersonDocGenNormalizer.php | 8 +-- .../Normalizer/PersonJsonNormalizer.php | 10 ++-- .../Normalizer/SocialIssueNormalizer.php | 4 +- .../AccompanyingPeriodContext.php | 20 +++---- ...ccompanyingPeriodWorkEvaluationContext.php | 12 ++--- .../Service/DocGenerator/PersonContext.php | 12 ++--- .../AccompanyingCourseApiControllerTest.php | 4 +- .../Controller/HouseholdApiControllerTest.php | 4 +- .../Controller/PersonControllerUpdateTest.php | 52 +++++-------------- ...onControllerUpdateWithHiddenFieldsTest.php | 24 +++------ .../Tests/Entity/AccompanyingPeriodTest.php | 4 +- .../Tests/Household/MembersEditorTest.php | 24 +++------ .../Normalizer/PersonDocGenNormalizerTest.php | 4 +- .../RelationshipDocGenNormalizerTest.php | 8 +-- .../DocGenerator/PersonContextTest.php | 4 +- .../PersonContextWithThirdPartyTest.php | 4 +- .../AccompanyingPeriodValidityValidator.php | 4 +- .../Export/Export/ReportList.php | 10 ++-- .../ChillReportBundle/Search/ReportSearch.php | 4 +- .../Controller/ReportControllerNextTest.php | 4 +- .../Tests/Controller/ReportControllerTest.php | 4 +- .../Tests/Timeline/TimelineProviderTest.php | 4 +- .../Timeline/TimelineReportProvider.php | 2 +- .../Controller/TaskController.php | 4 +- .../Form/SingleTaskListType.php | 8 +-- .../Controller/SingleTaskControllerTest.php | 4 +- ...TaskTaskLifeCycleEventTimelineProvider.php | 4 +- .../TaskLifeCycleEventTimelineProvider.php | 4 +- .../DataFixtures/ORM/LoadThirdParty.php | 4 +- .../Entity/ThirdParty.php | 6 +-- .../Form/Type/PickThirdPartyType.php | 14 ++--- .../Type/PickThirdPartyTypeCategoryType.php | 4 +- 213 files changed, 433 insertions(+), 1052 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/DependencyInjection/Configuration.php b/src/Bundle/ChillActivityBundle/DependencyInjection/Configuration.php index c6b3189cc..35388464b 100644 --- a/src/Bundle/ChillActivityBundle/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillActivityBundle/DependencyInjection/Configuration.php @@ -59,9 +59,7 @@ class Configuration implements ConfigurationInterface ->info('The number of seconds of this duration. Must be an integer.') ->cannotBeEmpty() ->validate() - ->ifTrue(static function ($data) { - return !is_int($data); - })->thenInvalid('The value %s is not a valid integer') + ->ifTrue(static fn($data) => !is_int($data))->thenInvalid('The value %s is not a valid integer') ->end() ->end() ->scalarNode('label') diff --git a/src/Bundle/ChillActivityBundle/Entity/Activity.php b/src/Bundle/ChillActivityBundle/Entity/Activity.php index 9adfa057f..32ceb2e74 100644 --- a/src/Bundle/ChillActivityBundle/Entity/Activity.php +++ b/src/Bundle/ChillActivityBundle/Entity/Activity.php @@ -195,7 +195,7 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User") * @Groups({"docgen:read"}) */ - private ?User $user; + private ?User $user = null; /** * @ORM\ManyToMany(targetEntity="Chill\MainBundle\Entity\User") diff --git a/src/Bundle/ChillActivityBundle/Entity/ActivityPresence.php b/src/Bundle/ChillActivityBundle/Entity/ActivityPresence.php index 95b3c95d2..b0154e509 100644 --- a/src/Bundle/ChillActivityBundle/Entity/ActivityPresence.php +++ b/src/Bundle/ChillActivityBundle/Entity/ActivityPresence.php @@ -34,7 +34,7 @@ class ActivityPresence * @ORM\GeneratedValue(strategy="AUTO") * @Serializer\Groups({"docgen:read"}) */ - private ?int $id; + private ?int $id = null; /** * @ORM\Column(type="json") diff --git a/src/Bundle/ChillActivityBundle/Entity/ActivityType.php b/src/Bundle/ChillActivityBundle/Entity/ActivityType.php index a6e0fc694..ed8260a4d 100644 --- a/src/Bundle/ChillActivityBundle/Entity/ActivityType.php +++ b/src/Bundle/ChillActivityBundle/Entity/ActivityType.php @@ -122,7 +122,7 @@ class ActivityType * @ORM\GeneratedValue(strategy="AUTO") * @Groups({"docgen:read"}) */ - private ?int $id; + private ?int $id = null; /** * @ORM\Column(type="string", nullable=false, options={"default": ""}) diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php index 2b6919340..0de7f420c 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php @@ -86,9 +86,7 @@ class AvgActivityDuration implements ExportInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static function ($el) { - return $el['center']; - }, $acl); + $centers = array_map(static fn($el) => $el['center'], $acl); $qb = $this->repository->createQueryBuilder('activity'); diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php index 359593059..d9382d857 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php @@ -87,9 +87,7 @@ class AvgActivityVisitDuration implements ExportInterface, GroupedExportInterfac public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static function ($el) { - return $el['center']; - }, $acl); + $centers = array_map(static fn($el) => $el['center'], $acl); $qb = $this->repository->createQueryBuilder('activity'); diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php index 2dc844aa2..fe6de3e24 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php @@ -86,9 +86,7 @@ class CountActivity implements ExportInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static function ($el) { - return $el['center']; - }, $acl); + $centers = array_map(static fn($el) => $el['center'], $acl); $qb = $this->repository ->createQueryBuilder('activity') diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php index 6d25b4e22..616f4d848 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php @@ -109,9 +109,7 @@ class ListActivity implements ListInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static function ($el) { - return $el['center']; - }, $acl); + $centers = array_map(static fn($el) => $el['center'], $acl); $qb = $this->entityManager->createQueryBuilder(); diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php index 1cf20dc5f..d4aa65f22 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php @@ -87,9 +87,7 @@ class SumActivityDuration implements ExportInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static function ($el) { - return $el['center']; - }, $acl); + $centers = array_map(static fn($el) => $el['center'], $acl); $qb = $this->repository ->createQueryBuilder('activity') diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php index 2c160f3cf..859c3e6b5 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php @@ -87,9 +87,7 @@ class SumActivityVisitDuration implements ExportInterface, GroupedExportInterfac public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static function ($el) { - return $el['center']; - }, $acl); + $centers = array_map(static fn($el) => $el['center'], $acl); $qb = $this->repository ->createQueryBuilder('activity') diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php index 8b69216b6..d9b1eb212 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php @@ -137,13 +137,11 @@ class ListActivity implements ListInterface, GroupedExportInterface $activity = $activityRepository->find($value); - return implode(', ', array_map(function (ActivityReason $r) { - return '"' . - $this->translatableStringHelper->localize($r->getCategory()->getName()) - . ' > ' . - $this->translatableStringHelper->localize($r->getName()) - . '"'; - }, $activity->getReasons()->toArray())); + return implode(', ', array_map(fn(ActivityReason $r) => '"' . + $this->translatableStringHelper->localize($r->getCategory()->getName()) + . ' > ' . + $this->translatableStringHelper->localize($r->getName()) + . '"', $activity->getReasons()->toArray())); }; case 'circle_name': @@ -197,9 +195,7 @@ class ListActivity implements ListInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static function ($el) { - return $el['center']; - }, $acl); + $centers = array_map(static fn($el) => $el['center'], $acl); // throw an error if any fields are present if (!array_key_exists('fields', $data)) { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php index a793f21de..346eab316 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php @@ -61,12 +61,9 @@ class ActivityTypeFilter implements FilterInterface $builder->add('accepted_activitytypes', EntityType::class, [ 'class' => ActivityType::class, 'choices' => $this->activityTypeRepository->findAllActive(), - 'choice_label' => function (ActivityType $aty) { - return - ($aty->hasCategory() ? $this->translatableStringHelper->localize($aty->getCategory()->getName()) . ' > ' : '') - . - $this->translatableStringHelper->localize($aty->getName()); - }, + 'choice_label' => fn(ActivityType $aty) => ($aty->hasCategory() ? $this->translatableStringHelper->localize($aty->getCategory()->getName()) . ' > ' : '') + . + $this->translatableStringHelper->localize($aty->getName()), 'multiple' => true, 'expanded' => true, ]); diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserScopeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserScopeFilter.php index 1906db75e..4254137ba 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserScopeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserScopeFilter.php @@ -64,11 +64,9 @@ class UserScopeFilter implements FilterInterface { $builder->add('accepted_userscope', EntityType::class, [ 'class' => Scope::class, - 'choice_label' => function (Scope $s) { - return $this->translatableStringHelper->localize( - $s->getName() - ); - }, + 'choice_label' => fn(Scope $s) => $this->translatableStringHelper->localize( + $s->getName() + ), 'multiple' => true, 'expanded' => true, ]); diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php index d1758039a..725223fdd 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php @@ -61,12 +61,9 @@ class ActivityTypeFilter implements ExportElementValidatedInterface, FilterInter $builder->add('types', EntityType::class, [ 'choices' => $this->activityTypeRepository->findAllActive(), 'class' => ActivityType::class, - 'choice_label' => function (ActivityType $aty) { - return - ($aty->hasCategory() ? $this->translatableStringHelper->localize($aty->getCategory()->getName()) . ' > ' : '') - . - $this->translatableStringHelper->localize($aty->getName()); - }, + 'choice_label' => fn(ActivityType $aty) => ($aty->hasCategory() ? $this->translatableStringHelper->localize($aty->getCategory()->getName()) . ' > ' : '') + . + $this->translatableStringHelper->localize($aty->getName()), 'group_by' => function (ActivityType $type) { if (!$type->hasCategory()) { return null; diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityType.php b/src/Bundle/ChillActivityBundle/Form/ActivityType.php index 50d1a66c7..dad4c3137 100644 --- a/src/Bundle/ChillActivityBundle/Form/ActivityType.php +++ b/src/Bundle/ChillActivityBundle/Form/ActivityType.php @@ -211,13 +211,9 @@ class ActivityType extends AbstractType 'required' => $activityType->isRequired('attendee'), 'expanded' => true, 'class' => ActivityPresence::class, - 'choice_label' => function (ActivityPresence $activityPresence) { - return $this->translatableStringHelper->localize($activityPresence->getName()); - }, - 'query_builder' => static function (EntityRepository $er) { - return $er->createQueryBuilder('a') - ->where('a.active = true'); - }, + 'choice_label' => fn(ActivityPresence $activityPresence) => $this->translatableStringHelper->localize($activityPresence->getName()), + 'query_builder' => static fn(EntityRepository $er) => $er->createQueryBuilder('a') + ->where('a.active = true'), ]); } @@ -357,9 +353,7 @@ class ActivityType extends AbstractType return (string) $location->getId(); }, - function (?string $id): ?Location { - return $this->om->getRepository(Location::class)->findOneBy(['id' => (int) $id]); - } + fn(?string $id): ?Location => $this->om->getRepository(Location::class)->findOneBy(['id' => (int) $id]) )); } diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php b/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php index b27fa883e..42353cda7 100644 --- a/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php +++ b/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php @@ -45,9 +45,7 @@ class ActivityTypeType extends AbstractType ]) ->add('category', EntityType::class, [ 'class' => ActivityTypeCategory::class, - 'choice_label' => function (ActivityTypeCategory $activityTypeCategory) { - return $this->translatableStringHelper->localize($activityTypeCategory->getName()); - }, + 'choice_label' => fn(ActivityTypeCategory $activityTypeCategory) => $this->translatableStringHelper->localize($activityTypeCategory->getName()), ]) ->add('ordering', NumberType::class, [ 'required' => true, diff --git a/src/Bundle/ChillActivityBundle/Form/Type/PickActivityReasonType.php b/src/Bundle/ChillActivityBundle/Form/Type/PickActivityReasonType.php index a951ef940..0b63de112 100644 --- a/src/Bundle/ChillActivityBundle/Form/Type/PickActivityReasonType.php +++ b/src/Bundle/ChillActivityBundle/Form/Type/PickActivityReasonType.php @@ -45,9 +45,7 @@ class PickActivityReasonType extends AbstractType $resolver->setDefaults( [ 'class' => ActivityReason::class, - 'choice_label' => function (ActivityReason $choice) { - return $this->reasonRender->renderString($choice, []); - }, + 'choice_label' => fn(ActivityReason $choice) => $this->reasonRender->renderString($choice, []), 'group_by' => function (ActivityReason $choice): ?string { if (null !== $category = $choice->getCategory()) { return $this->translatableStringHelper->localize($category->getName()); diff --git a/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityReasonCategoryType.php b/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityReasonCategoryType.php index 96dabe008..83dcb43f0 100644 --- a/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityReasonCategoryType.php +++ b/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityReasonCategoryType.php @@ -38,10 +38,8 @@ class TranslatableActivityReasonCategoryType extends AbstractType $resolver->setDefaults( [ 'class' => ActivityReasonCategory::class, - 'choice_label' => function (ActivityReasonCategory $category) { - return $this->translatableStringHelper->localize($category->getName()) - . (!$category->getActive() ? ' (' . $this->translator->trans('inactive') . ')' : ''); - }, + 'choice_label' => fn(ActivityReasonCategory $category) => $this->translatableStringHelper->localize($category->getName()) + . (!$category->getActive() ? ' (' . $this->translator->trans('inactive') . ')' : ''), ] ); } diff --git a/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityType.php b/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityType.php index 4a1d4bfa7..065f80c9b 100644 --- a/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityType.php +++ b/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityType.php @@ -39,9 +39,7 @@ class TranslatableActivityType extends AbstractType 'class' => ActivityType::class, 'active_only' => true, 'choices' => $this->activityTypeRepository->findAllActive(), - 'choice_label' => function (ActivityType $type) { - return $this->translatableStringHelper->localize($type->getName()); - }, + 'choice_label' => fn(ActivityType $type) => $this->translatableStringHelper->localize($type->getName()), ] ); } diff --git a/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php b/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php index 185e008eb..3e5ff813b 100644 --- a/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php +++ b/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php @@ -254,9 +254,7 @@ final class ActivityACLAwareRepository implements ActivityACLAwareRepositoryInte $reachableScopes = $this->authorizationHelper->getReachableScopes($this->tokenStorage->getToken()->getUser(), ActivityVoter::SEE, $center); // we get the ids for those scopes $reachablesScopesId = array_map( - static function (Scope $scope) { - return $scope->getId(); - }, + static fn(Scope $scope) => $scope->getId(), $reachableScopes ); diff --git a/src/Bundle/ChillActivityBundle/Service/DocGenerator/ActivityContext.php b/src/Bundle/ChillActivityBundle/Service/DocGenerator/ActivityContext.php index ad570a8a4..241526b03 100644 --- a/src/Bundle/ChillActivityBundle/Service/DocGenerator/ActivityContext.php +++ b/src/Bundle/ChillActivityBundle/Service/DocGenerator/ActivityContext.php @@ -134,9 +134,7 @@ class ActivityContext implements $builder->add($key, EntityType::class, [ 'class' => Person::class, 'choices' => $persons, - 'choice_label' => function (Person $p) { - return $this->personRender->renderString($p, []); - }, + 'choice_label' => fn(Person $p) => $this->personRender->renderString($p, []), 'multiple' => false, 'required' => false, 'expanded' => true, diff --git a/src/Bundle/ChillActivityBundle/Service/DocGenerator/ListActivitiesByAccompanyingPeriodContext.php b/src/Bundle/ChillActivityBundle/Service/DocGenerator/ListActivitiesByAccompanyingPeriodContext.php index 266fadfee..9f9e03669 100644 --- a/src/Bundle/ChillActivityBundle/Service/DocGenerator/ListActivitiesByAccompanyingPeriodContext.php +++ b/src/Bundle/ChillActivityBundle/Service/DocGenerator/ListActivitiesByAccompanyingPeriodContext.php @@ -146,9 +146,7 @@ class ListActivitiesByAccompanyingPeriodContext implements return array_filter( $activities, function ($activity) use ($user) { - $activityUsernames = array_map(static function ($user) { - return $user['username']; - }, $activity['users'] ?? []); + $activityUsernames = array_map(static fn($user) => $user['username'], $activity['users'] ?? []); return in_array($user->getUsername(), $activityUsernames, true); } ); @@ -159,9 +157,7 @@ class ListActivitiesByAccompanyingPeriodContext implements return array_filter( $works, function ($work) use ($user) { - $workUsernames = array_map(static function ($user) { - return $user['username']; - }, $work['referrers'] ?? []); + $workUsernames = array_map(static fn($user) => $user['username'], $work['referrers'] ?? []); return in_array($user->getUsername(), $workUsernames, true); } diff --git a/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityControllerTest.php b/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityControllerTest.php index 8e2c219f0..d01821e6e 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityControllerTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityControllerTest.php @@ -369,12 +369,8 @@ final class ActivityControllerTest extends WebTestCase $center ); $reachableScopesId = array_intersect( - array_map(static function ($s) { - return $s->getId(); - }, $reachableScopesDelete), - array_map(static function ($s) { - return $s->getId(); - }, $reachableScopesUpdate) + array_map(static fn($s) => $s->getId(), $reachableScopesDelete), + array_map(static fn($s) => $s->getId(), $reachableScopesUpdate) ); if (count($reachableScopesId) === 0) { diff --git a/src/Bundle/ChillActivityBundle/Tests/Form/ActivityTypeTest.php b/src/Bundle/ChillActivityBundle/Tests/Form/ActivityTypeTest.php index df0a602a4..cd73b259a 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Form/ActivityTypeTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Form/ActivityTypeTest.php @@ -188,9 +188,7 @@ final class ActivityTypeTest extends KernelTestCase // map all the values in an array $values = array_map( - static function ($choice) { - return $choice->value; - }, + static fn($choice) => $choice->value, $view['activity']['durationTime']->vars['choices'] ); diff --git a/src/Bundle/ChillActivityBundle/Tests/Form/Type/TranslatableActivityReasonTest.php b/src/Bundle/ChillActivityBundle/Tests/Form/Type/TranslatableActivityReasonTest.php index 881e5a607..aefa0d115 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Form/Type/TranslatableActivityReasonTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Form/Type/TranslatableActivityReasonTest.php @@ -83,9 +83,7 @@ final class TranslatableActivityReasonTest extends TypeTestCase $request->getLocale()->willReturn($fallbackLocale); $requestStack->willExtend(\Symfony\Component\HttpFoundation\RequestStack::class); - $requestStack->getCurrentRequest()->will(static function () use ($request) { - return $request; - }); + $requestStack->getCurrentRequest()->will(static fn() => $request); $translator->willExtend(\Symfony\Component\Translation\Translator::class); $translator->getFallbackLocales()->willReturn($locale); diff --git a/src/Bundle/ChillAsideActivityBundle/src/DependencyInjection/Configuration.php b/src/Bundle/ChillAsideActivityBundle/src/DependencyInjection/Configuration.php index 8341e0240..85d76227d 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillAsideActivityBundle/src/DependencyInjection/Configuration.php @@ -132,9 +132,7 @@ class Configuration implements ConfigurationInterface ->info('The number of seconds of this duration. Must be an integer.') ->cannotBeEmpty() ->validate() - ->ifTrue(static function ($data) { - return !is_int($data); - })->thenInvalid('The value %s is not a valid integer') + ->ifTrue(static fn($data) => !is_int($data))->thenInvalid('The value %s is not a valid integer') ->end() ->end() ->scalarNode('label') diff --git a/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivity.php b/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivity.php index 598988cfb..3dc205f09 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivity.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivity.php @@ -57,7 +57,7 @@ class AsideActivity implements TrackCreationInterface, TrackUpdateInterface * @ORM\GeneratedValue * @ORM\Column(type="integer") */ - private ?int $id; + private ?int $id = null; /** * @ORM\Column(type="string", length=100, nullable=true) diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/CountAsideActivity.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/CountAsideActivity.php index 87aad1659..8eb8d1b64 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/CountAsideActivity.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/CountAsideActivity.php @@ -59,9 +59,7 @@ class CountAsideActivity implements ExportInterface, GroupedExportInterface $labels = array_combine($values, $values); $labels['_header'] = $this->getTitle(); - return static function ($value) use ($labels) { - return $labels[$value]; - }; + return static fn($value) => $labels[$value]; } public function getQueryKeys($data): array diff --git a/src/Bundle/ChillBudgetBundle/Entity/AbstractElement.php b/src/Bundle/ChillBudgetBundle/Entity/AbstractElement.php index f12ba3d72..619a6cdd7 100644 --- a/src/Bundle/ChillBudgetBundle/Entity/AbstractElement.php +++ b/src/Bundle/ChillBudgetBundle/Entity/AbstractElement.php @@ -41,7 +41,7 @@ abstract class AbstractElement /** * @ORM\Column(name="comment", type="text", nullable=true) */ - private ?string $comment; + private ?string $comment = null; /** * @ORM\Column(name="endDate", type="datetime_immutable", nullable=true) @@ -50,7 +50,7 @@ abstract class AbstractElement * message="The budget element's end date must be after the start date" * ) */ - private ?DateTimeImmutable $endDate; + private ?DateTimeImmutable $endDate = null; /** * @ORM\ManyToOne( diff --git a/src/Bundle/ChillBudgetBundle/Form/ChargeType.php b/src/Bundle/ChillBudgetBundle/Form/ChargeType.php index 3356057cf..de8317ab3 100644 --- a/src/Bundle/ChillBudgetBundle/Form/ChargeType.php +++ b/src/Bundle/ChillBudgetBundle/Form/ChargeType.php @@ -52,9 +52,7 @@ class ChargeType extends AbstractType 'label' => 'Charge type', 'required' => true, 'placeholder' => $this->translator->trans('admin.form.Choose the type of charge'), - 'choice_label' => function (ChargeKind $resource) { - return $this->translatableStringHelper->localize($resource->getName()); - }, + 'choice_label' => fn(ChargeKind $resource) => $this->translatableStringHelper->localize($resource->getName()), 'attr' => ['class' => 'select2'], ]) ->add('amount', MoneyType::class) diff --git a/src/Bundle/ChillBudgetBundle/Form/ResourceType.php b/src/Bundle/ChillBudgetBundle/Form/ResourceType.php index fd859217a..3b14e9a05 100644 --- a/src/Bundle/ChillBudgetBundle/Form/ResourceType.php +++ b/src/Bundle/ChillBudgetBundle/Form/ResourceType.php @@ -51,9 +51,7 @@ class ResourceType extends AbstractType 'label' => 'Resource type', 'required' => true, 'placeholder' => $this->translator->trans('admin.form.Choose the type of resource'), - 'choice_label' => function (ResourceKind $resource) { - return $this->translatableStringHelper->localize($resource->getName()); - }, + 'choice_label' => fn(ResourceKind $resource) => $this->translatableStringHelper->localize($resource->getName()), 'attr' => ['class' => 'select2'], ]) ->add('amount', MoneyType::class) diff --git a/src/Bundle/ChillBudgetBundle/Service/Summary/SummaryBudget.php b/src/Bundle/ChillBudgetBundle/Service/Summary/SummaryBudget.php index ad2a014ed..3e0ee2cec 100644 --- a/src/Bundle/ChillBudgetBundle/Service/Summary/SummaryBudget.php +++ b/src/Bundle/ChillBudgetBundle/Service/Summary/SummaryBudget.php @@ -66,9 +66,7 @@ final class SummaryBudget implements SummaryBudgetInterface ]; } - $personIds = $household->getCurrentPersons()->map(static function (Person $p) { - return $p->getId(); - }); + $personIds = $household->getCurrentPersons()->map(static fn(Person $p) => $p->getId()); $ids = implode(', ', array_fill(0, count($personIds), '?')); $parameters = [...$personIds, $household->getId()]; @@ -127,18 +125,14 @@ final class SummaryBudget implements SummaryBudgetInterface { $keys = array_map(static fn (ChargeKind $kind) => $kind->getKind(), $this->chargeKindRepository->findAll()); - return array_combine($keys, array_map(function ($kind) { - return ['sum' => 0.0, 'label' => $this->translatableStringHelper->localize($this->chargeKindRepository->findOneByKind($kind)->getName()), 'comment' => '']; - }, $keys)); + return array_combine($keys, array_map(fn($kind) => ['sum' => 0.0, 'label' => $this->translatableStringHelper->localize($this->chargeKindRepository->findOneByKind($kind)->getName()), 'comment' => ''], $keys)); } private function getEmptyResourceArray(): array { $keys = array_map(static fn (ResourceKind $kind) => $kind->getKind(), $this->resourceKindRepository->findAll()); - return array_combine($keys, array_map(function ($kind) { - return ['sum' => 0.0, 'label' => $this->translatableStringHelper->localize($this->resourceKindRepository->findOneByKind($kind)->getName()), 'comment' => '']; - }, $keys)); + return array_combine($keys, array_map(fn($kind) => ['sum' => 0.0, 'label' => $this->translatableStringHelper->localize($this->resourceKindRepository->findOneByKind($kind)->getName()), 'comment' => ''], $keys)); } private function rowToArray(array $rows, string $kind): array diff --git a/src/Bundle/ChillBudgetBundle/Tests/Service/Summary/SummaryBudgetTest.php b/src/Bundle/ChillBudgetBundle/Tests/Service/Summary/SummaryBudgetTest.php index 7fcda6b11..194c23672 100644 --- a/src/Bundle/ChillBudgetBundle/Tests/Service/Summary/SummaryBudgetTest.php +++ b/src/Bundle/ChillBudgetBundle/Tests/Service/Summary/SummaryBudgetTest.php @@ -50,9 +50,7 @@ final class SummaryBudgetTest extends TestCase ], ]); $queryCharges->setParameters(Argument::type('array')) - ->will(static function ($args, $query) { - return $query; - }); + ->will(static fn($args, $query) => $query); $queryResources = $this->prophesize(AbstractQuery::class); $queryResources->getResult()->willReturn([ @@ -63,9 +61,7 @@ final class SummaryBudgetTest extends TestCase ], ]); $queryResources->setParameters(Argument::type('array')) - ->will(static function ($args, $query) { - return $query; - }); + ->will(static fn($args, $query) => $query); $em = $this->prophesize(EntityManagerInterface::class); $em->createNativeQuery(Argument::type('string'), Argument::type(Query\ResultSetMapping::class)) @@ -100,9 +96,7 @@ final class SummaryBudgetTest extends TestCase $resourceRepository->findOneByKind('misc')->willReturn($misc); $translatableStringHelper = $this->prophesize(TranslatableStringHelperInterface::class); - $translatableStringHelper->localize(Argument::type('array'))->will(static function ($arg) { - return $arg[0]['fr']; - }); + $translatableStringHelper->localize(Argument::type('array'))->will(static fn($arg) => $arg[0]['fr']); $person = new Person(); $personReflection = new ReflectionClass($person); diff --git a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php index d7f38adf0..418bfcea2 100644 --- a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php +++ b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php @@ -514,9 +514,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente */ public function getUsers(): ReadableCollection { - return $this->getInvites()->map(static function (Invite $i) { - return $i->getUser(); - }); + return $this->getInvites()->map(static fn(Invite $i) => $i->getUser()); } public function hasCalendarRange(): bool @@ -601,9 +599,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente } $invite = $this->invites - ->filter(static function (Invite $invite) use ($user) { - return $invite->getUser() === $user; - }) + ->filter(static fn(Invite $invite) => $invite->getUser() === $user) ->first(); $this->removeInvite($invite); diff --git a/src/Bundle/ChillCalendarBundle/Entity/CalendarRange.php b/src/Bundle/ChillCalendarBundle/Entity/CalendarRange.php index 14cfad98b..5dbc4286f 100644 --- a/src/Bundle/ChillCalendarBundle/Entity/CalendarRange.php +++ b/src/Bundle/ChillCalendarBundle/Entity/CalendarRange.php @@ -63,7 +63,7 @@ class CalendarRange implements TrackCreationInterface, TrackUpdateInterface * @Groups({"read", "write", "calendar:read"}) * @Assert\NotNull */ - private ?Location $location; + private ?Location $location = null; /** * @ORM\Column(type="datetime_immutable", nullable=false) diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php b/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php index f3bf79547..c21b4a4d6 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php @@ -61,9 +61,7 @@ class CountCalendars implements ExportInterface, GroupedExportInterface $labels = array_combine($values, $values); $labels['_header'] = $this->getTitle(); - return static function ($value) use ($labels) { - return $labels[$value]; - }; + return static fn($value) => $labels[$value]; } public function getQueryKeys($data): array @@ -91,9 +89,7 @@ class CountCalendars implements ExportInterface, GroupedExportInterface */ public function initiateQuery(array $requiredModifiers, array $acl, array $data = []): QueryBuilder { - $centers = array_map(static function ($el) { - return $el['center']; - }, $acl); + $centers = array_map(static fn($el) => $el['center'], $acl); $qb = $this->calendarRepository->createQueryBuilder('cal'); diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php index ddecba415..78be10834 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php @@ -61,9 +61,7 @@ class StatCalendarAvgDuration implements ExportInterface, GroupedExportInterface $labels = array_combine($values, $values); $labels['_header'] = $this->getTitle(); - return static function ($value) use ($labels) { - return $labels[$value]; - }; + return static fn($value) => $labels[$value]; } public function getQueryKeys($data): array diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php index d99e73a2e..5dd9dca44 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php @@ -61,9 +61,7 @@ class StatCalendarSumDuration implements ExportInterface, GroupedExportInterface $labels = array_combine($values, $values); $labels['_header'] = $this->getTitle(); - return static function ($value) use ($labels) { - return $labels[$value]; - }; + return static fn($value) => $labels[$value]; } public function getQueryKeys($data): array diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php index 18a4b0f4b..058251004 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php @@ -58,9 +58,7 @@ class AgentFilter implements FilterInterface { $builder->add('accepted_agents', EntityType::class, [ 'class' => User::class, - 'choice_label' => function (User $u) { - return $this->userRender->renderString($u, []); - }, + 'choice_label' => fn(User $u) => $this->userRender->renderString($u, []), 'multiple' => true, 'expanded' => true, ]); diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php index 0f0f42adc..04f6ba02b 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php @@ -69,11 +69,9 @@ class JobFilter implements FilterInterface { $builder->add('job', EntityType::class, [ 'class' => UserJob::class, - 'choice_label' => function (UserJob $j) { - return $this->translatableStringHelper->localize( - $j->getLabel() - ); - }, + 'choice_label' => fn(UserJob $j) => $this->translatableStringHelper->localize( + $j->getLabel() + ), 'multiple' => true, 'expanded' => true, ]); diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php index 4d84543a3..ce6c90de2 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php @@ -69,11 +69,9 @@ class ScopeFilter implements FilterInterface { $builder->add('scope', EntityType::class, [ 'class' => Scope::class, - 'choice_label' => function (Scope $s) { - return $this->translatableStringHelper->localize( - $s->getName() - ); - }, + 'choice_label' => fn(Scope $s) => $this->translatableStringHelper->localize( + $s->getName() + ), 'multiple' => true, 'expanded' => true, ]); diff --git a/src/Bundle/ChillCalendarBundle/Messenger/Handler/CalendarToRemoteHandler.php b/src/Bundle/ChillCalendarBundle/Messenger/Handler/CalendarToRemoteHandler.php index 9bcc0c434..1ec257cad 100644 --- a/src/Bundle/ChillCalendarBundle/Messenger/Handler/CalendarToRemoteHandler.php +++ b/src/Bundle/ChillCalendarBundle/Messenger/Handler/CalendarToRemoteHandler.php @@ -89,14 +89,10 @@ class CalendarToRemoteHandler implements MessageHandlerInterface $newInvites = array_filter( array_map( - function ($id) { - return $this->inviteRepository->find($id); - }, + fn($id) => $this->inviteRepository->find($id), $calendarMessage->getNewInvitesIds(), ), - static function (?Invite $invite) { - return null !== $invite; - } + static fn(?Invite $invite) => null !== $invite ); $this->calendarConnector->syncCalendar( diff --git a/src/Bundle/ChillCalendarBundle/Messenger/Message/CalendarMessage.php b/src/Bundle/ChillCalendarBundle/Messenger/Message/CalendarMessage.php index ec5977ad3..6232ca06c 100644 --- a/src/Bundle/ChillCalendarBundle/Messenger/Message/CalendarMessage.php +++ b/src/Bundle/ChillCalendarBundle/Messenger/Message/CalendarMessage.php @@ -58,14 +58,12 @@ class CalendarMessage $this->previousMainUserId = null !== $calendar->previousMainUser ? $calendar->previousMainUser->getId() : null; $this->newInvitesIds = array_map(static fn (Invite $i) => $i->getId(), $calendar->newInvites); - $this->oldInvites = array_map(static function (Invite $i) { - return [ - 'inviteId' => $i->getId(), - 'userId' => $i->getUser()->getId(), - 'userEmail' => $i->getUser()->getEmail(), - 'userLabel' => $i->getUser()->getLabel(), - ]; - }, $calendar->oldInvites); + $this->oldInvites = array_map(static fn(Invite $i) => [ + 'inviteId' => $i->getId(), + 'userId' => $i->getUser()->getId(), + 'userEmail' => $i->getUser()->getEmail(), + 'userLabel' => $i->getUser()->getLabel(), + ], $calendar->oldInvites); } public function getAction(): string diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteEventConverter.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteEventConverter.php index ac1de552a..b7a1c2df6 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteEventConverter.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteEventConverter.php @@ -121,9 +121,7 @@ class RemoteEventConverter 'subject' => '[Chill] ' . implode( ', ', - $calendar->getPersons()->map(function (Person $p) { - return $this->personRender->renderString($p, []); - })->toArray() + $calendar->getPersons()->map(fn(Person $p) => $this->personRender->renderString($p, []))->toArray() ), 'start' => [ 'dateTime' => $calendar->getStartDate()->setTimezone($this->remoteDateTimeZone) @@ -161,9 +159,7 @@ class RemoteEventConverter { return [ 'attendees' => $calendar->getInvites()->map( - function (Invite $i) { - return $this->buildInviteToAttendee($i); - } + fn(Invite $i) => $this->buildInviteToAttendee($i) )->toArray(), ]; } diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraphRemoteCalendarConnector.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraphRemoteCalendarConnector.php index 0454bae69..75995948e 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraphRemoteCalendarConnector.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraphRemoteCalendarConnector.php @@ -190,23 +190,17 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface ] )->toArray(); - $ids = array_map(static function ($item) { - return $item['id']; - }, $bareEvents['value']); + $ids = array_map(static fn($item) => $item['id'], $bareEvents['value']); $existingIdsInRange = $this->calendarRangeRepository->findRemoteIdsPresent($ids); $existingIdsInCalendar = $this->calendarRepository->findRemoteIdsPresent($ids); return array_values( array_map( - function ($item) { - return $this->remoteEventConverter->convertToRemote($item); - }, + fn($item) => $this->remoteEventConverter->convertToRemote($item), // filter all event to keep only the one not in range array_filter( $bareEvents['value'], - static function ($item) use ($existingIdsInRange, $existingIdsInCalendar) { - return ((!$existingIdsInRange[$item['id']]) ?? true) && ((!$existingIdsInCalendar[$item['id']]) ?? true); - } + static fn($item) => ((!$existingIdsInRange[$item['id']]) ?? true) && ((!$existingIdsInCalendar[$item['id']]) ?? true) ) ) ); @@ -601,9 +595,7 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface } $this->cacheScheduleTimeForUser[$userId] = array_map( - function ($item) { - return $this->remoteEventConverter->convertAvailabilityToRemoteEvent($item); - }, + fn($item) => $this->remoteEventConverter->convertAvailabilityToRemoteEvent($item), $response['value'][0]['scheduleItems'] ); diff --git a/src/Bundle/ChillCalendarBundle/Tests/Form/CalendarTypeTest.php b/src/Bundle/ChillCalendarBundle/Tests/Form/CalendarTypeTest.php index 80b2f8c45..f7a3509f4 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Form/CalendarTypeTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Form/CalendarTypeTest.php @@ -114,12 +114,8 @@ final class CalendarTypeTest extends TypeTestCase $this->assertEquals(8, $calendar->getCalendarRange()->getId()); $this->assertEquals(9, $calendar->getLocation()->getId()); $this->assertEquals(true, $calendar->getSendSMS()); - $this->assertContains(2, $calendar->getUsers()->map(static function (User $u) { - return $u->getId(); - })); - $this->assertContains(3, $calendar->getUsers()->map(static function (User $u) { - return $u->getId(); - })); + $this->assertContains(2, $calendar->getUsers()->map(static fn(User $u) => $u->getId())); + $this->assertContains(3, $calendar->getUsers()->map(static fn(User $u) => $u->getId())); } protected function getExtensions() @@ -148,25 +144,17 @@ final class CalendarTypeTest extends TypeTestCase ) { $transformer = $this->prophesize($classTransformer); $transformer->transform(Argument::type('array')) - ->will(static function ($args) { - return implode( - ',', - array_map(static function ($p) { - return $p->getId(); - }, $args[0]) - ); - }); + ->will(static fn($args) => implode( + ',', + array_map(static fn($p) => $p->getId(), $args[0]) + )); $transformer->transform(Argument::exact(null)) ->willReturn([]); $transformer->transform(Argument::type(Collection::class)) - ->will(static function ($args) { - return implode( - ',', - array_map(static function ($p) { - return $p->getId(); - }, $args[0]->toArray()) - ); - }); + ->will(static fn($args) => implode( + ',', + array_map(static fn($p) => $p->getId(), $args[0]->toArray()) + )); $transformer->reverseTransform(Argument::type('string')) ->will(static function ($args) use ($objClass) { if (null === $args[0]) { @@ -195,9 +183,7 @@ final class CalendarTypeTest extends TypeTestCase ) { $transformer = $this->prophesize($classTransformer); $transformer->transform(Argument::type('object')) - ->will(static function ($args) { - return (string) $args[0]->getId(); - }); + ->will(static fn($args) => (string) $args[0]->getId()); $transformer->transform(Argument::exact(null)) ->willReturn(''); $transformer->reverseTransform(Argument::type('string')) diff --git a/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/AddressConverterTest.php b/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/AddressConverterTest.php index 485146939..35c067eb7 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/AddressConverterTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/AddressConverterTest.php @@ -63,9 +63,7 @@ final class AddressConverterTest extends TestCase { $engine = $this->prophesize(EngineInterface::class); $translatableStringHelper = $this->prophesize(TranslatableStringHelperInterface::class); - $translatableStringHelper->localize(Argument::type('array'))->will(static function ($args): string { - return ($args[0] ?? ['fr' => 'not provided'])['fr'] ?? 'not provided'; - }); + $translatableStringHelper->localize(Argument::type('array'))->will(static fn($args): string => ($args[0] ?? ['fr' => 'not provided'])['fr'] ?? 'not provided'); $addressRender = new AddressRender($engine->reveal(), $translatableStringHelper->reveal()); diff --git a/src/Bundle/ChillCalendarBundle/Tests/Service/ShortMessageNotification/CalendarForShortMessageProviderTest.php b/src/Bundle/ChillCalendarBundle/Tests/Service/ShortMessageNotification/CalendarForShortMessageProviderTest.php index f3e35ef93..9ee2ac82b 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Service/ShortMessageNotification/CalendarForShortMessageProviderTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Service/ShortMessageNotification/CalendarForShortMessageProviderTest.php @@ -72,17 +72,13 @@ final class CalendarForShortMessageProviderTest extends TestCase Argument::type(DateTimeImmutable::class), Argument::type('int'), Argument::exact(0) - )->will(static function ($args) { - return array_fill(0, $args[2], new Calendar()); - })->shouldBeCalledTimes(1); + )->will(static fn($args) => array_fill(0, $args[2], new Calendar()))->shouldBeCalledTimes(1); $calendarRepository->findByNotificationAvailable( Argument::type(DateTimeImmutable::class), Argument::type(DateTimeImmutable::class), Argument::type('int'), Argument::not(0) - )->will(static function ($args) { - return array_fill(0, $args[2] - 1, new Calendar()); - })->shouldBeCalledTimes(1); + )->will(static fn($args) => array_fill(0, $args[2] - 1, new Calendar()))->shouldBeCalledTimes(1); $em = $this->prophesize(EntityManagerInterface::class); $em->clear()->shouldBeCalled(); @@ -108,17 +104,13 @@ final class CalendarForShortMessageProviderTest extends TestCase Argument::type(DateTimeImmutable::class), Argument::type('int'), Argument::exact(0) - )->will(static function ($args) { - return array_fill(0, 1, new Calendar()); - })->shouldBeCalledTimes(1); + )->will(static fn($args) => array_fill(0, 1, new Calendar()))->shouldBeCalledTimes(1); $calendarRepository->findByNotificationAvailable( Argument::type(DateTimeImmutable::class), Argument::type(DateTimeImmutable::class), Argument::type('int'), Argument::not(0) - )->will(static function ($args) { - return []; - })->shouldBeCalledTimes(1); + )->will(static fn($args) => [])->shouldBeCalledTimes(1); $em = $this->prophesize(EntityManagerInterface::class); $em->clear()->shouldBeCalled(); diff --git a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldLongChoice.php b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldLongChoice.php index 41c8b4694..c60d947dd 100644 --- a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldLongChoice.php +++ b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldLongChoice.php @@ -58,9 +58,7 @@ class CustomFieldLongChoice extends AbstractCustomField $translatableStringHelper = $this->translatableStringHelper; $builder->add($customField->getSlug(), Select2ChoiceType::class, [ 'choices' => $entries, - 'choice_label' => static function (Option $option) use ($translatableStringHelper) { - return $translatableStringHelper->localize($option->getText()); - }, + 'choice_label' => static fn(Option $option) => $translatableStringHelper->localize($option->getText()), 'choice_value' => static fn (Option $key): ?int => null === $key ? null : $key->getId(), 'multiple' => false, 'expanded' => false, diff --git a/src/Bundle/ChillCustomFieldsBundle/EntityRepository/CustomFieldLongChoice/OptionRepository.php b/src/Bundle/ChillCustomFieldsBundle/EntityRepository/CustomFieldLongChoice/OptionRepository.php index 328eda36a..e1ed1d363 100644 --- a/src/Bundle/ChillCustomFieldsBundle/EntityRepository/CustomFieldLongChoice/OptionRepository.php +++ b/src/Bundle/ChillCustomFieldsBundle/EntityRepository/CustomFieldLongChoice/OptionRepository.php @@ -57,8 +57,6 @@ class OptionRepository extends EntityRepository ->getQuery() ->getScalarResult(); - return array_map(static function ($r) { - return $r['key']; - }, $keys); + return array_map(static fn($r) => $r['key'], $keys); } } diff --git a/src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldType.php b/src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldType.php index ea572759b..f9a9f2509 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldType.php +++ b/src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldType.php @@ -70,9 +70,7 @@ class CustomFieldType extends AbstractType if ('entity' === $options['group_widget']) { $builder->add('customFieldsGroup', EntityType::class, [ 'class' => 'ChillCustomFieldsBundle:CustomFieldsGroup', - 'choice_label' => function ($g) { - return $this->translatableStringHelper->localize($g->getName()); - }, + 'choice_label' => fn($g) => $this->translatableStringHelper->localize($g->getName()), ]); } elseif ('hidden' === $options['group_widget']) { $builder->add('customFieldsGroup', HiddenType::class); diff --git a/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/JsonCustomFieldToArrayTransformer.php b/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/JsonCustomFieldToArrayTransformer.php index bccf797e5..ab67ca581 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/JsonCustomFieldToArrayTransformer.php +++ b/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/JsonCustomFieldToArrayTransformer.php @@ -38,9 +38,7 @@ class JsonCustomFieldToArrayTransformer implements DataTransformerInterface // @TODO: in the array_map callback, CustomField::getLabel() does not exist. What do we do here? $customFieldsLablels = array_map( - static function ($e) { - return $e->getLabel(); - }, + static fn($e) => $e->getLabel(), $customFields ); diff --git a/src/Bundle/ChillDocGeneratorBundle/Form/DocGeneratorTemplateType.php b/src/Bundle/ChillDocGeneratorBundle/Form/DocGeneratorTemplateType.php index b5bd10d16..0b1fbec9d 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Form/DocGeneratorTemplateType.php +++ b/src/Bundle/ChillDocGeneratorBundle/Form/DocGeneratorTemplateType.php @@ -61,12 +61,8 @@ class DocGeneratorTemplateType extends AbstractType $sub = $builder ->create('options', null, ['compound' => true]) ->addModelTransformer(new CallbackTransformer( - static function (array $data) use ($context) { - return $context->adminFormTransform($data); - }, - static function (array $data) use ($context) { - return $context->adminFormReverseTransform($data); - } + static fn(array $data) => $context->adminFormTransform($data), + static fn(array $data) => $context->adminFormReverseTransform($data) )); $context->buildAdminForm($sub); $builder->add($sub); diff --git a/src/Bundle/ChillDocGeneratorBundle/Service/Generator/ObjectReadyException.php b/src/Bundle/ChillDocGeneratorBundle/Service/Generator/ObjectReadyException.php index 37540a2f8..15db2eed4 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Service/Generator/ObjectReadyException.php +++ b/src/Bundle/ChillDocGeneratorBundle/Service/Generator/ObjectReadyException.php @@ -17,6 +17,6 @@ class ObjectReadyException extends RuntimeException { public function __construct() { - parent::__construct('object is already ready', 6698856); + parent::__construct('object is already ready', 6_698_856); } } diff --git a/src/Bundle/ChillDocGeneratorBundle/Service/Generator/RelatedEntityNotFoundException.php b/src/Bundle/ChillDocGeneratorBundle/Service/Generator/RelatedEntityNotFoundException.php index 9cca0bcda..0453975b2 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Service/Generator/RelatedEntityNotFoundException.php +++ b/src/Bundle/ChillDocGeneratorBundle/Service/Generator/RelatedEntityNotFoundException.php @@ -19,7 +19,7 @@ class RelatedEntityNotFoundException extends RuntimeException { parent::__construct( sprintf('Related entity not found: %s, %s', $relatedEntityClass, $relatedEntityId), - 99876652, + 99_876_652, $previous ); } diff --git a/src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php b/src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php index e83d3b3fc..0583e26b2 100644 --- a/src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php +++ b/src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php @@ -58,7 +58,7 @@ class StoredObject implements AsyncFileInterface, Document, TrackCreationInterfa * @ORM\Column(type="integer") * @Serializer\Groups({"read", "write"}) */ - private ?int $id; + private ?int $id = null; /** * @var int[] @@ -94,7 +94,7 @@ class StoredObject implements AsyncFileInterface, Document, TrackCreationInterfa /** * @ORM\ManyToOne(targetEntity=DocGeneratorTemplate::class) */ - private ?DocGeneratorTemplate $template; + private ?DocGeneratorTemplate $template = null; /** * @ORM\Column(type="text", options={"default": "ready"}) diff --git a/src/Bundle/ChillDocStoreBundle/Form/AccompanyingCourseDocumentType.php b/src/Bundle/ChillDocStoreBundle/Form/AccompanyingCourseDocumentType.php index f77083390..255ca5dc5 100644 --- a/src/Bundle/ChillDocStoreBundle/Form/AccompanyingCourseDocumentType.php +++ b/src/Bundle/ChillDocStoreBundle/Form/AccompanyingCourseDocumentType.php @@ -72,14 +72,10 @@ class AccompanyingCourseDocumentType extends AbstractType ->add('category', EntityType::class, [ 'placeholder' => 'Choose a document category', 'class' => DocumentCategory::class, - 'query_builder' => static function (EntityRepository $er) { - return $er->createQueryBuilder('c') - ->where('c.documentClass = :docClass') - ->setParameter('docClass', AccompanyingCourseDocument::class); - }, - 'choice_label' => function ($entity = null) { - return $entity ? $this->translatableStringHelper->localize($entity->getName()) : ''; - }, + 'query_builder' => static fn(EntityRepository $er) => $er->createQueryBuilder('c') + ->where('c.documentClass = :docClass') + ->setParameter('docClass', AccompanyingCourseDocument::class), + 'choice_label' => fn($entity = null) => $entity ? $this->translatableStringHelper->localize($entity->getName()) : '', ]); } diff --git a/src/Bundle/ChillDocStoreBundle/Form/PersonDocumentType.php b/src/Bundle/ChillDocStoreBundle/Form/PersonDocumentType.php index c87cc4e73..c7cf31534 100644 --- a/src/Bundle/ChillDocStoreBundle/Form/PersonDocumentType.php +++ b/src/Bundle/ChillDocStoreBundle/Form/PersonDocumentType.php @@ -67,14 +67,10 @@ class PersonDocumentType extends AbstractType ->add('category', EntityType::class, [ 'placeholder' => 'Choose a document category', 'class' => DocumentCategory::class, - 'query_builder' => static function (EntityRepository $er) { - return $er->createQueryBuilder('c') - ->where('c.documentClass = :docClass') - ->setParameter('docClass', PersonDocument::class); - }, - 'choice_label' => function ($entity = null) { - return $entity ? $this->translatableStringHelper->localize($entity->getName()) : ''; - }, + 'query_builder' => static fn(EntityRepository $er) => $er->createQueryBuilder('c') + ->where('c.documentClass = :docClass') + ->setParameter('docClass', PersonDocument::class), + 'choice_label' => fn($entity = null) => $entity ? $this->translatableStringHelper->localize($entity->getName()) : '', ]); if ($isScopeConcerned && $this->parameterBag->get('chill_main')['acl']['form_show_scopes']) { diff --git a/src/Bundle/ChillDocStoreBundle/Workflow/AccompanyingCourseDocumentWorkflowHandler.php b/src/Bundle/ChillDocStoreBundle/Workflow/AccompanyingCourseDocumentWorkflowHandler.php index c538bd107..b819ae8c3 100644 --- a/src/Bundle/ChillDocStoreBundle/Workflow/AccompanyingCourseDocumentWorkflowHandler.php +++ b/src/Bundle/ChillDocStoreBundle/Workflow/AccompanyingCourseDocumentWorkflowHandler.php @@ -51,9 +51,7 @@ class AccompanyingCourseDocumentWorkflowHandler implements EntityWorkflowHandler $persons = []; if (null !== $course) { - $persons = $course->getCurrentParticipations()->map(static function (AccompanyingPeriodParticipation $participation) { - return $participation->getPerson(); - })->toArray(); + $persons = $course->getCurrentParticipations()->map(static fn(AccompanyingPeriodParticipation $participation) => $participation->getPerson())->toArray(); } return [ diff --git a/src/Bundle/ChillEventBundle/Controller/ParticipationController.php b/src/Bundle/ChillEventBundle/Controller/ParticipationController.php index dafbc8b8a..51ba3634d 100644 --- a/src/Bundle/ChillEventBundle/Controller/ParticipationController.php +++ b/src/Bundle/ChillEventBundle/Controller/ParticipationController.php @@ -113,9 +113,7 @@ class ParticipationController extends AbstractController [ 'event_id' => current($participations)->getEvent()->getId(), 'persons_ids' => implode(',', array_map( - static function (Participation $p) { - return $p->getPerson()->getId(); - }, + static fn(Participation $p) => $p->getPerson()->getId(), $participations )), ] @@ -649,19 +647,14 @@ class ParticipationController extends AbstractController // create a collection of person's id participating to the event /** @var \Doctrine\Common\Collections\ArrayCollection $peopleParticipating */ - $peopleParticipating = $peopleParticipating ?? - $participation->getEvent()->getParticipations()->map( - static function (Participation $p) { - return $p->getPerson()->getId(); - } - ); + $peopleParticipating ??= $participation->getEvent()->getParticipations()->map( + static fn(Participation $p) => $p->getPerson()->getId() + ); // check that the user is not already in the event if ($peopleParticipating->contains($participation->getPerson()->getId())) { $ignoredParticipations[] = $participation ->getEvent()->getParticipations()->filter( - static function (Participation $p) use ($participation) { - return $p->getPerson()->getId() === $participation->getPerson()->getId(); - } + static fn(Participation $p) => $p->getPerson()->getId() === $participation->getPerson()->getId() )->first(); } else { $newParticipations[] = $participation; diff --git a/src/Bundle/ChillEventBundle/Entity/Event.php b/src/Bundle/ChillEventBundle/Entity/Event.php index 6ac9c1508..669cb02db 100644 --- a/src/Bundle/ChillEventBundle/Entity/Event.php +++ b/src/Bundle/ChillEventBundle/Entity/Event.php @@ -176,9 +176,7 @@ class Event implements HasCenterInterface, HasScopeInterface { $iterator = $this->participations->getIterator(); - $iterator->uasort(static function ($first, $second) { - return strnatcasecmp($first->getPerson()->getFirstName(), $second->getPerson()->getFirstName()); - }); + $iterator->uasort(static fn($first, $second) => strnatcasecmp($first->getPerson()->getFirstName(), $second->getPerson()->getFirstName())); return $iterator; } diff --git a/src/Bundle/ChillEventBundle/Form/ChoiceLoader/EventChoiceLoader.php b/src/Bundle/ChillEventBundle/Form/ChoiceLoader/EventChoiceLoader.php index 30a00ebb9..de1c42cf8 100644 --- a/src/Bundle/ChillEventBundle/Form/ChoiceLoader/EventChoiceLoader.php +++ b/src/Bundle/ChillEventBundle/Form/ChoiceLoader/EventChoiceLoader.php @@ -62,9 +62,7 @@ class EventChoiceLoader implements ChoiceLoaderInterface { return new \Symfony\Component\Form\ChoiceList\ArrayChoiceList( $this->lazyLoadedEvents, - static function (Event $p) use ($value) { - return call_user_func($value, $p); - } + static fn(Event $p) => call_user_func($value, $p) ); } diff --git a/src/Bundle/ChillEventBundle/Form/RoleType.php b/src/Bundle/ChillEventBundle/Form/RoleType.php index 9c56d17e6..2a0b6765a 100644 --- a/src/Bundle/ChillEventBundle/Form/RoleType.php +++ b/src/Bundle/ChillEventBundle/Form/RoleType.php @@ -38,9 +38,7 @@ class RoleType extends AbstractType ->add('active') ->add('type', EntityType::class, [ 'class' => EventType::class, - 'choice_label' => function (EventType $e) { - return $this->translatableStringHelper->localize($e->getName()); - }, + 'choice_label' => fn(EventType $e) => $this->translatableStringHelper->localize($e->getName()), ]); } diff --git a/src/Bundle/ChillEventBundle/Form/Type/PickEventType.php b/src/Bundle/ChillEventBundle/Form/Type/PickEventType.php index 4e8179f10..1ec088ba6 100644 --- a/src/Bundle/ChillEventBundle/Form/Type/PickEventType.php +++ b/src/Bundle/ChillEventBundle/Form/Type/PickEventType.php @@ -109,16 +109,12 @@ class PickEventType extends AbstractType // add the default options $resolver->setDefaults([ 'class' => Event::class, - 'choice_label' => static function (Event $e) { - return $e->getDate()->format('d/m/Y, H:i') . ' → ' . - // $e->getType()->getName()['fr'] . ': ' . // display the type of event - $e->getName(); - }, + 'choice_label' => static fn(Event $e) => $e->getDate()->format('d/m/Y, H:i') . ' → ' . + // $e->getType()->getName()['fr'] . ': ' . // display the type of event + $e->getName(), 'placeholder' => 'Pick an event', 'attr' => ['class' => 'select2 '], - 'choice_attr' => static function (Event $e) { - return ['data-center' => $e->getCenter()->getId()]; - }, + 'choice_attr' => static fn(Event $e) => ['data-center' => $e->getCenter()->getId()], 'choiceloader' => function (Options $options) { $centers = $this->filterCenters($options); @@ -143,9 +139,7 @@ class PickEventType extends AbstractType // option role if (null === $options['role']) { $centers = array_map( - static function (GroupCenter $g) { - return $g->getCenter(); - }, + static fn(GroupCenter $g) => $g->getCenter(), $this->user->getGroupCenters()->toArray() ); } else { @@ -173,9 +167,7 @@ class PickEventType extends AbstractType if ( !in_array($c->getId(), array_map( - static function (Center $c) { - return $c->getId(); - }, + static fn(Center $c) => $c->getId(), $centers ), true) ) { diff --git a/src/Bundle/ChillEventBundle/Form/Type/PickEventTypeType.php b/src/Bundle/ChillEventBundle/Form/Type/PickEventTypeType.php index eacdc78f1..2ecdb27d7 100644 --- a/src/Bundle/ChillEventBundle/Form/Type/PickEventTypeType.php +++ b/src/Bundle/ChillEventBundle/Form/Type/PickEventTypeType.php @@ -39,16 +39,10 @@ class PickEventTypeType extends AbstractType $resolver->setDefaults( [ 'class' => EventType::class, - 'query_builder' => static function (EntityRepository $er) { - return $er->createQueryBuilder('et') - ->where('et.active = true'); - }, - 'choice_label' => static function (EventType $t) use ($helper) { - return $helper->localize($t->getName()); - }, - 'choice_attrs' => static function (EventType $t) { - return ['data-link-category' => $t->getId()]; - }, + 'query_builder' => static fn(EntityRepository $er) => $er->createQueryBuilder('et') + ->where('et.active = true'), + 'choice_label' => static fn(EventType $t) => $helper->localize($t->getName()), + 'choice_attrs' => static fn(EventType $t) => ['data-link-category' => $t->getId()], ] ); } diff --git a/src/Bundle/ChillEventBundle/Form/Type/PickRoleType.php b/src/Bundle/ChillEventBundle/Form/Type/PickRoleType.php index 95864056a..ca6425dc8 100644 --- a/src/Bundle/ChillEventBundle/Form/Type/PickRoleType.php +++ b/src/Bundle/ChillEventBundle/Form/Type/PickRoleType.php @@ -80,9 +80,7 @@ class PickRoleType extends AbstractType $options = $config->getOptions(); $form->getParent()->add($name, $type, array_replace($options, [ - 'group_by' => function (Role $r) { - return $this->translatableStringHelper->localize($r->getType()->getName()); - }, + 'group_by' => fn(Role $r) => $this->translatableStringHelper->localize($r->getType()->getName()), ])); } } @@ -111,17 +109,13 @@ class PickRoleType extends AbstractType 'class' => Role::class, 'query_builder' => $qb, 'group_by' => null, - 'choice_attr' => static function (Role $r) { - return [ - 'data-event-type' => $r->getType()->getId(), - 'data-link-category' => $r->getType()->getId(), - ]; - }, - 'choice_label' => static function (Role $r) use ($translatableStringHelper, $translator) { - return $translatableStringHelper->localize($r->getName()) . - ($r->getActive() === true ? '' : - ' (' . $translator->trans('unactive') . ')'); - }, + 'choice_attr' => static fn(Role $r) => [ + 'data-event-type' => $r->getType()->getId(), + 'data-link-category' => $r->getType()->getId(), + ], + 'choice_label' => static fn(Role $r) => $translatableStringHelper->localize($r->getName()) . + ($r->getActive() === true ? '' : + ' (' . $translator->trans('unactive') . ')'), ]); } diff --git a/src/Bundle/ChillEventBundle/Form/Type/PickStatusType.php b/src/Bundle/ChillEventBundle/Form/Type/PickStatusType.php index 4d96ed95d..b1078ab61 100644 --- a/src/Bundle/ChillEventBundle/Form/Type/PickStatusType.php +++ b/src/Bundle/ChillEventBundle/Form/Type/PickStatusType.php @@ -82,9 +82,7 @@ class PickStatusType extends AbstractType $type = $config->getType()->getName(); $options = $config->getOptions(); $form->getParent()->add($name, $type, array_replace($options, [ - 'group_by' => function (Status $s) { - return $this->translatableStringHelper->localize($s->getType()->getName()); - }, + 'group_by' => fn(Status $s) => $this->translatableStringHelper->localize($s->getType()->getName()), ])); } ); @@ -112,17 +110,13 @@ class PickStatusType extends AbstractType 'class' => Status::class, 'query_builder' => $qb, 'group_by' => null, - 'choice_attr' => static function (Status $s) { - return [ - 'data-event-type' => $s->getType()->getId(), - 'data-link-category' => $s->getType()->getId(), - ]; - }, - 'choice_label' => static function (Status $s) use ($translatableStringHelper, $translator) { - return $translatableStringHelper->localize($s->getName()) . - ($s->getActive() === true ? '' : - ' (' . $translator->trans('unactive') . ')'); - }, + 'choice_attr' => static fn(Status $s) => [ + 'data-event-type' => $s->getType()->getId(), + 'data-link-category' => $s->getType()->getId(), + ], + 'choice_label' => static fn(Status $s) => $translatableStringHelper->localize($s->getName()) . + ($s->getActive() === true ? '' : + ' (' . $translator->trans('unactive') . ')'), ]); } diff --git a/src/Bundle/ChillEventBundle/Tests/Controller/ParticipationControllerTest.php b/src/Bundle/ChillEventBundle/Tests/Controller/ParticipationControllerTest.php index fa1ecabbe..7c79e52e3 100644 --- a/src/Bundle/ChillEventBundle/Tests/Controller/ParticipationControllerTest.php +++ b/src/Bundle/ChillEventBundle/Tests/Controller/ParticipationControllerTest.php @@ -239,9 +239,7 @@ final class ParticipationControllerTest extends WebTestCase $this->personsIdsCache = array_merge( $this->personsIdsCache, $event->getParticipations()->map( - static function ($p) { - return $p->getPerson()->getId(); - } + static fn($p) => $p->getPerson()->getId() ) ->toArray() ); @@ -305,9 +303,7 @@ final class ParticipationControllerTest extends WebTestCase $event = $this->getRandomEventWithMultipleParticipations(); $persons_id = implode(',', $event->getParticipations()->map( - static function ($p) { - return $p->getPerson()->getId(); - } + static fn($p) => $p->getPerson()->getId() )->toArray()); $crawler = $this->client->request( @@ -333,9 +329,7 @@ final class ParticipationControllerTest extends WebTestCase $nbParticipations = $event->getParticipations()->count(); // get the persons_id participating on this event $persons_id = $event->getParticipations()->map( - static function ($p) { - return $p->getPerson()->getId(); - } + static fn($p) => $p->getPerson()->getId() )->toArray(); // exclude the existing persons_ids from the new person $this->personsIdsCache = array_merge($this->personsIdsCache, $persons_id); @@ -464,9 +458,7 @@ final class ParticipationControllerTest extends WebTestCase $circles = $this->em->getRepository(\Chill\MainBundle\Entity\Scope::class) ->findAll(); - array_filter($circles, static function ($circle) use ($circleName) { - return in_array($circleName, $circle->getName(), true); - }); + array_filter($circles, static fn($circle) => in_array($circleName, $circle->getName(), true)); $circle = $circles[0]; $events = $this->em->getRepository(\Chill\EventBundle\Entity\Event::class) diff --git a/src/Bundle/ChillEventBundle/Timeline/TimelineEventProvider.php b/src/Bundle/ChillEventBundle/Timeline/TimelineEventProvider.php index c1ae84b95..a7bf08741 100644 --- a/src/Bundle/ChillEventBundle/Timeline/TimelineEventProvider.php +++ b/src/Bundle/ChillEventBundle/Timeline/TimelineEventProvider.php @@ -208,9 +208,7 @@ class TimelineEventProvider implements TimelineProviderInterface foreach ($reachableCenters as $center) { $reachableCircleId = array_map( - static function (Scope $scope) { - return $scope->getId(); - }, + static fn(Scope $scope) => $scope->getId(), $this->helper->getReachableCircles($this->user, $role, $person->getCenter()) ); $centerAndScopeLines[] = sprintf( diff --git a/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php b/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php index 9e6555025..730ac32c1 100644 --- a/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php +++ b/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php @@ -230,7 +230,7 @@ class CRUDController extends AbstractController */ protected function createFormFor(string $action, $entity, ?string $formClass = null, array $formOptions = []): FormInterface { - $formClass = $formClass ?? $this->getFormClassFor($action); + $formClass ??= $this->getFormClassFor($action); $form = $this->createForm($formClass, $entity, $formOptions); diff --git a/src/Bundle/ChillMainBundle/CRUD/Routing/CRUDRoutesLoader.php b/src/Bundle/ChillMainBundle/CRUD/Routing/CRUDRoutesLoader.php index 76da401a3..01f80d1b8 100644 --- a/src/Bundle/ChillMainBundle/CRUD/Routing/CRUDRoutesLoader.php +++ b/src/Bundle/ChillMainBundle/CRUD/Routing/CRUDRoutesLoader.php @@ -141,9 +141,7 @@ class CRUDRoutesLoader extends Loader $methods = array_keys(array_filter( $action['methods'], - static function ($value, $key) { - return $value; - }, + static fn($value, $key) => $value, ARRAY_FILTER_USE_BOTH )); diff --git a/src/Bundle/ChillMainBundle/Controller/NotificationController.php b/src/Bundle/ChillMainBundle/Controller/NotificationController.php index a6e876b6d..29ec6e7f0 100644 --- a/src/Bundle/ChillMainBundle/Controller/NotificationController.php +++ b/src/Bundle/ChillMainBundle/Controller/NotificationController.php @@ -282,9 +282,7 @@ class NotificationController extends AbstractController if ($request->query->has('edit')) { $commentId = $request->query->getInt('edit'); - $editedComment = $notification->getComments()->filter(static function (NotificationComment $c) use ($commentId) { - return $c->getId() === $commentId; - })->first(); + $editedComment = $notification->getComments()->filter(static fn(NotificationComment $c) => $c->getId() === $commentId)->first(); if (false === $editedComment) { throw $this->createNotFoundException("Comment with id {$commentId} does not exists nor belong to this notification"); diff --git a/src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php b/src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php index 372d0d7d1..3292b3540 100644 --- a/src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php +++ b/src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php @@ -158,9 +158,7 @@ class PermissionsGroupController extends AbstractController 'edit_form' => $editForm->createView(), 'role_scopes_sorted' => $roleScopesSorted, 'expanded_roles' => $this->getExpandedRoles($permissionsGroup->getRoleScopes()->toArray()), - 'delete_role_scopes_form' => array_map(static function ($form) { - return $form->createView(); - }, $deleteRoleScopesForm), + 'delete_role_scopes_form' => array_map(static fn($form) => $form->createView(), $deleteRoleScopesForm), 'add_role_scopes_form' => $addRoleScopesForm->createView(), ]); } @@ -305,9 +303,7 @@ class PermissionsGroupController extends AbstractController 'role_scopes_sorted' => $roleScopesSorted, 'edit_form' => $editForm->createView(), 'expanded_roles' => $this->getExpandedRoles($permissionsGroup->getRoleScopes()->toArray()), - 'delete_role_scopes_form' => array_map(static function ($form) { - return $form->createView(); - }, $deleteRoleScopesForm), + 'delete_role_scopes_form' => array_map(static fn($form) => $form->createView(), $deleteRoleScopesForm), 'add_role_scopes_form' => $addRoleScopesForm->createView(), ]); } @@ -449,9 +445,7 @@ class PermissionsGroupController extends AbstractController 'role_scopes_sorted' => $roleScopesSorted, 'edit_form' => $editForm->createView(), 'expanded_roles' => $this->getExpandedRoles($permissionsGroup->getRoleScopes()->toArray()), - 'delete_role_scopes_form' => array_map(static function ($form) { - return $form->createView(); - }, $deleteRoleScopesForm), + 'delete_role_scopes_form' => array_map(static fn($form) => $form->createView(), $deleteRoleScopesForm), 'add_role_scopes_form' => $addRoleScopesForm->createView(), ]); } @@ -573,9 +567,7 @@ class PermissionsGroupController extends AbstractController if (!array_key_exists($roleScope->getRole(), $expandedRoles)) { $expandedRoles[$roleScope->getRole()] = array_map( - static function (Role $role) { - return $role->getRole(); - }, + static fn(Role $role) => $role->getRole(), $this->roleHierarchy ->getReachableRoles( [new Role($roleScope->getRole())] diff --git a/src/Bundle/ChillMainBundle/Controller/UserController.php b/src/Bundle/ChillMainBundle/Controller/UserController.php index 9d3941411..64cef168d 100644 --- a/src/Bundle/ChillMainBundle/Controller/UserController.php +++ b/src/Bundle/ChillMainBundle/Controller/UserController.php @@ -337,9 +337,7 @@ class UserController extends CRUDController [ 'add_groupcenter_form' => $this->createAddLinkGroupCenterForm($entity, $request)->createView(), 'delete_groupcenter_form' => array_map( - static function (Form $form) { - return $form->createView(); - }, + static fn(Form $form) => $form->createView(), iterator_to_array($this->getDeleteLinkGroupCenterByUser($entity, $request), true) ), ] diff --git a/src/Bundle/ChillMainBundle/Controller/WorkflowController.php b/src/Bundle/ChillMainBundle/Controller/WorkflowController.php index ee09cc1a6..af4974bbe 100644 --- a/src/Bundle/ChillMainBundle/Controller/WorkflowController.php +++ b/src/Bundle/ChillMainBundle/Controller/WorkflowController.php @@ -345,12 +345,10 @@ class WorkflowController extends AbstractController if ($transitionForm->isSubmitted() && $transitionForm->isValid()) { if (!$workflow->can($entityWorkflow, $transition = $transitionForm['transition']->getData()->getName())) { $blockers = $workflow->buildTransitionBlockerList($entityWorkflow, $transition); - $msgs = array_map(function (TransitionBlocker $tb) { - return $this->translator->trans( - $tb->getMessage(), - $tb->getParameters() - ); - }, iterator_to_array($blockers)); + $msgs = array_map(fn(TransitionBlocker $tb) => $this->translator->trans( + $tb->getMessage(), + $tb->getParameters() + ), iterator_to_array($blockers)); throw $this->createAccessDeniedException( sprintf( diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/MenuCompilerPass.php b/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/MenuCompilerPass.php index ae53f09df..da2cbff1f 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/MenuCompilerPass.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/MenuCompilerPass.php @@ -37,9 +37,7 @@ class MenuCompilerPass implements CompilerPassInterface ]; } - usort($services, static function ($a, $b) { - return $a['priority'] <=> $b['priority']; - }); + usort($services, static fn($a, $b) => $a['priority'] <=> $b['priority']); foreach ($services as $service) { $class = $container->getDefinition($service['id'])->getClass(); diff --git a/src/Bundle/ChillMainBundle/Doctrine/DQL/Greatest.php b/src/Bundle/ChillMainBundle/Doctrine/DQL/Greatest.php index b9ca9c4b6..a56bcb50c 100644 --- a/src/Bundle/ChillMainBundle/Doctrine/DQL/Greatest.php +++ b/src/Bundle/ChillMainBundle/Doctrine/DQL/Greatest.php @@ -33,9 +33,7 @@ class Greatest extends FunctionNode public function getSql(SqlWalker $sqlWalker) { - return 'GREATEST(' . implode(', ', array_map(static function (Node $expr) use ($sqlWalker) { - return $expr->dispatch($sqlWalker); - }, $this->exprs)) . ')'; + return 'GREATEST(' . implode(', ', array_map(static fn(Node $expr) => $expr->dispatch($sqlWalker), $this->exprs)) . ')'; } public function parse(Parser $parser) diff --git a/src/Bundle/ChillMainBundle/Doctrine/DQL/Least.php b/src/Bundle/ChillMainBundle/Doctrine/DQL/Least.php index 0c8a1b17d..e31d31456 100644 --- a/src/Bundle/ChillMainBundle/Doctrine/DQL/Least.php +++ b/src/Bundle/ChillMainBundle/Doctrine/DQL/Least.php @@ -33,9 +33,7 @@ class Least extends FunctionNode public function getSql(SqlWalker $sqlWalker) { - return 'LEAST(' . implode(', ', array_map(static function (Node $expr) use ($sqlWalker) { - return $expr->dispatch($sqlWalker); - }, $this->exprs)) . ')'; + return 'LEAST(' . implode(', ', array_map(static fn(Node $expr) => $expr->dispatch($sqlWalker), $this->exprs)) . ')'; } public function parse(Parser $parser) diff --git a/src/Bundle/ChillMainBundle/Entity/Address.php b/src/Bundle/ChillMainBundle/Entity/Address.php index 8bf4d1be5..1bd1a453a 100644 --- a/src/Bundle/ChillMainBundle/Entity/Address.php +++ b/src/Bundle/ChillMainBundle/Entity/Address.php @@ -149,7 +149,7 @@ class Address implements TrackCreationInterface, TrackUpdateInterface * @Groups({"write"}) * @ORM\JoinColumn(nullable=true, onDelete="SET NULL") */ - private ?ThirdParty $linkedToThirdParty; + private ?ThirdParty $linkedToThirdParty = null; /** * A geospatial field storing the coordinates of the Address. diff --git a/src/Bundle/ChillMainBundle/Entity/AddressReference.php b/src/Bundle/ChillMainBundle/Entity/AddressReference.php index 57421749f..e75402c5f 100644 --- a/src/Bundle/ChillMainBundle/Entity/AddressReference.php +++ b/src/Bundle/ChillMainBundle/Entity/AddressReference.php @@ -55,7 +55,7 @@ class AddressReference * @ORM\Column(type="integer") * @groups({"read"}) */ - private ?int $id; + private ?int $id = null; /** * @ORM\Column(type="text", nullable=false, options={"default": ""}) @@ -79,7 +79,7 @@ class AddressReference * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\PostalCode") * @groups({"read"}) */ - private ?PostalCode $postcode; + private ?PostalCode $postcode = null; /** * @ORM\Column(type="text", nullable=false, options={"default": ""}) diff --git a/src/Bundle/ChillMainBundle/Entity/GeographicalUnit.php b/src/Bundle/ChillMainBundle/Entity/GeographicalUnit.php index 37735bbc2..ea017f053 100644 --- a/src/Bundle/ChillMainBundle/Entity/GeographicalUnit.php +++ b/src/Bundle/ChillMainBundle/Entity/GeographicalUnit.php @@ -36,7 +36,7 @@ class GeographicalUnit /** * @ORM\ManyToOne(targetEntity=GeographicalUnitLayer::class, inversedBy="units") */ - private ?GeographicalUnitLayer $layer; + private ?GeographicalUnitLayer $layer = null; /** * @ORM\Column(type="text", nullable=false, options={"default": ""}) diff --git a/src/Bundle/ChillMainBundle/Entity/Notification.php b/src/Bundle/ChillMainBundle/Entity/Notification.php index b8586b2e6..dc81b1b54 100644 --- a/src/Bundle/ChillMainBundle/Entity/Notification.php +++ b/src/Bundle/ChillMainBundle/Entity/Notification.php @@ -120,12 +120,12 @@ class Notification implements TrackUpdateInterface /** * @ORM\Column(type="datetime_immutable") */ - private ?DateTimeImmutable $updatedAt; + private ?DateTimeImmutable $updatedAt = null; /** * @ORM\ManyToOne(targetEntity=User::class) */ - private ?User $updatedBy; + private ?User $updatedBy = null; public function __construct() { diff --git a/src/Bundle/ChillMainBundle/Entity/PermissionsGroup.php b/src/Bundle/ChillMainBundle/Entity/PermissionsGroup.php index fa505e550..34e22d3e1 100644 --- a/src/Bundle/ChillMainBundle/Entity/PermissionsGroup.php +++ b/src/Bundle/ChillMainBundle/Entity/PermissionsGroup.php @@ -121,9 +121,7 @@ class PermissionsGroup public function isRoleScopePresentOnce(ExecutionContextInterface $context) { $roleScopesId = array_map( - static function (RoleScope $roleScope) { - return $roleScope->getId(); - }, + static fn(RoleScope $roleScope) => $roleScope->getId(), $this->getRoleScopes()->toArray() ); $countedIds = array_count_values($roleScopesId); diff --git a/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStep.php b/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStep.php index e43d524a4..f94a154db 100644 --- a/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStep.php +++ b/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStep.php @@ -291,9 +291,7 @@ class EntityWorkflowStep public function removeDestEmail(string $email): self { - $this->destEmail = array_filter($this->destEmail, static function (string $existing) use ($email) { - return $email !== $existing; - }); + $this->destEmail = array_filter($this->destEmail, static fn(string $existing) => $email !== $existing); return $this; } diff --git a/src/Bundle/ChillMainBundle/Export/Formatter/CSVListFormatter.php b/src/Bundle/ChillMainBundle/Export/Formatter/CSVListFormatter.php index 7dc6f120f..a6b7094e4 100644 --- a/src/Bundle/ChillMainBundle/Export/Formatter/CSVListFormatter.php +++ b/src/Bundle/ChillMainBundle/Export/Formatter/CSVListFormatter.php @@ -199,9 +199,7 @@ class CSVListFormatter implements FormatterInterface foreach ($keys as $key) { // get an array with all values for this key if possible - $values = array_map(static function ($v) use ($key) { - return $v[$key]; - }, $this->result); + $values = array_map(static fn($v) => $v[$key], $this->result); // store the label in the labelsCache property $this->labelsCache[$key] = $export->getLabels($key, $values, $this->exportData); } diff --git a/src/Bundle/ChillMainBundle/Export/Formatter/CSVPivotedListFormatter.php b/src/Bundle/ChillMainBundle/Export/Formatter/CSVPivotedListFormatter.php index b062a9c3c..87814eb47 100644 --- a/src/Bundle/ChillMainBundle/Export/Formatter/CSVPivotedListFormatter.php +++ b/src/Bundle/ChillMainBundle/Export/Formatter/CSVPivotedListFormatter.php @@ -187,9 +187,7 @@ class CSVPivotedListFormatter implements FormatterInterface foreach ($keys as $key) { // get an array with all values for this key if possible - $values = array_map(static function ($v) use ($key) { - return $v[$key]; - }, $this->result); + $values = array_map(static fn($v) => $v[$key], $this->result); // store the label in the labelsCache property $this->labelsCache[$key] = $export->getLabels($key, $values, $this->exportData); } diff --git a/src/Bundle/ChillMainBundle/Export/Formatter/SpreadSheetFormatter.php b/src/Bundle/ChillMainBundle/Export/Formatter/SpreadSheetFormatter.php index 66db056c4..dc09c55a1 100644 --- a/src/Bundle/ChillMainBundle/Export/Formatter/SpreadSheetFormatter.php +++ b/src/Bundle/ChillMainBundle/Export/Formatter/SpreadSheetFormatter.php @@ -445,7 +445,7 @@ class SpreadSheetFormatter implements FormatterInterface $this->initializeCache($key); } - $value = $value ?? ''; + $value ??= ''; return call_user_func($this->cacheDisplayableResult[$key], $value); } diff --git a/src/Bundle/ChillMainBundle/Export/Helper/ExportAddressHelper.php b/src/Bundle/ChillMainBundle/Export/Helper/ExportAddressHelper.php index c9882f557..99f78fe80 100644 --- a/src/Bundle/ChillMainBundle/Export/Helper/ExportAddressHelper.php +++ b/src/Bundle/ChillMainBundle/Export/Helper/ExportAddressHelper.php @@ -249,7 +249,7 @@ class ExportAddressHelper if (($params & $bitmask) === $bitmask) { if ('geographical_units' === $key) { // geographical unit generate keys dynamically, depending on layers - $prefixes = array_merge($prefixes, array_keys($this->generateKeysForUnitsNames($prefix)), array_keys($this->generateKeysForUnitsRefs($prefix))); + $prefixes = [...$prefixes, ...array_keys($this->generateKeysForUnitsNames($prefix)), ...array_keys($this->generateKeysForUnitsRefs($prefix))]; continue; } @@ -257,9 +257,7 @@ class ExportAddressHelper $prefixes = array_merge( $prefixes, array_map( - static function ($item) use ($prefix) { - return $prefix . $item; - }, + static fn($item) => $prefix . $item, self::COLUMN_MAPPING[$key] ) ); diff --git a/src/Bundle/ChillMainBundle/Form/ChoiceLoader/PostalCodeChoiceLoader.php b/src/Bundle/ChillMainBundle/Form/ChoiceLoader/PostalCodeChoiceLoader.php index bb9b180f5..99fb54514 100644 --- a/src/Bundle/ChillMainBundle/Form/ChoiceLoader/PostalCodeChoiceLoader.php +++ b/src/Bundle/ChillMainBundle/Form/ChoiceLoader/PostalCodeChoiceLoader.php @@ -48,9 +48,7 @@ class PostalCodeChoiceLoader implements ChoiceLoaderInterface { return new \Symfony\Component\Form\ChoiceList\ArrayChoiceList( $this->lazyLoadedPostalCodes, - static function (?PostalCode $pc = null) use ($value) { - return call_user_func($value, $pc); - } + static fn(?PostalCode $pc = null) => call_user_func($value, $pc) ); } diff --git a/src/Bundle/ChillMainBundle/Form/DataMapper/ExportPickCenterDataMapper.php b/src/Bundle/ChillMainBundle/Form/DataMapper/ExportPickCenterDataMapper.php index 52e053795..90c919f1d 100644 --- a/src/Bundle/ChillMainBundle/Form/DataMapper/ExportPickCenterDataMapper.php +++ b/src/Bundle/ChillMainBundle/Form/DataMapper/ExportPickCenterDataMapper.php @@ -37,9 +37,7 @@ class ExportPickCenterDataMapper implements DataMapperInterface foreach ($this->regroupmentRepository->findAll() as $regroupment) { /** @phpstan-ignore-next-line */ - [$contained, $notContained] = $regroupment->getCenters()->partition(static function (Center $center): bool { - return false; - }); + [$contained, $notContained] = $regroupment->getCenters()->partition(static fn(Center $center): bool => false); if (0 === count($notContained)) { $pickedRegroupment[] = $regroupment; diff --git a/src/Bundle/ChillMainBundle/Form/DataTransformer/IdToEntityDataTransformer.php b/src/Bundle/ChillMainBundle/Form/DataTransformer/IdToEntityDataTransformer.php index cc215e7aa..4d89f7851 100644 --- a/src/Bundle/ChillMainBundle/Form/DataTransformer/IdToEntityDataTransformer.php +++ b/src/Bundle/ChillMainBundle/Form/DataTransformer/IdToEntityDataTransformer.php @@ -42,9 +42,7 @@ class IdToEntityDataTransformer implements DataTransformerInterface { $this->repository = $repository; $this->multiple = $multiple; - $this->getId = $getId ?? static function (object $o) { - return $o->getId(); - }; + $this->getId = $getId ?? static fn(object $o) => $o->getId(); } /** diff --git a/src/Bundle/ChillMainBundle/Form/LocationFormType.php b/src/Bundle/ChillMainBundle/Form/LocationFormType.php index 5a6776daf..3cf599a52 100644 --- a/src/Bundle/ChillMainBundle/Form/LocationFormType.php +++ b/src/Bundle/ChillMainBundle/Form/LocationFormType.php @@ -36,15 +36,11 @@ final class LocationFormType extends AbstractType $builder ->add('locationType', EntityType::class, [ 'class' => EntityLocationType::class, - 'choice_attr' => static function (EntityLocationType $entity) { - return [ - 'data-address' => $entity->getAddressRequired(), - 'data-contact' => $entity->getContactData(), - ]; - }, - 'choice_label' => function (EntityLocationType $entity) { - return $this->translatableStringHelper->localize($entity->getTitle()); - }, + 'choice_attr' => static fn(EntityLocationType $entity) => [ + 'data-address' => $entity->getAddressRequired(), + 'data-contact' => $entity->getContactData(), + ], + 'choice_label' => fn(EntityLocationType $entity) => $this->translatableStringHelper->localize($entity->getTitle()), ]) ->add('name', TextType::class) ->add('phonenumber1', ChillPhoneNumberType::class, ['required' => false]) diff --git a/src/Bundle/ChillMainBundle/Form/Type/ComposedGroupCenterType.php b/src/Bundle/ChillMainBundle/Form/Type/ComposedGroupCenterType.php index cfc838f5a..fdd24eb3f 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/ComposedGroupCenterType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/ComposedGroupCenterType.php @@ -24,14 +24,10 @@ class ComposedGroupCenterType extends AbstractType { $builder->add('permissionsgroup', EntityType::class, [ 'class' => \Chill\MainBundle\Entity\PermissionsGroup::class, - 'choice_label' => static function (PermissionsGroup $group) { - return $group->getName(); - }, + 'choice_label' => static fn(PermissionsGroup $group) => $group->getName(), ])->add('center', EntityType::class, [ 'class' => \Chill\MainBundle\Entity\Center::class, - 'choice_label' => static function (Center $center) { - return $center->getName(); - }, + 'choice_label' => static fn(Center $center) => $center->getName(), ]); } diff --git a/src/Bundle/ChillMainBundle/Form/Type/ComposedRoleScopeType.php b/src/Bundle/ChillMainBundle/Form/Type/ComposedRoleScopeType.php index a09130c03..4424cccf3 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/ComposedRoleScopeType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/ComposedRoleScopeType.php @@ -82,15 +82,11 @@ class ComposedRoleScopeType extends AbstractType return ['data-has-scope' => '1']; }, - 'group_by' => function ($role, $key, $index) { - return $this->roleProvider->getRoleTitle($role); - }, + 'group_by' => fn($role, $key, $index) => $this->roleProvider->getRoleTitle($role), ]) ->add('scope', EntityType::class, [ 'class' => Scope::class, - 'choice_label' => static function (Scope $scope) use ($translatableStringHelper) { - return $translatableStringHelper->localize($scope->getName()); - }, + 'choice_label' => static fn(Scope $scope) => $translatableStringHelper->localize($scope->getName()), 'required' => false, 'data' => null, ]); diff --git a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php index d4759a794..24e3ffc5b 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php +++ b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php @@ -51,9 +51,7 @@ class EntityToJsonTransformer implements DataTransformerInterface } return array_map( - function ($item) { - return $this->denormalizeOne($item); - }, + fn($item) => $this->denormalizeOne($item), $denormalized ); } diff --git a/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php b/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php index 8287a8814..7a1ebcaf5 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php @@ -67,9 +67,7 @@ final class PickCenterType extends AbstractType 'choices' => $centers, 'multiple' => true, 'expanded' => true, - 'choice_label' => static function (Center $c) { - return $c->getName(); - }, + 'choice_label' => static fn(Center $c) => $c->getName(), 'data' => $centers, ]); @@ -80,9 +78,7 @@ final class PickCenterType extends AbstractType 'multiple' => true, 'expanded' => true, 'choices' => $this->regroupmentRepository->findAllActive(), - 'choice_label' => static function (Regroupment $r) { - return $r->getName(); - }, + 'choice_label' => static fn(Regroupment $r) => $r->getName(), ]); } diff --git a/src/Bundle/ChillMainBundle/Form/Type/PickCenterType.php b/src/Bundle/ChillMainBundle/Form/Type/PickCenterType.php index 0f6dd44bc..b977dd102 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PickCenterType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PickCenterType.php @@ -90,9 +90,7 @@ class PickCenterType extends AbstractType return ['center' => $data]; }, - static function ($data) { - return $data['center']; - } + static fn($data) => $data['center'] )); } diff --git a/src/Bundle/ChillMainBundle/Form/Type/PickCivilityType.php b/src/Bundle/ChillMainBundle/Form/Type/PickCivilityType.php index 84342dfc3..c5e0f7d80 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PickCivilityType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PickCivilityType.php @@ -34,17 +34,13 @@ class PickCivilityType extends AbstractType ->setDefault('label', 'Civility') ->setDefault( 'choice_label', - function (Civility $civility): string { - return $this->translatableStringHelper->localize($civility->getName()); - } + fn(Civility $civility): string => $this->translatableStringHelper->localize($civility->getName()) ) ->setDefault( 'query_builder', - static function (EntityRepository $er): QueryBuilder { - return $er->createQueryBuilder('c') - ->where('c.active = true') - ->orderBy('c.order'); - }, + static fn(EntityRepository $er): QueryBuilder => $er->createQueryBuilder('c') + ->where('c.active = true') + ->orderBy('c.order'), ) ->setDefault('placeholder', 'choose civility') ->setDefault('class', Civility::class); diff --git a/src/Bundle/ChillMainBundle/Form/Type/PickLocationTypeType.php b/src/Bundle/ChillMainBundle/Form/Type/PickLocationTypeType.php index 6774e0941..0763e485e 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PickLocationTypeType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PickLocationTypeType.php @@ -31,9 +31,7 @@ class PickLocationTypeType extends AbstractType $resolver ->setDefaults([ 'class' => LocationType::class, - 'choice_label' => function (LocationType $type) { - return $this->translatableStringHelper->localize($type->getTitle()); - }, + 'choice_label' => fn(LocationType $type) => $this->translatableStringHelper->localize($type->getTitle()), 'placeholder' => 'Pick a location type', 'required' => false, 'attr' => ['class' => 'select2'], diff --git a/src/Bundle/ChillMainBundle/Form/Type/PickUserLocationType.php b/src/Bundle/ChillMainBundle/Form/Type/PickUserLocationType.php index 792daa39e..bd19e5f29 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PickUserLocationType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PickUserLocationType.php @@ -36,11 +36,9 @@ class PickUserLocationType extends AbstractType ->setDefaults([ 'class' => Location::class, 'choices' => $this->locationRepository->findByPublicLocations(), - 'choice_label' => function (Location $entity) { - return $entity->getName() ? - $entity->getName() . ' (' . $this->translatableStringHelper->localize($entity->getLocationType()->getTitle()) . ')' : - $this->translatableStringHelper->localize($entity->getLocationType()->getTitle()); - }, + 'choice_label' => fn(Location $entity) => $entity->getName() ? + $entity->getName() . ' (' . $this->translatableStringHelper->localize($entity->getLocationType()->getTitle()) . ')' : + $this->translatableStringHelper->localize($entity->getLocationType()->getTitle()), 'placeholder' => 'Pick a location', 'required' => false, 'attr' => ['class' => 'select2'], diff --git a/src/Bundle/ChillMainBundle/Form/Type/PostalCodeType.php b/src/Bundle/ChillMainBundle/Form/Type/PostalCodeType.php index 60fefddfa..a611f3da9 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PostalCodeType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PostalCodeType.php @@ -77,10 +77,8 @@ class PostalCodeType extends AbstractType $helper = $this->translatableStringHelper; $resolver ->setDefault('class', PostalCode::class) - ->setDefault('choice_label', static function (PostalCode $code) use ($helper) { - return $code->getCode() . ' ' . $code->getName() . ' [' . - $helper->localize($code->getCountry()->getName()) . ']'; - }) + ->setDefault('choice_label', static fn(PostalCode $code) => $code->getCode() . ' ' . $code->getName() . ' [' . + $helper->localize($code->getCountry()->getName()) . ']') ->setDefault('choice_loader', $this->choiceLoader) ->setDefault('placeholder', 'Select a postal code'); } diff --git a/src/Bundle/ChillMainBundle/Form/Type/ScopePickerType.php b/src/Bundle/ChillMainBundle/Form/Type/ScopePickerType.php index 79ed6df40..77bf84cca 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/ScopePickerType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/ScopePickerType.php @@ -66,9 +66,7 @@ class ScopePickerType extends AbstractType $options['role'] instanceof Role ? $options['role']->getRole() : $options['role'], $options['center'] ), - static function (Scope $s) { - return $s->isActive(); - } + static fn(Scope $s) => $s->isActive() ); if (0 === count($items)) { @@ -79,9 +77,7 @@ class ScopePickerType extends AbstractType $builder->add('scope', EntityType::class, [ 'class' => Scope::class, 'placeholder' => 'Choose the circle', - 'choice_label' => function (Scope $c) { - return $this->translatableStringHelper->localize($c->getName()); - }, + 'choice_label' => fn(Scope $c) => $this->translatableStringHelper->localize($c->getName()), 'choices' => $items, ]); $builder->setDataMapper(new ScopePickerDataMapper()); diff --git a/src/Bundle/ChillMainBundle/Form/Type/UserPickerType.php b/src/Bundle/ChillMainBundle/Form/Type/UserPickerType.php index 6b1bb357a..974ef4566 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/UserPickerType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/UserPickerType.php @@ -79,9 +79,7 @@ class UserPickerType extends AbstractType ->setAllowedTypes('having_permissions_group_flag', ['string', 'null']) ->setDefault('class', User::class) ->setDefault('placeholder', 'Choose an user') - ->setDefault('choice_label', function (User $u) { - return $this->userRender->renderString($u, []); - }) + ->setDefault('choice_label', fn(User $u) => $this->userRender->renderString($u, [])) ->setDefault('scope', null) ->setAllowedTypes('scope', [Scope::class, 'array', 'null']) ->setNormalizer('choices', function (Options $options) { diff --git a/src/Bundle/ChillMainBundle/Form/UserType.php b/src/Bundle/ChillMainBundle/Form/UserType.php index e2255a1ab..e343b0fc4 100644 --- a/src/Bundle/ChillMainBundle/Form/UserType.php +++ b/src/Bundle/ChillMainBundle/Form/UserType.php @@ -77,18 +77,14 @@ class UserType extends AbstractType 'required' => false, 'placeholder' => 'Choose a main scope', 'class' => Scope::class, - 'choice_label' => function (Scope $c) { - return $this->translatableStringHelper->localize($c->getName()); - }, + 'choice_label' => fn(Scope $c) => $this->translatableStringHelper->localize($c->getName()), ]) ->add('userJob', EntityType::class, [ 'label' => 'user job', 'required' => false, 'placeholder' => 'choose a job', 'class' => UserJob::class, - 'choice_label' => function (UserJob $c) { - return $this->translatableStringHelper->localize($c->getLabel()); - }, + 'choice_label' => fn(UserJob $c) => $this->translatableStringHelper->localize($c->getLabel()), 'query_builder' => static function (EntityRepository $er) { $qb = $er->createQueryBuilder('uj'); $qb->where('uj.active = TRUE'); @@ -101,9 +97,7 @@ class UserType extends AbstractType 'required' => false, 'placeholder' => 'choose a location', 'class' => Location::class, - 'choice_label' => function (Location $l) { - return $this->translatableStringHelper->localize($l->getLocationType()->getTitle()) . ' - ' . $l->getName(); - }, + 'choice_label' => fn(Location $l) => $this->translatableStringHelper->localize($l->getLocationType()->getTitle()) . ' - ' . $l->getName(), 'query_builder' => static function (EntityRepository $er) { $qb = $er->createQueryBuilder('l'); $qb->orderBy('l.locationType'); diff --git a/src/Bundle/ChillMainBundle/Form/WorkflowStepType.php b/src/Bundle/ChillMainBundle/Form/WorkflowStepType.php index 328917ac7..0e6e12b3e 100644 --- a/src/Bundle/ChillMainBundle/Form/WorkflowStepType.php +++ b/src/Bundle/ChillMainBundle/Form/WorkflowStepType.php @@ -69,9 +69,7 @@ class WorkflowStepType extends AbstractType $choices = array_combine( array_map( - static function (Transition $transition) { - return $transition->getName(); - }, + static fn(Transition $transition) => $transition->getName(), $transitions ), $transitions @@ -88,14 +86,10 @@ class WorkflowStepType extends AbstractType 'backward' => 'backward', 'neutral' => 'neutral', ], - 'choice_label' => function (string $key) use ($inputLabels) { - return $this->translatableStringHelper->localize($inputLabels[$key]); - }, - 'choice_attr' => static function (string $key) { - return [ - $key => $key, - ]; - }, + 'choice_label' => fn(string $key) => $this->translatableStringHelper->localize($inputLabels[$key]), + 'choice_attr' => static fn(string $key) => [ + $key => $key, + ], 'mapped' => false, 'expanded' => true, 'data' => 'forward', diff --git a/src/Bundle/ChillMainBundle/Routing/MenuBuilder/UserMenuBuilder.php b/src/Bundle/ChillMainBundle/Routing/MenuBuilder/UserMenuBuilder.php index ea5ed2062..e4ee3b062 100644 --- a/src/Bundle/ChillMainBundle/Routing/MenuBuilder/UserMenuBuilder.php +++ b/src/Bundle/ChillMainBundle/Routing/MenuBuilder/UserMenuBuilder.php @@ -72,7 +72,7 @@ class UserMenuBuilder implements LocalMenuBuilderInterface ] ) ->setExtras([ - 'order' => -9999999, + 'order' => -9_999_999, 'icon' => 'map-marker', ]); @@ -84,7 +84,7 @@ class UserMenuBuilder implements LocalMenuBuilderInterface 'route' => 'chill_main_user_absence_index', ]) ->setExtras([ - 'order' => -8888888, + 'order' => -8_888_888, ]); $menu @@ -116,7 +116,7 @@ class UserMenuBuilder implements LocalMenuBuilderInterface ['route' => 'change_my_password'] ) ->setExtras([ - 'order' => 99999999998, + 'order' => 99_999_999_998, ]); } } @@ -129,7 +129,7 @@ class UserMenuBuilder implements LocalMenuBuilderInterface ] ) ->setExtras([ - 'order' => 99999999999, + 'order' => 99_999_999_999, 'icon' => 'power-off', ]); } diff --git a/src/Bundle/ChillMainBundle/Search/SearchProvider.php b/src/Bundle/ChillMainBundle/Search/SearchProvider.php index a629a45d2..9010c8548 100644 --- a/src/Bundle/ChillMainBundle/Search/SearchProvider.php +++ b/src/Bundle/ChillMainBundle/Search/SearchProvider.php @@ -90,9 +90,7 @@ class SearchProvider public function getByOrder() { //sort the array - uasort($this->searchServices, static function (SearchInterface $a, SearchInterface $b) { - return $a->getOrder() <=> $b->getOrder(); - }); + uasort($this->searchServices, static fn(SearchInterface $a, SearchInterface $b) => $a->getOrder() <=> $b->getOrder()); return $this->searchServices; } @@ -119,9 +117,7 @@ class SearchProvider public function getHasAdvancedFormSearchServices() { //sort the array - uasort($this->hasAdvancedFormSearchServices, static function (SearchInterface $a, SearchInterface $b) { - return $a->getOrder() <=> $b->getOrder(); - }); + uasort($this->hasAdvancedFormSearchServices, static fn(SearchInterface $a, SearchInterface $b) => $a->getOrder() <=> $b->getOrder()); return $this->hasAdvancedFormSearchServices; } diff --git a/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceBEFromBestAddress.php b/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceBEFromBestAddress.php index 88a9cb4c5..a52379faa 100644 --- a/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceBEFromBestAddress.php +++ b/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceBEFromBestAddress.php @@ -54,9 +54,7 @@ class AddressReferenceBEFromBestAddress throw new RuntimeException('could not get the release definition', 0, $e); } - $asset = array_filter($release['assets'], static function (array $item) use ($lang, $list) { - return 'addresses-' . $list . '.' . $lang . '.csv.gz' === $item['name']; - }); + $asset = array_filter($release['assets'], static fn(array $item) => 'addresses-' . $list . '.' . $lang . '.csv.gz' === $item['name']); return array_values($asset)[0]['browser_download_url']; } diff --git a/src/Bundle/ChillMainBundle/Service/Import/PostalCodeBEFromBestAddress.php b/src/Bundle/ChillMainBundle/Service/Import/PostalCodeBEFromBestAddress.php index 64acd072a..4bca126a6 100644 --- a/src/Bundle/ChillMainBundle/Service/Import/PostalCodeBEFromBestAddress.php +++ b/src/Bundle/ChillMainBundle/Service/Import/PostalCodeBEFromBestAddress.php @@ -82,9 +82,7 @@ class PostalCodeBEFromBestAddress throw new RuntimeException('could not get the release definition', 0, $e); } - $postals = array_filter($release['assets'], static function (array $item) use ($lang) { - return 'postals.' . $lang . '.csv.gz' === $item['name']; - }); + $postals = array_filter($release['assets'], static fn(array $item) => 'postals.' . $lang . '.csv.gz' === $item['name']); return array_values($postals)[0]['browser_download_url']; } diff --git a/src/Bundle/ChillMainBundle/Service/Mailer/ChillMailer.php b/src/Bundle/ChillMainBundle/Service/Mailer/ChillMailer.php index 4658d7e3b..c6246213f 100644 --- a/src/Bundle/ChillMainBundle/Service/Mailer/ChillMailer.php +++ b/src/Bundle/ChillMainBundle/Service/Mailer/ChillMailer.php @@ -39,9 +39,7 @@ class ChillMailer implements MailerInterface } $this->chillLogger->info('chill email sent', [ - 'to' => array_map(static function (Address $address) { - return $address->getAddress(); - }, $message->getTo()), + 'to' => array_map(static fn(Address $address) => $address->getAddress(), $message->getTo()), 'subject' => $message->getSubject(), ]); diff --git a/src/Bundle/ChillMainBundle/Tests/Entity/NotificationTest.php b/src/Bundle/ChillMainBundle/Tests/Entity/NotificationTest.php index 9246cf1e6..051d04591 100644 --- a/src/Bundle/ChillMainBundle/Tests/Entity/NotificationTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Entity/NotificationTest.php @@ -134,9 +134,7 @@ final class NotificationTest extends KernelTestCase $this->assertEquals($senderId, $notification->getSender()->getId()); $this->assertCount(count($addressesIds), $notification->getUnreadBy()); - $unreadIds = $notification->getUnreadBy()->map(static function (User $u) { - return $u->getId(); - }); + $unreadIds = $notification->getUnreadBy()->map(static fn(User $u) => $u->getId()); foreach ($addressesIds as $addresseeId) { $this->assertContains($addresseeId, $unreadIds); diff --git a/src/Bundle/ChillMainBundle/Tests/Form/Type/ScopePickerTypeTest.php b/src/Bundle/ChillMainBundle/Tests/Form/Type/ScopePickerTypeTest.php index ce41c9a21..42f6d71d8 100644 --- a/src/Bundle/ChillMainBundle/Tests/Form/Type/ScopePickerTypeTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Form/Type/ScopePickerTypeTest.php @@ -96,9 +96,7 @@ final class ScopePickerTypeTest extends TypeTestCase $translatableStringHelper = $this->prophesize(TranslatableStringHelperInterface::class); $translatableStringHelper->localize(Argument::type('array'))->will( - static function ($args) { - return $args[0]['fr']; - } + static fn($args) => $args[0]['fr'] ); $type = new ScopePickerType( diff --git a/src/Bundle/ChillMainBundle/Tests/Search/Utils/ExtractDateFromPatternTest.php b/src/Bundle/ChillMainBundle/Tests/Search/Utils/ExtractDateFromPatternTest.php index 392e9a4ff..5f79494a3 100644 --- a/src/Bundle/ChillMainBundle/Tests/Search/Utils/ExtractDateFromPatternTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Search/Utils/ExtractDateFromPatternTest.php @@ -52,9 +52,7 @@ final class ExtractDateFromPatternTest extends TestCase $this->assertContainsOnlyInstancesOf(DateTimeImmutable::class, $result->getFound()); $dates = array_map( - static function (DateTimeImmutable $d) { - return $d->format('Y-m-d'); - }, + static fn(DateTimeImmutable $d) => $d->format('Y-m-d'), $result->getFound() ); diff --git a/src/Bundle/ChillMainBundle/Tests/Security/Authorization/AuthorizationHelperTest.php b/src/Bundle/ChillMainBundle/Tests/Security/Authorization/AuthorizationHelperTest.php index 8e3c27e99..657e37e36 100644 --- a/src/Bundle/ChillMainBundle/Tests/Security/Authorization/AuthorizationHelperTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Security/Authorization/AuthorizationHelperTest.php @@ -211,9 +211,7 @@ final class AuthorizationHelperTest extends KernelTestCase $centerA ); - $usernames = array_map(static function (User $u) { - return $u->getUsername(); - }, $users); + $usernames = array_map(static fn(User $u) => $u->getUsername(), $users); $this->assertContains('center a_social', $usernames); } diff --git a/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/EntityWorkflowTransitionEventSubscriber.php b/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/EntityWorkflowTransitionEventSubscriber.php index 192ca0712..dfe47ecc8 100644 --- a/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/EntityWorkflowTransitionEventSubscriber.php +++ b/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/EntityWorkflowTransitionEventSubscriber.php @@ -105,9 +105,7 @@ class EntityWorkflowTransitionEventSubscriber implements EventSubscriberInterfac [ '%users%' => implode( ', ', - $entityWorkflow->getCurrentStep()->getAllDestUser()->map(function (User $u) { - return $this->userRender->renderString($u, []); - })->toArray() + $entityWorkflow->getCurrentStep()->getAllDestUser()->map(fn(User $u) => $this->userRender->renderString($u, []))->toArray() ), ] )); diff --git a/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/NotificationOnTransition.php b/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/NotificationOnTransition.php index f02341ff7..dc9657e3c 100644 --- a/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/NotificationOnTransition.php +++ b/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/NotificationOnTransition.php @@ -109,9 +109,7 @@ class NotificationOnTransition implements EventSubscriberInterface 'dest' => $subscriber, 'place' => $place, 'workflow' => $workflow, - 'is_dest' => in_array($subscriber->getId(), array_map(static function (User $u) { - return $u->getId(); - }, $entityWorkflow->futureDestUsers), true), + 'is_dest' => in_array($subscriber->getId(), array_map(static fn(User $u) => $u->getId(), $entityWorkflow->futureDestUsers), true), ]; $notification = new Notification(); diff --git a/src/Bundle/ChillMainBundle/Workflow/Validator/EntityWorkflowCreationValidator.php b/src/Bundle/ChillMainBundle/Workflow/Validator/EntityWorkflowCreationValidator.php index 0c8d1c72f..6ab44f625 100644 --- a/src/Bundle/ChillMainBundle/Workflow/Validator/EntityWorkflowCreationValidator.php +++ b/src/Bundle/ChillMainBundle/Workflow/Validator/EntityWorkflowCreationValidator.php @@ -59,9 +59,7 @@ class EntityWorkflowCreationValidator extends \Symfony\Component\Validator\Const $workflows = $this->entityWorkflowManager->getSupportedWorkflows($value); - $matched = array_filter($workflows, static function (WorkflowInterface $workflow) use ($value) { - return $workflow->getName() === $value->getWorkflowName(); - }); + $matched = array_filter($workflows, static fn(WorkflowInterface $workflow) => $workflow->getName() === $value->getWorkflowName()); if (0 === count($matched)) { $this->context->buildViolation($constraint->messageWorkflowNotAvailable) diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php index 70ea1d3c5..d7289c68a 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php @@ -169,9 +169,7 @@ final class AccompanyingCourseApiController extends ApiController $accompanyingPeriods = $person->getCurrentAccompanyingPeriods(); $accompanyingPeriodsChecked = array_filter( $accompanyingPeriods, - function (AccompanyingPeriod $period) { - return $this->isGranted(AccompanyingPeriodVoter::SEE, $period); - } + fn(AccompanyingPeriod $period) => $this->isGranted(AccompanyingPeriodVoter::SEE, $period) ); return $this->json(array_values($accompanyingPeriodsChecked), Response::HTTP_OK, [], ['groups' => ['read']]); diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodController.php index e9e27f9c9..18098a129 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodController.php @@ -222,14 +222,10 @@ class AccompanyingPeriodController extends AbstractController $accompanyingPeriodsRaw = $this->accompanyingPeriodACLAwareRepository ->findByPerson($person, AccompanyingPeriodVoter::SEE); - usort($accompanyingPeriodsRaw, static function ($a, $b) { - return $b->getOpeningDate() > $a->getOpeningDate(); - }); + usort($accompanyingPeriodsRaw, static fn($a, $b) => $b->getOpeningDate() > $a->getOpeningDate()); // filter visible or not visible - $accompanyingPeriods = array_filter($accompanyingPeriodsRaw, function (AccompanyingPeriod $ap) { - return $this->isGranted(AccompanyingPeriodVoter::SEE, $ap); - }); + $accompanyingPeriods = array_filter($accompanyingPeriodsRaw, fn(AccompanyingPeriod $ap) => $this->isGranted(AccompanyingPeriodVoter::SEE, $ap)); return $this->render('@ChillPerson/AccompanyingPeriod/list.html.twig', [ 'accompanying_periods' => $accompanyingPeriods, @@ -331,9 +327,7 @@ class AccompanyingPeriodController extends AbstractController /** @var AccompanyingPeriod $period */ $period = array_filter( $person->getAccompanyingPeriods(), - static function (AccompanyingPeriod $p) use ($period_id) { - return $p->getId() === ($period_id); - } + static fn(AccompanyingPeriod $p) => $p->getId() === ($period_id) )[0] ?? null; if (null === $period) { diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodRegulationListController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodRegulationListController.php index a91b0f5ff..ced5ccd9d 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodRegulationListController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodRegulationListController.php @@ -105,12 +105,8 @@ class AccompanyingPeriodRegulationListController $builder ->add('services', EntityType::class, [ 'class' => Scope::class, - 'query_builder' => static function (EntityRepository $er) { - return $er->createQueryBuilder('s'); - }, - 'choice_label' => function (Scope $s) { - return $this->translatableStringHelper->localize($s->getName()); - }, + 'query_builder' => static fn(EntityRepository $er) => $er->createQueryBuilder('s'), + 'choice_label' => fn(Scope $s) => $this->translatableStringHelper->localize($s->getName()), 'multiple' => true, 'label' => 'Service', 'required' => false, @@ -123,9 +119,7 @@ class AccompanyingPeriodRegulationListController return $qb; }, - 'choice_label' => function (UserJob $j) { - return $this->translatableStringHelper->localize($j->getLabel()); - }, + 'choice_label' => fn(UserJob $j) => $this->translatableStringHelper->localize($j->getLabel()), 'multiple' => true, 'label' => 'Métier', 'required' => false, @@ -147,9 +141,7 @@ class AccompanyingPeriodRegulationListController return $qb; }, - 'choice_label' => static function (Location $l) { - return $l->getName(); - }, + 'choice_label' => static fn(Location $l) => $l->getName(), 'multiple' => true, 'group_by' => function (Location $l) { if (null === $type = $l->getLocationType()) { diff --git a/src/Bundle/ChillPersonBundle/Controller/HouseholdCompositionController.php b/src/Bundle/ChillPersonBundle/Controller/HouseholdCompositionController.php index 43d35934b..98fa0ebfe 100644 --- a/src/Bundle/ChillPersonBundle/Controller/HouseholdCompositionController.php +++ b/src/Bundle/ChillPersonBundle/Controller/HouseholdCompositionController.php @@ -164,9 +164,7 @@ class HouseholdCompositionController extends AbstractController $isEdit = $request->query->has('edit'); if ($isEdit) { - $householdCompositions = $household->getCompositions()->filter(static function (HouseholdComposition $composition) use ($request) { - return $composition->getId() === $request->query->getInt('edit'); - }); + $householdCompositions = $household->getCompositions()->filter(static fn(HouseholdComposition $composition) => $composition->getId() === $request->query->getInt('edit')); if ($householdCompositions->count() !== 1) { throw new BadRequestHttpException('could not find the composition with this id associated to the household'); diff --git a/src/Bundle/ChillPersonBundle/Controller/HouseholdController.php b/src/Bundle/ChillPersonBundle/Controller/HouseholdController.php index 7b9eb0084..68f32c886 100644 --- a/src/Bundle/ChillPersonBundle/Controller/HouseholdController.php +++ b/src/Bundle/ChillPersonBundle/Controller/HouseholdController.php @@ -81,9 +81,7 @@ class HouseholdController extends AbstractController } } - usort($accompanyingPeriods, static function ($a, $b) { - return $b->getOpeningDate() <=> $a->getOpeningDate(); - }); + usort($accompanyingPeriods, static fn($a, $b) => $b->getOpeningDate() <=> $a->getOpeningDate()); $oldMembers = $household->getNonCurrentMembers(); $accompanyingPeriodsOld = []; diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php b/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php index bf0d998ff..35256ce56 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php @@ -108,14 +108,10 @@ class PersonApiController extends ApiController $addresses = $person ->getAccompanyingPeriodParticipations() ->filter( - static function (AccompanyingPeriodParticipation $accompanyingPeriodParticipation): bool { - return null !== $accompanyingPeriodParticipation->getAccompanyingPeriod()->getAddressLocation(); - } + static fn(AccompanyingPeriodParticipation $accompanyingPeriodParticipation): bool => null !== $accompanyingPeriodParticipation->getAccompanyingPeriod()->getAddressLocation() ) ->map( - static function (AccompanyingPeriodParticipation $accompanyingPeriodParticipation): ?Address { - return $accompanyingPeriodParticipation->getAccompanyingPeriod()->getAddressLocation(); - } + static fn(AccompanyingPeriodParticipation $accompanyingPeriodParticipation): ?Address => $accompanyingPeriodParticipation->getAccompanyingPeriod()->getAddressLocation() ) ->filter( // We remove potential null addresses. diff --git a/src/Bundle/ChillPersonBundle/Controller/SocialWorkSocialActionApiController.php b/src/Bundle/ChillPersonBundle/Controller/SocialWorkSocialActionApiController.php index 3ae5c5b7c..75293fd7b 100644 --- a/src/Bundle/ChillPersonBundle/Controller/SocialWorkSocialActionApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/SocialWorkSocialActionApiController.php @@ -44,9 +44,7 @@ class SocialWorkSocialActionApiController extends ApiController $socialActions = $socialIssue->getRecursiveSocialActions()->toArray(); - usort($socialActions, static function (SocialAction $sa, SocialAction $sb) { - return $sa->getOrdering() <=> $sb->getOrdering(); - }); + usort($socialActions, static fn(SocialAction $sa, SocialAction $sb) => $sa->getOrdering() <=> $sb->getOrdering()); $pagination = $this->paginator->create(count($socialActions)); // max one page diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadCustomFields.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadCustomFields.php index 87746842a..fb5ae6e4e 100644 --- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadCustomFields.php +++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadCustomFields.php @@ -115,9 +115,7 @@ class LoadCustomFields extends AbstractFixture implements // get possible values for cfGroup $choices = array_map( - static function ($a) { - return $a['slug']; - }, + static fn($a) => $a['slug'], $this->customFieldChoice->getOptions()['choices'] ); // create faker diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php index 510e1c327..364cb41d5 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php @@ -828,9 +828,7 @@ class AccompanyingPeriod implements $collection = $this ->getParticipationsContainsPerson($person) ->filter( - static function (AccompanyingPeriodParticipation $participation): bool { - return null === $participation->getEndDate(); - } + static fn(AccompanyingPeriodParticipation $participation): bool => null === $participation->getEndDate() ); return $collection->count() > 0 ? $collection->first() : null; @@ -844,9 +842,7 @@ class AccompanyingPeriod implements return $this ->getParticipations() ->filter( - static function (AccompanyingPeriodParticipation $participation): bool { - return null === $participation->getEndDate(); - } + static fn(AccompanyingPeriodParticipation $participation): bool => null === $participation->getEndDate() ); } diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Comment.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Comment.php index 592c833d3..1652a45e9 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Comment.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Comment.php @@ -44,20 +44,20 @@ class Comment implements TrackCreationInterface, TrackUpdateInterface * @Assert\NotBlank * @Assert\NotNull */ - private ?string $content; + private ?string $content = null; /** * @ORM\Column(type="datetime") * @Groups({"read", "docgen:read"}) */ - private ?DateTimeInterface $createdAt; + private ?DateTimeInterface $createdAt = null; /** * @ORM\ManyToOne(targetEntity=User::class) * @ORM\JoinColumn(nullable=false) * @Groups({"read", "docgen:read"}) */ - private ?User $creator; + private ?User $creator = null; /** * @ORM\Id @@ -65,20 +65,20 @@ class Comment implements TrackCreationInterface, TrackUpdateInterface * @ORM\Column(type="integer") * @Groups({"read", "docgen:read"}) */ - private ?int $id; + private ?int $id = null; /** * @ORM\Column(type="datetime") * @Groups({"read"}) */ - private ?DateTimeInterface $updatedAt; + private ?DateTimeInterface $updatedAt = null; /** * @ORM\ManyToOne(targetEntity=User::class) * @ORM\JoinColumn(nullable=false) * @Groups({"read"}) */ - private ?User $updatedBy; + private ?User $updatedBy = null; public function getAccompanyingPeriod(): ?AccompanyingPeriod { diff --git a/src/Bundle/ChillPersonBundle/Entity/Household/Household.php b/src/Bundle/ChillPersonBundle/Entity/Household/Household.php index 48e1ac1fc..2fa1df203 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Household/Household.php +++ b/src/Bundle/ChillPersonBundle/Entity/Household/Household.php @@ -200,13 +200,11 @@ class Household */ public function getCurrentAddress(?DateTime $at = null): ?Address { - $at = $at ?? new DateTime('today'); + $at ??= new DateTime('today'); - $addrs = $this->getAddresses()->filter(static function (Address $a) use ($at) { - return $a->getValidFrom() <= $at && ( - null === $a->getValidTo() || $a->getValidTo() > $at - ); - }); + $addrs = $this->getAddresses()->filter(static fn(Address $a) => $a->getValidFrom() <= $at && ( + null === $a->getValidTo() || $a->getValidTo() > $at + )); if ($addrs->count() > 0) { return $addrs->first(); @@ -338,9 +336,7 @@ class Household public function getCurrentPersons(?DateTimeImmutable $now = null): ReadableCollection { return $this->getCurrentMembers($now) - ->map(static function (HouseholdMember $m) { - return $m->getPerson(); - }); + ->map(static fn(HouseholdMember $m) => $m->getPerson()); } public function getId(): ?int @@ -367,9 +363,7 @@ class Household $membership->getStartDate(), $membership->getEndDate() )->filter( - static function (HouseholdMember $m) use ($membership) { - return $m->getPerson() !== $membership->getPerson(); - } + static fn(HouseholdMember $m) => $m->getPerson() !== $membership->getPerson() ); } @@ -508,9 +502,7 @@ class Household usort( $compositionOrdered, - static function (HouseholdComposition $a, HouseholdComposition $b) { - return $a->getStartDate() <=> $b->getStartDate(); - } + static fn(HouseholdComposition $a, HouseholdComposition $b) => $a->getStartDate() <=> $b->getStartDate() ); $iterator = new ArrayIterator($compositionOrdered); diff --git a/src/Bundle/ChillPersonBundle/Entity/Household/HouseholdMember.php b/src/Bundle/ChillPersonBundle/Entity/Household/HouseholdMember.php index 031279173..fad3b213a 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Household/HouseholdMember.php +++ b/src/Bundle/ChillPersonBundle/Entity/Household/HouseholdMember.php @@ -142,7 +142,7 @@ class HouseholdMember public function isCurrent(?DateTimeImmutable $at = null): bool { - $at = $at ?? new DateTimeImmutable('now'); + $at ??= new DateTimeImmutable('now'); return $this->getStartDate() < $at && ( null === $this->getEndDate() || $this->getEndDate() > $at diff --git a/src/Bundle/ChillPersonBundle/Entity/Person.php b/src/Bundle/ChillPersonBundle/Entity/Person.php index 63bd6efba..1507bafd7 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person.php @@ -775,9 +775,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI ): int { // TODO should be optimized to avoid loading accompanying period ? return $this->getAccompanyingPeriodInvolved($asParticipantOpen, $asRequestor) - ->filter(function (AccompanyingPeriod $p) { - return $p->getStep() !== AccompanyingPeriod::STEP_DRAFT; - }) + ->filter(fn(AccompanyingPeriod $p) => $p->getStep() !== AccompanyingPeriod::STEP_DRAFT) ->count(); } @@ -1341,9 +1339,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI return $this->getAccompanyingPeriodParticipations() ->matching($criteria) - ->filter(static function (AccompanyingPeriodParticipation $app) { - return AccompanyingPeriod::STEP_CLOSED !== $app->getAccompanyingPeriod()->getStep(); - }); + ->filter(static fn(AccompanyingPeriodParticipation $app) => AccompanyingPeriod::STEP_CLOSED !== $app->getAccompanyingPeriod()->getStep()); } public function getOtherPhoneNumbers(): Collection diff --git a/src/Bundle/ChillPersonBundle/Entity/Person/PersonCurrentAddress.php b/src/Bundle/ChillPersonBundle/Entity/Person/PersonCurrentAddress.php index d95f4c7c8..52d6a34af 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person/PersonCurrentAddress.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person/PersonCurrentAddress.php @@ -50,7 +50,7 @@ class PersonCurrentAddress /** * @ORM\Column(name="valid_to", type="date_immutable") */ - protected ?DateTimeImmutable $validTo; + protected ?DateTimeImmutable $validTo = null; public function getAddress(): Address { diff --git a/src/Bundle/ChillPersonBundle/Entity/Person/PersonResource.php b/src/Bundle/ChillPersonBundle/Entity/Person/PersonResource.php index 576380476..a4b6cf085 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person/PersonResource.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person/PersonResource.php @@ -55,7 +55,7 @@ class PersonResource implements TrackCreationInterface, TrackUpdateInterface * @ORM\Column(type="integer") * @Groups({"read", "docgen:read"}) */ - private ?int $id; + private ?int $id = null; /** * @ORM\ManyToOne(targetEntity=PersonResourceKind::class, inversedBy="personResources") diff --git a/src/Bundle/ChillPersonBundle/Entity/PersonPhone.php b/src/Bundle/ChillPersonBundle/Entity/PersonPhone.php index 5013ac9b7..068260b45 100644 --- a/src/Bundle/ChillPersonBundle/Entity/PersonPhone.php +++ b/src/Bundle/ChillPersonBundle/Entity/PersonPhone.php @@ -41,7 +41,7 @@ class PersonPhone * @ORM\Column(name="id", type="integer") * @ORM\GeneratedValue(strategy="AUTO") */ - private ?int $id; + private ?int $id = null; /** * @ORM\ManyToOne( @@ -59,7 +59,7 @@ class PersonPhone /** * @ORM\Column(type="text", length=40, nullable=true) */ - private ?string $type; + private ?string $type = null; public function __construct() { diff --git a/src/Bundle/ChillPersonBundle/Entity/SocialWork/Result.php b/src/Bundle/ChillPersonBundle/Entity/SocialWork/Result.php index 823f31426..f65192a04 100644 --- a/src/Bundle/ChillPersonBundle/Entity/SocialWork/Result.php +++ b/src/Bundle/ChillPersonBundle/Entity/SocialWork/Result.php @@ -45,7 +45,7 @@ class Result /** * @ORM\Column(type="datetime", nullable=true) */ - private ?DateTime $desactivationDate; + private ?DateTime $desactivationDate = null; /** * @ORM\ManyToMany(targetEntity=Goal::class, mappedBy="results") diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php index 80781b823..c018eb95f 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php @@ -128,9 +128,7 @@ final class GeographicalUnitStatAggregator implements AggregatorInterface 'placeholder' => 'Select a geographical layer', 'class' => GeographicalUnitLayer::class, 'choices' => $this->geographicalUnitLayerRepository->findAllHavingUnits(), - 'choice_label' => function (GeographicalUnitLayer $item) { - return $this->translatableStringHelper->localize($item->getName()); - }, + 'choice_label' => fn(GeographicalUnitLayer $item) => $this->translatableStringHelper->localize($item->getName()), ]); } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/CountryOfBirthAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/CountryOfBirthAggregator.php index 395070a8a..c2923c9e9 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/CountryOfBirthAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/CountryOfBirthAggregator.php @@ -147,9 +147,7 @@ final class CountryOfBirthAggregator implements AggregatorInterface, ExportEleme ]; } - return static function (string $value) use ($labels): string { - return $labels[$value]; - }; + return static fn(string $value): string => $labels[$value]; } public function getQueryKeys($data) diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GeographicalUnitAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GeographicalUnitAggregator.php index 6193f3c61..1ab9f1b78 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GeographicalUnitAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GeographicalUnitAggregator.php @@ -100,9 +100,7 @@ class GeographicalUnitAggregator implements AggregatorInterface 'placeholder' => 'Select a geographical layer', 'class' => GeographicalUnitLayer::class, 'choices' => $this->geographicalUnitLayerRepository->findAllHavingUnits(), - 'choice_label' => function (GeographicalUnitLayer $item) { - return $this->translatableStringHelper->localize($item->getName()); - }, + 'choice_label' => fn(GeographicalUnitLayer $item) => $this->translatableStringHelper->localize($item->getName()), ]); } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/NationalityAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/NationalityAggregator.php index 1eced58d3..b91a90000 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/NationalityAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/NationalityAggregator.php @@ -141,9 +141,7 @@ final class NationalityAggregator implements AggregatorInterface, ExportElementV ]; } - return static function ($value) use ($labels): string { - return $labels[$value]; - }; + return static fn($value): string => $labels[$value]; } public function getQueryKeys($data) diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php b/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php index a9f794888..7cb2e623f 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php @@ -64,9 +64,7 @@ class CountAccompanyingCourse implements ExportInterface, GroupedExportInterface $labels = array_combine($values, $values); $labels['_header'] = $this->getTitle(); - return static function ($value) use ($labels) { - return $labels[$value]; - }; + return static fn($value) => $labels[$value]; } public function getQueryKeys($data): array @@ -91,9 +89,7 @@ class CountAccompanyingCourse implements ExportInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []): QueryBuilder { - $centers = array_map(static function ($el) { - return $el['center']; - }, $acl); + $centers = array_map(static fn($el) => $el['center'], $acl); $qb = $this->repository->createQueryBuilder('acp'); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingPeriodWork.php b/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingPeriodWork.php index 40253ea0b..412890241 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingPeriodWork.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingPeriodWork.php @@ -63,9 +63,7 @@ class CountAccompanyingPeriodWork implements ExportInterface, GroupedExportInter $labels = array_combine($values, $values); $labels['_header'] = $this->getTitle(); - return static function ($value) use ($labels) { - return $labels[$value]; - }; + return static fn($value) => $labels[$value]; } public function getQueryKeys($data): array @@ -90,9 +88,7 @@ class CountAccompanyingPeriodWork implements ExportInterface, GroupedExportInter public function initiateQuery(array $requiredModifiers, array $acl, array $data = []): QueryBuilder { - $centers = array_map(static function ($el) { - return $el['center']; - }, $acl); + $centers = array_map(static fn($el) => $el['center'], $acl); $qb = $this->em->createQueryBuilder(); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php b/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php index 578cc1452..4efd7e246 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php @@ -62,9 +62,7 @@ class CountEvaluation implements ExportInterface, GroupedExportInterface $labels = array_combine($values, $values); $labels['_header'] = $this->getTitle(); - return static function ($value) use ($labels) { - return $labels[$value]; - }; + return static fn($value) => $labels[$value]; } public function getQueryKeys($data): array @@ -89,9 +87,7 @@ class CountEvaluation implements ExportInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static function ($el) { - return $el['center']; - }, $acl); + $centers = array_map(static fn($el) => $el['center'], $acl); $qb = $this->entityManager->createQueryBuilder(); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php b/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php index f1eaeb4cb..2b782d1ed 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php @@ -113,9 +113,7 @@ class CountHousehold implements ExportInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static function ($el) { - return $el['center']; - }, $acl); + $centers = array_map(static fn($el) => $el['center'], $acl); $qb = $this->entityManager->createQueryBuilder(); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountPerson.php b/src/Bundle/ChillPersonBundle/Export/Export/CountPerson.php index 07a307563..528be42c8 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountPerson.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountPerson.php @@ -62,9 +62,7 @@ class CountPerson implements ExportInterface, GroupedExportInterface $labels = array_combine($values, $values); $labels['_header'] = $this->getTitle(); - return static function ($value) use ($labels) { - return $labels[$value]; - }; + return static fn($value) => $labels[$value]; } public function getQueryKeys($data) @@ -94,9 +92,7 @@ class CountPerson implements ExportInterface, GroupedExportInterface */ public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static function ($el) { - return $el['center']; - }, $acl); + $centers = array_map(static fn($el) => $el['center'], $acl); $qb = $this->personRepository->createQueryBuilder('person'); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountPersonWithAccompanyingCourse.php b/src/Bundle/ChillPersonBundle/Export/Export/CountPersonWithAccompanyingCourse.php index 7acbd09cf..e58439112 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountPersonWithAccompanyingCourse.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountPersonWithAccompanyingCourse.php @@ -64,9 +64,7 @@ class CountPersonWithAccompanyingCourse implements ExportInterface, GroupedExpor $labels = array_combine($values, $values); $labels['_header'] = $this->getTitle(); - return static function ($value) use ($labels) { - return $labels[$value]; - }; + return static fn($value) => $labels[$value]; } public function getQueryKeys($data): array @@ -91,9 +89,7 @@ class CountPersonWithAccompanyingCourse implements ExportInterface, GroupedExpor public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static function ($el) { - return $el['center']; - }, $acl); + $centers = array_map(static fn($el) => $el['center'], $acl); $qb = $this->repository->createQueryBuilder('acp'); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php index cacdf2ee1..1bfd1870f 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php @@ -290,9 +290,7 @@ class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static function ($el) { - return $el['center']; - }, $acl); + $centers = array_map(static fn($el) => $el['center'], $acl); $qb = $this->entityManager->createQueryBuilder(); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriodWork.php b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriodWork.php index d0c1863c3..17c2c4f99 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriodWork.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriodWork.php @@ -263,9 +263,7 @@ class ListAccompanyingPeriodWork implements ListInterface, GroupedExportInterfac public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static function ($el) { - return $el['center']; - }, $acl); + $centers = array_map(static fn($el) => $el['center'], $acl); $qb = $this->entityManager->createQueryBuilder(); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListEvaluation.php b/src/Bundle/ChillPersonBundle/Export/Export/ListEvaluation.php index 010618733..0f63d41ca 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListEvaluation.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListEvaluation.php @@ -241,9 +241,7 @@ class ListEvaluation implements ListInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static function ($el) { - return $el['center']; - }, $acl); + $centers = array_map(static fn($el) => $el['center'], $acl); $qb = $this->entityManager->createQueryBuilder(); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListHouseholdInPeriod.php b/src/Bundle/ChillPersonBundle/Export/Export/ListHouseholdInPeriod.php index fc72de77b..d176f7bb8 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListHouseholdInPeriod.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListHouseholdInPeriod.php @@ -146,9 +146,7 @@ class ListHouseholdInPeriod implements ListInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static function ($el) { - return $el['center']; - }, $acl); + $centers = array_map(static fn($el) => $el['center'], $acl); $qb = $this->entityManager->createQueryBuilder(); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php b/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php index 21675a86a..322917b02 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php @@ -191,9 +191,7 @@ class ListPerson implements ExportElementValidatedInterface, ListInterface, Grou */ public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static function ($el) { - return $el['center']; - }, $acl); + $centers = array_map(static fn($el) => $el['center'], $acl); // throw an error if any fields are present if (!array_key_exists('fields', $data)) { diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriod.php index bab67fb39..35bb8a6c1 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriod.php @@ -159,9 +159,7 @@ class ListPersonWithAccompanyingPeriod implements ExportElementValidatedInterfac */ public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static function ($el) { - return $el['center']; - }, $acl); + $centers = array_map(static fn($el) => $el['center'], $acl); // throw an error if any fields are present if (!array_key_exists('fields', $data)) { diff --git a/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php b/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php index c124f0227..0c2fb63f5 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php @@ -112,9 +112,7 @@ class StatAccompanyingCourseDuration implements ExportInterface, GroupedExportIn public function initiateQuery(array $requiredModifiers, array $acl, array $data = []): QueryBuilder { - $centers = array_map(static function ($el) { - return $el['center']; - }, $acl); + $centers = array_map(static fn($el) => $el['center'], $acl); $qb = $this->repository->createQueryBuilder('acp'); diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ClosingMotiveFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ClosingMotiveFilter.php index 07e61b42e..05c883309 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ClosingMotiveFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ClosingMotiveFilter.php @@ -59,9 +59,7 @@ class ClosingMotiveFilter implements FilterInterface { $builder->add('accepted_closingmotives', EntityType::class, [ 'class' => ClosingMotive::class, - 'choice_label' => function (ClosingMotive $cm) { - return $this->translatableStringHelper->localize($cm->getName()); - }, + 'choice_label' => fn(ClosingMotive $cm) => $this->translatableStringHelper->localize($cm->getName()), 'multiple' => true, 'expanded' => true, ]); diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorJobFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorJobFilter.php index 62cf49d6d..497068c39 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorJobFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorJobFilter.php @@ -61,11 +61,9 @@ class CreatorJobFilter implements FilterInterface $builder->add('creator_job', EntityType::class, [ 'class' => UserJob::class, 'choices' => $this->userJobRepository->findAllActive(), - 'choice_label' => function (UserJob $j) { - return $this->translatableStringHelper->localize( - $j->getLabel() - ); - }, + 'choice_label' => fn(UserJob $j) => $this->translatableStringHelper->localize( + $j->getLabel() + ), 'multiple' => true, 'expanded' => true, 'label' => 'Job', diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EvaluationFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EvaluationFilter.php index 1839268e1..7f409c022 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EvaluationFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EvaluationFilter.php @@ -69,9 +69,7 @@ class EvaluationFilter implements FilterInterface $builder->add('accepted_evaluations', EntityType::class, [ 'class' => Evaluation::class, 'choices' => $this->evaluationRepository->findAllActive(), - 'choice_label' => function (Evaluation $ev) { - return $this->translatableStringHelper->localize($ev->getTitle()); - }, + 'choice_label' => fn(Evaluation $ev) => $this->translatableStringHelper->localize($ev->getTitle()), 'multiple' => true, 'expanded' => false, 'attr' => ['class' => 'select2'], diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php index 5bbb22e53..719029d38 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php @@ -107,9 +107,7 @@ class GeographicalUnitStatFilter implements FilterInterface 'placeholder' => 'Select a geographical unit', 'choices' => $this->geographicalUnitRepository->findAll(), 'choice_value' => static fn (SimpleGeographicalUnitDTO $item) => $item->id, - 'choice_label' => function (SimpleGeographicalUnitDTO $item) { - return $this->translatableStringHelper->localize($this->geographicalUnitLayerRepository->find($item->layerId)->getName()) . ' > ' . $item->unitName; - }, + 'choice_label' => fn(SimpleGeographicalUnitDTO $item) => $this->translatableStringHelper->localize($this->geographicalUnitLayerRepository->find($item->layerId)->getName()) . ' > ' . $item->unitName, 'attr' => [ 'class' => 'select2', ], @@ -124,9 +122,7 @@ class GeographicalUnitStatFilter implements FilterInterface '%units' => implode( ', ', array_map( - function (SimpleGeographicalUnitDTO $item) { - return $this->translatableStringHelper->localize($this->geographicalUnitLayerRepository->find($item->layerId)->getName()) . ' > ' . $item->unitName; - }, + fn(SimpleGeographicalUnitDTO $item) => $this->translatableStringHelper->localize($this->geographicalUnitLayerRepository->find($item->layerId)->getName()) . ' > ' . $item->unitName, $data['units'] ) ), diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OriginFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OriginFilter.php index 445535734..bde641b2d 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OriginFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OriginFilter.php @@ -59,9 +59,7 @@ class OriginFilter implements FilterInterface { $builder->add('accepted_origins', EntityType::class, [ 'class' => Origin::class, - 'choice_label' => function (Origin $o) { - return $this->translatableStringHelper->localize($o->getLabel()); - }, + 'choice_label' => fn(Origin $o) => $this->translatableStringHelper->localize($o->getLabel()), 'multiple' => true, 'expanded' => true, ]); diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/EvaluationTypeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/EvaluationTypeFilter.php index 65e38f41e..15be1a52b 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/EvaluationTypeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/EvaluationTypeFilter.php @@ -59,9 +59,7 @@ final class EvaluationTypeFilter implements FilterInterface { $builder->add('accepted_evaluationtype', EntityType::class, [ 'class' => Evaluation::class, - 'choice_label' => function (Evaluation $ev): string { - return $this->translatableStringHelper->localize($ev->getTitle()); - }, + 'choice_label' => fn(Evaluation $ev): string => $this->translatableStringHelper->localize($ev->getTitle()), 'multiple' => true, 'expanded' => true, ]); diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/HouseholdFilters/CompositionFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/HouseholdFilters/CompositionFilter.php index 922702418..7eb00fc2b 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/HouseholdFilters/CompositionFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/HouseholdFilters/CompositionFilter.php @@ -78,11 +78,9 @@ class CompositionFilter implements FilterInterface $builder ->add('accepted_composition', EntityType::class, [ 'class' => HouseholdCompositionType::class, - 'choice_label' => function (HouseholdCompositionType $type) { - return $this->translatableStringHelper->localize( - $type->getLabel() - ); - }, + 'choice_label' => fn(HouseholdCompositionType $type) => $this->translatableStringHelper->localize( + $type->getLabel() + ), 'multiple' => true, 'expanded' => true, ]) diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AddressRefStatusFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AddressRefStatusFilter.php index 0fe1973e9..5ecdc1fda 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AddressRefStatusFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AddressRefStatusFilter.php @@ -81,9 +81,7 @@ class AddressRefStatusFilter implements \Chill\MainBundle\Export\FilterInterface ->add('ref_statuses', ChoiceType::class, [ 'label' => 'export.filter.person.by_address_ref_status.Status', 'choices' => [Address::ADDR_REFERENCE_STATUS_TO_REVIEW, Address::ADDR_REFERENCE_STATUS_REVIEWED, Address::ADDR_REFERENCE_STATUS_MATCH], - 'choice_label' => function (string $item) { - return 'export.filter.person.by_address_ref_status.'.$item; - }, + 'choice_label' => fn(string $item) => 'export.filter.person.by_address_ref_status.'.$item, 'multiple' => true, 'expanded' => true, 'data' => [Address::ADDR_REFERENCE_STATUS_TO_REVIEW] @@ -99,9 +97,7 @@ class AddressRefStatusFilter implements \Chill\MainBundle\Export\FilterInterface '%statuses%' => implode( ', ', array_map( - function (string $item) { - return 'export.filter.person.by_address_ref_status.'.$item; - }, + fn(string $item) => 'export.filter.person.by_address_ref_status.'.$item, $data['ref_statuses'] ?? RollingDate::T_TODAY ) ), diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GenderFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GenderFilter.php index 228749c34..92b8ad08b 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GenderFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GenderFilter.php @@ -67,9 +67,7 @@ class GenderFilter implements $qb->add('where', $where); $qb->setParameter('person_gender', array_filter( $data['accepted_genders'], - static function ($el) { - return 'null' !== $el; - } + static fn($el) => 'null' !== $el )); } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GeographicalUnitFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GeographicalUnitFilter.php index 9bdb3f2d4..15882b705 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GeographicalUnitFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GeographicalUnitFilter.php @@ -98,9 +98,7 @@ class GeographicalUnitFilter implements \Chill\MainBundle\Export\FilterInterface 'placeholder' => 'Select a geographical unit', 'choices' => $this->geographicalUnitRepository->findAll(), 'choice_value' => static fn (SimpleGeographicalUnitDTO $item) => $item->id, - 'choice_label' => function (SimpleGeographicalUnitDTO $item) { - return $this->translatableStringHelper->localize($this->geographicalUnitLayerRepository->find($item->layerId)->getName()) . ' > ' . $item->unitName; - }, + 'choice_label' => fn(SimpleGeographicalUnitDTO $item) => $this->translatableStringHelper->localize($this->geographicalUnitLayerRepository->find($item->layerId)->getName()) . ' > ' . $item->unitName, 'attr' => [ 'class' => 'select2', ], @@ -117,9 +115,7 @@ class GeographicalUnitFilter implements \Chill\MainBundle\Export\FilterInterface '%units%' => implode( ', ', array_map( - function (SimpleGeographicalUnitDTO $item) { - return $this->translatableStringHelper->localize($this->geographicalUnitLayerRepository->find($item->layerId)->getName()) . ' > ' . $item->unitName; - }, + fn(SimpleGeographicalUnitDTO $item) => $this->translatableStringHelper->localize($this->geographicalUnitLayerRepository->find($item->layerId)->getName()) . ' > ' . $item->unitName, $data['units'] ) ), diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/MaritalStatusFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/MaritalStatusFilter.php index aad98a394..62b6a34d7 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/MaritalStatusFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/MaritalStatusFilter.php @@ -49,11 +49,9 @@ class MaritalStatusFilter implements FilterInterface { $builder->add('maritalStatus', EntityType::class, [ 'class' => MaritalStatus::class, - 'choice_label' => function (MaritalStatus $ms) { - return $this->translatableStringHelper->localize( - $ms->getName() - ); - }, + 'choice_label' => fn(MaritalStatus $ms) => $this->translatableStringHelper->localize( + $ms->getName() + ), 'multiple' => true, 'expanded' => true, ]); diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/NationalityFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/NationalityFilter.php index 1156527cc..19e5f999c 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/NationalityFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/NationalityFilter.php @@ -72,9 +72,7 @@ class NationalityFilter implements { $countries = $data['nationalities']; - $names = array_map(function (Country $c) { - return $this->translatableStringHelper->localize($c->getName()); - }, [$countries]); + $names = array_map(fn(Country $c) => $this->translatableStringHelper->localize($c->getName()), [$countries]); return [ 'Filtered by nationality : %nationalities%', diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php index 90003c6bf..32dc2a2fb 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php @@ -100,9 +100,7 @@ class ResidentialAddressAtThirdpartyFilter implements FilterInterface $builder->add('thirdparty_cat', EntityType::class, [ 'class' => ThirdPartyCategory::class, 'label' => 'Category', - 'choice_label' => function (ThirdPartyCategory $tpc) { - return $this->translatableStringHelper->localize($tpc->getName()); - }, + 'choice_label' => fn(ThirdPartyCategory $tpc) => $this->translatableStringHelper->localize($tpc->getName()), 'multiple' => true, 'expanded' => true, ]); diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/JobFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/JobFilter.php index a69e1ac76..1c38a030e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/JobFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/JobFilter.php @@ -69,11 +69,9 @@ class JobFilter implements FilterInterface { $builder->add('job', EntityType::class, [ 'class' => UserJob::class, - 'choice_label' => function (UserJob $j) { - return $this->translatableStringHelper->localize( - $j->getLabel() - ); - }, + 'choice_label' => fn(UserJob $j) => $this->translatableStringHelper->localize( + $j->getLabel() + ), 'multiple' => true, 'expanded' => true, ]); diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ScopeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ScopeFilter.php index 8cb2f6421..5d8e20832 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ScopeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ScopeFilter.php @@ -69,11 +69,9 @@ class ScopeFilter implements FilterInterface { $builder->add('scope', EntityType::class, [ 'class' => Scope::class, - 'choice_label' => function (Scope $s) { - return $this->translatableStringHelper->localize( - $s->getName() - ); - }, + 'choice_label' => fn(Scope $s) => $this->translatableStringHelper->localize( + $s->getName() + ), 'multiple' => true, 'expanded' => true, ]); diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/SocialWorkTypeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/SocialWorkTypeFilter.php index 853d50744..11fd0ed9d 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/SocialWorkTypeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/SocialWorkTypeFilter.php @@ -136,7 +136,7 @@ class SocialWorkTypeFilter implements FilterInterface } return ['Filtered actions by type, goals and results: %selected%', [ - '%selected%' => implode(', ', array_merge($actionTypes, $goals, $results)), + '%selected%' => implode(', ', [...$actionTypes, ...$goals, ...$results]), ]]; } diff --git a/src/Bundle/ChillPersonBundle/Form/ChoiceLoader/PersonChoiceLoader.php b/src/Bundle/ChillPersonBundle/Form/ChoiceLoader/PersonChoiceLoader.php index 0e63fe580..fe9a3490f 100644 --- a/src/Bundle/ChillPersonBundle/Form/ChoiceLoader/PersonChoiceLoader.php +++ b/src/Bundle/ChillPersonBundle/Form/ChoiceLoader/PersonChoiceLoader.php @@ -55,9 +55,7 @@ class PersonChoiceLoader implements ChoiceLoaderInterface { return new \Symfony\Component\Form\ChoiceList\ArrayChoiceList( $this->lazyLoadedPersons, - static function (Person $p) use ($value) { - return call_user_func($value, $p); - } + static fn(Person $p) => call_user_func($value, $p) ); } diff --git a/src/Bundle/ChillPersonBundle/Form/HouseholdCompositionType.php b/src/Bundle/ChillPersonBundle/Form/HouseholdCompositionType.php index d6919cc5d..6e4877b63 100644 --- a/src/Bundle/ChillPersonBundle/Form/HouseholdCompositionType.php +++ b/src/Bundle/ChillPersonBundle/Form/HouseholdCompositionType.php @@ -40,9 +40,7 @@ class HouseholdCompositionType extends AbstractType ->add('householdCompositionType', EntityType::class, [ 'class' => \Chill\PersonBundle\Entity\Household\HouseholdCompositionType::class, 'choices' => $types, - 'choice_label' => function (\Chill\PersonBundle\Entity\Household\HouseholdCompositionType $type) { - return $this->translatableStringHelper->localize($type->getLabel()); - }, + 'choice_label' => fn(\Chill\PersonBundle\Entity\Household\HouseholdCompositionType $type) => $this->translatableStringHelper->localize($type->getLabel()), 'label' => 'household_composition.Household composition', ]) ->add('startDate', ChillDateType::class, [ diff --git a/src/Bundle/ChillPersonBundle/Form/PersonType.php b/src/Bundle/ChillPersonBundle/Form/PersonType.php index 42e62929d..4752fb628 100644 --- a/src/Bundle/ChillPersonBundle/Form/PersonType.php +++ b/src/Bundle/ChillPersonBundle/Form/PersonType.php @@ -118,12 +118,8 @@ class PersonType extends AbstractType ]); $builder->get('placeOfBirth')->addModelTransformer(new CallbackTransformer( - static function ($string) { - return strtoupper((string) $string); - }, - static function ($string) { - return strtoupper((string) $string); - } + static fn($string) => strtoupper((string) $string), + static fn($string) => strtoupper((string) $string) )); } @@ -167,9 +163,7 @@ class PersonType extends AbstractType 'allow_delete' => true, 'by_reference' => false, 'label' => false, - 'delete_empty' => static function (?PersonPhone $pp = null) { - return null === $pp || $pp->isEmpty(); - }, + 'delete_empty' => static fn(?PersonPhone $pp = null) => null === $pp || $pp->isEmpty(), 'error_bubbling' => false, 'empty_collection_explain' => 'No additional phone numbers', ]); diff --git a/src/Bundle/ChillPersonBundle/Form/SocialWork/GoalType.php b/src/Bundle/ChillPersonBundle/Form/SocialWork/GoalType.php index 6d07bf64f..7a6a7484d 100644 --- a/src/Bundle/ChillPersonBundle/Form/SocialWork/GoalType.php +++ b/src/Bundle/ChillPersonBundle/Form/SocialWork/GoalType.php @@ -46,9 +46,7 @@ class GoalType extends AbstractType 'class' => Result::class, 'required' => false, 'multiple' => true, - 'choice_label' => function (Result $r) { - return $this->translatableStringHelper->localize($r->getTitle()); - }, + 'choice_label' => fn(Result $r) => $this->translatableStringHelper->localize($r->getTitle()), 'attr' => ['class' => 'select2 '], ]) ->add('desactivationDate', ChillDateType::class, [ diff --git a/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialActionType.php b/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialActionType.php index 5a6095f7b..7f5b434dd 100644 --- a/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialActionType.php +++ b/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialActionType.php @@ -50,16 +50,12 @@ class SocialActionType extends AbstractType ->add('issue', EntityType::class, [ 'class' => SocialIssue::class, 'label' => 'socialAction.socialIssue', - 'choice_label' => function (SocialIssue $issue) { - return $this->translatableStringHelper->localize($issue->getTitle()); - }, + 'choice_label' => fn(SocialIssue $issue) => $this->translatableStringHelper->localize($issue->getTitle()), ]) ->add('parent', EntityType::class, [ 'class' => SocialAction::class, 'required' => false, - 'choice_label' => function (SocialAction $issue) { - return $this->translatableStringHelper->localize($issue->getTitle()); - }, + 'choice_label' => fn(SocialAction $issue) => $this->translatableStringHelper->localize($issue->getTitle()), ]) ->add('ordering', NumberType::class, [ 'required' => true, @@ -70,9 +66,7 @@ class SocialActionType extends AbstractType 'required' => false, 'multiple' => true, 'attr' => ['class' => 'select2'], - 'choice_label' => function (Result $r) { - return $this->translatableStringHelper->localize($r->getTitle()); - }, + 'choice_label' => fn(Result $r) => $this->translatableStringHelper->localize($r->getTitle()), ]) ->add('goals', EntityType::class, [ @@ -80,9 +74,7 @@ class SocialActionType extends AbstractType 'required' => false, 'multiple' => true, 'attr' => ['class' => 'select2'], - 'choice_label' => function (Goal $g) { - return $this->translatableStringHelper->localize($g->getTitle()); - }, + 'choice_label' => fn(Goal $g) => $this->translatableStringHelper->localize($g->getTitle()), ]) ->add('evaluations', EntityType::class, [ @@ -90,9 +82,7 @@ class SocialActionType extends AbstractType 'required' => false, 'multiple' => true, 'attr' => ['class' => 'select2'], - 'choice_label' => function (Evaluation $e) { - return $this->translatableStringHelper->localize($e->getTitle()); - }, + 'choice_label' => fn(Evaluation $e) => $this->translatableStringHelper->localize($e->getTitle()), ]) ->add('defaultNotificationDelay', DateIntervalType::class, [ diff --git a/src/Bundle/ChillPersonBundle/Form/Type/ClosingMotivePickerType.php b/src/Bundle/ChillPersonBundle/Form/Type/ClosingMotivePickerType.php index 2f96d4966..2b4613376 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/ClosingMotivePickerType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/ClosingMotivePickerType.php @@ -60,18 +60,14 @@ class ClosingMotivePickerType extends AbstractType 'class' => ClosingMotive::class, 'empty_data' => null, 'placeholder' => 'Choose a motive', - 'choice_label' => function (ClosingMotive $cm) { - return $this->entityRenderExtension->renderString($cm); - }, + 'choice_label' => fn(ClosingMotive $cm) => $this->entityRenderExtension->renderString($cm), 'only_leaf' => true, ]); $resolver ->setAllowedTypes('only_leaf', 'bool') - ->setNormalizer('choices', function (Options $options) { - return $this->repository - ->getActiveClosingMotive($options['only_leaf']); - }); + ->setNormalizer('choices', fn(Options $options) => $this->repository + ->getActiveClosingMotive($options['only_leaf'])); } /** diff --git a/src/Bundle/ChillPersonBundle/Form/Type/PickPersonType.php b/src/Bundle/ChillPersonBundle/Form/Type/PickPersonType.php index 501af5b9d..3c0a1d5af 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/PickPersonType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/PickPersonType.php @@ -113,15 +113,11 @@ class PickPersonType extends AbstractType // add the default options $resolver->setDefaults([ 'class' => Person::class, - 'choice_label' => static function (Person $p) { - return $p->getFirstname() . ' ' . $p->getLastname(); - }, + 'choice_label' => static fn(Person $p) => $p->getFirstname() . ' ' . $p->getLastname(), 'placeholder' => 'Pick a person', - 'choice_attr' => static function (Person $p) { - return [ - 'data-center' => $p->getCenter()->getId(), - ]; - }, + 'choice_attr' => static fn(Person $p) => [ + 'data-center' => $p->getCenter()->getId(), + ], 'attr' => ['class' => 'select2 '], 'choice_loader' => function (Options $options) { $centers = $this->filterCentersfom($options); @@ -139,9 +135,7 @@ class PickPersonType extends AbstractType protected function filterCentersfom(Options $options) { if (null === $options['role']) { - $centers = array_map(static function (GroupCenter $g) { - return $g->getCenter(); - }, $this->user->getGroupCenters()->toArray()); + $centers = array_map(static fn(GroupCenter $g) => $g->getCenter(), $this->user->getGroupCenters()->toArray()); } else { $centers = $this->authorizationHelper ->getReachableCenters($this->user, $options['role']->getRole()); @@ -164,9 +158,7 @@ class PickPersonType extends AbstractType if ( !in_array($c->getId(), array_map( - static function (Center $c) { - return $c->getId(); - }, + static fn(Center $c) => $c->getId(), $centers ), true) ) { diff --git a/src/Bundle/ChillPersonBundle/Form/Type/PickSocialActionType.php b/src/Bundle/ChillPersonBundle/Form/Type/PickSocialActionType.php index 7c0da43b1..695d3aa12 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/PickSocialActionType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/PickSocialActionType.php @@ -38,9 +38,7 @@ class PickSocialActionType extends AbstractType ->setDefaults([ 'class' => SocialAction::class, 'choices' => $this->actionRepository->findAllActive(), - 'choice_label' => function (SocialAction $sa) { - return $this->actionRender->renderString($sa, []); - }, + 'choice_label' => fn(SocialAction $sa) => $this->actionRender->renderString($sa, []), 'placeholder' => 'Pick a social action', 'required' => false, 'attr' => ['class' => 'select2'], diff --git a/src/Bundle/ChillPersonBundle/Form/Type/PickSocialIssueType.php b/src/Bundle/ChillPersonBundle/Form/Type/PickSocialIssueType.php index e79c17191..9c02a7905 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/PickSocialIssueType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/PickSocialIssueType.php @@ -38,9 +38,7 @@ class PickSocialIssueType extends AbstractType ->setDefaults([ 'class' => SocialIssue::class, 'choices' => $this->issueRepository->findAllActive(), - 'choice_label' => function (SocialIssue $si) { - return $this->issueRender->renderString($si, []); - }, + 'choice_label' => fn(SocialIssue $si) => $this->issueRender->renderString($si, []), 'placeholder' => 'Pick a social issue', 'required' => false, 'attr' => ['class' => 'select2'], diff --git a/src/Bundle/ChillPersonBundle/Privacy/PrivacyEventSubscriber.php b/src/Bundle/ChillPersonBundle/Privacy/PrivacyEventSubscriber.php index 0b67537cb..f83d6faf4 100644 --- a/src/Bundle/ChillPersonBundle/Privacy/PrivacyEventSubscriber.php +++ b/src/Bundle/ChillPersonBundle/Privacy/PrivacyEventSubscriber.php @@ -76,9 +76,7 @@ class PrivacyEventSubscriber implements EventSubscriberInterface $involved = $this->getInvolved(); $involved['period_id'] = $event->getPeriod()->getId(); $involved['persons'] = $event->getPeriod()->getPersons() - ->map(static function (Person $p) { - return $p->getId(); - }) + ->map(static fn(Person $p) => $p->getId()) ->toArray(); $this->logger->notice( @@ -102,9 +100,7 @@ class PrivacyEventSubscriber implements EventSubscriberInterface if ($event->hasPersons()) { $involved['persons'] = array_map( - static function (Person $p) { - return $p->getId(); - }, + static fn(Person $p) => $p->getId(), $event->getPersons() ); } diff --git a/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepository.php b/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepository.php index cc9e7b145..bbe6eed32 100644 --- a/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepository.php @@ -322,9 +322,7 @@ final class PersonACLAwareRepository implements PersonACLAwareRepositoryInterfac ), ] ), - array_map(static function (Center $c) { - return $c->getId(); - }, $authorizedCenters) + array_map(static fn(Center $c) => $c->getId(), $authorizedCenters) ); } } diff --git a/src/Bundle/ChillPersonBundle/Security/Authorization/HouseholdVoter.php b/src/Bundle/ChillPersonBundle/Security/Authorization/HouseholdVoter.php index 47a15db54..3e2308089 100644 --- a/src/Bundle/ChillPersonBundle/Security/Authorization/HouseholdVoter.php +++ b/src/Bundle/ChillPersonBundle/Security/Authorization/HouseholdVoter.php @@ -97,9 +97,7 @@ class HouseholdVoter extends Voter implements ProvideRoleHierarchyInterface, Chi private function checkAssociatedMembersRole(Household $household, string $attribute): bool { - foreach ($household->getCurrentMembers()->map(static function (HouseholdMember $member) { - return $member->getPerson(); - }) as $person) { + foreach ($household->getCurrentMembers()->map(static fn(HouseholdMember $member) => $member->getPerson()) as $person) { if ($this->security->isGranted($attribute, $person)) { return true; } diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodDocGenNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodDocGenNormalizer.php index 0e1c81592..bbd068fc9 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodDocGenNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodDocGenNormalizer.php @@ -150,12 +150,8 @@ class AccompanyingPeriodDocGenNormalizer implements ContextAwareNormalizerInterf $this->closingMotiveRender->renderString($period->getClosingMotive(), []) : '', 'ref' => $this->normalizer->normalize($period->getUser(), $format, $userContext), 'hasRef' => $period->getUser() !== null, - 'socialIssuesText' => implode(', ', array_map(function (SocialIssue $s) { - return $this->socialIssueRender->renderString($s, []); - }, $period->getSocialIssues()->toArray())), - 'scopesText' => implode(', ', array_map(function (Scope $s) { - return $this->translatableStringHelper->localize($s->getName()); - }, $scopes)), + 'socialIssuesText' => implode(', ', array_map(fn(SocialIssue $s) => $this->socialIssueRender->renderString($s, []), $period->getSocialIssues()->toArray())), + 'scopesText' => implode(', ', array_map(fn(Scope $s) => $this->translatableStringHelper->localize($s->getName()), $scopes)), 'hasRequestor' => $period->getRequestor() !== null, 'requestorKind' => $period->getRequestorKind(), 'hasLocation' => $period->getLocation() !== null, diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationNormalizer.php index 8cd917961..a6b13af4e 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationNormalizer.php @@ -48,9 +48,7 @@ class AccompanyingPeriodWorkEvaluationNormalizer implements ContextAwareNormaliz $initial = $this->normalizer->normalize($object, $format, array_merge( $context, [self::IGNORE_EVALUATION => spl_object_hash($object)], - [AbstractNormalizer::CIRCULAR_REFERENCE_HANDLER => static function ($object, $format, $context) { - return $object->getId(); - }] + [AbstractNormalizer::CIRCULAR_REFERENCE_HANDLER => static fn($object, $format, $context) => $object->getId()] )); // due to bug: https://api-platform.com/docs/core/serialization/#collection-relation diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonDocGenNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonDocGenNormalizer.php index 74ca55398..308fe3ba1 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonDocGenNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonDocGenNormalizer.php @@ -94,9 +94,7 @@ class PersonDocGenNormalizer implements // we simplify the list of attributes for the embedded persons AbstractNormalizer::GROUPS => ['docgen:read'], // when a person reference the same person... take care of circular references - AbstractNormalizer::CIRCULAR_REFERENCE_HANDLER => function ($object, $format, $context) { - return $this->normalizer->normalize(null, $format, $context); - }, + AbstractNormalizer::CIRCULAR_REFERENCE_HANDLER => fn($object, $format, $context) => $this->normalizer->normalize(null, $format, $context), ]); if (null === $person) { @@ -117,9 +115,7 @@ class PersonDocGenNormalizer implements 'altNames' => implode( ', ', array_map( - static function (PersonAltName $altName) { - return $altName->getLabel(); - }, + static fn(PersonAltName $altName) => $altName->getLabel(), $person->getAltNames()->toArray() ) ), diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php index a94ae3af9..29570e532 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php @@ -257,12 +257,10 @@ class PersonJsonNormalizer implements DenormalizerAwareInterface, NormalizerAwar { return $altNames ->map( - static function (PersonAltName $personAltName): array { - return [ - 'key' => $personAltName->getKey(), - 'label' => $personAltName->getLabel(), - ]; - } + static fn(PersonAltName $personAltName): array => [ + 'key' => $personAltName->getKey(), + 'label' => $personAltName->getLabel(), + ] ) ->toArray(); } diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialIssueNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialIssueNormalizer.php index 3f2e46b3f..1f8994644 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialIssueNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialIssueNormalizer.php @@ -37,9 +37,7 @@ class SocialIssueNormalizer implements ContextAwareNormalizerInterface, Normaliz 'type' => 'social_issue', 'id' => $socialIssue->getId(), 'parent_id' => $socialIssue->hasParent() ? $socialIssue->getParent()->getId() : null, - 'children_ids' => $socialIssue->getChildren()->map(static function (SocialIssue $si) { - return $si->getId(); - }), + 'children_ids' => $socialIssue->getChildren()->map(static fn(SocialIssue $si) => $si->getId()), 'title' => $socialIssue->getTitle(), 'text' => $this->render->renderString($socialIssue, []), ]; diff --git a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php index 4a08eff08..ed66593c4 100644 --- a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php +++ b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php @@ -143,14 +143,10 @@ class AccompanyingPeriodContext implements ->add('category', EntityType::class, [ 'placeholder' => 'Choose a document category', 'class' => DocumentCategory::class, - 'query_builder' => static function (EntityRepository $er) { - return $er->createQueryBuilder('c') - ->where('c.documentClass = :docClass') - ->setParameter('docClass', AccompanyingCourseDocument::class); - }, - 'choice_label' => function ($entity = null) { - return $entity ? $this->translatableStringHelper->localize($entity->getName()) : ''; - }, + 'query_builder' => static fn(EntityRepository $er) => $er->createQueryBuilder('c') + ->where('c.documentClass = :docClass') + ->setParameter('docClass', AccompanyingCourseDocument::class), + 'choice_label' => fn($entity = null) => $entity ? $this->translatableStringHelper->localize($entity->getName()) : '', ]); } @@ -160,9 +156,7 @@ class AccompanyingPeriodContext implements public function buildPublicForm(FormBuilderInterface $builder, DocGeneratorTemplate $template, mixed $entity): void { $options = $template->getOptions(); - $persons = new ArrayCollection($entity->getCurrentParticipations()->map(static function (AccompanyingPeriodParticipation $p) { - return $p->getPerson(); - })->toArray()); + $persons = new ArrayCollection($entity->getCurrentParticipations()->map(static fn(AccompanyingPeriodParticipation $p) => $p->getPerson())->toArray()); foreach ($entity->getCurrentParticipations() as $p) { foreach ($p->getPerson()->getResources() as $r) { @@ -187,9 +181,7 @@ class AccompanyingPeriodContext implements $builder->add($key, EntityType::class, [ 'class' => Person::class, 'choices' => $persons, - 'choice_label' => function (Person $p) { - return $this->personRender->renderString($p, ['addAge' => true]); - }, + 'choice_label' => fn(Person $p) => $this->personRender->renderString($p, ['addAge' => true]), 'multiple' => false, 'expanded' => true, 'required' => false, diff --git a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php index 4718b7b00..325e666b9 100644 --- a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php +++ b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php @@ -63,9 +63,7 @@ class AccompanyingPeriodWorkEvaluationContext implements $this->accompanyingPeriodWorkContext->adminFormReverseTransform($data), [ 'evaluations' => array_map( - static function (Evaluation $e) { - return $e->getId(); - }, + static fn(Evaluation $e) => $e->getId(), $data['evaluations'] ), ] @@ -78,9 +76,7 @@ class AccompanyingPeriodWorkEvaluationContext implements $this->accompanyingPeriodWorkContext->adminFormTransform($data), [ 'evaluations' => array_map( - function ($id) { - return $this->evaluationRepository->find($id); - }, + fn($id) => $this->evaluationRepository->find($id), $data['evaluations'] ?? [] ), ] @@ -97,9 +93,7 @@ class AccompanyingPeriodWorkEvaluationContext implements 'class' => Evaluation::class, 'label' => 'Linked evaluations', 'choices' => $this->evaluationRepository->findAll(), - 'choice_label' => function (Evaluation $e) { - return $this->translatableStringHelper->localize($e->getTitle()); - }, + 'choice_label' => fn(Evaluation $e) => $this->translatableStringHelper->localize($e->getTitle()), 'multiple' => true, 'attr' => ['class' => 'select2'], ]); diff --git a/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php b/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php index c7c7d2352..8a7b7e2ba 100644 --- a/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php +++ b/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php @@ -126,14 +126,10 @@ final class PersonContext implements PersonContextInterface ->add('category', EntityType::class, [ 'placeholder' => 'Choose a document category', 'class' => DocumentCategory::class, - 'query_builder' => static function (EntityRepository $er) { - return $er->createQueryBuilder('c') - ->where('c.documentClass = :docClass') - ->setParameter('docClass', PersonDocument::class); - }, - 'choice_label' => function ($entity = null) { - return $entity ? $this->translatableStringHelper->localize($entity->getName()) : ''; - }, + 'query_builder' => static fn(EntityRepository $er) => $er->createQueryBuilder('c') + ->where('c.documentClass = :docClass') + ->setParameter('docClass', PersonDocument::class), + 'choice_label' => fn($entity = null) => $entity ? $this->translatableStringHelper->localize($entity->getName()) : '', 'required' => true, ]); } diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseApiControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseApiControllerTest.php index 596e0a870..53d6a0a93 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseApiControllerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseApiControllerTest.php @@ -342,9 +342,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase // check that the person id is contained $participationsPersonsIds = array_map( - static function ($participation) { - return $participation->person->id; - }, + static fn($participation) => $participation->person->id, $data->participations ); diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdApiControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdApiControllerTest.php index 710c5fc6b..cb0587b5e 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdApiControllerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdApiControllerTest.php @@ -161,9 +161,7 @@ final class HouseholdApiControllerTest extends WebTestCase $this->assertArrayHasKey('count', $data); $this->assertArrayHasKey('results', $data); - $householdIds = array_map(static function ($r) { - return $r['id']; - }, $data['results']); + $householdIds = array_map(static fn($r) => $r['id'], $data['results']); $this->assertContains($expectedHouseholdId, $householdIds); } diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateTest.php index bb70866e2..cf8c134ad 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateTest.php @@ -294,49 +294,23 @@ final class PersonControllerUpdateTest extends WebTestCase public function validTextFieldsProvider() { return [ - ['firstName', 'random Value', static function (Person $person) { - return $person->getFirstName(); - }], - ['lastName', 'random Value', static function (Person $person) { - return $person->getLastName(); - }], + ['firstName', 'random Value', static fn(Person $person) => $person->getFirstName()], + ['lastName', 'random Value', static fn(Person $person) => $person->getLastName()], // reminder: this value is capitalized - ['placeOfBirth', 'A PLACE', static function (Person $person) { - return $person->getPlaceOfBirth(); - }], - ['birthdate', '1980-12-15', static function (Person $person) { - return $person->getBirthdate()->format('Y-m-d'); - }], + ['placeOfBirth', 'A PLACE', static fn(Person $person) => $person->getPlaceOfBirth()], + ['birthdate', '1980-12-15', static fn(Person $person) => $person->getBirthdate()->format('Y-m-d')], // TODO test on phonenumber update // ['phonenumber', '+32123456789', static function (Person $person) { return $person->getPhonenumber(); }], - ['memo', 'jfkdlmq jkfldmsq jkmfdsq', static function (Person $person) { - return $person->getMemo(); - }], - ['countryOfBirth', 'BE', static function (Person $person) { - return $person->getCountryOfBirth()->getCountryCode(); - }], - ['nationality', 'FR', static function (Person $person) { - return $person->getNationality()->getCountryCode(); - }], - ['placeOfBirth', '', static function (Person $person) { - return $person->getPlaceOfBirth(); - }], - ['birthdate', '', static function (Person $person) { - return $person->getBirthdate(); - }], + ['memo', 'jfkdlmq jkfldmsq jkmfdsq', static fn(Person $person) => $person->getMemo()], + ['countryOfBirth', 'BE', static fn(Person $person) => $person->getCountryOfBirth()->getCountryCode()], + ['nationality', 'FR', static fn(Person $person) => $person->getNationality()->getCountryCode()], + ['placeOfBirth', '', static fn(Person $person) => $person->getPlaceOfBirth()], + ['birthdate', '', static fn(Person $person) => $person->getBirthdate()], //['phonenumber', '', static function (Person $person) { return $person->getPhonenumber(); }], - ['memo', '', static function (Person $person) { - return $person->getMemo(); - }], - ['countryOfBirth', null, static function (Person $person) { - return $person->getCountryOfBirth(); - }], - ['nationality', null, static function (Person $person) { - return $person->getNationality(); - }], - ['gender', Person::FEMALE_GENDER, static function (Person $person) { - return $person->getGender(); - }], + ['memo', '', static fn(Person $person) => $person->getMemo()], + ['countryOfBirth', null, static fn(Person $person) => $person->getCountryOfBirth()], + ['nationality', null, static fn(Person $person) => $person->getNationality()], + ['gender', Person::FEMALE_GENDER, static fn(Person $person) => $person->getGender()], ]; } diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateWithHiddenFieldsTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateWithHiddenFieldsTest.php index 403f89dd4..d9cf2241a 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateWithHiddenFieldsTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateWithHiddenFieldsTest.php @@ -197,24 +197,12 @@ final class PersonControllerUpdateWithHiddenFieldsTest extends WebTestCase public function validTextFieldsProvider() { return [ - ['firstName', 'random Value', static function (Person $person) { - return $person->getFirstName(); - }], - ['lastName', 'random Value', static function (Person $person) { - return $person->getLastName(); - }], - ['birthdate', '15-12-1980', static function (Person $person) { - return $person->getBirthdate()->format('d-m-Y'); - }], - ['memo', 'jfkdlmq jkfldmsq jkmfdsq', static function (Person $person) { - return $person->getMemo(); - }], - ['birthdate', '', static function (Person $person) { - return $person->getBirthdate(); - }], - ['gender', Person::FEMALE_GENDER, static function (Person $person) { - return $person->getGender(); - }], + ['firstName', 'random Value', static fn(Person $person) => $person->getFirstName()], + ['lastName', 'random Value', static fn(Person $person) => $person->getLastName()], + ['birthdate', '15-12-1980', static fn(Person $person) => $person->getBirthdate()->format('d-m-Y')], + ['memo', 'jfkdlmq jkfldmsq jkmfdsq', static fn(Person $person) => $person->getMemo()], + ['birthdate', '', static fn(Person $person) => $person->getBirthdate()], + ['gender', Person::FEMALE_GENDER, static fn(Person $person) => $person->getGender()], ]; } diff --git a/src/Bundle/ChillPersonBundle/Tests/Entity/AccompanyingPeriodTest.php b/src/Bundle/ChillPersonBundle/Tests/Entity/AccompanyingPeriodTest.php index 2f38da244..5ce35317e 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Entity/AccompanyingPeriodTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Entity/AccompanyingPeriodTest.php @@ -152,9 +152,7 @@ final class AccompanyingPeriodTest extends \PHPUnit\Framework\TestCase $locations = $period->getLocationHistories()->toArray(); - usort($locations, static function (AccompanyingPeriod\AccompanyingPeriodLocationHistory $a, AccompanyingPeriod\AccompanyingPeriodLocationHistory $b) { - return $a->getStartDate() <=> $b->getStartDate(); - }); + usort($locations, static fn(AccompanyingPeriod\AccompanyingPeriodLocationHistory $a, AccompanyingPeriod\AccompanyingPeriodLocationHistory $b) => $a->getStartDate() <=> $b->getStartDate()); $iterator = new ArrayIterator($locations); $iterator->rewind(); diff --git a/src/Bundle/ChillPersonBundle/Tests/Household/MembersEditorTest.php b/src/Bundle/ChillPersonBundle/Tests/Household/MembersEditorTest.php index a58560bdd..55169757f 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Household/MembersEditorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Household/MembersEditorTest.php @@ -101,19 +101,13 @@ final class MembersEditorTest extends TestCase $editor = $factory->createEditor($household2 = new Household()); $editor->addMovement(new DateTimeImmutable('yesterday'), $person, $positionNotSharing); - $sharings = $household->getCurrentMembers()->filter(static function (HouseholdMember $m) { - return $m->getShareHousehold(); - }); - $notSharing = $household2->getCurrentMembers()->filter(static function (HouseholdMember $m) { - return !$m->getShareHousehold(); - }); + $sharings = $household->getCurrentMembers()->filter(static fn(HouseholdMember $m) => $m->getShareHousehold()); + $notSharing = $household2->getCurrentMembers()->filter(static fn(HouseholdMember $m) => !$m->getShareHousehold()); $this->assertCount(1, $notSharing); $this->assertCount(1, $sharings); - $getPerson = static function (HouseholdMember $m) { - return $m->getPerson(); - }; + $getPerson = static fn(HouseholdMember $m) => $m->getPerson(); $this->assertContains($person, $notSharing->map($getPerson)); } @@ -143,19 +137,13 @@ final class MembersEditorTest extends TestCase $editor = $factory->createEditor($household); $editor->addMovement(new DateTimeImmutable('yesterday'), $person, $positionNotSharing); - $sharings = $household->getCurrentMembers()->filter(static function (HouseholdMember $m) { - return $m->getShareHousehold(); - }); - $notSharing = $household->getCurrentMembers()->filter(static function (HouseholdMember $m) { - return !$m->getShareHousehold(); - }); + $sharings = $household->getCurrentMembers()->filter(static fn(HouseholdMember $m) => $m->getShareHousehold()); + $notSharing = $household->getCurrentMembers()->filter(static fn(HouseholdMember $m) => !$m->getShareHousehold()); $this->assertCount(1, $notSharing); $this->assertCount(0, $sharings); - $getPerson = static function (HouseholdMember $m) { - return $m->getPerson(); - }; + $getPerson = static fn(HouseholdMember $m) => $m->getPerson(); $this->assertContains($person, $notSharing->map($getPerson)); } diff --git a/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/PersonDocGenNormalizerTest.php b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/PersonDocGenNormalizerTest.php index e85813d62..6057a29c9 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/PersonDocGenNormalizerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/PersonDocGenNormalizerTest.php @@ -318,9 +318,7 @@ final class PersonDocGenNormalizerTest extends KernelTestCase $normalizerManager = $this->prophesize(NormalizerInterface::class); $normalizerManager->supportsNormalization(Argument::any(), 'docgen', Argument::any())->willReturn(true); $normalizerManager->normalize(Argument::type(Person::class), 'docgen', Argument::any()) - ->will(static function ($args) use ($normalizer) { - return $normalizer->normalize($args[0], $args[1], $args[2]); - }); + ->will(static fn($args) => $normalizer->normalize($args[0], $args[1], $args[2])); $normalizerManager->normalize(Argument::any(), 'docgen', Argument::any())->will( static function ($args) { if (is_iterable($args[0])) { diff --git a/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/RelationshipDocGenNormalizerTest.php b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/RelationshipDocGenNormalizerTest.php index 05d2eace1..6d841436e 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/RelationshipDocGenNormalizerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/RelationshipDocGenNormalizerTest.php @@ -118,9 +118,7 @@ final class RelationshipDocGenNormalizerTest extends TestCase { $translatableStringHelper = $this->prophesize(TranslatableStringHelperInterface::class); $translatableStringHelper->localize(Argument::type('array'))->will( - static function ($args) { - return $args[0][array_keys($args[0])[0]]; - } + static fn($args) => $args[0][array_keys($args[0])[0]] ); $normalizer = new RelationshipDocGenNormalizer( @@ -130,9 +128,7 @@ final class RelationshipDocGenNormalizerTest extends TestCase $normalizerManager = $this->prophesize(NormalizerInterface::class); $normalizerManager->supportsNormalization(Argument::any(), 'docgen', Argument::any())->willReturn(true); $normalizerManager->normalize(Argument::type(Relationship::class), 'docgen', Argument::any()) - ->will(static function ($args) use ($normalizer) { - return $normalizer->normalize($args[0], $args[1], $args[2]); - }); + ->will(static fn($args) => $normalizer->normalize($args[0], $args[1], $args[2])); $normalizerManager->normalize(Argument::any(), 'docgen', Argument::any())->will( static function ($args) { if (null === $args[0]) { diff --git a/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextTest.php b/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextTest.php index 17c6195b3..e84b27813 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextTest.php @@ -263,9 +263,7 @@ final class PersonContextTest extends TestCase if (null === $translatableStringHelper) { $translatableStringHelper = $this->prophesize(TranslatableStringHelperInterface::class); // return only the 'fr' key - $translatableStringHelper->localize(Argument::type('array'))->will(static function ($args) { - return $args[0]['fr']; - }); + $translatableStringHelper->localize(Argument::type('array'))->will(static fn($args) => $args[0]['fr']); $translatableStringHelper = $translatableStringHelper->reveal(); } diff --git a/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextWithThirdPartyTest.php b/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextWithThirdPartyTest.php index a4f08e7c1..753a9f855 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextWithThirdPartyTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextWithThirdPartyTest.php @@ -70,9 +70,7 @@ final class PersonContextWithThirdPartyTest extends KernelTestCase { $normalizer = $this->prophesize(NormalizerInterface::class); $normalizer->normalize(Argument::type(ThirdParty::class), 'docgen', Argument::type('array')) - ->will(static function ($args): array { - return ['class' => '3party', 'hash' => spl_object_hash($args[0])]; - }); + ->will(static fn($args): array => ['class' => '3party', 'hash' => spl_object_hash($args[0])]); $personContext = $this->prophesize(PersonContextInterface::class); diff --git a/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/AccompanyingPeriodValidityValidator.php b/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/AccompanyingPeriodValidityValidator.php index 9454d31d0..cae4829f7 100644 --- a/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/AccompanyingPeriodValidityValidator.php +++ b/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/AccompanyingPeriodValidityValidator.php @@ -74,9 +74,7 @@ class AccompanyingPeriodValidityValidator extends ConstraintValidator $periodIssuesWithAncestors = array_merge( $periodIssuesWithAncestors, array_map( - static function (SocialIssue $si) { - return spl_object_hash($si); - }, + static fn(SocialIssue $si) => spl_object_hash($si), $si->getAncestors(true) ) ); diff --git a/src/Bundle/ChillReportBundle/Export/Export/ReportList.php b/src/Bundle/ChillReportBundle/Export/Export/ReportList.php index 16ae19daa..d957f37e3 100644 --- a/src/Bundle/ChillReportBundle/Export/Export/ReportList.php +++ b/src/Bundle/ChillReportBundle/Export/Export/ReportList.php @@ -306,7 +306,7 @@ class ReportList implements ExportElementValidatedInterface, ListInterface } // add the key from slugs and return - return array_merge($fields, array_keys($this->slugs)); + return [...$fields, ...array_keys($this->slugs)]; } public function getResult($query, $data) @@ -331,9 +331,7 @@ class ReportList implements ExportElementValidatedInterface, ListInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static function ($el) { - return $el['center']; - }, $acl); + $centers = array_map(static fn($el) => $el['center'], $acl); // throw an error if any fields are present if (!array_key_exists('fields', $data)) { @@ -505,9 +503,7 @@ class ReportList implements ExportElementValidatedInterface, ListInterface private function getCustomFields() { return array_filter($this->customfieldsGroup - ->getCustomFields()->toArray(), static function (CustomField $cf) { - return $cf->getType() !== 'title'; - }); + ->getCustomFields()->toArray(), static fn(CustomField $cf) => $cf->getType() !== 'title'); } private function getLabelForCustomField($key, array $values, $data) diff --git a/src/Bundle/ChillReportBundle/Search/ReportSearch.php b/src/Bundle/ChillReportBundle/Search/ReportSearch.php index e392c37f5..e0aaa89e1 100644 --- a/src/Bundle/ChillReportBundle/Search/ReportSearch.php +++ b/src/Bundle/ChillReportBundle/Search/ReportSearch.php @@ -97,9 +97,7 @@ class ReportSearch extends AbstractSearch implements ContainerAwareInterface foreach ($reachableCenters as $center) { $reachableScopesId = array_map( - static function (Scope $scope) { - return $scope->getId(); - }, + static fn(Scope $scope) => $scope->getId(), $this->helper->getReachableScopes($this->user, $role, $center) ); $whereElement->add( diff --git a/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerNextTest.php b/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerNextTest.php index d299860bc..803ecf38f 100644 --- a/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerNextTest.php +++ b/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerNextTest.php @@ -68,9 +68,7 @@ final class ReportControllerNextTest extends WebTestCase //filter customFieldsGroup to get only "situation de logement" $filteredCustomFieldsGroupHouse = array_filter( $customFieldsGroups, - static function (CustomFieldsGroup $group) { - return in_array('Situation de logement', $group->getName(), true); - } + static fn(CustomFieldsGroup $group) => in_array('Situation de logement', $group->getName(), true) ); $this->group = $filteredCustomFieldsGroupHouse[0]; } diff --git a/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerTest.php b/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerTest.php index 1afe851b8..cd3b0f185 100644 --- a/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerTest.php +++ b/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerTest.php @@ -86,9 +86,7 @@ final class ReportControllerTest extends WebTestCase //filter customFieldsGroup to get only "situation de logement" $filteredCustomFieldsGroupHouse = array_filter( $customFieldsGroups, - static function (CustomFieldsGroup $group) { - return in_array('Situation de logement', $group->getName(), true); - } + static fn(CustomFieldsGroup $group) => in_array('Situation de logement', $group->getName(), true) ); self::$group = $filteredCustomFieldsGroupHouse[0]; diff --git a/src/Bundle/ChillReportBundle/Tests/Timeline/TimelineProviderTest.php b/src/Bundle/ChillReportBundle/Tests/Timeline/TimelineProviderTest.php index ecaabb495..253616a84 100644 --- a/src/Bundle/ChillReportBundle/Tests/Timeline/TimelineProviderTest.php +++ b/src/Bundle/ChillReportBundle/Tests/Timeline/TimelineProviderTest.php @@ -67,9 +67,7 @@ final class TimelineProviderTest extends WebTestCase self::$em ->getRepository(\Chill\MainBundle\Entity\Scope::class) ->findAll(), - static function (Scope $scope) { - return $scope->getName()['en'] === 'social'; - } + static fn(Scope $scope) => $scope->getName()['en'] === 'social' ); $report = (new Report()) diff --git a/src/Bundle/ChillReportBundle/Timeline/TimelineReportProvider.php b/src/Bundle/ChillReportBundle/Timeline/TimelineReportProvider.php index 900920a7f..0e28fffa9 100644 --- a/src/Bundle/ChillReportBundle/Timeline/TimelineReportProvider.php +++ b/src/Bundle/ChillReportBundle/Timeline/TimelineReportProvider.php @@ -267,7 +267,7 @@ class TimelineReportProvider implements TimelineProviderInterface '{scopes_ids}' => implode(', ', array_fill(0, count($scopeIds), '?')), ]); // append $scopeIds to parameters - $parameters = array_merge($parameters, $scopeIds); + $parameters = [...$parameters, ...$scopeIds]; } if (0 === count($formattedClauses)) { diff --git a/src/Bundle/ChillTaskBundle/Controller/TaskController.php b/src/Bundle/ChillTaskBundle/Controller/TaskController.php index 6525d5572..2c052619b 100644 --- a/src/Bundle/ChillTaskBundle/Controller/TaskController.php +++ b/src/Bundle/ChillTaskBundle/Controller/TaskController.php @@ -94,9 +94,7 @@ class TaskController extends AbstractController $transitionInstance = array_values( // array_values needed to reset keys (array_filter preserves keys) array_filter( $workflow->getEnabledTransitions($task), - static function (Transition $t) use ($transition) { - return $t->getName() === $transition; - } + static fn(Transition $t) => $t->getName() === $transition ) )[0]; diff --git a/src/Bundle/ChillTaskBundle/Form/SingleTaskListType.php b/src/Bundle/ChillTaskBundle/Form/SingleTaskListType.php index 4020eeef3..ec336856e 100644 --- a/src/Bundle/ChillTaskBundle/Form/SingleTaskListType.php +++ b/src/Bundle/ChillTaskBundle/Form/SingleTaskListType.php @@ -218,13 +218,9 @@ class SingleTaskListType extends AbstractType $users = $this->getUsersAssigneedToTask($options); $choices = array_combine( // get usernames - array_map(static function (User $user) { - return $user->getUsername(); - }, $users), + array_map(static fn(User $user) => $user->getUsername(), $users), // get ids - array_map(static function (User $user) { - return $user->getId(); - }, $users) + array_map(static fn(User $user) => $user->getId(), $users) ); $choices['Unassigned'] = '_unassigned'; diff --git a/src/Bundle/ChillTaskBundle/Tests/Controller/SingleTaskControllerTest.php b/src/Bundle/ChillTaskBundle/Tests/Controller/SingleTaskControllerTest.php index c51eb9ed4..50c360610 100644 --- a/src/Bundle/ChillTaskBundle/Tests/Controller/SingleTaskControllerTest.php +++ b/src/Bundle/ChillTaskBundle/Tests/Controller/SingleTaskControllerTest.php @@ -92,9 +92,7 @@ final class SingleTaskControllerTest extends WebTestCase $center = array_filter( $centers, - static function (Center $c) use ($centerName) { - return $c->getName() === $centerName; - } + static fn(Center $c) => $c->getName() === $centerName )[0]; $ids = $em diff --git a/src/Bundle/ChillTaskBundle/Timeline/SingleTaskTaskLifeCycleEventTimelineProvider.php b/src/Bundle/ChillTaskBundle/Timeline/SingleTaskTaskLifeCycleEventTimelineProvider.php index b29c1818e..c07fd707e 100644 --- a/src/Bundle/ChillTaskBundle/Timeline/SingleTaskTaskLifeCycleEventTimelineProvider.php +++ b/src/Bundle/ChillTaskBundle/Timeline/SingleTaskTaskLifeCycleEventTimelineProvider.php @@ -86,9 +86,7 @@ class SingleTaskTaskLifeCycleEventTimelineProvider implements TimelineProviderIn ->findBy(['id' => $ids]); return array_combine( - array_map(static function ($e) { - return $e->getId(); - }, $events), + array_map(static fn($e) => $e->getId(), $events), $events ); } diff --git a/src/Bundle/ChillTaskBundle/Timeline/TaskLifeCycleEventTimelineProvider.php b/src/Bundle/ChillTaskBundle/Timeline/TaskLifeCycleEventTimelineProvider.php index 4d8ddd062..e6f98cef9 100644 --- a/src/Bundle/ChillTaskBundle/Timeline/TaskLifeCycleEventTimelineProvider.php +++ b/src/Bundle/ChillTaskBundle/Timeline/TaskLifeCycleEventTimelineProvider.php @@ -97,9 +97,7 @@ class TaskLifeCycleEventTimelineProvider implements TimelineProviderInterface ->findBy(['id' => $ids]); return array_combine( - array_map(static function ($e) { - return $e->getId(); - }, $events), + array_map(static fn($e) => $e->getId(), $events), $events ); } diff --git a/src/Bundle/ChillThirdPartyBundle/DataFixtures/ORM/LoadThirdParty.php b/src/Bundle/ChillThirdPartyBundle/DataFixtures/ORM/LoadThirdParty.php index 6b40f01b9..8250f7bf0 100644 --- a/src/Bundle/ChillThirdPartyBundle/DataFixtures/ORM/LoadThirdParty.php +++ b/src/Bundle/ChillThirdPartyBundle/DataFixtures/ORM/LoadThirdParty.php @@ -69,9 +69,7 @@ class LoadThirdParty extends Fixture implements DependentFixtureInterface private function getCenters(): Iterator { $references = array_map( - static function ($a) { - return $a['ref']; - }, + static fn($a) => $a['ref'], LoadCenters::$centers ); $number = random_int(1, count($references)); diff --git a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php index ca24d2442..09b8ba516 100644 --- a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php +++ b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php @@ -189,7 +189,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User") * @ORM\JoinColumn(name="created_by", referencedColumnName="id") */ - private ?User $createdBy; + private ?User $createdBy = null; /** * @ORM\Column(name="email", type="string", length=255, nullable=true) @@ -272,13 +272,13 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface /** * @ORM\Column(name="updated_at", type="datetime_immutable", nullable=true) */ - private ?DateTimeImmutable $updatedAt; + private ?DateTimeImmutable $updatedAt = null; /** * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User") * @ORM\JoinColumn(name="updated_by", referencedColumnName="id") */ - private ?User $updatedBy; + private ?User $updatedBy = null; /** * ThirdParty constructor. diff --git a/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdPartyType.php b/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdPartyType.php index ed4b3c1e7..01309a37e 100644 --- a/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdPartyType.php +++ b/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdPartyType.php @@ -103,15 +103,11 @@ class PickThirdPartyType extends AbstractType $resolver ->setDefault('class', ThirdParty::class) - ->setDefault('choice_label', static function (ThirdParty $tp) { - return $tp->getName(); - }) - ->setDefault('choice_loader', function (Options $options) { - return new ThirdPartyChoiceLoader( - $options['center'], - $this->em->getRepository(ThirdParty::class) - ); - }); + ->setDefault('choice_label', static fn(ThirdParty $tp) => $tp->getName()) + ->setDefault('choice_loader', fn(Options $options) => new ThirdPartyChoiceLoader( + $options['center'], + $this->em->getRepository(ThirdParty::class) + )); } public function getParent(): string diff --git a/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdPartyTypeCategoryType.php b/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdPartyTypeCategoryType.php index eb7966084..6bc83f0f2 100644 --- a/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdPartyTypeCategoryType.php +++ b/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdPartyTypeCategoryType.php @@ -77,9 +77,7 @@ class PickThirdPartyTypeCategoryType extends \Symfony\Component\Form\AbstractTyp return self::PREFIX_TYPE . $item; }, - 'choice_value' => function ($item) { - return $this->reverseTransform($item); - }, + 'choice_value' => fn($item) => $this->reverseTransform($item), ]); } From a9db133a7be4e581e3e049941ea8c92ce0f56014 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sat, 15 Apr 2023 00:33:31 +0200 Subject: [PATCH 016/724] DX: fix typing in SearchProvider --- .../_static/code/exports/CountPerson.php | 4 +- .../Form/AdvancedSearchType.php | 44 ------------------- .../Search/HasAdvancedSearchFormInterface.php | 2 + .../ChillMainBundle/Search/SearchProvider.php | 10 ++--- .../ChillPersonBundle/Search/PersonSearch.php | 2 +- 5 files changed, 7 insertions(+), 55 deletions(-) delete mode 100644 src/Bundle/ChillMainBundle/Form/AdvancedSearchType.php diff --git a/docs/source/_static/code/exports/CountPerson.php b/docs/source/_static/code/exports/CountPerson.php index 48eab8a55..afe19c73b 100644 --- a/docs/source/_static/code/exports/CountPerson.php +++ b/docs/source/_static/code/exports/CountPerson.php @@ -90,9 +90,7 @@ class CountPerson implements ExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { // we gather all center the user choose. - $centers = array_map(static function ($el) { - return $el['center']; - }, $acl); + $centers = array_map(static fn($el) => $el['center'], $acl); $qb = $this->entityManager->createQueryBuilder(); diff --git a/src/Bundle/ChillMainBundle/Form/AdvancedSearchType.php b/src/Bundle/ChillMainBundle/Form/AdvancedSearchType.php deleted file mode 100644 index 9157e8023..000000000 --- a/src/Bundle/ChillMainBundle/Form/AdvancedSearchType.php +++ /dev/null @@ -1,44 +0,0 @@ -searchProvider = $searchProvider; - } - - public function buildForm(FormBuilderInterface $builder, array $options) - { - $this->searchProvider - ->getHasAdvancedFormByName($options['search_service']) - ->createSearchForm($builder); - } - - public function configureOptions(OptionsResolver $resolver) - { - $resolver - ->setRequired('search_service') - ->setAllowedTypes('search_service', ['string']); - } -} diff --git a/src/Bundle/ChillMainBundle/Search/HasAdvancedSearchFormInterface.php b/src/Bundle/ChillMainBundle/Search/HasAdvancedSearchFormInterface.php index e5f103cdf..7aaf31bb3 100644 --- a/src/Bundle/ChillMainBundle/Search/HasAdvancedSearchFormInterface.php +++ b/src/Bundle/ChillMainBundle/Search/HasAdvancedSearchFormInterface.php @@ -20,4 +20,6 @@ interface HasAdvancedSearchFormInterface extends SearchInterface public function convertFormDataToQuery(array $data); public function convertTermsToFormData(array $terms); + + public function getAdvancedSearchTitle(): string; } diff --git a/src/Bundle/ChillMainBundle/Search/SearchProvider.php b/src/Bundle/ChillMainBundle/Search/SearchProvider.php index a629a45d2..a6b17133f 100644 --- a/src/Bundle/ChillMainBundle/Search/SearchProvider.php +++ b/src/Bundle/ChillMainBundle/Search/SearchProvider.php @@ -33,7 +33,7 @@ use function count; class SearchProvider { /** - * @var HasAdvancedSearchForm[] + * @var HasAdvancedSearchFormInterface[] */ private $hasAdvancedFormSearchServices = []; @@ -101,13 +101,9 @@ class SearchProvider * return searchservice with an advanced form, defined in service * definition. * - * @param string $name - * * @throws UnknowSearchNameException - * - * @return HasAdvancedSearchForm */ - public function getHasAdvancedFormByName($name) + public function getHasAdvancedFormByName(string $name): HasAdvancedSearchFormInterface { if (array_key_exists($name, $this->hasAdvancedFormSearchServices)) { return $this->hasAdvancedFormSearchServices[$name]; @@ -119,7 +115,7 @@ class SearchProvider public function getHasAdvancedFormSearchServices() { //sort the array - uasort($this->hasAdvancedFormSearchServices, static function (SearchInterface $a, SearchInterface $b) { + uasort($this->hasAdvancedFormSearchServices, static function (HasAdvancedSearchFormInterface $a, HasAdvancedSearchFormInterface $b): int { return $a->getOrder() <=> $b->getOrder(); }); diff --git a/src/Bundle/ChillPersonBundle/Search/PersonSearch.php b/src/Bundle/ChillPersonBundle/Search/PersonSearch.php index 7cd1849a3..dabc79475 100644 --- a/src/Bundle/ChillPersonBundle/Search/PersonSearch.php +++ b/src/Bundle/ChillPersonBundle/Search/PersonSearch.php @@ -173,7 +173,7 @@ class PersonSearch extends AbstractSearch implements HasAdvancedSearchFormInterf return $data; } - public function getAdvancedSearchTitle() + public function getAdvancedSearchTitle(): string { return 'Search within persons'; } From 746ed4f5e5b2f4f3830c91718edb232e672a85d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sat, 15 Apr 2023 00:43:55 +0200 Subject: [PATCH 017/724] DX: fix cs --- .../DependencyInjection/Configuration.php | 2 +- .../LinkedToACP/AvgActivityDuration.php | 2 +- .../LinkedToACP/AvgActivityVisitDuration.php | 2 +- .../Export/LinkedToACP/CountActivity.php | 2 +- .../Export/LinkedToACP/ListActivity.php | 2 +- .../LinkedToACP/SumActivityDuration.php | 2 +- .../LinkedToACP/SumActivityVisitDuration.php | 2 +- .../Export/LinkedToPerson/ListActivity.php | 4 +-- .../Filter/ACPFilters/ActivityTypeFilter.php | 2 +- .../Filter/ACPFilters/UserScopeFilter.php | 2 +- .../Export/Filter/ActivityTypeFilter.php | 2 +- .../ChillActivityBundle/Form/ActivityType.php | 6 ++--- .../Form/ActivityTypeType.php | 2 +- .../Form/Type/PickActivityReasonType.php | 2 +- ...TranslatableActivityReasonCategoryType.php | 2 +- .../Form/Type/TranslatableActivityType.php | 2 +- .../Repository/ActivityACLAwareRepository.php | 2 +- .../Service/DocGenerator/ActivityContext.php | 2 +- ...tActivitiesByAccompanyingPeriodContext.php | 4 +-- .../Controller/ActivityControllerTest.php | 4 +-- .../Tests/Form/ActivityTypeTest.php | 2 +- .../Type/TranslatableActivityReasonTest.php | 2 +- .../src/DependencyInjection/Configuration.php | 2 +- .../src/Export/Export/CountAsideActivity.php | 2 +- .../ChillBudgetBundle/Form/ChargeType.php | 2 +- .../ChillBudgetBundle/Form/ResourceType.php | 2 +- .../Service/Summary/SummaryBudget.php | 6 ++--- .../Service/Summary/SummaryBudgetTest.php | 6 ++--- .../ChillCalendarBundle/Entity/Calendar.php | 4 +-- .../Export/Export/CountCalendars.php | 4 +-- .../Export/Export/StatCalendarAvgDuration.php | 2 +- .../Export/Export/StatCalendarSumDuration.php | 2 +- .../Export/Filter/AgentFilter.php | 2 +- .../Export/Filter/JobFilter.php | 2 +- .../Export/Filter/ScopeFilter.php | 2 +- .../Handler/CalendarToRemoteHandler.php | 4 +-- .../Messenger/Message/CalendarMessage.php | 2 +- .../MSGraph/RemoteEventConverter.php | 4 +-- .../MSGraphRemoteCalendarConnector.php | 8 +++--- .../Tests/Form/CalendarTypeTest.php | 14 +++++----- .../MSGraph/AddressConverterTest.php | 2 +- .../CalendarForShortMessageProviderTest.php | 8 +++--- .../CustomFields/CustomFieldLongChoice.php | 2 +- .../OptionRepository.php | 2 +- .../Form/CustomFieldType.php | 2 +- .../JsonCustomFieldToArrayTransformer.php | 2 +- .../Form/DocGeneratorTemplateType.php | 4 +-- .../Form/AccompanyingCourseDocumentType.php | 4 +-- .../Form/PersonDocumentType.php | 4 +-- ...ompanyingCourseDocumentWorkflowHandler.php | 2 +- .../Controller/ParticipationController.php | 6 ++--- src/Bundle/ChillEventBundle/Entity/Event.php | 2 +- .../Form/ChoiceLoader/EventChoiceLoader.php | 2 +- src/Bundle/ChillEventBundle/Form/RoleType.php | 2 +- .../Form/Type/PickEventType.php | 8 +++--- .../Form/Type/PickEventTypeType.php | 6 ++--- .../Form/Type/PickRoleType.php | 6 ++--- .../Form/Type/PickStatusType.php | 6 ++--- .../ParticipationControllerTest.php | 8 +++--- .../Timeline/TimelineEventProvider.php | 2 +- .../CRUD/Routing/CRUDRoutesLoader.php | 2 +- .../Controller/NotificationController.php | 2 +- .../Controller/PermissionsGroupController.php | 8 +++--- .../Controller/UserController.php | 5 ++-- .../Controller/WorkflowController.php | 2 +- .../CompilerPass/MenuCompilerPass.php | 2 +- .../ChillMainBundle/Doctrine/DQL/Greatest.php | 2 +- .../ChillMainBundle/Doctrine/DQL/Least.php | 2 +- .../Entity/PermissionsGroup.php | 2 +- .../Entity/Workflow/EntityWorkflowStep.php | 2 +- .../Export/Formatter/CSVListFormatter.php | 2 +- .../Formatter/CSVPivotedListFormatter.php | 2 +- .../Export/Helper/ExportAddressHelper.php | 2 +- .../ChoiceLoader/PostalCodeChoiceLoader.php | 2 +- .../DataMapper/ExportPickCenterDataMapper.php | 2 +- .../IdToEntityDataTransformer.php | 2 +- .../ChillMainBundle/Form/LocationFormType.php | 4 +-- .../Form/Type/ComposedGroupCenterType.php | 4 +-- .../Form/Type/ComposedRoleScopeType.php | 4 +-- .../EntityToJsonTransformer.php | 2 +- .../Form/Type/Export/PickCenterType.php | 4 +-- .../Form/Type/PickCenterType.php | 2 +- .../Form/Type/PickCivilityType.php | 4 +-- .../Form/Type/PickLocationTypeType.php | 2 +- .../Form/Type/PickUserLocationType.php | 2 +- .../Form/Type/PostalCodeType.php | 2 +- .../Form/Type/ScopePickerType.php | 4 +-- .../Form/Type/UserPickerType.php | 2 +- src/Bundle/ChillMainBundle/Form/UserType.php | 6 ++--- .../ChillMainBundle/Form/WorkflowStepType.php | 6 ++--- .../ChillMainBundle/Search/SearchProvider.php | 2 +- .../AddressReferenceBEFromBestAddress.php | 2 +- .../Import/PostalCodeBEFromBestAddress.php | 2 +- .../Service/Mailer/ChillMailer.php | 2 +- .../Tests/Entity/NotificationTest.php | 2 +- .../Tests/Form/Type/ScopePickerTypeTest.php | 2 +- .../Utils/ExtractDateFromPatternTest.php | 2 +- .../Authorization/AuthorizationHelperTest.php | 2 +- ...ntityWorkflowTransitionEventSubscriber.php | 2 +- .../NotificationOnTransition.php | 2 +- .../EntityWorkflowCreationValidator.php | 2 +- .../AccompanyingCourseApiController.php | 2 +- .../AccompanyingPeriodController.php | 6 ++--- ...mpanyingPeriodRegulationListController.php | 8 +++--- .../HouseholdCompositionController.php | 2 +- .../Controller/HouseholdController.php | 2 +- .../Controller/PersonApiController.php | 4 +-- .../SocialWorkSocialActionApiController.php | 2 +- .../DataFixtures/ORM/LoadCustomFields.php | 2 +- .../Entity/AccompanyingPeriod.php | 4 +-- .../Entity/Household/Household.php | 8 +++--- .../ChillPersonBundle/Entity/Person.php | 4 +-- .../GeographicalUnitStatAggregator.php | 2 +- .../CountryOfBirthAggregator.php | 2 +- .../GeographicalUnitAggregator.php | 2 +- .../NationalityAggregator.php | 2 +- .../Export/Export/CountAccompanyingCourse.php | 4 +-- .../Export/CountAccompanyingPeriodWork.php | 4 +-- .../Export/Export/CountEvaluation.php | 4 +-- .../Export/Export/CountHousehold.php | 2 +- .../Export/Export/CountPerson.php | 4 +-- .../CountPersonWithAccompanyingCourse.php | 4 +-- .../Export/Export/ListAccompanyingPeriod.php | 2 +- .../Export/ListAccompanyingPeriodWork.php | 2 +- .../Export/Export/ListEvaluation.php | 2 +- .../Export/Export/ListHouseholdInPeriod.php | 2 +- .../Export/Export/ListPerson.php | 2 +- .../ListPersonWithAccompanyingPeriod.php | 2 +- .../Export/StatAccompanyingCourseDuration.php | 2 +- .../ClosingMotiveFilter.php | 2 +- .../CreatorJobFilter.php | 2 +- .../EvaluationFilter.php | 2 +- .../GeographicalUnitStatFilter.php | 4 +-- .../OriginFilter.php | 2 +- .../EvaluationTypeFilter.php | 2 +- .../HouseholdFilters/CompositionFilter.php | 2 +- .../PersonFilters/AddressRefStatusFilter.php | 4 +-- .../Filter/PersonFilters/GenderFilter.php | 2 +- .../PersonFilters/GeographicalUnitFilter.php | 4 +-- .../PersonFilters/MaritalStatusFilter.php | 2 +- .../PersonFilters/NationalityFilter.php | 2 +- .../ResidentialAddressAtThirdpartyFilter.php | 2 +- .../Filter/SocialWorkFilters/JobFilter.php | 2 +- .../Filter/SocialWorkFilters/ScopeFilter.php | 2 +- .../Form/ChoiceLoader/PersonChoiceLoader.php | 2 +- .../Form/HouseholdCompositionType.php | 2 +- .../ChillPersonBundle/Form/PersonType.php | 6 ++--- .../Form/SocialWork/GoalType.php | 2 +- .../Form/SocialWork/SocialActionType.php | 10 +++---- .../Form/Type/ClosingMotivePickerType.php | 4 +-- .../Form/Type/PickPersonType.php | 8 +++--- .../Form/Type/PickSocialActionType.php | 2 +- .../Form/Type/PickSocialIssueType.php | 2 +- .../Privacy/PrivacyEventSubscriber.php | 4 +-- .../Repository/PersonACLAwareRepository.php | 2 +- .../Security/Authorization/HouseholdVoter.php | 2 +- .../AccompanyingPeriodDocGenNormalizer.php | 4 +-- ...mpanyingPeriodWorkEvaluationNormalizer.php | 2 +- .../Normalizer/PersonDocGenNormalizer.php | 4 +-- .../Normalizer/PersonJsonNormalizer.php | 2 +- .../Normalizer/SocialIssueNormalizer.php | 2 +- .../AccompanyingPeriodContext.php | 8 +++--- ...ccompanyingPeriodWorkEvaluationContext.php | 6 ++--- .../Service/DocGenerator/PersonContext.php | 4 +-- .../AccompanyingCourseApiControllerTest.php | 2 +- .../Controller/HouseholdApiControllerTest.php | 2 +- .../Controller/PersonControllerUpdateTest.php | 26 +++++++++---------- ...onControllerUpdateWithHiddenFieldsTest.php | 12 ++++----- .../Tests/Entity/AccompanyingPeriodTest.php | 2 +- .../Tests/Household/MembersEditorTest.php | 12 ++++----- .../Normalizer/PersonDocGenNormalizerTest.php | 2 +- .../RelationshipDocGenNormalizerTest.php | 4 +-- .../DocGenerator/PersonContextTest.php | 2 +- .../PersonContextWithThirdPartyTest.php | 2 +- .../AccompanyingPeriodValidityValidator.php | 2 +- .../Export/Export/ReportList.php | 4 +-- .../ChillReportBundle/Search/ReportSearch.php | 2 +- .../Controller/ReportControllerNextTest.php | 2 +- .../Tests/Controller/ReportControllerTest.php | 2 +- .../Tests/Timeline/TimelineProviderTest.php | 2 +- .../Controller/TaskController.php | 2 +- .../Form/SingleTaskListType.php | 4 +-- .../Controller/SingleTaskControllerTest.php | 2 +- ...TaskTaskLifeCycleEventTimelineProvider.php | 2 +- .../TaskLifeCycleEventTimelineProvider.php | 2 +- .../DataFixtures/ORM/LoadThirdParty.php | 2 +- .../Form/Type/PickThirdPartyType.php | 4 +-- .../Type/PickThirdPartyTypeCategoryType.php | 2 +- 188 files changed, 309 insertions(+), 308 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/DependencyInjection/Configuration.php b/src/Bundle/ChillActivityBundle/DependencyInjection/Configuration.php index 35388464b..57a1ec578 100644 --- a/src/Bundle/ChillActivityBundle/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillActivityBundle/DependencyInjection/Configuration.php @@ -59,7 +59,7 @@ class Configuration implements ConfigurationInterface ->info('The number of seconds of this duration. Must be an integer.') ->cannotBeEmpty() ->validate() - ->ifTrue(static fn($data) => !is_int($data))->thenInvalid('The value %s is not a valid integer') + ->ifTrue(static fn ($data) => !is_int($data))->thenInvalid('The value %s is not a valid integer') ->end() ->end() ->scalarNode('label') diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php index 0de7f420c..34771d077 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php @@ -86,7 +86,7 @@ class AvgActivityDuration implements ExportInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static fn($el) => $el['center'], $acl); + $centers = array_map(static fn ($el) => $el['center'], $acl); $qb = $this->repository->createQueryBuilder('activity'); diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php index d9382d857..df21362cd 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php @@ -87,7 +87,7 @@ class AvgActivityVisitDuration implements ExportInterface, GroupedExportInterfac public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static fn($el) => $el['center'], $acl); + $centers = array_map(static fn ($el) => $el['center'], $acl); $qb = $this->repository->createQueryBuilder('activity'); diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php index fe6de3e24..6b7b1562d 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php @@ -86,7 +86,7 @@ class CountActivity implements ExportInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static fn($el) => $el['center'], $acl); + $centers = array_map(static fn ($el) => $el['center'], $acl); $qb = $this->repository ->createQueryBuilder('activity') diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php index 616f4d848..026e16f90 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php @@ -109,7 +109,7 @@ class ListActivity implements ListInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static fn($el) => $el['center'], $acl); + $centers = array_map(static fn ($el) => $el['center'], $acl); $qb = $this->entityManager->createQueryBuilder(); diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php index d4aa65f22..e916cab54 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php @@ -87,7 +87,7 @@ class SumActivityDuration implements ExportInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static fn($el) => $el['center'], $acl); + $centers = array_map(static fn ($el) => $el['center'], $acl); $qb = $this->repository ->createQueryBuilder('activity') diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php index 859c3e6b5..18a47289c 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php @@ -87,7 +87,7 @@ class SumActivityVisitDuration implements ExportInterface, GroupedExportInterfac public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static fn($el) => $el['center'], $acl); + $centers = array_map(static fn ($el) => $el['center'], $acl); $qb = $this->repository ->createQueryBuilder('activity') diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php index d9b1eb212..60110c9a8 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php @@ -137,7 +137,7 @@ class ListActivity implements ListInterface, GroupedExportInterface $activity = $activityRepository->find($value); - return implode(', ', array_map(fn(ActivityReason $r) => '"' . + return implode(', ', array_map(fn (ActivityReason $r) => '"' . $this->translatableStringHelper->localize($r->getCategory()->getName()) . ' > ' . $this->translatableStringHelper->localize($r->getName()) @@ -195,7 +195,7 @@ class ListActivity implements ListInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static fn($el) => $el['center'], $acl); + $centers = array_map(static fn ($el) => $el['center'], $acl); // throw an error if any fields are present if (!array_key_exists('fields', $data)) { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php index 346eab316..c6616a4c6 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php @@ -61,7 +61,7 @@ class ActivityTypeFilter implements FilterInterface $builder->add('accepted_activitytypes', EntityType::class, [ 'class' => ActivityType::class, 'choices' => $this->activityTypeRepository->findAllActive(), - 'choice_label' => fn(ActivityType $aty) => ($aty->hasCategory() ? $this->translatableStringHelper->localize($aty->getCategory()->getName()) . ' > ' : '') + 'choice_label' => fn (ActivityType $aty) => ($aty->hasCategory() ? $this->translatableStringHelper->localize($aty->getCategory()->getName()) . ' > ' : '') . $this->translatableStringHelper->localize($aty->getName()), 'multiple' => true, diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserScopeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserScopeFilter.php index 4254137ba..4319c100a 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserScopeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserScopeFilter.php @@ -64,7 +64,7 @@ class UserScopeFilter implements FilterInterface { $builder->add('accepted_userscope', EntityType::class, [ 'class' => Scope::class, - 'choice_label' => fn(Scope $s) => $this->translatableStringHelper->localize( + 'choice_label' => fn (Scope $s) => $this->translatableStringHelper->localize( $s->getName() ), 'multiple' => true, diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php index 725223fdd..b9d39c3ce 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php @@ -61,7 +61,7 @@ class ActivityTypeFilter implements ExportElementValidatedInterface, FilterInter $builder->add('types', EntityType::class, [ 'choices' => $this->activityTypeRepository->findAllActive(), 'class' => ActivityType::class, - 'choice_label' => fn(ActivityType $aty) => ($aty->hasCategory() ? $this->translatableStringHelper->localize($aty->getCategory()->getName()) . ' > ' : '') + 'choice_label' => fn (ActivityType $aty) => ($aty->hasCategory() ? $this->translatableStringHelper->localize($aty->getCategory()->getName()) . ' > ' : '') . $this->translatableStringHelper->localize($aty->getName()), 'group_by' => function (ActivityType $type) { diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityType.php b/src/Bundle/ChillActivityBundle/Form/ActivityType.php index dad4c3137..a74178afd 100644 --- a/src/Bundle/ChillActivityBundle/Form/ActivityType.php +++ b/src/Bundle/ChillActivityBundle/Form/ActivityType.php @@ -211,8 +211,8 @@ class ActivityType extends AbstractType 'required' => $activityType->isRequired('attendee'), 'expanded' => true, 'class' => ActivityPresence::class, - 'choice_label' => fn(ActivityPresence $activityPresence) => $this->translatableStringHelper->localize($activityPresence->getName()), - 'query_builder' => static fn(EntityRepository $er) => $er->createQueryBuilder('a') + 'choice_label' => fn (ActivityPresence $activityPresence) => $this->translatableStringHelper->localize($activityPresence->getName()), + 'query_builder' => static fn (EntityRepository $er) => $er->createQueryBuilder('a') ->where('a.active = true'), ]); } @@ -353,7 +353,7 @@ class ActivityType extends AbstractType return (string) $location->getId(); }, - fn(?string $id): ?Location => $this->om->getRepository(Location::class)->findOneBy(['id' => (int) $id]) + fn (?string $id): ?Location => $this->om->getRepository(Location::class)->findOneBy(['id' => (int) $id]) )); } diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php b/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php index 42353cda7..073b8099f 100644 --- a/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php +++ b/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php @@ -45,7 +45,7 @@ class ActivityTypeType extends AbstractType ]) ->add('category', EntityType::class, [ 'class' => ActivityTypeCategory::class, - 'choice_label' => fn(ActivityTypeCategory $activityTypeCategory) => $this->translatableStringHelper->localize($activityTypeCategory->getName()), + 'choice_label' => fn (ActivityTypeCategory $activityTypeCategory) => $this->translatableStringHelper->localize($activityTypeCategory->getName()), ]) ->add('ordering', NumberType::class, [ 'required' => true, diff --git a/src/Bundle/ChillActivityBundle/Form/Type/PickActivityReasonType.php b/src/Bundle/ChillActivityBundle/Form/Type/PickActivityReasonType.php index 0b63de112..35da7e02f 100644 --- a/src/Bundle/ChillActivityBundle/Form/Type/PickActivityReasonType.php +++ b/src/Bundle/ChillActivityBundle/Form/Type/PickActivityReasonType.php @@ -45,7 +45,7 @@ class PickActivityReasonType extends AbstractType $resolver->setDefaults( [ 'class' => ActivityReason::class, - 'choice_label' => fn(ActivityReason $choice) => $this->reasonRender->renderString($choice, []), + 'choice_label' => fn (ActivityReason $choice) => $this->reasonRender->renderString($choice, []), 'group_by' => function (ActivityReason $choice): ?string { if (null !== $category = $choice->getCategory()) { return $this->translatableStringHelper->localize($category->getName()); diff --git a/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityReasonCategoryType.php b/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityReasonCategoryType.php index 83dcb43f0..4aa259097 100644 --- a/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityReasonCategoryType.php +++ b/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityReasonCategoryType.php @@ -38,7 +38,7 @@ class TranslatableActivityReasonCategoryType extends AbstractType $resolver->setDefaults( [ 'class' => ActivityReasonCategory::class, - 'choice_label' => fn(ActivityReasonCategory $category) => $this->translatableStringHelper->localize($category->getName()) + 'choice_label' => fn (ActivityReasonCategory $category) => $this->translatableStringHelper->localize($category->getName()) . (!$category->getActive() ? ' (' . $this->translator->trans('inactive') . ')' : ''), ] ); diff --git a/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityType.php b/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityType.php index 065f80c9b..d4807b82d 100644 --- a/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityType.php +++ b/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityType.php @@ -39,7 +39,7 @@ class TranslatableActivityType extends AbstractType 'class' => ActivityType::class, 'active_only' => true, 'choices' => $this->activityTypeRepository->findAllActive(), - 'choice_label' => fn(ActivityType $type) => $this->translatableStringHelper->localize($type->getName()), + 'choice_label' => fn (ActivityType $type) => $this->translatableStringHelper->localize($type->getName()), ] ); } diff --git a/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php b/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php index 3e5ff813b..1f2039a2c 100644 --- a/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php +++ b/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php @@ -254,7 +254,7 @@ final class ActivityACLAwareRepository implements ActivityACLAwareRepositoryInte $reachableScopes = $this->authorizationHelper->getReachableScopes($this->tokenStorage->getToken()->getUser(), ActivityVoter::SEE, $center); // we get the ids for those scopes $reachablesScopesId = array_map( - static fn(Scope $scope) => $scope->getId(), + static fn (Scope $scope) => $scope->getId(), $reachableScopes ); diff --git a/src/Bundle/ChillActivityBundle/Service/DocGenerator/ActivityContext.php b/src/Bundle/ChillActivityBundle/Service/DocGenerator/ActivityContext.php index 241526b03..624859eda 100644 --- a/src/Bundle/ChillActivityBundle/Service/DocGenerator/ActivityContext.php +++ b/src/Bundle/ChillActivityBundle/Service/DocGenerator/ActivityContext.php @@ -134,7 +134,7 @@ class ActivityContext implements $builder->add($key, EntityType::class, [ 'class' => Person::class, 'choices' => $persons, - 'choice_label' => fn(Person $p) => $this->personRender->renderString($p, []), + 'choice_label' => fn (Person $p) => $this->personRender->renderString($p, []), 'multiple' => false, 'required' => false, 'expanded' => true, diff --git a/src/Bundle/ChillActivityBundle/Service/DocGenerator/ListActivitiesByAccompanyingPeriodContext.php b/src/Bundle/ChillActivityBundle/Service/DocGenerator/ListActivitiesByAccompanyingPeriodContext.php index 9f9e03669..557bbcb84 100644 --- a/src/Bundle/ChillActivityBundle/Service/DocGenerator/ListActivitiesByAccompanyingPeriodContext.php +++ b/src/Bundle/ChillActivityBundle/Service/DocGenerator/ListActivitiesByAccompanyingPeriodContext.php @@ -146,7 +146,7 @@ class ListActivitiesByAccompanyingPeriodContext implements return array_filter( $activities, function ($activity) use ($user) { - $activityUsernames = array_map(static fn($user) => $user['username'], $activity['users'] ?? []); + $activityUsernames = array_map(static fn ($user) => $user['username'], $activity['users'] ?? []); return in_array($user->getUsername(), $activityUsernames, true); } ); @@ -157,7 +157,7 @@ class ListActivitiesByAccompanyingPeriodContext implements return array_filter( $works, function ($work) use ($user) { - $workUsernames = array_map(static fn($user) => $user['username'], $work['referrers'] ?? []); + $workUsernames = array_map(static fn ($user) => $user['username'], $work['referrers'] ?? []); return in_array($user->getUsername(), $workUsernames, true); } diff --git a/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityControllerTest.php b/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityControllerTest.php index d01821e6e..04301afae 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityControllerTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityControllerTest.php @@ -369,8 +369,8 @@ final class ActivityControllerTest extends WebTestCase $center ); $reachableScopesId = array_intersect( - array_map(static fn($s) => $s->getId(), $reachableScopesDelete), - array_map(static fn($s) => $s->getId(), $reachableScopesUpdate) + array_map(static fn ($s) => $s->getId(), $reachableScopesDelete), + array_map(static fn ($s) => $s->getId(), $reachableScopesUpdate) ); if (count($reachableScopesId) === 0) { diff --git a/src/Bundle/ChillActivityBundle/Tests/Form/ActivityTypeTest.php b/src/Bundle/ChillActivityBundle/Tests/Form/ActivityTypeTest.php index cd73b259a..3ed6b4409 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Form/ActivityTypeTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Form/ActivityTypeTest.php @@ -188,7 +188,7 @@ final class ActivityTypeTest extends KernelTestCase // map all the values in an array $values = array_map( - static fn($choice) => $choice->value, + static fn ($choice) => $choice->value, $view['activity']['durationTime']->vars['choices'] ); diff --git a/src/Bundle/ChillActivityBundle/Tests/Form/Type/TranslatableActivityReasonTest.php b/src/Bundle/ChillActivityBundle/Tests/Form/Type/TranslatableActivityReasonTest.php index aefa0d115..a8d85daa6 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Form/Type/TranslatableActivityReasonTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Form/Type/TranslatableActivityReasonTest.php @@ -83,7 +83,7 @@ final class TranslatableActivityReasonTest extends TypeTestCase $request->getLocale()->willReturn($fallbackLocale); $requestStack->willExtend(\Symfony\Component\HttpFoundation\RequestStack::class); - $requestStack->getCurrentRequest()->will(static fn() => $request); + $requestStack->getCurrentRequest()->will(static fn () => $request); $translator->willExtend(\Symfony\Component\Translation\Translator::class); $translator->getFallbackLocales()->willReturn($locale); diff --git a/src/Bundle/ChillAsideActivityBundle/src/DependencyInjection/Configuration.php b/src/Bundle/ChillAsideActivityBundle/src/DependencyInjection/Configuration.php index 85d76227d..2e2398c3e 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillAsideActivityBundle/src/DependencyInjection/Configuration.php @@ -132,7 +132,7 @@ class Configuration implements ConfigurationInterface ->info('The number of seconds of this duration. Must be an integer.') ->cannotBeEmpty() ->validate() - ->ifTrue(static fn($data) => !is_int($data))->thenInvalid('The value %s is not a valid integer') + ->ifTrue(static fn ($data) => !is_int($data))->thenInvalid('The value %s is not a valid integer') ->end() ->end() ->scalarNode('label') diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/CountAsideActivity.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/CountAsideActivity.php index 8eb8d1b64..9204fad4b 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/CountAsideActivity.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/CountAsideActivity.php @@ -59,7 +59,7 @@ class CountAsideActivity implements ExportInterface, GroupedExportInterface $labels = array_combine($values, $values); $labels['_header'] = $this->getTitle(); - return static fn($value) => $labels[$value]; + return static fn ($value) => $labels[$value]; } public function getQueryKeys($data): array diff --git a/src/Bundle/ChillBudgetBundle/Form/ChargeType.php b/src/Bundle/ChillBudgetBundle/Form/ChargeType.php index de8317ab3..72863163f 100644 --- a/src/Bundle/ChillBudgetBundle/Form/ChargeType.php +++ b/src/Bundle/ChillBudgetBundle/Form/ChargeType.php @@ -52,7 +52,7 @@ class ChargeType extends AbstractType 'label' => 'Charge type', 'required' => true, 'placeholder' => $this->translator->trans('admin.form.Choose the type of charge'), - 'choice_label' => fn(ChargeKind $resource) => $this->translatableStringHelper->localize($resource->getName()), + 'choice_label' => fn (ChargeKind $resource) => $this->translatableStringHelper->localize($resource->getName()), 'attr' => ['class' => 'select2'], ]) ->add('amount', MoneyType::class) diff --git a/src/Bundle/ChillBudgetBundle/Form/ResourceType.php b/src/Bundle/ChillBudgetBundle/Form/ResourceType.php index 3b14e9a05..09dfd16f3 100644 --- a/src/Bundle/ChillBudgetBundle/Form/ResourceType.php +++ b/src/Bundle/ChillBudgetBundle/Form/ResourceType.php @@ -51,7 +51,7 @@ class ResourceType extends AbstractType 'label' => 'Resource type', 'required' => true, 'placeholder' => $this->translator->trans('admin.form.Choose the type of resource'), - 'choice_label' => fn(ResourceKind $resource) => $this->translatableStringHelper->localize($resource->getName()), + 'choice_label' => fn (ResourceKind $resource) => $this->translatableStringHelper->localize($resource->getName()), 'attr' => ['class' => 'select2'], ]) ->add('amount', MoneyType::class) diff --git a/src/Bundle/ChillBudgetBundle/Service/Summary/SummaryBudget.php b/src/Bundle/ChillBudgetBundle/Service/Summary/SummaryBudget.php index 3e0ee2cec..1c66d4c1c 100644 --- a/src/Bundle/ChillBudgetBundle/Service/Summary/SummaryBudget.php +++ b/src/Bundle/ChillBudgetBundle/Service/Summary/SummaryBudget.php @@ -66,7 +66,7 @@ final class SummaryBudget implements SummaryBudgetInterface ]; } - $personIds = $household->getCurrentPersons()->map(static fn(Person $p) => $p->getId()); + $personIds = $household->getCurrentPersons()->map(static fn (Person $p) => $p->getId()); $ids = implode(', ', array_fill(0, count($personIds), '?')); $parameters = [...$personIds, $household->getId()]; @@ -125,14 +125,14 @@ final class SummaryBudget implements SummaryBudgetInterface { $keys = array_map(static fn (ChargeKind $kind) => $kind->getKind(), $this->chargeKindRepository->findAll()); - return array_combine($keys, array_map(fn($kind) => ['sum' => 0.0, 'label' => $this->translatableStringHelper->localize($this->chargeKindRepository->findOneByKind($kind)->getName()), 'comment' => ''], $keys)); + return array_combine($keys, array_map(fn ($kind) => ['sum' => 0.0, 'label' => $this->translatableStringHelper->localize($this->chargeKindRepository->findOneByKind($kind)->getName()), 'comment' => ''], $keys)); } private function getEmptyResourceArray(): array { $keys = array_map(static fn (ResourceKind $kind) => $kind->getKind(), $this->resourceKindRepository->findAll()); - return array_combine($keys, array_map(fn($kind) => ['sum' => 0.0, 'label' => $this->translatableStringHelper->localize($this->resourceKindRepository->findOneByKind($kind)->getName()), 'comment' => ''], $keys)); + return array_combine($keys, array_map(fn ($kind) => ['sum' => 0.0, 'label' => $this->translatableStringHelper->localize($this->resourceKindRepository->findOneByKind($kind)->getName()), 'comment' => ''], $keys)); } private function rowToArray(array $rows, string $kind): array diff --git a/src/Bundle/ChillBudgetBundle/Tests/Service/Summary/SummaryBudgetTest.php b/src/Bundle/ChillBudgetBundle/Tests/Service/Summary/SummaryBudgetTest.php index 194c23672..77017abc5 100644 --- a/src/Bundle/ChillBudgetBundle/Tests/Service/Summary/SummaryBudgetTest.php +++ b/src/Bundle/ChillBudgetBundle/Tests/Service/Summary/SummaryBudgetTest.php @@ -50,7 +50,7 @@ final class SummaryBudgetTest extends TestCase ], ]); $queryCharges->setParameters(Argument::type('array')) - ->will(static fn($args, $query) => $query); + ->will(static fn ($args, $query) => $query); $queryResources = $this->prophesize(AbstractQuery::class); $queryResources->getResult()->willReturn([ @@ -61,7 +61,7 @@ final class SummaryBudgetTest extends TestCase ], ]); $queryResources->setParameters(Argument::type('array')) - ->will(static fn($args, $query) => $query); + ->will(static fn ($args, $query) => $query); $em = $this->prophesize(EntityManagerInterface::class); $em->createNativeQuery(Argument::type('string'), Argument::type(Query\ResultSetMapping::class)) @@ -96,7 +96,7 @@ final class SummaryBudgetTest extends TestCase $resourceRepository->findOneByKind('misc')->willReturn($misc); $translatableStringHelper = $this->prophesize(TranslatableStringHelperInterface::class); - $translatableStringHelper->localize(Argument::type('array'))->will(static fn($arg) => $arg[0]['fr']); + $translatableStringHelper->localize(Argument::type('array'))->will(static fn ($arg) => $arg[0]['fr']); $person = new Person(); $personReflection = new ReflectionClass($person); diff --git a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php index 418bfcea2..79219a6e0 100644 --- a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php +++ b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php @@ -514,7 +514,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente */ public function getUsers(): ReadableCollection { - return $this->getInvites()->map(static fn(Invite $i) => $i->getUser()); + return $this->getInvites()->map(static fn (Invite $i) => $i->getUser()); } public function hasCalendarRange(): bool @@ -599,7 +599,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente } $invite = $this->invites - ->filter(static fn(Invite $invite) => $invite->getUser() === $user) + ->filter(static fn (Invite $invite) => $invite->getUser() === $user) ->first(); $this->removeInvite($invite); diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php b/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php index c21b4a4d6..9d3f00f99 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php @@ -61,7 +61,7 @@ class CountCalendars implements ExportInterface, GroupedExportInterface $labels = array_combine($values, $values); $labels['_header'] = $this->getTitle(); - return static fn($value) => $labels[$value]; + return static fn ($value) => $labels[$value]; } public function getQueryKeys($data): array @@ -89,7 +89,7 @@ class CountCalendars implements ExportInterface, GroupedExportInterface */ public function initiateQuery(array $requiredModifiers, array $acl, array $data = []): QueryBuilder { - $centers = array_map(static fn($el) => $el['center'], $acl); + $centers = array_map(static fn ($el) => $el['center'], $acl); $qb = $this->calendarRepository->createQueryBuilder('cal'); diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php index 78be10834..14dd42d6b 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php @@ -61,7 +61,7 @@ class StatCalendarAvgDuration implements ExportInterface, GroupedExportInterface $labels = array_combine($values, $values); $labels['_header'] = $this->getTitle(); - return static fn($value) => $labels[$value]; + return static fn ($value) => $labels[$value]; } public function getQueryKeys($data): array diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php index 5dd9dca44..1d31bfa26 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php @@ -61,7 +61,7 @@ class StatCalendarSumDuration implements ExportInterface, GroupedExportInterface $labels = array_combine($values, $values); $labels['_header'] = $this->getTitle(); - return static fn($value) => $labels[$value]; + return static fn ($value) => $labels[$value]; } public function getQueryKeys($data): array diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php index 058251004..b58cee594 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php @@ -58,7 +58,7 @@ class AgentFilter implements FilterInterface { $builder->add('accepted_agents', EntityType::class, [ 'class' => User::class, - 'choice_label' => fn(User $u) => $this->userRender->renderString($u, []), + 'choice_label' => fn (User $u) => $this->userRender->renderString($u, []), 'multiple' => true, 'expanded' => true, ]); diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php index 04f6ba02b..69fb24447 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php @@ -69,7 +69,7 @@ class JobFilter implements FilterInterface { $builder->add('job', EntityType::class, [ 'class' => UserJob::class, - 'choice_label' => fn(UserJob $j) => $this->translatableStringHelper->localize( + 'choice_label' => fn (UserJob $j) => $this->translatableStringHelper->localize( $j->getLabel() ), 'multiple' => true, diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php index ce6c90de2..08d9ae023 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php @@ -69,7 +69,7 @@ class ScopeFilter implements FilterInterface { $builder->add('scope', EntityType::class, [ 'class' => Scope::class, - 'choice_label' => fn(Scope $s) => $this->translatableStringHelper->localize( + 'choice_label' => fn (Scope $s) => $this->translatableStringHelper->localize( $s->getName() ), 'multiple' => true, diff --git a/src/Bundle/ChillCalendarBundle/Messenger/Handler/CalendarToRemoteHandler.php b/src/Bundle/ChillCalendarBundle/Messenger/Handler/CalendarToRemoteHandler.php index 1ec257cad..eabdf9063 100644 --- a/src/Bundle/ChillCalendarBundle/Messenger/Handler/CalendarToRemoteHandler.php +++ b/src/Bundle/ChillCalendarBundle/Messenger/Handler/CalendarToRemoteHandler.php @@ -89,10 +89,10 @@ class CalendarToRemoteHandler implements MessageHandlerInterface $newInvites = array_filter( array_map( - fn($id) => $this->inviteRepository->find($id), + fn ($id) => $this->inviteRepository->find($id), $calendarMessage->getNewInvitesIds(), ), - static fn(?Invite $invite) => null !== $invite + static fn (?Invite $invite) => null !== $invite ); $this->calendarConnector->syncCalendar( diff --git a/src/Bundle/ChillCalendarBundle/Messenger/Message/CalendarMessage.php b/src/Bundle/ChillCalendarBundle/Messenger/Message/CalendarMessage.php index 6232ca06c..c8a8f8aeb 100644 --- a/src/Bundle/ChillCalendarBundle/Messenger/Message/CalendarMessage.php +++ b/src/Bundle/ChillCalendarBundle/Messenger/Message/CalendarMessage.php @@ -58,7 +58,7 @@ class CalendarMessage $this->previousMainUserId = null !== $calendar->previousMainUser ? $calendar->previousMainUser->getId() : null; $this->newInvitesIds = array_map(static fn (Invite $i) => $i->getId(), $calendar->newInvites); - $this->oldInvites = array_map(static fn(Invite $i) => [ + $this->oldInvites = array_map(static fn (Invite $i) => [ 'inviteId' => $i->getId(), 'userId' => $i->getUser()->getId(), 'userEmail' => $i->getUser()->getEmail(), diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteEventConverter.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteEventConverter.php index b7a1c2df6..176dbe0b0 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteEventConverter.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteEventConverter.php @@ -121,7 +121,7 @@ class RemoteEventConverter 'subject' => '[Chill] ' . implode( ', ', - $calendar->getPersons()->map(fn(Person $p) => $this->personRender->renderString($p, []))->toArray() + $calendar->getPersons()->map(fn (Person $p) => $this->personRender->renderString($p, []))->toArray() ), 'start' => [ 'dateTime' => $calendar->getStartDate()->setTimezone($this->remoteDateTimeZone) @@ -159,7 +159,7 @@ class RemoteEventConverter { return [ 'attendees' => $calendar->getInvites()->map( - fn(Invite $i) => $this->buildInviteToAttendee($i) + fn (Invite $i) => $this->buildInviteToAttendee($i) )->toArray(), ]; } diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraphRemoteCalendarConnector.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraphRemoteCalendarConnector.php index 75995948e..e3690042c 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraphRemoteCalendarConnector.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraphRemoteCalendarConnector.php @@ -190,17 +190,17 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface ] )->toArray(); - $ids = array_map(static fn($item) => $item['id'], $bareEvents['value']); + $ids = array_map(static fn ($item) => $item['id'], $bareEvents['value']); $existingIdsInRange = $this->calendarRangeRepository->findRemoteIdsPresent($ids); $existingIdsInCalendar = $this->calendarRepository->findRemoteIdsPresent($ids); return array_values( array_map( - fn($item) => $this->remoteEventConverter->convertToRemote($item), + fn ($item) => $this->remoteEventConverter->convertToRemote($item), // filter all event to keep only the one not in range array_filter( $bareEvents['value'], - static fn($item) => ((!$existingIdsInRange[$item['id']]) ?? true) && ((!$existingIdsInCalendar[$item['id']]) ?? true) + static fn ($item) => ((!$existingIdsInRange[$item['id']]) ?? true) && ((!$existingIdsInCalendar[$item['id']]) ?? true) ) ) ); @@ -595,7 +595,7 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface } $this->cacheScheduleTimeForUser[$userId] = array_map( - fn($item) => $this->remoteEventConverter->convertAvailabilityToRemoteEvent($item), + fn ($item) => $this->remoteEventConverter->convertAvailabilityToRemoteEvent($item), $response['value'][0]['scheduleItems'] ); diff --git a/src/Bundle/ChillCalendarBundle/Tests/Form/CalendarTypeTest.php b/src/Bundle/ChillCalendarBundle/Tests/Form/CalendarTypeTest.php index f7a3509f4..9195d5eac 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Form/CalendarTypeTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Form/CalendarTypeTest.php @@ -114,8 +114,8 @@ final class CalendarTypeTest extends TypeTestCase $this->assertEquals(8, $calendar->getCalendarRange()->getId()); $this->assertEquals(9, $calendar->getLocation()->getId()); $this->assertEquals(true, $calendar->getSendSMS()); - $this->assertContains(2, $calendar->getUsers()->map(static fn(User $u) => $u->getId())); - $this->assertContains(3, $calendar->getUsers()->map(static fn(User $u) => $u->getId())); + $this->assertContains(2, $calendar->getUsers()->map(static fn (User $u) => $u->getId())); + $this->assertContains(3, $calendar->getUsers()->map(static fn (User $u) => $u->getId())); } protected function getExtensions() @@ -144,16 +144,16 @@ final class CalendarTypeTest extends TypeTestCase ) { $transformer = $this->prophesize($classTransformer); $transformer->transform(Argument::type('array')) - ->will(static fn($args) => implode( + ->will(static fn ($args) => implode( ',', - array_map(static fn($p) => $p->getId(), $args[0]) + array_map(static fn ($p) => $p->getId(), $args[0]) )); $transformer->transform(Argument::exact(null)) ->willReturn([]); $transformer->transform(Argument::type(Collection::class)) - ->will(static fn($args) => implode( + ->will(static fn ($args) => implode( ',', - array_map(static fn($p) => $p->getId(), $args[0]->toArray()) + array_map(static fn ($p) => $p->getId(), $args[0]->toArray()) )); $transformer->reverseTransform(Argument::type('string')) ->will(static function ($args) use ($objClass) { @@ -183,7 +183,7 @@ final class CalendarTypeTest extends TypeTestCase ) { $transformer = $this->prophesize($classTransformer); $transformer->transform(Argument::type('object')) - ->will(static fn($args) => (string) $args[0]->getId()); + ->will(static fn ($args) => (string) $args[0]->getId()); $transformer->transform(Argument::exact(null)) ->willReturn(''); $transformer->reverseTransform(Argument::type('string')) diff --git a/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/AddressConverterTest.php b/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/AddressConverterTest.php index 35c067eb7..827e22381 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/AddressConverterTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/AddressConverterTest.php @@ -63,7 +63,7 @@ final class AddressConverterTest extends TestCase { $engine = $this->prophesize(EngineInterface::class); $translatableStringHelper = $this->prophesize(TranslatableStringHelperInterface::class); - $translatableStringHelper->localize(Argument::type('array'))->will(static fn($args): string => ($args[0] ?? ['fr' => 'not provided'])['fr'] ?? 'not provided'); + $translatableStringHelper->localize(Argument::type('array'))->will(static fn ($args): string => ($args[0] ?? ['fr' => 'not provided'])['fr'] ?? 'not provided'); $addressRender = new AddressRender($engine->reveal(), $translatableStringHelper->reveal()); diff --git a/src/Bundle/ChillCalendarBundle/Tests/Service/ShortMessageNotification/CalendarForShortMessageProviderTest.php b/src/Bundle/ChillCalendarBundle/Tests/Service/ShortMessageNotification/CalendarForShortMessageProviderTest.php index 9ee2ac82b..34867d8bd 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Service/ShortMessageNotification/CalendarForShortMessageProviderTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Service/ShortMessageNotification/CalendarForShortMessageProviderTest.php @@ -72,13 +72,13 @@ final class CalendarForShortMessageProviderTest extends TestCase Argument::type(DateTimeImmutable::class), Argument::type('int'), Argument::exact(0) - )->will(static fn($args) => array_fill(0, $args[2], new Calendar()))->shouldBeCalledTimes(1); + )->will(static fn ($args) => array_fill(0, $args[2], new Calendar()))->shouldBeCalledTimes(1); $calendarRepository->findByNotificationAvailable( Argument::type(DateTimeImmutable::class), Argument::type(DateTimeImmutable::class), Argument::type('int'), Argument::not(0) - )->will(static fn($args) => array_fill(0, $args[2] - 1, new Calendar()))->shouldBeCalledTimes(1); + )->will(static fn ($args) => array_fill(0, $args[2] - 1, new Calendar()))->shouldBeCalledTimes(1); $em = $this->prophesize(EntityManagerInterface::class); $em->clear()->shouldBeCalled(); @@ -104,13 +104,13 @@ final class CalendarForShortMessageProviderTest extends TestCase Argument::type(DateTimeImmutable::class), Argument::type('int'), Argument::exact(0) - )->will(static fn($args) => array_fill(0, 1, new Calendar()))->shouldBeCalledTimes(1); + )->will(static fn ($args) => array_fill(0, 1, new Calendar()))->shouldBeCalledTimes(1); $calendarRepository->findByNotificationAvailable( Argument::type(DateTimeImmutable::class), Argument::type(DateTimeImmutable::class), Argument::type('int'), Argument::not(0) - )->will(static fn($args) => [])->shouldBeCalledTimes(1); + )->will(static fn ($args) => [])->shouldBeCalledTimes(1); $em = $this->prophesize(EntityManagerInterface::class); $em->clear()->shouldBeCalled(); diff --git a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldLongChoice.php b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldLongChoice.php index c60d947dd..75dc7792f 100644 --- a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldLongChoice.php +++ b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldLongChoice.php @@ -58,7 +58,7 @@ class CustomFieldLongChoice extends AbstractCustomField $translatableStringHelper = $this->translatableStringHelper; $builder->add($customField->getSlug(), Select2ChoiceType::class, [ 'choices' => $entries, - 'choice_label' => static fn(Option $option) => $translatableStringHelper->localize($option->getText()), + 'choice_label' => static fn (Option $option) => $translatableStringHelper->localize($option->getText()), 'choice_value' => static fn (Option $key): ?int => null === $key ? null : $key->getId(), 'multiple' => false, 'expanded' => false, diff --git a/src/Bundle/ChillCustomFieldsBundle/EntityRepository/CustomFieldLongChoice/OptionRepository.php b/src/Bundle/ChillCustomFieldsBundle/EntityRepository/CustomFieldLongChoice/OptionRepository.php index e1ed1d363..4ef6e046d 100644 --- a/src/Bundle/ChillCustomFieldsBundle/EntityRepository/CustomFieldLongChoice/OptionRepository.php +++ b/src/Bundle/ChillCustomFieldsBundle/EntityRepository/CustomFieldLongChoice/OptionRepository.php @@ -57,6 +57,6 @@ class OptionRepository extends EntityRepository ->getQuery() ->getScalarResult(); - return array_map(static fn($r) => $r['key'], $keys); + return array_map(static fn ($r) => $r['key'], $keys); } } diff --git a/src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldType.php b/src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldType.php index f9a9f2509..0630bccf5 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldType.php +++ b/src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldType.php @@ -70,7 +70,7 @@ class CustomFieldType extends AbstractType if ('entity' === $options['group_widget']) { $builder->add('customFieldsGroup', EntityType::class, [ 'class' => 'ChillCustomFieldsBundle:CustomFieldsGroup', - 'choice_label' => fn($g) => $this->translatableStringHelper->localize($g->getName()), + 'choice_label' => fn ($g) => $this->translatableStringHelper->localize($g->getName()), ]); } elseif ('hidden' === $options['group_widget']) { $builder->add('customFieldsGroup', HiddenType::class); diff --git a/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/JsonCustomFieldToArrayTransformer.php b/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/JsonCustomFieldToArrayTransformer.php index ab67ca581..2b34b498a 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/JsonCustomFieldToArrayTransformer.php +++ b/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/JsonCustomFieldToArrayTransformer.php @@ -38,7 +38,7 @@ class JsonCustomFieldToArrayTransformer implements DataTransformerInterface // @TODO: in the array_map callback, CustomField::getLabel() does not exist. What do we do here? $customFieldsLablels = array_map( - static fn($e) => $e->getLabel(), + static fn ($e) => $e->getLabel(), $customFields ); diff --git a/src/Bundle/ChillDocGeneratorBundle/Form/DocGeneratorTemplateType.php b/src/Bundle/ChillDocGeneratorBundle/Form/DocGeneratorTemplateType.php index 0b1fbec9d..5b4a8be30 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Form/DocGeneratorTemplateType.php +++ b/src/Bundle/ChillDocGeneratorBundle/Form/DocGeneratorTemplateType.php @@ -61,8 +61,8 @@ class DocGeneratorTemplateType extends AbstractType $sub = $builder ->create('options', null, ['compound' => true]) ->addModelTransformer(new CallbackTransformer( - static fn(array $data) => $context->adminFormTransform($data), - static fn(array $data) => $context->adminFormReverseTransform($data) + static fn (array $data) => $context->adminFormTransform($data), + static fn (array $data) => $context->adminFormReverseTransform($data) )); $context->buildAdminForm($sub); $builder->add($sub); diff --git a/src/Bundle/ChillDocStoreBundle/Form/AccompanyingCourseDocumentType.php b/src/Bundle/ChillDocStoreBundle/Form/AccompanyingCourseDocumentType.php index 255ca5dc5..5ed5b5981 100644 --- a/src/Bundle/ChillDocStoreBundle/Form/AccompanyingCourseDocumentType.php +++ b/src/Bundle/ChillDocStoreBundle/Form/AccompanyingCourseDocumentType.php @@ -72,10 +72,10 @@ class AccompanyingCourseDocumentType extends AbstractType ->add('category', EntityType::class, [ 'placeholder' => 'Choose a document category', 'class' => DocumentCategory::class, - 'query_builder' => static fn(EntityRepository $er) => $er->createQueryBuilder('c') + 'query_builder' => static fn (EntityRepository $er) => $er->createQueryBuilder('c') ->where('c.documentClass = :docClass') ->setParameter('docClass', AccompanyingCourseDocument::class), - 'choice_label' => fn($entity = null) => $entity ? $this->translatableStringHelper->localize($entity->getName()) : '', + 'choice_label' => fn ($entity = null) => $entity ? $this->translatableStringHelper->localize($entity->getName()) : '', ]); } diff --git a/src/Bundle/ChillDocStoreBundle/Form/PersonDocumentType.php b/src/Bundle/ChillDocStoreBundle/Form/PersonDocumentType.php index c7cf31534..11f73e862 100644 --- a/src/Bundle/ChillDocStoreBundle/Form/PersonDocumentType.php +++ b/src/Bundle/ChillDocStoreBundle/Form/PersonDocumentType.php @@ -67,10 +67,10 @@ class PersonDocumentType extends AbstractType ->add('category', EntityType::class, [ 'placeholder' => 'Choose a document category', 'class' => DocumentCategory::class, - 'query_builder' => static fn(EntityRepository $er) => $er->createQueryBuilder('c') + 'query_builder' => static fn (EntityRepository $er) => $er->createQueryBuilder('c') ->where('c.documentClass = :docClass') ->setParameter('docClass', PersonDocument::class), - 'choice_label' => fn($entity = null) => $entity ? $this->translatableStringHelper->localize($entity->getName()) : '', + 'choice_label' => fn ($entity = null) => $entity ? $this->translatableStringHelper->localize($entity->getName()) : '', ]); if ($isScopeConcerned && $this->parameterBag->get('chill_main')['acl']['form_show_scopes']) { diff --git a/src/Bundle/ChillDocStoreBundle/Workflow/AccompanyingCourseDocumentWorkflowHandler.php b/src/Bundle/ChillDocStoreBundle/Workflow/AccompanyingCourseDocumentWorkflowHandler.php index b819ae8c3..c3285507e 100644 --- a/src/Bundle/ChillDocStoreBundle/Workflow/AccompanyingCourseDocumentWorkflowHandler.php +++ b/src/Bundle/ChillDocStoreBundle/Workflow/AccompanyingCourseDocumentWorkflowHandler.php @@ -51,7 +51,7 @@ class AccompanyingCourseDocumentWorkflowHandler implements EntityWorkflowHandler $persons = []; if (null !== $course) { - $persons = $course->getCurrentParticipations()->map(static fn(AccompanyingPeriodParticipation $participation) => $participation->getPerson())->toArray(); + $persons = $course->getCurrentParticipations()->map(static fn (AccompanyingPeriodParticipation $participation) => $participation->getPerson())->toArray(); } return [ diff --git a/src/Bundle/ChillEventBundle/Controller/ParticipationController.php b/src/Bundle/ChillEventBundle/Controller/ParticipationController.php index 51ba3634d..1929beac1 100644 --- a/src/Bundle/ChillEventBundle/Controller/ParticipationController.php +++ b/src/Bundle/ChillEventBundle/Controller/ParticipationController.php @@ -113,7 +113,7 @@ class ParticipationController extends AbstractController [ 'event_id' => current($participations)->getEvent()->getId(), 'persons_ids' => implode(',', array_map( - static fn(Participation $p) => $p->getPerson()->getId(), + static fn (Participation $p) => $p->getPerson()->getId(), $participations )), ] @@ -648,13 +648,13 @@ 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() + static fn (Participation $p) => $p->getPerson()->getId() ); // check that the user is not already in the event if ($peopleParticipating->contains($participation->getPerson()->getId())) { $ignoredParticipations[] = $participation ->getEvent()->getParticipations()->filter( - static fn(Participation $p) => $p->getPerson()->getId() === $participation->getPerson()->getId() + static fn (Participation $p) => $p->getPerson()->getId() === $participation->getPerson()->getId() )->first(); } else { $newParticipations[] = $participation; diff --git a/src/Bundle/ChillEventBundle/Entity/Event.php b/src/Bundle/ChillEventBundle/Entity/Event.php index 669cb02db..d55a7b8a8 100644 --- a/src/Bundle/ChillEventBundle/Entity/Event.php +++ b/src/Bundle/ChillEventBundle/Entity/Event.php @@ -176,7 +176,7 @@ class Event implements HasCenterInterface, HasScopeInterface { $iterator = $this->participations->getIterator(); - $iterator->uasort(static fn($first, $second) => strnatcasecmp($first->getPerson()->getFirstName(), $second->getPerson()->getFirstName())); + $iterator->uasort(static fn ($first, $second) => strnatcasecmp($first->getPerson()->getFirstName(), $second->getPerson()->getFirstName())); return $iterator; } diff --git a/src/Bundle/ChillEventBundle/Form/ChoiceLoader/EventChoiceLoader.php b/src/Bundle/ChillEventBundle/Form/ChoiceLoader/EventChoiceLoader.php index de1c42cf8..962799dbc 100644 --- a/src/Bundle/ChillEventBundle/Form/ChoiceLoader/EventChoiceLoader.php +++ b/src/Bundle/ChillEventBundle/Form/ChoiceLoader/EventChoiceLoader.php @@ -62,7 +62,7 @@ class EventChoiceLoader implements ChoiceLoaderInterface { return new \Symfony\Component\Form\ChoiceList\ArrayChoiceList( $this->lazyLoadedEvents, - static fn(Event $p) => call_user_func($value, $p) + static fn (Event $p) => call_user_func($value, $p) ); } diff --git a/src/Bundle/ChillEventBundle/Form/RoleType.php b/src/Bundle/ChillEventBundle/Form/RoleType.php index 2a0b6765a..519e814cf 100644 --- a/src/Bundle/ChillEventBundle/Form/RoleType.php +++ b/src/Bundle/ChillEventBundle/Form/RoleType.php @@ -38,7 +38,7 @@ class RoleType extends AbstractType ->add('active') ->add('type', EntityType::class, [ 'class' => EventType::class, - 'choice_label' => fn(EventType $e) => $this->translatableStringHelper->localize($e->getName()), + 'choice_label' => fn (EventType $e) => $this->translatableStringHelper->localize($e->getName()), ]); } diff --git a/src/Bundle/ChillEventBundle/Form/Type/PickEventType.php b/src/Bundle/ChillEventBundle/Form/Type/PickEventType.php index 1ec088ba6..05436b3e8 100644 --- a/src/Bundle/ChillEventBundle/Form/Type/PickEventType.php +++ b/src/Bundle/ChillEventBundle/Form/Type/PickEventType.php @@ -109,12 +109,12 @@ class PickEventType extends AbstractType // add the default options $resolver->setDefaults([ 'class' => Event::class, - 'choice_label' => static fn(Event $e) => $e->getDate()->format('d/m/Y, H:i') . ' → ' . + 'choice_label' => static fn (Event $e) => $e->getDate()->format('d/m/Y, H:i') . ' → ' . // $e->getType()->getName()['fr'] . ': ' . // display the type of event $e->getName(), 'placeholder' => 'Pick an event', 'attr' => ['class' => 'select2 '], - 'choice_attr' => static fn(Event $e) => ['data-center' => $e->getCenter()->getId()], + 'choice_attr' => static fn (Event $e) => ['data-center' => $e->getCenter()->getId()], 'choiceloader' => function (Options $options) { $centers = $this->filterCenters($options); @@ -139,7 +139,7 @@ class PickEventType extends AbstractType // option role if (null === $options['role']) { $centers = array_map( - static fn(GroupCenter $g) => $g->getCenter(), + static fn (GroupCenter $g) => $g->getCenter(), $this->user->getGroupCenters()->toArray() ); } else { @@ -167,7 +167,7 @@ class PickEventType extends AbstractType if ( !in_array($c->getId(), array_map( - static fn(Center $c) => $c->getId(), + static fn (Center $c) => $c->getId(), $centers ), true) ) { diff --git a/src/Bundle/ChillEventBundle/Form/Type/PickEventTypeType.php b/src/Bundle/ChillEventBundle/Form/Type/PickEventTypeType.php index 2ecdb27d7..d027c05cf 100644 --- a/src/Bundle/ChillEventBundle/Form/Type/PickEventTypeType.php +++ b/src/Bundle/ChillEventBundle/Form/Type/PickEventTypeType.php @@ -39,10 +39,10 @@ class PickEventTypeType extends AbstractType $resolver->setDefaults( [ 'class' => EventType::class, - 'query_builder' => static fn(EntityRepository $er) => $er->createQueryBuilder('et') + 'query_builder' => static fn (EntityRepository $er) => $er->createQueryBuilder('et') ->where('et.active = true'), - 'choice_label' => static fn(EventType $t) => $helper->localize($t->getName()), - 'choice_attrs' => static fn(EventType $t) => ['data-link-category' => $t->getId()], + 'choice_label' => static fn (EventType $t) => $helper->localize($t->getName()), + 'choice_attrs' => static fn (EventType $t) => ['data-link-category' => $t->getId()], ] ); } diff --git a/src/Bundle/ChillEventBundle/Form/Type/PickRoleType.php b/src/Bundle/ChillEventBundle/Form/Type/PickRoleType.php index ca6425dc8..8fd8ff7d7 100644 --- a/src/Bundle/ChillEventBundle/Form/Type/PickRoleType.php +++ b/src/Bundle/ChillEventBundle/Form/Type/PickRoleType.php @@ -80,7 +80,7 @@ class PickRoleType extends AbstractType $options = $config->getOptions(); $form->getParent()->add($name, $type, array_replace($options, [ - 'group_by' => fn(Role $r) => $this->translatableStringHelper->localize($r->getType()->getName()), + 'group_by' => fn (Role $r) => $this->translatableStringHelper->localize($r->getType()->getName()), ])); } } @@ -109,11 +109,11 @@ class PickRoleType extends AbstractType 'class' => Role::class, 'query_builder' => $qb, 'group_by' => null, - 'choice_attr' => static fn(Role $r) => [ + 'choice_attr' => static fn (Role $r) => [ 'data-event-type' => $r->getType()->getId(), 'data-link-category' => $r->getType()->getId(), ], - 'choice_label' => static fn(Role $r) => $translatableStringHelper->localize($r->getName()) . + 'choice_label' => static fn (Role $r) => $translatableStringHelper->localize($r->getName()) . ($r->getActive() === true ? '' : ' (' . $translator->trans('unactive') . ')'), ]); diff --git a/src/Bundle/ChillEventBundle/Form/Type/PickStatusType.php b/src/Bundle/ChillEventBundle/Form/Type/PickStatusType.php index b1078ab61..dcc3ba205 100644 --- a/src/Bundle/ChillEventBundle/Form/Type/PickStatusType.php +++ b/src/Bundle/ChillEventBundle/Form/Type/PickStatusType.php @@ -82,7 +82,7 @@ class PickStatusType extends AbstractType $type = $config->getType()->getName(); $options = $config->getOptions(); $form->getParent()->add($name, $type, array_replace($options, [ - 'group_by' => fn(Status $s) => $this->translatableStringHelper->localize($s->getType()->getName()), + 'group_by' => fn (Status $s) => $this->translatableStringHelper->localize($s->getType()->getName()), ])); } ); @@ -110,11 +110,11 @@ class PickStatusType extends AbstractType 'class' => Status::class, 'query_builder' => $qb, 'group_by' => null, - 'choice_attr' => static fn(Status $s) => [ + 'choice_attr' => static fn (Status $s) => [ 'data-event-type' => $s->getType()->getId(), 'data-link-category' => $s->getType()->getId(), ], - 'choice_label' => static fn(Status $s) => $translatableStringHelper->localize($s->getName()) . + 'choice_label' => static fn (Status $s) => $translatableStringHelper->localize($s->getName()) . ($s->getActive() === true ? '' : ' (' . $translator->trans('unactive') . ')'), ]); diff --git a/src/Bundle/ChillEventBundle/Tests/Controller/ParticipationControllerTest.php b/src/Bundle/ChillEventBundle/Tests/Controller/ParticipationControllerTest.php index 7c79e52e3..d61c1f385 100644 --- a/src/Bundle/ChillEventBundle/Tests/Controller/ParticipationControllerTest.php +++ b/src/Bundle/ChillEventBundle/Tests/Controller/ParticipationControllerTest.php @@ -239,7 +239,7 @@ final class ParticipationControllerTest extends WebTestCase $this->personsIdsCache = array_merge( $this->personsIdsCache, $event->getParticipations()->map( - static fn($p) => $p->getPerson()->getId() + static fn ($p) => $p->getPerson()->getId() ) ->toArray() ); @@ -303,7 +303,7 @@ final class ParticipationControllerTest extends WebTestCase $event = $this->getRandomEventWithMultipleParticipations(); $persons_id = implode(',', $event->getParticipations()->map( - static fn($p) => $p->getPerson()->getId() + static fn ($p) => $p->getPerson()->getId() )->toArray()); $crawler = $this->client->request( @@ -329,7 +329,7 @@ final class ParticipationControllerTest extends WebTestCase $nbParticipations = $event->getParticipations()->count(); // get the persons_id participating on this event $persons_id = $event->getParticipations()->map( - static fn($p) => $p->getPerson()->getId() + static fn ($p) => $p->getPerson()->getId() )->toArray(); // exclude the existing persons_ids from the new person $this->personsIdsCache = array_merge($this->personsIdsCache, $persons_id); @@ -458,7 +458,7 @@ final class ParticipationControllerTest extends WebTestCase $circles = $this->em->getRepository(\Chill\MainBundle\Entity\Scope::class) ->findAll(); - array_filter($circles, static fn($circle) => in_array($circleName, $circle->getName(), true)); + array_filter($circles, static fn ($circle) => in_array($circleName, $circle->getName(), true)); $circle = $circles[0]; $events = $this->em->getRepository(\Chill\EventBundle\Entity\Event::class) diff --git a/src/Bundle/ChillEventBundle/Timeline/TimelineEventProvider.php b/src/Bundle/ChillEventBundle/Timeline/TimelineEventProvider.php index a7bf08741..9fac6c88e 100644 --- a/src/Bundle/ChillEventBundle/Timeline/TimelineEventProvider.php +++ b/src/Bundle/ChillEventBundle/Timeline/TimelineEventProvider.php @@ -208,7 +208,7 @@ class TimelineEventProvider implements TimelineProviderInterface foreach ($reachableCenters as $center) { $reachableCircleId = array_map( - static fn(Scope $scope) => $scope->getId(), + static fn (Scope $scope) => $scope->getId(), $this->helper->getReachableCircles($this->user, $role, $person->getCenter()) ); $centerAndScopeLines[] = sprintf( diff --git a/src/Bundle/ChillMainBundle/CRUD/Routing/CRUDRoutesLoader.php b/src/Bundle/ChillMainBundle/CRUD/Routing/CRUDRoutesLoader.php index 01f80d1b8..4fbf5961d 100644 --- a/src/Bundle/ChillMainBundle/CRUD/Routing/CRUDRoutesLoader.php +++ b/src/Bundle/ChillMainBundle/CRUD/Routing/CRUDRoutesLoader.php @@ -141,7 +141,7 @@ class CRUDRoutesLoader extends Loader $methods = array_keys(array_filter( $action['methods'], - static fn($value, $key) => $value, + static fn ($value, $key) => $value, ARRAY_FILTER_USE_BOTH )); diff --git a/src/Bundle/ChillMainBundle/Controller/NotificationController.php b/src/Bundle/ChillMainBundle/Controller/NotificationController.php index 29ec6e7f0..327a06df6 100644 --- a/src/Bundle/ChillMainBundle/Controller/NotificationController.php +++ b/src/Bundle/ChillMainBundle/Controller/NotificationController.php @@ -282,7 +282,7 @@ class NotificationController extends AbstractController if ($request->query->has('edit')) { $commentId = $request->query->getInt('edit'); - $editedComment = $notification->getComments()->filter(static fn(NotificationComment $c) => $c->getId() === $commentId)->first(); + $editedComment = $notification->getComments()->filter(static fn (NotificationComment $c) => $c->getId() === $commentId)->first(); if (false === $editedComment) { throw $this->createNotFoundException("Comment with id {$commentId} does not exists nor belong to this notification"); diff --git a/src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php b/src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php index 3292b3540..5d32a8dbb 100644 --- a/src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php +++ b/src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php @@ -158,7 +158,7 @@ class PermissionsGroupController extends AbstractController 'edit_form' => $editForm->createView(), 'role_scopes_sorted' => $roleScopesSorted, 'expanded_roles' => $this->getExpandedRoles($permissionsGroup->getRoleScopes()->toArray()), - 'delete_role_scopes_form' => array_map(static fn($form) => $form->createView(), $deleteRoleScopesForm), + 'delete_role_scopes_form' => array_map(static fn ($form) => $form->createView(), $deleteRoleScopesForm), 'add_role_scopes_form' => $addRoleScopesForm->createView(), ]); } @@ -303,7 +303,7 @@ class PermissionsGroupController extends AbstractController 'role_scopes_sorted' => $roleScopesSorted, 'edit_form' => $editForm->createView(), 'expanded_roles' => $this->getExpandedRoles($permissionsGroup->getRoleScopes()->toArray()), - 'delete_role_scopes_form' => array_map(static fn($form) => $form->createView(), $deleteRoleScopesForm), + 'delete_role_scopes_form' => array_map(static fn ($form) => $form->createView(), $deleteRoleScopesForm), 'add_role_scopes_form' => $addRoleScopesForm->createView(), ]); } @@ -445,7 +445,7 @@ class PermissionsGroupController extends AbstractController 'role_scopes_sorted' => $roleScopesSorted, 'edit_form' => $editForm->createView(), 'expanded_roles' => $this->getExpandedRoles($permissionsGroup->getRoleScopes()->toArray()), - 'delete_role_scopes_form' => array_map(static fn($form) => $form->createView(), $deleteRoleScopesForm), + 'delete_role_scopes_form' => array_map(static fn ($form) => $form->createView(), $deleteRoleScopesForm), 'add_role_scopes_form' => $addRoleScopesForm->createView(), ]); } @@ -567,7 +567,7 @@ class PermissionsGroupController extends AbstractController if (!array_key_exists($roleScope->getRole(), $expandedRoles)) { $expandedRoles[$roleScope->getRole()] = array_map( - static fn(Role $role) => $role->getRole(), + static fn (Role $role) => $role->getRole(), $this->roleHierarchy ->getReachableRoles( [new Role($roleScope->getRole())] diff --git a/src/Bundle/ChillMainBundle/Controller/UserController.php b/src/Bundle/ChillMainBundle/Controller/UserController.php index 64cef168d..ecf8a3c9c 100644 --- a/src/Bundle/ChillMainBundle/Controller/UserController.php +++ b/src/Bundle/ChillMainBundle/Controller/UserController.php @@ -337,12 +337,13 @@ class UserController extends CRUDController [ 'add_groupcenter_form' => $this->createAddLinkGroupCenterForm($entity, $request)->createView(), 'delete_groupcenter_form' => array_map( - static fn(Form $form) => $form->createView(), + static fn (Form $form) => $form->createView(), iterator_to_array($this->getDeleteLinkGroupCenterByUser($entity, $request), true) ), ] ); - } elseif ('index' === $action) { + } + if ('index' === $action) { return array_merge( ['allow_change_password' => $this->parameterBag->get('chill_main.access_user_change_password')], $defaultTemplateParameters diff --git a/src/Bundle/ChillMainBundle/Controller/WorkflowController.php b/src/Bundle/ChillMainBundle/Controller/WorkflowController.php index af4974bbe..36647612b 100644 --- a/src/Bundle/ChillMainBundle/Controller/WorkflowController.php +++ b/src/Bundle/ChillMainBundle/Controller/WorkflowController.php @@ -345,7 +345,7 @@ class WorkflowController extends AbstractController if ($transitionForm->isSubmitted() && $transitionForm->isValid()) { if (!$workflow->can($entityWorkflow, $transition = $transitionForm['transition']->getData()->getName())) { $blockers = $workflow->buildTransitionBlockerList($entityWorkflow, $transition); - $msgs = array_map(fn(TransitionBlocker $tb) => $this->translator->trans( + $msgs = array_map(fn (TransitionBlocker $tb) => $this->translator->trans( $tb->getMessage(), $tb->getParameters() ), iterator_to_array($blockers)); diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/MenuCompilerPass.php b/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/MenuCompilerPass.php index da2cbff1f..d6a27c943 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/MenuCompilerPass.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/MenuCompilerPass.php @@ -37,7 +37,7 @@ class MenuCompilerPass implements CompilerPassInterface ]; } - usort($services, static fn($a, $b) => $a['priority'] <=> $b['priority']); + usort($services, static fn ($a, $b) => $a['priority'] <=> $b['priority']); foreach ($services as $service) { $class = $container->getDefinition($service['id'])->getClass(); diff --git a/src/Bundle/ChillMainBundle/Doctrine/DQL/Greatest.php b/src/Bundle/ChillMainBundle/Doctrine/DQL/Greatest.php index a56bcb50c..c76bd22cf 100644 --- a/src/Bundle/ChillMainBundle/Doctrine/DQL/Greatest.php +++ b/src/Bundle/ChillMainBundle/Doctrine/DQL/Greatest.php @@ -33,7 +33,7 @@ class Greatest extends FunctionNode public function getSql(SqlWalker $sqlWalker) { - return 'GREATEST(' . implode(', ', array_map(static fn(Node $expr) => $expr->dispatch($sqlWalker), $this->exprs)) . ')'; + return 'GREATEST(' . implode(', ', array_map(static fn (Node $expr) => $expr->dispatch($sqlWalker), $this->exprs)) . ')'; } public function parse(Parser $parser) diff --git a/src/Bundle/ChillMainBundle/Doctrine/DQL/Least.php b/src/Bundle/ChillMainBundle/Doctrine/DQL/Least.php index e31d31456..9befa5f40 100644 --- a/src/Bundle/ChillMainBundle/Doctrine/DQL/Least.php +++ b/src/Bundle/ChillMainBundle/Doctrine/DQL/Least.php @@ -33,7 +33,7 @@ class Least extends FunctionNode public function getSql(SqlWalker $sqlWalker) { - return 'LEAST(' . implode(', ', array_map(static fn(Node $expr) => $expr->dispatch($sqlWalker), $this->exprs)) . ')'; + return 'LEAST(' . implode(', ', array_map(static fn (Node $expr) => $expr->dispatch($sqlWalker), $this->exprs)) . ')'; } public function parse(Parser $parser) diff --git a/src/Bundle/ChillMainBundle/Entity/PermissionsGroup.php b/src/Bundle/ChillMainBundle/Entity/PermissionsGroup.php index 34e22d3e1..6c0d0be5b 100644 --- a/src/Bundle/ChillMainBundle/Entity/PermissionsGroup.php +++ b/src/Bundle/ChillMainBundle/Entity/PermissionsGroup.php @@ -121,7 +121,7 @@ class PermissionsGroup public function isRoleScopePresentOnce(ExecutionContextInterface $context) { $roleScopesId = array_map( - static fn(RoleScope $roleScope) => $roleScope->getId(), + static fn (RoleScope $roleScope) => $roleScope->getId(), $this->getRoleScopes()->toArray() ); $countedIds = array_count_values($roleScopesId); diff --git a/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStep.php b/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStep.php index f94a154db..1f3070eb2 100644 --- a/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStep.php +++ b/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStep.php @@ -291,7 +291,7 @@ class EntityWorkflowStep public function removeDestEmail(string $email): self { - $this->destEmail = array_filter($this->destEmail, static fn(string $existing) => $email !== $existing); + $this->destEmail = array_filter($this->destEmail, static fn (string $existing) => $email !== $existing); return $this; } diff --git a/src/Bundle/ChillMainBundle/Export/Formatter/CSVListFormatter.php b/src/Bundle/ChillMainBundle/Export/Formatter/CSVListFormatter.php index a6b7094e4..b84c80118 100644 --- a/src/Bundle/ChillMainBundle/Export/Formatter/CSVListFormatter.php +++ b/src/Bundle/ChillMainBundle/Export/Formatter/CSVListFormatter.php @@ -199,7 +199,7 @@ class CSVListFormatter implements FormatterInterface foreach ($keys as $key) { // get an array with all values for this key if possible - $values = array_map(static fn($v) => $v[$key], $this->result); + $values = array_map(static fn ($v) => $v[$key], $this->result); // store the label in the labelsCache property $this->labelsCache[$key] = $export->getLabels($key, $values, $this->exportData); } diff --git a/src/Bundle/ChillMainBundle/Export/Formatter/CSVPivotedListFormatter.php b/src/Bundle/ChillMainBundle/Export/Formatter/CSVPivotedListFormatter.php index 87814eb47..63d691443 100644 --- a/src/Bundle/ChillMainBundle/Export/Formatter/CSVPivotedListFormatter.php +++ b/src/Bundle/ChillMainBundle/Export/Formatter/CSVPivotedListFormatter.php @@ -187,7 +187,7 @@ class CSVPivotedListFormatter implements FormatterInterface foreach ($keys as $key) { // get an array with all values for this key if possible - $values = array_map(static fn($v) => $v[$key], $this->result); + $values = array_map(static fn ($v) => $v[$key], $this->result); // store the label in the labelsCache property $this->labelsCache[$key] = $export->getLabels($key, $values, $this->exportData); } diff --git a/src/Bundle/ChillMainBundle/Export/Helper/ExportAddressHelper.php b/src/Bundle/ChillMainBundle/Export/Helper/ExportAddressHelper.php index 99f78fe80..fca338a6f 100644 --- a/src/Bundle/ChillMainBundle/Export/Helper/ExportAddressHelper.php +++ b/src/Bundle/ChillMainBundle/Export/Helper/ExportAddressHelper.php @@ -257,7 +257,7 @@ class ExportAddressHelper $prefixes = array_merge( $prefixes, array_map( - static fn($item) => $prefix . $item, + static fn ($item) => $prefix . $item, self::COLUMN_MAPPING[$key] ) ); diff --git a/src/Bundle/ChillMainBundle/Form/ChoiceLoader/PostalCodeChoiceLoader.php b/src/Bundle/ChillMainBundle/Form/ChoiceLoader/PostalCodeChoiceLoader.php index 99fb54514..174fb3304 100644 --- a/src/Bundle/ChillMainBundle/Form/ChoiceLoader/PostalCodeChoiceLoader.php +++ b/src/Bundle/ChillMainBundle/Form/ChoiceLoader/PostalCodeChoiceLoader.php @@ -48,7 +48,7 @@ class PostalCodeChoiceLoader implements ChoiceLoaderInterface { return new \Symfony\Component\Form\ChoiceList\ArrayChoiceList( $this->lazyLoadedPostalCodes, - static fn(?PostalCode $pc = null) => call_user_func($value, $pc) + static fn (?PostalCode $pc = null) => call_user_func($value, $pc) ); } diff --git a/src/Bundle/ChillMainBundle/Form/DataMapper/ExportPickCenterDataMapper.php b/src/Bundle/ChillMainBundle/Form/DataMapper/ExportPickCenterDataMapper.php index 90c919f1d..01303bfbb 100644 --- a/src/Bundle/ChillMainBundle/Form/DataMapper/ExportPickCenterDataMapper.php +++ b/src/Bundle/ChillMainBundle/Form/DataMapper/ExportPickCenterDataMapper.php @@ -37,7 +37,7 @@ class ExportPickCenterDataMapper implements DataMapperInterface foreach ($this->regroupmentRepository->findAll() as $regroupment) { /** @phpstan-ignore-next-line */ - [$contained, $notContained] = $regroupment->getCenters()->partition(static fn(Center $center): bool => false); + [$contained, $notContained] = $regroupment->getCenters()->partition(static fn (Center $center): bool => false); if (0 === count($notContained)) { $pickedRegroupment[] = $regroupment; diff --git a/src/Bundle/ChillMainBundle/Form/DataTransformer/IdToEntityDataTransformer.php b/src/Bundle/ChillMainBundle/Form/DataTransformer/IdToEntityDataTransformer.php index 4d89f7851..6aa5eee40 100644 --- a/src/Bundle/ChillMainBundle/Form/DataTransformer/IdToEntityDataTransformer.php +++ b/src/Bundle/ChillMainBundle/Form/DataTransformer/IdToEntityDataTransformer.php @@ -42,7 +42,7 @@ class IdToEntityDataTransformer implements DataTransformerInterface { $this->repository = $repository; $this->multiple = $multiple; - $this->getId = $getId ?? static fn(object $o) => $o->getId(); + $this->getId = $getId ?? static fn (object $o) => $o->getId(); } /** diff --git a/src/Bundle/ChillMainBundle/Form/LocationFormType.php b/src/Bundle/ChillMainBundle/Form/LocationFormType.php index 3cf599a52..ff2c563d3 100644 --- a/src/Bundle/ChillMainBundle/Form/LocationFormType.php +++ b/src/Bundle/ChillMainBundle/Form/LocationFormType.php @@ -36,11 +36,11 @@ final class LocationFormType extends AbstractType $builder ->add('locationType', EntityType::class, [ 'class' => EntityLocationType::class, - 'choice_attr' => static fn(EntityLocationType $entity) => [ + 'choice_attr' => static fn (EntityLocationType $entity) => [ 'data-address' => $entity->getAddressRequired(), 'data-contact' => $entity->getContactData(), ], - 'choice_label' => fn(EntityLocationType $entity) => $this->translatableStringHelper->localize($entity->getTitle()), + 'choice_label' => fn (EntityLocationType $entity) => $this->translatableStringHelper->localize($entity->getTitle()), ]) ->add('name', TextType::class) ->add('phonenumber1', ChillPhoneNumberType::class, ['required' => false]) diff --git a/src/Bundle/ChillMainBundle/Form/Type/ComposedGroupCenterType.php b/src/Bundle/ChillMainBundle/Form/Type/ComposedGroupCenterType.php index fdd24eb3f..48bd37dcc 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/ComposedGroupCenterType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/ComposedGroupCenterType.php @@ -24,10 +24,10 @@ class ComposedGroupCenterType extends AbstractType { $builder->add('permissionsgroup', EntityType::class, [ 'class' => \Chill\MainBundle\Entity\PermissionsGroup::class, - 'choice_label' => static fn(PermissionsGroup $group) => $group->getName(), + 'choice_label' => static fn (PermissionsGroup $group) => $group->getName(), ])->add('center', EntityType::class, [ 'class' => \Chill\MainBundle\Entity\Center::class, - 'choice_label' => static fn(Center $center) => $center->getName(), + 'choice_label' => static fn (Center $center) => $center->getName(), ]); } diff --git a/src/Bundle/ChillMainBundle/Form/Type/ComposedRoleScopeType.php b/src/Bundle/ChillMainBundle/Form/Type/ComposedRoleScopeType.php index 4424cccf3..970787cd1 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/ComposedRoleScopeType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/ComposedRoleScopeType.php @@ -82,11 +82,11 @@ class ComposedRoleScopeType extends AbstractType return ['data-has-scope' => '1']; }, - 'group_by' => fn($role, $key, $index) => $this->roleProvider->getRoleTitle($role), + 'group_by' => fn ($role, $key, $index) => $this->roleProvider->getRoleTitle($role), ]) ->add('scope', EntityType::class, [ 'class' => Scope::class, - 'choice_label' => static fn(Scope $scope) => $translatableStringHelper->localize($scope->getName()), + 'choice_label' => static fn (Scope $scope) => $translatableStringHelper->localize($scope->getName()), 'required' => false, 'data' => null, ]); diff --git a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php index 24e3ffc5b..529bd9789 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php +++ b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php @@ -51,7 +51,7 @@ class EntityToJsonTransformer implements DataTransformerInterface } return array_map( - fn($item) => $this->denormalizeOne($item), + fn ($item) => $this->denormalizeOne($item), $denormalized ); } diff --git a/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php b/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php index 7a1ebcaf5..c89907cf3 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php @@ -67,7 +67,7 @@ final class PickCenterType extends AbstractType 'choices' => $centers, 'multiple' => true, 'expanded' => true, - 'choice_label' => static fn(Center $c) => $c->getName(), + 'choice_label' => static fn (Center $c) => $c->getName(), 'data' => $centers, ]); @@ -78,7 +78,7 @@ final class PickCenterType extends AbstractType 'multiple' => true, 'expanded' => true, 'choices' => $this->regroupmentRepository->findAllActive(), - 'choice_label' => static fn(Regroupment $r) => $r->getName(), + 'choice_label' => static fn (Regroupment $r) => $r->getName(), ]); } diff --git a/src/Bundle/ChillMainBundle/Form/Type/PickCenterType.php b/src/Bundle/ChillMainBundle/Form/Type/PickCenterType.php index b977dd102..83e957623 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PickCenterType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PickCenterType.php @@ -90,7 +90,7 @@ class PickCenterType extends AbstractType return ['center' => $data]; }, - static fn($data) => $data['center'] + static fn ($data) => $data['center'] )); } diff --git a/src/Bundle/ChillMainBundle/Form/Type/PickCivilityType.php b/src/Bundle/ChillMainBundle/Form/Type/PickCivilityType.php index c5e0f7d80..adb0f2a67 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PickCivilityType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PickCivilityType.php @@ -34,11 +34,11 @@ class PickCivilityType extends AbstractType ->setDefault('label', 'Civility') ->setDefault( 'choice_label', - fn(Civility $civility): string => $this->translatableStringHelper->localize($civility->getName()) + fn (Civility $civility): string => $this->translatableStringHelper->localize($civility->getName()) ) ->setDefault( 'query_builder', - static fn(EntityRepository $er): QueryBuilder => $er->createQueryBuilder('c') + static fn (EntityRepository $er): QueryBuilder => $er->createQueryBuilder('c') ->where('c.active = true') ->orderBy('c.order'), ) diff --git a/src/Bundle/ChillMainBundle/Form/Type/PickLocationTypeType.php b/src/Bundle/ChillMainBundle/Form/Type/PickLocationTypeType.php index 0763e485e..3d993c9f1 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PickLocationTypeType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PickLocationTypeType.php @@ -31,7 +31,7 @@ class PickLocationTypeType extends AbstractType $resolver ->setDefaults([ 'class' => LocationType::class, - 'choice_label' => fn(LocationType $type) => $this->translatableStringHelper->localize($type->getTitle()), + 'choice_label' => fn (LocationType $type) => $this->translatableStringHelper->localize($type->getTitle()), 'placeholder' => 'Pick a location type', 'required' => false, 'attr' => ['class' => 'select2'], diff --git a/src/Bundle/ChillMainBundle/Form/Type/PickUserLocationType.php b/src/Bundle/ChillMainBundle/Form/Type/PickUserLocationType.php index bd19e5f29..d78957f29 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PickUserLocationType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PickUserLocationType.php @@ -36,7 +36,7 @@ class PickUserLocationType extends AbstractType ->setDefaults([ 'class' => Location::class, 'choices' => $this->locationRepository->findByPublicLocations(), - 'choice_label' => fn(Location $entity) => $entity->getName() ? + 'choice_label' => fn (Location $entity) => $entity->getName() ? $entity->getName() . ' (' . $this->translatableStringHelper->localize($entity->getLocationType()->getTitle()) . ')' : $this->translatableStringHelper->localize($entity->getLocationType()->getTitle()), 'placeholder' => 'Pick a location', diff --git a/src/Bundle/ChillMainBundle/Form/Type/PostalCodeType.php b/src/Bundle/ChillMainBundle/Form/Type/PostalCodeType.php index a611f3da9..51a321be6 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PostalCodeType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PostalCodeType.php @@ -77,7 +77,7 @@ class PostalCodeType extends AbstractType $helper = $this->translatableStringHelper; $resolver ->setDefault('class', PostalCode::class) - ->setDefault('choice_label', static fn(PostalCode $code) => $code->getCode() . ' ' . $code->getName() . ' [' . + ->setDefault('choice_label', static fn (PostalCode $code) => $code->getCode() . ' ' . $code->getName() . ' [' . $helper->localize($code->getCountry()->getName()) . ']') ->setDefault('choice_loader', $this->choiceLoader) ->setDefault('placeholder', 'Select a postal code'); diff --git a/src/Bundle/ChillMainBundle/Form/Type/ScopePickerType.php b/src/Bundle/ChillMainBundle/Form/Type/ScopePickerType.php index 77bf84cca..4d04b9f03 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/ScopePickerType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/ScopePickerType.php @@ -66,7 +66,7 @@ class ScopePickerType extends AbstractType $options['role'] instanceof Role ? $options['role']->getRole() : $options['role'], $options['center'] ), - static fn(Scope $s) => $s->isActive() + static fn (Scope $s) => $s->isActive() ); if (0 === count($items)) { @@ -77,7 +77,7 @@ class ScopePickerType extends AbstractType $builder->add('scope', EntityType::class, [ 'class' => Scope::class, 'placeholder' => 'Choose the circle', - 'choice_label' => fn(Scope $c) => $this->translatableStringHelper->localize($c->getName()), + 'choice_label' => fn (Scope $c) => $this->translatableStringHelper->localize($c->getName()), 'choices' => $items, ]); $builder->setDataMapper(new ScopePickerDataMapper()); diff --git a/src/Bundle/ChillMainBundle/Form/Type/UserPickerType.php b/src/Bundle/ChillMainBundle/Form/Type/UserPickerType.php index 974ef4566..c430a1053 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/UserPickerType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/UserPickerType.php @@ -79,7 +79,7 @@ class UserPickerType extends AbstractType ->setAllowedTypes('having_permissions_group_flag', ['string', 'null']) ->setDefault('class', User::class) ->setDefault('placeholder', 'Choose an user') - ->setDefault('choice_label', fn(User $u) => $this->userRender->renderString($u, [])) + ->setDefault('choice_label', fn (User $u) => $this->userRender->renderString($u, [])) ->setDefault('scope', null) ->setAllowedTypes('scope', [Scope::class, 'array', 'null']) ->setNormalizer('choices', function (Options $options) { diff --git a/src/Bundle/ChillMainBundle/Form/UserType.php b/src/Bundle/ChillMainBundle/Form/UserType.php index e343b0fc4..f8485aa99 100644 --- a/src/Bundle/ChillMainBundle/Form/UserType.php +++ b/src/Bundle/ChillMainBundle/Form/UserType.php @@ -77,14 +77,14 @@ class UserType extends AbstractType 'required' => false, 'placeholder' => 'Choose a main scope', 'class' => Scope::class, - 'choice_label' => fn(Scope $c) => $this->translatableStringHelper->localize($c->getName()), + 'choice_label' => fn (Scope $c) => $this->translatableStringHelper->localize($c->getName()), ]) ->add('userJob', EntityType::class, [ 'label' => 'user job', 'required' => false, 'placeholder' => 'choose a job', 'class' => UserJob::class, - 'choice_label' => fn(UserJob $c) => $this->translatableStringHelper->localize($c->getLabel()), + 'choice_label' => fn (UserJob $c) => $this->translatableStringHelper->localize($c->getLabel()), 'query_builder' => static function (EntityRepository $er) { $qb = $er->createQueryBuilder('uj'); $qb->where('uj.active = TRUE'); @@ -97,7 +97,7 @@ class UserType extends AbstractType 'required' => false, 'placeholder' => 'choose a location', 'class' => Location::class, - 'choice_label' => fn(Location $l) => $this->translatableStringHelper->localize($l->getLocationType()->getTitle()) . ' - ' . $l->getName(), + 'choice_label' => fn (Location $l) => $this->translatableStringHelper->localize($l->getLocationType()->getTitle()) . ' - ' . $l->getName(), 'query_builder' => static function (EntityRepository $er) { $qb = $er->createQueryBuilder('l'); $qb->orderBy('l.locationType'); diff --git a/src/Bundle/ChillMainBundle/Form/WorkflowStepType.php b/src/Bundle/ChillMainBundle/Form/WorkflowStepType.php index 0e6e12b3e..b3d498610 100644 --- a/src/Bundle/ChillMainBundle/Form/WorkflowStepType.php +++ b/src/Bundle/ChillMainBundle/Form/WorkflowStepType.php @@ -69,7 +69,7 @@ class WorkflowStepType extends AbstractType $choices = array_combine( array_map( - static fn(Transition $transition) => $transition->getName(), + static fn (Transition $transition) => $transition->getName(), $transitions ), $transitions @@ -86,8 +86,8 @@ class WorkflowStepType extends AbstractType 'backward' => 'backward', 'neutral' => 'neutral', ], - 'choice_label' => fn(string $key) => $this->translatableStringHelper->localize($inputLabels[$key]), - 'choice_attr' => static fn(string $key) => [ + 'choice_label' => fn (string $key) => $this->translatableStringHelper->localize($inputLabels[$key]), + 'choice_attr' => static fn (string $key) => [ $key => $key, ], 'mapped' => false, diff --git a/src/Bundle/ChillMainBundle/Search/SearchProvider.php b/src/Bundle/ChillMainBundle/Search/SearchProvider.php index e96f531e2..7ebb5ed87 100644 --- a/src/Bundle/ChillMainBundle/Search/SearchProvider.php +++ b/src/Bundle/ChillMainBundle/Search/SearchProvider.php @@ -90,7 +90,7 @@ class SearchProvider public function getByOrder() { //sort the array - uasort($this->searchServices, static fn(SearchInterface $a, SearchInterface $b) => $a->getOrder() <=> $b->getOrder()); + uasort($this->searchServices, static fn (SearchInterface $a, SearchInterface $b) => $a->getOrder() <=> $b->getOrder()); return $this->searchServices; } diff --git a/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceBEFromBestAddress.php b/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceBEFromBestAddress.php index a52379faa..c06ded0a8 100644 --- a/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceBEFromBestAddress.php +++ b/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceBEFromBestAddress.php @@ -54,7 +54,7 @@ class AddressReferenceBEFromBestAddress throw new RuntimeException('could not get the release definition', 0, $e); } - $asset = array_filter($release['assets'], static fn(array $item) => 'addresses-' . $list . '.' . $lang . '.csv.gz' === $item['name']); + $asset = array_filter($release['assets'], static fn (array $item) => 'addresses-' . $list . '.' . $lang . '.csv.gz' === $item['name']); return array_values($asset)[0]['browser_download_url']; } diff --git a/src/Bundle/ChillMainBundle/Service/Import/PostalCodeBEFromBestAddress.php b/src/Bundle/ChillMainBundle/Service/Import/PostalCodeBEFromBestAddress.php index 4bca126a6..aa04c9ac3 100644 --- a/src/Bundle/ChillMainBundle/Service/Import/PostalCodeBEFromBestAddress.php +++ b/src/Bundle/ChillMainBundle/Service/Import/PostalCodeBEFromBestAddress.php @@ -82,7 +82,7 @@ class PostalCodeBEFromBestAddress throw new RuntimeException('could not get the release definition', 0, $e); } - $postals = array_filter($release['assets'], static fn(array $item) => 'postals.' . $lang . '.csv.gz' === $item['name']); + $postals = array_filter($release['assets'], static fn (array $item) => 'postals.' . $lang . '.csv.gz' === $item['name']); return array_values($postals)[0]['browser_download_url']; } diff --git a/src/Bundle/ChillMainBundle/Service/Mailer/ChillMailer.php b/src/Bundle/ChillMainBundle/Service/Mailer/ChillMailer.php index c6246213f..36374c6af 100644 --- a/src/Bundle/ChillMainBundle/Service/Mailer/ChillMailer.php +++ b/src/Bundle/ChillMainBundle/Service/Mailer/ChillMailer.php @@ -39,7 +39,7 @@ class ChillMailer implements MailerInterface } $this->chillLogger->info('chill email sent', [ - 'to' => array_map(static fn(Address $address) => $address->getAddress(), $message->getTo()), + 'to' => array_map(static fn (Address $address) => $address->getAddress(), $message->getTo()), 'subject' => $message->getSubject(), ]); diff --git a/src/Bundle/ChillMainBundle/Tests/Entity/NotificationTest.php b/src/Bundle/ChillMainBundle/Tests/Entity/NotificationTest.php index 051d04591..d641b94a8 100644 --- a/src/Bundle/ChillMainBundle/Tests/Entity/NotificationTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Entity/NotificationTest.php @@ -134,7 +134,7 @@ final class NotificationTest extends KernelTestCase $this->assertEquals($senderId, $notification->getSender()->getId()); $this->assertCount(count($addressesIds), $notification->getUnreadBy()); - $unreadIds = $notification->getUnreadBy()->map(static fn(User $u) => $u->getId()); + $unreadIds = $notification->getUnreadBy()->map(static fn (User $u) => $u->getId()); foreach ($addressesIds as $addresseeId) { $this->assertContains($addresseeId, $unreadIds); diff --git a/src/Bundle/ChillMainBundle/Tests/Form/Type/ScopePickerTypeTest.php b/src/Bundle/ChillMainBundle/Tests/Form/Type/ScopePickerTypeTest.php index 42f6d71d8..0e37f0fde 100644 --- a/src/Bundle/ChillMainBundle/Tests/Form/Type/ScopePickerTypeTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Form/Type/ScopePickerTypeTest.php @@ -96,7 +96,7 @@ final class ScopePickerTypeTest extends TypeTestCase $translatableStringHelper = $this->prophesize(TranslatableStringHelperInterface::class); $translatableStringHelper->localize(Argument::type('array'))->will( - static fn($args) => $args[0]['fr'] + static fn ($args) => $args[0]['fr'] ); $type = new ScopePickerType( diff --git a/src/Bundle/ChillMainBundle/Tests/Search/Utils/ExtractDateFromPatternTest.php b/src/Bundle/ChillMainBundle/Tests/Search/Utils/ExtractDateFromPatternTest.php index 5f79494a3..49419f261 100644 --- a/src/Bundle/ChillMainBundle/Tests/Search/Utils/ExtractDateFromPatternTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Search/Utils/ExtractDateFromPatternTest.php @@ -52,7 +52,7 @@ final class ExtractDateFromPatternTest extends TestCase $this->assertContainsOnlyInstancesOf(DateTimeImmutable::class, $result->getFound()); $dates = array_map( - static fn(DateTimeImmutable $d) => $d->format('Y-m-d'), + static fn (DateTimeImmutable $d) => $d->format('Y-m-d'), $result->getFound() ); diff --git a/src/Bundle/ChillMainBundle/Tests/Security/Authorization/AuthorizationHelperTest.php b/src/Bundle/ChillMainBundle/Tests/Security/Authorization/AuthorizationHelperTest.php index 657e37e36..8c681bfb0 100644 --- a/src/Bundle/ChillMainBundle/Tests/Security/Authorization/AuthorizationHelperTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Security/Authorization/AuthorizationHelperTest.php @@ -211,7 +211,7 @@ final class AuthorizationHelperTest extends KernelTestCase $centerA ); - $usernames = array_map(static fn(User $u) => $u->getUsername(), $users); + $usernames = array_map(static fn (User $u) => $u->getUsername(), $users); $this->assertContains('center a_social', $usernames); } diff --git a/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/EntityWorkflowTransitionEventSubscriber.php b/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/EntityWorkflowTransitionEventSubscriber.php index dfe47ecc8..f3e04eeca 100644 --- a/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/EntityWorkflowTransitionEventSubscriber.php +++ b/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/EntityWorkflowTransitionEventSubscriber.php @@ -105,7 +105,7 @@ class EntityWorkflowTransitionEventSubscriber implements EventSubscriberInterfac [ '%users%' => implode( ', ', - $entityWorkflow->getCurrentStep()->getAllDestUser()->map(fn(User $u) => $this->userRender->renderString($u, []))->toArray() + $entityWorkflow->getCurrentStep()->getAllDestUser()->map(fn (User $u) => $this->userRender->renderString($u, []))->toArray() ), ] )); diff --git a/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/NotificationOnTransition.php b/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/NotificationOnTransition.php index dc9657e3c..76ad4a4b0 100644 --- a/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/NotificationOnTransition.php +++ b/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/NotificationOnTransition.php @@ -109,7 +109,7 @@ class NotificationOnTransition implements EventSubscriberInterface 'dest' => $subscriber, 'place' => $place, 'workflow' => $workflow, - 'is_dest' => in_array($subscriber->getId(), array_map(static fn(User $u) => $u->getId(), $entityWorkflow->futureDestUsers), true), + 'is_dest' => in_array($subscriber->getId(), array_map(static fn (User $u) => $u->getId(), $entityWorkflow->futureDestUsers), true), ]; $notification = new Notification(); diff --git a/src/Bundle/ChillMainBundle/Workflow/Validator/EntityWorkflowCreationValidator.php b/src/Bundle/ChillMainBundle/Workflow/Validator/EntityWorkflowCreationValidator.php index 6ab44f625..bb3586251 100644 --- a/src/Bundle/ChillMainBundle/Workflow/Validator/EntityWorkflowCreationValidator.php +++ b/src/Bundle/ChillMainBundle/Workflow/Validator/EntityWorkflowCreationValidator.php @@ -59,7 +59,7 @@ class EntityWorkflowCreationValidator extends \Symfony\Component\Validator\Const $workflows = $this->entityWorkflowManager->getSupportedWorkflows($value); - $matched = array_filter($workflows, static fn(WorkflowInterface $workflow) => $workflow->getName() === $value->getWorkflowName()); + $matched = array_filter($workflows, static fn (WorkflowInterface $workflow) => $workflow->getName() === $value->getWorkflowName()); if (0 === count($matched)) { $this->context->buildViolation($constraint->messageWorkflowNotAvailable) diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php index d7289c68a..181f60a02 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php @@ -169,7 +169,7 @@ final class AccompanyingCourseApiController extends ApiController $accompanyingPeriods = $person->getCurrentAccompanyingPeriods(); $accompanyingPeriodsChecked = array_filter( $accompanyingPeriods, - fn(AccompanyingPeriod $period) => $this->isGranted(AccompanyingPeriodVoter::SEE, $period) + fn (AccompanyingPeriod $period) => $this->isGranted(AccompanyingPeriodVoter::SEE, $period) ); return $this->json(array_values($accompanyingPeriodsChecked), Response::HTTP_OK, [], ['groups' => ['read']]); diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodController.php index 18098a129..b32454387 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodController.php @@ -222,10 +222,10 @@ class AccompanyingPeriodController extends AbstractController $accompanyingPeriodsRaw = $this->accompanyingPeriodACLAwareRepository ->findByPerson($person, AccompanyingPeriodVoter::SEE); - usort($accompanyingPeriodsRaw, static fn($a, $b) => $b->getOpeningDate() > $a->getOpeningDate()); + usort($accompanyingPeriodsRaw, static fn ($a, $b) => $b->getOpeningDate() > $a->getOpeningDate()); // filter visible or not visible - $accompanyingPeriods = array_filter($accompanyingPeriodsRaw, fn(AccompanyingPeriod $ap) => $this->isGranted(AccompanyingPeriodVoter::SEE, $ap)); + $accompanyingPeriods = array_filter($accompanyingPeriodsRaw, fn (AccompanyingPeriod $ap) => $this->isGranted(AccompanyingPeriodVoter::SEE, $ap)); return $this->render('@ChillPerson/AccompanyingPeriod/list.html.twig', [ 'accompanying_periods' => $accompanyingPeriods, @@ -327,7 +327,7 @@ class AccompanyingPeriodController extends AbstractController /** @var AccompanyingPeriod $period */ $period = array_filter( $person->getAccompanyingPeriods(), - static fn(AccompanyingPeriod $p) => $p->getId() === ($period_id) + static fn (AccompanyingPeriod $p) => $p->getId() === ($period_id) )[0] ?? null; if (null === $period) { diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodRegulationListController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodRegulationListController.php index ced5ccd9d..6bbb6c368 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodRegulationListController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodRegulationListController.php @@ -105,8 +105,8 @@ class AccompanyingPeriodRegulationListController $builder ->add('services', EntityType::class, [ 'class' => Scope::class, - 'query_builder' => static fn(EntityRepository $er) => $er->createQueryBuilder('s'), - 'choice_label' => fn(Scope $s) => $this->translatableStringHelper->localize($s->getName()), + 'query_builder' => static fn (EntityRepository $er) => $er->createQueryBuilder('s'), + 'choice_label' => fn (Scope $s) => $this->translatableStringHelper->localize($s->getName()), 'multiple' => true, 'label' => 'Service', 'required' => false, @@ -119,7 +119,7 @@ class AccompanyingPeriodRegulationListController return $qb; }, - 'choice_label' => fn(UserJob $j) => $this->translatableStringHelper->localize($j->getLabel()), + 'choice_label' => fn (UserJob $j) => $this->translatableStringHelper->localize($j->getLabel()), 'multiple' => true, 'label' => 'Métier', 'required' => false, @@ -141,7 +141,7 @@ class AccompanyingPeriodRegulationListController return $qb; }, - 'choice_label' => static fn(Location $l) => $l->getName(), + 'choice_label' => static fn (Location $l) => $l->getName(), 'multiple' => true, 'group_by' => function (Location $l) { if (null === $type = $l->getLocationType()) { diff --git a/src/Bundle/ChillPersonBundle/Controller/HouseholdCompositionController.php b/src/Bundle/ChillPersonBundle/Controller/HouseholdCompositionController.php index 98fa0ebfe..61e030322 100644 --- a/src/Bundle/ChillPersonBundle/Controller/HouseholdCompositionController.php +++ b/src/Bundle/ChillPersonBundle/Controller/HouseholdCompositionController.php @@ -164,7 +164,7 @@ class HouseholdCompositionController extends AbstractController $isEdit = $request->query->has('edit'); if ($isEdit) { - $householdCompositions = $household->getCompositions()->filter(static fn(HouseholdComposition $composition) => $composition->getId() === $request->query->getInt('edit')); + $householdCompositions = $household->getCompositions()->filter(static fn (HouseholdComposition $composition) => $composition->getId() === $request->query->getInt('edit')); if ($householdCompositions->count() !== 1) { throw new BadRequestHttpException('could not find the composition with this id associated to the household'); diff --git a/src/Bundle/ChillPersonBundle/Controller/HouseholdController.php b/src/Bundle/ChillPersonBundle/Controller/HouseholdController.php index 68f32c886..42092249b 100644 --- a/src/Bundle/ChillPersonBundle/Controller/HouseholdController.php +++ b/src/Bundle/ChillPersonBundle/Controller/HouseholdController.php @@ -81,7 +81,7 @@ class HouseholdController extends AbstractController } } - usort($accompanyingPeriods, static fn($a, $b) => $b->getOpeningDate() <=> $a->getOpeningDate()); + usort($accompanyingPeriods, static fn ($a, $b) => $b->getOpeningDate() <=> $a->getOpeningDate()); $oldMembers = $household->getNonCurrentMembers(); $accompanyingPeriodsOld = []; diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php b/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php index 35256ce56..505f307e6 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php @@ -108,10 +108,10 @@ class PersonApiController extends ApiController $addresses = $person ->getAccompanyingPeriodParticipations() ->filter( - static fn(AccompanyingPeriodParticipation $accompanyingPeriodParticipation): bool => null !== $accompanyingPeriodParticipation->getAccompanyingPeriod()->getAddressLocation() + static fn (AccompanyingPeriodParticipation $accompanyingPeriodParticipation): bool => null !== $accompanyingPeriodParticipation->getAccompanyingPeriod()->getAddressLocation() ) ->map( - static fn(AccompanyingPeriodParticipation $accompanyingPeriodParticipation): ?Address => $accompanyingPeriodParticipation->getAccompanyingPeriod()->getAddressLocation() + static fn (AccompanyingPeriodParticipation $accompanyingPeriodParticipation): ?Address => $accompanyingPeriodParticipation->getAccompanyingPeriod()->getAddressLocation() ) ->filter( // We remove potential null addresses. diff --git a/src/Bundle/ChillPersonBundle/Controller/SocialWorkSocialActionApiController.php b/src/Bundle/ChillPersonBundle/Controller/SocialWorkSocialActionApiController.php index 75293fd7b..4fe877a72 100644 --- a/src/Bundle/ChillPersonBundle/Controller/SocialWorkSocialActionApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/SocialWorkSocialActionApiController.php @@ -44,7 +44,7 @@ class SocialWorkSocialActionApiController extends ApiController $socialActions = $socialIssue->getRecursiveSocialActions()->toArray(); - usort($socialActions, static fn(SocialAction $sa, SocialAction $sb) => $sa->getOrdering() <=> $sb->getOrdering()); + usort($socialActions, static fn (SocialAction $sa, SocialAction $sb) => $sa->getOrdering() <=> $sb->getOrdering()); $pagination = $this->paginator->create(count($socialActions)); // max one page diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadCustomFields.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadCustomFields.php index fb5ae6e4e..78180adff 100644 --- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadCustomFields.php +++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadCustomFields.php @@ -115,7 +115,7 @@ class LoadCustomFields extends AbstractFixture implements // get possible values for cfGroup $choices = array_map( - static fn($a) => $a['slug'], + static fn ($a) => $a['slug'], $this->customFieldChoice->getOptions()['choices'] ); // create faker diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php index 364cb41d5..a0f6e7d7e 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php @@ -828,7 +828,7 @@ class AccompanyingPeriod implements $collection = $this ->getParticipationsContainsPerson($person) ->filter( - static fn(AccompanyingPeriodParticipation $participation): bool => null === $participation->getEndDate() + static fn (AccompanyingPeriodParticipation $participation): bool => null === $participation->getEndDate() ); return $collection->count() > 0 ? $collection->first() : null; @@ -842,7 +842,7 @@ class AccompanyingPeriod implements return $this ->getParticipations() ->filter( - static fn(AccompanyingPeriodParticipation $participation): bool => null === $participation->getEndDate() + static fn (AccompanyingPeriodParticipation $participation): bool => null === $participation->getEndDate() ); } diff --git a/src/Bundle/ChillPersonBundle/Entity/Household/Household.php b/src/Bundle/ChillPersonBundle/Entity/Household/Household.php index 2fa1df203..8a99c7eb4 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Household/Household.php +++ b/src/Bundle/ChillPersonBundle/Entity/Household/Household.php @@ -202,7 +202,7 @@ class Household { $at ??= new DateTime('today'); - $addrs = $this->getAddresses()->filter(static fn(Address $a) => $a->getValidFrom() <= $at && ( + $addrs = $this->getAddresses()->filter(static fn (Address $a) => $a->getValidFrom() <= $at && ( null === $a->getValidTo() || $a->getValidTo() > $at )); @@ -336,7 +336,7 @@ class Household public function getCurrentPersons(?DateTimeImmutable $now = null): ReadableCollection { return $this->getCurrentMembers($now) - ->map(static fn(HouseholdMember $m) => $m->getPerson()); + ->map(static fn (HouseholdMember $m) => $m->getPerson()); } public function getId(): ?int @@ -363,7 +363,7 @@ class Household $membership->getStartDate(), $membership->getEndDate() )->filter( - static fn(HouseholdMember $m) => $m->getPerson() !== $membership->getPerson() + static fn (HouseholdMember $m) => $m->getPerson() !== $membership->getPerson() ); } @@ -502,7 +502,7 @@ class Household usort( $compositionOrdered, - static fn(HouseholdComposition $a, HouseholdComposition $b) => $a->getStartDate() <=> $b->getStartDate() + static fn (HouseholdComposition $a, HouseholdComposition $b) => $a->getStartDate() <=> $b->getStartDate() ); $iterator = new ArrayIterator($compositionOrdered); diff --git a/src/Bundle/ChillPersonBundle/Entity/Person.php b/src/Bundle/ChillPersonBundle/Entity/Person.php index 1507bafd7..af8e7f92b 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person.php @@ -775,7 +775,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI ): int { // TODO should be optimized to avoid loading accompanying period ? return $this->getAccompanyingPeriodInvolved($asParticipantOpen, $asRequestor) - ->filter(fn(AccompanyingPeriod $p) => $p->getStep() !== AccompanyingPeriod::STEP_DRAFT) + ->filter(fn (AccompanyingPeriod $p) => $p->getStep() !== AccompanyingPeriod::STEP_DRAFT) ->count(); } @@ -1339,7 +1339,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI return $this->getAccompanyingPeriodParticipations() ->matching($criteria) - ->filter(static fn(AccompanyingPeriodParticipation $app) => AccompanyingPeriod::STEP_CLOSED !== $app->getAccompanyingPeriod()->getStep()); + ->filter(static fn (AccompanyingPeriodParticipation $app) => AccompanyingPeriod::STEP_CLOSED !== $app->getAccompanyingPeriod()->getStep()); } public function getOtherPhoneNumbers(): Collection diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php index c018eb95f..4ac96aac1 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php @@ -128,7 +128,7 @@ final class GeographicalUnitStatAggregator implements AggregatorInterface 'placeholder' => 'Select a geographical layer', 'class' => GeographicalUnitLayer::class, 'choices' => $this->geographicalUnitLayerRepository->findAllHavingUnits(), - 'choice_label' => fn(GeographicalUnitLayer $item) => $this->translatableStringHelper->localize($item->getName()), + 'choice_label' => fn (GeographicalUnitLayer $item) => $this->translatableStringHelper->localize($item->getName()), ]); } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/CountryOfBirthAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/CountryOfBirthAggregator.php index c2923c9e9..3d785b586 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/CountryOfBirthAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/CountryOfBirthAggregator.php @@ -147,7 +147,7 @@ final class CountryOfBirthAggregator implements AggregatorInterface, ExportEleme ]; } - return static fn(string $value): string => $labels[$value]; + return static fn (string $value): string => $labels[$value]; } public function getQueryKeys($data) diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GeographicalUnitAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GeographicalUnitAggregator.php index 1ab9f1b78..ff72994ba 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GeographicalUnitAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GeographicalUnitAggregator.php @@ -100,7 +100,7 @@ class GeographicalUnitAggregator implements AggregatorInterface 'placeholder' => 'Select a geographical layer', 'class' => GeographicalUnitLayer::class, 'choices' => $this->geographicalUnitLayerRepository->findAllHavingUnits(), - 'choice_label' => fn(GeographicalUnitLayer $item) => $this->translatableStringHelper->localize($item->getName()), + 'choice_label' => fn (GeographicalUnitLayer $item) => $this->translatableStringHelper->localize($item->getName()), ]); } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/NationalityAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/NationalityAggregator.php index b91a90000..d7c4097af 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/NationalityAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/NationalityAggregator.php @@ -141,7 +141,7 @@ final class NationalityAggregator implements AggregatorInterface, ExportElementV ]; } - return static fn($value): string => $labels[$value]; + return static fn ($value): string => $labels[$value]; } public function getQueryKeys($data) diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php b/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php index 7cb2e623f..978f88a10 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php @@ -64,7 +64,7 @@ class CountAccompanyingCourse implements ExportInterface, GroupedExportInterface $labels = array_combine($values, $values); $labels['_header'] = $this->getTitle(); - return static fn($value) => $labels[$value]; + return static fn ($value) => $labels[$value]; } public function getQueryKeys($data): array @@ -89,7 +89,7 @@ class CountAccompanyingCourse implements ExportInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []): QueryBuilder { - $centers = array_map(static fn($el) => $el['center'], $acl); + $centers = array_map(static fn ($el) => $el['center'], $acl); $qb = $this->repository->createQueryBuilder('acp'); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingPeriodWork.php b/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingPeriodWork.php index 412890241..122ee14d9 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingPeriodWork.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingPeriodWork.php @@ -63,7 +63,7 @@ class CountAccompanyingPeriodWork implements ExportInterface, GroupedExportInter $labels = array_combine($values, $values); $labels['_header'] = $this->getTitle(); - return static fn($value) => $labels[$value]; + return static fn ($value) => $labels[$value]; } public function getQueryKeys($data): array @@ -88,7 +88,7 @@ class CountAccompanyingPeriodWork implements ExportInterface, GroupedExportInter public function initiateQuery(array $requiredModifiers, array $acl, array $data = []): QueryBuilder { - $centers = array_map(static fn($el) => $el['center'], $acl); + $centers = array_map(static fn ($el) => $el['center'], $acl); $qb = $this->em->createQueryBuilder(); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php b/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php index 4efd7e246..1613b63d3 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php @@ -62,7 +62,7 @@ class CountEvaluation implements ExportInterface, GroupedExportInterface $labels = array_combine($values, $values); $labels['_header'] = $this->getTitle(); - return static fn($value) => $labels[$value]; + return static fn ($value) => $labels[$value]; } public function getQueryKeys($data): array @@ -87,7 +87,7 @@ class CountEvaluation implements ExportInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static fn($el) => $el['center'], $acl); + $centers = array_map(static fn ($el) => $el['center'], $acl); $qb = $this->entityManager->createQueryBuilder(); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php b/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php index 2b782d1ed..0b693b9d8 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php @@ -113,7 +113,7 @@ class CountHousehold implements ExportInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static fn($el) => $el['center'], $acl); + $centers = array_map(static fn ($el) => $el['center'], $acl); $qb = $this->entityManager->createQueryBuilder(); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountPerson.php b/src/Bundle/ChillPersonBundle/Export/Export/CountPerson.php index 528be42c8..60429ae55 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountPerson.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountPerson.php @@ -62,7 +62,7 @@ class CountPerson implements ExportInterface, GroupedExportInterface $labels = array_combine($values, $values); $labels['_header'] = $this->getTitle(); - return static fn($value) => $labels[$value]; + return static fn ($value) => $labels[$value]; } public function getQueryKeys($data) @@ -92,7 +92,7 @@ class CountPerson implements ExportInterface, GroupedExportInterface */ public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static fn($el) => $el['center'], $acl); + $centers = array_map(static fn ($el) => $el['center'], $acl); $qb = $this->personRepository->createQueryBuilder('person'); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountPersonWithAccompanyingCourse.php b/src/Bundle/ChillPersonBundle/Export/Export/CountPersonWithAccompanyingCourse.php index e58439112..e52cc83b1 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountPersonWithAccompanyingCourse.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountPersonWithAccompanyingCourse.php @@ -64,7 +64,7 @@ class CountPersonWithAccompanyingCourse implements ExportInterface, GroupedExpor $labels = array_combine($values, $values); $labels['_header'] = $this->getTitle(); - return static fn($value) => $labels[$value]; + return static fn ($value) => $labels[$value]; } public function getQueryKeys($data): array @@ -89,7 +89,7 @@ class CountPersonWithAccompanyingCourse implements ExportInterface, GroupedExpor public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static fn($el) => $el['center'], $acl); + $centers = array_map(static fn ($el) => $el['center'], $acl); $qb = $this->repository->createQueryBuilder('acp'); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php index 1bfd1870f..045039930 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php @@ -290,7 +290,7 @@ class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static fn($el) => $el['center'], $acl); + $centers = array_map(static fn ($el) => $el['center'], $acl); $qb = $this->entityManager->createQueryBuilder(); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriodWork.php b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriodWork.php index 17c2c4f99..00fa8adb1 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriodWork.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriodWork.php @@ -263,7 +263,7 @@ class ListAccompanyingPeriodWork implements ListInterface, GroupedExportInterfac public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static fn($el) => $el['center'], $acl); + $centers = array_map(static fn ($el) => $el['center'], $acl); $qb = $this->entityManager->createQueryBuilder(); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListEvaluation.php b/src/Bundle/ChillPersonBundle/Export/Export/ListEvaluation.php index 0f63d41ca..f0985436b 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListEvaluation.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListEvaluation.php @@ -241,7 +241,7 @@ class ListEvaluation implements ListInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static fn($el) => $el['center'], $acl); + $centers = array_map(static fn ($el) => $el['center'], $acl); $qb = $this->entityManager->createQueryBuilder(); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListHouseholdInPeriod.php b/src/Bundle/ChillPersonBundle/Export/Export/ListHouseholdInPeriod.php index d176f7bb8..24d929c00 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListHouseholdInPeriod.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListHouseholdInPeriod.php @@ -146,7 +146,7 @@ class ListHouseholdInPeriod implements ListInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static fn($el) => $el['center'], $acl); + $centers = array_map(static fn ($el) => $el['center'], $acl); $qb = $this->entityManager->createQueryBuilder(); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php b/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php index 322917b02..8145fd658 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php @@ -191,7 +191,7 @@ class ListPerson implements ExportElementValidatedInterface, ListInterface, Grou */ public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static fn($el) => $el['center'], $acl); + $centers = array_map(static fn ($el) => $el['center'], $acl); // throw an error if any fields are present if (!array_key_exists('fields', $data)) { diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriod.php index 35bb8a6c1..7cb066e87 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriod.php @@ -159,7 +159,7 @@ class ListPersonWithAccompanyingPeriod implements ExportElementValidatedInterfac */ public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static fn($el) => $el['center'], $acl); + $centers = array_map(static fn ($el) => $el['center'], $acl); // throw an error if any fields are present if (!array_key_exists('fields', $data)) { diff --git a/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php b/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php index 0c2fb63f5..31ca41cbb 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php @@ -112,7 +112,7 @@ class StatAccompanyingCourseDuration implements ExportInterface, GroupedExportIn public function initiateQuery(array $requiredModifiers, array $acl, array $data = []): QueryBuilder { - $centers = array_map(static fn($el) => $el['center'], $acl); + $centers = array_map(static fn ($el) => $el['center'], $acl); $qb = $this->repository->createQueryBuilder('acp'); diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ClosingMotiveFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ClosingMotiveFilter.php index 05c883309..e57370f30 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ClosingMotiveFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ClosingMotiveFilter.php @@ -59,7 +59,7 @@ class ClosingMotiveFilter implements FilterInterface { $builder->add('accepted_closingmotives', EntityType::class, [ 'class' => ClosingMotive::class, - 'choice_label' => fn(ClosingMotive $cm) => $this->translatableStringHelper->localize($cm->getName()), + 'choice_label' => fn (ClosingMotive $cm) => $this->translatableStringHelper->localize($cm->getName()), 'multiple' => true, 'expanded' => true, ]); diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorJobFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorJobFilter.php index 497068c39..f585cfafb 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorJobFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorJobFilter.php @@ -61,7 +61,7 @@ class CreatorJobFilter implements FilterInterface $builder->add('creator_job', EntityType::class, [ 'class' => UserJob::class, 'choices' => $this->userJobRepository->findAllActive(), - 'choice_label' => fn(UserJob $j) => $this->translatableStringHelper->localize( + 'choice_label' => fn (UserJob $j) => $this->translatableStringHelper->localize( $j->getLabel() ), 'multiple' => true, diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EvaluationFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EvaluationFilter.php index 7f409c022..ab7f4257e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EvaluationFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EvaluationFilter.php @@ -69,7 +69,7 @@ class EvaluationFilter implements FilterInterface $builder->add('accepted_evaluations', EntityType::class, [ 'class' => Evaluation::class, 'choices' => $this->evaluationRepository->findAllActive(), - 'choice_label' => fn(Evaluation $ev) => $this->translatableStringHelper->localize($ev->getTitle()), + 'choice_label' => fn (Evaluation $ev) => $this->translatableStringHelper->localize($ev->getTitle()), 'multiple' => true, 'expanded' => false, 'attr' => ['class' => 'select2'], diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php index 719029d38..d35565c80 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php @@ -107,7 +107,7 @@ class GeographicalUnitStatFilter implements FilterInterface 'placeholder' => 'Select a geographical unit', 'choices' => $this->geographicalUnitRepository->findAll(), 'choice_value' => static fn (SimpleGeographicalUnitDTO $item) => $item->id, - 'choice_label' => fn(SimpleGeographicalUnitDTO $item) => $this->translatableStringHelper->localize($this->geographicalUnitLayerRepository->find($item->layerId)->getName()) . ' > ' . $item->unitName, + 'choice_label' => fn (SimpleGeographicalUnitDTO $item) => $this->translatableStringHelper->localize($this->geographicalUnitLayerRepository->find($item->layerId)->getName()) . ' > ' . $item->unitName, 'attr' => [ 'class' => 'select2', ], @@ -122,7 +122,7 @@ class GeographicalUnitStatFilter implements FilterInterface '%units' => implode( ', ', array_map( - fn(SimpleGeographicalUnitDTO $item) => $this->translatableStringHelper->localize($this->geographicalUnitLayerRepository->find($item->layerId)->getName()) . ' > ' . $item->unitName, + fn (SimpleGeographicalUnitDTO $item) => $this->translatableStringHelper->localize($this->geographicalUnitLayerRepository->find($item->layerId)->getName()) . ' > ' . $item->unitName, $data['units'] ) ), diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OriginFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OriginFilter.php index bde641b2d..00febc640 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OriginFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OriginFilter.php @@ -59,7 +59,7 @@ class OriginFilter implements FilterInterface { $builder->add('accepted_origins', EntityType::class, [ 'class' => Origin::class, - 'choice_label' => fn(Origin $o) => $this->translatableStringHelper->localize($o->getLabel()), + 'choice_label' => fn (Origin $o) => $this->translatableStringHelper->localize($o->getLabel()), 'multiple' => true, 'expanded' => true, ]); diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/EvaluationTypeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/EvaluationTypeFilter.php index 15be1a52b..6a0c71d55 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/EvaluationTypeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/EvaluationTypeFilter.php @@ -59,7 +59,7 @@ final class EvaluationTypeFilter implements FilterInterface { $builder->add('accepted_evaluationtype', EntityType::class, [ 'class' => Evaluation::class, - 'choice_label' => fn(Evaluation $ev): string => $this->translatableStringHelper->localize($ev->getTitle()), + 'choice_label' => fn (Evaluation $ev): string => $this->translatableStringHelper->localize($ev->getTitle()), 'multiple' => true, 'expanded' => true, ]); diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/HouseholdFilters/CompositionFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/HouseholdFilters/CompositionFilter.php index 7eb00fc2b..22761c158 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/HouseholdFilters/CompositionFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/HouseholdFilters/CompositionFilter.php @@ -78,7 +78,7 @@ class CompositionFilter implements FilterInterface $builder ->add('accepted_composition', EntityType::class, [ 'class' => HouseholdCompositionType::class, - 'choice_label' => fn(HouseholdCompositionType $type) => $this->translatableStringHelper->localize( + 'choice_label' => fn (HouseholdCompositionType $type) => $this->translatableStringHelper->localize( $type->getLabel() ), 'multiple' => true, diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AddressRefStatusFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AddressRefStatusFilter.php index 5ecdc1fda..7580a37a3 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AddressRefStatusFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AddressRefStatusFilter.php @@ -81,7 +81,7 @@ class AddressRefStatusFilter implements \Chill\MainBundle\Export\FilterInterface ->add('ref_statuses', ChoiceType::class, [ 'label' => 'export.filter.person.by_address_ref_status.Status', 'choices' => [Address::ADDR_REFERENCE_STATUS_TO_REVIEW, Address::ADDR_REFERENCE_STATUS_REVIEWED, Address::ADDR_REFERENCE_STATUS_MATCH], - 'choice_label' => fn(string $item) => 'export.filter.person.by_address_ref_status.'.$item, + 'choice_label' => fn (string $item) => 'export.filter.person.by_address_ref_status.'.$item, 'multiple' => true, 'expanded' => true, 'data' => [Address::ADDR_REFERENCE_STATUS_TO_REVIEW] @@ -97,7 +97,7 @@ class AddressRefStatusFilter implements \Chill\MainBundle\Export\FilterInterface '%statuses%' => implode( ', ', array_map( - fn(string $item) => 'export.filter.person.by_address_ref_status.'.$item, + fn (string $item) => 'export.filter.person.by_address_ref_status.'.$item, $data['ref_statuses'] ?? RollingDate::T_TODAY ) ), diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GenderFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GenderFilter.php index 92b8ad08b..739945b98 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GenderFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GenderFilter.php @@ -67,7 +67,7 @@ class GenderFilter implements $qb->add('where', $where); $qb->setParameter('person_gender', array_filter( $data['accepted_genders'], - static fn($el) => 'null' !== $el + static fn ($el) => 'null' !== $el )); } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GeographicalUnitFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GeographicalUnitFilter.php index 15882b705..79f5cb2d4 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GeographicalUnitFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GeographicalUnitFilter.php @@ -98,7 +98,7 @@ class GeographicalUnitFilter implements \Chill\MainBundle\Export\FilterInterface 'placeholder' => 'Select a geographical unit', 'choices' => $this->geographicalUnitRepository->findAll(), 'choice_value' => static fn (SimpleGeographicalUnitDTO $item) => $item->id, - 'choice_label' => fn(SimpleGeographicalUnitDTO $item) => $this->translatableStringHelper->localize($this->geographicalUnitLayerRepository->find($item->layerId)->getName()) . ' > ' . $item->unitName, + 'choice_label' => fn (SimpleGeographicalUnitDTO $item) => $this->translatableStringHelper->localize($this->geographicalUnitLayerRepository->find($item->layerId)->getName()) . ' > ' . $item->unitName, 'attr' => [ 'class' => 'select2', ], @@ -115,7 +115,7 @@ class GeographicalUnitFilter implements \Chill\MainBundle\Export\FilterInterface '%units%' => implode( ', ', array_map( - fn(SimpleGeographicalUnitDTO $item) => $this->translatableStringHelper->localize($this->geographicalUnitLayerRepository->find($item->layerId)->getName()) . ' > ' . $item->unitName, + fn (SimpleGeographicalUnitDTO $item) => $this->translatableStringHelper->localize($this->geographicalUnitLayerRepository->find($item->layerId)->getName()) . ' > ' . $item->unitName, $data['units'] ) ), diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/MaritalStatusFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/MaritalStatusFilter.php index 62b6a34d7..47a75871c 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/MaritalStatusFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/MaritalStatusFilter.php @@ -49,7 +49,7 @@ class MaritalStatusFilter implements FilterInterface { $builder->add('maritalStatus', EntityType::class, [ 'class' => MaritalStatus::class, - 'choice_label' => fn(MaritalStatus $ms) => $this->translatableStringHelper->localize( + 'choice_label' => fn (MaritalStatus $ms) => $this->translatableStringHelper->localize( $ms->getName() ), 'multiple' => true, diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/NationalityFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/NationalityFilter.php index 19e5f999c..b1d77d60e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/NationalityFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/NationalityFilter.php @@ -72,7 +72,7 @@ class NationalityFilter implements { $countries = $data['nationalities']; - $names = array_map(fn(Country $c) => $this->translatableStringHelper->localize($c->getName()), [$countries]); + $names = array_map(fn (Country $c) => $this->translatableStringHelper->localize($c->getName()), [$countries]); return [ 'Filtered by nationality : %nationalities%', diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php index 32dc2a2fb..21bb40947 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php @@ -100,7 +100,7 @@ class ResidentialAddressAtThirdpartyFilter implements FilterInterface $builder->add('thirdparty_cat', EntityType::class, [ 'class' => ThirdPartyCategory::class, 'label' => 'Category', - 'choice_label' => fn(ThirdPartyCategory $tpc) => $this->translatableStringHelper->localize($tpc->getName()), + 'choice_label' => fn (ThirdPartyCategory $tpc) => $this->translatableStringHelper->localize($tpc->getName()), 'multiple' => true, 'expanded' => true, ]); diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/JobFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/JobFilter.php index 1c38a030e..144bf3260 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/JobFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/JobFilter.php @@ -69,7 +69,7 @@ class JobFilter implements FilterInterface { $builder->add('job', EntityType::class, [ 'class' => UserJob::class, - 'choice_label' => fn(UserJob $j) => $this->translatableStringHelper->localize( + 'choice_label' => fn (UserJob $j) => $this->translatableStringHelper->localize( $j->getLabel() ), 'multiple' => true, diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ScopeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ScopeFilter.php index 5d8e20832..315025722 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ScopeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ScopeFilter.php @@ -69,7 +69,7 @@ class ScopeFilter implements FilterInterface { $builder->add('scope', EntityType::class, [ 'class' => Scope::class, - 'choice_label' => fn(Scope $s) => $this->translatableStringHelper->localize( + 'choice_label' => fn (Scope $s) => $this->translatableStringHelper->localize( $s->getName() ), 'multiple' => true, diff --git a/src/Bundle/ChillPersonBundle/Form/ChoiceLoader/PersonChoiceLoader.php b/src/Bundle/ChillPersonBundle/Form/ChoiceLoader/PersonChoiceLoader.php index fe9a3490f..03db7c156 100644 --- a/src/Bundle/ChillPersonBundle/Form/ChoiceLoader/PersonChoiceLoader.php +++ b/src/Bundle/ChillPersonBundle/Form/ChoiceLoader/PersonChoiceLoader.php @@ -55,7 +55,7 @@ class PersonChoiceLoader implements ChoiceLoaderInterface { return new \Symfony\Component\Form\ChoiceList\ArrayChoiceList( $this->lazyLoadedPersons, - static fn(Person $p) => call_user_func($value, $p) + static fn (Person $p) => call_user_func($value, $p) ); } diff --git a/src/Bundle/ChillPersonBundle/Form/HouseholdCompositionType.php b/src/Bundle/ChillPersonBundle/Form/HouseholdCompositionType.php index 6e4877b63..a63b008c6 100644 --- a/src/Bundle/ChillPersonBundle/Form/HouseholdCompositionType.php +++ b/src/Bundle/ChillPersonBundle/Form/HouseholdCompositionType.php @@ -40,7 +40,7 @@ class HouseholdCompositionType extends AbstractType ->add('householdCompositionType', EntityType::class, [ 'class' => \Chill\PersonBundle\Entity\Household\HouseholdCompositionType::class, 'choices' => $types, - 'choice_label' => fn(\Chill\PersonBundle\Entity\Household\HouseholdCompositionType $type) => $this->translatableStringHelper->localize($type->getLabel()), + 'choice_label' => fn (\Chill\PersonBundle\Entity\Household\HouseholdCompositionType $type) => $this->translatableStringHelper->localize($type->getLabel()), 'label' => 'household_composition.Household composition', ]) ->add('startDate', ChillDateType::class, [ diff --git a/src/Bundle/ChillPersonBundle/Form/PersonType.php b/src/Bundle/ChillPersonBundle/Form/PersonType.php index 4752fb628..927812929 100644 --- a/src/Bundle/ChillPersonBundle/Form/PersonType.php +++ b/src/Bundle/ChillPersonBundle/Form/PersonType.php @@ -118,8 +118,8 @@ class PersonType extends AbstractType ]); $builder->get('placeOfBirth')->addModelTransformer(new CallbackTransformer( - static fn($string) => strtoupper((string) $string), - static fn($string) => strtoupper((string) $string) + static fn ($string) => strtoupper((string) $string), + static fn ($string) => strtoupper((string) $string) )); } @@ -163,7 +163,7 @@ class PersonType extends AbstractType 'allow_delete' => true, 'by_reference' => false, 'label' => false, - 'delete_empty' => static fn(?PersonPhone $pp = null) => null === $pp || $pp->isEmpty(), + 'delete_empty' => static fn (?PersonPhone $pp = null) => null === $pp || $pp->isEmpty(), 'error_bubbling' => false, 'empty_collection_explain' => 'No additional phone numbers', ]); diff --git a/src/Bundle/ChillPersonBundle/Form/SocialWork/GoalType.php b/src/Bundle/ChillPersonBundle/Form/SocialWork/GoalType.php index 7a6a7484d..a6f55e917 100644 --- a/src/Bundle/ChillPersonBundle/Form/SocialWork/GoalType.php +++ b/src/Bundle/ChillPersonBundle/Form/SocialWork/GoalType.php @@ -46,7 +46,7 @@ class GoalType extends AbstractType 'class' => Result::class, 'required' => false, 'multiple' => true, - 'choice_label' => fn(Result $r) => $this->translatableStringHelper->localize($r->getTitle()), + 'choice_label' => fn (Result $r) => $this->translatableStringHelper->localize($r->getTitle()), 'attr' => ['class' => 'select2 '], ]) ->add('desactivationDate', ChillDateType::class, [ diff --git a/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialActionType.php b/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialActionType.php index 7f5b434dd..0b6cbe73d 100644 --- a/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialActionType.php +++ b/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialActionType.php @@ -50,12 +50,12 @@ class SocialActionType extends AbstractType ->add('issue', EntityType::class, [ 'class' => SocialIssue::class, 'label' => 'socialAction.socialIssue', - 'choice_label' => fn(SocialIssue $issue) => $this->translatableStringHelper->localize($issue->getTitle()), + 'choice_label' => fn (SocialIssue $issue) => $this->translatableStringHelper->localize($issue->getTitle()), ]) ->add('parent', EntityType::class, [ 'class' => SocialAction::class, 'required' => false, - 'choice_label' => fn(SocialAction $issue) => $this->translatableStringHelper->localize($issue->getTitle()), + 'choice_label' => fn (SocialAction $issue) => $this->translatableStringHelper->localize($issue->getTitle()), ]) ->add('ordering', NumberType::class, [ 'required' => true, @@ -66,7 +66,7 @@ class SocialActionType extends AbstractType 'required' => false, 'multiple' => true, 'attr' => ['class' => 'select2'], - 'choice_label' => fn(Result $r) => $this->translatableStringHelper->localize($r->getTitle()), + 'choice_label' => fn (Result $r) => $this->translatableStringHelper->localize($r->getTitle()), ]) ->add('goals', EntityType::class, [ @@ -74,7 +74,7 @@ class SocialActionType extends AbstractType 'required' => false, 'multiple' => true, 'attr' => ['class' => 'select2'], - 'choice_label' => fn(Goal $g) => $this->translatableStringHelper->localize($g->getTitle()), + 'choice_label' => fn (Goal $g) => $this->translatableStringHelper->localize($g->getTitle()), ]) ->add('evaluations', EntityType::class, [ @@ -82,7 +82,7 @@ class SocialActionType extends AbstractType 'required' => false, 'multiple' => true, 'attr' => ['class' => 'select2'], - 'choice_label' => fn(Evaluation $e) => $this->translatableStringHelper->localize($e->getTitle()), + 'choice_label' => fn (Evaluation $e) => $this->translatableStringHelper->localize($e->getTitle()), ]) ->add('defaultNotificationDelay', DateIntervalType::class, [ diff --git a/src/Bundle/ChillPersonBundle/Form/Type/ClosingMotivePickerType.php b/src/Bundle/ChillPersonBundle/Form/Type/ClosingMotivePickerType.php index 2b4613376..240bcfbb4 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/ClosingMotivePickerType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/ClosingMotivePickerType.php @@ -60,13 +60,13 @@ class ClosingMotivePickerType extends AbstractType 'class' => ClosingMotive::class, 'empty_data' => null, 'placeholder' => 'Choose a motive', - 'choice_label' => fn(ClosingMotive $cm) => $this->entityRenderExtension->renderString($cm), + 'choice_label' => fn (ClosingMotive $cm) => $this->entityRenderExtension->renderString($cm), 'only_leaf' => true, ]); $resolver ->setAllowedTypes('only_leaf', 'bool') - ->setNormalizer('choices', fn(Options $options) => $this->repository + ->setNormalizer('choices', fn (Options $options) => $this->repository ->getActiveClosingMotive($options['only_leaf'])); } diff --git a/src/Bundle/ChillPersonBundle/Form/Type/PickPersonType.php b/src/Bundle/ChillPersonBundle/Form/Type/PickPersonType.php index 3c0a1d5af..026a24bb6 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/PickPersonType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/PickPersonType.php @@ -113,9 +113,9 @@ class PickPersonType extends AbstractType // add the default options $resolver->setDefaults([ 'class' => Person::class, - 'choice_label' => static fn(Person $p) => $p->getFirstname() . ' ' . $p->getLastname(), + 'choice_label' => static fn (Person $p) => $p->getFirstname() . ' ' . $p->getLastname(), 'placeholder' => 'Pick a person', - 'choice_attr' => static fn(Person $p) => [ + 'choice_attr' => static fn (Person $p) => [ 'data-center' => $p->getCenter()->getId(), ], 'attr' => ['class' => 'select2 '], @@ -135,7 +135,7 @@ class PickPersonType extends AbstractType protected function filterCentersfom(Options $options) { if (null === $options['role']) { - $centers = array_map(static fn(GroupCenter $g) => $g->getCenter(), $this->user->getGroupCenters()->toArray()); + $centers = array_map(static fn (GroupCenter $g) => $g->getCenter(), $this->user->getGroupCenters()->toArray()); } else { $centers = $this->authorizationHelper ->getReachableCenters($this->user, $options['role']->getRole()); @@ -158,7 +158,7 @@ class PickPersonType extends AbstractType if ( !in_array($c->getId(), array_map( - static fn(Center $c) => $c->getId(), + static fn (Center $c) => $c->getId(), $centers ), true) ) { diff --git a/src/Bundle/ChillPersonBundle/Form/Type/PickSocialActionType.php b/src/Bundle/ChillPersonBundle/Form/Type/PickSocialActionType.php index 695d3aa12..fd947e9cd 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/PickSocialActionType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/PickSocialActionType.php @@ -38,7 +38,7 @@ class PickSocialActionType extends AbstractType ->setDefaults([ 'class' => SocialAction::class, 'choices' => $this->actionRepository->findAllActive(), - 'choice_label' => fn(SocialAction $sa) => $this->actionRender->renderString($sa, []), + 'choice_label' => fn (SocialAction $sa) => $this->actionRender->renderString($sa, []), 'placeholder' => 'Pick a social action', 'required' => false, 'attr' => ['class' => 'select2'], diff --git a/src/Bundle/ChillPersonBundle/Form/Type/PickSocialIssueType.php b/src/Bundle/ChillPersonBundle/Form/Type/PickSocialIssueType.php index 9c02a7905..b560337ac 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/PickSocialIssueType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/PickSocialIssueType.php @@ -38,7 +38,7 @@ class PickSocialIssueType extends AbstractType ->setDefaults([ 'class' => SocialIssue::class, 'choices' => $this->issueRepository->findAllActive(), - 'choice_label' => fn(SocialIssue $si) => $this->issueRender->renderString($si, []), + 'choice_label' => fn (SocialIssue $si) => $this->issueRender->renderString($si, []), 'placeholder' => 'Pick a social issue', 'required' => false, 'attr' => ['class' => 'select2'], diff --git a/src/Bundle/ChillPersonBundle/Privacy/PrivacyEventSubscriber.php b/src/Bundle/ChillPersonBundle/Privacy/PrivacyEventSubscriber.php index f83d6faf4..33d01de1b 100644 --- a/src/Bundle/ChillPersonBundle/Privacy/PrivacyEventSubscriber.php +++ b/src/Bundle/ChillPersonBundle/Privacy/PrivacyEventSubscriber.php @@ -76,7 +76,7 @@ class PrivacyEventSubscriber implements EventSubscriberInterface $involved = $this->getInvolved(); $involved['period_id'] = $event->getPeriod()->getId(); $involved['persons'] = $event->getPeriod()->getPersons() - ->map(static fn(Person $p) => $p->getId()) + ->map(static fn (Person $p) => $p->getId()) ->toArray(); $this->logger->notice( @@ -100,7 +100,7 @@ class PrivacyEventSubscriber implements EventSubscriberInterface if ($event->hasPersons()) { $involved['persons'] = array_map( - static fn(Person $p) => $p->getId(), + static fn (Person $p) => $p->getId(), $event->getPersons() ); } diff --git a/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepository.php b/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepository.php index bbe6eed32..30c79147c 100644 --- a/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepository.php @@ -322,7 +322,7 @@ final class PersonACLAwareRepository implements PersonACLAwareRepositoryInterfac ), ] ), - array_map(static fn(Center $c) => $c->getId(), $authorizedCenters) + array_map(static fn (Center $c) => $c->getId(), $authorizedCenters) ); } } diff --git a/src/Bundle/ChillPersonBundle/Security/Authorization/HouseholdVoter.php b/src/Bundle/ChillPersonBundle/Security/Authorization/HouseholdVoter.php index 3e2308089..6ba1ac1a9 100644 --- a/src/Bundle/ChillPersonBundle/Security/Authorization/HouseholdVoter.php +++ b/src/Bundle/ChillPersonBundle/Security/Authorization/HouseholdVoter.php @@ -97,7 +97,7 @@ class HouseholdVoter extends Voter implements ProvideRoleHierarchyInterface, Chi private function checkAssociatedMembersRole(Household $household, string $attribute): bool { - foreach ($household->getCurrentMembers()->map(static fn(HouseholdMember $member) => $member->getPerson()) as $person) { + foreach ($household->getCurrentMembers()->map(static fn (HouseholdMember $member) => $member->getPerson()) as $person) { if ($this->security->isGranted($attribute, $person)) { return true; } diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodDocGenNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodDocGenNormalizer.php index bbd068fc9..bc13dec66 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodDocGenNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodDocGenNormalizer.php @@ -150,8 +150,8 @@ class AccompanyingPeriodDocGenNormalizer implements ContextAwareNormalizerInterf $this->closingMotiveRender->renderString($period->getClosingMotive(), []) : '', 'ref' => $this->normalizer->normalize($period->getUser(), $format, $userContext), 'hasRef' => $period->getUser() !== null, - 'socialIssuesText' => implode(', ', array_map(fn(SocialIssue $s) => $this->socialIssueRender->renderString($s, []), $period->getSocialIssues()->toArray())), - 'scopesText' => implode(', ', array_map(fn(Scope $s) => $this->translatableStringHelper->localize($s->getName()), $scopes)), + 'socialIssuesText' => implode(', ', array_map(fn (SocialIssue $s) => $this->socialIssueRender->renderString($s, []), $period->getSocialIssues()->toArray())), + 'scopesText' => implode(', ', array_map(fn (Scope $s) => $this->translatableStringHelper->localize($s->getName()), $scopes)), 'hasRequestor' => $period->getRequestor() !== null, 'requestorKind' => $period->getRequestorKind(), 'hasLocation' => $period->getLocation() !== null, diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationNormalizer.php index a6b13af4e..a0268ae31 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationNormalizer.php @@ -48,7 +48,7 @@ class AccompanyingPeriodWorkEvaluationNormalizer implements ContextAwareNormaliz $initial = $this->normalizer->normalize($object, $format, array_merge( $context, [self::IGNORE_EVALUATION => spl_object_hash($object)], - [AbstractNormalizer::CIRCULAR_REFERENCE_HANDLER => static fn($object, $format, $context) => $object->getId()] + [AbstractNormalizer::CIRCULAR_REFERENCE_HANDLER => static fn ($object, $format, $context) => $object->getId()] )); // due to bug: https://api-platform.com/docs/core/serialization/#collection-relation diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonDocGenNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonDocGenNormalizer.php index 308fe3ba1..7b500e6bb 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonDocGenNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonDocGenNormalizer.php @@ -94,7 +94,7 @@ class PersonDocGenNormalizer implements // we simplify the list of attributes for the embedded persons AbstractNormalizer::GROUPS => ['docgen:read'], // when a person reference the same person... take care of circular references - AbstractNormalizer::CIRCULAR_REFERENCE_HANDLER => fn($object, $format, $context) => $this->normalizer->normalize(null, $format, $context), + AbstractNormalizer::CIRCULAR_REFERENCE_HANDLER => fn ($object, $format, $context) => $this->normalizer->normalize(null, $format, $context), ]); if (null === $person) { @@ -115,7 +115,7 @@ class PersonDocGenNormalizer implements 'altNames' => implode( ', ', array_map( - static fn(PersonAltName $altName) => $altName->getLabel(), + static fn (PersonAltName $altName) => $altName->getLabel(), $person->getAltNames()->toArray() ) ), diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php index 29570e532..2cadd0c75 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php @@ -257,7 +257,7 @@ class PersonJsonNormalizer implements DenormalizerAwareInterface, NormalizerAwar { return $altNames ->map( - static fn(PersonAltName $personAltName): array => [ + static fn (PersonAltName $personAltName): array => [ 'key' => $personAltName->getKey(), 'label' => $personAltName->getLabel(), ] diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialIssueNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialIssueNormalizer.php index 1f8994644..32b1635c4 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialIssueNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialIssueNormalizer.php @@ -37,7 +37,7 @@ class SocialIssueNormalizer implements ContextAwareNormalizerInterface, Normaliz 'type' => 'social_issue', 'id' => $socialIssue->getId(), 'parent_id' => $socialIssue->hasParent() ? $socialIssue->getParent()->getId() : null, - 'children_ids' => $socialIssue->getChildren()->map(static fn(SocialIssue $si) => $si->getId()), + 'children_ids' => $socialIssue->getChildren()->map(static fn (SocialIssue $si) => $si->getId()), 'title' => $socialIssue->getTitle(), 'text' => $this->render->renderString($socialIssue, []), ]; diff --git a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php index ed66593c4..a42765c12 100644 --- a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php +++ b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php @@ -143,10 +143,10 @@ class AccompanyingPeriodContext implements ->add('category', EntityType::class, [ 'placeholder' => 'Choose a document category', 'class' => DocumentCategory::class, - 'query_builder' => static fn(EntityRepository $er) => $er->createQueryBuilder('c') + 'query_builder' => static fn (EntityRepository $er) => $er->createQueryBuilder('c') ->where('c.documentClass = :docClass') ->setParameter('docClass', AccompanyingCourseDocument::class), - 'choice_label' => fn($entity = null) => $entity ? $this->translatableStringHelper->localize($entity->getName()) : '', + 'choice_label' => fn ($entity = null) => $entity ? $this->translatableStringHelper->localize($entity->getName()) : '', ]); } @@ -156,7 +156,7 @@ class AccompanyingPeriodContext implements public function buildPublicForm(FormBuilderInterface $builder, DocGeneratorTemplate $template, mixed $entity): void { $options = $template->getOptions(); - $persons = new ArrayCollection($entity->getCurrentParticipations()->map(static fn(AccompanyingPeriodParticipation $p) => $p->getPerson())->toArray()); + $persons = new ArrayCollection($entity->getCurrentParticipations()->map(static fn (AccompanyingPeriodParticipation $p) => $p->getPerson())->toArray()); foreach ($entity->getCurrentParticipations() as $p) { foreach ($p->getPerson()->getResources() as $r) { @@ -181,7 +181,7 @@ class AccompanyingPeriodContext implements $builder->add($key, EntityType::class, [ 'class' => Person::class, 'choices' => $persons, - 'choice_label' => fn(Person $p) => $this->personRender->renderString($p, ['addAge' => true]), + 'choice_label' => fn (Person $p) => $this->personRender->renderString($p, ['addAge' => true]), 'multiple' => false, 'expanded' => true, 'required' => false, diff --git a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php index 325e666b9..34b339822 100644 --- a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php +++ b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php @@ -63,7 +63,7 @@ class AccompanyingPeriodWorkEvaluationContext implements $this->accompanyingPeriodWorkContext->adminFormReverseTransform($data), [ 'evaluations' => array_map( - static fn(Evaluation $e) => $e->getId(), + static fn (Evaluation $e) => $e->getId(), $data['evaluations'] ), ] @@ -76,7 +76,7 @@ class AccompanyingPeriodWorkEvaluationContext implements $this->accompanyingPeriodWorkContext->adminFormTransform($data), [ 'evaluations' => array_map( - fn($id) => $this->evaluationRepository->find($id), + fn ($id) => $this->evaluationRepository->find($id), $data['evaluations'] ?? [] ), ] @@ -93,7 +93,7 @@ class AccompanyingPeriodWorkEvaluationContext implements 'class' => Evaluation::class, 'label' => 'Linked evaluations', 'choices' => $this->evaluationRepository->findAll(), - 'choice_label' => fn(Evaluation $e) => $this->translatableStringHelper->localize($e->getTitle()), + 'choice_label' => fn (Evaluation $e) => $this->translatableStringHelper->localize($e->getTitle()), 'multiple' => true, 'attr' => ['class' => 'select2'], ]); diff --git a/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php b/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php index 8a7b7e2ba..1fdfd23d9 100644 --- a/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php +++ b/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php @@ -126,10 +126,10 @@ final class PersonContext implements PersonContextInterface ->add('category', EntityType::class, [ 'placeholder' => 'Choose a document category', 'class' => DocumentCategory::class, - 'query_builder' => static fn(EntityRepository $er) => $er->createQueryBuilder('c') + 'query_builder' => static fn (EntityRepository $er) => $er->createQueryBuilder('c') ->where('c.documentClass = :docClass') ->setParameter('docClass', PersonDocument::class), - 'choice_label' => fn($entity = null) => $entity ? $this->translatableStringHelper->localize($entity->getName()) : '', + 'choice_label' => fn ($entity = null) => $entity ? $this->translatableStringHelper->localize($entity->getName()) : '', 'required' => true, ]); } diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseApiControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseApiControllerTest.php index 53d6a0a93..ac722f2f6 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseApiControllerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseApiControllerTest.php @@ -342,7 +342,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase // check that the person id is contained $participationsPersonsIds = array_map( - static fn($participation) => $participation->person->id, + static fn ($participation) => $participation->person->id, $data->participations ); diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdApiControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdApiControllerTest.php index cb0587b5e..f01eeeaa9 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdApiControllerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdApiControllerTest.php @@ -161,7 +161,7 @@ final class HouseholdApiControllerTest extends WebTestCase $this->assertArrayHasKey('count', $data); $this->assertArrayHasKey('results', $data); - $householdIds = array_map(static fn($r) => $r['id'], $data['results']); + $householdIds = array_map(static fn ($r) => $r['id'], $data['results']); $this->assertContains($expectedHouseholdId, $householdIds); } diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateTest.php index cf8c134ad..94b618e41 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateTest.php @@ -294,23 +294,23 @@ final class PersonControllerUpdateTest extends WebTestCase public function validTextFieldsProvider() { return [ - ['firstName', 'random Value', static fn(Person $person) => $person->getFirstName()], - ['lastName', 'random Value', static fn(Person $person) => $person->getLastName()], + ['firstName', 'random Value', static fn (Person $person) => $person->getFirstName()], + ['lastName', 'random Value', static fn (Person $person) => $person->getLastName()], // reminder: this value is capitalized - ['placeOfBirth', 'A PLACE', static fn(Person $person) => $person->getPlaceOfBirth()], - ['birthdate', '1980-12-15', static fn(Person $person) => $person->getBirthdate()->format('Y-m-d')], + ['placeOfBirth', 'A PLACE', static fn (Person $person) => $person->getPlaceOfBirth()], + ['birthdate', '1980-12-15', static fn (Person $person) => $person->getBirthdate()->format('Y-m-d')], // TODO test on phonenumber update // ['phonenumber', '+32123456789', static function (Person $person) { return $person->getPhonenumber(); }], - ['memo', 'jfkdlmq jkfldmsq jkmfdsq', static fn(Person $person) => $person->getMemo()], - ['countryOfBirth', 'BE', static fn(Person $person) => $person->getCountryOfBirth()->getCountryCode()], - ['nationality', 'FR', static fn(Person $person) => $person->getNationality()->getCountryCode()], - ['placeOfBirth', '', static fn(Person $person) => $person->getPlaceOfBirth()], - ['birthdate', '', static fn(Person $person) => $person->getBirthdate()], + ['memo', 'jfkdlmq jkfldmsq jkmfdsq', static fn (Person $person) => $person->getMemo()], + ['countryOfBirth', 'BE', static fn (Person $person) => $person->getCountryOfBirth()->getCountryCode()], + ['nationality', 'FR', static fn (Person $person) => $person->getNationality()->getCountryCode()], + ['placeOfBirth', '', static fn (Person $person) => $person->getPlaceOfBirth()], + ['birthdate', '', static fn (Person $person) => $person->getBirthdate()], //['phonenumber', '', static function (Person $person) { return $person->getPhonenumber(); }], - ['memo', '', static fn(Person $person) => $person->getMemo()], - ['countryOfBirth', null, static fn(Person $person) => $person->getCountryOfBirth()], - ['nationality', null, static fn(Person $person) => $person->getNationality()], - ['gender', Person::FEMALE_GENDER, static fn(Person $person) => $person->getGender()], + ['memo', '', static fn (Person $person) => $person->getMemo()], + ['countryOfBirth', null, static fn (Person $person) => $person->getCountryOfBirth()], + ['nationality', null, static fn (Person $person) => $person->getNationality()], + ['gender', Person::FEMALE_GENDER, static fn (Person $person) => $person->getGender()], ]; } diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateWithHiddenFieldsTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateWithHiddenFieldsTest.php index d9cf2241a..441358c02 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateWithHiddenFieldsTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateWithHiddenFieldsTest.php @@ -197,12 +197,12 @@ final class PersonControllerUpdateWithHiddenFieldsTest extends WebTestCase public function validTextFieldsProvider() { return [ - ['firstName', 'random Value', static fn(Person $person) => $person->getFirstName()], - ['lastName', 'random Value', static fn(Person $person) => $person->getLastName()], - ['birthdate', '15-12-1980', static fn(Person $person) => $person->getBirthdate()->format('d-m-Y')], - ['memo', 'jfkdlmq jkfldmsq jkmfdsq', static fn(Person $person) => $person->getMemo()], - ['birthdate', '', static fn(Person $person) => $person->getBirthdate()], - ['gender', Person::FEMALE_GENDER, static fn(Person $person) => $person->getGender()], + ['firstName', 'random Value', static fn (Person $person) => $person->getFirstName()], + ['lastName', 'random Value', static fn (Person $person) => $person->getLastName()], + ['birthdate', '15-12-1980', static fn (Person $person) => $person->getBirthdate()->format('d-m-Y')], + ['memo', 'jfkdlmq jkfldmsq jkmfdsq', static fn (Person $person) => $person->getMemo()], + ['birthdate', '', static fn (Person $person) => $person->getBirthdate()], + ['gender', Person::FEMALE_GENDER, static fn (Person $person) => $person->getGender()], ]; } diff --git a/src/Bundle/ChillPersonBundle/Tests/Entity/AccompanyingPeriodTest.php b/src/Bundle/ChillPersonBundle/Tests/Entity/AccompanyingPeriodTest.php index 5ce35317e..0a9c22df1 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Entity/AccompanyingPeriodTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Entity/AccompanyingPeriodTest.php @@ -152,7 +152,7 @@ final class AccompanyingPeriodTest extends \PHPUnit\Framework\TestCase $locations = $period->getLocationHistories()->toArray(); - usort($locations, static fn(AccompanyingPeriod\AccompanyingPeriodLocationHistory $a, AccompanyingPeriod\AccompanyingPeriodLocationHistory $b) => $a->getStartDate() <=> $b->getStartDate()); + usort($locations, static fn (AccompanyingPeriod\AccompanyingPeriodLocationHistory $a, AccompanyingPeriod\AccompanyingPeriodLocationHistory $b) => $a->getStartDate() <=> $b->getStartDate()); $iterator = new ArrayIterator($locations); $iterator->rewind(); diff --git a/src/Bundle/ChillPersonBundle/Tests/Household/MembersEditorTest.php b/src/Bundle/ChillPersonBundle/Tests/Household/MembersEditorTest.php index 55169757f..8ec7ee573 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Household/MembersEditorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Household/MembersEditorTest.php @@ -101,13 +101,13 @@ final class MembersEditorTest extends TestCase $editor = $factory->createEditor($household2 = new Household()); $editor->addMovement(new DateTimeImmutable('yesterday'), $person, $positionNotSharing); - $sharings = $household->getCurrentMembers()->filter(static fn(HouseholdMember $m) => $m->getShareHousehold()); - $notSharing = $household2->getCurrentMembers()->filter(static fn(HouseholdMember $m) => !$m->getShareHousehold()); + $sharings = $household->getCurrentMembers()->filter(static fn (HouseholdMember $m) => $m->getShareHousehold()); + $notSharing = $household2->getCurrentMembers()->filter(static fn (HouseholdMember $m) => !$m->getShareHousehold()); $this->assertCount(1, $notSharing); $this->assertCount(1, $sharings); - $getPerson = static fn(HouseholdMember $m) => $m->getPerson(); + $getPerson = static fn (HouseholdMember $m) => $m->getPerson(); $this->assertContains($person, $notSharing->map($getPerson)); } @@ -137,13 +137,13 @@ final class MembersEditorTest extends TestCase $editor = $factory->createEditor($household); $editor->addMovement(new DateTimeImmutable('yesterday'), $person, $positionNotSharing); - $sharings = $household->getCurrentMembers()->filter(static fn(HouseholdMember $m) => $m->getShareHousehold()); - $notSharing = $household->getCurrentMembers()->filter(static fn(HouseholdMember $m) => !$m->getShareHousehold()); + $sharings = $household->getCurrentMembers()->filter(static fn (HouseholdMember $m) => $m->getShareHousehold()); + $notSharing = $household->getCurrentMembers()->filter(static fn (HouseholdMember $m) => !$m->getShareHousehold()); $this->assertCount(1, $notSharing); $this->assertCount(0, $sharings); - $getPerson = static fn(HouseholdMember $m) => $m->getPerson(); + $getPerson = static fn (HouseholdMember $m) => $m->getPerson(); $this->assertContains($person, $notSharing->map($getPerson)); } diff --git a/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/PersonDocGenNormalizerTest.php b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/PersonDocGenNormalizerTest.php index 6057a29c9..f7a05f7ce 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/PersonDocGenNormalizerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/PersonDocGenNormalizerTest.php @@ -318,7 +318,7 @@ final class PersonDocGenNormalizerTest extends KernelTestCase $normalizerManager = $this->prophesize(NormalizerInterface::class); $normalizerManager->supportsNormalization(Argument::any(), 'docgen', Argument::any())->willReturn(true); $normalizerManager->normalize(Argument::type(Person::class), 'docgen', Argument::any()) - ->will(static fn($args) => $normalizer->normalize($args[0], $args[1], $args[2])); + ->will(static fn ($args) => $normalizer->normalize($args[0], $args[1], $args[2])); $normalizerManager->normalize(Argument::any(), 'docgen', Argument::any())->will( static function ($args) { if (is_iterable($args[0])) { diff --git a/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/RelationshipDocGenNormalizerTest.php b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/RelationshipDocGenNormalizerTest.php index 6d841436e..6b3f49fde 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/RelationshipDocGenNormalizerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/RelationshipDocGenNormalizerTest.php @@ -118,7 +118,7 @@ final class RelationshipDocGenNormalizerTest extends TestCase { $translatableStringHelper = $this->prophesize(TranslatableStringHelperInterface::class); $translatableStringHelper->localize(Argument::type('array'))->will( - static fn($args) => $args[0][array_keys($args[0])[0]] + static fn ($args) => $args[0][array_keys($args[0])[0]] ); $normalizer = new RelationshipDocGenNormalizer( @@ -128,7 +128,7 @@ final class RelationshipDocGenNormalizerTest extends TestCase $normalizerManager = $this->prophesize(NormalizerInterface::class); $normalizerManager->supportsNormalization(Argument::any(), 'docgen', Argument::any())->willReturn(true); $normalizerManager->normalize(Argument::type(Relationship::class), 'docgen', Argument::any()) - ->will(static fn($args) => $normalizer->normalize($args[0], $args[1], $args[2])); + ->will(static fn ($args) => $normalizer->normalize($args[0], $args[1], $args[2])); $normalizerManager->normalize(Argument::any(), 'docgen', Argument::any())->will( static function ($args) { if (null === $args[0]) { diff --git a/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextTest.php b/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextTest.php index e84b27813..d0138dc30 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextTest.php @@ -263,7 +263,7 @@ final class PersonContextTest extends TestCase if (null === $translatableStringHelper) { $translatableStringHelper = $this->prophesize(TranslatableStringHelperInterface::class); // return only the 'fr' key - $translatableStringHelper->localize(Argument::type('array'))->will(static fn($args) => $args[0]['fr']); + $translatableStringHelper->localize(Argument::type('array'))->will(static fn ($args) => $args[0]['fr']); $translatableStringHelper = $translatableStringHelper->reveal(); } diff --git a/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextWithThirdPartyTest.php b/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextWithThirdPartyTest.php index 753a9f855..70bccfda4 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextWithThirdPartyTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextWithThirdPartyTest.php @@ -70,7 +70,7 @@ final class PersonContextWithThirdPartyTest extends KernelTestCase { $normalizer = $this->prophesize(NormalizerInterface::class); $normalizer->normalize(Argument::type(ThirdParty::class), 'docgen', Argument::type('array')) - ->will(static fn($args): array => ['class' => '3party', 'hash' => spl_object_hash($args[0])]); + ->will(static fn ($args): array => ['class' => '3party', 'hash' => spl_object_hash($args[0])]); $personContext = $this->prophesize(PersonContextInterface::class); diff --git a/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/AccompanyingPeriodValidityValidator.php b/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/AccompanyingPeriodValidityValidator.php index cae4829f7..ed0337f1f 100644 --- a/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/AccompanyingPeriodValidityValidator.php +++ b/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/AccompanyingPeriodValidityValidator.php @@ -74,7 +74,7 @@ class AccompanyingPeriodValidityValidator extends ConstraintValidator $periodIssuesWithAncestors = array_merge( $periodIssuesWithAncestors, array_map( - static fn(SocialIssue $si) => spl_object_hash($si), + static fn (SocialIssue $si) => spl_object_hash($si), $si->getAncestors(true) ) ); diff --git a/src/Bundle/ChillReportBundle/Export/Export/ReportList.php b/src/Bundle/ChillReportBundle/Export/Export/ReportList.php index d957f37e3..9adae0097 100644 --- a/src/Bundle/ChillReportBundle/Export/Export/ReportList.php +++ b/src/Bundle/ChillReportBundle/Export/Export/ReportList.php @@ -331,7 +331,7 @@ class ReportList implements ExportElementValidatedInterface, ListInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static fn($el) => $el['center'], $acl); + $centers = array_map(static fn ($el) => $el['center'], $acl); // throw an error if any fields are present if (!array_key_exists('fields', $data)) { @@ -503,7 +503,7 @@ class ReportList implements ExportElementValidatedInterface, ListInterface private function getCustomFields() { return array_filter($this->customfieldsGroup - ->getCustomFields()->toArray(), static fn(CustomField $cf) => $cf->getType() !== 'title'); + ->getCustomFields()->toArray(), static fn (CustomField $cf) => $cf->getType() !== 'title'); } private function getLabelForCustomField($key, array $values, $data) diff --git a/src/Bundle/ChillReportBundle/Search/ReportSearch.php b/src/Bundle/ChillReportBundle/Search/ReportSearch.php index e0aaa89e1..b08e01ee5 100644 --- a/src/Bundle/ChillReportBundle/Search/ReportSearch.php +++ b/src/Bundle/ChillReportBundle/Search/ReportSearch.php @@ -97,7 +97,7 @@ class ReportSearch extends AbstractSearch implements ContainerAwareInterface foreach ($reachableCenters as $center) { $reachableScopesId = array_map( - static fn(Scope $scope) => $scope->getId(), + static fn (Scope $scope) => $scope->getId(), $this->helper->getReachableScopes($this->user, $role, $center) ); $whereElement->add( diff --git a/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerNextTest.php b/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerNextTest.php index 803ecf38f..5c25861b1 100644 --- a/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerNextTest.php +++ b/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerNextTest.php @@ -68,7 +68,7 @@ final class ReportControllerNextTest extends WebTestCase //filter customFieldsGroup to get only "situation de logement" $filteredCustomFieldsGroupHouse = array_filter( $customFieldsGroups, - static fn(CustomFieldsGroup $group) => in_array('Situation de logement', $group->getName(), true) + static fn (CustomFieldsGroup $group) => in_array('Situation de logement', $group->getName(), true) ); $this->group = $filteredCustomFieldsGroupHouse[0]; } diff --git a/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerTest.php b/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerTest.php index cd3b0f185..69ccd3d54 100644 --- a/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerTest.php +++ b/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerTest.php @@ -86,7 +86,7 @@ final class ReportControllerTest extends WebTestCase //filter customFieldsGroup to get only "situation de logement" $filteredCustomFieldsGroupHouse = array_filter( $customFieldsGroups, - static fn(CustomFieldsGroup $group) => in_array('Situation de logement', $group->getName(), true) + static fn (CustomFieldsGroup $group) => in_array('Situation de logement', $group->getName(), true) ); self::$group = $filteredCustomFieldsGroupHouse[0]; diff --git a/src/Bundle/ChillReportBundle/Tests/Timeline/TimelineProviderTest.php b/src/Bundle/ChillReportBundle/Tests/Timeline/TimelineProviderTest.php index 253616a84..95f85ed1f 100644 --- a/src/Bundle/ChillReportBundle/Tests/Timeline/TimelineProviderTest.php +++ b/src/Bundle/ChillReportBundle/Tests/Timeline/TimelineProviderTest.php @@ -67,7 +67,7 @@ final class TimelineProviderTest extends WebTestCase self::$em ->getRepository(\Chill\MainBundle\Entity\Scope::class) ->findAll(), - static fn(Scope $scope) => $scope->getName()['en'] === 'social' + static fn (Scope $scope) => $scope->getName()['en'] === 'social' ); $report = (new Report()) diff --git a/src/Bundle/ChillTaskBundle/Controller/TaskController.php b/src/Bundle/ChillTaskBundle/Controller/TaskController.php index 2c052619b..435c9eaa2 100644 --- a/src/Bundle/ChillTaskBundle/Controller/TaskController.php +++ b/src/Bundle/ChillTaskBundle/Controller/TaskController.php @@ -94,7 +94,7 @@ class TaskController extends AbstractController $transitionInstance = array_values( // array_values needed to reset keys (array_filter preserves keys) array_filter( $workflow->getEnabledTransitions($task), - static fn(Transition $t) => $t->getName() === $transition + static fn (Transition $t) => $t->getName() === $transition ) )[0]; diff --git a/src/Bundle/ChillTaskBundle/Form/SingleTaskListType.php b/src/Bundle/ChillTaskBundle/Form/SingleTaskListType.php index ec336856e..2af71810d 100644 --- a/src/Bundle/ChillTaskBundle/Form/SingleTaskListType.php +++ b/src/Bundle/ChillTaskBundle/Form/SingleTaskListType.php @@ -218,9 +218,9 @@ class SingleTaskListType extends AbstractType $users = $this->getUsersAssigneedToTask($options); $choices = array_combine( // get usernames - array_map(static fn(User $user) => $user->getUsername(), $users), + array_map(static fn (User $user) => $user->getUsername(), $users), // get ids - array_map(static fn(User $user) => $user->getId(), $users) + array_map(static fn (User $user) => $user->getId(), $users) ); $choices['Unassigned'] = '_unassigned'; diff --git a/src/Bundle/ChillTaskBundle/Tests/Controller/SingleTaskControllerTest.php b/src/Bundle/ChillTaskBundle/Tests/Controller/SingleTaskControllerTest.php index 50c360610..2ff7092f0 100644 --- a/src/Bundle/ChillTaskBundle/Tests/Controller/SingleTaskControllerTest.php +++ b/src/Bundle/ChillTaskBundle/Tests/Controller/SingleTaskControllerTest.php @@ -92,7 +92,7 @@ final class SingleTaskControllerTest extends WebTestCase $center = array_filter( $centers, - static fn(Center $c) => $c->getName() === $centerName + static fn (Center $c) => $c->getName() === $centerName )[0]; $ids = $em diff --git a/src/Bundle/ChillTaskBundle/Timeline/SingleTaskTaskLifeCycleEventTimelineProvider.php b/src/Bundle/ChillTaskBundle/Timeline/SingleTaskTaskLifeCycleEventTimelineProvider.php index c07fd707e..9a8fcf6bd 100644 --- a/src/Bundle/ChillTaskBundle/Timeline/SingleTaskTaskLifeCycleEventTimelineProvider.php +++ b/src/Bundle/ChillTaskBundle/Timeline/SingleTaskTaskLifeCycleEventTimelineProvider.php @@ -86,7 +86,7 @@ class SingleTaskTaskLifeCycleEventTimelineProvider implements TimelineProviderIn ->findBy(['id' => $ids]); return array_combine( - array_map(static fn($e) => $e->getId(), $events), + array_map(static fn ($e) => $e->getId(), $events), $events ); } diff --git a/src/Bundle/ChillTaskBundle/Timeline/TaskLifeCycleEventTimelineProvider.php b/src/Bundle/ChillTaskBundle/Timeline/TaskLifeCycleEventTimelineProvider.php index e6f98cef9..aa8776aa2 100644 --- a/src/Bundle/ChillTaskBundle/Timeline/TaskLifeCycleEventTimelineProvider.php +++ b/src/Bundle/ChillTaskBundle/Timeline/TaskLifeCycleEventTimelineProvider.php @@ -97,7 +97,7 @@ class TaskLifeCycleEventTimelineProvider implements TimelineProviderInterface ->findBy(['id' => $ids]); return array_combine( - array_map(static fn($e) => $e->getId(), $events), + array_map(static fn ($e) => $e->getId(), $events), $events ); } diff --git a/src/Bundle/ChillThirdPartyBundle/DataFixtures/ORM/LoadThirdParty.php b/src/Bundle/ChillThirdPartyBundle/DataFixtures/ORM/LoadThirdParty.php index 8250f7bf0..e813cbd7f 100644 --- a/src/Bundle/ChillThirdPartyBundle/DataFixtures/ORM/LoadThirdParty.php +++ b/src/Bundle/ChillThirdPartyBundle/DataFixtures/ORM/LoadThirdParty.php @@ -69,7 +69,7 @@ class LoadThirdParty extends Fixture implements DependentFixtureInterface private function getCenters(): Iterator { $references = array_map( - static fn($a) => $a['ref'], + static fn ($a) => $a['ref'], LoadCenters::$centers ); $number = random_int(1, count($references)); diff --git a/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdPartyType.php b/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdPartyType.php index 01309a37e..0dd4f16e6 100644 --- a/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdPartyType.php +++ b/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdPartyType.php @@ -103,8 +103,8 @@ class PickThirdPartyType extends AbstractType $resolver ->setDefault('class', ThirdParty::class) - ->setDefault('choice_label', static fn(ThirdParty $tp) => $tp->getName()) - ->setDefault('choice_loader', fn(Options $options) => new ThirdPartyChoiceLoader( + ->setDefault('choice_label', static fn (ThirdParty $tp) => $tp->getName()) + ->setDefault('choice_loader', fn (Options $options) => new ThirdPartyChoiceLoader( $options['center'], $this->em->getRepository(ThirdParty::class) )); diff --git a/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdPartyTypeCategoryType.php b/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdPartyTypeCategoryType.php index 6bc83f0f2..26cb0ae2e 100644 --- a/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdPartyTypeCategoryType.php +++ b/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdPartyTypeCategoryType.php @@ -77,7 +77,7 @@ class PickThirdPartyTypeCategoryType extends \Symfony\Component\Form\AbstractTyp return self::PREFIX_TYPE . $item; }, - 'choice_value' => fn($item) => $this->reverseTransform($item), + 'choice_value' => fn ($item) => $this->reverseTransform($item), ]); } From 25c033be6176369c6737c579092bdf1df0502b0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sat, 15 Apr 2023 00:47:06 +0200 Subject: [PATCH 018/724] DX: apply rector rules --- src/Bundle/ChillMainBundle/Search/SearchProvider.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Search/SearchProvider.php b/src/Bundle/ChillMainBundle/Search/SearchProvider.php index 7ebb5ed87..095b749bc 100644 --- a/src/Bundle/ChillMainBundle/Search/SearchProvider.php +++ b/src/Bundle/ChillMainBundle/Search/SearchProvider.php @@ -113,9 +113,7 @@ class SearchProvider public function getHasAdvancedFormSearchServices() { //sort the array - uasort($this->hasAdvancedFormSearchServices, static function (HasAdvancedSearchFormInterface $a, HasAdvancedSearchFormInterface $b): int { - return $a->getOrder() <=> $b->getOrder(); - }); + uasort($this->hasAdvancedFormSearchServices, static fn (HasAdvancedSearchFormInterface $a, HasAdvancedSearchFormInterface $b): int => $a->getOrder() <=> $b->getOrder()); return $this->hasAdvancedFormSearchServices; } From fe3d4370966e41c411e02f82adc23f73f1787d54 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Mon, 24 Apr 2023 12:12:10 +0200 Subject: [PATCH 019/724] improve title hierarchy coherence --- .../Resources/views/Budget/_budget.html.twig | 2 +- .../Resources/views/Budget/_current_budget.html.twig | 4 +++- .../Resources/views/Household/index.html.twig | 2 +- src/Bundle/ChillBudgetBundle/translations/messages.fr.yml | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_budget.html.twig b/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_budget.html.twig index e11a822cd..e75b83ee8 100644 --- a/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_budget.html.twig +++ b/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_budget.html.twig @@ -45,7 +45,7 @@ {% endif %} {% if pastCharges|length > 0 or pastResources|length > 0 %} -

    {{ 'Past budget'|trans }}

    a +

    {{ 'Past budget'|trans }}

    {% include '@ChillBudget/Budget/_past_budget.html.twig' with { 'pastCharges': pastCharges, 'pastResources': pastResources, diff --git a/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_current_budget.html.twig b/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_current_budget.html.twig index 98e784cc5..27a77df1d 100644 --- a/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_current_budget.html.twig +++ b/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_current_budget.html.twig @@ -1,6 +1,8 @@ {% from '@ChillBudget/Budget/_macros.html.twig' import table_elements, table_results %} -{#

    {{ 'Actual budget'|trans }}

    #} +{# +

    {{ 'Actual budget'|trans }}

    +#}

    {{ 'Actual resources'|trans }}

    diff --git a/src/Bundle/ChillBudgetBundle/Resources/views/Household/index.html.twig b/src/Bundle/ChillBudgetBundle/Resources/views/Household/index.html.twig index c2533e4c0..310220df1 100644 --- a/src/Bundle/ChillBudgetBundle/Resources/views/Household/index.html.twig +++ b/src/Bundle/ChillBudgetBundle/Resources/views/Household/index.html.twig @@ -33,7 +33,7 @@ #} {% if household.getCurrentMembers|length > 0 %} -

    {{ 'Current budget household members'|trans }}

    +

    {{ 'Budget household members'|trans }}

    {% for hm in household.getCurrentMembers %} {% set member = hm.person %} diff --git a/src/Bundle/ChillBudgetBundle/translations/messages.fr.yml b/src/Bundle/ChillBudgetBundle/translations/messages.fr.yml index a5e5490a0..5d71f4228 100644 --- a/src/Bundle/ChillBudgetBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillBudgetBundle/translations/messages.fr.yml @@ -3,7 +3,7 @@ Resource: Ressource Charge: Charge Budget for %name%: Budget de %name% Budget for household %household%: Budget du ménage -Current budget household members: Budget actuel des membres du ménage +Budget household members: Budget des membres du ménage Show budget of %name%: Montrer budget de %name% See complete budget: Voir budget complet Hide budget: Masquer From 241e605ea6de96a2dc5ec9e594585869ed3ed118 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Mon, 24 Apr 2023 12:22:41 +0200 Subject: [PATCH 020/724] - style of h3 subtitle --- .../Resources/public/page/chillbudget.scss | 7 ++++++- .../Resources/views/Budget/_budget.html.twig | 6 +++--- .../Resources/views/Person/index.html.twig | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Bundle/ChillBudgetBundle/Resources/public/page/chillbudget.scss b/src/Bundle/ChillBudgetBundle/Resources/public/page/chillbudget.scss index 20a87cce2..82230d13b 100644 --- a/src/Bundle/ChillBudgetBundle/Resources/public/page/chillbudget.scss +++ b/src/Bundle/ChillBudgetBundle/Resources/public/page/chillbudget.scss @@ -2,6 +2,11 @@ margin-top: 1rem; margin-bottom: 1rem; padding: 1rem; + &::before { + font: normal normal normal 20px/1 ForkAwesome; + margin-right: 0.5em; + content: "\f061"; + } } .family-title { margin-bottom: 1rem !important; @@ -58,4 +63,4 @@ button[aria-expanded="true"] > span.folded, button[aria-expanded="false"] > span.unfolded { display: none; } button[aria-expanded="false"] > span.folded, -button[aria-expanded="true"] > span.unfolded { display: inline; } \ No newline at end of file +button[aria-expanded="true"] > span.unfolded { display: inline; } diff --git a/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_budget.html.twig b/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_budget.html.twig index e75b83ee8..8a3fa6de2 100644 --- a/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_budget.html.twig +++ b/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_budget.html.twig @@ -32,7 +32,7 @@ {% endif %} {% endfor %} -

    {{ 'Actual budget'|trans }}

    +

    {{ 'Actual budget'|trans }}

    {% if actualCharges|length > 0 or actualResources|length > 0 %} {% include '@ChillBudget/Budget/_current_budget.html.twig' with { 'actualResources': actualResources, @@ -45,7 +45,7 @@ {% endif %} {% if pastCharges|length > 0 or pastResources|length > 0 %} -

    {{ 'Past budget'|trans }}

    +

    {{ 'Past budget'|trans }}

    {% include '@ChillBudget/Budget/_past_budget.html.twig' with { 'pastCharges': pastCharges, 'pastResources': pastResources, @@ -54,7 +54,7 @@ {% endif %} {% if futureCharges|length > 0 or futureResources|length > 0 %} -

    {{ 'Future budget'|trans }}

    +

    {{ 'Future budget'|trans }}

    {% include '@ChillBudget/Budget/_future_budget.html.twig' with { 'futureResources': futureResources, 'futureCharges': futureCharges, diff --git a/src/Bundle/ChillBudgetBundle/Resources/views/Person/index.html.twig b/src/Bundle/ChillBudgetBundle/Resources/views/Person/index.html.twig index 18d04b889..c365b9b84 100644 --- a/src/Bundle/ChillBudgetBundle/Resources/views/Person/index.html.twig +++ b/src/Bundle/ChillBudgetBundle/Resources/views/Person/index.html.twig @@ -24,7 +24,7 @@ } %}
    -

    {{ 'Budget calculator'|trans }}

    +

    {{ 'Budget calculator'|trans }}

    {{ table_results(charges, resources) }}
    From be965e8698c0ffec07b51fcca4a1e637aa18e735 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Mon, 24 Apr 2023 13:01:58 +0200 Subject: [PATCH 021/724] - improve title hierarchy and ergonomie --- .../Resources/public/page/chillbudget.scss | 20 +++++++++++--- .../Resources/views/Budget/_budget.html.twig | 6 ++--- .../views/Budget/_current_budget.html.twig | 12 +++------ .../views/Budget/_future_budget.html.twig | 27 +++++++------------ .../views/Budget/_past_budget.html.twig | 26 ++++++------------ .../Resources/views/Household/index.html.twig | 12 ++++----- .../Resources/views/Person/index.html.twig | 2 +- .../translations/messages.fr.yml | 6 ++--- 8 files changed, 49 insertions(+), 62 deletions(-) diff --git a/src/Bundle/ChillBudgetBundle/Resources/public/page/chillbudget.scss b/src/Bundle/ChillBudgetBundle/Resources/public/page/chillbudget.scss index 82230d13b..cca1b1a4a 100644 --- a/src/Bundle/ChillBudgetBundle/Resources/public/page/chillbudget.scss +++ b/src/Bundle/ChillBudgetBundle/Resources/public/page/chillbudget.scss @@ -1,4 +1,4 @@ -.subtitle { +h3.subtitle { margin-top: 1rem; margin-bottom: 1rem; padding: 1rem; @@ -8,22 +8,34 @@ content: "\f061"; } } -.family-title { + +$col_charge: #e03851d7; +$col_resource: #6d9e63d8; + +h4.family-title { + margin-top: 1.5rem; margin-bottom: 1rem !important; + padding-left: 0.7em; + i { + margin-right: 0.4em; + } + &.charge i { color: $col_charge; } + &.resource i { color: $col_resource; } } .budget-table th { th { color: white; } } + .budget-table { th.charge { - background-color: #e03851d7; + background-color: $col_charge; } } .budget-table { th.resource { - background-color: #6d9e63d8; + background-color: $col_resource; } } .budget-table { diff --git a/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_budget.html.twig b/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_budget.html.twig index 8a3fa6de2..e75b83ee8 100644 --- a/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_budget.html.twig +++ b/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_budget.html.twig @@ -32,7 +32,7 @@ {% endif %} {% endfor %} -

    {{ 'Actual budget'|trans }}

    +

    {{ 'Actual budget'|trans }}

    {% if actualCharges|length > 0 or actualResources|length > 0 %} {% include '@ChillBudget/Budget/_current_budget.html.twig' with { 'actualResources': actualResources, @@ -45,7 +45,7 @@ {% endif %} {% if pastCharges|length > 0 or pastResources|length > 0 %} -

    {{ 'Past budget'|trans }}

    +

    {{ 'Past budget'|trans }}

    {% include '@ChillBudget/Budget/_past_budget.html.twig' with { 'pastCharges': pastCharges, 'pastResources': pastResources, @@ -54,7 +54,7 @@ {% endif %} {% if futureCharges|length > 0 or futureResources|length > 0 %} -

    {{ 'Future budget'|trans }}

    +

    {{ 'Future budget'|trans }}

    {% include '@ChillBudget/Budget/_future_budget.html.twig' with { 'futureResources': futureResources, 'futureCharges': futureCharges, diff --git a/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_current_budget.html.twig b/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_current_budget.html.twig index 27a77df1d..d8626aee2 100644 --- a/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_current_budget.html.twig +++ b/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_current_budget.html.twig @@ -1,20 +1,14 @@ {% from '@ChillBudget/Budget/_macros.html.twig' import table_elements, table_results %} -{# -

    {{ 'Actual budget'|trans }}

    -#} - -
    -

    {{ 'Actual resources'|trans }}

    +
    +

    {{ 'Actual resources'|trans }}

    {% if actualResources|length > 0 %} {{ table_elements(actualResources, 'resource') }} {% else %} {{ 'No resources registered'|trans }} {% endif %} -
    -
    -

    {{ 'Actual charges'|trans }}

    +

    {{ 'Actual charges'|trans }}

    {% if actualCharges|length > 0 %} {{ table_elements(actualCharges, 'charge') }} {% else %} diff --git a/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_future_budget.html.twig b/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_future_budget.html.twig index 1547d8749..62f4e3e96 100644 --- a/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_future_budget.html.twig +++ b/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_future_budget.html.twig @@ -20,32 +20,23 @@ aria-labelledby="heading_future_{{ entity.id }}" data-bs-parent="#future_{{ entity.id }}"> -
    -

    {{ 'Future resources'|trans }}

    +
    +

    {{ 'Future resources'|trans }}

    {% if futureResources|length > 0 %} -
    - {{ table_elements(futureResources, 'resource') }} -
    + {{ table_elements(futureResources, 'resource') }} {% else %} -
    - {{ 'No future resources registered'|trans }} -
    + {{ 'No future resources registered'|trans }} {% endif %} -
    -
    -

    {{ 'Future charges'|trans }}

    + +

    {{ 'Future charges'|trans }}

    {% if futureCharges|length > 0 %} -
    - {{ table_elements(futureCharges, 'charge') }} -
    + {{ table_elements(futureCharges, 'charge') }} {% else %} -
    - {{ 'No future charges registered'|trans }} -
    + {{ 'No future charges registered'|trans }} {% endif %}
    -
    \ No newline at end of file +
    diff --git a/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_past_budget.html.twig b/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_past_budget.html.twig index 14573048e..ad0a12755 100644 --- a/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_past_budget.html.twig +++ b/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_past_budget.html.twig @@ -20,34 +20,24 @@ aria-labelledby="heading_past_{{ entity.id }}" data-bs-parent="#past_{{ entity.id }}"> -
    -

    {{ 'Past resources'|trans }}

    +
    +

    {{ 'Past resources'|trans }}

    {% if pastResources|length > 0 %} -
    - {{ table_elements(pastResources, 'resource') }} -
    + {{ table_elements(pastResources, 'resource') }} {% else %} -
    - {{ 'No past resources registered'|trans }} -
    + {{ 'No past resources registered'|trans }} {% endif %} -
    -
    -

    {{ 'Past charges'|trans }}

    +

    {{ 'Past charges'|trans }}

    {% if pastCharges|length > 0 %} -
    - {{ table_elements(pastCharges, 'charge') }} -
    + {{ table_elements(pastCharges, 'charge') }} {% else %} -
    - {{ 'No past charges registered'|trans }} -
    + {{ 'No past charges registered'|trans }} {% endif %}
    - \ No newline at end of file + diff --git a/src/Bundle/ChillBudgetBundle/Resources/views/Household/index.html.twig b/src/Bundle/ChillBudgetBundle/Resources/views/Household/index.html.twig index 310220df1..1df92b297 100644 --- a/src/Bundle/ChillBudgetBundle/Resources/views/Household/index.html.twig +++ b/src/Bundle/ChillBudgetBundle/Resources/views/Household/index.html.twig @@ -24,16 +24,14 @@ } %} {# -
    -

    {{ 'Budget calculator'|trans }}

    -
    - {{ table_results(wholeCharges, wholeResources) }} -
    +
    +

    {{ 'Budget calculator'|trans }}

    + {{ table_results(wholeCharges, wholeResources) }}
    #} {% if household.getCurrentMembers|length > 0 %} -

    {{ 'Budget household members'|trans }}

    +

    {{ 'Budget household members'|trans }}

    {% for hm in household.getCurrentMembers %} {% set member = hm.person %} @@ -57,6 +55,8 @@ aria-labelledby="heading_{{ member.id }}" data-bs-parent="#nonCurrent"> +

    {{ 'Budget for %name%'|trans({'%name%': member.firstName ~ " " ~ member.lastName }) }}

    + {% include 'ChillBudgetBundle:Budget:_budget.html.twig' with { 'resources': member.getBudgetResources, 'charges': member.getBudgetCharges, diff --git a/src/Bundle/ChillBudgetBundle/Resources/views/Person/index.html.twig b/src/Bundle/ChillBudgetBundle/Resources/views/Person/index.html.twig index c365b9b84..18d04b889 100644 --- a/src/Bundle/ChillBudgetBundle/Resources/views/Person/index.html.twig +++ b/src/Bundle/ChillBudgetBundle/Resources/views/Person/index.html.twig @@ -24,7 +24,7 @@ } %}
    -

    {{ 'Budget calculator'|trans }}

    +

    {{ 'Budget calculator'|trans }}

    {{ table_results(charges, resources) }}
    diff --git a/src/Bundle/ChillBudgetBundle/translations/messages.fr.yml b/src/Bundle/ChillBudgetBundle/translations/messages.fr.yml index 5d71f4228..73add43ed 100644 --- a/src/Bundle/ChillBudgetBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillBudgetBundle/translations/messages.fr.yml @@ -9,17 +9,17 @@ See complete budget: Voir budget complet Hide budget: Masquer Hide budget of %name%: Masquer budget de %name% Resource element type: Nature de la ressource -Actual budget: Éléments actuels du budget +Actual budget: Éléments actuels Actual resources: Ressources actuelles Actual resources for %name%: Ressources actuelles de %name% Actual charges for %name%: Charges actuelles de %name% Actual charges: Charges actuelles -Past budget: Éléments du budget passé +Past budget: Éléments passés Show past budget: Montrer budget passé Show future budget: Montrer budget future Past resources: Ressources passées Past charges: Charges passées -Future budget: Futurs éléments du budget +Future budget: Éléments futurs Future resources: Ressources futures Future charges: Charges futures Budget element type: Nature From cb0ff88318856f0b9369c1996b9e90596c85794f Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Mon, 24 Apr 2023 13:29:45 +0200 Subject: [PATCH 022/724] Fix action column width --- .../Resources/public/page/chillbudget.scss | 24 ++++--------------- .../Resources/views/Budget/_macros.html.twig | 21 +++++++--------- 2 files changed, 14 insertions(+), 31 deletions(-) diff --git a/src/Bundle/ChillBudgetBundle/Resources/public/page/chillbudget.scss b/src/Bundle/ChillBudgetBundle/Resources/public/page/chillbudget.scss index cca1b1a4a..79f40dc76 100644 --- a/src/Bundle/ChillBudgetBundle/Resources/public/page/chillbudget.scss +++ b/src/Bundle/ChillBudgetBundle/Resources/public/page/chillbudget.scss @@ -28,29 +28,15 @@ h4.family-title { } } -.budget-table { - th.charge { - background-color: $col_charge; - } -} -.budget-table { - th.resource { - background-color: $col_resource; - } -} -.budget-table { +table.budget-table { th, td { padding: 10px; text-align: right; } - td.column-wide { - width: 20%; - } - td.column-small { - width: 15%; - &.right { - align-items: right; - } + th.charge { background-color: $col_charge; } + th.resource { background-color: $col_resource; } + td.column-fixed { + width: 9.5em; } } diff --git a/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_macros.html.twig b/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_macros.html.twig index 42090984a..70e96d96c 100644 --- a/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_macros.html.twig +++ b/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_macros.html.twig @@ -13,25 +13,22 @@ {% for f in elements %} {% set total = total + f.amount %}
    - - - {% if f.isResource %} - {{ f.resource.name|localize_translatable_string }} - {% else %} - {{ f.charge.name|localize_translatable_string }} - {% endif %} - + + {% if f.isResource %} + {{ f.resource.name|localize_translatable_string }} + {% else %} + {{ f.charge.name|localize_translatable_string }} + {% endif %} {{ f.amount|format_currency('EUR') }} + {{ f.amount|format_currency('EUR') }} {% if f.endDate is not null %} {{ f.startDate|format_date('short') ~ ' - ' ~ f.endDate|format_date('short') }} {% else %} {{ 'depuis le ' ~ f.startDate|format_date('short') }} {% endif %} +
      {% if is_granted('CHILL_BUDGET_ELEMENT_SEE', f) %}
    • From 8fd9010ea5affa9dac91bcb6dd12416fc229d2c4 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Mon, 24 Apr 2023 14:44:26 +0200 Subject: [PATCH 023/724] fix event bundle stuffs - adapt event templates - event bundle: fix deprecated deps injections - fix error with n=0 not iterated into querybuilder with centers loop --- .../Resources/views/Event/list.html.twig | 10 ++++-- .../views/Event/listByPerson.html.twig | 2 +- .../views/Event/newPickCenter.html.twig | 4 +-- .../Resources/views/Event/show.html.twig | 20 +++++------ .../ChillEventBundle/Search/EventSearch.php | 35 ++++++++++--------- .../config/services/repositories.yaml | 2 +- .../config/services/search.yaml | 15 ++++---- .../translations/messages.fr.yml | 2 +- 8 files changed, 47 insertions(+), 43 deletions(-) diff --git a/src/Bundle/ChillEventBundle/Resources/views/Event/list.html.twig b/src/Bundle/ChillEventBundle/Resources/views/Event/list.html.twig index 8d5f49da8..d6f871125 100644 --- a/src/Bundle/ChillEventBundle/Resources/views/Event/list.html.twig +++ b/src/Bundle/ChillEventBundle/Resources/views/Event/list.html.twig @@ -2,11 +2,15 @@

      {% transchoice total with { '%pattern%' : pattern } %}%total% events match the search %pattern%{% endtranschoice %}

      + {% if events|length > 0 %}

      {{ 'Results %start%-%end% of %total%'|trans({ '%start%' : start, '%end%': start + events|length, '%total%' : total } ) }}

      - - +
      @@ -25,7 +29,7 @@
      • {# {% if is_granted('CHILL_EVENT_SEE_DETAILS', event) %} #} - + {{ 'See'|trans }} {# {% endif %} #} diff --git a/src/Bundle/ChillEventBundle/Resources/views/Event/listByPerson.html.twig b/src/Bundle/ChillEventBundle/Resources/views/Event/listByPerson.html.twig index ef2dae85c..ec9ebf76a 100644 --- a/src/Bundle/ChillEventBundle/Resources/views/Event/listByPerson.html.twig +++ b/src/Bundle/ChillEventBundle/Resources/views/Event/listByPerson.html.twig @@ -24,7 +24,7 @@ {% block content %}

        {{ 'Events participation' |trans }}

        -
      {{ 'Name'|trans }}
      +
      diff --git a/src/Bundle/ChillEventBundle/Resources/views/Event/newPickCenter.html.twig b/src/Bundle/ChillEventBundle/Resources/views/Event/newPickCenter.html.twig index a10d754e6..71c68002a 100644 --- a/src/Bundle/ChillEventBundle/Resources/views/Event/newPickCenter.html.twig +++ b/src/Bundle/ChillEventBundle/Resources/views/Event/newPickCenter.html.twig @@ -18,10 +18,10 @@
    • - {{ form_widget(form.submit, { 'attr' : { 'class' : 'btn btn-chill-green' } }) }} + {{ form_widget(form.submit, { 'attr' : { 'class' : 'btn btn-submit' } }) }}
    • - + {{ form_end(form) }} {% endblock %} diff --git a/src/Bundle/ChillEventBundle/Resources/views/Event/show.html.twig b/src/Bundle/ChillEventBundle/Resources/views/Event/show.html.twig index 4ce92a200..31eaf0df6 100644 --- a/src/Bundle/ChillEventBundle/Resources/views/Event/show.html.twig +++ b/src/Bundle/ChillEventBundle/Resources/views/Event/show.html.twig @@ -1,14 +1,14 @@ {% extends '@ChillEvent/layout.html.twig' %} {% block title 'Event : %label%'|trans({ '%label%' : event.name } ) %} - -{% import 'ChillPersonBundle:Person:macro.html.twig' as person_macro %} + +{% import 'ChillPersonBundle:Person:macro.html.twig' as person_macro %} {% block event_content -%}

      {{ 'Details of an event'|trans }}

      -
      {{ 'Date'|trans }}
      +
      @@ -33,7 +33,7 @@
      {{ 'Name'|trans }}
      - +
        {% set returnPath = app.request.get('return_path') %} @@ -64,13 +64,13 @@
      - +

      {{ 'Participations'|trans }}

      {% set count = event.participations|length %}

      {% transchoice count %}%count% participations to this event{% endtranschoice %}

      - + {% if count > 0 %} - +
      @@ -108,10 +108,10 @@ {% endfor %}
      {{ 'Person'|trans }}
      - - + + {% endif %} - +
        {% if count > 0 %}
      • {{ 'Edit all the participations'|trans }}
      • diff --git a/src/Bundle/ChillEventBundle/Search/EventSearch.php b/src/Bundle/ChillEventBundle/Search/EventSearch.php index a7ac22592..6bb3d435d 100644 --- a/src/Bundle/ChillEventBundle/Search/EventSearch.php +++ b/src/Bundle/ChillEventBundle/Search/EventSearch.php @@ -12,13 +12,14 @@ declare(strict_types=1); namespace Chill\EventBundle\Search; use Chill\EventBundle\Entity\Event; +use Chill\EventBundle\Repository\EventRepository; use Chill\MainBundle\Pagination\PaginatorFactory; use Chill\MainBundle\Search\AbstractSearch; use Chill\MainBundle\Search\SearchInterface; use Chill\MainBundle\Security\Authorization\AuthorizationHelper; -use Doctrine\ORM\EntityRepository; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; +use Symfony\Component\Security\Core\Security; use Symfony\Component\Templating\EngineInterface as TemplatingEngine; use function count; @@ -40,15 +41,17 @@ class EventSearch extends AbstractSearch { public const NAME = 'event_regular'; + private $security; + /** - * @var EntityRepository + * @var EventRepository */ private $er; /** * @var AuthorizationHelper */ - private $helper; + private $authorizationHelper; /** * @var PaginatorFactory @@ -60,21 +63,16 @@ class EventSearch extends AbstractSearch */ private $templating; - /** - * @var \Chill\MainBundle\Entity\User - */ - private $user; - public function __construct( - TokenStorageInterface $tokenStorage, - EntityRepository $eventRepository, + Security $security, + EventRepository $eventRepository, AuthorizationHelper $authorizationHelper, TemplatingEngine $templating, PaginatorFactory $paginatorFactory ) { - $this->user = $tokenStorage->getToken()->getUser(); + $this->security = $security; $this->er = $eventRepository; - $this->helper = $authorizationHelper; + $this->authorizationHelper = $authorizationHelper; $this->templating = $templating; $this->paginationFactory = $paginatorFactory; } @@ -101,7 +99,7 @@ class EventSearch extends AbstractSearch if ('html' === $format) { return $this->templating->render( - 'ChillEventBundle:Event:list.html.twig', + '@ChillEvent/Event/list.html.twig', [ 'events' => $this->search($terms, $start, $limit, $options), 'pattern' => $this->recomposePattern($terms, $this->getAvailableTerms(), $terms['_domain']), @@ -140,8 +138,10 @@ class EventSearch extends AbstractSearch protected function composeQuery(QueryBuilder &$qb, $terms) { // add security clauses - $reachableCenters = $this->helper - ->getReachableCenters($this->user, 'CHILL_EVENT_SEE'); + $reachableCenters = $this->authorizationHelper->getReachableCenters( + $this->security->getUser(), + 'CHILL_EVENT_SEE' + ); if (count($reachableCenters) === 0) { // add a clause to block all events @@ -152,8 +152,9 @@ class EventSearch extends AbstractSearch $orWhere = $qb->expr()->orX(); foreach ($reachableCenters as $center) { - $circles = $this->helper->getReachableScopes( - $this->user, + $n = $n+1; + $circles = $this->authorizationHelper->getReachableScopes( + $this->security->getUser(), 'CHILL_EVENT_SEE', $center ); diff --git a/src/Bundle/ChillEventBundle/config/services/repositories.yaml b/src/Bundle/ChillEventBundle/config/services/repositories.yaml index 4d627f625..ff20d094e 100644 --- a/src/Bundle/ChillEventBundle/config/services/repositories.yaml +++ b/src/Bundle/ChillEventBundle/config/services/repositories.yaml @@ -17,7 +17,7 @@ services: factory: ['@doctrine.orm.entity_manager', getRepository] arguments: - 'Chill\EventBundle\Entity\Role' - + chill_event.repository.status: class: Doctrine\ORM\EntityRepository factory: ['@doctrine.orm.entity_manager', getRepository] diff --git a/src/Bundle/ChillEventBundle/config/services/search.yaml b/src/Bundle/ChillEventBundle/config/services/search.yaml index 2df3db26f..5c55fc388 100644 --- a/src/Bundle/ChillEventBundle/config/services/search.yaml +++ b/src/Bundle/ChillEventBundle/config/services/search.yaml @@ -1,12 +1,11 @@ services: - chill_event.search_events: - class: Chill\EventBundle\Search\EventSearch + Chill\EventBundle\Search\EventSearch: arguments: - - "@security.token_storage" - - "@chill_event.repository.event" - - "@chill.main.security.authorization.helper" - - "@templating" - - "@chill_main.paginator_factory" + $security: '@Symfony\Component\Security\Core\Security' + $eventRepository: "@chill_event.repository.event" + $authorizationHelper: "@chill.main.security.authorization.helper" + $templating: "@templating" + $paginatorFactory: "@chill_main.paginator_factory" tags: - { name: chill.search, alias: 'event_regular' } - + diff --git a/src/Bundle/ChillEventBundle/translations/messages.fr.yml b/src/Bundle/ChillEventBundle/translations/messages.fr.yml index 8810c040a..6b6ac220f 100644 --- a/src/Bundle/ChillEventBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillEventBundle/translations/messages.fr.yml @@ -30,7 +30,7 @@ The event was created: L'événement a été créé #crud participation Edit all the participations: Modifier toutes les participations -Edit the participation: Modifier la participation +Edit the participation: Modifier la participation à l'événement Participation Edit: Modifier une participation Add a participation: Ajouter un participant Participation creation: Ajouter une participation From cdaca533a02967ef36301564446da12b8f5ec2b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 25 Apr 2023 17:37:27 +0200 Subject: [PATCH 024/724] Feature: [export] allow to check multiple geographical layers in geographical aggregators BC: saved exports which activated this layers won't work any more. This is the query to find them: ```sql SELECT * FROM chill_main_saved_export WHERE options->'export'->'export'->'aggregators'->'accompanyingcourse_geographicalunitstat_aggregator'->>'enabled' = '1' ``` --- .../GeographicalUnitStatAggregator.php | 4 +++- .../PersonAggregators/GeographicalUnitAggregator.php | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php index 80781b823..6f10dbaa7 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php @@ -98,7 +98,7 @@ final class GeographicalUnitStatAggregator implements AggregatorInterface 'acp_geog_units' ); - $qb->andWhere($qb->expr()->eq('acp_geog_units.layer', ':acp_geog_unit_layer')); + $qb->andWhere($qb->expr()->in('acp_geog_units.layer', ':acp_geog_unit_layer')); $qb->setParameter('acp_geog_unit_layer', $data['level']); @@ -131,6 +131,8 @@ final class GeographicalUnitStatAggregator implements AggregatorInterface 'choice_label' => function (GeographicalUnitLayer $item) { return $this->translatableStringHelper->localize($item->getName()); }, + 'multiple' => true, + 'expanded' => true, ]); } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GeographicalUnitAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GeographicalUnitAggregator.php index 6193f3c61..9d34edfca 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GeographicalUnitAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GeographicalUnitAggregator.php @@ -103,6 +103,8 @@ class GeographicalUnitAggregator implements AggregatorInterface 'choice_label' => function (GeographicalUnitLayer $item) { return $this->translatableStringHelper->localize($item->getName()); }, + 'multiple' => true, + 'expanded' => true, ]); } From ba43b6b02579406da96131827ccb749567f59016 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Tue, 25 Apr 2023 15:41:28 +0200 Subject: [PATCH 025/724] Fix: align ux design styles to chill theme --- .../views/Button/button_group.html.twig | 2 +- .../AccompanyingCourseWork/_item.html.twig | 2 +- .../_objectifs_results_evaluations.html.twig | 17 +++++++++-------- .../views/AccompanyingCourseWork/show.html.twig | 11 +++++------ ...owEvaluationDocumentInNotification.html.twig | 17 +++++++++-------- .../showInNotification.html.twig | 2 +- 6 files changed, 26 insertions(+), 25 deletions(-) diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/Button/button_group.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/Button/button_group.html.twig index f83cafd51..2babe1ad9 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/views/Button/button_group.html.twig +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/Button/button_group.html.twig @@ -1,5 +1,5 @@ {%- import "@ChillDocStore/Macro/macro.html.twig" as m -%} -
        {% if displayNotification is defined and displayNotification == true %}
      • - diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_objectifs_results_evaluations.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_objectifs_results_evaluations.html.twig index e66dde463..4ab0b6e08 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_objectifs_results_evaluations.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_objectifs_results_evaluations.html.twig @@ -118,9 +118,7 @@
      • {% endif %} {% endif %} -
      -
    {% if recordAction is defined %} @@ -136,16 +134,19 @@ {% import "@ChillDocStore/Macro/macro.html.twig" as m %} {% import "@ChillDocStore/Macro/macro_mimeicon.html.twig" as mm %} {% if e.documents|length > 0 %} - - +
    {% for d in e.documents %} - + - - {% endfor %}
    {{ d.title }} {{ mm.mimeIcon(d.storedObject.type) }} - + + + {{ d.storedObject|chill_document_button_group(d.title, is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_UPDATE', w), {'small': true}) }} {{ d.storedObject|chill_document_button_group(d.title, is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_UPDATE', w), {'small': true}) }}
    diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/show.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/show.html.twig index 96b47e6c9..8d508539d 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/show.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/show.html.twig @@ -35,7 +35,6 @@ {{ 'Back to the list'|trans }} -
  • {{ macro.workflowButton(work) }}
  • {% if accompanyingCourse.hasUser and accompanyingCourse.user is not same as(app.user) %} @@ -46,21 +45,21 @@ {{ 'notification.Notify referrer'|trans }}
  • - "{{ 'notification.Notify any'|trans }}" + {{ 'notification.Notify any'|trans }}
  • {% else %} - + - {% endif %} +
  • {{ macro.workflowButton(work) }}
  • {% if is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_UPDATE', work) %}
  • - + >{{ 'Edit'|trans }}
  • {% endif %} {% if is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_DELETE', work) %} diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showEvaluationDocumentInNotification.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showEvaluationDocumentInNotification.html.twig index 6d5d22a7d..4ea70d9f0 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showEvaluationDocumentInNotification.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showEvaluationDocumentInNotification.html.twig @@ -1,23 +1,24 @@ {% macro recordAction(document) %} {% import "@ChillDocStore/Macro/macro_mimeicon.html.twig" as mm %}
    - - +
    - - - + + + title="{{ 'See the document'|trans }}"> +
    {{ document.title }}{{ mm.mimeIcon(document.storedObject.type) }}{{ document.title }}{{ mm.mimeIcon(document.storedObject.type) }} +
    {% endmacro %} {% if document is not null %} -
    +
    {% if is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_EVALUATION_DOCUMENT_SHOW', document) %} -
    +
    {% include '@ChillPerson/AccompanyingCourseWork/_objectifs_results_evaluations.html.twig' with { 'w': document.accompanyingPeriodWorkEvaluation.accompanyingPeriodWork, 'd': document.storedObject, diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showInNotification.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showInNotification.html.twig index 9b06e306c..fdafcc040 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showInNotification.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showInNotification.html.twig @@ -6,7 +6,7 @@ {% endmacro %} {% if work is not null %} -
    +
    {% if is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_SEE', work) %} {% include "@ChillPerson/AccompanyingCourseWork/_item.html.twig" with { 'itemBlocClass': 'bg-chill-llight-gray', From 67b32341d17209061c2c00f3527338df71862027 Mon Sep 17 00:00:00 2001 From: Lucas Silva Date: Thu, 27 Apr 2023 10:58:31 +0200 Subject: [PATCH 026/724] adding referer in list action --- .../AccompanyingCourseWork/_item.html.twig | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_item.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_item.html.twig index 7891d8cd4..4c056eec5 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_item.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_item.html.twig @@ -133,10 +133,23 @@
      {% if displayNotification is defined and displayNotification == true %}
    • - - - +
      + {% if accompanyingCourse.hasUser and accompanyingCourse.user is not same as(app.user) %} + + + {% else %} + + + {% endif %} +
    • {% endif %}
    • {{ macro.workflowButton(w) }}
    • From 0a2f41c8a0acd6587638a93b2a44f4859c28618b Mon Sep 17 00:00:00 2001 From: Lucas Silva Date: Thu, 27 Apr 2023 10:59:09 +0200 Subject: [PATCH 027/724] adding button notification in edit view of a work. --- .../vuejs/AccompanyingCourseWorkEdit/App.vue | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue index 755e4455c..e6ee7de79 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue @@ -296,7 +296,13 @@ @go-to-generate-workflow="goToGenerateWorkflow" > - +
    • + +
    diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_objectifs_results_evaluations.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_objectifs_results_evaluations.html.twig index 57305095d..fc2891ca6 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_objectifs_results_evaluations.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_objectifs_results_evaluations.html.twig @@ -3,6 +3,7 @@ # - displayContent: [short|long] default: short #} {% if w.results|length > 0 %} + @@ -64,9 +65,11 @@ - {% for e in w.accompanyingPeriodWorkEvaluations %} - - + + - - {% endfor %} + + + {% endfor %} + {% endif %}

    {{ 'accompanying_course_work.goal'|trans }}

    + {% if onlyone %} + {% for e in w.accompanyingPeriodWorkEvaluations %} + {% if evalId is defined and evalId == e.id %} +
    • {{ e.evaluation.title|localize_translatable_string }} @@ -78,13 +81,15 @@ {% if e.endDate %}
    • - {{ 'accompanying_course_work.end_date'|trans ~ ' : ' }} + {{ 'accompanying_course_work.end_date'|trans ~ ' : ' }} {{ e.endDate|format_date('short') }}
    • {% else %} {% if displayContent is defined and displayContent == 'long' %}
    • - {{ 'accompanying_course_work.end_date'|trans ~ ' : ' }} + {{ 'accompanying_course_work.end_date'|trans ~ ' : ' }} {{ 'Not given'|trans }}
    • {% endif %} @@ -92,13 +97,15 @@ {% if e.maxDate %}
    • - {{ 'accompanying_course_work.max_date'|trans ~ ' : ' }} + {{ 'accompanying_course_work.max_date'|trans ~ ' : ' }} {{ e.maxDate|format_date('short') }}
    • {% else %} {% if displayContent is defined and displayContent == 'long' %}
    • - {{ 'accompanying_course_work.max_date'|trans ~ ' : ' }} + {{ 'accompanying_course_work.max_date'|trans ~ ' : ' }} {{ 'Not given'|trans }}
    • {% endif %} @@ -107,13 +114,15 @@ {% if e.warningInterval and e.warningInterval.d > 0 %}
    • {% set days = (e.warningInterval.d + e.warningInterval.m * 30) %} - {{ 'accompanying_course_work.warning_interval'|trans ~ ' : ' }} + {{ 'accompanying_course_work.warning_interval'|trans ~ ' : ' }} {{ 'accompanying_course_work.%days% days before max_date'|trans({'%days%': days }) }}
    • {% else %} {% if displayContent is defined and displayContent == 'long' %}
    • - {{ 'accompanying_course_work.warning_interval'|trans ~ ' : ' }} + {{ 'accompanying_course_work.warning_interval'|trans ~ ' : ' }} {{ 'Not given'|trans }}
    • {% endif %} @@ -122,55 +131,145 @@ {% if e.timeSpent is not null and e.timeSpent > 0 %}
    • {% set minutes = (e.timeSpent / 60) %} - {{ 'accompanying_course_work.timeSpent'|trans ~ ' : ' }} {{ 'duration.minute'|trans({ '{m}' : minutes }) }} + {{ 'accompanying_course_work.timeSpent'|trans ~ ' : ' }} {{ 'duration.minute'|trans({ '{m}' : minutes }) }}
    • {% elseif displayContent is defined and displayContent == 'long' %}
    • - {{ 'accompanying_course_work.timeSpent'|trans ~ ' : ' }} + {{ 'accompanying_course_work.timeSpent'|trans ~ ' : ' }} {{ 'Not given'|trans }}
    • {% endif %}
    - {% if recordAction is defined %} - {{ recordAction }} - {% endif %} + {% endif %} - {% if displayContent is defined and displayContent == 'long' %} - {% if e.comment is not empty %} -
    {{ e.comment|chill_entity_render_box }}
    + {% endfor %} + {% if recordAction is defined %} + {{ recordAction }} + {% endif %} + {% else %} + {% for e in w.accompanyingPeriodWorkEvaluations %} +
    +
      +
    • + {{ e.evaluation.title|localize_translatable_string }} +
        +
      • + {{ 'accompanying_course_work.start_date'|trans ~ ' : ' }} + {{ e.startDate|format_date('short') }} +
      • + + {% if e.endDate %} +
      • + {{ 'accompanying_course_work.end_date'|trans ~ ' : ' }} + {{ e.endDate|format_date('short') }} +
      • + {% else %} + {% if displayContent is defined and displayContent == 'long' %} +
      • + {{ 'accompanying_course_work.end_date'|trans ~ ' : ' }} + {{ 'Not given'|trans }} +
      • + {% endif %} + {% endif %} + + {% if e.maxDate %} +
      • + {{ 'accompanying_course_work.max_date'|trans ~ ' : ' }} + {{ e.maxDate|format_date('short') }} +
      • + {% else %} + {% if displayContent is defined and displayContent == 'long' %} +
      • + {{ 'accompanying_course_work.max_date'|trans ~ ' : ' }} + {{ 'Not given'|trans }} +
      • + {% endif %} + {% endif %} + + {% if e.warningInterval and e.warningInterval.d > 0 %} +
      • + {% set days = (e.warningInterval.d + e.warningInterval.m * 30) %} + {{ 'accompanying_course_work.warning_interval'|trans ~ ' : ' }} + {{ 'accompanying_course_work.%days% days before max_date'|trans({'%days%': days }) }} +
      • + {% else %} + {% if displayContent is defined and displayContent == 'long' %} +
      • + {{ 'accompanying_course_work.warning_interval'|trans ~ ' : ' }} + {{ 'Not given'|trans }} +
      • + {% endif %} + {% endif %} + + {% if e.timeSpent is not null and e.timeSpent > 0 %} +
      • + {% set minutes = (e.timeSpent / 60) %} + {{ 'accompanying_course_work.timeSpent'|trans ~ ' : ' }} {{ 'duration.minute'|trans({ '{m}' : minutes }) }} +
      • + {% elseif displayContent is defined and displayContent == 'long' %} +
      • + {{ 'accompanying_course_work.timeSpent'|trans ~ ' : ' }} + {{ 'Not given'|trans }} +
      • + {% endif %} +
      +
    • +
    + {% if recordAction is defined %} + {{ recordAction }} {% endif %} - {% import "@ChillDocStore/Macro/macro.html.twig" as m %} - {% import "@ChillDocStore/Macro/macro_mimeicon.html.twig" as mm %} - {% if e.documents|length > 0 %} - - {% for d in e.documents %} - - - - - - {% endfor %} -
    {{ d.title }}{{ mm.mimeIcon(d.storedObject.type) }} - - {{ d.storedObject|chill_document_button_group(d.title, is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_UPDATE', w), {'small': true}) }} -
    - {% else %} - {{ 'No document found'|trans }} + {% if displayContent is defined and displayContent == 'long' %} + + {% if e.comment is not empty %} +
    {{ e.comment|chill_entity_render_box }}
    + {% endif %} + + {% import "@ChillDocStore/Macro/macro.html.twig" as m %} + {% import "@ChillDocStore/Macro/macro_mimeicon.html.twig" as mm %} + {% if e.documents|length > 0 %} + + {% for d in e.documents %} + + + + + + {% endfor %} +
    {{ d.title }}{{ mm.mimeIcon(d.storedObject.type) }} + + {{ d.storedObject|chill_document_button_group(d.title, is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_UPDATE', w), {'small': true}) }} +
    + {% else %} + {{ 'No document found'|trans }} + {% endif %} + + {% endif %} - - - {% endif %} -
    {% endif %} diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showEvaluationDocumentInNotification.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showEvaluationDocumentInNotification.html.twig index 4ea70d9f0..b4df52254 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showEvaluationDocumentInNotification.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showEvaluationDocumentInNotification.html.twig @@ -23,7 +23,9 @@ 'w': document.accompanyingPeriodWorkEvaluation.accompanyingPeriodWork, 'd': document.storedObject, 'displayContent': 'short', - 'recordAction': _self.recordAction(document) + 'recordAction': _self.recordAction(document), + 'onlyone' : true, + 'evalId': document.accompanyingPeriodWorkEvaluation.id } %}
    From 1a66a081425475f5aa54559fbac2afa9db9632b7 Mon Sep 17 00:00:00 2001 From: Lucas Silva Date: Thu, 27 Apr 2023 16:01:35 +0200 Subject: [PATCH 029/724] Button in vue edit --- .../components/FormEvaluation.vue | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue index 7dcb595a3..6d40acae5 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue @@ -103,6 +103,11 @@
      + +
    • + +
    • { console.log(e); throw e; }); }, + goToGenerateDocumentNotification(document){ + const callback = (data) => { + let evaluation = data.accompanyingPeriodWorkEvaluations.find(e => e.key === this.evaluation.key); + window.location.assign(`/fr/notification/create?entityClass=Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluationDocument&entityId=${document.id}&returnPath=/fr/person/accompanying-period/work/${evaluation.id}/edit`) + }; + return this.$store.dispatch('submit', callback) + .catch(e => {console.log(e); throw e}); + } }, } From f2e1c73f37be6a78a1786fe0ddd9629c2babfc0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 18 Apr 2023 21:16:40 +0200 Subject: [PATCH 030/724] Build parts to track info on accompanying period --- .../ChillMainBundle/ChillMainBundle.php | 3 + .../SynchronizeEntityInfoViewsCommand.php | 40 ++++++++++ .../EntityInfo/ViewEntityInfoManager.php | 48 +++++++++++ .../ViewEntityInfoProviderInterface.php | 19 +++++ .../ChillMainBundle/config/services.yaml | 4 + .../config/services/command.yaml | 4 + .../ChillPersonBundle/ChillPersonBundle.php | 3 + .../AccompanyingPeriodInfo.php | 79 +++++++++++++++++++ .../AccompanyingPeriodInfoQueryBuilder.php | 49 ++++++++++++ ...kEndQueryPartForAccompanyingPeriodInfo.php | 64 +++++++++++++++ ...tartQueryPartForAccompanyingPeriodInfo.php | 64 +++++++++++++++ ...nyingPeriodInfoUnionQueryPartInterface.php | 36 +++++++++ ...companyingPeriodViewEntityInfoProvider.php | 42 ++++++++++ .../ChillPersonBundle/config/services.yaml | 4 + 14 files changed, 459 insertions(+) create mode 100644 src/Bundle/ChillMainBundle/Command/SynchronizeEntityInfoViewsCommand.php create mode 100644 src/Bundle/ChillMainBundle/Service/EntityInfo/ViewEntityInfoManager.php create mode 100644 src/Bundle/ChillMainBundle/Service/EntityInfo/ViewEntityInfoProviderInterface.php create mode 100644 src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodInfo.php create mode 100644 src/Bundle/ChillPersonBundle/Service/EntityInfo/AccompanyingPeriodInfoQueryBuilder.php create mode 100644 src/Bundle/ChillPersonBundle/Service/EntityInfo/AccompanyingPeriodInfoQueryPart/AccompanyingPeriodWorkEndQueryPartForAccompanyingPeriodInfo.php create mode 100644 src/Bundle/ChillPersonBundle/Service/EntityInfo/AccompanyingPeriodInfoQueryPart/AccompanyingPeriodWorkStartQueryPartForAccompanyingPeriodInfo.php create mode 100644 src/Bundle/ChillPersonBundle/Service/EntityInfo/AccompanyingPeriodInfoUnionQueryPartInterface.php create mode 100644 src/Bundle/ChillPersonBundle/Service/EntityInfo/AccompanyingPeriodViewEntityInfoProvider.php diff --git a/src/Bundle/ChillMainBundle/ChillMainBundle.php b/src/Bundle/ChillMainBundle/ChillMainBundle.php index 9e276311d..8e115fa4f 100644 --- a/src/Bundle/ChillMainBundle/ChillMainBundle.php +++ b/src/Bundle/ChillMainBundle/ChillMainBundle.php @@ -30,6 +30,7 @@ use Chill\MainBundle\Search\SearchApiInterface; use Chill\MainBundle\Security\ProvideRoleInterface; use Chill\MainBundle\Security\Resolver\CenterResolverInterface; use Chill\MainBundle\Security\Resolver\ScopeResolverInterface; +use Chill\MainBundle\Service\EntityInfo\ViewEntityInfoProviderInterface; use Chill\MainBundle\Templating\Entity\ChillEntityRenderInterface; use Chill\MainBundle\Templating\UI\NotificationCounterInterface; use Chill\MainBundle\Workflow\EntityWorkflowHandlerInterface; @@ -62,6 +63,8 @@ class ChillMainBundle extends Bundle ->addTag('chill_main.workflow_handler'); $container->registerForAutoconfiguration(CronJobInterface::class) ->addTag('chill_main.cron_job'); + $container->registerForAutoconfiguration(ViewEntityInfoProviderInterface::class) + ->addTag('chill_main.entity_info_provider'); $container->addCompilerPass(new SearchableServicesCompilerPass()); $container->addCompilerPass(new ConfigConsistencyCompilerPass()); diff --git a/src/Bundle/ChillMainBundle/Command/SynchronizeEntityInfoViewsCommand.php b/src/Bundle/ChillMainBundle/Command/SynchronizeEntityInfoViewsCommand.php new file mode 100644 index 000000000..c3dc8a87c --- /dev/null +++ b/src/Bundle/ChillMainBundle/Command/SynchronizeEntityInfoViewsCommand.php @@ -0,0 +1,40 @@ +setDescription('Update or create sql views which provide info for various entities'); + } + + protected function execute(InputInterface $input, OutputInterface $output): int + { + $this->viewEntityInfoManager->synchronizeOnDB(); + + return 0; + } + +} diff --git a/src/Bundle/ChillMainBundle/Service/EntityInfo/ViewEntityInfoManager.php b/src/Bundle/ChillMainBundle/Service/EntityInfo/ViewEntityInfoManager.php new file mode 100644 index 000000000..6b7b81224 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Service/EntityInfo/ViewEntityInfoManager.php @@ -0,0 +1,48 @@ +connection->transactional(function (Connection $conn): void { + foreach ($this->vienEntityInfoProviders as $viewProvider) { + foreach ($this->createOrReplaceViewSQL($viewProvider, $viewProvider->getViewName()) as $sql) { + $conn->executeQuery($sql); + } + } + }); + } + + /** + * @return array + */ + private function createOrReplaceViewSQL(ViewEntityInfoProviderInterface $viewProvider, string $viewName): array + { + return [ + "DROP VIEW IF EXISTS {$viewName}", + sprintf("CREATE VIEW {$viewName} AS %s", $viewProvider->getViewQuery()) + ]; + } +} diff --git a/src/Bundle/ChillMainBundle/Service/EntityInfo/ViewEntityInfoProviderInterface.php b/src/Bundle/ChillMainBundle/Service/EntityInfo/ViewEntityInfoProviderInterface.php new file mode 100644 index 000000000..392c0f82c --- /dev/null +++ b/src/Bundle/ChillMainBundle/Service/EntityInfo/ViewEntityInfoProviderInterface.php @@ -0,0 +1,19 @@ +addWidgetFactory(new PersonListWidgetFactory()); $container->addCompilerPass(new AccompanyingPeriodTimelineCompilerPass()); + $container->registerForAutoconfiguration(AccompanyingPeriodInfoUnionQueryPartInterface::class) + ->addTag('chill_person.accompanying_period_info_part'); } } diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodInfo.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodInfo.php new file mode 100644 index 000000000..795247eda --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodInfo.php @@ -0,0 +1,79 @@ + $query->getAccompanyingPeriodIdColumn(), + '{related_entity_column_id}' => $query->getRelatedEntityColumn(), + '{related_entity_id_column_id}' => $query->getRelatedEntityIdColumn(), + '{user_id}' => $query->getUserIdColumn(), + '{datetime}' => $query->getDateTimeColumn(), + '{discriminator}' => $query->getDiscriminator(), + '{metadata}' => $query->getMetadataColumn(), + '{from_statement}' => $query->getFromStatement(), + '{where_statement}' => '' === $query->getWhereClause() ? '' : 'WHERE '.$query->getWhereClause(), + ] + ); + } +} diff --git a/src/Bundle/ChillPersonBundle/Service/EntityInfo/AccompanyingPeriodInfoQueryPart/AccompanyingPeriodWorkEndQueryPartForAccompanyingPeriodInfo.php b/src/Bundle/ChillPersonBundle/Service/EntityInfo/AccompanyingPeriodInfoQueryPart/AccompanyingPeriodWorkEndQueryPartForAccompanyingPeriodInfo.php new file mode 100644 index 000000000..8ba9b9640 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Service/EntityInfo/AccompanyingPeriodInfoQueryPart/AccompanyingPeriodWorkEndQueryPartForAccompanyingPeriodInfo.php @@ -0,0 +1,64 @@ + $this->builder->buildQuery($part), + iterator_to_array($this->unions) + ) + ); + } + + public function getViewName(): string + { + return 'view_chill_person_accompanying_period_info'; + } +} diff --git a/src/Bundle/ChillPersonBundle/config/services.yaml b/src/Bundle/ChillPersonBundle/config/services.yaml index f989b5dda..45548d843 100644 --- a/src/Bundle/ChillPersonBundle/config/services.yaml +++ b/src/Bundle/ChillPersonBundle/config/services.yaml @@ -98,3 +98,7 @@ services: autowire: true autoconfigure: true resource: '../Workflow/' + + Chill\PersonBundle\Service\EntityInfo\AccompanyingPeriodViewEntityInfoProvider: + arguments: + $unions: !tagged_iterator chill_person.accompanying_period_info_part From 4974995ea2f4e4f89adf2619c799c0a7d6cc9fa7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 19 Apr 2023 17:32:32 +0200 Subject: [PATCH 031/724] Feature: add evaluation info to accompangyin preiod info --- ...nMaxQueryPartForAccompanyingPeriodInfo.php | 66 +++++++++++++++++++ ...tartQueryPartForAccompanyingPeriodInfo.php | 66 +++++++++++++++++++ ...DateQueryPartForAccompanyingPeriodInfo.php | 65 ++++++++++++++++++ 3 files changed, 197 insertions(+) create mode 100644 src/Bundle/ChillPersonBundle/Service/EntityInfo/AccompanyingPeriodInfoQueryPart/AccompanyingPeriodWorkEvaluationMaxQueryPartForAccompanyingPeriodInfo.php create mode 100644 src/Bundle/ChillPersonBundle/Service/EntityInfo/AccompanyingPeriodInfoQueryPart/AccompanyingPeriodWorkEvaluationStartQueryPartForAccompanyingPeriodInfo.php create mode 100644 src/Bundle/ChillPersonBundle/Service/EntityInfo/AccompanyingPeriodInfoQueryPart/AccompanyingPeriodWorkEvaluationWarningDateQueryPartForAccompanyingPeriodInfo.php diff --git a/src/Bundle/ChillPersonBundle/Service/EntityInfo/AccompanyingPeriodInfoQueryPart/AccompanyingPeriodWorkEvaluationMaxQueryPartForAccompanyingPeriodInfo.php b/src/Bundle/ChillPersonBundle/Service/EntityInfo/AccompanyingPeriodInfoQueryPart/AccompanyingPeriodWorkEvaluationMaxQueryPartForAccompanyingPeriodInfo.php new file mode 100644 index 000000000..b89f77460 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Service/EntityInfo/AccompanyingPeriodInfoQueryPart/AccompanyingPeriodWorkEvaluationMaxQueryPartForAccompanyingPeriodInfo.php @@ -0,0 +1,66 @@ + Date: Thu, 20 Apr 2023 12:41:04 +0200 Subject: [PATCH 032/724] Feature: takes document and evaluation update into account for AccompanyingPeriodInfo --- ...dateQueryPartForAccompanyingPeriodInfo.php | 65 ++++++++++++++++++ ...dateQueryPartForAccompanyingPeriodInfo.php | 67 +++++++++++++++++++ ...DateQueryPartForAccompanyingPeriodInfo.php | 2 +- 3 files changed, 133 insertions(+), 1 deletion(-) create mode 100644 src/Bundle/ChillPersonBundle/Service/EntityInfo/AccompanyingPeriodInfoQueryPart/AccompanyingPeriodWorkEvaluationDocumentUpdateQueryPartForAccompanyingPeriodInfo.php create mode 100644 src/Bundle/ChillPersonBundle/Service/EntityInfo/AccompanyingPeriodInfoQueryPart/AccompanyingPeriodWorkEvaluationUpdateQueryPartForAccompanyingPeriodInfo.php diff --git a/src/Bundle/ChillPersonBundle/Service/EntityInfo/AccompanyingPeriodInfoQueryPart/AccompanyingPeriodWorkEvaluationDocumentUpdateQueryPartForAccompanyingPeriodInfo.php b/src/Bundle/ChillPersonBundle/Service/EntityInfo/AccompanyingPeriodInfoQueryPart/AccompanyingPeriodWorkEvaluationDocumentUpdateQueryPartForAccompanyingPeriodInfo.php new file mode 100644 index 000000000..68d761cc2 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Service/EntityInfo/AccompanyingPeriodInfoQueryPart/AccompanyingPeriodWorkEvaluationDocumentUpdateQueryPartForAccompanyingPeriodInfo.php @@ -0,0 +1,65 @@ + Date: Thu, 20 Apr 2023 16:22:16 +0200 Subject: [PATCH 033/724] Feature: takes activity into account for AccompanyingPeriodInfo --- ...DateQueryPartForAccompanyingPeriodInfo.php | 64 +++++++++++++++++++ .../ChillActivityBundle/config/services.yaml | 5 +- .../Entity/AccompanyingPeriod.php | 9 +++ 3 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 src/Bundle/ChillActivityBundle/Service/EntityInfo/AccompanyingPeriodInfoQueryPart/ActivityUsersDateQueryPartForAccompanyingPeriodInfo.php diff --git a/src/Bundle/ChillActivityBundle/Service/EntityInfo/AccompanyingPeriodInfoQueryPart/ActivityUsersDateQueryPartForAccompanyingPeriodInfo.php b/src/Bundle/ChillActivityBundle/Service/EntityInfo/AccompanyingPeriodInfoQueryPart/ActivityUsersDateQueryPartForAccompanyingPeriodInfo.php new file mode 100644 index 000000000..bb70d6e87 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Service/EntityInfo/AccompanyingPeriodInfoQueryPart/ActivityUsersDateQueryPartForAccompanyingPeriodInfo.php @@ -0,0 +1,64 @@ + Date: Fri, 21 Apr 2023 14:59:04 +0200 Subject: [PATCH 034/724] Feature: Change accompanying period info step in a cronjob --- composer.json | 1 + .../ChillMainBundle/config/services.yaml | 3 + .../config/services/clock.yaml | 4 + .../AccompanyingPeriodStepChangeCronjob.php | 46 +++++++++ ...mpanyingPeriodStepChangeMessageHandler.php | 38 ++++++++ ...mpanyingPeriodStepChangeRequestMessage.php | 47 ++++++++++ .../AccompanyingPeriodStepChangeRequestor.php | 88 ++++++++++++++++++ .../AccompanyingPeriodStepChanger.php | 58 ++++++++++++ .../ChillPersonExtension.php | 39 ++++++-- .../DependencyInjection/Configuration.php | 9 ++ .../Entity/AccompanyingPeriod.php | 11 ++- .../AccompanyingPeriodInfoRepository.php | 93 +++++++++++++++++++ ...ompanyingPeriodInfoRepositoryInterface.php | 38 ++++++++ ...ccompanyingPeriodStepChangeCronjobTest.php | 55 +++++++++++ .../config/services/accompanyingPeriod.yaml | 5 + 15 files changed, 527 insertions(+), 8 deletions(-) create mode 100644 src/Bundle/ChillMainBundle/config/services/clock.yaml create mode 100644 src/Bundle/ChillPersonBundle/AccompanyingPeriod/Lifecycle/AccompanyingPeriodStepChangeCronjob.php create mode 100644 src/Bundle/ChillPersonBundle/AccompanyingPeriod/Lifecycle/AccompanyingPeriodStepChangeMessageHandler.php create mode 100644 src/Bundle/ChillPersonBundle/AccompanyingPeriod/Lifecycle/AccompanyingPeriodStepChangeRequestMessage.php create mode 100644 src/Bundle/ChillPersonBundle/AccompanyingPeriod/Lifecycle/AccompanyingPeriodStepChangeRequestor.php create mode 100644 src/Bundle/ChillPersonBundle/AccompanyingPeriod/Lifecycle/AccompanyingPeriodStepChanger.php create mode 100644 src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodInfoRepository.php create mode 100644 src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodInfoRepositoryInterface.php create mode 100644 src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/Lifecycle/AccompanyingPeriodStepChangeCronjobTest.php diff --git a/composer.json b/composer.json index b47856954..f6d3eb27a 100644 --- a/composer.json +++ b/composer.json @@ -34,6 +34,7 @@ "sensio/framework-extra-bundle": "^5.5", "spomky-labs/base64url": "^2.0", "symfony/browser-kit": "^4.4", + "symfony/clock": "^6.2", "symfony/css-selector": "^4.4", "symfony/expression-language": "^4.4", "symfony/form": "^4.4", diff --git a/src/Bundle/ChillMainBundle/config/services.yaml b/src/Bundle/ChillMainBundle/config/services.yaml index 54153ccfb..5976cb8b0 100644 --- a/src/Bundle/ChillMainBundle/config/services.yaml +++ b/src/Bundle/ChillMainBundle/config/services.yaml @@ -1,6 +1,9 @@ parameters: # cl_chill_main.example.class: Chill\MainBundle\Example +imports: + - ./services/clock.yaml + services: _defaults: autowire: true diff --git a/src/Bundle/ChillMainBundle/config/services/clock.yaml b/src/Bundle/ChillMainBundle/config/services/clock.yaml new file mode 100644 index 000000000..0629cd869 --- /dev/null +++ b/src/Bundle/ChillMainBundle/config/services/clock.yaml @@ -0,0 +1,4 @@ +# temporary, waiting for symfony 6.0 to load clock +services: + Symfony\Component\Clock\NativeClock: ~ + Symfony\Component\Clock\ClockInterface: '@Symfony\Component\Clock\NativeClock' diff --git a/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Lifecycle/AccompanyingPeriodStepChangeCronjob.php b/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Lifecycle/AccompanyingPeriodStepChangeCronjob.php new file mode 100644 index 000000000..bec31d45d --- /dev/null +++ b/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Lifecycle/AccompanyingPeriodStepChangeCronjob.php @@ -0,0 +1,46 @@ +clock->now(); + + if ($now->sub(new \DateInterval('P1D')) < $cronJobExecution->getLastStart()) { + return false; + } + + return in_array((int) $now->format('H'), [1, 2, 3, 4, 5, 6], true); + } + + public function getKey(): string + { + return 'accompanying-period-step-change'; + } + + public function run(): void + { + ($this->requestor)(); + } +} diff --git a/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Lifecycle/AccompanyingPeriodStepChangeMessageHandler.php b/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Lifecycle/AccompanyingPeriodStepChangeMessageHandler.php new file mode 100644 index 000000000..881b3999a --- /dev/null +++ b/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Lifecycle/AccompanyingPeriodStepChangeMessageHandler.php @@ -0,0 +1,38 @@ +accompanyingPeriodRepository->find($message->getPeriodId())) { + throw new \RuntimeException(self::LOG_PREFIX . 'Could not find period with this id: '. $message->getPeriodId()); + } + + ($this->changer)($period, $message->getTransition()); + } + +} diff --git a/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Lifecycle/AccompanyingPeriodStepChangeRequestMessage.php b/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Lifecycle/AccompanyingPeriodStepChangeRequestMessage.php new file mode 100644 index 000000000..457e78d35 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Lifecycle/AccompanyingPeriodStepChangeRequestMessage.php @@ -0,0 +1,47 @@ +periodId = $period; + } else { + if (null !== $id = $period->getId()) { + $this->periodId = $id; + } + + throw new \LogicException("This AccompanyingPeriod does not have and id yet"); + } + } + + public function getPeriodId(): int + { + return $this->periodId; + } + + public function getTransition(): string + { + return $this->transition; + } +} diff --git a/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Lifecycle/AccompanyingPeriodStepChangeRequestor.php b/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Lifecycle/AccompanyingPeriodStepChangeRequestor.php new file mode 100644 index 000000000..3d4979608 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Lifecycle/AccompanyingPeriodStepChangeRequestor.php @@ -0,0 +1,88 @@ +get('chill_person')['accompanying_period_lifecycle_delays']; + $this->isMarkInactive = $config['mark_inactive']; + $this->intervalForShortInactive = new \DateInterval($config['mark_inactive_short_after']); + $this->intervalForLongInactive = new \DateInterval($config['mark_inactive_long_after']); + } + + public function __invoke(): void + { + if (!$this->isMarkInactive) { + return; + } + + // get the oldest ones first + foreach ( + $olders = $this->accompanyingPeriodInfoRepository->findAccompanyingPeriodIdInactiveAfter( + $this->intervalForLongInactive, + [AccompanyingPeriod::STEP_CONFIRMED, AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_SHORT] + ) as $accompanyingPeriodId + ) { + $this->logger->debug('request mark period as inactive_short', ['period' => $accompanyingPeriodId]); + $this->messageBus->dispatch(new AccompanyingPeriodStepChangeRequestMessage($accompanyingPeriodId, 'mark_inactive_long')); + } + + // the newest + foreach ( + $this->accompanyingPeriodInfoRepository->findAccompanyingPeriodIdInactiveAfter( + $this->intervalForShortInactive, + [AccompanyingPeriod::STEP_CONFIRMED] + ) as $accompanyingPeriodId + ) { + if (in_array($accompanyingPeriodId, $olders, true)) { + continue; + } + + $this->logger->debug('request mark period as inactive_long', ['period' => $accompanyingPeriodId]); + $this->messageBus->dispatch(new AccompanyingPeriodStepChangeRequestMessage($accompanyingPeriodId, 'mark_inactive_short')); + } + + // a new event has been created => remove inactive long, or short + foreach ( + $this->accompanyingPeriodInfoRepository->findAccompanyingPeriodIdActiveSince( + $this->intervalForShortInactive, + [AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_SHORT, AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_LONG] + ) as $accompanyingPeriodId + ) { + $this->logger->debug('request mark period as active', ['period' => $accompanyingPeriodId]); + $this->messageBus->dispatch(new AccompanyingPeriodStepChangeRequestMessage($accompanyingPeriodId, 'mark_active')); + } + } + +} diff --git a/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Lifecycle/AccompanyingPeriodStepChanger.php b/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Lifecycle/AccompanyingPeriodStepChanger.php new file mode 100644 index 000000000..05dfee6db --- /dev/null +++ b/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Lifecycle/AccompanyingPeriodStepChanger.php @@ -0,0 +1,58 @@ +workflowRegistry->get($period, $workflowName); + + if (!$workflow->can($period, $transition)) { + $this->logger->info(self::LOG_PREFIX . 'not able to apply the transition on period', [ + 'period_id' => $period->getId(), + 'transition' => $transition + ]); + + return; + } + + $workflow->apply($period, $transition); + + $this->entityManager->flush(); + + $this->logger->info(self::LOG_PREFIX . 'could apply a transition', [ + 'period_id' => $period->getId(), + 'transition' => $transition + ]); + } +} diff --git a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php index 6a2dc924e..569dd1502 100644 --- a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php +++ b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php @@ -15,6 +15,7 @@ use Chill\MainBundle\DependencyInjection\MissingBundleException; use Chill\MainBundle\Security\Authorization\ChillExportVoter; use Chill\PersonBundle\Controller\HouseholdCompositionTypeApiController; use Chill\PersonBundle\Doctrine\DQL\AddressPart; +use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodCommentVoter; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodResourceVoter; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; @@ -1010,18 +1011,42 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac ], 'initial_marking' => 'DRAFT', 'places' => [ - 'DRAFT', - 'CONFIRMED', - 'CLOSED', + AccompanyingPeriod::STEP_DRAFT, + AccompanyingPeriod::STEP_CONFIRMED, + AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_SHORT, + AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_LONG, + AccompanyingPeriod::STEP_CLOSED, ], 'transitions' => [ 'confirm' => [ - 'from' => 'DRAFT', - 'to' => 'CONFIRMED', + 'from' => AccompanyingPeriod::STEP_DRAFT, + 'to' => AccompanyingPeriod::STEP_CONFIRMED, + ], + 'mark_inactive_short' => [ + 'from' => AccompanyingPeriod::STEP_CONFIRMED, + 'to' => AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_SHORT, + ], + 'mark_inactive_long' => [ + 'from' => [ + AccompanyingPeriod::STEP_CONFIRMED, + AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_SHORT + ], + 'to' => AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_LONG, + ], + 'mark_active' => [ + 'from' => [ + AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_LONG, + AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_SHORT, + ], + 'to' => AccompanyingPeriod::STEP_CONFIRMED ], 'close' => [ - 'from' => 'CONFIRMED', - 'to' => 'CLOSED', + 'from' => [ + AccompanyingPeriod::STEP_CONFIRMED, + AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_SHORT, + AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_LONG, + ], + 'to' => AccompanyingPeriod::STEP_CLOSED, ], ], ], diff --git a/src/Bundle/ChillPersonBundle/DependencyInjection/Configuration.php b/src/Bundle/ChillPersonBundle/DependencyInjection/Configuration.php index a591663ad..64ca07066 100644 --- a/src/Bundle/ChillPersonBundle/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillPersonBundle/DependencyInjection/Configuration.php @@ -128,6 +128,15 @@ class Configuration implements ConfigurationInterface ->info('Can we have more than one simultaneous accompanying period in the same time. Default false.') ->defaultValue(false) ->end() + ->arrayNode('accompanying_period_lifecycle_delays') + ->addDefaultsIfNotSet() + ->info('Delays before marking an accompanying period as inactive') + ->children() + ->booleanNode('mark_inactive')->defaultTrue()->end() + ->scalarNode('mark_inactive_short_after')->defaultValue('P6M')->end() + ->scalarNode('mark_inactive_long_after')->defaultValue('P2Y')->end() + ->end() + ->end() // end of 'accompanying_period_lifecycle_delays ->end() // children of 'root', parent = root ; diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php index f7eeec28e..a724596a9 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php @@ -116,7 +116,16 @@ class AccompanyingPeriod implements * confirmed, but no activity (Activity, AccompanyingPeriod, ...) * has been associated, or updated, within this accompanying period. */ - public const STEP_CONFIRMED_INACTIVE = 'CONFIRMED_INACTIVE'; + public const STEP_CONFIRMED_INACTIVE_SHORT = 'CONFIRMED_INACTIVE_SHORT'; + + /** + * Mark an accompanying period as confirmed, but inactive + * + * this means that the accompanying period **is** + * confirmed, but no activity (Activity, AccompanyingPeriod, ...) + * has been associated, or updated, within this accompanying period. + */ + public const STEP_CONFIRMED_INACTIVE_LONG = 'CONFIRMED_INACTIVE_LONG'; /** * Mark an accompanying period as "draft". diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodInfoRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodInfoRepository.php new file mode 100644 index 000000000..57925b131 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodInfoRepository.php @@ -0,0 +1,93 @@ +entityRepository = $em->getRepository($this->getClassName()); + } + + public function findAccompanyingPeriodIdInactiveAfter(DateInterval $interval, array $statuses = []): array + { + $query = $this->em->createQuery(); + $baseDql = 'SELECT DISTINCT IDENTITY(ai.accompanyingPeriod) FROM '.AccompanyingPeriodInfo::class.' ai JOIN ai.accompanyingPeriod a WHERE NOT EXISTS + (SELECT 1 FROM ' . AccompanyingPeriodInfo::class . ' aiz WHERE aiz.infoDate > :after AND IDENTITY(aiz.accompanyingPeriod) = IDENTITY(ai.accompanyingPeriod))'; + + if ([] !== $statuses) { + $dql = $baseDql . ' AND a.step IN (:statuses)'; + $query->setParameter('statuses', $statuses); + } else { + $dql = $baseDql; + } + + return $query->setDQL($dql) + ->setParameter('after', $this->clock->now()->sub($interval)) + ->getSingleColumnResult(); + } + + public function findAccompanyingPeriodIdActiveSince(DateInterval $interval, array $statuses = []): array + { + $query = $this->em->createQuery(); + $baseDql = 'SELECT DISTINCT IDENTITY(ai.accompanyingPeriod) FROM ' . AccompanyingPeriodInfo::class . ' ai + JOIN ai.accompanyingPeriod a WHERE ai.infoDate > :after'; + + if ([] !== $statuses) { + $dql = $baseDql . ' AND a.step IN (:statuses)'; + $query->setParameter('statuses', $statuses); + } else { + $dql = $baseDql; + } + + return $query->setDQL($dql) + ->setParameter('after', $this->clock->now()->sub($interval)) + ->getSingleColumnResult(); + } + + public function find($id): ?AccompanyingPeriodInfo + { + throw new LogicException("Calling an accompanying period info by his id does not make sense"); + } + + public function findAll(): array + { + return $this->entityRepository->findAll(); + } + + public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array + { + return $this->entityRepository->findBy($criteria, $orderBy, $limit, $offset); + } + + public function findOneBy(array $criteria): ?AccompanyingPeriodInfo + { + return $this->entityRepository->findOneBy($criteria); + } + + public function getClassName(): string + { + return AccompanyingPeriodInfo::class; + } + +} diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodInfoRepositoryInterface.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodInfoRepositoryInterface.php new file mode 100644 index 000000000..07397cd48 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodInfoRepositoryInterface.php @@ -0,0 +1,38 @@ + + */ +interface AccompanyingPeriodInfoRepositoryInterface extends ObjectRepository +{ + /** + * Return a list of id for inactive accompanying periods + * + * @param \DateInterval $interval + * @param list $statuses + * @return list + */ + public function findAccompanyingPeriodIdInactiveAfter(\DateInterval $interval, array $statuses = []): array; + + /** + * @param \DateInterval $interval + * @param list $statuses + * @return list + */ + public function findAccompanyingPeriodIdActiveSince(\DateInterval $interval, array $statuses = []): array; +} diff --git a/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/Lifecycle/AccompanyingPeriodStepChangeCronjobTest.php b/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/Lifecycle/AccompanyingPeriodStepChangeCronjobTest.php new file mode 100644 index 000000000..5c3c29179 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/Lifecycle/AccompanyingPeriodStepChangeCronjobTest.php @@ -0,0 +1,55 @@ +prophesize(AccompanyingPeriodStepChangeRequestor::class); + $clock = new MockClock($datetime); + + $cronJob = new AccompanyingPeriodStepChangeCronjob($clock, $requestor->reveal()); + $cronJobExecution = (new CronJobExecution($cronJob->getKey()))->setLastStart($lastExecutionStart); + + $this->assertEquals($canRun, $cronJob->canRun($cronJobExecution)); + } + + public function provideRunTimes(): iterable + { + // can run, during the night + yield ['2023-01-15T01:00:00+02:00', new \DateTimeImmutable('2023-01-14T00:00:00+02:00'), true]; + + // can not run, not during the night + yield ['2023-01-15T10:00:00+02:00', new \DateTimeImmutable('2023-01-14T00:00:00+02:00'), false]; + + // can not run: not enough elapsed time + yield ['2023-01-15T01:00:00+02:00', new \DateTimeImmutable('2023-01-15T00:30:00+02:00'), false]; + } + +} diff --git a/src/Bundle/ChillPersonBundle/config/services/accompanyingPeriod.yaml b/src/Bundle/ChillPersonBundle/config/services/accompanyingPeriod.yaml index 7d7f9072d..e6b35de77 100644 --- a/src/Bundle/ChillPersonBundle/config/services/accompanyingPeriod.yaml +++ b/src/Bundle/ChillPersonBundle/config/services/accompanyingPeriod.yaml @@ -25,6 +25,11 @@ services: autowire: true autoconfigure: true + Chill\PersonBundle\AccompanyingPeriod\Lifecycle\: + resource: './../../AccompanyingPeriod/Lifecycle' + autowire: true + autoconfigure: true + Chill\PersonBundle\AccompanyingPeriod\Events\UserRefEventSubscriber: autowire: true autoconfigure: true From fcbc00d0f1b5c7490d3965c4bce1fe8314f8cb00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 21 Apr 2023 15:59:33 +0200 Subject: [PATCH 035/724] Feature: force to add updatedAt and createdAt even if no user iss associated --- .../Event/TrackCreateUpdateSubscriber.php | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Doctrine/Event/TrackCreateUpdateSubscriber.php b/src/Bundle/ChillMainBundle/Doctrine/Event/TrackCreateUpdateSubscriber.php index bf493c344..26a302b13 100644 --- a/src/Bundle/ChillMainBundle/Doctrine/Event/TrackCreateUpdateSubscriber.php +++ b/src/Bundle/ChillMainBundle/Doctrine/Event/TrackCreateUpdateSubscriber.php @@ -41,12 +41,12 @@ class TrackCreateUpdateSubscriber implements EventSubscriber { $object = $args->getObject(); - if ( - $object instanceof TrackCreationInterface - && $this->security->getUser() instanceof User - ) { - $object->setCreatedBy($this->security->getUser()); + if ($object instanceof TrackCreationInterface) { $object->setCreatedAt(new DateTimeImmutable('now')); + + if ($this->security->getUser() instanceof User) { + $object->setCreatedBy($this->security->getUser()); + } } $this->onUpdate($object); @@ -61,12 +61,12 @@ class TrackCreateUpdateSubscriber implements EventSubscriber protected function onUpdate(object $object): void { - if ( - $object instanceof TrackUpdateInterface - && $this->security->getUser() instanceof User - ) { - $object->setUpdatedBy($this->security->getUser()); - $object->setUpdatedAt(new DateTimeImmutable('now')); + if ($object instanceof TrackUpdateInterface) { + $object->setUpdatedAt(new DateTimeImmutable('now')); + + if ($this->security->getUser() instanceof User) { + $object->setUpdatedBy($this->security->getUser()); + } } } } From c5989de12059b990c913ecd093d1dd32b3819cce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 24 Apr 2023 15:38:53 +0200 Subject: [PATCH 036/724] Feature: Adapt UI to show new steps --- .../public/vuejs/AccompanyingCourse/App.vue | 2 +- .../vuejs/AccompanyingCourse/components/Banner.vue | 14 ++++++++++++-- .../public/vuejs/AccompanyingCourse/js/i18n.js | 4 +++- .../views/Person/list_with_period.html.twig | 12 +++++++----- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/App.vue index 51fc2c1d0..c66214b0b 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/App.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/App.vue @@ -14,7 +14,7 @@ - + diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Banner.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Banner.vue index dcade7e0f..fb8a09784 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Banner.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Banner.vue @@ -11,12 +11,22 @@ {{ $t('course.step.draft') }} - - + + {{ $t('course.step.active') }} + + + {{ $t('course.step.inactive_short') }} + + + + + {{ $t('course.step.inactive_long') }} + + {{ $t('course.open_at') }}{{ $d(accompanyingCourse.openingDate.datetime, 'text') }} diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js index 8bbd5c4ca..1a46a79ca 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js @@ -21,7 +21,9 @@ const appMessages = { step: { draft: "Brouillon", active: "En file active", - closed: "Cloturé" + closed: "Cloturé", + inactive_short: "Hors file active", + inactive_long: "Pré-archivé", }, open_at: "ouvert le ", by: "par ", diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Person/list_with_period.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Person/list_with_period.html.twig index 4497b8226..4735fb5a3 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Person/list_with_period.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Person/list_with_period.html.twig @@ -52,11 +52,13 @@ {% endif %} {% if acp.step == 'DRAFT' %} - {{ 'course.draft'|trans }} - {% endif %} - - {% if acp.step == 'CLOSED' %} - {{ 'course.closed'|trans }} + {{ 'course.draft'|trans }} + {% elseif acp.step == 'CLOSED' %} + {{ 'course.closed'|trans }} + {% elseif acp.step == 'CONFIRMED_INACTIVE_SHORT' %} + {{ 'course.inactive_short'|trans }} + {% elseif acp.step == 'CONFIRMED_INACTIVE_LONG' %} + {{ 'course.inactive_long'|trans }} {% endif %}
    From e80a6e417b271428a646e214c9e54dce30d76cad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 24 Apr 2023 15:39:39 +0200 Subject: [PATCH 037/724] Feature: Track update of entities if no user is associated to the request This happens in scripts/cli (messenger, ...) --- .../Doctrine/Event/TrackCreateUpdateSubscriber.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Doctrine/Event/TrackCreateUpdateSubscriber.php b/src/Bundle/ChillMainBundle/Doctrine/Event/TrackCreateUpdateSubscriber.php index 26a302b13..166003f73 100644 --- a/src/Bundle/ChillMainBundle/Doctrine/Event/TrackCreateUpdateSubscriber.php +++ b/src/Bundle/ChillMainBundle/Doctrine/Event/TrackCreateUpdateSubscriber.php @@ -62,11 +62,11 @@ class TrackCreateUpdateSubscriber implements EventSubscriber protected function onUpdate(object $object): void { if ($object instanceof TrackUpdateInterface) { - $object->setUpdatedAt(new DateTimeImmutable('now')); + $object->setUpdatedAt(new DateTimeImmutable('now')); - if ($this->security->getUser() instanceof User) { - $object->setUpdatedBy($this->security->getUser()); - } + if ($this->security->getUser() instanceof User) { + $object->setUpdatedBy($this->security->getUser()); + } } } } From 229af2e4f98a48cbaa25cb1e9ea8b790d1bd92c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 24 Apr 2023 15:40:20 +0200 Subject: [PATCH 038/724] Feature: Adapt filters and aggregators with new steps --- .../translations/messages.fr.yml | 1 + .../Entity/AccompanyingPeriod.php | 5 ++-- .../StepAggregator.php | 12 ++++++-- .../Export/Export/ListAccompanyingPeriod.php | 30 +++++++++++++++++++ .../AccompanyingCourseFilters/StepFilter.php | 10 ++++--- .../StepFilterTest.php | 2 ++ .../translations/messages.fr.yml | 17 +++++++++-- 7 files changed, 64 insertions(+), 13 deletions(-) diff --git a/src/Bundle/ChillMainBundle/translations/messages.fr.yml b/src/Bundle/ChillMainBundle/translations/messages.fr.yml index b8349ce2e..14de6dbf0 100644 --- a/src/Bundle/ChillMainBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillMainBundle/translations/messages.fr.yml @@ -564,6 +564,7 @@ export: _as_string: Adresse formattée confidential: Adresse confidentielle ? isNoAddress: Adresse incomplète ? + steps: Escaliers _lat: Latitude _lon: Longitude diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php index a724596a9..a8e191df3 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php @@ -358,6 +358,7 @@ class AccompanyingPeriod implements /** * @ORM\Column(type="string", length=32, nullable=true) * @Groups({"read"}) + * @var AccompanyingPeriod::STEP_* */ private string $step = self::STEP_DRAFT; @@ -730,11 +731,9 @@ class AccompanyingPeriod implements if ($this->getStep() === self::STEP_DRAFT) { return [[self::STEP_DRAFT]]; } - - if ($this->getStep() === self::STEP_CONFIRMED) { + if (str_starts_with($this->getStep(), 'CONFIRM')) { return [[self::STEP_DRAFT, self::STEP_CONFIRMED]]; } - if ($this->getStep() === self::STEP_CLOSED) { return [[self::STEP_DRAFT, self::STEP_CONFIRMED, self::STEP_CLOSED]]; } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/StepAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/StepAggregator.php index 84dbd4e69..85cfc3190 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/StepAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/StepAggregator.php @@ -86,13 +86,19 @@ final class StepAggregator implements AggregatorInterface return function ($value): string { switch ($value) { case AccompanyingPeriod::STEP_DRAFT: - return $this->translator->trans('Draft'); + return $this->translator->trans('course.draft'); case AccompanyingPeriod::STEP_CONFIRMED: - return $this->translator->trans('Confirmed'); + return $this->translator->trans('course.confirmed'); case AccompanyingPeriod::STEP_CLOSED: - return $this->translator->trans('Closed'); + return $this->translator->trans('course.closed'); + + case AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_SHORT: + return $this->translator->trans('course.inactive_short'); + + case AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_LONG: + return $this->translator->trans('course.inactive_long'); case '_header': return 'Step'; diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php index 045039930..3fd7ee01a 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php @@ -41,6 +41,7 @@ use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Query\Expr\Join; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; +use Symfony\Contracts\Translation\TranslatorInterface; use function strlen; class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface @@ -100,6 +101,8 @@ class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface private TranslatableStringHelperInterface $translatableStringHelper; + private TranslatorInterface $translator; + private UserHelper $userHelper; public function __construct( @@ -113,6 +116,7 @@ class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface SocialIssueRepository $socialIssueRepository, SocialIssueRender $socialIssueRender, TranslatableStringHelperInterface $translatableStringHelper, + TranslatorInterface $translator, RollingDateConverterInterface $rollingDateConverter, UserHelper $userHelper ) { @@ -126,6 +130,7 @@ class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface $this->thirdPartyRender = $thirdPartyRender; $this->thirdPartyRepository = $thirdPartyRepository; $this->translatableStringHelper = $translatableStringHelper; + $this->translator = $translator; $this->rollingDateConverter = $rollingDateConverter; $this->userHelper = $userHelper; } @@ -250,6 +255,31 @@ class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface ); }; + case 'step': + return function ($value) { + return match ($value) { + '_header' => 'export.list.acp.step', + null => '', + AccompanyingPeriod::STEP_DRAFT => $this->translator->trans('course.draft'), + AccompanyingPeriod::STEP_CONFIRMED => $this->translator->trans('course.confirmed'), + AccompanyingPeriod::STEP_CLOSED => $this->translator->trans('course.closed'), + AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_SHORT => $this->translator->trans('course.inactive_short'), + AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_LONG => $this->translator->trans('course.inactive_long'), + default => $value, + }; + }; + + case 'intensity': + return function ($value) { + return match ($value) { + '_header' => 'export.list.acp.intensity', + null => '', + AccompanyingPeriod::INTENSITY_OCCASIONAL => $this->translator->trans('occasional'), + AccompanyingPeriod::INTENSITY_REGULAR => $this->translator->trans('regular'), + default => $value, + }; + }; + default: return static function ($value) use ($key) { if ('_header' === $value) { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/StepFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/StepFilter.php index 240b093b5..8ee798c07 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/StepFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/StepFilter.php @@ -32,9 +32,11 @@ class StepFilter implements FilterInterface private const P = 'acp_step_filter_date'; private const STEPS = [ - 'Draft' => AccompanyingPeriod::STEP_DRAFT, - 'Confirmed' => AccompanyingPeriod::STEP_CONFIRMED, - 'Closed' => AccompanyingPeriod::STEP_CLOSED, + 'course.draft' => AccompanyingPeriod::STEP_DRAFT, + 'course.confirmed' => AccompanyingPeriod::STEP_CONFIRMED, + 'course.closed' => AccompanyingPeriod::STEP_CLOSED, + 'course.inactive_short' => AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_SHORT, + 'course.inactive_long' => AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_LONG, ]; private RollingDateConverterInterface $rollingDateConverter; @@ -96,7 +98,7 @@ class StepFilter implements FilterInterface 'data' => self::DEFAULT_CHOICE, ]) ->add('calc_date', PickRollingDateType::class, [ - 'label' => 'export.acp.filter.by_step.date_calc', + 'label' => 'export.filter.course.by_step.date_calc', 'data' => new RollingDate(RollingDate::T_TODAY), ]); } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/StepFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/StepFilterTest.php index 9388aa8ae..42eec5823 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/StepFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/StepFilterTest.php @@ -40,6 +40,8 @@ final class StepFilterTest extends AbstractFilterTest return [ ['accepted_steps' => AccompanyingPeriod::STEP_DRAFT], ['accepted_steps' => AccompanyingPeriod::STEP_CONFIRMED], + ['accepted_steps' => AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_LONG], + ['accepted_steps' => AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_SHORT], ['accepted_steps' => AccompanyingPeriod::STEP_CLOSED], ]; } diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index d33957ea7..0cdc9e601 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -57,7 +57,7 @@ Add new phone: Ajouter un numéro de téléphone Remove phone: Supprimer 'Notes on contact information': 'Remarques sur les informations de contact' 'Remarks': 'Remarques' -'Spoken languages': 'Langues parlées' +Spoken languages': 'Langues parlées' 'Unknown spoken languages': 'Langues parlées inconnues' Male: Homme Female: Femme @@ -237,8 +237,12 @@ No referrer: Pas d'agent traitant Some peoples does not belong to any household currently. Add them to an household soon: Certains usagers n'appartiennent à aucun ménage actuellement. Renseignez leur ménage dès que possible. Add to household now: Ajouter à un ménage Any resource for this accompanying course: Aucun interlocuteur privilégié pour ce parcours -course.draft: Brouillon -course.closed: Clôturé +course: + draft: Brouillon + closed: Clôturé + inactive_short: Hors file active + inactive_long: Pré-archivé + confirmed: Confirmé Origin: Origine de la demande Delete accompanying period: Supprimer le parcours d'accompagnement Are you sure you want to remove the accompanying period "%id%" ?: Êtes-vous sûr de vouloir supprimer le parcours d'accompagnement %id% ? @@ -1072,6 +1076,8 @@ export: Status: Statut course: + by_step: + date_calc: Date de prise en compte du statut by_user_scope: Computation date for referrer: Date à laquelle le référent était actif by_referrer: @@ -1095,12 +1101,15 @@ export: id: Identifiant du parcours openingDate: Date d'ouverture du parcours closingDate: Date de fermeture du parcours + closingMotive: Motif de cloture + job: Métier confidential: Confidentiel emergency: Urgent intensity: Intensité createdAt: Créé le updatedAt: Dernière mise à jour le acpOrigin: Origine du parcours + origin: Origine du parcourse acpClosingMotive: Motif de fermeture acpJob: Métier du parcours createdBy: Créé par @@ -1120,6 +1129,8 @@ export: acprequestorPerson: Nom du demandeur usager scopes: Services socialIssues: Problématiques sociales + requestorPerson: Demandeur (personne) + requestorThirdParty: Demandeur (tiers) eval: List of evaluations: Liste des évaluations Generate a list of evaluations, filtered on different parameters: Génère une liste des évaluations, filtrée sur différents paramètres. From 5b729e1cb190883593acfe504d1d06888b7fa870 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 27 Apr 2023 12:01:47 +0200 Subject: [PATCH 039/724] add dev docs --- docs/source/development/entity-info.rst | 203 ++++++++++++++++++++++++ docs/source/development/index.rst | 1 + docs/source/development/timelines.rst | 100 ++++++------ 3 files changed, 255 insertions(+), 49 deletions(-) create mode 100644 docs/source/development/entity-info.rst diff --git a/docs/source/development/entity-info.rst b/docs/source/development/entity-info.rst new file mode 100644 index 000000000..72d8b70ea --- /dev/null +++ b/docs/source/development/entity-info.rst @@ -0,0 +1,203 @@ + +.. Copyright (C) 2014 Champs Libres Cooperative SCRLFS +Permission is granted to copy, distribute and/or modify this document +under the terms of the GNU Free Documentation License, Version 1.3 +or any later version published by the Free Software Foundation; +with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. +A copy of the license is included in the section entitled "GNU +Free Documentation License". + +.. _entity-info: + +Stats about event on entity in php world +######################################## + +It is necessary to be able to gather information about events for some entities: + +- when the event has been done; +- who did it; +- ... + +Those "infos" are not linked with right management, like describe in :ref:`timelines`. + + +“infos” for some stats and info about an entity +----------------------------------------------- + +Building an info means: + +- create an Entity, and map this entity to a SQL view (not a regular table); +- use the framework to build this entity dynamically. + +A framework api is built to be able to build multiple “infos” entities +through “union” views: + +- use a command ``bin/console chill:db:sync-views`` to synchronize view (create view if it does not exists, or update + views when new SQL parts are added in the UNION query. Internally, this command call a new ``ViewEntityInfoManager``, + which iterate over available views to build the SQL; +- one can create a new “view entity info” by implementing a + ``ViewEntityInfoProviderInterface`` +- this implementation of the interface is free to create another + interface for building each part of the UNION query. This interface + is created for AccompanyingPeriodInfo: + ``Chill\PersonBundle\Service\EntityInfo\AccompanyingPeriodInfoUnionQueryPartInterface`` + +So, converting new “events” into rows for ``AccompanyingPeriodInfo`` is +just implementing this interface! + +Implementation for AccompanyingPeriod (``AccompanyingPeriod/AccompanyingPeriodInfo``) +------------------------------------------------------------------------------------- + +A class is created for computing some statistical info for an +AccompanyingPeriod: ``AccompanyingPeriod/AccompanyingPeriodInfo``. This +contains information about “something happens”, who did it and when. + +Having those info in table answer some questions like: + +- when is the last and the first action (AccompanyingPeriodWork, + Activity, AccompanyingPeriodWorkEvaluation, …) on the period; +- who is “acting” on the period, and when is the last “action” for each + user. + +The AccompanyingPeriod info is mapped to a SQL view, not a table. The +sql view is built dynamically (see below), and gather infos from +ActivityBundle, PersonBundle, CalendarBundle, … It is possible to create +custom bundle and add info on this view. + +.. code:: php + + /** + * + * @ORM\Entity() + * @ORM\Table(name="view_chill_person_accompanying_period_info") <==== THIS IS A VIEW, NOT A TABLE + */ + class AccompanyingPeriodInfo + { + // ... + } + +Why do we need this ? +~~~~~~~~~~~~~~~~~~~~~ + +For multiple jobs in PHP world: + +- moving the accompanying period to another steps when inactive, + automatically; +- listing all the users which are intervening on the action on a new + “Liste des intervenants” page; +- filtering on exports + +Later, we will launch automatic anonymise for accompanying period and +all related entities through this information. + +How is built the SQL views which is mapped to “info” entities ? +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The AccompanyingPeriodInfo entity is mapped by a SQL view (not a regular +table). + +The sql view is built dynamically, it is a SQL view like this, for now (April 2023): + +.. code:: sql + + create view view_chill_person_accompanying_period_info + (accompanyingperiod_id, relatedentity, relatedentityid, user_id, infodate, discriminator, metadata) as + SELECT w.accompanyingperiod_id, + 'Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork'::text AS relatedentity, + w.id AS relatedentityid, + cpapwr.user_id, + w.enddate AS infodate, + 'accompanying_period_work_end'::text AS discriminator, + '{}'::jsonb AS metadata + FROM chill_person_accompanying_period_work w + LEFT JOIN chill_person_accompanying_period_work_referrer cpapwr ON w.id = cpapwr.accompanyingperiodwork_id + WHERE w.enddate IS NOT NULL + UNION + SELECT cpapw.accompanyingperiod_id, + 'Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation'::text AS relatedentity, + e.id AS relatedentityid, + e.updatedby_id AS user_id, + e.updatedat AS infodate, + 'accompanying_period_work_evaluation_updated_at'::text AS discriminator, + '{}'::jsonb AS metadata + FROM chill_person_accompanying_period_work_evaluation e + JOIN chill_person_accompanying_period_work cpapw ON cpapw.id = e.accompanyingperiodwork_id + WHERE e.updatedat IS NOT NULL + UNION + SELECT cpapw.accompanyingperiod_id, + 'Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation'::text AS relatedentity, + e.id AS relatedentityid, + cpapwr.user_id, + e.maxdate AS infodate, + 'accompanying_period_work_evaluation_start'::text AS discriminator, + '{}'::jsonb AS metadata + FROM chill_person_accompanying_period_work_evaluation e + JOIN chill_person_accompanying_period_work cpapw ON cpapw.id = e.accompanyingperiodwork_id + LEFT JOIN chill_person_accompanying_period_work_referrer cpapwr ON cpapw.id = cpapwr.accompanyingperiodwork_id + WHERE e.maxdate IS NOT NULL + UNION + SELECT cpapw.accompanyingperiod_id, + 'Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation'::text AS relatedentity, + e.id AS relatedentityid, + cpapwr.user_id, + e.startdate AS infodate, + 'accompanying_period_work_evaluation_start'::text AS discriminator, + '{}'::jsonb AS metadata + FROM chill_person_accompanying_period_work_evaluation e + JOIN chill_person_accompanying_period_work cpapw ON cpapw.id = e.accompanyingperiodwork_id + LEFT JOIN chill_person_accompanying_period_work_referrer cpapwr ON cpapw.id = cpapwr.accompanyingperiodwork_id + UNION + SELECT cpapw.accompanyingperiod_id, + 'Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocument'::text AS relatedentity, + doc.id AS relatedentityid, + doc.updatedby_id AS user_id, + doc.updatedat AS infodate, + 'accompanying_period_work_evaluation_document_updated_at'::text AS discriminator, + '{}'::jsonb AS metadata + FROM chill_person_accompanying_period_work_evaluation_document doc + JOIN chill_person_accompanying_period_work_evaluation e ON doc.accompanyingperiodworkevaluation_id = e.id + JOIN chill_person_accompanying_period_work cpapw ON cpapw.id = e.accompanyingperiodwork_id + WHERE doc.updatedat IS NOT NULL + UNION + SELECT cpapw.accompanyingperiod_id, + 'Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation'::text AS relatedentity, + e.id AS relatedentityid, + cpapwr.user_id, + e.maxdate AS infodate, + 'accompanying_period_work_evaluation_max'::text AS discriminator, + '{}'::jsonb AS metadata + FROM chill_person_accompanying_period_work_evaluation e + JOIN chill_person_accompanying_period_work cpapw ON cpapw.id = e.accompanyingperiodwork_id + LEFT JOIN chill_person_accompanying_period_work_referrer cpapwr ON cpapw.id = cpapwr.accompanyingperiodwork_id + WHERE e.maxdate IS NOT NULL + UNION + SELECT w.accompanyingperiod_id, + 'Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork'::text AS relatedentity, + w.id AS relatedentityid, + cpapwr.user_id, + w.startdate AS infodate, + 'accompanying_period_work_start'::text AS discriminator, + '{}'::jsonb AS metadata + FROM chill_person_accompanying_period_work w + LEFT JOIN chill_person_accompanying_period_work_referrer cpapwr ON w.id = cpapwr.accompanyingperiodwork_id + UNION + SELECT activity.accompanyingperiod_id, + 'Chill\ActivityBundle\Entity\Activity'::text AS relatedentity, + activity.id AS relatedentityid, + au.user_id, + activity.date AS infodate, + 'activity_date'::text AS discriminator, + '{}'::jsonb AS metadata + FROM activity + LEFT JOIN activity_user au ON activity.id = au.activity_id + WHERE activity.accompanyingperiod_id IS NOT NULL; + +As you can see, the view gather multiple SELECT queries and bind them +with UNION. + +Each SELECT query is built dynamically, through a class implementing an +interface: ``Chill\PersonBundle\Service\EntityInfo\AccompanyingPeriodInfoUnionQueryPartInterface``, `like +here `__ + +To add new `SELECT` query in different `UNION` parts in the sql view, create a +service and implements this interface: ``Chill\PersonBundle\Service\EntityInfo\AccompanyingPeriodInfoUnionQueryPartInterface``. diff --git a/docs/source/development/index.rst b/docs/source/development/index.rst index 52c541c8e..fd9ae43ba 100644 --- a/docs/source/development/index.rst +++ b/docs/source/development/index.rst @@ -35,6 +35,7 @@ As Chill rely on the `symfony `_ framework, reading the fram manual/index.rst Assets Cron Jobs + Info about entities Layout and UI ************** diff --git a/docs/source/development/timelines.rst b/docs/source/development/timelines.rst index afabdb398..51c0a1bad 100644 --- a/docs/source/development/timelines.rst +++ b/docs/source/development/timelines.rst @@ -6,6 +6,8 @@ A copy of the license is included in the section entitled "GNU Free Documentation License". +.. _timelines: + Timelines ********* @@ -18,24 +20,24 @@ Concept From an user point of view -------------------------- -Chill has two objectives : +Chill has two objectives : * make the administrative tasks more lightweight ; * help social workers to have all information they need to work To reach this second objective, Chill provides a special view: **timeline**. On a timeline view, information is gathered and shown on a single page, from the most recent event to the oldest one. -The information gathered is linked to a *context*. This *context* may be, for instance : +The information gathered is linked to a *context*. This *context* may be, for instance : * a person : events linked to this person are shown on the page ; * a center: events linked to a center are shown. They may concern different peoples ; -* ... +* ... In other word, the *context* is the kind of argument that will be used in the event's query. Let us recall that only the data the user has allowed to see should be shown. -.. seealso:: +.. seealso:: `The issue where the subject was first discussed `_ @@ -43,30 +45,30 @@ Let us recall that only the data the user has allowed to see should be shown. For developers -------------- -The `Main` bundle provides interfaces and services to help to build timelines. +The `Main` bundle provides interfaces and services to help to build timelines. If a bundle wants to *push* information in a timeline, it should be create a service which implements `Chill\MainBundle\Timeline\TimelineProviderInterface`, and tag is with `chill.timeline` and arguments defining the supported context (you may use multiple `chill.timeline` tags in order to support multiple context with a single service/class). -If a bundle wants to provide a new context for a timeline, the service `chill.main.timeline_builder` will helps to gather timeline's services supporting the defined context, and run queries across the models. +If a bundle wants to provide a new context for a timeline, the service `chill.main.timeline_builder` will helps to gather timeline's services supporting the defined context, and run queries across the models. .. _understanding-queries : Understanding queries ^^^^^^^^^^^^^^^^^^^^^ -Due to the fact that timelines should show only the X last events from Y differents tables, queries for a timeline may consume a lot of resources: at first on the database, and then on the ORM part, which will have to deserialize DB data to PHP classes, which may not be used if they are not part of the "last X events". +Due to the fact that timelines should show only the X last events from Y differents tables, queries for a timeline may consume a lot of resources: at first on the database, and then on the ORM part, which will have to deserialize DB data to PHP classes, which may not be used if they are not part of the "last X events". -To avoid such load on database, the objects are queried in two steps : +To avoid such load on database, the objects are queried in two steps : 1. An UNION request which gather the last X events, ordered by date. The data retrieved are the ID, the date, and a string key: a type. This type discriminates the data type. -2. The PHP objects are queried by ID, the type helps the program to link id with the kind of objects. +2. The PHP objects are queried by ID, the type helps the program to link id with the kind of objects. Those methods should ensure that only X PHP objects will be gathered and build by the ORM. What does the master timeline builder service ? ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - When the service `chill.main.timeline_builder` is instanciated, the service is informed of each service taggued with `chill.timeline` tags. Then, + When the service `chill.main.timeline_builder` is instanciated, the service is informed of each service taggued with `chill.timeline` tags. Then, 1. The service build an UNION query by assembling column and tables names provided by the `fetchQuery` result ; 2. The UNION query is run, the result contains an id and a type for each row (see :ref:`above `) @@ -84,7 +86,7 @@ To push events on a timeline : Implementing the TimelineProviderInterface ------------------------------------------ -The has the following signature : +The has the following signature : .. code-block:: php @@ -92,19 +94,19 @@ The has the following signature : interface TimelineProviderInterface { - - /** - * + + /** + * * @param string $context * @param mixed[] $args the argument to the context. * @return TimelineSingleQuery * @throw \LogicException if the context is not supported */ public function fetchQuery($context, array $args); - + /** * Indicate if the result type may be handled by the service - * + * * @param string $type the key present in the SELECT query * @return boolean */ @@ -113,42 +115,42 @@ The has the following signature : /** * fetch entities from db into an associative array. The keys **MUST BE** * the id - * - * All ids returned by all SELECT queries + * + * All ids returned by all SELECT queries * (@see TimeLineProviderInterface::fetchQuery) and with the type * supported by the provider (@see TimelineProviderInterface::supportsType) * will be passed as argument. - * + * * @param array $ids an array of id * @return mixed[] an associative array of entities, with id as key */ public function getEntities(array $ids); - + /** * return an associative array with argument to render the entity * in an html template, which will be included in the timeline page - * + * * The result must have the following key : - * + * * - `template` : the template FQDN * - `template_data`: the data required by the template - * - * + * + * * Example: - * + * * ``` - * array( + * array( * 'template' => 'ChillMyBundle:timeline:template.html.twig', * 'template_data' => array( - * 'accompanyingPeriod' => $entity, - * 'person' => $args['person'] + * 'accompanyingPeriod' => $entity, + * 'person' => $args['person'] * ) * ); * ``` - * + * * `$context` and `$args` are defined by the bundle which will call the timeline - * rendering. - * + * rendering. + * * @param type $entity * @param type $context * @param array $args @@ -156,7 +158,7 @@ The has the following signature : * @throws \LogicException if the context is not supported */ public function getEntityTemplate($entity, $context, array $args); - + } @@ -176,7 +178,7 @@ The parameters should be replaced into the query by :code:`?`. They will be repl `$context` and `$args` are defined by the bundle which will call the timeline rendering. You may use them to build a different query depending on this context. -For instance, if the context is `'person'`, the args will be this array : +For instance, if the context is `'person'`, the args will be this array : .. code-block:: php @@ -197,7 +199,7 @@ You should find in the bundle documentation which contexts are arguments the bun .. note:: - We encourage to use `ClassMetaData` to define column names arguments. If you change your column names, changes will be reflected automatically during the execution of your code. + We encourage to use `ClassMetaData` to define column names arguments. If you change your column names, changes will be reflected automatically during the execution of your code. Example of an implementation : @@ -215,13 +217,13 @@ Example of an implementation : */ class TimelineReportProvider implements TimelineProviderInterface { - + /** * * @var EntityManager */ protected $em; - + public function __construct(EntityManager $em) { $this->em = $em; @@ -230,9 +232,9 @@ Example of an implementation : public function fetchQuery($context, array $args) { $this->checkContext($context); - + $metadata = $this->em->getClassMetadata('ChillReportBundle:Report'); - + return TimelineSingleQuery::fromArray([ 'id' => $metadata->getColumnName('id'), 'type' => 'report', @@ -254,11 +256,11 @@ Example of an implementation : The `supportsType` function ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -This function indicate to the master `chill.main.timeline_builder` service (which orchestrate the build of UNION queries) that the service supports the type indicated in the result's array of the `fetchQuery` function. +This function indicate to the master `chill.main.timeline_builder` service (which orchestrate the build of UNION queries) that the service supports the type indicated in the result's array of the `fetchQuery` function. -The implementation of our previous example will be : +The implementation of our previous example will be : -.. code-block:: php +.. code-block:: php namespace Chill\ReportBundle\Timeline; @@ -272,7 +274,7 @@ The implementation of our previous example will be : //... /** - * + * * {@inheritDoc} */ public function supportsType($type) @@ -304,12 +306,12 @@ The results **must be** an array where the id given by the UNION query (remember { $reports = $this->em->getRepository('ChillReportBundle:Report') ->findBy(array('id' => $ids)); - + $result = array(); foreach($reports as $report) { $result[$report->getId()] = $report; } - + return $result; } @@ -318,9 +320,9 @@ The results **must be** an array where the id given by the UNION query (remember The `getEntityTemplate` function ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -This is where the master service will collect information to render the entity. +This is where the master service will collect information to render the entity. -The result must be an associative array with : +The result must be an associative array with : - **template** is the FQDN of the template ; - **template_data** is an associative array where keys are the variables'names for this template, and values are the values. @@ -332,8 +334,8 @@ Example : array( 'template' => 'ChillMyBundle:timeline:template.html.twig', 'template_data' => array( - 'period' => $entity, - 'person' => $args['person'] + 'period' => $entity, + 'person' => $args['person'] ) ); @@ -349,7 +351,7 @@ Create a timeline with his own context You have to create a Controller which will execute the service `chill.main.timeline_builder`. Using the `Chill\MainBundle\Timeline\TimelineBuilder::getTimelineHTML` function, you will get an HTML representation of the timeline, which you may include with twig `raw` filter. -Example : +Example : .. code-block:: php From c73e57ad73793785252428cc51996935bf63c663 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 27 Apr 2023 12:21:25 +0200 Subject: [PATCH 040/724] doc: add info about syncrhonizing views --- docs/source/installation/index.rst | 22 +++++++++++++++++++++- docs/source/installation/prod.rst | 8 ++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/docs/source/installation/index.rst b/docs/source/installation/index.rst index 852a2a6d0..910122196 100644 --- a/docs/source/installation/index.rst +++ b/docs/source/installation/index.rst @@ -151,6 +151,7 @@ This script will : # mount into to container ./docker-php.sh + bin/console chill:db:sync-views # and load fixtures bin/console doctrine:migrations:migrate @@ -161,7 +162,7 @@ Chill will be available at ``http://localhost:8001.`` Currently, there isn't any # mount into to container ./docker-php.sh - # and load fixtures + # and load fixtures (do not this for production) bin/console doctrine:fixtures:load --purge-with-truncate There are several users available: @@ -204,8 +205,10 @@ How to create the database schema (= run migrations) ? # if a container is running ./docker-php.sh bin/console doctrine:migrations:migrate + bin/console chill:db:sync-views # if not docker-compose run --user $(id -u) php bin/console doctrine:migrations:migrate + docker-compose run --user $(id -u) php bin/console chill:db:sync-views How to read the email sent by the program ? @@ -236,6 +239,23 @@ How to open a terminal in the project # if not docker-compose run --user $(id -u) php /bin/bash +How to run cron-jobs ? +====================== + +Some command must be executed in :ref:`cron jobs `. To execute them: + +.. code-block:: bash + + # if a container is running + ./docker-php.sh + bin/console chill:cron-job:execute + # some of them are executed only during the night. So, we have to force the execution during the day: + bin/console chill:cron-job:execute 'name-of-the-cron' + # if not + docker-compose run --user $(id -u) php bin/console chill:cron-job:execute + # some of them are executed only during the night. So, we have to force the execution during the day: + docker-compose run --user $(id -u) php bin/console chill:cron-job:execute 'name-of-the-cron' + How to run composer ? ===================== diff --git a/docs/source/installation/prod.rst b/docs/source/installation/prod.rst index f51141e8d..21da15267 100644 --- a/docs/source/installation/prod.rst +++ b/docs/source/installation/prod.rst @@ -38,6 +38,14 @@ This should be adapted to your needs: * Think about how you will backup your database. Some adminsys find easier to store database outside of docker, which might be easier to administrate or replicate. +Run migrations on each update +============================= + +Every time you start a new version, you should apply update the sql schema: + +- running ``bin/console doctrine:migration:migrate`` to run sql migration; +- synchonizing sql views to the last state: ``bin/console chill:db:sync-views`` + Cron jobs ========= From ea4294d12d8b5c3b6532e35a9074569df5568c23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 27 Apr 2023 22:45:25 +0200 Subject: [PATCH 041/724] add start date's accompanying period in accompanyingperiod info --- ...tartQueryPartForAccompanyingPeriodInfo.php | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 src/Bundle/ChillPersonBundle/Service/EntityInfo/AccompanyingPeriodInfoQueryPart/AccompanyingPeriodStartQueryPartForAccompanyingPeriodInfo.php diff --git a/src/Bundle/ChillPersonBundle/Service/EntityInfo/AccompanyingPeriodInfoQueryPart/AccompanyingPeriodStartQueryPartForAccompanyingPeriodInfo.php b/src/Bundle/ChillPersonBundle/Service/EntityInfo/AccompanyingPeriodInfoQueryPart/AccompanyingPeriodStartQueryPartForAccompanyingPeriodInfo.php new file mode 100644 index 000000000..19272900a --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Service/EntityInfo/AccompanyingPeriodInfoQueryPart/AccompanyingPeriodStartQueryPartForAccompanyingPeriodInfo.php @@ -0,0 +1,63 @@ + Date: Thu, 27 Apr 2023 22:45:45 +0200 Subject: [PATCH 042/724] add migration to fix existing period steps --- .../migrations/Version20230427102309.php | 189 ++++++++++++++++++ 1 file changed, 189 insertions(+) create mode 100644 src/Bundle/ChillPersonBundle/migrations/Version20230427102309.php diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20230427102309.php b/src/Bundle/ChillPersonBundle/migrations/Version20230427102309.php new file mode 100644 index 000000000..7398a2292 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/migrations/Version20230427102309.php @@ -0,0 +1,189 @@ +addSql(<<<'SQL' + CREATE TEMPORARY TABLE acc_period_info AS + SELECT a.id AS accompanyingperiod_id, + 'Chill\PersonBundle\Entity\AccompanyingPeriod'::text AS relatedentity, + a.id AS relatedentityid, + NULL::integer AS user_id, + a.openingdate AS infodate, + 'accompanying_period_start'::text AS discriminator, + '{}'::jsonb AS metadata + FROM chill_person_accompanying_period a + UNION + SELECT w.accompanyingperiod_id, + 'Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork'::text AS relatedentity, + w.id AS relatedentityid, + cpapwr.user_id, + w.enddate AS infodate, + 'accompanying_period_work_end'::text AS discriminator, + '{}'::jsonb AS metadata + FROM chill_person_accompanying_period_work w + LEFT JOIN chill_person_accompanying_period_work_referrer cpapwr ON w.id = cpapwr.accompanyingperiodwork_id + WHERE w.enddate IS NOT NULL + UNION + SELECT cpapw.accompanyingperiod_id, + 'Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation'::text AS relatedentity, + e.id AS relatedentityid, + e.updatedby_id AS user_id, + e.updatedat AS infodate, + 'accompanying_period_work_evaluation_updated_at'::text AS discriminator, + '{}'::jsonb AS metadata + FROM chill_person_accompanying_period_work_evaluation e + JOIN chill_person_accompanying_period_work cpapw ON cpapw.id = e.accompanyingperiodwork_id + WHERE e.updatedat IS NOT NULL + UNION + SELECT cpapw.accompanyingperiod_id, + 'Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation'::text AS relatedentity, + e.id AS relatedentityid, + cpapwr.user_id, + e.maxdate AS infodate, + 'accompanying_period_work_evaluation_start'::text AS discriminator, + '{}'::jsonb AS metadata + FROM chill_person_accompanying_period_work_evaluation e + JOIN chill_person_accompanying_period_work cpapw ON cpapw.id = e.accompanyingperiodwork_id + LEFT JOIN chill_person_accompanying_period_work_referrer cpapwr ON cpapw.id = cpapwr.accompanyingperiodwork_id + WHERE e.maxdate IS NOT NULL + UNION + SELECT cpapw.accompanyingperiod_id, + 'Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation'::text AS relatedentity, + e.id AS relatedentityid, + cpapwr.user_id, + e.startdate AS infodate, + 'accompanying_period_work_evaluation_start'::text AS discriminator, + '{}'::jsonb AS metadata + FROM chill_person_accompanying_period_work_evaluation e + JOIN chill_person_accompanying_period_work cpapw ON cpapw.id = e.accompanyingperiodwork_id + LEFT JOIN chill_person_accompanying_period_work_referrer cpapwr ON cpapw.id = cpapwr.accompanyingperiodwork_id + UNION + SELECT cpapw.accompanyingperiod_id, + 'Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocument'::text AS relatedentity, + doc.id AS relatedentityid, + doc.updatedby_id AS user_id, + doc.updatedat AS infodate, + 'accompanying_period_work_evaluation_document_updated_at'::text AS discriminator, + '{}'::jsonb AS metadata + FROM chill_person_accompanying_period_work_evaluation_document doc + JOIN chill_person_accompanying_period_work_evaluation e ON doc.accompanyingperiodworkevaluation_id = e.id + JOIN chill_person_accompanying_period_work cpapw ON cpapw.id = e.accompanyingperiodwork_id + WHERE doc.updatedat IS NOT NULL + UNION + SELECT cpapw.accompanyingperiod_id, + 'Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation'::text AS relatedentity, + e.id AS relatedentityid, + cpapwr.user_id, + e.maxdate AS infodate, + 'accompanying_period_work_evaluation_max'::text AS discriminator, + '{}'::jsonb AS metadata + FROM chill_person_accompanying_period_work_evaluation e + JOIN chill_person_accompanying_period_work cpapw ON cpapw.id = e.accompanyingperiodwork_id + LEFT JOIN chill_person_accompanying_period_work_referrer cpapwr ON cpapw.id = cpapwr.accompanyingperiodwork_id + WHERE e.maxdate IS NOT NULL + UNION + SELECT w.accompanyingperiod_id, + 'Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork'::text AS relatedentity, + w.id AS relatedentityid, + cpapwr.user_id, + w.startdate AS infodate, + 'accompanying_period_work_start'::text AS discriminator, + '{}'::jsonb AS metadata + FROM chill_person_accompanying_period_work w + LEFT JOIN chill_person_accompanying_period_work_referrer cpapwr ON w.id = cpapwr.accompanyingperiodwork_id + UNION + SELECT activity.accompanyingperiod_id, + 'Chill\ActivityBundle\Entity\Activity'::text AS relatedentity, + activity.id AS relatedentityid, + au.user_id, + activity.date AS infodate, + 'activity_date'::text AS discriminator, + '{}'::jsonb AS metadata + FROM activity + LEFT JOIN activity_user au ON activity.id = au.activity_id + WHERE activity.accompanyingperiod_id IS NOT NULL; + SQL); + + // create a table to store oldest inactives + $this->addSql(<<<'SQL' + CREATE TEMPORARY TABLE inactive_long AS + SELECT a.accompanyingperiod_id, MAX(infodate) AS last_date + FROM acc_period_info a JOIN chill_person_accompanying_period acp ON acp.id = a.accompanyingperiod_id + WHERE + NOT EXISTS (SELECT 1 FROM acc_period_info WHERE infodate > (NOW() - '2 years'::interval) AND acc_period_info.accompanyingperiod_id = a.accompanyingperiod_id) + AND acp.step LIKE 'CONFIRMED' + GROUP BY accompanyingperiod_id; + SQL); + + $this->addSql(<<<'SQL' + UPDATE chill_person_accompanying_period_step_history SET enddate = GREATEST(last_date + '2 years'::interval, startdate) + FROM inactive_long WHERE inactive_long.accompanyingperiod_id = period_id AND enddate IS NULL; + SQL); + + $this->addSql(<<<'SQL' + INSERT INTO chill_person_accompanying_period_step_history (id, period_id, enddate, startdate, step, createdat, updatedat) + SELECT nextval('chill_person_accompanying_period_step_history_id_seq'), accompanyingperiod_id, NULL, last_date + '2 years'::interval, 'CONFIRMED_INACTIVE_LONG', NOW(), NOW() + FROM inactive_long; + SQL); + + $this->addSql(<<<'SQL' + UPDATE chill_person_accompanying_period a SET step = 'CONFIRMED_INACTIVE_LONG' FROM inactive_long inactive WHERE a.id = inactive.accompanyingperiod_id; + SQL); + + $this->addSql(<<<'SQL' + DROP TABLE inactive_long + SQL); + + $this->addSql(<<<'SQL' + CREATE TEMPORARY TABLE inactive_long AS + SELECT a.accompanyingperiod_id, MAX(infodate) AS last_date + FROM acc_period_info a JOIN chill_person_accompanying_period acp ON acp.id = a.accompanyingperiod_id + WHERE + NOT EXISTS (SELECT 1 FROM acc_period_info WHERE infodate > (NOW() - '6 months'::interval) AND acc_period_info.accompanyingperiod_id = a.accompanyingperiod_id) + AND acp.step LIKE 'CONFIRMED' + GROUP BY accompanyingperiod_id; + SQL); + + $this->addSql(<<<'SQL' + UPDATE chill_person_accompanying_period_step_history SET enddate = GREATEST(last_date + '6 months'::interval, startdate) + FROM inactive_long WHERE inactive_long.accompanyingperiod_id = period_id AND enddate IS NULL; + SQL); + + $this->addSql(<<<'SQL' + INSERT INTO chill_person_accompanying_period_step_history (id, period_id, enddate, startdate, step, createdat, updatedat) + SELECT nextval('chill_person_accompanying_period_step_history_id_seq'), accompanyingperiod_id, NULL, last_date + '6 months'::interval, 'CONFIRMED_INACTIVE_SHORT', NOW(), NOW() + FROM inactive_long; + SQL); + + $this->addSql(<<<'SQL' + UPDATE chill_person_accompanying_period a SET step = 'CONFIRMED_INACTIVE_SHORT' FROM inactive_long inactive WHERE a.id = inactive.accompanyingperiod_id; + SQL); + } + + public function down(Schema $schema): void + { + $this->throwIrreversibleMigrationException(); + } +} From f75b90cb26994827dbafdda8b03ab546283dc4f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 28 Apr 2023 11:49:09 +0200 Subject: [PATCH 043/724] Feature: [export] add filters regarding to accompanying period infos --- ...ccompanyingPeriodInfoWithinDatesFilter.php | 91 +++++++++++++++++++ .../UserWorkingOnCourseFilter.php | 88 ++++++++++++++++++ .../services/exports_accompanying_course.yaml | 7 ++ .../translations/messages.fr.yml | 8 ++ 4 files changed, 194 insertions(+) create mode 100644 src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HavingAnAccompanyingPeriodInfoWithinDatesFilter.php create mode 100644 src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserWorkingOnCourseFilter.php diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HavingAnAccompanyingPeriodInfoWithinDatesFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HavingAnAccompanyingPeriodInfoWithinDatesFilter.php new file mode 100644 index 000000000..7069a1d80 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HavingAnAccompanyingPeriodInfoWithinDatesFilter.php @@ -0,0 +1,91 @@ +add('start_date', PickRollingDateType::class, [ + 'label' => 'export.filter.course.having_info_within_interval.start_date', + 'data' => new RollingDate(RollingDate::T_TODAY), + ]) + ->add('end_date', PickRollingDateType::class, [ + 'label' => 'export.filter.course.having_info_within_interval.end_date', + 'data' => new RollingDate(RollingDate::T_TODAY), + ]) + ; + } + + public function getTitle(): string + { + return 'export.filter.course.having_info_within_interval.title'; + } + + public function describeAction($data, $format = 'string'): array + { + return [ + 'export.filter.course.having_info_within_interval.Only course with events between %startDate% and %endDate%', + [ + '%startDate%' => $this->rollingDateConverter->convert($data['start_date'])->format('d-m-Y'), + '%endDate%' => $this->rollingDateConverter->convert($data['end_date'])->format('d-m-Y'), + ] + ]; + } + + public function addRole(): ?string + { + return null; + } + + public function alterQuery(QueryBuilder $qb, $data): void + { + $ai = 'having_ai_within_interval_acc_info'; + $as = 'having_ai_within_interval_start_date'; + $ae = 'having_ai_within_interval_end_date'; + + $qb + ->andWhere( + $qb->expr()->exists( + 'SELECT 1 FROM ' . AccompanyingPeriodInfo::class . " {$ai} WHERE {$ai}.infoDate BETWEEN :{$as} AND :{$ae} AND IDENTITY({$ai}.accompanyingPeriod) = acp.id" + ) + ) + ->setParameter($as, $this->rollingDateConverter->convert($data['start_date']), Types::DATETIME_IMMUTABLE) + ->setParameter($ae, $this->rollingDateConverter->convert($data['end_date']), Types::DATETIME_IMMUTABLE); + } + + public function applyOn(): string + { + return Declarations::ACP_TYPE; + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserWorkingOnCourseFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserWorkingOnCourseFilter.php new file mode 100644 index 000000000..586bb645d --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserWorkingOnCourseFilter.php @@ -0,0 +1,88 @@ +add('users', PickUserDynamicType::class, [ + 'multiple' => true, + ]); + } + + public function getTitle(): string + { + return 'export.filter.course.by_user_working.title'; + } + + public function describeAction($data, $format = 'string'): array + { + return [ + 'export.filter.course.by_user_working.Filtered by user working on course: only %users%', [ + '%users%' => implode( + ', ', + array_map( + fn (User $u) => $this->userRender->renderString($u, []), + $data['users'] + ) + ), + ], + ]; + } + + public function addRole(): ?string + { + return null; + } + + public function alterQuery(QueryBuilder $qb, $data): void + { + $qb + ->andWhere( + $qb->expr()->exists( + "SELECT 1 FROM " . AccompanyingPeriod\AccompanyingPeriodInfo::class . " " . self::AI_ALIAS . " " . + "WHERE " . self::AI_ALIAS . ".user IN (:" . self::AI_USERS .") AND IDENTITY(" . self::AI_ALIAS . ".accompanyingPeriod) = acp.id" + ) + ) + ->setParameter(self::AI_USERS, $data['users']) + ; + } + + public function applyOn(): string + { + return Declarations::ACP_TYPE; + } +} diff --git a/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_course.yaml b/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_course.yaml index bb2cfa556..adde8d336 100644 --- a/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_course.yaml +++ b/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_course.yaml @@ -128,6 +128,13 @@ services: tags: - { name: chill.export_filter, alias: accompanyingcourse_creator_job_filter } + Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\UserWorkingOnCourseFilter: + tags: + - { name: chill.export_filter, alias: accompanyingcourse_user_working_on_filter } + + Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\HavingAnAccompanyingPeriodInfoWithinDatesFilter: + tags: + - { name: chill.export_filter, alias: accompanyingcourse_info_within_filter } ## Aggregators chill.person.export.aggregator_referrer_scope: diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 0cdc9e601..9b9f1fde2 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -1076,6 +1076,14 @@ export: Status: Statut course: + having_info_within_interval: + title: Filter les parcours ayant reçu une intervention entre deux dates + start_date: Début de la période + end_date: Fin de la période + Only course with events between %startDate% and %endDate%: Seulement les parcours ayant reçu une intervention entre le %startDate% et le %endDate% + by_user_working: + title: Filter les parcours par intervenant + 'Filtered by user working on course: only %users%': 'Filtré par intervenants sur le parcours: seulement %users%' by_step: date_calc: Date de prise en compte du statut by_user_scope: From 36413f16c32bd1a76d4d8e1f1a9ae46779b44597 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 28 Apr 2023 11:51:16 +0200 Subject: [PATCH 044/724] DX: convert closure to arrow function --- .../Export/Export/ListAccompanyingPeriod.php | 34 ++++++++----------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php index 3fd7ee01a..23b104ac4 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php @@ -256,28 +256,24 @@ class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface }; case 'step': - return function ($value) { - return match ($value) { - '_header' => 'export.list.acp.step', - null => '', - AccompanyingPeriod::STEP_DRAFT => $this->translator->trans('course.draft'), - AccompanyingPeriod::STEP_CONFIRMED => $this->translator->trans('course.confirmed'), - AccompanyingPeriod::STEP_CLOSED => $this->translator->trans('course.closed'), - AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_SHORT => $this->translator->trans('course.inactive_short'), - AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_LONG => $this->translator->trans('course.inactive_long'), - default => $value, - }; + return fn($value) => match ($value) { + '_header' => 'export.list.acp.step', + null => '', + AccompanyingPeriod::STEP_DRAFT => $this->translator->trans('course.draft'), + AccompanyingPeriod::STEP_CONFIRMED => $this->translator->trans('course.confirmed'), + AccompanyingPeriod::STEP_CLOSED => $this->translator->trans('course.closed'), + AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_SHORT => $this->translator->trans('course.inactive_short'), + AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_LONG => $this->translator->trans('course.inactive_long'), + default => $value, }; case 'intensity': - return function ($value) { - return match ($value) { - '_header' => 'export.list.acp.intensity', - null => '', - AccompanyingPeriod::INTENSITY_OCCASIONAL => $this->translator->trans('occasional'), - AccompanyingPeriod::INTENSITY_REGULAR => $this->translator->trans('regular'), - default => $value, - }; + return fn($value) => match ($value) { + '_header' => 'export.list.acp.intensity', + null => '', + AccompanyingPeriod::INTENSITY_OCCASIONAL => $this->translator->trans('occasional'), + AccompanyingPeriod::INTENSITY_REGULAR => $this->translator->trans('regular'), + default => $value, }; default: From ab5ad7ae148c7044f7d4a616bf3ec071887aebec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 28 Apr 2023 12:02:31 +0200 Subject: [PATCH 045/724] fix cs --- .../Export/Export/ListAccompanyingPeriod.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php index 23b104ac4..0647460dd 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php @@ -256,7 +256,7 @@ class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface }; case 'step': - return fn($value) => match ($value) { + return fn ($value) => match ($value) { '_header' => 'export.list.acp.step', null => '', AccompanyingPeriod::STEP_DRAFT => $this->translator->trans('course.draft'), @@ -268,7 +268,7 @@ class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface }; case 'intensity': - return fn($value) => match ($value) { + return fn ($value) => match ($value) { '_header' => 'export.list.acp.intensity', null => '', AccompanyingPeriod::INTENSITY_OCCASIONAL => $this->translator->trans('occasional'), From 997f3cdb098b63ab6c36cc3225d2a265db0de771 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 28 Apr 2023 12:37:28 +0200 Subject: [PATCH 046/724] Feature: [exports] add filters for start and end date for accompanying period works --- ...yingPeriodWorkEndDateBetweenDateFilter.php | 114 ++++++++++++++++++ ...ngPeriodWorkStartDateBetweenDateFilter.php | 114 ++++++++++++++++++ .../services/exports_social_actions.yaml | 14 ++- .../translations/messages.fr.yml | 15 +++ 4 files changed, 256 insertions(+), 1 deletion(-) create mode 100644 src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/AccompanyingPeriodWorkEndDateBetweenDateFilter.php create mode 100644 src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/AccompanyingPeriodWorkStartDateBetweenDateFilter.php diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/AccompanyingPeriodWorkEndDateBetweenDateFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/AccompanyingPeriodWorkEndDateBetweenDateFilter.php new file mode 100644 index 000000000..b13c49e9a --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/AccompanyingPeriodWorkEndDateBetweenDateFilter.php @@ -0,0 +1,114 @@ +add('start_date', PickRollingDateType::class, [ + 'label' => 'export.filter.work.end_between_dates.start_date', + 'data' => new RollingDate(RollingDate::T_TODAY), + ]) + ->add('end_date', PickRollingDateType::class, [ + 'label' => 'export.filter.work.end_between_dates.end_date', + 'data' => new RollingDate(RollingDate::T_TODAY), + ]) + ->add('keep_null', CheckboxType::class, [ + 'label' => 'export.filter.work.end_between_dates.keep_null', + 'help' => 'export.filter.work.end_between_dates.keep_null_help', + ]) + ; + } + + public function getTitle(): string + { + return 'export.filter.work.end_between_dates.title'; + } + + public function describeAction($data, $format = 'string'): array + { + return [ + 'export.filter.work.end_between_dates.Only where end date is between %endDate% and %endDate%', + [ + '%startDate%' => null !== $data['start_date'] ? $this->rollingDateConverter->convert($data['start_date'])->format('d-m-Y') : '', + '%endDate%' => null !== $data['end_date'] ? $this->rollingDateConverter->convert($data['end_date'])->format('d-m-Y') : '', + ] + ]; + } + + public function addRole(): ?string + { + return null; + } + + public function alterQuery(QueryBuilder $qb, $data): void + { + $as = 'acc_pe_work_end_between_filter_start'; + $ae = 'acc_pe_work_end_between_filter_end'; + + $start = match ($data['keep_null']) { + true => $qb->expr()->orX( + $qb->expr()->lte('acpw.endDate', ':'.$ae), + $qb->expr()->isNull('acpw.endDate') + ), + false => $qb->expr()->andX( + $qb->expr()->lte('acpw.endDate', ':'.$ae), + $qb->expr()->isNotNull('acpw.endDate') + ), + default => throw new \LogicException("This value is not supported"), + }; + $end = match ($data['keep_null']) { + true => $qb->expr()->orX( + $qb->expr()->gt('acpw.endDate', ':'.$as), + $qb->expr()->isNull('acpw.endDate') + ), + false => $qb->expr()->andX( + $qb->expr()->gt('acpw.endDate', ':'.$as), + $qb->expr()->isNotNull('acpw.endDate') + ), + default => throw new \LogicException("This value is not supported"), + }; + + if (null !== $data['start_date']) { + $qb + ->andWhere($start) + ->setParameter($as, $this->rollingDateConverter->convert($data['start_date'])); + } + + if (null !== $data['end_date']) { + $qb + ->andWhere($end) + ->setParameter($ae, $this->rollingDateConverter->convert($data['end_date'])); + } + } + + public function applyOn(): string + { + return Declarations::SOCIAL_WORK_ACTION_TYPE; + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/AccompanyingPeriodWorkStartDateBetweenDateFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/AccompanyingPeriodWorkStartDateBetweenDateFilter.php new file mode 100644 index 000000000..e9526a9a5 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/AccompanyingPeriodWorkStartDateBetweenDateFilter.php @@ -0,0 +1,114 @@ +add('start_date', PickRollingDateType::class, [ + 'label' => 'export.filter.work.start_between_dates.start_date', + 'data' => new RollingDate(RollingDate::T_TODAY), + ]) + ->add('end_date', PickRollingDateType::class, [ + 'label' => 'export.filter.work.start_between_dates.end_date', + 'data' => new RollingDate(RollingDate::T_TODAY), + ]) + ->add('keep_null', CheckboxType::class, [ + 'label' => 'export.filter.work.start_between_dates.keep_null', + 'help' => 'export.filter.work.start_between_dates.keep_null_help', + ]) + ; + } + + public function getTitle(): string + { + return 'export.filter.work.start_between_dates.title'; + } + + public function describeAction($data, $format = 'string'): array + { + return [ + 'export.filter.work.start_between_dates.Only where start date is between %startDate% and %endDate%', + [ + '%startDate%' => null !== $data['start_date'] ? $this->rollingDateConverter->convert($data['start_date'])->format('d-m-Y') : '', + '%endDate%' => null !== $data['end_date'] ? $this->rollingDateConverter->convert($data['end_date'])->format('d-m-Y') : '', + ] + ]; + } + + public function addRole(): ?string + { + return null; + } + + public function alterQuery(QueryBuilder $qb, $data): void + { + $as = 'acc_pe_work_start_between_filter_start'; + $ae = 'acc_pe_work_start_between_filter_end'; + + $start = match ($data['keep_null']) { + true => $qb->expr()->orX( + $qb->expr()->lte('acpw.startDate', ':'.$ae), + $qb->expr()->isNull('acpw.startDate') + ), + false => $qb->expr()->andX( + $qb->expr()->lte('acpw.startDate', ':'.$ae), + $qb->expr()->isNotNull('acpw.startDate') + ), + default => throw new \LogicException("This value is not supported"), + }; + $end = match ($data['keep_null']) { + true => $qb->expr()->orX( + $qb->expr()->gt('acpw.startDate', ':'.$as), + $qb->expr()->isNull('acpw.startDate') + ), + false => $qb->expr()->andX( + $qb->expr()->gt('acpw.startDate', ':'.$as), + $qb->expr()->isNotNull('acpw.startDate') + ), + default => throw new \LogicException("This value is not supported"), + }; + + if (null !== $data['start_date']) { + $qb + ->andWhere($start) + ->setParameter($as, $this->rollingDateConverter->convert($data['start_date'])); + } + + if (null !== $data['end_date']) { + $qb + ->andWhere($end) + ->setParameter($ae, $this->rollingDateConverter->convert($data['end_date'])); + } + } + + public function applyOn(): string + { + return Declarations::SOCIAL_WORK_ACTION_TYPE; + } +} diff --git a/src/Bundle/ChillPersonBundle/config/services/exports_social_actions.yaml b/src/Bundle/ChillPersonBundle/config/services/exports_social_actions.yaml index ecf0ec399..5f6c2690d 100644 --- a/src/Bundle/ChillPersonBundle/config/services/exports_social_actions.yaml +++ b/src/Bundle/ChillPersonBundle/config/services/exports_social_actions.yaml @@ -48,7 +48,19 @@ services: tags: - { name: chill.export_filter, alias: social_work_actions_current_filter } - ## AGGREGATORS + Chill\PersonBundle\Export\Filter\SocialWorkFilters\AccompanyingPeriodWorkStartDateBetweenDateFilter: + autowire: true + autoconfigure: true + tags: + - { name: chill.export_filter, alias: social_work_actions_start_btw_dates_filter } + + Chill\PersonBundle\Export\Filter\SocialWorkFilters\AccompanyingPeriodWorkEndDateBetweenDateFilter: + autowire: true + autoconfigure: true + tags: + - { name: chill.export_filter, alias: social_work_actions_end_btw_dates_filter } + + ## AGGREGATORS chill.person.export.aggregator_action_type: class: Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\ActionTypeAggregator autowire: true diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index d33957ea7..471333df2 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -1083,6 +1083,21 @@ export: Calculation date: Date de la localisation creator_job: 'Filtered by creator job: only %jobs%': 'Filtré par métier du créateur: seulement %jobs%' + work: + start_between_dates: + title: Filtre les actions d'accompagnement dont la date d'ouverture est entre deux dates + start_date: Date de début + end_date: Date de fin + keep_null: Conserver les actions dont la date de début n'est pas indiquée + keep_null_help: Si coché, les actions dont la date de début est vide seront prises en compte. Si non coché, elles ne seront pas comptabilisée. + Only where start date is between %startDate% and %endDate%: Seulement les actions dont la date de début est entre le %startDate% et le %endDate% + end_between_dates: + title: Filtre les actions d'accompagnement dont la date de clotûre est entre deux dates (ou l'action est toujours ouverte) + start_date: Date de début + end_date: Date de fin + keep_null: Conserver les actions dont la date de fin n'est pas indiquée (actions en cours) + keep_null_help: Si coché, les actions dont la date de fin est vide seront prises en compte. Si non coché, elles ne seront pas comptabilisée. + Only where start date is between %startDate% and %endDate%: Seulement les actions dont la date de fin est entre le %startDate% et le %endDate% list: person_with_acp: List peoples having an accompanying period: Liste des usagers ayant un parcours d'accompagnement From 3e3f20993d758c719dea09062bb76dfd6b52df47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 28 Apr 2023 15:55:41 +0200 Subject: [PATCH 047/724] fix migration after test on real data --- .../migrations/Version20230427102309.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20230427102309.php b/src/Bundle/ChillPersonBundle/migrations/Version20230427102309.php index 7398a2292..662c11d9a 100644 --- a/src/Bundle/ChillPersonBundle/migrations/Version20230427102309.php +++ b/src/Bundle/ChillPersonBundle/migrations/Version20230427102309.php @@ -144,8 +144,9 @@ final class Version20230427102309 extends AbstractMigration $this->addSql(<<<'SQL' INSERT INTO chill_person_accompanying_period_step_history (id, period_id, enddate, startdate, step, createdat, updatedat) - SELECT nextval('chill_person_accompanying_period_step_history_id_seq'), accompanyingperiod_id, NULL, last_date + '2 years'::interval, 'CONFIRMED_INACTIVE_LONG', NOW(), NOW() - FROM inactive_long; + SELECT nextval('chill_person_accompanying_period_step_history_id_seq'), period_id, NULL, sq.g, 'CONFIRMED_INACTIVE_LONG', NOW(), NOW() + FROM (SELECT GREATEST(MAX(startdate), MAX(enddate)) AS g, period_id FROM chill_person_accompanying_period_step_history GROUP BY period_id) AS sq + JOIN inactive_long ON sq.period_id = inactive_long.accompanyingperiod_id SQL); $this->addSql(<<<'SQL' @@ -173,8 +174,9 @@ final class Version20230427102309 extends AbstractMigration $this->addSql(<<<'SQL' INSERT INTO chill_person_accompanying_period_step_history (id, period_id, enddate, startdate, step, createdat, updatedat) - SELECT nextval('chill_person_accompanying_period_step_history_id_seq'), accompanyingperiod_id, NULL, last_date + '6 months'::interval, 'CONFIRMED_INACTIVE_SHORT', NOW(), NOW() - FROM inactive_long; + SELECT nextval('chill_person_accompanying_period_step_history_id_seq'), period_id, NULL, sq.g, 'CONFIRMED_INACTIVE_SHORT', NOW(), NOW() + FROM (SELECT GREATEST(MAX(startdate), MAX(enddate)) AS g, period_id FROM chill_person_accompanying_period_step_history GROUP BY period_id) AS sq + JOIN inactive_long ON sq.period_id = inactive_long.accompanyingperiod_id SQL); $this->addSql(<<<'SQL' From d8870e906f510db451be028b60939cad95e22875 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sat, 15 Apr 2023 00:54:21 +0200 Subject: [PATCH 048/724] DX: rector in docs directory --- docs/source/_static/code/exports/CountPerson.php | 15 +++------------ .../widgets/ChillMainConfiguration.php | 9 +-------- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/docs/source/_static/code/exports/CountPerson.php b/docs/source/_static/code/exports/CountPerson.php index afe19c73b..a77ff1be5 100644 --- a/docs/source/_static/code/exports/CountPerson.php +++ b/docs/source/_static/code/exports/CountPerson.php @@ -50,18 +50,9 @@ class CountPerson implements ExportInterface public function getLabels($key, array $values, $data) { // the Closure which will be executed by the formatter. - return function ($value) { - switch ($value) { - case '_header': - // we have to process specifically the '_header' string, - // which will be used by the formatter to show a column title - return $this->getTitle(); - - default: - // for all value, we do not process them and return them - // immediatly - return $value; - } + return fn($value) => match ($value) { + '_header' => $this->getTitle(), + default => $value, }; } diff --git a/docs/source/development/user-interface/widgets/ChillMainConfiguration.php b/docs/source/development/user-interface/widgets/ChillMainConfiguration.php index 9eca0ae76..b4567729c 100644 --- a/docs/source/development/user-interface/widgets/ChillMainConfiguration.php +++ b/docs/source/development/user-interface/widgets/ChillMainConfiguration.php @@ -23,19 +23,12 @@ class ChillMainConfiguration implements ConfigurationInterface { use AddWidgetConfigurationTrait; - /** - * @var ContainerBuilder - */ - private $containerBuilder; - public function __construct( array $widgetFactories, - ContainerBuilder $containerBuilder + private ContainerBuilder $containerBuilder ) { // we register here widget factories (see below) $this->setWidgetFactories($widgetFactories); - // we will need the container builder later... - $this->containerBuilder = $containerBuilder; } public function getConfigTreeBuilder() From dde300210021cda4c3748b1a9487681d78ea2328 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sat, 15 Apr 2023 01:05:37 +0200 Subject: [PATCH 049/724] DX: apply rector rules up to php8.0 --- .../Controller/ActivityController.php | 68 +----- .../ActivityReasonCategoryController.php | 12 +- .../Controller/ActivityReasonController.php | 17 +- .../DataFixtures/ORM/LoadActivity.php | 5 +- .../Entity/ActivityReason.php | 4 +- .../Entity/ActivityReasonCategory.php | 4 +- .../Entity/ActivityType.php | 4 +- .../EntityListener/ActivityEntityListener.php | 8 +- .../ACPAggregators/ByCreatorAggregator.php | 12 +- .../BySocialActionAggregator.php | 12 +- .../BySocialIssueAggregator.php | 12 +- .../ACPAggregators/ByThirdpartyAggregator.php | 12 +- .../ACPAggregators/CreatorScopeAggregator.php | 12 +- .../ACPAggregators/DateAggregator.php | 22 +- .../ACPAggregators/LocationTypeAggregator.php | 12 +- .../Aggregator/ActivityTypeAggregator.php | 12 +- .../Aggregator/ActivityUserAggregator.php | 12 +- .../Aggregator/ActivityUsersAggregator.php | 8 +- .../Aggregator/ActivityUsersJobAggregator.php | 8 +- .../ActivityUsersScopeAggregator.php | 8 +- .../ActivityReasonAggregator.php | 36 +-- .../Aggregator/SentReceivedAggregator.php | 5 +- .../Export/LinkedToACP/ListActivity.php | 41 +--- .../Export/LinkedToPerson/CountActivity.php | 8 +- .../Export/LinkedToPerson/ListActivity.php | 20 +- .../LinkedToPerson/StatActivityDuration.php | 16 +- .../Export/Export/ListActivityHelper.php | 200 ++++++---------- .../Filter/ACPFilters/ActivityTypeFilter.php | 12 +- .../Filter/ACPFilters/ByCreatorFilter.php | 5 +- .../ACPFilters/BySocialActionFilter.php | 5 +- .../Filter/ACPFilters/BySocialIssueFilter.php | 5 +- .../Filter/ACPFilters/EmergencyFilter.php | 5 +- .../Filter/ACPFilters/LocationTypeFilter.php | 5 +- .../Filter/ACPFilters/SentReceivedFilter.php | 5 +- .../Export/Filter/ACPFilters/UserFilter.php | 5 +- .../Filter/ACPFilters/UserScopeFilter.php | 5 +- .../Export/Filter/ActivityDateFilter.php | 12 +- .../Export/Filter/ActivityTypeFilter.php | 12 +- .../Export/Filter/ActivityUsersFilter.php | 5 +- .../PersonFilters/ActivityReasonFilter.php | 12 +- .../PersonHavingActivityBetweenDateFilter.php | 16 +- .../Export/Filter/UsersJobFilter.php | 5 +- .../Export/Filter/UsersScopeFilter.php | 12 +- .../ChillActivityBundle/Form/ActivityType.php | 30 +-- .../Form/ActivityTypeType.php | 5 +- .../Form/Type/PickActivityReasonType.php | 16 +- ...TranslatableActivityReasonCategoryType.php | 8 +- .../Form/Type/TranslatableActivityType.php | 12 +- .../Menu/AccompanyingCourseMenuBuilder.php | 12 +- .../Menu/AdminMenuBuilder.php | 5 +- .../Menu/PersonMenuBuilder.php | 18 +- .../ActivityNotificationHandler.php | 5 +- .../Repository/ActivityACLAwareRepository.php | 28 +-- .../Repository/ActivityReasonRepository.php | 6 +- .../Security/Authorization/ActivityVoter.php | 5 +- .../Service/DocGenerator/ActivityContext.php | 36 +-- ...tActivitiesByAccompanyingPeriodContext.php | 40 +--- .../Controller/ActivityControllerTest.php | 8 +- .../Type/TranslatableActivityTypeTest.php | 4 +- .../Timeline/TimelineActivityProvider.php | 16 +- .../Controller/AsideActivityController.php | 5 +- .../DataFixtures/ORM/LoadAsideActivity.php | 5 +- .../src/Entity/AsideActivityCategory.php | 4 +- .../Aggregator/ByActivityTypeAggregator.php | 8 +- .../Export/Aggregator/ByUserJobAggregator.php | 8 +- .../Aggregator/ByUserScopeAggregator.php | 8 +- .../Export/AvgAsideActivityDuration.php | 8 +- .../src/Export/Export/CountAsideActivity.php | 8 +- .../src/Export/Export/ListAsideActivity.php | 157 +++++-------- .../Export/SumAsideActivityDuration.php | 8 +- .../Export/Filter/ByActivityTypeFilter.php | 16 +- .../src/Export/Filter/ByDateFilter.php | 12 +- .../src/Export/Filter/ByUserFilter.php | 5 +- .../src/Export/Filter/ByUserJobFilter.php | 5 +- .../src/Export/Filter/ByUserScopeFilter.php | 12 +- .../src/Form/AsideActivityCategoryType.php | 8 +- .../Type/PickAsideActivityCategoryType.php | 8 +- .../src/Menu/AdminMenuBuilder.php | 5 +- .../src/Menu/SectionMenuBuilder.php | 8 +- .../src/Templating/Entity/CategoryRender.php | 8 +- .../Controller/AbstractElementController.php | 34 +-- .../Controller/ElementController.php | 16 +- .../ChillBudgetBundle/Form/ChargeType.php | 16 +- .../ChillBudgetBundle/Form/ResourceType.php | 16 +- .../Menu/AdminMenuBuilder.php | 5 +- .../Menu/HouseholdMenuBuilder.php | 12 +- .../Menu/PersonMenuBuilder.php | 12 +- .../Service/Summary/SummaryBudget.php | 20 +- .../Templating/BudgetElementTypeRender.php | 8 +- .../Service/Summary/SummaryBudgetTest.php | 4 +- .../AzureGrantAdminConsentAndAcquireToken.php | 12 +- .../MapAndSubscribeUserCalendarCommand.php | 26 +-- .../SendShortMessageOnEligibleCalendar.php | 6 +- .../SendTestShortMessageOnCalendarCommand.php | 31 +-- .../Controller/CalendarAPIController.php | 5 +- .../Controller/CalendarController.php | 52 +---- .../Controller/CalendarDocController.php | 28 +-- .../Controller/CalendarRangeAPIController.php | 5 +- .../Controller/InviteApiController.php | 11 +- .../RemoteCalendarConnectAzureController.php | 12 +- .../RemoteCalendarMSGraphSyncController.php | 5 +- .../RemoteCalendarProxyController.php | 11 +- .../DataFixtures/ORM/LoadCalendarRange.php | 8 +- .../ChillCalendarBundle/Entity/Calendar.php | 15 +- .../Entity/CalendarDoc.php | 14 +- .../Event/ListenToActivityCreate.php | 5 +- .../Export/Aggregator/AgentAggregator.php | 12 +- .../Aggregator/CancelReasonAggregator.php | 12 +- .../Export/Aggregator/JobAggregator.php | 12 +- .../Export/Aggregator/LocationAggregator.php | 8 +- .../Aggregator/LocationTypeAggregator.php | 12 +- .../Export/Aggregator/ScopeAggregator.php | 12 +- .../Export/Aggregator/UrgencyAggregator.php | 23 +- .../Export/Export/CountCalendars.php | 5 +- .../Export/Export/StatCalendarAvgDuration.php | 8 +- .../Export/Export/StatCalendarSumDuration.php | 8 +- .../Export/Filter/AgentFilter.php | 5 +- .../Export/Filter/BetweenDatesFilter.php | 5 +- .../Export/Filter/CalendarRangeFilter.php | 5 +- .../Export/Filter/JobFilter.php | 12 +- .../Export/Filter/ScopeFilter.php | 12 +- .../ChillCalendarBundle/Form/CalendarType.php | 28 +-- .../Menu/AccompanyingCourseMenuBuilder.php | 12 +- .../Menu/PersonMenuBuilder.php | 12 +- .../Menu/UserMenuBuilder.php | 12 +- .../Doctrine/CalendarEntityListener.php | 8 +- .../Doctrine/CalendarRangeEntityListener.php | 8 +- .../CalendarRangeRemoveToRemoteHandler.php | 8 +- .../Handler/CalendarRangeToRemoteHandler.php | 16 +- .../Handler/CalendarRemoveHandler.php | 11 +- .../Handler/CalendarToRemoteHandler.php | 28 +-- .../Messenger/Handler/InviteUpdateHandler.php | 11 +- .../MSGraphChangeNotificationHandler.php | 36 +-- .../Messenger/Message/CalendarMessage.php | 5 +- .../Message/CalendarRangeMessage.php | 5 +- .../MSGraphChangeNotificationMessage.php | 8 +- .../Connector/MSGraph/AddressConverter.php | 8 +- .../EventsOnUserSubscriptionCreator.php | 20 +- .../Connector/MSGraph/LocationConverter.php | 5 +- .../MSGraph/MSGraphUserRepository.php | 5 +- .../Connector/MSGraph/MachineHttpClient.php | 5 +- .../Connector/MSGraph/MachineTokenStorage.php | 8 +- .../Connector/MSGraph/MapCalendarToUser.php | 12 +- .../MSGraph/OnBehalfOfUserHttpClient.php | 5 +- .../MSGraph/OnBehalfOfUserTokenStorage.php | 8 +- .../MSGraph/RemoteEventConverter.php | 25 +- .../RemoteToLocalSync/CalendarRangeSyncer.php | 16 +- .../RemoteToLocalSync/CalendarSyncer.php | 65 ++---- .../MSGraphRemoteCalendarConnector.php | 50 +--- .../RemoteCalendar/Model/RemoteEvent.php | 58 ++--- .../Repository/CalendarACLAwareRepository.php | 12 +- .../Repository/CalendarRangeRepository.php | 7 +- .../Security/Voter/CalendarDocVoter.php | 20 +- .../Security/Voter/CalendarVoter.php | 5 +- .../Service/DocGenerator/CalendarContext.php | 36 +-- .../BulkCalendarShortMessageSender.php | 17 +- .../CalendarForShortMessageProvider.php | 16 +- .../DefaultShortMessageForCalendarBuilder.php | 8 +- .../Command/CreateFieldsOnGroupCommand.php | 34 +-- .../Controller/CustomFieldController.php | 18 +- .../CustomFieldsGroupController.php | 30 +-- .../CustomFields/CustomFieldChoice.php | 26 +-- .../CustomFields/CustomFieldDate.php | 16 +- .../CustomFields/CustomFieldLongChoice.php | 18 +- .../CustomFields/CustomFieldNumber.php | 14 +- .../CustomFields/CustomFieldText.php | 24 +- .../CustomFields/CustomFieldTitle.php | 24 +- .../OptionRepository.php | 4 +- .../Form/CustomFieldType.php | 25 +- .../Form/CustomFieldsGroupType.php | 16 +- .../CustomFieldDataTransformer.php | 15 +- .../CustomFieldsGroupToIdTransformer.php | 12 +- .../JsonCustomFieldToArrayTransformer.php | 14 +- .../Form/Type/CustomFieldType.php | 8 +- .../Form/Type/LinkedCustomFieldsType.php | 8 +- .../Service/CustomFieldsHelper.php | 17 +- .../Twig/CustomFieldRenderingTwig.php | 8 +- .../CustomFields/CustomFieldsChoiceTest.php | 6 +- .../CustomFieldsGroupRenderingTwigTest.php | 4 +- .../Context/ContextManager.php | 7 +- .../Exception/UnexpectedTypeException.php | 2 +- .../AdminDocGeneratorTemplateController.php | 5 +- .../DocGeneratorTemplateController.php | 28 +-- .../Form/DocGeneratorTemplateType.php | 5 +- .../Exception/TemplateException.php | 5 +- .../GeneratorDriver/RelatorioDriver.php | 10 +- .../Menu/AdminMenuBuilder.php | 8 +- .../DocGeneratorTemplateRepository.php | 5 +- .../Helper/NormalizeNullValueHelper.php | 39 +--- .../Normalizer/DocGenObjectNormalizer.php | 17 +- .../Service/Context/BaseContextData.php | 5 +- .../Service/Generator/Generator.php | 24 +- .../Service/Generator/GeneratorException.php | 10 +- .../Service/Messenger/OnGenerationFails.php | 43 +--- .../Messenger/RequestGenerationHandler.php | 28 +-- .../Messenger/RequestGenerationMessage.php | 10 +- .../Serializer/Encoder/DocGenEncoderTest.php | 5 +- .../DocumentAccompanyingCourseController.php | 24 +- .../Controller/DocumentCategoryController.php | 15 +- .../Controller/DocumentPersonController.php | 24 +- .../Controller/StoredObjectApiController.php | 5 +- .../Entity/DocumentCategory.php | 40 ++-- .../Entity/StoredObject.php | 15 +- .../Form/DocumentCategoryType.php | 2 +- .../Form/PersonDocumentType.php | 20 +- .../ChillDocStoreBundle/Menu/MenuBuilder.php | 31 +-- .../AccompanyingCourseDocumentRepository.php | 5 +- .../Repository/DocumentCategoryRepository.php | 5 +- .../PersonDocumentACLAwareRepository.php | 14 +- .../AccompanyingCourseDocumentVoter.php | 10 +- .../Authorization/PersonDocumentVoter.php | 10 +- .../Normalizer/StoredObjectDenormalizer.php | 5 +- .../Service/StoredObjectManager.php | 12 +- .../WopiEditTwigExtensionRuntime.php | 8 +- ...ompanyingCourseDocumentWorkflowHandler.php | 5 +- .../Controller/EventController.php | 8 +- .../Controller/EventTypeController.php | 18 +- .../Controller/ParticipationController.php | 24 +- .../Controller/RoleController.php | 18 +- .../Controller/StatusController.php | 18 +- src/Bundle/ChillEventBundle/Entity/Event.php | 4 +- .../ChillEventBundle/Entity/Participation.php | 43 +--- .../Form/Type/PickEventType.php | 5 +- .../ChillEventBundle/Search/EventSearch.php | 32 +-- .../ParticipationControllerTest.php | 4 +- .../Config/ConfigRepository.php | 13 +- .../Controller/FamilyMemberController.php | 15 +- .../Form/FamilyMemberType.php | 18 +- .../Controller/AbstractCRUDController.php | 37 +-- .../CRUD/Controller/ApiController.php | 128 ++++------- .../CRUD/Controller/CRUDController.php | 109 +++------ .../CRUD/Routing/CRUDRoutesLoader.php | 31 +-- .../Command/ChillImportUsersCommand.php | 26 +-- .../ChillUserSendRenewPasswordCodeCommand.php | 4 +- .../Command/ExecuteCronJobCommand.php | 6 +- .../LoadAddressesBEFromBestAddressCommand.php | 10 +- .../LoadAddressesFRFromBANOCommand.php | 5 +- .../Command/LoadAndUpdateLanguagesCommand.php | 11 +- .../Command/LoadCountriesCommand.php | 11 +- .../Command/LoadPostalCodeFR.php | 6 +- .../Command/LoadPostalCodesCommand.php | 8 +- .../Command/SetPasswordCommand.php | 8 +- .../AddressReferenceAPIController.php | 8 +- .../AddressToReferenceMatcherController.php | 16 +- .../Controller/CenterController.php | 12 +- .../Controller/ExportController.php | 90 ++------ ...GeographicalUnitByAddressApiController.php | 26 +-- .../Controller/NotificationApiController.php | 43 +--- .../Controller/NotificationController.php | 42 +--- .../Controller/PasswordController.php | 4 +- .../Controller/PermissionApiController.php | 12 +- .../Controller/PermissionsGroupController.php | 53 +---- .../Controller/PostalCodeAPIController.php | 16 +- .../Controller/SavedExportController.php | 40 +--- .../Controller/ScopeController.php | 12 +- .../Controller/SearchController.php | 22 +- .../Controller/TimelineCenterController.php | 16 +- .../Controller/UserApiController.php | 8 +- .../Controller/UserController.php | 37 +-- .../Controller/WorkflowApiController.php | 77 ++----- .../Controller/WorkflowController.php | 26 +-- .../ChillMainBundle/Cron/CronManager.php | 25 +- .../ChillMainExtension.php | 5 +- .../CompilerPass/ACLFlagsCompilerPass.php | 25 +- .../DependencyInjection/Configuration.php | 5 +- .../Widget/AbstractWidgetsCompilerPass.php | 12 +- .../Doctrine/DQL/OverlapsI.php | 19 +- .../Event/TrackCreateUpdateSubscriber.php | 5 +- .../ChillMainBundle/Doctrine/Model/Point.php | 8 +- .../Doctrine/Type/NativeDateIntervalType.php | 28 +-- .../Doctrine/Type/PointType.php | 4 +- src/Bundle/ChillMainBundle/Entity/Address.php | 5 - src/Bundle/ChillMainBundle/Entity/Center.php | 6 +- .../ChillMainBundle/Entity/Civility.php | 3 - .../Entity/CronJobExecution.php | 15 +- .../SimpleGeographicalUnitDTO.php | 60 +++-- .../Entity/PermissionsGroup.php | 2 +- src/Bundle/ChillMainBundle/Entity/User.php | 8 +- .../Entity/Workflow/EntityWorkflow.php | 6 +- .../Entity/Workflow/EntityWorkflowStep.php | 8 +- .../ChillMainBundle/Export/ExportManager.php | 38 +--- .../Export/Formatter/CSVFormatter.php | 5 +- .../Export/Formatter/SpreadSheetFormatter.php | 30 +-- .../Export/Helper/DateTimeHelper.php | 5 +- .../Export/Helper/ExportAddressHelper.php | 35 +-- .../TranslatableStringExportLabelHelper.php | 5 +- .../Export/Helper/UserHelper.php | 8 +- .../DataMapper/PrivateCommentDataMapper.php | 5 +- .../Form/DataMapper/ScopePickerDataMapper.php | 8 +- .../IdToEntityDataTransformer.php | 8 +- .../Form/Event/CustomizeFormEvent.php | 8 +- .../ChillMainBundle/Form/LocationFormType.php | 5 +- .../Form/Type/ComposedRoleScopeType.php | 8 +- .../AddressToIdDataTransformer.php | 5 +- .../DataTransformer/CenterTransformer.php | 12 +- .../EntityToJsonTransformer.php | 39 +--- .../MultipleObjectsToIdTransformer.php | 8 +- .../DataTransformer/ObjectToIdTransformer.php | 12 +- .../PostalCodeToIdTransformer.php | 5 +- .../Type/DataTransformer/ScopeTransformer.php | 5 +- .../Form/Type/Export/PickCenterType.php | 15 +- .../Form/Type/Listing/FilterOrderType.php | 5 +- .../Form/Type/PickAddressType.php | 12 +- .../Form/Type/PickCenterType.php | 16 +- .../Form/Type/PickCivilityType.php | 5 +- .../Form/Type/PickLocationTypeType.php | 5 +- .../Form/Type/PickPostalCodeType.php | 5 +- .../Form/Type/PickUserDynamicType.php | 11 +- .../Form/Type/PickUserLocationType.php | 8 +- .../Form/Type/PrivateCommentType.php | 5 +- .../Form/Type/ScopePickerType.php | 16 +- .../Form/Type/Select2CountryType.php | 20 +- .../Form/Type/Select2LanguageType.php | 20 +- .../Form/Type/TranslatableStringFormType.php | 5 +- .../Form/Type/UserPickerType.php | 15 +- src/Bundle/ChillMainBundle/Form/UserType.php | 12 +- .../ChillMainBundle/Form/WorkflowStepType.php | 11 +- .../Counter/NotificationByUserCounter.php | 8 +- .../Notification/Email/NotificationMailer.php | 11 +- ...NotificationOnTerminateEventSubscriber.php | 8 +- .../ChillMainBundle/Notification/Mailer.php | 15 +- .../NotificationHandlerManager.php | 12 +- .../Notification/NotificationPresence.php | 8 +- .../NotificationTwigExtensionRuntime.php | 11 +- .../Pagination/ChillPaginationTwig.php | 19 +- .../ChillMainBundle/Pagination/Page.php | 65 ++---- .../Pagination/PageGenerator.php | 5 +- .../ChillMainBundle/Pagination/Paginator.php | 105 +++------ .../Pagination/PaginatorFactory.php | 42 ++-- .../Phonenumber/PhonenumberHelper.php | 26 +-- .../Phonenumber/Templating.php | 5 +- .../Repository/NotificationRepository.php | 7 +- .../Repository/UserACLAwareRepository.php | 8 +- .../Repository/UserRepository.php | 7 +- .../Routing/Loader/ChillRoutesLoader.php | 6 +- .../MenuBuilder/AdminUserMenuBuilder.php | 5 +- .../MenuBuilder/SectionMenuBuilder.php | 11 +- .../Routing/MenuBuilder/UserMenuBuilder.php | 28 +-- .../ChillMainBundle/Routing/MenuComposer.php | 16 +- .../ChillMainBundle/Routing/MenuTwig.php | 8 +- .../ChillMainBundle/Search/AbstractSearch.php | 2 +- .../Search/Entity/SearchUserApiProvider.php | 5 +- .../ChillMainBundle/Search/Model/Result.php | 18 +- .../ChillMainBundle/Search/SearchApi.php | 16 +- .../Search/SearchApiNoQueryException.php | 5 +- .../Search/SearchApiResult.php | 5 +- .../ChillMainBundle/Search/SearchProvider.php | 4 +- .../Search/Utils/SearchExtractionResult.php | 8 +- .../Authorization/AuthorizationHelper.php | 41 +--- .../AuthorizationHelperForCurrentUser.php | 8 +- .../Authorization/DefaultVoterHelper.php | 16 +- .../DefaultVoterHelperFactory.php | 12 +- .../DefaultVoterHelperGenerator.php | 12 +- .../Authorization/EntityWorkflowVoter.php | 8 +- .../Authorization/NotificationVoter.php | 43 ++-- .../Authorization/SavedExportVoter.php | 14 +- .../WorkflowEntityDeletionVoter.php | 10 +- .../Security/ParentRoleHelper.php | 5 +- .../PasswordRecover/PasswordRecoverEvent.php | 19 +- .../PasswordRecover/PasswordRecoverLocker.php | 75 ++---- .../Security/PasswordRecover/TokenManager.php | 7 +- .../Resolver/CenterResolverDispatcher.php | 7 +- .../Resolver/CenterResolverManager.php | 9 +- .../Resolver/ResolverTwigExtension.php | 14 +- .../Resolver/ScopeResolverDispatcher.php | 9 +- .../ChillMainBundle/Security/RoleProvider.php | 2 - .../Security/UserProvider/UserProvider.php | 5 +- .../Serializer/Model/Collection.php | 8 +- .../Serializer/Model/Counter.php | 5 +- .../Normalizer/AddressNormalizer.php | 5 +- .../Normalizer/CenterNormalizer.php | 5 +- .../CommentEmbeddableDocGenNormalizer.php | 5 +- .../Serializer/Normalizer/DateNormalizer.php | 8 +- .../DoctrineExistingEntityNormalizer.php | 8 +- .../Normalizer/EntityWorkflowNormalizer.php | 16 +- .../EntityWorkflowStepNormalizer.php | 5 +- .../Normalizer/NotificationNormalizer.php | 11 +- .../PrivateCommentEmbeddableNormalizer.php | 5 +- .../Serializer/Normalizer/UserNormalizer.php | 5 +- ...eographicalUnitMaterializedViewCronJob.php | 5 +- .../AddressReferenceBEFromBestAddress.php | 16 +- .../Import/AddressReferenceBaseImporter.php | 8 +- .../Import/AddressReferenceFromBano.php | 11 +- .../Import/AddressToReferenceMatcher.php | 8 +- .../Import/GeographicalUnitBaseImporter.php | 8 +- .../Import/PostalCodeBEFromBestAddress.php | 11 +- .../Service/Import/PostalCodeBaseImporter.php | 8 +- .../Import/PostalCodeFRFromOpenData.php | 18 +- .../Service/Mailer/ChillMailer.php | 8 +- .../Service/RollingDate/RollingDate.php | 8 +- .../RollingDate/RollingDateConverter.php | 39 +--- .../Service/ShortMessage/ShortMessage.php | 11 +- .../ShortMessage/ShortMessageHandler.php | 5 +- .../ShortMessage/ShortMessageTransporter.php | 8 +- .../ShortMessageOvh/OvhShortMessageSender.php | 28 +-- .../Templating/ChillTwigHelper.php | 28 +-- .../Templating/Entity/AddressRender.php | 12 +- .../Templating/Entity/CommentRender.php | 14 +- .../Templating/Entity/UserRender.php | 11 +- .../Templating/Listing/FilterOrderHelper.php | 12 +- .../Listing/FilterOrderHelperBuilder.php | 12 +- .../Listing/FilterOrderHelperFactory.php | 12 +- .../Templating/TranslatableStringHelper.php | 8 +- .../Templating/TranslatableStringTwig.php | 8 +- .../Templating/Widget/WidgetRenderingTwig.php | 2 +- .../Test/Export/AbstractExportTest.php | 4 +- .../Test/Export/AbstractFilterTest.php | 2 +- .../Controller/UserApiControllerTest.php | 4 +- .../Tests/Controller/UserControllerTest.php | 4 +- .../Tests/Cron/CronManagerTest.php | 5 +- .../Tests/Export/ExportManagerTest.php | 16 +- .../Tests/Pagination/PageTest.php | 6 +- .../Tests/Pagination/PaginatorTest.php | 9 +- .../ExtractPhonenumberFromPatternTest.php | 8 +- .../Authorization/AuthorizationHelperTest.php | 6 +- .../Normalizer/DateNormalizerTest.php | 8 +- .../DoctrineExistingEntityNormalizerTest.php | 4 +- .../Normalizer/PhonenumberNormalizerTest.php | 6 +- .../ChillMainBundle/Tests/TestHelper.php | 6 +- .../Timeline/TimelineBuilder.php | 12 +- .../Timeline/TimelineSingleQuery.php | 28 +-- .../Util/DateRangeCovering.php | 5 +- .../Validator/RoleScopeScopePresence.php | 25 +- .../Validation/Validator/ValidPhonenumber.php | 12 +- .../Counter/WorkflowByUserCounter.php | 8 +- .../Workflow/EntityWorkflowManager.php | 10 +- ...ntityWorkflowTransitionEventSubscriber.php | 16 +- .../NotificationOnTransition.php | 24 +- .../SendAccessKeyEventSubscriber.php | 17 +- .../Workflow/Helper/MetadataExtractor.php | 8 +- .../WorkflowNotificationHandler.php | 16 +- .../WorkflowTwigExtensionRuntime.php | 24 +- .../EntityWorkflowCreationValidator.php | 8 +- .../Validator/StepDestValidValidator.php | 1 - .../migrations/Version20180703191509.php | 2 +- .../PersonAddressMoveEventSubscriber.php | 20 +- .../Events/UserRefEventSubscriber.php | 14 +- .../ChillPersonBundle/Actions/ActionEvent.php | 49 ++-- .../Controller/EntityPersonCRUDController.php | 66 ++---- .../OneToOneEntityPersonCRUDController.php | 23 +- .../Command/ChillPersonMoveCommand.php | 16 +- .../Command/ImportSocialWorkMetadata.php | 9 +- ...emoveOldDraftAccompanyingPeriodCommand.php | 9 +- .../Config/ConfigPersonAltNamesHelper.php | 15 +- .../AccompanyingCourseApiController.php | 51 +---- .../AccompanyingCourseCommentController.php | 16 +- .../AccompanyingCourseController.php | 28 +-- .../AccompanyingCourseWorkApiController.php | 5 +- .../AccompanyingCourseWorkController.php | 24 +- .../AccompanyingPeriodController.php | 5 +- ...mpanyingPeriodRegulationListController.php | 20 +- ...nyingPeriodWorkEvaluationApiController.php | 24 +- .../Controller/HouseholdApiController.php | 16 +- .../HouseholdCompositionController.php | 45 +--- .../HouseholdCompositionTypeApiController.php | 13 +- .../Controller/HouseholdController.php | 20 +- .../Controller/HouseholdMemberController.php | 20 +- .../Controller/PersonAddressController.php | 2 - .../Controller/PersonApiController.php | 10 +- .../Controller/PersonController.php | 75 ++---- .../Controller/PersonDuplicateController.php | 43 +--- .../Controller/PersonResourceController.php | 20 +- .../ReassignAccompanyingPeriodController.php | 40 +--- .../Controller/RelationshipApiController.php | 8 +- .../ResidentialAddressController.php | 16 +- .../SocialWorkEvaluationApiController.php | 5 +- .../SocialWorkGoalApiController.php | 8 +- .../SocialWorkResultApiController.php | 5 +- .../SocialWorkSocialActionApiController.php | 8 +- .../Controller/TimelinePersonController.php | 16 +- .../UserAccompanyingPeriodController.php | 8 +- .../ORM/LoadAccompanyingPeriodWork.php | 12 +- .../DataFixtures/ORM/LoadCustomFields.php | 18 +- .../DataFixtures/ORM/LoadHousehold.php | 8 +- .../DataFixtures/ORM/LoadPeople.php | 35 +-- .../DataFixtures/ORM/LoadRelationships.php | 5 +- .../ORM/LoadSocialWorkMetadata.php | 5 +- .../ChillPersonExtension.php | 15 +- .../DependencyInjection/Configuration.php | 17 +- .../Entity/AccompanyingPeriod.php | 10 +- .../AccompanyingPeriodWorkEvaluation.php | 4 +- ...companyingPeriodWorkEvaluationDocument.php | 4 +- .../Entity/AccompanyingPeriod/Resource.php | 3 +- .../Entity/AccompanyingPeriod/UserHistory.php | 21 +- .../AccompanyingPeriodParticipation.php | 28 +-- .../Entity/MaritalStatus.php | 4 - .../ChillPersonBundle/Entity/Person.php | 45 ++-- .../Entity/Person/PersonCenterHistory.php | 34 ++- .../Entity/Person/PersonResource.php | 4 +- .../Entity/SocialWork/SocialAction.php | 4 +- .../Entity/SocialWork/SocialIssue.php | 3 +- .../Event/Person/PersonAddressMoveEvent.php | 8 +- .../AccompanyingPeriodWorkEventListener.php | 5 +- .../AdministrativeLocationAggregator.php | 12 +- .../ClosingMotiveAggregator.php | 12 +- .../ConfidentialAggregator.php | 23 +- .../CreatorJobAggregator.php | 12 +- .../DurationAggregator.php | 32 +-- .../EmergencyAggregator.php | 23 +- .../EvaluationAggregator.php | 12 +- .../GeographicalUnitStatAggregator.php | 63 ++---- .../IntensityAggregator.php | 23 +- .../OriginAggregator.php | 5 +- .../ReferrerAggregator.php | 16 +- .../ReferrerScopeAggregator.php | 16 +- .../RequestorAggregator.php | 8 +- .../ScopeAggregator.php | 12 +- .../SocialActionAggregator.php | 12 +- .../SocialIssueAggregator.php | 12 +- .../StepAggregator.php | 12 +- .../UserJobAggregator.php | 12 +- .../ByEndDateAggregator.php | 25 +- .../ByMaxDateAggregator.php | 25 +- .../ByStartDateAggregator.php | 25 +- .../EvaluationTypeAggregator.php | 12 +- .../HavingEndDateAggregator.php | 20 +- .../ChildrenNumberAggregator.php | 12 +- .../CompositionAggregator.php | 16 +- .../PersonAggregators/AgeAggregator.php | 5 +- .../ByHouseholdCompositionAggregator.php | 16 +- .../CountryOfBirthAggregator.php | 16 +- .../PersonAggregators/GenderAggregator.php | 5 +- .../GeographicalUnitAggregator.php | 63 ++---- .../HouseholdPositionAggregator.php | 20 +- .../MaritalStatusAggregator.php | 8 +- .../NationalityAggregator.php | 16 +- .../ActionTypeAggregator.php | 67 ++---- .../CurrentActionAggregator.php | 20 +- .../SocialWorkAggregators/GoalAggregator.php | 8 +- .../GoalResultAggregator.php | 16 +- .../SocialWorkAggregators/JobAggregator.php | 12 +- .../ReferrerAggregator.php | 12 +- .../ResultAggregator.php | 8 +- .../SocialWorkAggregators/ScopeAggregator.php | 12 +- .../Export/CountAccompanyingPeriodWork.php | 8 +- .../Export/Export/CountEvaluation.php | 8 +- .../Export/Export/CountHousehold.php | 27 +-- .../Export/Export/CountPerson.php | 8 +- .../Export/Export/ListAccompanyingPeriod.php | 213 ++++++------------ .../Export/ListAccompanyingPeriodWork.php | 172 ++++---------- .../Export/Export/ListEvaluation.php | 157 ++++--------- .../Export/Export/ListHouseholdInPeriod.php | 53 ++--- .../Export/Export/ListPerson.php | 34 +-- .../Export/Export/ListPersonDuplicate.php | 16 +- .../ListPersonWithAccompanyingPeriod.php | 22 +- .../Export/StatAccompanyingCourseDuration.php | 23 +- .../ActiveOnDateFilter.php | 5 +- .../ActiveOneDayBetweenDatesFilter.php | 5 +- .../AdministrativeLocationFilter.php | 8 +- .../ClosingMotiveFilter.php | 8 +- .../ConfidentialFilter.php | 5 +- .../CreatorJobFilter.php | 12 +- .../EmergencyFilter.php | 5 +- .../EvaluationFilter.php | 12 +- .../GeographicalUnitStatFilter.php | 20 +- .../HasNoReferrerFilter.php | 8 +- .../HasTemporaryLocationFilter.php | 57 ++--- .../IntensityFilter.php | 5 +- .../OpenBetweenDatesFilter.php | 5 +- .../OriginFilter.php | 8 +- .../ReferrerFilter.php | 8 +- .../RequestorFilter.php | 12 +- .../SocialActionFilter.php | 12 +- .../SocialIssueFilter.php | 5 +- .../AccompanyingCourseFilters/StepFilter.php | 15 +- .../UserJobFilter.php | 16 +- .../UserScopeFilter.php | 20 +- .../EvaluationFilters/ByEndDateFilter.php | 5 +- .../EvaluationFilters/ByStartDateFilter.php | 5 +- .../EvaluationTypeFilter.php | 8 +- .../EvaluationFilters/MaxDateFilter.php | 5 +- .../HouseholdFilters/CompositionFilter.php | 12 +- .../PersonFilters/AddressRefStatusFilter.php | 9 +- .../Export/Filter/PersonFilters/AgeFilter.php | 5 +- .../Filter/PersonFilters/BirthdateFilter.php | 5 +- .../ByHouseholdCompositionFilter.php | 16 +- .../PersonFilters/DeadOrAliveFilter.php | 8 +- .../Filter/PersonFilters/DeathdateFilter.php | 8 +- .../PersonFilters/GeographicalUnitFilter.php | 20 +- .../PersonFilters/MaritalStatusFilter.php | 8 +- .../PersonFilters/NationalityFilter.php | 8 +- .../ResidentialAddressAtThirdpartyFilter.php | 12 +- .../ResidentialAddressAtUserFilter.php | 8 +- .../WithoutHouseholdComposition.php | 8 +- .../Filter/SocialWorkFilters/JobFilter.php | 12 +- .../Filter/SocialWorkFilters/ScopeFilter.php | 12 +- .../SocialWorkTypeFilter.php | 16 +- .../Export/Helper/LabelPersonHelper.php | 8 +- .../Export/Helper/ListPersonHelper.php | 42 +--- .../Form/ChoiceLoader/PersonChoiceLoader.php | 6 +- .../Form/CreationPersonType.php | 10 +- .../Form/HouseholdCompositionType.php | 8 +- .../Form/PersonResourceType.php | 14 +- .../ChillPersonBundle/Form/PersonType.php | 10 +- .../Form/SocialWork/SocialIssueType.php | 8 +- .../Form/Type/ClosingMotivePickerType.php | 5 +- .../Form/Type/PersonAltNameType.php | 18 +- .../Form/Type/PersonPhoneType.php | 8 +- .../Form/Type/PickPersonDynamicType.php | 16 +- .../Form/Type/PickSocialActionType.php | 12 +- .../Form/Type/PickSocialIssueType.php | 12 +- .../Form/Type/Select2MaritalStatusType.php | 8 +- .../Household/MembersEditor.php | 11 +- .../Household/MembersEditorFactory.php | 12 +- .../Menu/AccompanyingCourseMenuBuilder.php | 8 +- .../Menu/PersonMenuBuilder.php | 16 +- .../Menu/SectionMenuBuilder.php | 11 +- .../AccompanyingPeriodNotificationHandler.php | 5 +- .../AccompanyingPeriodPrivacyEvent.php | 8 +- .../Privacy/PrivacyEvent.php | 14 +- .../AccompanyingPeriodWorkRepository.php | 7 +- .../ClosingMotiveRepository.php | 5 +- .../AccompanyingPeriodACLAwareRepository.php | 20 +- .../Household/HouseholdACLAwareRepository.php | 11 +- .../Repository/PersonACLAwareRepository.php | 20 +- .../ChillPersonBundle/Search/PersonSearch.php | 26 +-- .../Search/SearchHouseholdApiProvider.php | 28 +-- .../Search/SearchPersonApiProvider.php | 28 +-- .../Search/SimilarPersonMatcher.php | 10 +- .../AccompanyingPeriodCommentVoter.php | 21 +- .../AccompanyingPeriodResourceVoter.php | 25 +- .../Authorization/AccompanyingPeriodVoter.php | 5 +- ...nyingPeriodWorkEvaluationDocumentVoter.php | 24 +- .../AccompanyingPeriodWorkEvaluationVoter.php | 20 +- .../AccompanyingPeriodWorkVoter.php | 45 ++-- .../Security/Authorization/HouseholdVoter.php | 24 +- .../AuthorizedCenterOnPersonCreation.php | 5 +- .../AccompanyingPeriodDocGenNormalizer.php | 24 +- .../AccompanyingPeriodResourceNormalizer.php | 5 +- .../AccompanyingPeriodWorkDenormalizer.php | 12 +- ...PeriodWorkEvaluationDocumentNormalizer.php | 11 +- ...mpanyingPeriodWorkEvaluationNormalizer.php | 11 +- .../AccompanyingPeriodWorkNormalizer.php | 15 +- .../Normalizer/MembersEditorNormalizer.php | 5 +- .../Normalizer/PersonDocGenNormalizer.php | 26 +-- .../Normalizer/PersonJsonNormalizer.php | 26 +-- .../RelationshipDocGenNormalizer.php | 5 +- .../Normalizer/SocialActionNormalizer.php | 5 +- .../Normalizer/SocialIssueNormalizer.php | 5 +- .../Normalizer/WorkflowNormalizer.php | 8 +- .../OldDraftAccompanyingPeriodRemover.php | 8 +- .../AccompanyingPeriodContext.php | 36 +-- .../AccompanyingPeriodWorkContext.php | 12 +- ...ccompanyingPeriodWorkEvaluationContext.php | 24 +- .../Service/DocGenerator/PersonContext.php | 50 +--- .../PersonContextWithThirdParty.php | 16 +- .../Service/Import/SocialWorkMetadata.php | 28 +-- .../Templating/Entity/ClosingMotiveRender.php | 8 +- .../Templating/Entity/PersonRender.php | 15 +- .../Templating/Entity/ResourceKindRender.php | 5 +- .../Templating/Entity/SocialActionRender.php | 16 +- .../Templating/Entity/SocialIssueRender.php | 16 +- ...cialIssueConsistencyEntityListenerTest.php | 8 +- .../AccompanyingCourseApiControllerTest.php | 15 +- .../AccompanyingCourseControllerTest.php | 5 +- .../Controller/HouseholdControllerTest.php | 16 +- .../HouseholdMemberControllerTest.php | 22 +- .../Controller/PersonApiControllerTest.php | 16 +- .../Controller/PersonControllerCreateTest.php | 2 +- .../RelationshipApiControllerTest.php | 11 +- .../EventListener/PersonCreateEventTest.php | 12 +- .../Tests/Search/PersonSearchTest.php | 4 +- .../Normalizer/PersonDocGenNormalizerTest.php | 14 +- .../TimelineAccompanyingPeriodTest.php | 4 +- .../Household/MaxHolderValidatorTest.php | 4 +- .../AbstractTimelineAccompanyingPeriod.php | 15 +- .../AccompanyingPeriodValidityValidator.php | 11 +- .../LocationValidityValidator.php | 5 +- .../ParticipationOverlapValidator.php | 8 +- .../ResourceDuplicateCheckValidator.php | 8 +- ...HouseholdMembershipSequentialValidator.php | 5 +- .../Constraints/Person/BirthdateValidator.php | 7 +- .../Person/PersonHasCenterValidator.php | 5 +- .../RelationshipNoDuplicateValidator.php | 5 +- .../Widget/PersonListWidget.php | 20 +- ...dWorkEvaluationDocumentWorkflowHandler.php | 16 +- ...ingPeriodWorkEvaluationWorkflowHandler.php | 16 +- .../AccompanyingPeriodWorkWorkflowHandler.php | 16 +- .../Controller/ReportController.php | 5 +- .../DataFixtures/ORM/LoadReports.php | 2 +- .../Export/Export/ReportList.php | 71 ++---- .../Export/Filter/ReportDateFilter.php | 8 +- .../ChillReportBundle/Search/ReportSearch.php | 17 +- .../Tests/Search/ReportSearchTest.php | 4 +- .../Timeline/TimelineReportProvider.php | 39 +--- .../Controller/SingleTaskController.php | 73 ++---- .../ChillTaskBundle/Event/UI/UIEvent.php | 16 +- .../Form/SingleTaskListType.php | 3 +- .../ChillTaskBundle/Form/SingleTaskType.php | 16 +- .../ChillTaskBundle/Menu/MenuBuilder.php | 25 +- .../SingleTaskAclAwareRepository.php | 22 +- .../Authorization/AuthorizationEvent.php | 20 +- .../Security/Authorization/TaskVoter.php | 16 +- .../Controller/SingleTaskControllerTest.php | 4 +- .../TaskLifeCycleEventTimelineProvider.php | 39 +--- .../Controller/ThirdPartyController.php | 25 +- .../Entity/ThirdParty.php | 29 +-- .../Export/Helper/LabelThirdPartyHelper.php | 8 +- .../Form/ThirdPartyType.php | 25 +- .../Type/PickThirdPartyTypeCategoryType.php | 20 +- .../Form/Type/PickThirdpartyDynamicType.php | 11 +- .../ThirdPartyACLAwareRepository.php | 11 +- .../Search/ThirdPartyApiSearch.php | 5 +- .../Search/ThirdPartySearch.php | 5 +- .../Normalizer/ThirdPartyNormalizer.php | 12 +- .../Templating/Entity/ThirdPartyRender.php | 11 +- .../src/Controller/Convert.php | 25 +- .../ChillWopiBundle/src/Controller/Editor.php | 44 +--- .../src/Service/Controller/Responder.php | 16 +- .../src/Service/Wopi/AuthorizationManager.php | 8 +- .../Service/Wopi/ChillDocumentLockManager.php | 5 +- .../src/Service/Wopi/ChillDocumentManager.php | 25 +- .../src/Service/Wopi/ChillWopi.php | 8 +- .../src/Service/Wopi/UserManager.php | 5 +- 714 files changed, 2348 insertions(+), 9263 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php index 97678af50..3ea61c0cf 100644 --- a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php +++ b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php @@ -47,76 +47,14 @@ use function array_key_exists; final class ActivityController extends AbstractController { - private AccompanyingPeriodRepository $accompanyingPeriodRepository; - - private ActivityACLAwareRepositoryInterface $activityACLAwareRepository; - - private ActivityRepository $activityRepository; - - private ActivityTypeCategoryRepository $activityTypeCategoryRepository; - - private ActivityTypeRepositoryInterface $activityTypeRepository; - - private CenterResolverManagerInterface $centerResolver; - - private EntityManagerInterface $entityManager; - - private EventDispatcherInterface $eventDispatcher; - - private LocationRepository $locationRepository; - - private LoggerInterface $logger; - - private PersonRepository $personRepository; - - private SerializerInterface $serializer; - - private ThirdPartyRepository $thirdPartyRepository; - - private TranslatorInterface $translator; - - private UserRepositoryInterface $userRepository; - - public function __construct( - ActivityACLAwareRepositoryInterface $activityACLAwareRepository, - ActivityTypeRepositoryInterface $activityTypeRepository, - ActivityTypeCategoryRepository $activityTypeCategoryRepository, - PersonRepository $personRepository, - ThirdPartyRepository $thirdPartyRepository, - LocationRepository $locationRepository, - ActivityRepository $activityRepository, - AccompanyingPeriodRepository $accompanyingPeriodRepository, - EntityManagerInterface $entityManager, - EventDispatcherInterface $eventDispatcher, - LoggerInterface $logger, - SerializerInterface $serializer, - UserRepositoryInterface $userRepository, - CenterResolverManagerInterface $centerResolver, - TranslatorInterface $translator - ) { - $this->activityACLAwareRepository = $activityACLAwareRepository; - $this->activityTypeRepository = $activityTypeRepository; - $this->activityTypeCategoryRepository = $activityTypeCategoryRepository; - $this->personRepository = $personRepository; - $this->thirdPartyRepository = $thirdPartyRepository; - $this->locationRepository = $locationRepository; - $this->activityRepository = $activityRepository; - $this->accompanyingPeriodRepository = $accompanyingPeriodRepository; - $this->entityManager = $entityManager; - $this->eventDispatcher = $eventDispatcher; - $this->logger = $logger; - $this->serializer = $serializer; - $this->userRepository = $userRepository; - $this->centerResolver = $centerResolver; - $this->translator = $translator; + public function __construct(private ActivityACLAwareRepositoryInterface $activityACLAwareRepository, private ActivityTypeRepositoryInterface $activityTypeRepository, private ActivityTypeCategoryRepository $activityTypeCategoryRepository, private PersonRepository $personRepository, private ThirdPartyRepository $thirdPartyRepository, private LocationRepository $locationRepository, private ActivityRepository $activityRepository, private AccompanyingPeriodRepository $accompanyingPeriodRepository, private EntityManagerInterface $entityManager, private EventDispatcherInterface $eventDispatcher, private LoggerInterface $logger, private SerializerInterface $serializer, private UserRepositoryInterface $userRepository, private CenterResolverManagerInterface $centerResolver, private TranslatorInterface $translator) + { } /** * Deletes a Activity entity. - * - * @param mixed $id */ - public function deleteAction(Request $request, $id) + public function deleteAction(Request $request, mixed $id) { $view = null; diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityReasonCategoryController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityReasonCategoryController.php index 32cec74a5..bff55a006 100644 --- a/src/Bundle/ChillActivityBundle/Controller/ActivityReasonCategoryController.php +++ b/src/Bundle/ChillActivityBundle/Controller/ActivityReasonCategoryController.php @@ -47,10 +47,8 @@ class ActivityReasonCategoryController extends AbstractController /** * Displays a form to edit an existing ActivityReasonCategory entity. - * - * @param mixed $id */ - public function editAction($id) + public function editAction(mixed $id) { $em = $this->getDoctrine()->getManager(); @@ -98,10 +96,8 @@ class ActivityReasonCategoryController extends AbstractController /** * Finds and displays a ActivityReasonCategory entity. - * - * @param mixed $id */ - public function showAction($id) + public function showAction(mixed $id) { $em = $this->getDoctrine()->getManager(); @@ -118,10 +114,8 @@ class ActivityReasonCategoryController extends AbstractController /** * Edits an existing ActivityReasonCategory entity. - * - * @param mixed $id */ - public function updateAction(Request $request, $id) + public function updateAction(Request $request, mixed $id) { $em = $this->getDoctrine()->getManager(); diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityReasonController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityReasonController.php index 95a49d0ba..60a7636e4 100644 --- a/src/Bundle/ChillActivityBundle/Controller/ActivityReasonController.php +++ b/src/Bundle/ChillActivityBundle/Controller/ActivityReasonController.php @@ -24,11 +24,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; */ class ActivityReasonController extends AbstractController { - private ActivityReasonRepository $activityReasonRepository; - - public function __construct(ActivityReasonRepository $activityReasonRepository) + public function __construct(private ActivityReasonRepository $activityReasonRepository) { - $this->activityReasonRepository = $activityReasonRepository; } /** @@ -56,10 +53,8 @@ class ActivityReasonController extends AbstractController /** * Displays a form to edit an existing ActivityReason entity. - * - * @param mixed $id */ - public function editAction($id) + public function editAction(mixed $id) { $em = $this->getDoctrine()->getManager(); @@ -107,10 +102,8 @@ class ActivityReasonController extends AbstractController /** * Finds and displays a ActivityReason entity. - * - * @param mixed $id */ - public function showAction($id) + public function showAction(mixed $id) { $em = $this->getDoctrine()->getManager(); @@ -127,10 +120,8 @@ class ActivityReasonController extends AbstractController /** * Edits an existing ActivityReason entity. - * - * @param mixed $id */ - public function updateAction(Request $request, $id) + public function updateAction(Request $request, mixed $id) { $em = $this->getDoctrine()->getManager(); diff --git a/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivity.php b/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivity.php index 82949d635..74eb4f8d3 100644 --- a/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivity.php +++ b/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivity.php @@ -25,17 +25,14 @@ class LoadActivity extends AbstractFixture implements OrderedFixtureInterface { use \Symfony\Component\DependencyInjection\ContainerAwareTrait; - private EntityManagerInterface $em; - /** * @var \Faker\Generator */ private $faker; - public function __construct(EntityManagerInterface $em) + public function __construct(private EntityManagerInterface $em) { $this->faker = FakerFactory::create('fr_FR'); - $this->em = $em; } public function getOrder() diff --git a/src/Bundle/ChillActivityBundle/Entity/ActivityReason.php b/src/Bundle/ChillActivityBundle/Entity/ActivityReason.php index e6da6b7e0..9d1e88409 100644 --- a/src/Bundle/ChillActivityBundle/Entity/ActivityReason.php +++ b/src/Bundle/ChillActivityBundle/Entity/ActivityReason.php @@ -83,10 +83,8 @@ class ActivityReason * Get name. * * @param mixed|null $locale - * - * @return array | string */ - public function getName($locale = null) + public function getName($locale = null): array|string { if ($locale) { if (isset($this->name[$locale])) { diff --git a/src/Bundle/ChillActivityBundle/Entity/ActivityReasonCategory.php b/src/Bundle/ChillActivityBundle/Entity/ActivityReasonCategory.php index e8c2e245d..ab63232a5 100644 --- a/src/Bundle/ChillActivityBundle/Entity/ActivityReasonCategory.php +++ b/src/Bundle/ChillActivityBundle/Entity/ActivityReasonCategory.php @@ -21,7 +21,7 @@ use Doctrine\ORM\Mapping as ORM; * @ORM\Table(name="activityreasoncategory") * @ORM\HasLifecycleCallbacks */ -class ActivityReasonCategory +class ActivityReasonCategory implements \Stringable { /** * @var bool @@ -65,7 +65,7 @@ class ActivityReasonCategory /** * @return string */ - public function __toString() + public function __toString(): string { return 'ActivityReasonCategory(' . $this->getName('x') . ')'; } diff --git a/src/Bundle/ChillActivityBundle/Entity/ActivityType.php b/src/Bundle/ChillActivityBundle/Entity/ActivityType.php index ed8260a4d..f49297f02 100644 --- a/src/Bundle/ChillActivityBundle/Entity/ActivityType.php +++ b/src/Bundle/ChillActivityBundle/Entity/ActivityType.php @@ -275,10 +275,8 @@ class ActivityType /** * @Assert\Callback - * - * @param mixed $payload */ - public function checkSocialActionsVisibility(ExecutionContextInterface $context, $payload) + public function checkSocialActionsVisibility(ExecutionContextInterface $context, mixed $payload) { if ($this->socialIssuesVisible !== $this->socialActionsVisible) { if (!(2 === $this->socialIssuesVisible && 1 === $this->socialActionsVisible)) { diff --git a/src/Bundle/ChillActivityBundle/EntityListener/ActivityEntityListener.php b/src/Bundle/ChillActivityBundle/EntityListener/ActivityEntityListener.php index 76fb440e7..fb2fb8a1c 100644 --- a/src/Bundle/ChillActivityBundle/EntityListener/ActivityEntityListener.php +++ b/src/Bundle/ChillActivityBundle/EntityListener/ActivityEntityListener.php @@ -22,14 +22,8 @@ use function in_array; class ActivityEntityListener { - private EntityManagerInterface $em; - - private AccompanyingPeriodWorkRepository $workRepository; - - public function __construct(EntityManagerInterface $em, AccompanyingPeriodWorkRepository $workRepository) + public function __construct(private EntityManagerInterface $em, private AccompanyingPeriodWorkRepository $workRepository) { - $this->em = $em; - $this->workRepository = $workRepository; } public function persistActionToCourse(Activity $activity) diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByCreatorAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByCreatorAggregator.php index 69149737b..60cff42f8 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByCreatorAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByCreatorAggregator.php @@ -20,16 +20,8 @@ use Symfony\Component\Form\FormBuilderInterface; class ByCreatorAggregator implements AggregatorInterface { - private UserRender $userRender; - - private UserRepositoryInterface $userRepository; - - public function __construct( - UserRepositoryInterface $userRepository, - UserRender $userRender - ) { - $this->userRepository = $userRepository; - $this->userRender = $userRender; + public function __construct(private UserRepositoryInterface $userRepository, private UserRender $userRender) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialActionAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialActionAggregator.php index 89732412d..a09c254eb 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialActionAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialActionAggregator.php @@ -21,16 +21,8 @@ use function in_array; class BySocialActionAggregator implements AggregatorInterface { - private SocialActionRender $actionRender; - - private SocialActionRepository $actionRepository; - - public function __construct( - SocialActionRender $actionRender, - SocialActionRepository $actionRepository - ) { - $this->actionRender = $actionRender; - $this->actionRepository = $actionRepository; + public function __construct(private SocialActionRender $actionRender, private SocialActionRepository $actionRepository) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialIssueAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialIssueAggregator.php index 158e87664..111bdcf4b 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialIssueAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialIssueAggregator.php @@ -21,16 +21,8 @@ use function in_array; class BySocialIssueAggregator implements AggregatorInterface { - private SocialIssueRender $issueRender; - - private SocialIssueRepository $issueRepository; - - public function __construct( - SocialIssueRepository $issueRepository, - SocialIssueRender $issueRender - ) { - $this->issueRepository = $issueRepository; - $this->issueRender = $issueRender; + public function __construct(private SocialIssueRepository $issueRepository, private SocialIssueRender $issueRender) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByThirdpartyAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByThirdpartyAggregator.php index c3ca6d59c..83c4a5d2a 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByThirdpartyAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByThirdpartyAggregator.php @@ -21,16 +21,8 @@ use function in_array; class ByThirdpartyAggregator implements AggregatorInterface { - private ThirdPartyRender $thirdPartyRender; - - private ThirdPartyRepository $thirdPartyRepository; - - public function __construct( - ThirdPartyRepository $thirdPartyRepository, - ThirdPartyRender $thirdPartyRender - ) { - $this->thirdPartyRepository = $thirdPartyRepository; - $this->thirdPartyRender = $thirdPartyRender; + public function __construct(private ThirdPartyRepository $thirdPartyRepository, private ThirdPartyRender $thirdPartyRender) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/CreatorScopeAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/CreatorScopeAggregator.php index 2c7ec1483..3014352ad 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/CreatorScopeAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/CreatorScopeAggregator.php @@ -21,16 +21,8 @@ use function in_array; class CreatorScopeAggregator implements AggregatorInterface { - private ScopeRepository $scopeRepository; - - private TranslatableStringHelper $translatableStringHelper; - - public function __construct( - ScopeRepository $scopeRepository, - TranslatableStringHelper $translatableStringHelper - ) { - $this->scopeRepository = $scopeRepository; - $this->translatableStringHelper = $translatableStringHelper; + public function __construct(private ScopeRepository $scopeRepository, private TranslatableStringHelper $translatableStringHelper) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/DateAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/DateAggregator.php index b4b23dc0b..a4f93e3b3 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/DateAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/DateAggregator.php @@ -29,12 +29,8 @@ class DateAggregator implements AggregatorInterface private const DEFAULT_CHOICE = 'year'; - private TranslatorInterface $translator; - - public function __construct( - TranslatorInterface $translator - ) { - $this->translator = $translator; + public function __construct(private TranslatorInterface $translator) + { } public function addRole(): ?string @@ -99,17 +95,9 @@ class DateAggregator implements AggregatorInterface return ''; } - switch ($data['frequency']) { - case 'month': - case 'week': - //return $this->translator->trans('for week') .' '. $value ; - - case 'year': - //return $this->translator->trans('in year') .' '. $value ; - - default: - return $value; - } + return match ($data['frequency']) { + default => $value, + }; }; } diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/LocationTypeAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/LocationTypeAggregator.php index ec4ce6315..fa2c7f7c2 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/LocationTypeAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/LocationTypeAggregator.php @@ -21,16 +21,8 @@ use function in_array; class LocationTypeAggregator implements AggregatorInterface { - private LocationTypeRepository $locationTypeRepository; - - private TranslatableStringHelper $translatableStringHelper; - - public function __construct( - LocationTypeRepository $locationTypeRepository, - TranslatableStringHelper $translatableStringHelper - ) { - $this->locationTypeRepository = $locationTypeRepository; - $this->translatableStringHelper = $translatableStringHelper; + public function __construct(private LocationTypeRepository $locationTypeRepository, private TranslatableStringHelper $translatableStringHelper) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php index 7cd16718e..272727d55 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php @@ -24,16 +24,8 @@ class ActivityTypeAggregator implements AggregatorInterface { public const KEY = 'activity_type_aggregator'; - protected ActivityTypeRepositoryInterface $activityTypeRepository; - - protected TranslatableStringHelperInterface $translatableStringHelper; - - public function __construct( - ActivityTypeRepositoryInterface $activityTypeRepository, - TranslatableStringHelperInterface $translatableStringHelper - ) { - $this->activityTypeRepository = $activityTypeRepository; - $this->translatableStringHelper = $translatableStringHelper; + public function __construct(protected ActivityTypeRepositoryInterface $activityTypeRepository, protected TranslatableStringHelperInterface $translatableStringHelper) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUserAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUserAggregator.php index 9bde692c6..228ab8500 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUserAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUserAggregator.php @@ -23,16 +23,8 @@ class ActivityUserAggregator implements AggregatorInterface { public const KEY = 'activity_user_id'; - private UserRender $userRender; - - private UserRepository $userRepository; - - public function __construct( - UserRepository $userRepository, - UserRender $userRender - ) { - $this->userRepository = $userRepository; - $this->userRender = $userRender; + public function __construct(private UserRepository $userRepository, private UserRender $userRender) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersAggregator.php index 139f2743e..c1b2ff845 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersAggregator.php @@ -21,14 +21,8 @@ use function in_array; class ActivityUsersAggregator implements AggregatorInterface { - private UserRender $userRender; - - private UserRepositoryInterface $userRepository; - - public function __construct(UserRepositoryInterface $userRepository, UserRender $userRender) + public function __construct(private UserRepositoryInterface $userRepository, private UserRender $userRender) { - $this->userRepository = $userRepository; - $this->userRender = $userRender; } public function addRole(): ?string diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersJobAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersJobAggregator.php index 5741a0e58..1b8cb7e1c 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersJobAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersJobAggregator.php @@ -20,14 +20,8 @@ use function in_array; class ActivityUsersJobAggregator implements \Chill\MainBundle\Export\AggregatorInterface { - private TranslatableStringHelperInterface $translatableStringHelper; - - private UserJobRepositoryInterface $userJobRepository; - - public function __construct(UserJobRepositoryInterface $userJobRepository, TranslatableStringHelperInterface $translatableStringHelper) + public function __construct(private UserJobRepositoryInterface $userJobRepository, private TranslatableStringHelperInterface $translatableStringHelper) { - $this->userJobRepository = $userJobRepository; - $this->translatableStringHelper = $translatableStringHelper; } public function addRole(): ?string diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersScopeAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersScopeAggregator.php index 15da300be..1f39ccf82 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersScopeAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersScopeAggregator.php @@ -20,14 +20,8 @@ use function in_array; class ActivityUsersScopeAggregator implements \Chill\MainBundle\Export\AggregatorInterface { - private ScopeRepositoryInterface $scopeRepository; - - private TranslatableStringHelperInterface $translatableStringHelper; - - public function __construct(ScopeRepositoryInterface $scopeRepository, TranslatableStringHelperInterface $translatableStringHelper) + public function __construct(private ScopeRepositoryInterface $scopeRepository, private TranslatableStringHelperInterface $translatableStringHelper) { - $this->scopeRepository = $scopeRepository; - $this->translatableStringHelper = $translatableStringHelper; } public function addRole(): ?string diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/PersonAggregators/ActivityReasonAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/PersonAggregators/ActivityReasonAggregator.php index eaccf95cb..afdc0bacf 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/PersonAggregators/ActivityReasonAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/PersonAggregators/ActivityReasonAggregator.php @@ -30,20 +30,8 @@ use function in_array; class ActivityReasonAggregator implements AggregatorInterface, ExportElementValidatedInterface { - protected ActivityReasonCategoryRepository $activityReasonCategoryRepository; - - protected ActivityReasonRepository $activityReasonRepository; - - protected TranslatableStringHelperInterface $translatableStringHelper; - - public function __construct( - ActivityReasonCategoryRepository $activityReasonCategoryRepository, - ActivityReasonRepository $activityReasonRepository, - TranslatableStringHelper $translatableStringHelper - ) { - $this->activityReasonCategoryRepository = $activityReasonCategoryRepository; - $this->activityReasonRepository = $activityReasonRepository; - $this->translatableStringHelper = $translatableStringHelper; + public function __construct(protected ActivityReasonCategoryRepository $activityReasonCategoryRepository, protected ActivityReasonRepository $activityReasonRepository, protected TranslatableStringHelper $translatableStringHelper) + { } public function addRole(): ?string @@ -113,21 +101,11 @@ class ActivityReasonAggregator implements AggregatorInterface, ExportElementVali public function getLabels($key, array $values, $data) { - // for performance reason, we load data from db only once - switch ($data['level']) { - case 'reasons': - $this->activityReasonRepository->findBy(['id' => $values]); - - break; - - case 'categories': - $this->activityReasonCategoryRepository->findBy(['id' => $values]); - - break; - - default: - throw new RuntimeException(sprintf("The level data '%s' is invalid.", $data['level'])); - } + match ($data['level']) { + 'reasons' => $this->activityReasonRepository->findBy(['id' => $values]), + 'categories' => $this->activityReasonCategoryRepository->findBy(['id' => $values]), + default => throw new RuntimeException(sprintf("The level data '%s' is invalid.", $data['level'])), + }; return function ($value) use ($data) { if ('_header' === $value) { diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/SentReceivedAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/SentReceivedAggregator.php index 5f772e156..7ff94aaca 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/SentReceivedAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/SentReceivedAggregator.php @@ -20,11 +20,8 @@ use Symfony\Contracts\Translation\TranslatorInterface; class SentReceivedAggregator implements AggregatorInterface { - private TranslatorInterface $translator; - - public function __construct(TranslatorInterface $translator) + public function __construct(private TranslatorInterface $translator) { - $this->translator = $translator; } public function addRole(): ?string diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php index 026e16f90..6e98565c6 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php @@ -24,20 +24,8 @@ use Symfony\Component\Form\FormBuilderInterface; class ListActivity implements ListInterface, GroupedExportInterface { - private EntityManagerInterface $entityManager; - - private ListActivityHelper $helper; - - private TranslatableStringExportLabelHelper $translatableStringExportLabelHelper; - - public function __construct( - ListActivityHelper $helper, - EntityManagerInterface $entityManager, - TranslatableStringExportLabelHelper $translatableStringExportLabelHelper - ) { - $this->helper = $helper; - $this->entityManager = $entityManager; - $this->translatableStringExportLabelHelper = $translatableStringExportLabelHelper; + public function __construct(private ListActivityHelper $helper, private EntityManagerInterface $entityManager, private TranslatableStringExportLabelHelper $translatableStringExportLabelHelper) + { } public function buildForm(FormBuilderInterface $builder) @@ -62,22 +50,17 @@ class ListActivity implements ListInterface, GroupedExportInterface public function getLabels($key, array $values, $data) { - switch ($key) { - case 'acpId': - return static function ($value) { - if ('_header' === $value) { - return ListActivityHelper::MSG_KEY . 'accompanying course id'; - } + return match ($key) { + 'acpId' => static function ($value) { + if ('_header' === $value) { + return ListActivityHelper::MSG_KEY . 'accompanying course id'; + } - return $value ?? ''; - }; - - case 'scopesNames': - return $this->translatableStringExportLabelHelper->getLabelMulti($key, $values, ListActivityHelper::MSG_KEY . 'course circles'); - - default: - return $this->helper->getLabels($key, $values, $data); - } + return $value ?? ''; + }, + 'scopesNames' => $this->translatableStringExportLabelHelper->getLabelMulti($key, $values, ListActivityHelper::MSG_KEY . 'course circles'), + default => $this->helper->getLabels($key, $values, $data), + }; } public function getQueryKeys($data) diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/CountActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/CountActivity.php index 4246df173..171d8f829 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/CountActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/CountActivity.php @@ -24,12 +24,8 @@ use Symfony\Component\Form\FormBuilderInterface; class CountActivity implements ExportInterface, GroupedExportInterface { - protected ActivityRepository $activityRepository; - - public function __construct( - ActivityRepository $activityRepository - ) { - $this->activityRepository = $activityRepository; + public function __construct(protected ActivityRepository $activityRepository) + { } public function buildForm(FormBuilderInterface $builder) diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php index 60110c9a8..ff4d4fa47 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php @@ -36,8 +36,6 @@ use function in_array; class ListActivity implements ListInterface, GroupedExportInterface { - protected EntityManagerInterface $entityManager; - protected array $fields = [ 'id', 'date', @@ -52,22 +50,8 @@ class ListActivity implements ListInterface, GroupedExportInterface 'person_id', ]; - protected TranslatableStringHelperInterface $translatableStringHelper; - - protected TranslatorInterface $translator; - - private ActivityRepository $activityRepository; - - public function __construct( - EntityManagerInterface $em, - TranslatorInterface $translator, - TranslatableStringHelperInterface $translatableStringHelper, - ActivityRepository $activityRepository - ) { - $this->entityManager = $em; - $this->translator = $translator; - $this->translatableStringHelper = $translatableStringHelper; - $this->activityRepository = $activityRepository; + public function __construct(protected EntityManagerInterface $entityManager, protected TranslatorInterface $translator, protected TranslatableStringHelperInterface $translatableStringHelper, private ActivityRepository $activityRepository) + { } public function buildForm(FormBuilderInterface $builder) diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/StatActivityDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/StatActivityDuration.php index 050034954..bb8be00ff 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/StatActivityDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/StatActivityDuration.php @@ -32,22 +32,16 @@ class StatActivityDuration implements ExportInterface, GroupedExportInterface { public const SUM = 'sum'; - /** - * The action for this report. - */ - protected string $action; - - private ActivityRepository $activityRepository; - /** * @param string $action the stat to perform */ public function __construct( - ActivityRepository $activityRepository, - string $action = 'sum' + private ActivityRepository $activityRepository, + /** + * The action for this report. + */ + protected string $action = 'sum' ) { - $this->action = $action; - $this->activityRepository = $activityRepository; } public function buildForm(FormBuilderInterface $builder) diff --git a/src/Bundle/ChillActivityBundle/Export/Export/ListActivityHelper.php b/src/Bundle/ChillActivityBundle/Export/Export/ListActivityHelper.php index fae6ea6a6..5af351b28 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/ListActivityHelper.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/ListActivityHelper.php @@ -32,44 +32,8 @@ class ListActivityHelper { public const MSG_KEY = 'export.list.activity.'; - private ActivityPresenceRepositoryInterface $activityPresenceRepository; - - private ActivityTypeRepositoryInterface $activityTypeRepository; - - private DateTimeHelper $dateTimeHelper; - - private LabelPersonHelper $labelPersonHelper; - - private LabelThirdPartyHelper $labelThirdPartyHelper; - - private TranslatableStringHelperInterface $translatableStringHelper; - - private TranslatableStringExportLabelHelper $translatableStringLabelHelper; - - private TranslatorInterface $translator; - - private UserHelper $userHelper; - - public function __construct( - ActivityPresenceRepositoryInterface $activityPresenceRepository, - ActivityTypeRepositoryInterface $activityTypeRepository, - DateTimeHelper $dateTimeHelper, - LabelPersonHelper $labelPersonHelper, - LabelThirdPartyHelper $labelThirdPartyHelper, - TranslatorInterface $translator, - TranslatableStringHelperInterface $translatableStringHelper, - TranslatableStringExportLabelHelper $translatableStringLabelHelper, - UserHelper $userHelper - ) { - $this->activityPresenceRepository = $activityPresenceRepository; - $this->activityTypeRepository = $activityTypeRepository; - $this->dateTimeHelper = $dateTimeHelper; - $this->labelPersonHelper = $labelPersonHelper; - $this->labelThirdPartyHelper = $labelThirdPartyHelper; - $this->translator = $translator; - $this->translatableStringHelper = $translatableStringHelper; - $this->translatableStringLabelHelper = $translatableStringLabelHelper; - $this->userHelper = $userHelper; + public function __construct(private ActivityPresenceRepositoryInterface $activityPresenceRepository, private ActivityTypeRepositoryInterface $activityTypeRepository, private DateTimeHelper $dateTimeHelper, private LabelPersonHelper $labelPersonHelper, private LabelThirdPartyHelper $labelThirdPartyHelper, private TranslatorInterface $translator, private TranslatableStringHelperInterface $translatableStringHelper, private TranslatableStringExportLabelHelper $translatableStringLabelHelper, private UserHelper $userHelper) + { } public function addSelect(QueryBuilder $qb): void @@ -115,113 +79,79 @@ class ListActivityHelper public function getLabels($key, array $values, $data) { - switch ($key) { - case 'createdAt': - case 'updatedAt': - return $this->dateTimeHelper->getLabel($key); + return match ($key) { + 'createdAt', 'updatedAt' => $this->dateTimeHelper->getLabel($key), + 'createdBy', 'updatedBy' => $this->userHelper->getLabel($key, $values, $key), + 'date' => $this->dateTimeHelper->getLabel(self::MSG_KEY . $key), + 'attendeeName' => function ($value) { + if ('_header' === $value) { + return 'Attendee'; + } - case 'createdBy': - case 'updatedBy': - return $this->userHelper->getLabel($key, $values, $key); + if (null === $value || null === $presence = $this->activityPresenceRepository->find($value)) { + return ''; + } - case 'date': - return $this->dateTimeHelper->getLabel(self::MSG_KEY . $key); + return $this->translatableStringHelper->localize($presence->getName()); + }, + 'listReasons' => $this->translatableStringLabelHelper->getLabelMulti($key, $values, 'Activity Reasons'), + 'typeName' => function ($value) { + if ('_header' === $value) { + return 'Activity type'; + } - case 'attendeeName': - return function ($value) { - if ('_header' === $value) { - return 'Attendee'; - } + if (null === $value || null === $type = $this->activityTypeRepository->find($value)) { + return ''; + } - if (null === $value || null === $presence = $this->activityPresenceRepository->find($value)) { - return ''; - } + return $this->translatableStringHelper->localize($type->getName()); + }, + 'usersNames' => $this->userHelper->getLabelMulti($key, $values, self::MSG_KEY . 'users name'), + 'usersIds', 'thirdPartiesIds', 'personsIds' => static function ($value) use ($key) { + if ('_header' === $value) { + return match ($key) { + 'usersIds' => self::MSG_KEY . 'users ids', + 'thirdPartiesIds' => self::MSG_KEY . 'third parties ids', + 'personsIds' => self::MSG_KEY . 'persons ids', + default => throw new LogicException('key not supported'), + }; + } - return $this->translatableStringHelper->localize($presence->getName()); - }; + $decoded = json_decode($value, null, 512, JSON_THROW_ON_ERROR); - case 'listReasons': - return $this->translatableStringLabelHelper->getLabelMulti($key, $values, 'Activity Reasons'); + return implode( + '|', + array_unique( + array_filter($decoded, static fn (?int $id) => null !== $id), + SORT_NUMERIC + ) + ); + }, + 'personsNames' => $this->labelPersonHelper->getLabelMulti($key, $values, self::MSG_KEY . 'persons name'), + 'thirdPartiesNames' => $this->labelThirdPartyHelper->getLabelMulti($key, $values, self::MSG_KEY . 'thirds parties'), + 'sentReceived' => function ($value) { + if ('_header' === $value) { + return self::MSG_KEY . 'sent received'; + } - case 'typeName': - return function ($value) { - if ('_header' === $value) { - return 'Activity type'; - } + if (null === $value) { + return ''; + } - if (null === $value || null === $type = $this->activityTypeRepository->find($value)) { - return ''; - } + return $this->translator->trans($value); + }, + default => function ($value) use ($key) { + if ('_header' === $value) { + return self::MSG_KEY . $key; + } - return $this->translatableStringHelper->localize($type->getName()); - }; + if (null === $value) { + return ''; + } - case 'usersNames': - return $this->userHelper->getLabelMulti($key, $values, self::MSG_KEY . 'users name'); - - case 'usersIds': - case 'thirdPartiesIds': - case 'personsIds': - return static function ($value) use ($key) { - if ('_header' === $value) { - switch ($key) { - case 'usersIds': - return self::MSG_KEY . 'users ids'; - - case 'thirdPartiesIds': - return self::MSG_KEY . 'third parties ids'; - - case 'personsIds': - return self::MSG_KEY . 'persons ids'; - - default: - throw new LogicException('key not supported'); - } - } - - $decoded = json_decode($value, null, 512, JSON_THROW_ON_ERROR); - - return implode( - '|', - array_unique( - array_filter($decoded, static fn (?int $id) => null !== $id), - SORT_NUMERIC - ) - ); - }; - - case 'personsNames': - return $this->labelPersonHelper->getLabelMulti($key, $values, self::MSG_KEY . 'persons name'); - - case 'thirdPartiesNames': - return $this->labelThirdPartyHelper->getLabelMulti($key, $values, self::MSG_KEY . 'thirds parties'); - - case 'sentReceived': - return function ($value) { - if ('_header' === $value) { - return self::MSG_KEY . 'sent received'; - } - - if (null === $value) { - return ''; - } - - return $this->translator->trans($value); - }; - - default: - return function ($value) use ($key) { - if ('_header' === $value) { - return self::MSG_KEY . $key; - } - - if (null === $value) { - return ''; - } - - return $this->translator->trans($value); - }; - } + return $this->translator->trans($value); + }, + }; } public function getQueryKeys($data) diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php index c6616a4c6..a1f2bc786 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php @@ -23,16 +23,8 @@ use Symfony\Component\Form\FormBuilderInterface; class ActivityTypeFilter implements FilterInterface { - private ActivityTypeRepositoryInterface $activityTypeRepository; - - private TranslatableStringHelperInterface $translatableStringHelper; - - public function __construct( - ActivityTypeRepositoryInterface $activityTypeRepository, - TranslatableStringHelperInterface $translatableStringHelper - ) { - $this->activityTypeRepository = $activityTypeRepository; - $this->translatableStringHelper = $translatableStringHelper; + public function __construct(private ActivityTypeRepositoryInterface $activityTypeRepository, private TranslatableStringHelperInterface $translatableStringHelper) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ByCreatorFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ByCreatorFilter.php index 322393f32..28264c919 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ByCreatorFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ByCreatorFilter.php @@ -20,11 +20,8 @@ use Symfony\Component\Form\FormBuilderInterface; class ByCreatorFilter implements FilterInterface { - private UserRender $userRender; - - public function __construct(UserRender $userRender) + public function __construct(private UserRender $userRender) { - $this->userRender = $userRender; } public function addRole(): ?string diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialActionFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialActionFilter.php index d0c1b0fc7..89330728f 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialActionFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialActionFilter.php @@ -22,11 +22,8 @@ use function in_array; class BySocialActionFilter implements FilterInterface { - private SocialActionRender $actionRender; - - public function __construct(SocialActionRender $actionRender) + public function __construct(private SocialActionRender $actionRender) { - $this->actionRender = $actionRender; } public function addRole(): ?string diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialIssueFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialIssueFilter.php index bbb882a65..d78efbde0 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialIssueFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialIssueFilter.php @@ -22,11 +22,8 @@ use function in_array; class BySocialIssueFilter implements FilterInterface { - private SocialIssueRender $issueRender; - - public function __construct(SocialIssueRender $issueRender) + public function __construct(private SocialIssueRender $issueRender) { - $this->issueRender = $issueRender; } public function addRole(): ?string diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/EmergencyFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/EmergencyFilter.php index b79c2ca10..aff224bf3 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/EmergencyFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/EmergencyFilter.php @@ -28,11 +28,8 @@ class EmergencyFilter implements FilterInterface private const DEFAULT_CHOICE = false; - private TranslatorInterface $translator; - - public function __construct(TranslatorInterface $translator) + public function __construct(private TranslatorInterface $translator) { - $this->translator = $translator; } public function addRole(): ?string diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationTypeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationTypeFilter.php index 5fe928b6c..800381416 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationTypeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationTypeFilter.php @@ -22,11 +22,8 @@ use function in_array; class LocationTypeFilter implements FilterInterface { - private TranslatableStringHelper $translatableStringHelper; - - public function __construct(TranslatableStringHelper $translatableStringHelper) + public function __construct(private TranslatableStringHelper $translatableStringHelper) { - $this->translatableStringHelper = $translatableStringHelper; } public function addRole(): ?string diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/SentReceivedFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/SentReceivedFilter.php index 8daa7a781..b901ebde7 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/SentReceivedFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/SentReceivedFilter.php @@ -29,11 +29,8 @@ class SentReceivedFilter implements FilterInterface private const DEFAULT_CHOICE = Activity::SENTRECEIVED_SENT; - private TranslatorInterface $translator; - - public function __construct(TranslatorInterface $translator) + public function __construct(private TranslatorInterface $translator) { - $this->translator = $translator; } public function addRole(): ?string diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserFilter.php index 6350f3ace..1a5d28059 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserFilter.php @@ -21,11 +21,8 @@ use Symfony\Component\Form\FormBuilderInterface; class UserFilter implements FilterInterface { - private UserRender $userRender; - - public function __construct(UserRender $userRender) + public function __construct(private UserRender $userRender) { - $this->userRender = $userRender; } public function addRole(): ?string diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserScopeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserScopeFilter.php index 4319c100a..47445a012 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserScopeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserScopeFilter.php @@ -23,11 +23,8 @@ use function in_array; class UserScopeFilter implements FilterInterface { - private TranslatableStringHelper $translatableStringHelper; - - public function __construct(TranslatableStringHelper $translatableStringHelper) + public function __construct(private TranslatableStringHelper $translatableStringHelper) { - $this->translatableStringHelper = $translatableStringHelper; } public function addRole(): ?string diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityDateFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityDateFilter.php index f2216c929..1ea273c64 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityDateFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityDateFilter.php @@ -27,16 +27,8 @@ use Symfony\Contracts\Translation\TranslatorInterface; class ActivityDateFilter implements FilterInterface { - protected TranslatorInterface $translator; - - private RollingDateConverterInterface $rollingDateConverter; - - public function __construct( - TranslatorInterface $translator, - RollingDateConverterInterface $rollingDateConverter - ) { - $this->translator = $translator; - $this->rollingDateConverter = $rollingDateConverter; + public function __construct(protected TranslatorInterface $translator, private RollingDateConverterInterface $rollingDateConverter) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php index b9d39c3ce..ac2f421b1 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php @@ -26,16 +26,8 @@ use function count; class ActivityTypeFilter implements ExportElementValidatedInterface, FilterInterface { - protected ActivityTypeRepositoryInterface $activityTypeRepository; - - protected TranslatableStringHelperInterface $translatableStringHelper; - - public function __construct( - TranslatableStringHelperInterface $translatableStringHelper, - ActivityTypeRepositoryInterface $activityTypeRepository - ) { - $this->translatableStringHelper = $translatableStringHelper; - $this->activityTypeRepository = $activityTypeRepository; + public function __construct(protected TranslatableStringHelperInterface $translatableStringHelper, protected ActivityTypeRepositoryInterface $activityTypeRepository) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityUsersFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityUsersFilter.php index 2f6cd8462..735b66a31 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityUsersFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityUsersFilter.php @@ -20,11 +20,8 @@ use Symfony\Component\Form\FormBuilderInterface; class ActivityUsersFilter implements FilterInterface { - private UserRender $userRender; - - public function __construct(UserRender $userRender) + public function __construct(private UserRender $userRender) { - $this->userRender = $userRender; } public function addRole(): ?string diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/ActivityReasonFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/ActivityReasonFilter.php index c55d579e4..1b599f403 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/ActivityReasonFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/ActivityReasonFilter.php @@ -29,16 +29,8 @@ use function in_array; class ActivityReasonFilter implements ExportElementValidatedInterface, FilterInterface { - protected ActivityReasonRepository $activityReasonRepository; - - protected TranslatableStringHelperInterface $translatableStringHelper; - - public function __construct( - TranslatableStringHelper $helper, - ActivityReasonRepository $activityReasonRepository - ) { - $this->translatableStringHelper = $helper; - $this->activityReasonRepository = $activityReasonRepository; + public function __construct(protected TranslatableStringHelper $translatableStringHelper, protected ActivityReasonRepository $activityReasonRepository) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/PersonHavingActivityBetweenDateFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/PersonHavingActivityBetweenDateFilter.php index e3c85fe9c..043d87c3b 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/PersonHavingActivityBetweenDateFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/PersonHavingActivityBetweenDateFilter.php @@ -37,20 +37,8 @@ use function count; class PersonHavingActivityBetweenDateFilter implements ExportElementValidatedInterface, FilterInterface { - protected ActivityReasonRepository $activityReasonRepository; - - protected TranslatableStringHelperInterface $translatableStringHelper; - - protected TranslatorInterface $translator; - - public function __construct( - TranslatableStringHelper $translatableStringHelper, - ActivityReasonRepository $activityReasonRepository, - TranslatorInterface $translator - ) { - $this->translatableStringHelper = $translatableStringHelper; - $this->activityReasonRepository = $activityReasonRepository; - $this->translator = $translator; + public function __construct(protected TranslatableStringHelper $translatableStringHelper, protected ActivityReasonRepository $activityReasonRepository, protected TranslatorInterface $translator) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/UsersJobFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/UsersJobFilter.php index b52ef441c..c9e942816 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/UsersJobFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/UsersJobFilter.php @@ -22,11 +22,8 @@ use Symfony\Component\Form\FormBuilderInterface; class UsersJobFilter implements FilterInterface { - private TranslatableStringHelperInterface $translatableStringHelper; - - public function __construct(TranslatableStringHelperInterface $translatableStringHelper) + public function __construct(private TranslatableStringHelperInterface $translatableStringHelper) { - $this->translatableStringHelper = $translatableStringHelper; } public function addRole(): ?string diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/UsersScopeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/UsersScopeFilter.php index 61b12264e..f93f982aa 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/UsersScopeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/UsersScopeFilter.php @@ -23,16 +23,8 @@ use Symfony\Component\Form\FormBuilderInterface; class UsersScopeFilter implements FilterInterface { - private ScopeRepositoryInterface $scopeRepository; - - private TranslatableStringHelperInterface $translatableStringHelper; - - public function __construct( - ScopeRepositoryInterface $scopeRepository, - TranslatableStringHelperInterface $translatableStringHelper - ) { - $this->scopeRepository = $scopeRepository; - $this->translatableStringHelper = $translatableStringHelper; + public function __construct(private ScopeRepositoryInterface $scopeRepository, private TranslatableStringHelperInterface $translatableStringHelper) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityType.php b/src/Bundle/ChillActivityBundle/Form/ActivityType.php index a74178afd..780e87db9 100644 --- a/src/Bundle/ChillActivityBundle/Form/ActivityType.php +++ b/src/Bundle/ChillActivityBundle/Form/ActivityType.php @@ -58,40 +58,22 @@ use function in_array; class ActivityType extends AbstractType { - protected AuthorizationHelper $authorizationHelper; - - protected ObjectManager $om; - - protected SocialActionRender $socialActionRender; - - protected SocialIssueRender $socialIssueRender; - - protected array $timeChoices; - - protected TranslatableStringHelper $translatableStringHelper; - protected User $user; public function __construct( TokenStorageInterface $tokenStorage, - AuthorizationHelper $authorizationHelper, - ObjectManager $om, - TranslatableStringHelper $translatableStringHelper, - array $timeChoices, - SocialIssueRender $socialIssueRender, - SocialActionRender $socialActionRender + protected AuthorizationHelper $authorizationHelper, + protected ObjectManager $om, + protected TranslatableStringHelper $translatableStringHelper, + protected array $timeChoices, + protected SocialIssueRender $socialIssueRender, + protected SocialActionRender $socialActionRender ) { if (!$tokenStorage->getToken()->getUser() instanceof User) { throw new RuntimeException('you should have a valid user'); } $this->user = $tokenStorage->getToken()->getUser(); - $this->authorizationHelper = $authorizationHelper; - $this->om = $om; - $this->translatableStringHelper = $translatableStringHelper; - $this->timeChoices = $timeChoices; - $this->socialIssueRender = $socialIssueRender; - $this->socialActionRender = $socialActionRender; } public function buildForm(FormBuilderInterface $builder, array $options): void diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php b/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php index 073b8099f..6288486f7 100644 --- a/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php +++ b/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php @@ -25,11 +25,8 @@ use Symfony\Component\OptionsResolver\OptionsResolver; class ActivityTypeType extends AbstractType { - private TranslatableStringHelper $translatableStringHelper; - - public function __construct(TranslatableStringHelper $translatableStringHelper) + public function __construct(private TranslatableStringHelper $translatableStringHelper) { - $this->translatableStringHelper = $translatableStringHelper; } public function buildForm(FormBuilderInterface $builder, array $options) diff --git a/src/Bundle/ChillActivityBundle/Form/Type/PickActivityReasonType.php b/src/Bundle/ChillActivityBundle/Form/Type/PickActivityReasonType.php index 35da7e02f..4709b3010 100644 --- a/src/Bundle/ChillActivityBundle/Form/Type/PickActivityReasonType.php +++ b/src/Bundle/ChillActivityBundle/Form/Type/PickActivityReasonType.php @@ -24,20 +24,8 @@ use Symfony\Component\OptionsResolver\OptionsResolver; */ class PickActivityReasonType extends AbstractType { - private ActivityReasonRepository $activityReasonRepository; - - private ActivityReasonRender $reasonRender; - - private TranslatableStringHelperInterface $translatableStringHelper; - - public function __construct( - ActivityReasonRepository $activityReasonRepository, - ActivityReasonRender $reasonRender, - TranslatableStringHelperInterface $translatableStringHelper - ) { - $this->activityReasonRepository = $activityReasonRepository; - $this->reasonRender = $reasonRender; - $this->translatableStringHelper = $translatableStringHelper; + public function __construct(private ActivityReasonRepository $activityReasonRepository, private ActivityReasonRender $reasonRender, private TranslatableStringHelperInterface $translatableStringHelper) + { } public function configureOptions(OptionsResolver $resolver) diff --git a/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityReasonCategoryType.php b/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityReasonCategoryType.php index 4aa259097..8ccdf42c8 100644 --- a/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityReasonCategoryType.php +++ b/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityReasonCategoryType.php @@ -23,14 +23,8 @@ use Symfony\Contracts\Translation\TranslatorInterface; */ class TranslatableActivityReasonCategoryType extends AbstractType { - private TranslatableStringHelperInterface $translatableStringHelper; - - private TranslatorInterface $translator; - - public function __construct(TranslatableStringHelperInterface $translatableStringHelper, TranslatorInterface $translator) + public function __construct(private TranslatableStringHelperInterface $translatableStringHelper, private TranslatorInterface $translator) { - $this->translatableStringHelper = $translatableStringHelper; - $this->translator = $translator; } public function configureOptions(OptionsResolver $resolver) diff --git a/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityType.php b/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityType.php index d4807b82d..e2233f3b1 100644 --- a/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityType.php +++ b/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityType.php @@ -20,16 +20,8 @@ use Symfony\Component\OptionsResolver\OptionsResolver; class TranslatableActivityType extends AbstractType { - protected ActivityTypeRepositoryInterface $activityTypeRepository; - - protected TranslatableStringHelperInterface $translatableStringHelper; - - public function __construct( - TranslatableStringHelperInterface $helper, - ActivityTypeRepositoryInterface $activityTypeRepository - ) { - $this->translatableStringHelper = $helper; - $this->activityTypeRepository = $activityTypeRepository; + public function __construct(protected TranslatableStringHelperInterface $translatableStringHelper, protected ActivityTypeRepositoryInterface $activityTypeRepository) + { } public function configureOptions(OptionsResolver $resolver) diff --git a/src/Bundle/ChillActivityBundle/Menu/AccompanyingCourseMenuBuilder.php b/src/Bundle/ChillActivityBundle/Menu/AccompanyingCourseMenuBuilder.php index 9884450ec..bae2b0577 100644 --- a/src/Bundle/ChillActivityBundle/Menu/AccompanyingCourseMenuBuilder.php +++ b/src/Bundle/ChillActivityBundle/Menu/AccompanyingCourseMenuBuilder.php @@ -23,16 +23,8 @@ use Symfony\Contracts\Translation\TranslatorInterface; */ class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface { - protected Security $security; - - protected TranslatorInterface $translator; - - public function __construct( - Security $security, - TranslatorInterface $translator - ) { - $this->security = $security; - $this->translator = $translator; + public function __construct(protected Security $security, protected TranslatorInterface $translator) + { } public function buildMenu($menuId, MenuItem $menu, array $parameters) diff --git a/src/Bundle/ChillActivityBundle/Menu/AdminMenuBuilder.php b/src/Bundle/ChillActivityBundle/Menu/AdminMenuBuilder.php index 4b2d348d7..bdffafcb2 100644 --- a/src/Bundle/ChillActivityBundle/Menu/AdminMenuBuilder.php +++ b/src/Bundle/ChillActivityBundle/Menu/AdminMenuBuilder.php @@ -20,11 +20,8 @@ use Symfony\Component\Security\Core\Security; */ final class AdminMenuBuilder implements LocalMenuBuilderInterface { - private Security $security; - - public function __construct(Security $security) + public function __construct(private Security $security) { - $this->security = $security; } public function buildMenu($menuId, MenuItem $menu, array $parameters) diff --git a/src/Bundle/ChillActivityBundle/Menu/PersonMenuBuilder.php b/src/Bundle/ChillActivityBundle/Menu/PersonMenuBuilder.php index 03a1b09ab..1ad7f9042 100644 --- a/src/Bundle/ChillActivityBundle/Menu/PersonMenuBuilder.php +++ b/src/Bundle/ChillActivityBundle/Menu/PersonMenuBuilder.php @@ -23,22 +23,8 @@ use Symfony\Contracts\Translation\TranslatorInterface; */ final class PersonMenuBuilder implements LocalMenuBuilderInterface { - /** - * @var AuthorizationCheckerInterface - */ - protected $authorizationChecker; - - /** - * @var TranslatorInterface - */ - protected $translator; - - public function __construct( - AuthorizationCheckerInterface $authorizationChecker, - TranslatorInterface $translator - ) { - $this->translator = $translator; - $this->authorizationChecker = $authorizationChecker; + public function __construct(protected AuthorizationCheckerInterface $authorizationChecker, protected TranslatorInterface $translator) + { } public function buildMenu($menuId, MenuItem $menu, array $parameters) diff --git a/src/Bundle/ChillActivityBundle/Notification/ActivityNotificationHandler.php b/src/Bundle/ChillActivityBundle/Notification/ActivityNotificationHandler.php index ab26da81d..4b8566484 100644 --- a/src/Bundle/ChillActivityBundle/Notification/ActivityNotificationHandler.php +++ b/src/Bundle/ChillActivityBundle/Notification/ActivityNotificationHandler.php @@ -18,11 +18,8 @@ use Chill\MainBundle\Notification\NotificationHandlerInterface; final class ActivityNotificationHandler implements NotificationHandlerInterface { - private ActivityRepository $activityRepository; - - public function __construct(ActivityRepository $activityRepository) + public function __construct(private ActivityRepository $activityRepository) { - $this->activityRepository = $activityRepository; } public function getTemplate(Notification $notification, array $options = []): string diff --git a/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php b/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php index 1f2039a2c..c4eae39f0 100644 --- a/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php +++ b/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php @@ -35,32 +35,8 @@ use function in_array; final class ActivityACLAwareRepository implements ActivityACLAwareRepositoryInterface { - private AuthorizationHelper $authorizationHelper; - - private CenterResolverDispatcherInterface $centerResolverDispatcher; - - private EntityManagerInterface $em; - - private ActivityRepository $repository; - - private Security $security; - - private TokenStorageInterface $tokenStorage; - - public function __construct( - AuthorizationHelper $authorizationHelper, - CenterResolverDispatcherInterface $centerResolverDispatcher, - TokenStorageInterface $tokenStorage, - ActivityRepository $repository, - EntityManagerInterface $em, - Security $security - ) { - $this->authorizationHelper = $authorizationHelper; - $this->centerResolverDispatcher = $centerResolverDispatcher; - $this->tokenStorage = $tokenStorage; - $this->repository = $repository; - $this->em = $em; - $this->security = $security; + public function __construct(private AuthorizationHelper $authorizationHelper, private CenterResolverDispatcherInterface $centerResolverDispatcher, private TokenStorageInterface $tokenStorage, private ActivityRepository $repository, private EntityManagerInterface $em, private Security $security) + { } public function findByAccompanyingPeriod(AccompanyingPeriod $period, string $role, ?int $start = 0, ?int $limit = 1000, ?array $orderBy = []): array diff --git a/src/Bundle/ChillActivityBundle/Repository/ActivityReasonRepository.php b/src/Bundle/ChillActivityBundle/Repository/ActivityReasonRepository.php index c6b69319e..33c36693e 100644 --- a/src/Bundle/ChillActivityBundle/Repository/ActivityReasonRepository.php +++ b/src/Bundle/ChillActivityBundle/Repository/ActivityReasonRepository.php @@ -23,15 +23,11 @@ use Symfony\Component\HttpFoundation\RequestStack; */ class ActivityReasonRepository extends ServiceEntityRepository { - private RequestStack $requestStack; - public function __construct( ManagerRegistry $registry, - RequestStack $requestStack + private RequestStack $requestStack ) { parent::__construct($registry, ActivityReason::class); - - $this->requestStack = $requestStack; } /** diff --git a/src/Bundle/ChillActivityBundle/Security/Authorization/ActivityVoter.php b/src/Bundle/ChillActivityBundle/Security/Authorization/ActivityVoter.php index 15d2441d5..a036c9784 100644 --- a/src/Bundle/ChillActivityBundle/Security/Authorization/ActivityVoter.php +++ b/src/Bundle/ChillActivityBundle/Security/Authorization/ActivityVoter.php @@ -74,15 +74,12 @@ class ActivityVoter extends AbstractChillVoter implements ProvideRoleHierarchyIn self::FULL, ]; - protected Security $security; - protected VoterHelperInterface $voterHelper; public function __construct( - Security $security, + protected Security $security, VoterHelperFactoryInterface $voterHelperFactory ) { - $this->security = $security; $this->voterHelper = $voterHelperFactory->generate(self::class) ->addCheckFor(Person::class, [self::SEE, self::CREATE]) ->addCheckFor(AccompanyingPeriod::class, [self::SEE, self::CREATE]) diff --git a/src/Bundle/ChillActivityBundle/Service/DocGenerator/ActivityContext.php b/src/Bundle/ChillActivityBundle/Service/DocGenerator/ActivityContext.php index 624859eda..95a5a4b10 100644 --- a/src/Bundle/ChillActivityBundle/Service/DocGenerator/ActivityContext.php +++ b/src/Bundle/ChillActivityBundle/Service/DocGenerator/ActivityContext.php @@ -39,40 +39,8 @@ class ActivityContext implements DocGeneratorContextWithAdminFormInterface, DocGeneratorContextWithPublicFormInterface { - private BaseContextData $baseContextData; - - private DocumentCategoryRepository $documentCategoryRepository; - - private EntityManagerInterface $em; - - private NormalizerInterface $normalizer; - - private PersonRenderInterface $personRender; - - private PersonRepository $personRepository; - - private TranslatableStringHelperInterface $translatableStringHelper; - - private TranslatorInterface $translator; - - public function __construct( - DocumentCategoryRepository $documentCategoryRepository, - NormalizerInterface $normalizer, - TranslatableStringHelperInterface $translatableStringHelper, - EntityManagerInterface $em, - PersonRenderInterface $personRender, - PersonRepository $personRepository, - TranslatorInterface $translator, - BaseContextData $baseContextData - ) { - $this->documentCategoryRepository = $documentCategoryRepository; - $this->normalizer = $normalizer; - $this->translatableStringHelper = $translatableStringHelper; - $this->em = $em; - $this->personRender = $personRender; - $this->personRepository = $personRepository; - $this->translator = $translator; - $this->baseContextData = $baseContextData; + public function __construct(private DocumentCategoryRepository $documentCategoryRepository, private NormalizerInterface $normalizer, private TranslatableStringHelperInterface $translatableStringHelper, private EntityManagerInterface $em, private PersonRenderInterface $personRender, private PersonRepository $personRepository, private TranslatorInterface $translator, private BaseContextData $baseContextData) + { } public function adminFormReverseTransform(array $data): array diff --git a/src/Bundle/ChillActivityBundle/Service/DocGenerator/ListActivitiesByAccompanyingPeriodContext.php b/src/Bundle/ChillActivityBundle/Service/DocGenerator/ListActivitiesByAccompanyingPeriodContext.php index 3da451f2e..dc895782a 100644 --- a/src/Bundle/ChillActivityBundle/Service/DocGenerator/ListActivitiesByAccompanyingPeriodContext.php +++ b/src/Bundle/ChillActivityBundle/Service/DocGenerator/ListActivitiesByAccompanyingPeriodContext.php @@ -48,44 +48,8 @@ class ListActivitiesByAccompanyingPeriodContext implements DocGeneratorContextWithAdminFormInterface, DocGeneratorContextWithPublicFormInterface { - private AccompanyingPeriodContext $accompanyingPeriodContext; - - private ActivityACLAwareRepositoryInterface $activityACLAwareRepository; - - private NormalizerInterface $normalizer; - - private PersonRepository $personRepository; - - private SocialActionRepository $socialActionRepository; - - private SocialIssueRepository $socialIssueRepository; - - private ThirdPartyRepository $thirdPartyRepository; - - private TranslatableStringHelperInterface $translatableStringHelper; - - private UserRepository $userRepository; - - public function __construct( - AccompanyingPeriodContext $accompanyingPeriodContext, - ActivityACLAwareRepositoryInterface $activityACLAwareRepository, - NormalizerInterface $normalizer, - PersonRepository $personRepository, - SocialActionRepository $socialActionRepository, - SocialIssueRepository $socialIssueRepository, - ThirdPartyRepository $thirdPartyRepository, - TranslatableStringHelperInterface $translatableStringHelper, - UserRepository $userRepository, - ) { - $this->accompanyingPeriodContext = $accompanyingPeriodContext; - $this->activityACLAwareRepository = $activityACLAwareRepository; - $this->normalizer = $normalizer; - $this->personRepository = $personRepository; - $this->socialActionRepository = $socialActionRepository; - $this->socialIssueRepository = $socialIssueRepository; - $this->thirdPartyRepository = $thirdPartyRepository; - $this->translatableStringHelper = $translatableStringHelper; - $this->userRepository = $userRepository; + public function __construct(private AccompanyingPeriodContext $accompanyingPeriodContext, private ActivityACLAwareRepositoryInterface $activityACLAwareRepository, private NormalizerInterface $normalizer, private PersonRepository $personRepository, private SocialActionRepository $socialActionRepository, private SocialIssueRepository $socialIssueRepository, private ThirdPartyRepository $thirdPartyRepository, private TranslatableStringHelperInterface $translatableStringHelper, private UserRepository $userRepository) + { } public function adminFormReverseTransform(array $data): array diff --git a/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityControllerTest.php b/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityControllerTest.php index 04301afae..b90a5018e 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityControllerTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityControllerTest.php @@ -76,10 +76,8 @@ final class ActivityControllerTest extends WebTestCase /** * @dataProvider getSecuredPagesUnauthenticated - * - * @param mixed $url */ - public function testAccessIsDeniedForUnauthenticated($url) + public function testAccessIsDeniedForUnauthenticated(mixed $url) { $client = $this->createClient(); @@ -262,11 +260,9 @@ final class ActivityControllerTest extends WebTestCase } /** - * @param mixed $username - * * @return \Symfony\Component\BrowserKit\Client */ - private function getAuthenticatedClient($username = 'center a_social') + private function getAuthenticatedClient(mixed $username = 'center a_social') { return self::createClient([], [ 'PHP_AUTH_USER' => $username, diff --git a/src/Bundle/ChillActivityBundle/Tests/Form/Type/TranslatableActivityTypeTest.php b/src/Bundle/ChillActivityBundle/Tests/Form/Type/TranslatableActivityTypeTest.php index 770b88cf4..c87a04f9a 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Form/Type/TranslatableActivityTypeTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Form/Type/TranslatableActivityTypeTest.php @@ -89,11 +89,9 @@ final class TranslatableActivityTypeTest extends KernelTestCase } /** - * @param mixed $active - * * @return \Chill\ActivityBundle\Entity\ActivityType */ - protected function getRandomType($active = true) + protected function getRandomType(mixed $active = true) { $types = $this->container->get('doctrine.orm.entity_manager') ->getRepository(ActivityType::class) diff --git a/src/Bundle/ChillActivityBundle/Timeline/TimelineActivityProvider.php b/src/Bundle/ChillActivityBundle/Timeline/TimelineActivityProvider.php index dad597676..208b28496 100644 --- a/src/Bundle/ChillActivityBundle/Timeline/TimelineActivityProvider.php +++ b/src/Bundle/ChillActivityBundle/Timeline/TimelineActivityProvider.php @@ -33,24 +33,14 @@ class TimelineActivityProvider implements TimelineProviderInterface { private const SUPPORTED_CONTEXTS = ['center', 'person']; - protected ActivityACLAwareRepository $aclAwareRepository; - - protected EntityManagerInterface $em; - - protected AuthorizationHelperInterface $helper; - protected UserInterface $user; public function __construct( - EntityManagerInterface $em, - AuthorizationHelperInterface $helper, + protected EntityManagerInterface $em, + protected AuthorizationHelperInterface $helper, TokenStorageInterface $storage, - ActivityACLAwareRepository $aclAwareRepository + protected ActivityACLAwareRepository $aclAwareRepository ) { - $this->em = $em; - $this->helper = $helper; - $this->aclAwareRepository = $aclAwareRepository; - if (!$storage->getToken()->getUser() instanceof User) { throw new RuntimeException('A user should be authenticated !'); } diff --git a/src/Bundle/ChillAsideActivityBundle/src/Controller/AsideActivityController.php b/src/Bundle/ChillAsideActivityBundle/src/Controller/AsideActivityController.php index 8481f24eb..281585bb9 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Controller/AsideActivityController.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Controller/AsideActivityController.php @@ -21,11 +21,8 @@ use Symfony\Component\HttpFoundation\Request; final class AsideActivityController extends CRUDController { - private AsideActivityCategoryRepository $categoryRepository; - - public function __construct(AsideActivityCategoryRepository $categoryRepository) + public function __construct(private AsideActivityCategoryRepository $categoryRepository) { - $this->categoryRepository = $categoryRepository; } public function createEntity(string $action, Request $request): object diff --git a/src/Bundle/ChillAsideActivityBundle/src/DataFixtures/ORM/LoadAsideActivity.php b/src/Bundle/ChillAsideActivityBundle/src/DataFixtures/ORM/LoadAsideActivity.php index 6f6a11390..e39813009 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/DataFixtures/ORM/LoadAsideActivity.php +++ b/src/Bundle/ChillAsideActivityBundle/src/DataFixtures/ORM/LoadAsideActivity.php @@ -24,11 +24,8 @@ use function random_int; class LoadAsideActivity extends Fixture implements DependentFixtureInterface { - private UserRepository $userRepository; - - public function __construct(UserRepository $userRepository) + public function __construct(private UserRepository $userRepository) { - $this->userRepository = $userRepository; } public function getDependencies(): array diff --git a/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php b/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php index 6c12e5828..2ccab56d0 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php @@ -114,10 +114,8 @@ class AsideActivityCategory /** * @Assert\Callback - * - * @param mixed $payload */ - public function preventRecursiveParent(ExecutionContextInterface $context, $payload) + public function preventRecursiveParent(ExecutionContextInterface $context, mixed $payload) { if (!$this->hasParent()) { return; diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByActivityTypeAggregator.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByActivityTypeAggregator.php index 32418e3c3..86a1360dc 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByActivityTypeAggregator.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByActivityTypeAggregator.php @@ -20,14 +20,8 @@ use Symfony\Component\Form\FormBuilderInterface; class ByActivityTypeAggregator implements AggregatorInterface { - private AsideActivityCategoryRepository $asideActivityCategoryRepository; - - private TranslatableStringHelper $translatableStringHelper; - - public function __construct(AsideActivityCategoryRepository $asideActivityCategoryRepository, TranslatableStringHelper $translatableStringHelper) + public function __construct(private AsideActivityCategoryRepository $asideActivityCategoryRepository, private TranslatableStringHelper $translatableStringHelper) { - $this->asideActivityCategoryRepository = $asideActivityCategoryRepository; - $this->translatableStringHelper = $translatableStringHelper; } public function addRole(): ?string diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserJobAggregator.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserJobAggregator.php index d2fe7c2f2..a911ad163 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserJobAggregator.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserJobAggregator.php @@ -22,14 +22,8 @@ use function in_array; class ByUserJobAggregator implements AggregatorInterface { - private TranslatableStringHelperInterface $translatableStringHelper; - - private UserJobRepositoryInterface $userJobRepository; - - public function __construct(UserJobRepositoryInterface $userJobRepository, TranslatableStringHelperInterface $translatableStringHelper) + public function __construct(private UserJobRepositoryInterface $userJobRepository, private TranslatableStringHelperInterface $translatableStringHelper) { - $this->userJobRepository = $userJobRepository; - $this->translatableStringHelper = $translatableStringHelper; } public function addRole(): ?string diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserScopeAggregator.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserScopeAggregator.php index 6c06ee756..553e2f77b 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserScopeAggregator.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserScopeAggregator.php @@ -22,14 +22,8 @@ use function in_array; class ByUserScopeAggregator implements AggregatorInterface { - private ScopeRepositoryInterface $scopeRepository; - - private TranslatableStringHelperInterface $translatableStringHelper; - - public function __construct(ScopeRepositoryInterface $scopeRepository, TranslatableStringHelperInterface $translatableStringHelper) + public function __construct(private ScopeRepositoryInterface $scopeRepository, private TranslatableStringHelperInterface $translatableStringHelper) { - $this->scopeRepository = $scopeRepository; - $this->translatableStringHelper = $translatableStringHelper; } public function addRole(): ?string diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/AvgAsideActivityDuration.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/AvgAsideActivityDuration.php index f3db629cb..75d221b70 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/AvgAsideActivityDuration.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/AvgAsideActivityDuration.php @@ -23,12 +23,8 @@ use Symfony\Component\Form\FormBuilderInterface; class AvgAsideActivityDuration implements ExportInterface, GroupedExportInterface { - private AsideActivityRepository $repository; - - public function __construct( - AsideActivityRepository $repository - ) { - $this->repository = $repository; + public function __construct(private AsideActivityRepository $repository) + { } public function buildForm(FormBuilderInterface $builder) diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/CountAsideActivity.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/CountAsideActivity.php index 9204fad4b..e9c4932f3 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/CountAsideActivity.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/CountAsideActivity.php @@ -23,12 +23,8 @@ use Symfony\Component\Form\FormBuilderInterface; class CountAsideActivity implements ExportInterface, GroupedExportInterface { - private AsideActivityRepository $repository; - - public function __construct( - AsideActivityRepository $repository - ) { - $this->repository = $repository; + public function __construct(private AsideActivityRepository $repository) + { } public function buildForm(FormBuilderInterface $builder) diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/ListAsideActivity.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/ListAsideActivity.php index aee168174..a59962829 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/ListAsideActivity.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/ListAsideActivity.php @@ -34,40 +34,8 @@ use Symfony\Component\Form\FormBuilderInterface; final class ListAsideActivity implements ListInterface, GroupedExportInterface { - private AsideActivityCategoryRepository $asideActivityCategoryRepository; - - private CategoryRender $categoryRender; - - private CenterRepositoryInterface $centerRepository; - - private DateTimeHelper $dateTimeHelper; - - private EntityManagerInterface $em; - - private ScopeRepositoryInterface $scopeRepository; - - private TranslatableStringHelperInterface $translatableStringHelper; - - private UserHelper $userHelper; - - public function __construct( - EntityManagerInterface $em, - DateTimeHelper $dateTimeHelper, - UserHelper $userHelper, - ScopeRepositoryInterface $scopeRepository, - CenterRepositoryInterface $centerRepository, - AsideActivityCategoryRepository $asideActivityCategoryRepository, - CategoryRender $categoryRender, - TranslatableStringHelperInterface $translatableStringHelper - ) { - $this->em = $em; - $this->dateTimeHelper = $dateTimeHelper; - $this->userHelper = $userHelper; - $this->scopeRepository = $scopeRepository; - $this->centerRepository = $centerRepository; - $this->asideActivityCategoryRepository = $asideActivityCategoryRepository; - $this->categoryRender = $categoryRender; - $this->translatableStringHelper = $translatableStringHelper; + public function __construct(private EntityManagerInterface $em, private DateTimeHelper $dateTimeHelper, private UserHelper $userHelper, private ScopeRepositoryInterface $scopeRepository, private CenterRepositoryInterface $centerRepository, private AsideActivityCategoryRepository $asideActivityCategoryRepository, private CategoryRender $categoryRender, private TranslatableStringHelperInterface $translatableStringHelper) + { } public function buildForm(FormBuilderInterface $builder) @@ -91,86 +59,67 @@ final class ListAsideActivity implements ListInterface, GroupedExportInterface public function getLabels($key, array $values, $data) { - switch ($key) { - case 'id': - case 'note': - return static function ($value) use ($key) { - if ('_header' === $value) { - return 'export.aside_activity.' . $key; - } + return match ($key) { + 'id', 'note' => static function ($value) use ($key) { + if ('_header' === $value) { + return 'export.aside_activity.' . $key; + } - return $value ?? ''; - }; + return $value ?? ''; + }, + 'duration' => static function ($value) use ($key) { + if ('_header' === $value) { + return 'export.aside_activity.' . $key; + } - case 'duration': - return static function ($value) use ($key) { - if ('_header' === $value) { - return 'export.aside_activity.' . $key; - } + if (null === $value) { + return ''; + } - if (null === $value) { - return ''; - } + if ($value instanceof DateTimeInterface) { + return $value->format('H:i:s'); + } - if ($value instanceof DateTimeInterface) { - return $value->format('H:i:s'); - } + return $value; + }, + 'createdAt', 'updatedAt', 'date' => $this->dateTimeHelper->getLabel('export.aside_activity.' . $key), + 'agent_id', 'creator_id' => $this->userHelper->getLabel($key, $values, 'export.aside_activity.' . $key), + 'aside_activity_type' => function ($value) { + if ('_header' === $value) { + return 'export.aside_activity.aside_activity_type'; + } - return $value; - }; + if (null === $value || '' === $value || null === $c = $this->asideActivityCategoryRepository->find($value)) { + return ''; + } - case 'createdAt': - case 'updatedAt': - case 'date': - return $this->dateTimeHelper->getLabel('export.aside_activity.' . $key); + return $this->categoryRender->renderString($c, []); + }, + 'main_scope' => function ($value) { + if ('_header' === $value) { + return 'export.aside_activity.main_scope'; + } - case 'agent_id': - case 'creator_id': - return $this->userHelper->getLabel($key, $values, 'export.aside_activity.' . $key); + if (null === $value || '' === $value || null === $c = $this->scopeRepository->find($value)) { + return ''; + } - case 'aside_activity_type': - return function ($value) { - if ('_header' === $value) { - return 'export.aside_activity.aside_activity_type'; - } + return $this->translatableStringHelper->localize($c->getName()); + }, + 'main_center' => function ($value) { + if ('_header' === $value) { + return 'export.aside_activity.main_center'; + } - if (null === $value || '' === $value || null === $c = $this->asideActivityCategoryRepository->find($value)) { - return ''; - } + if (null === $value || '' === $value || null === $c = $this->centerRepository->find($value)) { + /** @var Center $c */ + return ''; + } - return $this->categoryRender->renderString($c, []); - }; - - case 'main_scope': - return function ($value) { - if ('_header' === $value) { - return 'export.aside_activity.main_scope'; - } - - if (null === $value || '' === $value || null === $c = $this->scopeRepository->find($value)) { - return ''; - } - - return $this->translatableStringHelper->localize($c->getName()); - }; - - case 'main_center': - return function ($value) { - if ('_header' === $value) { - return 'export.aside_activity.main_center'; - } - - if (null === $value || '' === $value || null === $c = $this->centerRepository->find($value)) { - /** @var Center $c */ - return ''; - } - - return $c->getName(); - }; - - default: - throw new LogicException('this key is not supported : ' . $key); - } + return $c->getName(); + }, + default => throw new LogicException('this key is not supported : ' . $key), + }; } public function getQueryKeys($data) diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/SumAsideActivityDuration.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/SumAsideActivityDuration.php index af17a2591..278fd7b91 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/SumAsideActivityDuration.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/SumAsideActivityDuration.php @@ -23,12 +23,8 @@ use Symfony\Component\Form\FormBuilderInterface; class SumAsideActivityDuration implements ExportInterface, GroupedExportInterface { - private AsideActivityRepository $repository; - - public function __construct( - AsideActivityRepository $repository - ) { - $this->repository = $repository; + public function __construct(private AsideActivityRepository $repository) + { } public function buildForm(FormBuilderInterface $builder) diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByActivityTypeFilter.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByActivityTypeFilter.php index 3ad8e0e93..535ee04bb 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByActivityTypeFilter.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByActivityTypeFilter.php @@ -23,20 +23,8 @@ use Symfony\Component\Form\FormBuilderInterface; class ByActivityTypeFilter implements FilterInterface { - private AsideActivityCategoryRepository $asideActivityTypeRepository; - - private CategoryRender $categoryRender; - - private TranslatableStringHelperInterface $translatableStringHelper; - - public function __construct( - CategoryRender $categoryRender, - TranslatableStringHelperInterface $translatableStringHelper, - AsideActivityCategoryRepository $asideActivityTypeRepository - ) { - $this->categoryRender = $categoryRender; - $this->asideActivityTypeRepository = $asideActivityTypeRepository; - $this->translatableStringHelper = $translatableStringHelper; + public function __construct(private CategoryRender $categoryRender, private TranslatableStringHelperInterface $translatableStringHelper, private AsideActivityCategoryRepository $asideActivityTypeRepository) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByDateFilter.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByDateFilter.php index 7a1b6f4dc..05bf46889 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByDateFilter.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByDateFilter.php @@ -26,16 +26,8 @@ use Symfony\Contracts\Translation\TranslatorInterface; class ByDateFilter implements FilterInterface { - protected TranslatorInterface $translator; - - private RollingDateConverterInterface $rollingDateConverter; - - public function __construct( - RollingDateConverterInterface $rollingDateConverter, - TranslatorInterface $translator - ) { - $this->translator = $translator; - $this->rollingDateConverter = $rollingDateConverter; + public function __construct(private RollingDateConverterInterface $rollingDateConverter, protected TranslatorInterface $translator) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserFilter.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserFilter.php index 795c813cd..809ec1250 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserFilter.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserFilter.php @@ -20,11 +20,8 @@ use Symfony\Component\Form\FormBuilderInterface; class ByUserFilter implements FilterInterface { - private UserRender $userRender; - - public function __construct(UserRender $userRender) + public function __construct(private UserRender $userRender) { - $this->userRender = $userRender; } public function addRole(): ?string diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserJobFilter.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserJobFilter.php index 86194b123..8b7b1c662 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserJobFilter.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserJobFilter.php @@ -22,11 +22,8 @@ use Symfony\Component\Form\FormBuilderInterface; class ByUserJobFilter implements FilterInterface { - private TranslatableStringHelperInterface $translatableStringHelper; - - public function __construct(TranslatableStringHelperInterface $translatableStringHelper) + public function __construct(private TranslatableStringHelperInterface $translatableStringHelper) { - $this->translatableStringHelper = $translatableStringHelper; } public function addRole(): ?string diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserScopeFilter.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserScopeFilter.php index 4342e11eb..b7b7edfe4 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserScopeFilter.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserScopeFilter.php @@ -23,16 +23,8 @@ use Symfony\Component\Form\FormBuilderInterface; class ByUserScopeFilter implements FilterInterface { - private ScopeRepositoryInterface $scopeRepository; - - private TranslatableStringHelperInterface $translatableStringHelper; - - public function __construct( - ScopeRepositoryInterface $scopeRepository, - TranslatableStringHelperInterface $translatableStringHelper - ) { - $this->scopeRepository = $scopeRepository; - $this->translatableStringHelper = $translatableStringHelper; + public function __construct(private ScopeRepositoryInterface $scopeRepository, private TranslatableStringHelperInterface $translatableStringHelper) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityCategoryType.php b/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityCategoryType.php index c183fcea6..584c528e4 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityCategoryType.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityCategoryType.php @@ -22,12 +22,8 @@ use Symfony\Component\Form\FormBuilderInterface; final class AsideActivityCategoryType extends AbstractType { - private CategoryRender $categoryRender; - - public function __construct( - CategoryRender $categoryRender - ) { - $this->categoryRender = $categoryRender; + public function __construct(private CategoryRender $categoryRender) + { } public function buildForm(FormBuilderInterface $builder, array $options) diff --git a/src/Bundle/ChillAsideActivityBundle/src/Form/Type/PickAsideActivityCategoryType.php b/src/Bundle/ChillAsideActivityBundle/src/Form/Type/PickAsideActivityCategoryType.php index 3ee392517..63f6372d8 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Form/Type/PickAsideActivityCategoryType.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Form/Type/PickAsideActivityCategoryType.php @@ -20,12 +20,8 @@ use Symfony\Component\OptionsResolver\OptionsResolver; final class PickAsideActivityCategoryType extends AbstractType { - private CategoryRender $categoryRender; - - public function __construct( - CategoryRender $categoryRender - ) { - $this->categoryRender = $categoryRender; + public function __construct(private CategoryRender $categoryRender) + { } public function configureOptions(OptionsResolver $resolver) diff --git a/src/Bundle/ChillAsideActivityBundle/src/Menu/AdminMenuBuilder.php b/src/Bundle/ChillAsideActivityBundle/src/Menu/AdminMenuBuilder.php index 8cc076a6e..dcf5c6720 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Menu/AdminMenuBuilder.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Menu/AdminMenuBuilder.php @@ -16,11 +16,8 @@ use Symfony\Component\Security\Core\Security; final class AdminMenuBuilder implements \Chill\MainBundle\Routing\LocalMenuBuilderInterface { - private Security $security; - - public function __construct(Security $security) + public function __construct(private Security $security) { - $this->security = $security; } public function buildMenu($menuId, MenuItem $menu, array $parameters) diff --git a/src/Bundle/ChillAsideActivityBundle/src/Menu/SectionMenuBuilder.php b/src/Bundle/ChillAsideActivityBundle/src/Menu/SectionMenuBuilder.php index f23fcdc8a..15547c665 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Menu/SectionMenuBuilder.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Menu/SectionMenuBuilder.php @@ -21,14 +21,8 @@ use Symfony\Contracts\Translation\TranslatorInterface; */ class SectionMenuBuilder implements LocalMenuBuilderInterface { - public AuthorizationCheckerInterface $authorizationChecker; - - protected TranslatorInterface $translator; - - public function __construct(TranslatorInterface $translator, AuthorizationCheckerInterface $authorizationChecker) + public function __construct(protected TranslatorInterface $translator, public AuthorizationCheckerInterface $authorizationChecker) { - $this->translator = $translator; - $this->authorizationChecker = $authorizationChecker; } /** diff --git a/src/Bundle/ChillAsideActivityBundle/src/Templating/Entity/CategoryRender.php b/src/Bundle/ChillAsideActivityBundle/src/Templating/Entity/CategoryRender.php index 066a0ca52..f4a7c4977 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Templating/Entity/CategoryRender.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Templating/Entity/CategoryRender.php @@ -27,14 +27,8 @@ final class CategoryRender implements ChillEntityRenderInterface public const SEPERATOR_KEY = 'default.separator'; - private EngineInterface $engine; - - private TranslatableStringHelper $translatableStringHelper; - - public function __construct(TranslatableStringHelper $translatableStringHelper, EngineInterface $engine) + public function __construct(private TranslatableStringHelper $translatableStringHelper, private EngineInterface $engine) { - $this->translatableStringHelper = $translatableStringHelper; - $this->engine = $engine; } public function buildParents(AsideActivityCategory $asideActivityCategory) diff --git a/src/Bundle/ChillBudgetBundle/Controller/AbstractElementController.php b/src/Bundle/ChillBudgetBundle/Controller/AbstractElementController.php index 125c72ce4..3192cc14a 100644 --- a/src/Bundle/ChillBudgetBundle/Controller/AbstractElementController.php +++ b/src/Bundle/ChillBudgetBundle/Controller/AbstractElementController.php @@ -27,20 +27,8 @@ use function get_class; abstract class AbstractElementController extends AbstractController { - protected LoggerInterface $chillMainLogger; - - protected EntityManagerInterface $em; - - protected TranslatorInterface $translator; - - public function __construct( - EntityManagerInterface $em, - TranslatorInterface $translator, - LoggerInterface $chillMainLogger - ) { - $this->em = $em; - $this->translator = $translator; - $this->chillMainLogger = $chillMainLogger; + public function __construct(protected EntityManagerInterface $em, protected TranslatorInterface $translator, protected LoggerInterface $chillMainLogger) + { } /** @@ -48,11 +36,8 @@ abstract class AbstractElementController extends AbstractController * "{_locale}/family-members/family-members/{id}/delete", * name="chill_family_members_family_members_delete" * ). - * - * @param mixed $template - * @param mixed $flashMessage */ - protected function _delete(AbstractElement $element, Request $request, $template, $flashMessage): Response + protected function _delete(AbstractElement $element, Request $request, mixed $template, mixed $flashMessage): Response { $this->denyAccessUnlessGranted(BudgetElementVoter::DELETE, $element, 'You are not ' . 'allowed to delete this item'); @@ -72,7 +57,7 @@ abstract class AbstractElementController extends AbstractController if ($form->isValid()) { $this->chillMainLogger->notice('A budget element has been removed', [ - 'family_element' => get_class($element), + 'family_element' => $element::class, 'by_user' => $this->getUser()->getUsername(), 'family_member_id' => $element->getId(), 'amount' => $element->getAmount(), @@ -141,12 +126,7 @@ abstract class AbstractElementController extends AbstractController ]); } - /** - * @param mixed $template - * @param mixed $flashMessageOnSuccess - * @param mixed $entity - */ - protected function _new($entity, Request $request, $template, $flashMessageOnSuccess) + protected function _new(mixed $entity, Request $request, mixed $template, mixed $flashMessageOnSuccess) { /** @var AbstractElement $element */ $element = $this->createNewElement(); @@ -196,10 +176,8 @@ abstract class AbstractElementController extends AbstractController * "{_locale}/family-members/family-members/{id}/view", * name="chill_family_members_family_members_view" * ). - * - * @param mixed $template */ - protected function _view(AbstractElement $element, $template) + protected function _view(AbstractElement $element, mixed $template) { $this->denyAccessUnlessGranted(BudgetElementVoter::SEE, $element); diff --git a/src/Bundle/ChillBudgetBundle/Controller/ElementController.php b/src/Bundle/ChillBudgetBundle/Controller/ElementController.php index b5db3cd30..20f05a8ca 100644 --- a/src/Bundle/ChillBudgetBundle/Controller/ElementController.php +++ b/src/Bundle/ChillBudgetBundle/Controller/ElementController.php @@ -31,20 +31,8 @@ use function count; class ElementController extends AbstractController { - private CalculatorManager $calculator; - - private ResourceRepository $resourceRepository; - - private ChargeRepository $chargeRepository; - - public function __construct( - CalculatorManager $calculator, - ResourceRepository $resourceRepository, - ChargeRepository $chargeRepository, - ) { - $this->calculator = $calculator; - $this->resourceRepository = $resourceRepository; - $this->chargeRepository = $chargeRepository; + public function __construct(private CalculatorManager $calculator, private ResourceRepository $resourceRepository, private ChargeRepository $chargeRepository) + { } /** diff --git a/src/Bundle/ChillBudgetBundle/Form/ChargeType.php b/src/Bundle/ChillBudgetBundle/Form/ChargeType.php index 72863163f..778866cb3 100644 --- a/src/Bundle/ChillBudgetBundle/Form/ChargeType.php +++ b/src/Bundle/ChillBudgetBundle/Form/ChargeType.php @@ -27,20 +27,8 @@ use Symfony\Contracts\Translation\TranslatorInterface; class ChargeType extends AbstractType { - protected TranslatableStringHelperInterface $translatableStringHelper; - - private ChargeKindRepository $repository; - - private TranslatorInterface $translator; - - public function __construct( - TranslatableStringHelperInterface $translatableStringHelper, - ChargeKindRepository $repository, - TranslatorInterface $translator - ) { - $this->translatableStringHelper = $translatableStringHelper; - $this->repository = $repository; - $this->translator = $translator; + public function __construct(protected TranslatableStringHelperInterface $translatableStringHelper, private ChargeKindRepository $repository, private TranslatorInterface $translator) + { } public function buildForm(FormBuilderInterface $builder, array $options) diff --git a/src/Bundle/ChillBudgetBundle/Form/ResourceType.php b/src/Bundle/ChillBudgetBundle/Form/ResourceType.php index 09dfd16f3..c98301597 100644 --- a/src/Bundle/ChillBudgetBundle/Form/ResourceType.php +++ b/src/Bundle/ChillBudgetBundle/Form/ResourceType.php @@ -26,20 +26,8 @@ use Symfony\Contracts\Translation\TranslatorInterface; class ResourceType extends AbstractType { - protected TranslatableStringHelperInterface $translatableStringHelper; - - private ResourceKindRepository $repository; - - private TranslatorInterface $translator; - - public function __construct( - TranslatableStringHelperInterface $translatableStringHelper, - ResourceKindRepository $repository, - TranslatorInterface $translator - ) { - $this->translatableStringHelper = $translatableStringHelper; - $this->repository = $repository; - $this->translator = $translator; + public function __construct(protected TranslatableStringHelperInterface $translatableStringHelper, private ResourceKindRepository $repository, private TranslatorInterface $translator) + { } public function buildForm(FormBuilderInterface $builder, array $options) diff --git a/src/Bundle/ChillBudgetBundle/Menu/AdminMenuBuilder.php b/src/Bundle/ChillBudgetBundle/Menu/AdminMenuBuilder.php index 894230ad9..787980862 100644 --- a/src/Bundle/ChillBudgetBundle/Menu/AdminMenuBuilder.php +++ b/src/Bundle/ChillBudgetBundle/Menu/AdminMenuBuilder.php @@ -17,11 +17,8 @@ use Symfony\Component\Security\Core\Security; final class AdminMenuBuilder implements LocalMenuBuilderInterface { - private Security $security; - - public function __construct(Security $security) + public function __construct(private Security $security) { - $this->security = $security; } public function buildMenu($menuId, MenuItem $menu, array $parameters) diff --git a/src/Bundle/ChillBudgetBundle/Menu/HouseholdMenuBuilder.php b/src/Bundle/ChillBudgetBundle/Menu/HouseholdMenuBuilder.php index 1224c0bfe..c5d19262d 100644 --- a/src/Bundle/ChillBudgetBundle/Menu/HouseholdMenuBuilder.php +++ b/src/Bundle/ChillBudgetBundle/Menu/HouseholdMenuBuilder.php @@ -20,16 +20,8 @@ use Symfony\Contracts\Translation\TranslatorInterface; class HouseholdMenuBuilder implements LocalMenuBuilderInterface { - protected AuthorizationCheckerInterface $authorizationChecker; - - protected TranslatorInterface $translator; - - public function __construct( - AuthorizationCheckerInterface $authorizationChecker, - TranslatorInterface $translator - ) { - $this->authorizationChecker = $authorizationChecker; - $this->translator = $translator; + public function __construct(protected AuthorizationCheckerInterface $authorizationChecker, protected TranslatorInterface $translator) + { } public function buildMenu($menuId, MenuItem $menu, array $parameters) diff --git a/src/Bundle/ChillBudgetBundle/Menu/PersonMenuBuilder.php b/src/Bundle/ChillBudgetBundle/Menu/PersonMenuBuilder.php index 7322af849..97b10c72b 100644 --- a/src/Bundle/ChillBudgetBundle/Menu/PersonMenuBuilder.php +++ b/src/Bundle/ChillBudgetBundle/Menu/PersonMenuBuilder.php @@ -20,16 +20,8 @@ use Symfony\Contracts\Translation\TranslatorInterface; class PersonMenuBuilder implements LocalMenuBuilderInterface { - protected AuthorizationCheckerInterface $authorizationChecker; - - protected TranslatorInterface $translator; - - public function __construct( - AuthorizationCheckerInterface $authorizationChecker, - TranslatorInterface $translator - ) { - $this->authorizationChecker = $authorizationChecker; - $this->translator = $translator; + public function __construct(protected AuthorizationCheckerInterface $authorizationChecker, protected TranslatorInterface $translator) + { } public function buildMenu($menuId, MenuItem $menu, array $parameters) diff --git a/src/Bundle/ChillBudgetBundle/Service/Summary/SummaryBudget.php b/src/Bundle/ChillBudgetBundle/Service/Summary/SummaryBudget.php index 1c66d4c1c..17e80bd63 100644 --- a/src/Bundle/ChillBudgetBundle/Service/Summary/SummaryBudget.php +++ b/src/Bundle/ChillBudgetBundle/Service/Summary/SummaryBudget.php @@ -37,24 +37,8 @@ final class SummaryBudget implements SummaryBudgetInterface private const QUERY_RESOURCE_BY_PERSON = 'select SUM(amount) AS sum, string_agg(comment, \'|\') AS comment, resource_id AS kind_id FROM chill_budget.resource WHERE person_id = ? AND NOW() BETWEEN startdate AND COALESCE(enddate, \'infinity\'::timestamp) GROUP BY resource_id'; - private ChargeKindRepositoryInterface $chargeKindRepository; - - private EntityManagerInterface $em; - - private ResourceKindRepositoryInterface $resourceKindRepository; - - private TranslatableStringHelperInterface $translatableStringHelper; - - public function __construct( - EntityManagerInterface $em, - TranslatableStringHelperInterface $translatableStringHelper, - ResourceKindRepositoryInterface $resourceKindRepository, - ChargeKindRepositoryInterface $chargeKindRepository - ) { - $this->em = $em; - $this->translatableStringHelper = $translatableStringHelper; - $this->resourceKindRepository = $resourceKindRepository; - $this->chargeKindRepository = $chargeKindRepository; + public function __construct(private EntityManagerInterface $em, private TranslatableStringHelperInterface $translatableStringHelper, private ResourceKindRepositoryInterface $resourceKindRepository, private ChargeKindRepositoryInterface $chargeKindRepository) + { } public function getSummaryForHousehold(?Household $household): array diff --git a/src/Bundle/ChillBudgetBundle/Templating/BudgetElementTypeRender.php b/src/Bundle/ChillBudgetBundle/Templating/BudgetElementTypeRender.php index 842e6be4e..336d69c66 100644 --- a/src/Bundle/ChillBudgetBundle/Templating/BudgetElementTypeRender.php +++ b/src/Bundle/ChillBudgetBundle/Templating/BudgetElementTypeRender.php @@ -22,14 +22,8 @@ use Symfony\Component\Templating\EngineInterface; */ final class BudgetElementTypeRender implements ChillEntityRenderInterface { - private EngineInterface $engine; - - private TranslatableStringHelperInterface $translatableStringHelper; - - public function __construct(TranslatableStringHelperInterface $translatableStringHelper, EngineInterface $engine) + public function __construct(private TranslatableStringHelperInterface $translatableStringHelper, private EngineInterface $engine) { - $this->translatableStringHelper = $translatableStringHelper; - $this->engine = $engine; } public function renderBox($entity, array $options): string diff --git a/src/Bundle/ChillBudgetBundle/Tests/Service/Summary/SummaryBudgetTest.php b/src/Bundle/ChillBudgetBundle/Tests/Service/Summary/SummaryBudgetTest.php index 77017abc5..4190341d0 100644 --- a/src/Bundle/ChillBudgetBundle/Tests/Service/Summary/SummaryBudgetTest.php +++ b/src/Bundle/ChillBudgetBundle/Tests/Service/Summary/SummaryBudgetTest.php @@ -66,11 +66,11 @@ final class SummaryBudgetTest extends TestCase $em = $this->prophesize(EntityManagerInterface::class); $em->createNativeQuery(Argument::type('string'), Argument::type(Query\ResultSetMapping::class)) ->will(static function ($args) use ($queryResources, $queryCharges) { - if (false !== strpos($args[0], 'chill_budget.resource')) { + if (str_contains($args[0], 'chill_budget.resource')) { return $queryResources->reveal(); } - if (false !== strpos($args[0], 'chill_budget.charge')) { + if (str_contains($args[0], 'chill_budget.charge')) { return $queryCharges->reveal(); } diff --git a/src/Bundle/ChillCalendarBundle/Command/AzureGrantAdminConsentAndAcquireToken.php b/src/Bundle/ChillCalendarBundle/Command/AzureGrantAdminConsentAndAcquireToken.php index 400619990..d71439314 100644 --- a/src/Bundle/ChillCalendarBundle/Command/AzureGrantAdminConsentAndAcquireToken.php +++ b/src/Bundle/ChillCalendarBundle/Command/AzureGrantAdminConsentAndAcquireToken.php @@ -29,19 +29,9 @@ use TheNetworg\OAuth2\Client\Provider\Azure; class AzureGrantAdminConsentAndAcquireToken extends Command { - private Azure $azure; - - private ClientRegistry $clientRegistry; - - private MachineTokenStorage $machineTokenStorage; - - public function __construct(Azure $azure, ClientRegistry $clientRegistry, MachineTokenStorage $machineTokenStorage) + public function __construct(private Azure $azure, private ClientRegistry $clientRegistry, private MachineTokenStorage $machineTokenStorage) { parent::__construct('chill:calendar:msgraph-grant-admin-consent'); - - $this->azure = $azure; - $this->clientRegistry = $clientRegistry; - $this->machineTokenStorage = $machineTokenStorage; } protected function execute(InputInterface $input, OutputInterface $output) diff --git a/src/Bundle/ChillCalendarBundle/Command/MapAndSubscribeUserCalendarCommand.php b/src/Bundle/ChillCalendarBundle/Command/MapAndSubscribeUserCalendarCommand.php index b90fb83d4..48b9242fd 100644 --- a/src/Bundle/ChillCalendarBundle/Command/MapAndSubscribeUserCalendarCommand.php +++ b/src/Bundle/ChillCalendarBundle/Command/MapAndSubscribeUserCalendarCommand.php @@ -32,30 +32,14 @@ use Symfony\Component\Console\Output\OutputInterface; class MapAndSubscribeUserCalendarCommand extends Command { - private EntityManagerInterface $em; - - private EventsOnUserSubscriptionCreator $eventsOnUserSubscriptionCreator; - - private LoggerInterface $logger; - - private MapCalendarToUser $mapCalendarToUser; - - private MSGraphUserRepository $userRepository; - public function __construct( - EntityManagerInterface $em, - EventsOnUserSubscriptionCreator $eventsOnUserSubscriptionCreator, - LoggerInterface $logger, - MapCalendarToUser $mapCalendarToUser, - MSGraphUserRepository $userRepository + private EntityManagerInterface $em, + private EventsOnUserSubscriptionCreator $eventsOnUserSubscriptionCreator, + private LoggerInterface $logger, + private MapCalendarToUser $mapCalendarToUser, + private MSGraphUserRepository $userRepository ) { parent::__construct('chill:calendar:msgraph-user-map-subscribe'); - - $this->em = $em; - $this->eventsOnUserSubscriptionCreator = $eventsOnUserSubscriptionCreator; - $this->logger = $logger; - $this->mapCalendarToUser = $mapCalendarToUser; - $this->userRepository = $userRepository; } public function execute(InputInterface $input, OutputInterface $output): int diff --git a/src/Bundle/ChillCalendarBundle/Command/SendShortMessageOnEligibleCalendar.php b/src/Bundle/ChillCalendarBundle/Command/SendShortMessageOnEligibleCalendar.php index 6625a7adb..de5f43102 100644 --- a/src/Bundle/ChillCalendarBundle/Command/SendShortMessageOnEligibleCalendar.php +++ b/src/Bundle/ChillCalendarBundle/Command/SendShortMessageOnEligibleCalendar.php @@ -25,13 +25,9 @@ use Symfony\Component\Console\Output\OutputInterface; class SendShortMessageOnEligibleCalendar extends Command { - private BulkCalendarShortMessageSender $messageSender; - - public function __construct(BulkCalendarShortMessageSender $messageSender) + public function __construct(private BulkCalendarShortMessageSender $messageSender) { parent::__construct(); - - $this->messageSender = $messageSender; } public function getName() diff --git a/src/Bundle/ChillCalendarBundle/Command/SendTestShortMessageOnCalendarCommand.php b/src/Bundle/ChillCalendarBundle/Command/SendTestShortMessageOnCalendarCommand.php index 5891a7be8..882277c91 100644 --- a/src/Bundle/ChillCalendarBundle/Command/SendTestShortMessageOnCalendarCommand.php +++ b/src/Bundle/ChillCalendarBundle/Command/SendTestShortMessageOnCalendarCommand.php @@ -43,34 +43,15 @@ use function count; class SendTestShortMessageOnCalendarCommand extends Command { - private ShortMessageForCalendarBuilderInterface $messageForCalendarBuilder; - - private PersonRepository $personRepository; - - private PhoneNumberHelperInterface $phoneNumberHelper; - - private PhoneNumberUtil $phoneNumberUtil; - - private ShortMessageTransporterInterface $transporter; - - private UserRepositoryInterface $userRepository; - public function __construct( - PersonRepository $personRepository, - PhoneNumberUtil $phoneNumberUtil, - PhoneNumberHelperInterface $phoneNumberHelper, - ShortMessageForCalendarBuilderInterface $messageForCalendarBuilder, - ShortMessageTransporterInterface $transporter, - UserRepositoryInterface $userRepository + private PersonRepository $personRepository, + private PhoneNumberUtil $phoneNumberUtil, + private PhoneNumberHelperInterface $phoneNumberHelper, + private ShortMessageForCalendarBuilderInterface $messageForCalendarBuilder, + private ShortMessageTransporterInterface $transporter, + private UserRepositoryInterface $userRepository ) { parent::__construct(); - - $this->personRepository = $personRepository; - $this->phoneNumberUtil = $phoneNumberUtil; - $this->phoneNumberHelper = $phoneNumberHelper; - $this->messageForCalendarBuilder = $messageForCalendarBuilder; - $this->transporter = $transporter; - $this->userRepository = $userRepository; } public function getName() diff --git a/src/Bundle/ChillCalendarBundle/Controller/CalendarAPIController.php b/src/Bundle/ChillCalendarBundle/Controller/CalendarAPIController.php index 8e0e8099c..b426dabd8 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/CalendarAPIController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/CalendarAPIController.php @@ -24,11 +24,8 @@ use Symfony\Component\Routing\Annotation\Route; class CalendarAPIController extends ApiController { - private CalendarRepository $calendarRepository; - - public function __construct(CalendarRepository $calendarRepository) + public function __construct(private CalendarRepository $calendarRepository) { - $this->calendarRepository = $calendarRepository; } /** diff --git a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php index eed693451..34481facb 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php @@ -49,56 +49,8 @@ use Symfony\Contracts\Translation\TranslatorInterface; class CalendarController extends AbstractController { - private AccompanyingPeriodRepository $accompanyingPeriodRepository; - - private CalendarACLAwareRepositoryInterface $calendarACLAwareRepository; - - private DocGeneratorTemplateRepository $docGeneratorTemplateRepository; - - private FilterOrderHelperFactoryInterface $filterOrderHelperFactory; - - private LoggerInterface $logger; - - private PaginatorFactory $paginator; - - private PersonRepository $personRepository; - - private RemoteCalendarConnectorInterface $remoteCalendarConnector; - - private SerializerInterface $serializer; - - private TranslatableStringHelperInterface $translatableStringHelper; - - private TranslatorInterface $translator; - - private UserRepositoryInterface $userRepository; - - public function __construct( - CalendarACLAwareRepositoryInterface $calendarACLAwareRepository, - DocGeneratorTemplateRepository $docGeneratorTemplateRepository, - FilterOrderHelperFactoryInterface $filterOrderHelperFactory, - LoggerInterface $logger, - PaginatorFactory $paginator, - RemoteCalendarConnectorInterface $remoteCalendarConnector, - SerializerInterface $serializer, - TranslatableStringHelperInterface $translatableStringHelper, - PersonRepository $personRepository, - AccompanyingPeriodRepository $accompanyingPeriodRepository, - UserRepositoryInterface $userRepository, - TranslatorInterface $translator - ) { - $this->calendarACLAwareRepository = $calendarACLAwareRepository; - $this->docGeneratorTemplateRepository = $docGeneratorTemplateRepository; - $this->filterOrderHelperFactory = $filterOrderHelperFactory; - $this->logger = $logger; - $this->paginator = $paginator; - $this->remoteCalendarConnector = $remoteCalendarConnector; - $this->serializer = $serializer; - $this->translatableStringHelper = $translatableStringHelper; - $this->personRepository = $personRepository; - $this->accompanyingPeriodRepository = $accompanyingPeriodRepository; - $this->userRepository = $userRepository; - $this->translator = $translator; + public function __construct(private CalendarACLAwareRepositoryInterface $calendarACLAwareRepository, private DocGeneratorTemplateRepository $docGeneratorTemplateRepository, private FilterOrderHelperFactoryInterface $filterOrderHelperFactory, private LoggerInterface $logger, private PaginatorFactory $paginator, private RemoteCalendarConnectorInterface $remoteCalendarConnector, private SerializerInterface $serializer, private TranslatableStringHelperInterface $translatableStringHelper, private PersonRepository $personRepository, private AccompanyingPeriodRepository $accompanyingPeriodRepository, private UserRepositoryInterface $userRepository, private TranslatorInterface $translator) + { } /** diff --git a/src/Bundle/ChillCalendarBundle/Controller/CalendarDocController.php b/src/Bundle/ChillCalendarBundle/Controller/CalendarDocController.php index d02e55f32..16d1c942c 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/CalendarDocController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/CalendarDocController.php @@ -33,34 +33,10 @@ use UnexpectedValueException; class CalendarDocController { - private DocGeneratorTemplateRepository $docGeneratorTemplateRepository; - - private EngineInterface $engine; - - private EntityManagerInterface $entityManager; - - private FormFactoryInterface $formFactory; - - private Security $security; - private SerializerInterface $serializer; - private UrlGeneratorInterface $urlGenerator; - - public function __construct( - DocGeneratorTemplateRepository $docGeneratorTemplateRepository, - EngineInterface $engine, - EntityManagerInterface $entityManager, - FormFactoryInterface $formFactory, - Security $security, - UrlGeneratorInterface $urlGenerator - ) { - $this->docGeneratorTemplateRepository = $docGeneratorTemplateRepository; - $this->engine = $engine; - $this->entityManager = $entityManager; - $this->formFactory = $formFactory; - $this->security = $security; - $this->urlGenerator = $urlGenerator; + public function __construct(private DocGeneratorTemplateRepository $docGeneratorTemplateRepository, private EngineInterface $engine, private EntityManagerInterface $entityManager, private FormFactoryInterface $formFactory, private Security $security, private UrlGeneratorInterface $urlGenerator) + { } /** diff --git a/src/Bundle/ChillCalendarBundle/Controller/CalendarRangeAPIController.php b/src/Bundle/ChillCalendarBundle/Controller/CalendarRangeAPIController.php index 383e24efc..1b967a9ee 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/CalendarRangeAPIController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/CalendarRangeAPIController.php @@ -25,11 +25,8 @@ use Symfony\Component\Routing\Annotation\Route; class CalendarRangeAPIController extends ApiController { - private CalendarRangeRepository $calendarRangeRepository; - - public function __construct(CalendarRangeRepository $calendarRangeRepository) + public function __construct(private CalendarRangeRepository $calendarRangeRepository) { - $this->calendarRangeRepository = $calendarRangeRepository; } /** diff --git a/src/Bundle/ChillCalendarBundle/Controller/InviteApiController.php b/src/Bundle/ChillCalendarBundle/Controller/InviteApiController.php index 3016e1660..6e4930cdb 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/InviteApiController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/InviteApiController.php @@ -35,17 +35,8 @@ use function in_array; class InviteApiController { - private EntityManagerInterface $entityManager; - - private MessageBusInterface $messageBus; - - private Security $security; - - public function __construct(EntityManagerInterface $entityManager, MessageBusInterface $messageBus, Security $security) + public function __construct(private EntityManagerInterface $entityManager, private MessageBusInterface $messageBus, private Security $security) { - $this->entityManager = $entityManager; - $this->messageBus = $messageBus; - $this->security = $security; } /** diff --git a/src/Bundle/ChillCalendarBundle/Controller/RemoteCalendarConnectAzureController.php b/src/Bundle/ChillCalendarBundle/Controller/RemoteCalendarConnectAzureController.php index 9352e42fa..d10b5d41a 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/RemoteCalendarConnectAzureController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/RemoteCalendarConnectAzureController.php @@ -30,16 +30,8 @@ use TheNetworg\OAuth2\Client\Token\AccessToken; class RemoteCalendarConnectAzureController { - private ClientRegistry $clientRegistry; - - private OnBehalfOfUserTokenStorage $MSGraphTokenStorage; - - public function __construct( - ClientRegistry $clientRegistry, - OnBehalfOfUserTokenStorage $MSGraphTokenStorage - ) { - $this->clientRegistry = $clientRegistry; - $this->MSGraphTokenStorage = $MSGraphTokenStorage; + public function __construct(private ClientRegistry $clientRegistry, private OnBehalfOfUserTokenStorage $MSGraphTokenStorage) + { } /** diff --git a/src/Bundle/ChillCalendarBundle/Controller/RemoteCalendarMSGraphSyncController.php b/src/Bundle/ChillCalendarBundle/Controller/RemoteCalendarMSGraphSyncController.php index 535dda2f5..33e549b37 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/RemoteCalendarMSGraphSyncController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/RemoteCalendarMSGraphSyncController.php @@ -29,11 +29,8 @@ use const JSON_THROW_ON_ERROR; class RemoteCalendarMSGraphSyncController { - private MessageBusInterface $messageBus; - - public function __construct(MessageBusInterface $messageBus) + public function __construct(private MessageBusInterface $messageBus) { - $this->messageBus = $messageBus; } /** diff --git a/src/Bundle/ChillCalendarBundle/Controller/RemoteCalendarProxyController.php b/src/Bundle/ChillCalendarBundle/Controller/RemoteCalendarProxyController.php index a95aa1a3f..a2143922f 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/RemoteCalendarProxyController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/RemoteCalendarProxyController.php @@ -36,17 +36,8 @@ use function count; */ class RemoteCalendarProxyController { - private PaginatorFactory $paginatorFactory; - - private RemoteCalendarConnectorInterface $remoteCalendarConnector; - - private SerializerInterface $serializer; - - public function __construct(PaginatorFactory $paginatorFactory, RemoteCalendarConnectorInterface $remoteCalendarConnector, SerializerInterface $serializer) + public function __construct(private PaginatorFactory $paginatorFactory, private RemoteCalendarConnectorInterface $remoteCalendarConnector, private SerializerInterface $serializer) { - $this->paginatorFactory = $paginatorFactory; - $this->remoteCalendarConnector = $remoteCalendarConnector; - $this->serializer = $serializer; } /** diff --git a/src/Bundle/ChillCalendarBundle/DataFixtures/ORM/LoadCalendarRange.php b/src/Bundle/ChillCalendarBundle/DataFixtures/ORM/LoadCalendarRange.php index 805386669..493a97dec 100644 --- a/src/Bundle/ChillCalendarBundle/DataFixtures/ORM/LoadCalendarRange.php +++ b/src/Bundle/ChillCalendarBundle/DataFixtures/ORM/LoadCalendarRange.php @@ -29,12 +29,8 @@ class LoadCalendarRange extends Fixture implements FixtureGroupInterface, Ordere { public static array $references = []; - private UserRepository $userRepository; - - public function __construct( - UserRepository $userRepository - ) { - $this->userRepository = $userRepository; + public function __construct(private UserRepository $userRepository) + { } public static function getGroups(): array diff --git a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php index 79219a6e0..dc98c47d9 100644 --- a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php +++ b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php @@ -317,16 +317,11 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente public function getCenters(): ?iterable { - switch ($this->getContext()) { - case 'person': - return [$this->getPerson()->getCenter()]; - - case 'accompanying_period': - return $this->getAccompanyingPeriod()->getCenters(); - - default: - throw new LogicException('context not supported: ' . $this->getContext()); - } + return match ($this->getContext()) { + 'person' => [$this->getPerson()->getCenter()], + 'accompanying_period' => $this->getAccompanyingPeriod()->getCenters(), + default => throw new LogicException('context not supported: ' . $this->getContext()), + }; } public function getComment(): CommentEmbeddable diff --git a/src/Bundle/ChillCalendarBundle/Entity/CalendarDoc.php b/src/Bundle/ChillCalendarBundle/Entity/CalendarDoc.php index 7012b64e0..763488560 100644 --- a/src/Bundle/ChillCalendarBundle/Entity/CalendarDoc.php +++ b/src/Bundle/ChillCalendarBundle/Entity/CalendarDoc.php @@ -50,22 +50,18 @@ class CalendarDoc implements TrackCreationInterface, TrackUpdateInterface */ private ?int $id = null; - /** - * @ORM\ManyToOne(targetEntity=StoredObject::class, cascade={"persist"}) - * @ORM\JoinColumn(nullable=false) - */ - private ?StoredObject $storedObject; - /** * @ORM\Column(type="boolean", nullable=false, options={"default": false}) */ private bool $trackDateTimeVersion = false; - public function __construct(Calendar $calendar, ?StoredObject $storedObject) + public function __construct(Calendar $calendar, /** + * @ORM\ManyToOne(targetEntity=StoredObject::class, cascade={"persist"}) + * @ORM\JoinColumn(nullable=false) + */ + private ?\Chill\DocStoreBundle\Entity\StoredObject $storedObject) { $this->setCalendar($calendar); - - $this->storedObject = $storedObject; $this->datetimeVersion = $calendar->getDateTimeVersion(); } diff --git a/src/Bundle/ChillCalendarBundle/Event/ListenToActivityCreate.php b/src/Bundle/ChillCalendarBundle/Event/ListenToActivityCreate.php index 298a1ef9a..b781615ef 100644 --- a/src/Bundle/ChillCalendarBundle/Event/ListenToActivityCreate.php +++ b/src/Bundle/ChillCalendarBundle/Event/ListenToActivityCreate.php @@ -19,11 +19,8 @@ use function array_key_exists; class ListenToActivityCreate { - private RequestStack $requestStack; - - public function __construct(RequestStack $requestStack) + public function __construct(private RequestStack $requestStack) { - $this->requestStack = $requestStack; } public function postPersist(Activity $activity, LifecycleEventArgs $event): void diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/AgentAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/AgentAggregator.php index e1de9f399..bc76dc021 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/AgentAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/AgentAggregator.php @@ -22,16 +22,8 @@ use function in_array; final class AgentAggregator implements AggregatorInterface { - private UserRender $userRender; - - private UserRepository $userRepository; - - public function __construct( - UserRepository $userRepository, - UserRender $userRender - ) { - $this->userRepository = $userRepository; - $this->userRender = $userRender; + public function __construct(private UserRepository $userRepository, private UserRender $userRender) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/CancelReasonAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/CancelReasonAggregator.php index 611cb6d79..051150378 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/CancelReasonAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/CancelReasonAggregator.php @@ -22,16 +22,8 @@ use function in_array; class CancelReasonAggregator implements AggregatorInterface { - private CancelReasonRepository $cancelReasonRepository; - - private TranslatableStringHelper $translatableStringHelper; - - public function __construct( - CancelReasonRepository $cancelReasonRepository, - TranslatableStringHelper $translatableStringHelper - ) { - $this->cancelReasonRepository = $cancelReasonRepository; - $this->translatableStringHelper = $translatableStringHelper; + public function __construct(private CancelReasonRepository $cancelReasonRepository, private TranslatableStringHelper $translatableStringHelper) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/JobAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/JobAggregator.php index 23292a5b0..dbda0ad61 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/JobAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/JobAggregator.php @@ -22,16 +22,8 @@ use function in_array; final class JobAggregator implements AggregatorInterface { - private UserJobRepository $jobRepository; - - private TranslatableStringHelper $translatableStringHelper; - - public function __construct( - UserJobRepository $jobRepository, - TranslatableStringHelper $translatableStringHelper - ) { - $this->jobRepository = $jobRepository; - $this->translatableStringHelper = $translatableStringHelper; + public function __construct(private UserJobRepository $jobRepository, private TranslatableStringHelper $translatableStringHelper) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationAggregator.php index 940000f47..954175935 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationAggregator.php @@ -21,12 +21,8 @@ use function in_array; final class LocationAggregator implements AggregatorInterface { - private LocationRepository $locationRepository; - - public function __construct( - LocationRepository $locationRepository - ) { - $this->locationRepository = $locationRepository; + public function __construct(private LocationRepository $locationRepository) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationTypeAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationTypeAggregator.php index 6574e3934..489bda8cb 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationTypeAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationTypeAggregator.php @@ -22,16 +22,8 @@ use function in_array; final class LocationTypeAggregator implements AggregatorInterface { - private LocationTypeRepository $locationTypeRepository; - - private TranslatableStringHelper $translatableStringHelper; - - public function __construct( - LocationTypeRepository $locationTypeRepository, - TranslatableStringHelper $translatableStringHelper - ) { - $this->locationTypeRepository = $locationTypeRepository; - $this->translatableStringHelper = $translatableStringHelper; + public function __construct(private LocationTypeRepository $locationTypeRepository, private TranslatableStringHelper $translatableStringHelper) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/ScopeAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/ScopeAggregator.php index 3aff3e0d8..6f72648e0 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/ScopeAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/ScopeAggregator.php @@ -22,16 +22,8 @@ use function in_array; final class ScopeAggregator implements AggregatorInterface { - private ScopeRepository $scopeRepository; - - private TranslatableStringHelper $translatableStringHelper; - - public function __construct( - ScopeRepository $scopeRepository, - TranslatableStringHelper $translatableStringHelper - ) { - $this->scopeRepository = $scopeRepository; - $this->translatableStringHelper = $translatableStringHelper; + public function __construct(private ScopeRepository $scopeRepository, private TranslatableStringHelper $translatableStringHelper) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/UrgencyAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/UrgencyAggregator.php index ad5910461..c7b03a146 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/UrgencyAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/UrgencyAggregator.php @@ -28,12 +28,8 @@ use Symfony\Contracts\Translation\TranslatorInterface; class UrgencyAggregator implements AggregatorInterface { - private TranslatorInterface $translator; - - public function __construct( - TranslatorInterface $translator - ) { - $this->translator = $translator; + public function __construct(private TranslatorInterface $translator) + { } public function addRole(): ?string @@ -64,16 +60,11 @@ class UrgencyAggregator implements AggregatorInterface return 'Urgency'; } - switch ($value) { - case true: - return $this->translator->trans('is urgent'); - - case false: - return $this->translator->trans('is not urgent'); - - default: - throw new LogicException(sprintf('The value %s is not valid', $value)); - } + return match ($value) { + true => $this->translator->trans('is urgent'), + false => $this->translator->trans('is not urgent'), + default => throw new LogicException(sprintf('The value %s is not valid', $value)), + }; }; } diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php b/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php index 9d3f00f99..50367ece7 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php @@ -25,11 +25,8 @@ use Symfony\Component\Validator\Exception\LogicException; class CountCalendars implements ExportInterface, GroupedExportInterface { - private CalendarRepository $calendarRepository; - - public function __construct(CalendarRepository $calendarRepository) + public function __construct(private CalendarRepository $calendarRepository) { - $this->calendarRepository = $calendarRepository; } public function buildForm(FormBuilderInterface $builder) diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php index 14dd42d6b..68ab4fdd3 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php @@ -24,12 +24,8 @@ use Symfony\Component\Form\FormBuilderInterface; class StatCalendarAvgDuration implements ExportInterface, GroupedExportInterface { - private CalendarRepository $calendarRepository; - - public function __construct( - CalendarRepository $calendarRepository - ) { - $this->calendarRepository = $calendarRepository; + public function __construct(private CalendarRepository $calendarRepository) + { } public function buildForm(FormBuilderInterface $builder): void diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php index 1d31bfa26..fe94cc4e0 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php @@ -24,12 +24,8 @@ use Symfony\Component\Form\FormBuilderInterface; class StatCalendarSumDuration implements ExportInterface, GroupedExportInterface { - private CalendarRepository $calendarRepository; - - public function __construct( - CalendarRepository $calendarRepository - ) { - $this->calendarRepository = $calendarRepository; + public function __construct(private CalendarRepository $calendarRepository) + { } public function buildForm(FormBuilderInterface $builder): void diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php index b58cee594..6ae9d8236 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php @@ -22,11 +22,8 @@ use Symfony\Component\Form\FormBuilderInterface; class AgentFilter implements FilterInterface { - private UserRender $userRender; - - public function __construct(UserRender $userRender) + public function __construct(private UserRender $userRender) { - $this->userRender = $userRender; } public function addRole(): ?string diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/BetweenDatesFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/BetweenDatesFilter.php index 59019ac03..9a316208c 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/BetweenDatesFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/BetweenDatesFilter.php @@ -21,11 +21,8 @@ use Symfony\Component\Form\FormBuilderInterface; class BetweenDatesFilter implements FilterInterface { - private RollingDateConverterInterface $rollingDateConverter; - - public function __construct(RollingDateConverterInterface $rollingDateConverter) + public function __construct(private RollingDateConverterInterface $rollingDateConverter) { - $this->rollingDateConverter = $rollingDateConverter; } public function addRole(): ?string diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/CalendarRangeFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/CalendarRangeFilter.php index d6c38e163..6795457d9 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/CalendarRangeFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/CalendarRangeFilter.php @@ -35,11 +35,8 @@ class CalendarRangeFilter implements FilterInterface private const DEFAULT_CHOICE = false; - private TranslatorInterface $translator; - - public function __construct(TranslatorInterface $translator) + public function __construct(private TranslatorInterface $translator) { - $this->translator = $translator; } public function addRole(): ?string diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php index 69fb24447..47482c732 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php @@ -24,16 +24,8 @@ use function in_array; class JobFilter implements FilterInterface { - protected TranslatorInterface $translator; - - private TranslatableStringHelper $translatableStringHelper; - - public function __construct( - TranslatorInterface $translator, - TranslatableStringHelper $translatableStringHelper - ) { - $this->translator = $translator; - $this->translatableStringHelper = $translatableStringHelper; + public function __construct(protected TranslatorInterface $translator, private TranslatableStringHelper $translatableStringHelper) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php index 08d9ae023..80cbdec37 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php @@ -24,16 +24,8 @@ use function in_array; class ScopeFilter implements FilterInterface { - protected TranslatorInterface $translator; - - private TranslatableStringHelper $translatableStringHelper; - - public function __construct( - TranslatorInterface $translator, - TranslatableStringHelper $translatableStringHelper - ) { - $this->translator = $translator; - $this->translatableStringHelper = $translatableStringHelper; + public function __construct(protected TranslatorInterface $translator, private TranslatableStringHelper $translatableStringHelper) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillCalendarBundle/Form/CalendarType.php b/src/Bundle/ChillCalendarBundle/Form/CalendarType.php index a2d15484f..e54517ef3 100644 --- a/src/Bundle/ChillCalendarBundle/Form/CalendarType.php +++ b/src/Bundle/ChillCalendarBundle/Form/CalendarType.php @@ -32,32 +32,8 @@ use Symfony\Component\OptionsResolver\OptionsResolver; class CalendarType extends AbstractType { - private IdToCalendarRangeDataTransformer $calendarRangeDataTransformer; - - private IdToLocationDataTransformer $idToLocationDataTransformer; - - private IdToUserDataTransformer $idToUserDataTransformer; - - private IdToUsersDataTransformer $idToUsersDataTransformer; - - private ThirdPartiesToIdDataTransformer $partiesToIdDataTransformer; - - private PersonsToIdDataTransformer $personsToIdDataTransformer; - - public function __construct( - PersonsToIdDataTransformer $personsToIdDataTransformer, - IdToUserDataTransformer $idToUserDataTransformer, - IdToUsersDataTransformer $idToUsersDataTransformer, - IdToLocationDataTransformer $idToLocationDataTransformer, - ThirdPartiesToIdDataTransformer $partiesToIdDataTransformer, - IdToCalendarRangeDataTransformer $idToCalendarRangeDataTransformer - ) { - $this->personsToIdDataTransformer = $personsToIdDataTransformer; - $this->idToUserDataTransformer = $idToUserDataTransformer; - $this->idToUsersDataTransformer = $idToUsersDataTransformer; - $this->idToLocationDataTransformer = $idToLocationDataTransformer; - $this->partiesToIdDataTransformer = $partiesToIdDataTransformer; - $this->calendarRangeDataTransformer = $idToCalendarRangeDataTransformer; + public function __construct(private PersonsToIdDataTransformer $personsToIdDataTransformer, private IdToUserDataTransformer $idToUserDataTransformer, private IdToUsersDataTransformer $idToUsersDataTransformer, private IdToLocationDataTransformer $idToLocationDataTransformer, private ThirdPartiesToIdDataTransformer $partiesToIdDataTransformer, private IdToCalendarRangeDataTransformer $calendarRangeDataTransformer) + { } public function buildForm(FormBuilderInterface $builder, array $options) diff --git a/src/Bundle/ChillCalendarBundle/Menu/AccompanyingCourseMenuBuilder.php b/src/Bundle/ChillCalendarBundle/Menu/AccompanyingCourseMenuBuilder.php index 4b9dca19f..a81fbdedd 100644 --- a/src/Bundle/ChillCalendarBundle/Menu/AccompanyingCourseMenuBuilder.php +++ b/src/Bundle/ChillCalendarBundle/Menu/AccompanyingCourseMenuBuilder.php @@ -19,16 +19,8 @@ use Symfony\Contracts\Translation\TranslatorInterface; class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface { - protected TranslatorInterface $translator; - - private Security $security; - - public function __construct( - Security $security, - TranslatorInterface $translator - ) { - $this->security = $security; - $this->translator = $translator; + public function __construct(private Security $security, protected TranslatorInterface $translator) + { } public function buildMenu($menuId, MenuItem $menu, array $parameters) diff --git a/src/Bundle/ChillCalendarBundle/Menu/PersonMenuBuilder.php b/src/Bundle/ChillCalendarBundle/Menu/PersonMenuBuilder.php index eccbe1ffb..fb1a60a7b 100644 --- a/src/Bundle/ChillCalendarBundle/Menu/PersonMenuBuilder.php +++ b/src/Bundle/ChillCalendarBundle/Menu/PersonMenuBuilder.php @@ -19,16 +19,8 @@ use Symfony\Contracts\Translation\TranslatorInterface; class PersonMenuBuilder implements LocalMenuBuilderInterface { - protected TranslatorInterface $translator; - - private Security $security; - - public function __construct( - Security $security, - TranslatorInterface $translator - ) { - $this->security = $security; - $this->translator = $translator; + public function __construct(private Security $security, protected TranslatorInterface $translator) + { } public function buildMenu($menuId, MenuItem $menu, array $parameters) diff --git a/src/Bundle/ChillCalendarBundle/Menu/UserMenuBuilder.php b/src/Bundle/ChillCalendarBundle/Menu/UserMenuBuilder.php index 525039910..f8c804519 100644 --- a/src/Bundle/ChillCalendarBundle/Menu/UserMenuBuilder.php +++ b/src/Bundle/ChillCalendarBundle/Menu/UserMenuBuilder.php @@ -18,16 +18,8 @@ use Symfony\Contracts\Translation\TranslatorInterface; class UserMenuBuilder implements LocalMenuBuilderInterface { - public TranslatorInterface $translator; - - private Security $security; - - public function __construct( - Security $security, - TranslatorInterface $translator - ) { - $this->security = $security; - $this->translator = $translator; + public function __construct(private Security $security, public TranslatorInterface $translator) + { } public function buildMenu($menuId, MenuItem $menu, array $parameters) diff --git a/src/Bundle/ChillCalendarBundle/Messenger/Doctrine/CalendarEntityListener.php b/src/Bundle/ChillCalendarBundle/Messenger/Doctrine/CalendarEntityListener.php index f97cbc7b2..d940cbeca 100644 --- a/src/Bundle/ChillCalendarBundle/Messenger/Doctrine/CalendarEntityListener.php +++ b/src/Bundle/ChillCalendarBundle/Messenger/Doctrine/CalendarEntityListener.php @@ -30,14 +30,8 @@ use Symfony\Component\Security\Core\Security; class CalendarEntityListener { - private MessageBusInterface $messageBus; - - private Security $security; - - public function __construct(MessageBusInterface $messageBus, Security $security) + public function __construct(private MessageBusInterface $messageBus, private Security $security) { - $this->messageBus = $messageBus; - $this->security = $security; } public function postPersist(Calendar $calendar, PostPersistEventArgs $args): void diff --git a/src/Bundle/ChillCalendarBundle/Messenger/Doctrine/CalendarRangeEntityListener.php b/src/Bundle/ChillCalendarBundle/Messenger/Doctrine/CalendarRangeEntityListener.php index 4df548277..cb3d9a763 100644 --- a/src/Bundle/ChillCalendarBundle/Messenger/Doctrine/CalendarRangeEntityListener.php +++ b/src/Bundle/ChillCalendarBundle/Messenger/Doctrine/CalendarRangeEntityListener.php @@ -30,14 +30,8 @@ use Symfony\Component\Security\Core\Security; class CalendarRangeEntityListener { - private MessageBusInterface $messageBus; - - private Security $security; - - public function __construct(MessageBusInterface $messageBus, Security $security) + public function __construct(private MessageBusInterface $messageBus, private Security $security) { - $this->messageBus = $messageBus; - $this->security = $security; } public function postPersist(CalendarRange $calendarRange, PostPersistEventArgs $eventArgs): void diff --git a/src/Bundle/ChillCalendarBundle/Messenger/Handler/CalendarRangeRemoveToRemoteHandler.php b/src/Bundle/ChillCalendarBundle/Messenger/Handler/CalendarRangeRemoveToRemoteHandler.php index 4e3ae5891..b814d4cb8 100644 --- a/src/Bundle/ChillCalendarBundle/Messenger/Handler/CalendarRangeRemoveToRemoteHandler.php +++ b/src/Bundle/ChillCalendarBundle/Messenger/Handler/CalendarRangeRemoveToRemoteHandler.php @@ -31,14 +31,8 @@ use Symfony\Component\Messenger\Handler\MessageHandlerInterface; */ class CalendarRangeRemoveToRemoteHandler implements MessageHandlerInterface { - private RemoteCalendarConnectorInterface $remoteCalendarConnector; - - private UserRepository $userRepository; - - public function __construct(RemoteCalendarConnectorInterface $remoteCalendarConnector, UserRepository $userRepository) + public function __construct(private RemoteCalendarConnectorInterface $remoteCalendarConnector, private UserRepository $userRepository) { - $this->remoteCalendarConnector = $remoteCalendarConnector; - $this->userRepository = $userRepository; } public function __invoke(CalendarRangeRemovedMessage $calendarRangeRemovedMessage) diff --git a/src/Bundle/ChillCalendarBundle/Messenger/Handler/CalendarRangeToRemoteHandler.php b/src/Bundle/ChillCalendarBundle/Messenger/Handler/CalendarRangeToRemoteHandler.php index 79bcd24ee..b94ab6d9d 100644 --- a/src/Bundle/ChillCalendarBundle/Messenger/Handler/CalendarRangeToRemoteHandler.php +++ b/src/Bundle/ChillCalendarBundle/Messenger/Handler/CalendarRangeToRemoteHandler.php @@ -32,20 +32,8 @@ use Symfony\Component\Messenger\Handler\MessageHandlerInterface; */ class CalendarRangeToRemoteHandler implements MessageHandlerInterface { - private CalendarRangeRepository $calendarRangeRepository; - - private EntityManagerInterface $entityManager; - - private RemoteCalendarConnectorInterface $remoteCalendarConnector; - - public function __construct( - CalendarRangeRepository $calendarRangeRepository, - RemoteCalendarConnectorInterface $remoteCalendarConnector, - EntityManagerInterface $entityManager - ) { - $this->calendarRangeRepository = $calendarRangeRepository; - $this->remoteCalendarConnector = $remoteCalendarConnector; - $this->entityManager = $entityManager; + public function __construct(private CalendarRangeRepository $calendarRangeRepository, private RemoteCalendarConnectorInterface $remoteCalendarConnector, private EntityManagerInterface $entityManager) + { } public function __invoke(CalendarRangeMessage $calendarRangeMessage): void diff --git a/src/Bundle/ChillCalendarBundle/Messenger/Handler/CalendarRemoveHandler.php b/src/Bundle/ChillCalendarBundle/Messenger/Handler/CalendarRemoveHandler.php index f087766ec..ccc8d0a06 100644 --- a/src/Bundle/ChillCalendarBundle/Messenger/Handler/CalendarRemoveHandler.php +++ b/src/Bundle/ChillCalendarBundle/Messenger/Handler/CalendarRemoveHandler.php @@ -31,17 +31,8 @@ use Symfony\Component\Messenger\Handler\MessageHandlerInterface; */ class CalendarRemoveHandler implements MessageHandlerInterface { - private CalendarRangeRepository $calendarRangeRepository; - - private RemoteCalendarConnectorInterface $remoteCalendarConnector; - - private UserRepositoryInterface $userRepository; - - public function __construct(RemoteCalendarConnectorInterface $remoteCalendarConnector, CalendarRangeRepository $calendarRangeRepository, UserRepositoryInterface $userRepository) + public function __construct(private RemoteCalendarConnectorInterface $remoteCalendarConnector, private CalendarRangeRepository $calendarRangeRepository, private UserRepositoryInterface $userRepository) { - $this->remoteCalendarConnector = $remoteCalendarConnector; - $this->calendarRangeRepository = $calendarRangeRepository; - $this->userRepository = $userRepository; } public function __invoke(CalendarRemovedMessage $message) diff --git a/src/Bundle/ChillCalendarBundle/Messenger/Handler/CalendarToRemoteHandler.php b/src/Bundle/ChillCalendarBundle/Messenger/Handler/CalendarToRemoteHandler.php index eabdf9063..2698921fc 100644 --- a/src/Bundle/ChillCalendarBundle/Messenger/Handler/CalendarToRemoteHandler.php +++ b/src/Bundle/ChillCalendarBundle/Messenger/Handler/CalendarToRemoteHandler.php @@ -37,32 +37,8 @@ use Symfony\Component\Messenger\Handler\MessageHandlerInterface; */ class CalendarToRemoteHandler implements MessageHandlerInterface { - private RemoteCalendarConnectorInterface $calendarConnector; - - private CalendarRangeRepository $calendarRangeRepository; - - private CalendarRepository $calendarRepository; - - private EntityManagerInterface $entityManager; - - private InviteRepository $inviteRepository; - - private UserRepository $userRepository; - - public function __construct( - CalendarRangeRepository $calendarRangeRepository, - CalendarRepository $calendarRepository, - EntityManagerInterface $entityManager, - InviteRepository $inviteRepository, - RemoteCalendarConnectorInterface $calendarConnector, - UserRepository $userRepository - ) { - $this->calendarConnector = $calendarConnector; - $this->calendarRepository = $calendarRepository; - $this->calendarRangeRepository = $calendarRangeRepository; - $this->entityManager = $entityManager; - $this->userRepository = $userRepository; - $this->inviteRepository = $inviteRepository; + public function __construct(private CalendarRangeRepository $calendarRangeRepository, private CalendarRepository $calendarRepository, private EntityManagerInterface $entityManager, private InviteRepository $inviteRepository, private RemoteCalendarConnectorInterface $calendarConnector, private UserRepository $userRepository) + { } public function __invoke(CalendarMessage $calendarMessage) diff --git a/src/Bundle/ChillCalendarBundle/Messenger/Handler/InviteUpdateHandler.php b/src/Bundle/ChillCalendarBundle/Messenger/Handler/InviteUpdateHandler.php index e1df3ac3d..b917a13ae 100644 --- a/src/Bundle/ChillCalendarBundle/Messenger/Handler/InviteUpdateHandler.php +++ b/src/Bundle/ChillCalendarBundle/Messenger/Handler/InviteUpdateHandler.php @@ -31,17 +31,8 @@ use Symfony\Component\Messenger\Handler\MessageHandlerInterface; */ class InviteUpdateHandler implements MessageHandlerInterface { - private EntityManagerInterface $em; - - private InviteRepository $inviteRepository; - - private RemoteCalendarConnectorInterface $remoteCalendarConnector; - - public function __construct(EntityManagerInterface $em, InviteRepository $inviteRepository, RemoteCalendarConnectorInterface $remoteCalendarConnector) + public function __construct(private EntityManagerInterface $em, private InviteRepository $inviteRepository, private RemoteCalendarConnectorInterface $remoteCalendarConnector) { - $this->em = $em; - $this->inviteRepository = $inviteRepository; - $this->remoteCalendarConnector = $remoteCalendarConnector; } public function __invoke(InviteUpdateMessage $inviteUpdateMessage): void diff --git a/src/Bundle/ChillCalendarBundle/Messenger/Handler/MSGraphChangeNotificationHandler.php b/src/Bundle/ChillCalendarBundle/Messenger/Handler/MSGraphChangeNotificationHandler.php index a09c70c1e..f6debd2d5 100644 --- a/src/Bundle/ChillCalendarBundle/Messenger/Handler/MSGraphChangeNotificationHandler.php +++ b/src/Bundle/ChillCalendarBundle/Messenger/Handler/MSGraphChangeNotificationHandler.php @@ -36,40 +36,8 @@ use Symfony\Component\Messenger\Handler\MessageHandlerInterface; */ class MSGraphChangeNotificationHandler implements MessageHandlerInterface { - private CalendarRangeRepository $calendarRangeRepository; - - private CalendarRangeSyncer $calendarRangeSyncer; - - private CalendarRepository $calendarRepository; - - private CalendarSyncer $calendarSyncer; - - private EntityManagerInterface $em; - - private LoggerInterface $logger; - - private MapCalendarToUser $mapCalendarToUser; - - private UserRepository $userRepository; - - public function __construct( - CalendarRangeRepository $calendarRangeRepository, - CalendarRangeSyncer $calendarRangeSyncer, - CalendarRepository $calendarRepository, - CalendarSyncer $calendarSyncer, - EntityManagerInterface $em, - LoggerInterface $logger, - MapCalendarToUser $mapCalendarToUser, - UserRepository $userRepository - ) { - $this->calendarRangeRepository = $calendarRangeRepository; - $this->calendarRangeSyncer = $calendarRangeSyncer; - $this->calendarRepository = $calendarRepository; - $this->calendarSyncer = $calendarSyncer; - $this->em = $em; - $this->logger = $logger; - $this->mapCalendarToUser = $mapCalendarToUser; - $this->userRepository = $userRepository; + public function __construct(private CalendarRangeRepository $calendarRangeRepository, private CalendarRangeSyncer $calendarRangeSyncer, private CalendarRepository $calendarRepository, private CalendarSyncer $calendarSyncer, private EntityManagerInterface $em, private LoggerInterface $logger, private MapCalendarToUser $mapCalendarToUser, private UserRepository $userRepository) + { } public function __invoke(MSGraphChangeNotificationMessage $changeNotificationMessage): void diff --git a/src/Bundle/ChillCalendarBundle/Messenger/Message/CalendarMessage.php b/src/Bundle/ChillCalendarBundle/Messenger/Message/CalendarMessage.php index c8a8f8aeb..53b20e49e 100644 --- a/src/Bundle/ChillCalendarBundle/Messenger/Message/CalendarMessage.php +++ b/src/Bundle/ChillCalendarBundle/Messenger/Message/CalendarMessage.php @@ -28,8 +28,6 @@ class CalendarMessage public const CALENDAR_UPDATE = 'CHILL_CALENDAR_CALENDAR_UPDATE'; - private string $action; - private int $byUserId; private int $calendarId; @@ -47,12 +45,11 @@ class CalendarMessage public function __construct( Calendar $calendar, - string $action, + private string $action, User $byUser ) { $this->calendarId = $calendar->getId(); $this->byUserId = $byUser->getId(); - $this->action = $action; $this->previousCalendarRangeId = null !== $calendar->previousCalendarRange ? $calendar->previousCalendarRange->getId() : null; $this->previousMainUserId = null !== $calendar->previousMainUser ? diff --git a/src/Bundle/ChillCalendarBundle/Messenger/Message/CalendarRangeMessage.php b/src/Bundle/ChillCalendarBundle/Messenger/Message/CalendarRangeMessage.php index 526826ff8..61d006a79 100644 --- a/src/Bundle/ChillCalendarBundle/Messenger/Message/CalendarRangeMessage.php +++ b/src/Bundle/ChillCalendarBundle/Messenger/Message/CalendarRangeMessage.php @@ -27,15 +27,12 @@ class CalendarRangeMessage public const CALENDAR_RANGE_UPDATE = 'CHILL_CALENDAR_CALENDAR_RANGE_UPDATE'; - private string $action; - private ?int $byUserId = null; private int $calendarRangeId; - public function __construct(CalendarRange $calendarRange, string $action, ?User $byUser) + public function __construct(CalendarRange $calendarRange, private string $action, ?User $byUser) { - $this->action = $action; $this->calendarRangeId = $calendarRange->getId(); if (null !== $byUser) { diff --git a/src/Bundle/ChillCalendarBundle/Messenger/Message/MSGraphChangeNotificationMessage.php b/src/Bundle/ChillCalendarBundle/Messenger/Message/MSGraphChangeNotificationMessage.php index f1d3b6b04..8288787cb 100644 --- a/src/Bundle/ChillCalendarBundle/Messenger/Message/MSGraphChangeNotificationMessage.php +++ b/src/Bundle/ChillCalendarBundle/Messenger/Message/MSGraphChangeNotificationMessage.php @@ -20,14 +20,8 @@ namespace Chill\CalendarBundle\Messenger\Message; class MSGraphChangeNotificationMessage { - private array $content; - - private int $userId; - - public function __construct(array $content, int $userId) + public function __construct(private array $content, private int $userId) { - $this->content = $content; - $this->userId = $userId; } public function getContent(): array diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/AddressConverter.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/AddressConverter.php index 8b86ba0ec..05f116c6b 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/AddressConverter.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/AddressConverter.php @@ -24,14 +24,8 @@ use Chill\MainBundle\Templating\TranslatableStringHelperInterface; class AddressConverter { - private AddressRender $addressRender; - - private TranslatableStringHelperInterface $translatableStringHelper; - - public function __construct(AddressRender $addressRender, TranslatableStringHelperInterface $translatableStringHelper) + public function __construct(private AddressRender $addressRender, private TranslatableStringHelperInterface $translatableStringHelper) { - $this->addressRender = $addressRender; - $this->translatableStringHelper = $translatableStringHelper; } public function addressToRemote(Address $address): array diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/EventsOnUserSubscriptionCreator.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/EventsOnUserSubscriptionCreator.php index c400b6694..3bbe22161 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/EventsOnUserSubscriptionCreator.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/EventsOnUserSubscriptionCreator.php @@ -30,24 +30,8 @@ use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface; */ class EventsOnUserSubscriptionCreator { - private LoggerInterface $logger; - - private MachineHttpClient $machineHttpClient; - - private MapCalendarToUser $mapCalendarToUser; - - private UrlGeneratorInterface $urlGenerator; - - public function __construct( - LoggerInterface $logger, - MachineHttpClient $machineHttpClient, - MapCalendarToUser $mapCalendarToUser, - UrlGeneratorInterface $urlGenerator - ) { - $this->logger = $logger; - $this->machineHttpClient = $machineHttpClient; - $this->mapCalendarToUser = $mapCalendarToUser; - $this->urlGenerator = $urlGenerator; + public function __construct(private LoggerInterface $logger, private MachineHttpClient $machineHttpClient, private MapCalendarToUser $mapCalendarToUser, private UrlGeneratorInterface $urlGenerator) + { } /** diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/LocationConverter.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/LocationConverter.php index 396dfd931..5de500b52 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/LocationConverter.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/LocationConverter.php @@ -22,11 +22,8 @@ use Chill\MainBundle\Entity\Location; class LocationConverter { - private AddressConverter $addressConverter; - - public function __construct(AddressConverter $addressConverter) + public function __construct(private AddressConverter $addressConverter) { - $this->addressConverter = $addressConverter; } public function locationToRemote(Location $location): array diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MSGraphUserRepository.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MSGraphUserRepository.php index c523a1e92..39fbf6c15 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MSGraphUserRepository.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MSGraphUserRepository.php @@ -42,11 +42,8 @@ class MSGraphUserRepository ; SQL; - private EntityManagerInterface $entityManager; - - public function __construct(EntityManagerInterface $entityManager) + public function __construct(private EntityManagerInterface $entityManager) { - $this->entityManager = $entityManager; } public function countByMostOldSubscriptionOrWithoutSubscriptionOrData(DateInterval $interval): int diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MachineHttpClient.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MachineHttpClient.php index cc1692fb7..8a3f37678 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MachineHttpClient.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MachineHttpClient.php @@ -30,15 +30,12 @@ class MachineHttpClient implements HttpClientInterface private HttpClientInterface $decoratedClient; - private MachineTokenStorage $machineTokenStorage; - /** * @param HttpClientInterface $decoratedClient */ - public function __construct(MachineTokenStorage $machineTokenStorage, ?HttpClientInterface $decoratedClient = null) + public function __construct(private MachineTokenStorage $machineTokenStorage, ?HttpClientInterface $decoratedClient = null) { $this->decoratedClient = $decoratedClient ?? \Symfony\Component\HttpClient\HttpClient::create(); - $this->machineTokenStorage = $machineTokenStorage; } /** diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MachineTokenStorage.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MachineTokenStorage.php index ac62d44ac..ad7060c1a 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MachineTokenStorage.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MachineTokenStorage.php @@ -29,14 +29,8 @@ class MachineTokenStorage private ?AccessTokenInterface $accessToken = null; - private Azure $azure; - - private ChillRedis $chillRedis; - - public function __construct(Azure $azure, ChillRedis $chillRedis) + public function __construct(private Azure $azure, private ChillRedis $chillRedis) { - $this->azure = $azure; - $this->chillRedis = $chillRedis; } public function getToken(): AccessTokenInterface diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MapCalendarToUser.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MapCalendarToUser.php index 563bd3a38..6fcc9d20f 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MapCalendarToUser.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MapCalendarToUser.php @@ -39,16 +39,8 @@ class MapCalendarToUser public const SECRET_SUBSCRIPTION_EVENT = 'subscription_events_secret'; - private LoggerInterface $logger; - - private HttpClientInterface $machineHttpClient; - - public function __construct( - HttpClientInterface $machineHttpClient, - LoggerInterface $logger - ) { - $this->machineHttpClient = $machineHttpClient; - $this->logger = $logger; + public function __construct(private HttpClientInterface $machineHttpClient, private LoggerInterface $logger) + { } public function getActiveSubscriptionId(User $user): string diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/OnBehalfOfUserHttpClient.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/OnBehalfOfUserHttpClient.php index 9777bf4c0..70a7f1ca0 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/OnBehalfOfUserHttpClient.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/OnBehalfOfUserHttpClient.php @@ -30,15 +30,12 @@ class OnBehalfOfUserHttpClient private HttpClientInterface $decoratedClient; - private OnBehalfOfUserTokenStorage $tokenStorage; - /** * @param HttpClientInterface $decoratedClient */ - public function __construct(OnBehalfOfUserTokenStorage $tokenStorage, ?HttpClientInterface $decoratedClient = null) + public function __construct(private OnBehalfOfUserTokenStorage $tokenStorage, ?HttpClientInterface $decoratedClient = null) { $this->decoratedClient = $decoratedClient ?? \Symfony\Component\HttpClient\HttpClient::create(); - $this->tokenStorage = $tokenStorage; } public function request(string $method, string $url, array $options = []): ResponseInterface diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/OnBehalfOfUserTokenStorage.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/OnBehalfOfUserTokenStorage.php index 28f68e0e9..6bb171248 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/OnBehalfOfUserTokenStorage.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/OnBehalfOfUserTokenStorage.php @@ -30,14 +30,8 @@ class OnBehalfOfUserTokenStorage { public const MS_GRAPH_ACCESS_TOKEN = 'msgraph_access_token'; - private Azure $azure; - - private SessionInterface $session; - - public function __construct(Azure $azure, SessionInterface $session) + public function __construct(private Azure $azure, private SessionInterface $session) { - $this->azure = $azure; - $this->session = $session; } public function getToken(): AccessToken diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteEventConverter.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteEventConverter.php index 176dbe0b0..9d96357cd 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteEventConverter.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteEventConverter.php @@ -54,30 +54,15 @@ class RemoteEventConverter private DateTimeZone $defaultDateTimeZone; - private EngineInterface $engine; - - private LocationConverter $locationConverter; - - private LoggerInterface $logger; - - private PersonRenderInterface $personRender; - private DateTimeZone $remoteDateTimeZone; - private TranslatorInterface $translator; - public function __construct( - EngineInterface $engine, - LocationConverter $locationConverter, - LoggerInterface $logger, - PersonRenderInterface $personRender, - TranslatorInterface $translator + private EngineInterface $engine, + private LocationConverter $locationConverter, + private LoggerInterface $logger, + private PersonRenderInterface $personRender, + private TranslatorInterface $translator ) { - $this->engine = $engine; - $this->locationConverter = $locationConverter; - $this->logger = $logger; - $this->translator = $translator; - $this->personRender = $personRender; $this->defaultDateTimeZone = (new DateTimeImmutable())->getTimezone(); $this->remoteDateTimeZone = self::getRemoteTimeZone(); } diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteToLocalSync/CalendarRangeSyncer.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteToLocalSync/CalendarRangeSyncer.php index d05adfed7..add82d5d9 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteToLocalSync/CalendarRangeSyncer.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteToLocalSync/CalendarRangeSyncer.php @@ -30,23 +30,11 @@ use Symfony\Contracts\HttpClient\HttpClientInterface; class CalendarRangeSyncer { - private EntityManagerInterface $em; - - private LoggerInterface $logger; - - private HttpClientInterface $machineHttpClient; - /** * @param MachineHttpClient $machineHttpClient */ - public function __construct( - EntityManagerInterface $em, - LoggerInterface $logger, - HttpClientInterface $machineHttpClient - ) { - $this->em = $em; - $this->logger = $logger; - $this->machineHttpClient = $machineHttpClient; + public function __construct(private EntityManagerInterface $em, private LoggerInterface $logger, private HttpClientInterface $machineHttpClient) + { } public function handleCalendarRangeSync(CalendarRange $calendarRange, array $notification, User $user): void diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteToLocalSync/CalendarSyncer.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteToLocalSync/CalendarSyncer.php index b3febf4d4..7767c0a8b 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteToLocalSync/CalendarSyncer.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteToLocalSync/CalendarSyncer.php @@ -32,35 +32,17 @@ use function in_array; class CalendarSyncer { - private LoggerInterface $logger; - - private HttpClientInterface $machineHttpClient; - - private UserRepositoryInterface $userRepository; - - public function __construct(LoggerInterface $logger, HttpClientInterface $machineHttpClient, UserRepositoryInterface $userRepository) + public function __construct(private LoggerInterface $logger, private HttpClientInterface $machineHttpClient, private UserRepositoryInterface $userRepository) { - $this->logger = $logger; - $this->machineHttpClient = $machineHttpClient; - $this->userRepository = $userRepository; } public function handleCalendarSync(Calendar $calendar, array $notification, User $user): void { - switch ($notification['changeType']) { - case 'deleted': - $this->handleDeleteCalendar($calendar, $notification, $user); - - break; - - case 'updated': - $this->handleUpdateCalendar($calendar, $notification, $user); - - break; - - default: - throw new RuntimeException('this change type is not supported: ' . $notification['changeType']); - } + match ($notification['changeType']) { + 'deleted' => $this->handleDeleteCalendar($calendar, $notification, $user), + 'updated' => $this->handleUpdateCalendar($calendar, $notification, $user), + default => throw new RuntimeException('this change type is not supported: ' . $notification['changeType']), + }; } private function handleDeleteCalendar(Calendar $calendar, array $notification, User $user): void @@ -150,34 +132,13 @@ class CalendarSyncer $invite = $calendar->getInviteForUser($user); - switch ($status) { - // possible cases: none, organizer, tentativelyAccepted, accepted, declined, notResponded. - case 'none': - case 'notResponded': - $invite->setStatus(Invite::PENDING); - - break; - - case 'tentativelyAccepted': - $invite->setStatus(Invite::TENTATIVELY_ACCEPTED); - - break; - - case 'accepted': - $invite->setStatus(Invite::ACCEPTED); - - break; - - case 'declined': - $invite->setStatus(Invite::DECLINED); - - break; - - default: - throw new LogicException('should not happens, not implemented: ' . $status); - - break; - } + match ($status) { + 'none', 'notResponded' => $invite->setStatus(Invite::PENDING), + 'tentativelyAccepted' => $invite->setStatus(Invite::TENTATIVELY_ACCEPTED), + 'accepted' => $invite->setStatus(Invite::ACCEPTED), + 'declined' => $invite->setStatus(Invite::DECLINED), + default => throw new LogicException('should not happens, not implemented: ' . $status), + }; } foreach ($calendar->getUsers() as $user) { diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraphRemoteCalendarConnector.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraphRemoteCalendarConnector.php index 0e3beff5f..9d6dcd65c 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraphRemoteCalendarConnector.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraphRemoteCalendarConnector.php @@ -45,52 +45,8 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface { private array $cacheScheduleTimeForUser = []; - private CalendarRangeRepository $calendarRangeRepository; - - private CalendarRepository $calendarRepository; - - private LoggerInterface $logger; - - private HttpClientInterface $machineHttpClient; - - private MapCalendarToUser $mapCalendarToUser; - - private RemoteEventConverter $remoteEventConverter; - - private OnBehalfOfUserTokenStorage $tokenStorage; - - private TranslatorInterface $translator; - - private UrlGeneratorInterface $urlGenerator; - - private OnBehalfOfUserHttpClient $userHttpClient; - - private Security $security; - - public function __construct( - CalendarRepository $calendarRepository, - CalendarRangeRepository $calendarRangeRepository, - HttpClientInterface $machineHttpClient, - MapCalendarToUser $mapCalendarToUser, - LoggerInterface $logger, - OnBehalfOfUserTokenStorage $tokenStorage, - OnBehalfOfUserHttpClient $userHttpClient, - RemoteEventConverter $remoteEventConverter, - TranslatorInterface $translator, - UrlGeneratorInterface $urlGenerator, - Security $security - ) { - $this->calendarRepository = $calendarRepository; - $this->calendarRangeRepository = $calendarRangeRepository; - $this->machineHttpClient = $machineHttpClient; - $this->mapCalendarToUser = $mapCalendarToUser; - $this->logger = $logger; - $this->remoteEventConverter = $remoteEventConverter; - $this->tokenStorage = $tokenStorage; - $this->translator = $translator; - $this->urlGenerator = $urlGenerator; - $this->userHttpClient = $userHttpClient; - $this->security = $security; + public function __construct(private CalendarRepository $calendarRepository, private CalendarRangeRepository $calendarRangeRepository, private HttpClientInterface $machineHttpClient, private MapCalendarToUser $mapCalendarToUser, private LoggerInterface $logger, private OnBehalfOfUserTokenStorage $tokenStorage, private OnBehalfOfUserHttpClient $userHttpClient, private RemoteEventConverter $remoteEventConverter, private TranslatorInterface $translator, private UrlGeneratorInterface $urlGenerator, private Security $security) + { } public function countEventsForUser(User $user, DateTimeImmutable $startDate, DateTimeImmutable $endDate): int @@ -685,7 +641,7 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface 'DELETE', 'users/' . $userId . '/calendar/events/' . $remoteId ); - } catch (ClientExceptionInterface $e) { + } catch (ClientExceptionInterface) { $this->logger->warning('could not remove event from calendar', [ 'event_remote_id' => $remoteId, 'user_id' => $user->getId(), diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Model/RemoteEvent.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Model/RemoteEvent.php index 13c4a1c6a..fb914d693 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Model/RemoteEvent.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Model/RemoteEvent.php @@ -23,40 +23,28 @@ use Symfony\Component\Serializer\Annotation as Serializer; class RemoteEvent { - public string $description; - - /** - * @Serializer\Groups({"read"}) - */ - public DateTimeImmutable $endDate; - - /** - * @Serializer\Groups({"read"}) - */ - public string $id; - - /** - * @Serializer\Groups({"read"}) - */ - public bool $isAllDay; - - /** - * @Serializer\Groups({"read"}) - */ - public DateTimeImmutable $startDate; - - /** - * @Serializer\Groups({"read"}) - */ - public string $title; - - public function __construct(string $id, string $title, string $description, DateTimeImmutable $startDate, DateTimeImmutable $endDate, bool $isAllDay = false) - { - $this->id = $id; - $this->title = $title; - $this->description = $description; - $this->startDate = $startDate; - $this->endDate = $endDate; - $this->isAllDay = $isAllDay; + public function __construct( + /** + * @Serializer\Groups({"read"}) + */ + public string $id, + /** + * @Serializer\Groups({"read"}) + */ + public string $title, + public string $description, + /** + * @Serializer\Groups({"read"}) + */ + public DateTimeImmutable $startDate, + /** + * @Serializer\Groups({"read"}) + */ + public DateTimeImmutable $endDate, + /** + * @Serializer\Groups({"read"}) + */ + public bool $isAllDay = false + ) { } } diff --git a/src/Bundle/ChillCalendarBundle/Repository/CalendarACLAwareRepository.php b/src/Bundle/ChillCalendarBundle/Repository/CalendarACLAwareRepository.php index 7c6ef4e13..1fc5dd351 100644 --- a/src/Bundle/ChillCalendarBundle/Repository/CalendarACLAwareRepository.php +++ b/src/Bundle/ChillCalendarBundle/Repository/CalendarACLAwareRepository.php @@ -29,16 +29,8 @@ use Doctrine\ORM\QueryBuilder; class CalendarACLAwareRepository implements CalendarACLAwareRepositoryInterface { - private AccompanyingPeriodACLAwareRepositoryInterface $accompanyingPeriodACLAwareRepository; - - private EntityManagerInterface $em; - - public function __construct( - AccompanyingPeriodACLAwareRepositoryInterface $accompanyingPeriodACLAwareRepository, - EntityManagerInterface $em - ) { - $this->accompanyingPeriodACLAwareRepository = $accompanyingPeriodACLAwareRepository; - $this->em = $em; + public function __construct(private AccompanyingPeriodACLAwareRepositoryInterface $accompanyingPeriodACLAwareRepository, private EntityManagerInterface $em) + { } public function buildQueryByAccompanyingPeriod(AccompanyingPeriod $period, ?DateTimeImmutable $startDate, ?DateTimeImmutable $endDate): QueryBuilder diff --git a/src/Bundle/ChillCalendarBundle/Repository/CalendarRangeRepository.php b/src/Bundle/ChillCalendarBundle/Repository/CalendarRangeRepository.php index dc3405b7e..69a077e47 100644 --- a/src/Bundle/ChillCalendarBundle/Repository/CalendarRangeRepository.php +++ b/src/Bundle/ChillCalendarBundle/Repository/CalendarRangeRepository.php @@ -24,14 +24,11 @@ use function count; class CalendarRangeRepository implements ObjectRepository { - private EntityManagerInterface $em; - private EntityRepository $repository; - public function __construct(EntityManagerInterface $entityManager) + public function __construct(private EntityManagerInterface $em) { - $this->em = $entityManager; - $this->repository = $entityManager->getRepository(CalendarRange::class); + $this->repository = $em->getRepository(CalendarRange::class); } public function countByAvailableRangesForUser(User $user, DateTimeImmutable $from, DateTimeImmutable $to): int diff --git a/src/Bundle/ChillCalendarBundle/Security/Voter/CalendarDocVoter.php b/src/Bundle/ChillCalendarBundle/Security/Voter/CalendarDocVoter.php index 452286e85..7cd815961 100644 --- a/src/Bundle/ChillCalendarBundle/Security/Voter/CalendarDocVoter.php +++ b/src/Bundle/ChillCalendarBundle/Security/Voter/CalendarDocVoter.php @@ -29,11 +29,8 @@ class CalendarDocVoter extends Voter 'CHILL_CALENDAR_DOC_SEE', ]; - private Security $security; - - public function __construct(Security $security) + public function __construct(private Security $security) { - $this->security = $security; } protected function supports($attribute, $subject): bool @@ -47,15 +44,10 @@ class CalendarDocVoter extends Voter */ protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool { - switch ($attribute) { - case self::EDIT: - return $this->security->isGranted(CalendarVoter::EDIT, $subject->getCalendar()); - - case self::SEE: - return $this->security->isGranted(CalendarVoter::SEE, $subject->getCalendar()); - - default: - throw new UnexpectedValueException('Attribute not supported: ' . $attribute); - } + return match ($attribute) { + self::EDIT => $this->security->isGranted(CalendarVoter::EDIT, $subject->getCalendar()), + self::SEE => $this->security->isGranted(CalendarVoter::SEE, $subject->getCalendar()), + default => throw new UnexpectedValueException('Attribute not supported: ' . $attribute), + }; } } diff --git a/src/Bundle/ChillCalendarBundle/Security/Voter/CalendarVoter.php b/src/Bundle/ChillCalendarBundle/Security/Voter/CalendarVoter.php index 0e2be1d0f..faf6fb5c8 100644 --- a/src/Bundle/ChillCalendarBundle/Security/Voter/CalendarVoter.php +++ b/src/Bundle/ChillCalendarBundle/Security/Voter/CalendarVoter.php @@ -46,15 +46,12 @@ class CalendarVoter extends AbstractChillVoter implements ProvideRoleHierarchyIn private CenterResolverManagerInterface $centerResolverManager; - private Security $security; - private VoterHelperInterface $voterHelper; public function __construct( - Security $security, + private Security $security, VoterHelperFactoryInterface $voterHelperFactory ) { - $this->security = $security; $this->voterHelper = $voterHelperFactory ->generate(self::class) ->addCheckFor(AccompanyingPeriod::class, [self::SEE, self::CREATE]) diff --git a/src/Bundle/ChillCalendarBundle/Service/DocGenerator/CalendarContext.php b/src/Bundle/ChillCalendarBundle/Service/DocGenerator/CalendarContext.php index cabb7dcce..cb8bb5f7a 100644 --- a/src/Bundle/ChillCalendarBundle/Service/DocGenerator/CalendarContext.php +++ b/src/Bundle/ChillCalendarBundle/Service/DocGenerator/CalendarContext.php @@ -33,40 +33,8 @@ use function count; final class CalendarContext implements CalendarContextInterface { - private BaseContextData $baseContextData; - - private EntityManagerInterface $entityManager; - - private NormalizerInterface $normalizer; - - private PersonRender $personRender; - - private PersonRepository $personRepository; - - private ThirdPartyRepository $thirdPartyRepository; - - private ThirdPartyRender $thirdPartyRender; - - private TranslatableStringHelperInterface $translatableStringHelper; - - public function __construct( - BaseContextData $baseContextData, - EntityManagerInterface $entityManager, - NormalizerInterface $normalizer, - PersonRender $personRender, - PersonRepository $personRepository, - ThirdPartyRender $thirdPartyRender, - ThirdPartyRepository $thirdPartyRepository, - TranslatableStringHelperInterface $translatableStringHelper - ) { - $this->baseContextData = $baseContextData; - $this->entityManager = $entityManager; - $this->normalizer = $normalizer; - $this->personRender = $personRender; - $this->personRepository = $personRepository; - $this->thirdPartyRender = $thirdPartyRender; - $this->thirdPartyRepository = $thirdPartyRepository; - $this->translatableStringHelper = $translatableStringHelper; + public function __construct(private BaseContextData $baseContextData, private EntityManagerInterface $entityManager, private NormalizerInterface $normalizer, private PersonRender $personRender, private PersonRepository $personRepository, private ThirdPartyRender $thirdPartyRender, private ThirdPartyRepository $thirdPartyRepository, private TranslatableStringHelperInterface $translatableStringHelper) + { } public function adminFormReverseTransform(array $data): array diff --git a/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/BulkCalendarShortMessageSender.php b/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/BulkCalendarShortMessageSender.php index 83826bbcf..f5fc86373 100644 --- a/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/BulkCalendarShortMessageSender.php +++ b/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/BulkCalendarShortMessageSender.php @@ -26,23 +26,8 @@ use Symfony\Component\Messenger\MessageBusInterface; class BulkCalendarShortMessageSender { - private EntityManagerInterface $em; - - private LoggerInterface $logger; - - private MessageBusInterface $messageBus; - - private ShortMessageForCalendarBuilderInterface $messageForCalendarBuilder; - - private CalendarForShortMessageProvider $provider; - - public function __construct(CalendarForShortMessageProvider $provider, EntityManagerInterface $em, LoggerInterface $logger, MessageBusInterface $messageBus, ShortMessageForCalendarBuilderInterface $messageForCalendarBuilder) + public function __construct(private CalendarForShortMessageProvider $provider, private EntityManagerInterface $em, private LoggerInterface $logger, private MessageBusInterface $messageBus, private ShortMessageForCalendarBuilderInterface $messageForCalendarBuilder) { - $this->provider = $provider; - $this->em = $em; - $this->logger = $logger; - $this->messageBus = $messageBus; - $this->messageForCalendarBuilder = $messageForCalendarBuilder; } public function sendBulkMessageToEligibleCalendars() diff --git a/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/CalendarForShortMessageProvider.php b/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/CalendarForShortMessageProvider.php index 2316a5408..a6a8134ae 100644 --- a/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/CalendarForShortMessageProvider.php +++ b/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/CalendarForShortMessageProvider.php @@ -26,20 +26,8 @@ use function count; class CalendarForShortMessageProvider { - private CalendarRepository $calendarRepository; - - private EntityManagerInterface $em; - - private RangeGeneratorInterface $rangeGenerator; - - public function __construct( - CalendarRepository $calendarRepository, - EntityManagerInterface $em, - RangeGeneratorInterface $rangeGenerator - ) { - $this->calendarRepository = $calendarRepository; - $this->em = $em; - $this->rangeGenerator = $rangeGenerator; + public function __construct(private CalendarRepository $calendarRepository, private EntityManagerInterface $em, private RangeGeneratorInterface $rangeGenerator) + { } /** diff --git a/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/DefaultShortMessageForCalendarBuilder.php b/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/DefaultShortMessageForCalendarBuilder.php index cd61a8624..66de8781c 100644 --- a/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/DefaultShortMessageForCalendarBuilder.php +++ b/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/DefaultShortMessageForCalendarBuilder.php @@ -24,12 +24,8 @@ use Symfony\Component\Templating\EngineInterface; class DefaultShortMessageForCalendarBuilder implements ShortMessageForCalendarBuilderInterface { - private EngineInterface $engine; - - public function __construct( - EngineInterface $engine - ) { - $this->engine = $engine; + public function __construct(private EngineInterface $engine) + { } public function buildMessageForCalendar(Calendar $calendar): array diff --git a/src/Bundle/ChillCustomFieldsBundle/Command/CreateFieldsOnGroupCommand.php b/src/Bundle/ChillCustomFieldsBundle/Command/CreateFieldsOnGroupCommand.php index 2a03e90bb..739cc6c6e 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Command/CreateFieldsOnGroupCommand.php +++ b/src/Bundle/ChillCustomFieldsBundle/Command/CreateFieldsOnGroupCommand.php @@ -38,25 +38,6 @@ class CreateFieldsOnGroupCommand extends Command public const ARG_PATH = 'path'; - private $availableLanguages; - - /** - * @var CustomFieldProvider - */ - private $customFieldProvider; - - private $customizablesEntities; - - /** - * @var EntityManager - */ - private $entityManager; - - /** - * @var ValidatorInterface - */ - private $validator; - /** * CreateFieldsOnGroupCommand constructor. * @@ -64,17 +45,12 @@ class CreateFieldsOnGroupCommand extends Command * @param $customizablesEntities */ public function __construct( - CustomFieldProvider $customFieldProvider, - EntityManager $entityManager, - ValidatorInterface $validator, - $availableLanguages, - $customizablesEntities + private CustomFieldProvider $customFieldProvider, + private EntityManager $entityManager, + private ValidatorInterface $validator, + private $availableLanguages, + private $customizablesEntities ) { - $this->customFieldProvider = $customFieldProvider; - $this->entityManager = $entityManager; - $this->validator = $validator; - $this->availableLanguages = $availableLanguages; - $this->customizablesEntities = $customizablesEntities; parent::__construct(); } diff --git a/src/Bundle/ChillCustomFieldsBundle/Controller/CustomFieldController.php b/src/Bundle/ChillCustomFieldsBundle/Controller/CustomFieldController.php index 25e4d2359..bc7bcfd65 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Controller/CustomFieldController.php +++ b/src/Bundle/ChillCustomFieldsBundle/Controller/CustomFieldController.php @@ -57,10 +57,8 @@ class CustomFieldController extends AbstractController /** * Displays a form to edit an existing CustomField entity. - * - * @param mixed $id */ - public function editAction($id) + public function editAction(mixed $id) { $em = $this->getDoctrine()->getManager(); @@ -112,10 +110,8 @@ class CustomFieldController extends AbstractController * Finds and displays a CustomField entity. * * @deprecated is not used since there is no link to show action - * - * @param mixed $id */ - public function showAction($id) + public function showAction(mixed $id) { $em = $this->getDoctrine()->getManager(); @@ -131,10 +127,8 @@ class CustomFieldController extends AbstractController /** * Edits an existing CustomField entity. - * - * @param mixed $id */ - public function updateAction(Request $request, $id) + public function updateAction(Request $request, mixed $id) { $em = $this->getDoctrine()->getManager(); @@ -170,11 +164,10 @@ class CustomFieldController extends AbstractController * * @param CustomField $entity The entity * @param string - * @param mixed $type * * @return \Symfony\Component\Form\Form The form */ - private function createCreateForm(CustomField $entity, $type) + private function createCreateForm(CustomField $entity, mixed $type) { $form = $this->createForm(CustomFieldType::class, $entity, [ 'action' => $this->generateUrl( @@ -195,11 +188,10 @@ class CustomFieldController extends AbstractController * Creates a form to edit a CustomField entity. * * @param CustomField $entity The entity - * @param mixed $type * * @return \Symfony\Component\Form\Form The form */ - private function createEditForm(CustomField $entity, $type) + private function createEditForm(CustomField $entity, mixed $type) { $form = $this->createForm(CustomFieldType::class, $entity, [ 'action' => $this->generateUrl('customfield_update', ['id' => $entity->getId()]), diff --git a/src/Bundle/ChillCustomFieldsBundle/Controller/CustomFieldsGroupController.php b/src/Bundle/ChillCustomFieldsBundle/Controller/CustomFieldsGroupController.php index 4f180549a..68ccb9904 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Controller/CustomFieldsGroupController.php +++ b/src/Bundle/ChillCustomFieldsBundle/Controller/CustomFieldsGroupController.php @@ -33,25 +33,11 @@ use function in_array; */ class CustomFieldsGroupController extends AbstractController { - /** - * @var CustomFieldProvider - */ - private $customfieldProvider; - - /** - * @var TranslatorInterface - */ - private $translator; - /** * CustomFieldsGroupController constructor. */ - public function __construct( - CustomFieldProvider $customFieldProvider, - TranslatorInterface $translator - ) { - $this->customfieldProvider = $customFieldProvider; - $this->translator = $translator; + public function __construct(private CustomFieldProvider $customfieldProvider, private TranslatorInterface $translator) + { } /** @@ -85,10 +71,8 @@ class CustomFieldsGroupController extends AbstractController /** * Displays a form to edit an existing CustomFieldsGroup entity. - * - * @param mixed $id */ - public function editAction($id) + public function editAction(mixed $id) { $em = $this->getDoctrine()->getManager(); @@ -241,10 +225,8 @@ class CustomFieldsGroupController extends AbstractController /** * Finds and displays a CustomFieldsGroup entity. - * - * @param mixed $id */ - public function showAction($id) + public function showAction(mixed $id) { $em = $this->getDoctrine()->getManager(); @@ -265,10 +247,8 @@ class CustomFieldsGroupController extends AbstractController /** * Edits an existing CustomFieldsGroup entity. - * - * @param mixed $id */ - public function updateAction(Request $request, $id) + public function updateAction(Request $request, mixed $id) { $em = $this->getDoctrine()->getManager(); diff --git a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldChoice.php b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldChoice.php index 781b2b233..88ef15e3e 100644 --- a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldChoice.php +++ b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldChoice.php @@ -44,27 +44,18 @@ class CustomFieldChoice extends AbstractCustomField private $defaultLocales; - /** - * @var TwigEngine - */ - private $templating; - - /** - * @var TranslatableStringHelper Helper that find the string in current locale from an array of translation - */ - private $translatableStringHelper; - /** * CustomFieldChoice constructor. */ public function __construct( TranslatorInterface $translator, - TwigEngine $templating, - TranslatableStringHelper $translatableStringHelper + private TwigEngine $templating, + /** + * @var TranslatableStringHelper Helper that find the string in current locale from an array of translation + */ + private TranslatableStringHelper $translatableStringHelper ) { $this->defaultLocales = $translator->getFallbackLocales(); - $this->templating = $templating; - $this->translatableStringHelper = $translatableStringHelper; } public function allowOtherChoice(CustomField $cf) @@ -228,7 +219,7 @@ class CustomFieldChoice extends AbstractCustomField * * @return bool */ - public function isChecked(CustomField $cf, $choiceSlug, $data) + public function isChecked(CustomField $cf, $choiceSlug, array|string $data) { if (null === $data) { return false; @@ -330,10 +321,9 @@ class CustomFieldChoice extends AbstractCustomField * deserialized the data from the database to a multiple * field. * - * @param mixed $serialized * @param bool $allowOther */ - private function deserializeToMultiple($serialized, $allowOther) + private function deserializeToMultiple(mixed $serialized, $allowOther) { $value = $this->guessValue($serialized); @@ -387,7 +377,7 @@ class CustomFieldChoice extends AbstractCustomField * * @return mixed */ - private function guessValue($value) + private function guessValue(array|string $value) { if (null === $value) { return null; diff --git a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldDate.php b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldDate.php index 218bd5415..b8688efb1 100644 --- a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldDate.php +++ b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldDate.php @@ -44,20 +44,8 @@ class CustomFieldDate extends AbstractCustomField */ public const MIN = 'min'; - /** - * @var TwigEngine - */ - private $templating; - - /** - * @var TranslatableStringHelper - */ - private $translatableStringHelper; - - public function __construct(TwigEngine $templating, TranslatableStringHelper $translatableStringHelper) + public function __construct(private TwigEngine $templating, private TranslatableStringHelper $translatableStringHelper) { - $this->templating = $templating; - $this->translatableStringHelper = $translatableStringHelper; } public function buildForm(FormBuilderInterface $builder, CustomField $customField) @@ -82,7 +70,7 @@ class CustomFieldDate extends AbstractCustomField $validatorFunction = static function ($value, ExecutionContextInterface $context) { try { $date = new DateTime($value); - } catch (Exception $e) { + } catch (Exception) { $context->buildViolation('The expression "%expression%" is invalid', [ '%expression%' => $value, ]) diff --git a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldLongChoice.php b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldLongChoice.php index 75dc7792f..23f7b36bb 100644 --- a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldLongChoice.php +++ b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldLongChoice.php @@ -30,20 +30,8 @@ class CustomFieldLongChoice extends AbstractCustomField { public const KEY = 'key'; - private OptionRepository $optionRepository; - - private TwigEngine $templating; - - private TranslatableStringHelper $translatableStringHelper; - - public function __construct( - OptionRepository $optionRepository, - TranslatableStringHelper $translatableStringHelper, - TwigEngine $twigEngine - ) { - $this->optionRepository = $optionRepository; - $this->translatableStringHelper = $translatableStringHelper; - $this->templating = $twigEngine; + public function __construct(private OptionRepository $optionRepository, private TranslatableStringHelper $translatableStringHelper, private TwigEngine $templating) + { } public function buildForm(FormBuilderInterface $builder, CustomField $customField) @@ -130,7 +118,7 @@ class CustomFieldLongChoice extends AbstractCustomField if (!$value instanceof Option) { throw new LogicException('the value should be an instance of ' . 'Chill\CustomFieldsBundle\Entity\CustomFieldLongChoice\Option, ' - . is_object($value) ? get_class($value) : gettype($value) . ' given'); + . is_object($value) ? $value::class : gettype($value) . ' given'); } // we place the id in array, to allow in the future multiple select diff --git a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldNumber.php b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldNumber.php index 82b35f9f5..7c0e17931 100644 --- a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldNumber.php +++ b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldNumber.php @@ -39,20 +39,8 @@ class CustomFieldNumber extends AbstractCustomField public const SCALE = 'scale'; - /** - * @var TwigEngine - */ - private $templating; - - /** - * @var TranslatableStringHelper - */ - private $translatableStringHelper; - - public function __construct(TwigEngine $templating, TranslatableStringHelper $translatableStringHelper) + public function __construct(private TwigEngine $templating, private TranslatableStringHelper $translatableStringHelper) { - $this->templating = $templating; - $this->translatableStringHelper = $translatableStringHelper; } public function buildForm(FormBuilderInterface $builder, CustomField $customField) diff --git a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldText.php b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldText.php index 0a6efc2bc..389303906 100644 --- a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldText.php +++ b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldText.php @@ -29,26 +29,14 @@ class CustomFieldText extends AbstractCustomField public const MULTIPLE_CF_INLINE = 'multipleCFInline'; - private $requestStack; - - /** - * @var TwigEngine - */ - private $templating; - - /** - * @var TranslatableStringHelper Helper that find the string in current locale from an array of translation - */ - private $translatableStringHelper; - public function __construct( - RequestStack $requestStack, - TwigEngine $templating, - TranslatableStringHelper $translatableStringHelper + private RequestStack $requestStack, + private TwigEngine $templating, + /** + * @var TranslatableStringHelper Helper that find the string in current locale from an array of translation + */ + private TranslatableStringHelper $translatableStringHelper ) { - $this->requestStack = $requestStack; - $this->templating = $templating; - $this->translatableStringHelper = $translatableStringHelper; } /** diff --git a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldTitle.php b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldTitle.php index b22b84029..59114a4a5 100644 --- a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldTitle.php +++ b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldTitle.php @@ -27,26 +27,14 @@ class CustomFieldTitle extends AbstractCustomField public const TYPE_TITLE = 'title'; - private $requestStack; - - /** - * @var TwigEngine - */ - private $templating; - - /** - * @var TranslatableStringHelper Helper that find the string in current locale from an array of translation - */ - private $translatableStringHelper; - public function __construct( - RequestStack $requestStack, - TwigEngine $templating, - TranslatableStringHelper $translatableStringHelper + private RequestStack $requestStack, + private TwigEngine $templating, + /** + * @var TranslatableStringHelper Helper that find the string in current locale from an array of translation + */ + private TranslatableStringHelper $translatableStringHelper ) { - $this->requestStack = $requestStack; - $this->templating = $templating; - $this->translatableStringHelper = $translatableStringHelper; } public function buildForm(FormBuilderInterface $builder, CustomField $customField) diff --git a/src/Bundle/ChillCustomFieldsBundle/EntityRepository/CustomFieldLongChoice/OptionRepository.php b/src/Bundle/ChillCustomFieldsBundle/EntityRepository/CustomFieldLongChoice/OptionRepository.php index 4ef6e046d..e57473746 100644 --- a/src/Bundle/ChillCustomFieldsBundle/EntityRepository/CustomFieldLongChoice/OptionRepository.php +++ b/src/Bundle/ChillCustomFieldsBundle/EntityRepository/CustomFieldLongChoice/OptionRepository.php @@ -18,12 +18,10 @@ class OptionRepository extends EntityRepository { /** * @param string $key - * @param mixed $includeParents - * @param mixed $active * * @return Option[] */ - public function findFilteredByKey($key, $includeParents = true, $active = true) + public function findFilteredByKey($key, mixed $includeParents = true, mixed $active = true) { $qb = $this->createQueryBuilder('option'); $qb->where('option.key = :key'); diff --git a/src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldType.php b/src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldType.php index 0630bccf5..df4e82d5b 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldType.php +++ b/src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldType.php @@ -30,29 +30,8 @@ use Symfony\Component\OptionsResolver\OptionsResolver; class CustomFieldType extends AbstractType { - /** - * @var CustomFieldProvider - */ - private $customFieldProvider; - - /** - * @var ObjectManager - */ - private $om; - - /** - * @var TranslatableStringHelper - */ - private $translatableStringHelper; - - public function __construct( - CustomFieldProvider $compiler, - ObjectManager $om, - TranslatableStringHelper $translatableStringHelper - ) { - $this->customFieldProvider = $compiler; - $this->om = $om; - $this->translatableStringHelper = $translatableStringHelper; + public function __construct(private CustomFieldProvider $customFieldProvider, private ObjectManager $om, private TranslatableStringHelper $translatableStringHelper) + { } public function buildForm(FormBuilderInterface $builder, array $options) diff --git a/src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldsGroupType.php b/src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldsGroupType.php index 8eda50464..e62e85c04 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldsGroupType.php +++ b/src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldsGroupType.php @@ -25,17 +25,11 @@ use function count; class CustomFieldsGroupType extends AbstractType { - private $customizableEntities; //TODO : add comment about this variable - - /** - * @var \Symfony\Component\Translation\TranslatorInterface - */ - private $translator; - - public function __construct(array $customizableEntities, TranslatorInterface $translator) - { - $this->customizableEntities = $customizableEntities; - $this->translator = $translator; + public function __construct( + private array $customizableEntities, + //TODO : add comment about this variable + private TranslatorInterface $translator + ) { } //TODO : details about the function diff --git a/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/CustomFieldDataTransformer.php b/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/CustomFieldDataTransformer.php index cb626c214..f1df42ff7 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/CustomFieldDataTransformer.php +++ b/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/CustomFieldDataTransformer.php @@ -17,19 +17,8 @@ use Symfony\Component\Form\DataTransformerInterface; class CustomFieldDataTransformer implements DataTransformerInterface { - /** - * @var \Chill\CustomFieldsBundle\Entity\CustomField - */ - private $customField; - - private $customFieldDefinition; - - public function __construct( - CustomFieldInterface $customFieldDefinition, - CustomField $customField - ) { - $this->customFieldDefinition = $customFieldDefinition; - $this->customField = $customField; + public function __construct(private CustomFieldInterface $customFieldDefinition, private CustomField $customField) + { } public function reverseTransform($value) diff --git a/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/CustomFieldsGroupToIdTransformer.php b/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/CustomFieldsGroupToIdTransformer.php index 8e41e0537..5cba21068 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/CustomFieldsGroupToIdTransformer.php +++ b/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/CustomFieldsGroupToIdTransformer.php @@ -20,14 +20,8 @@ use function gettype; class CustomFieldsGroupToIdTransformer implements DataTransformerInterface { - /** - * @var ObjectManager - */ - private $om; - - public function __construct(ObjectManager $om) + public function __construct(private ObjectManager $om) { - $this->om = $om; } /** @@ -36,10 +30,8 @@ class CustomFieldsGroupToIdTransformer implements DataTransformerInterface * @param string $id * * @throws TransformationFailedException if object (report) is not found. - * - * @return CustomFieldsGroup|null */ - public function reverseTransform($id) + public function reverseTransform($id): ?\Chill\CustomFieldsBundle\Entity\CustomFieldsGroup { if (!$id) { return null; diff --git a/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/JsonCustomFieldToArrayTransformer.php b/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/JsonCustomFieldToArrayTransformer.php index 2b34b498a..1ac3ace19 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/JsonCustomFieldToArrayTransformer.php +++ b/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/JsonCustomFieldToArrayTransformer.php @@ -26,12 +26,8 @@ class JsonCustomFieldToArrayTransformer implements DataTransformerInterface { private array $customField; - private ObjectManager $om; - - public function __construct(ObjectManager $om) + public function __construct(private ObjectManager $om) { - $this->om = $om; - $customFields = $this->om ->getRepository(CustomField::class) ->findAll(); @@ -72,13 +68,13 @@ class JsonCustomFieldToArrayTransformer implements DataTransformerInterface if (array_key_exists($key, $this->customField)) { $type = $this->customField[$key]->getType(); - if (strpos($type, 'ManyToOne') === 0) { + if (str_starts_with($type, 'ManyToOne')) { // pour le manytoone() faire // un update du form en js ? : http://symfony.com/fr/doc/current/cookbook/form/form_collections.html // //$entityClass = substr($type, 10, -1); //echo $entityClasss; - if (strpos($type, 'ManyToOnePersist') === 0) { + if (str_starts_with($type, 'ManyToOnePersist')) { // PEUT ETRE A FAIRE SI SEULEMENT $value->getId() ne renvoie rien... // // @@ -127,8 +123,8 @@ class JsonCustomFieldToArrayTransformer implements DataTransformerInterface if (array_key_exists($key, $this->customField)) { $type = $this->customField[$key]->getType(); - if (strpos($type, 'ManyToOne') === 0) { - if (strpos($type, 'ManyToOnePersist') === 0) { + if (str_starts_with($type, 'ManyToOne')) { + if (str_starts_with($type, 'ManyToOnePersist')) { $entityClass = substr($type, 17, -1); } else { $entityClass = substr($type, 10, -1); diff --git a/src/Bundle/ChillCustomFieldsBundle/Form/Type/CustomFieldType.php b/src/Bundle/ChillCustomFieldsBundle/Form/Type/CustomFieldType.php index 67ea171e6..93e969e1f 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Form/Type/CustomFieldType.php +++ b/src/Bundle/ChillCustomFieldsBundle/Form/Type/CustomFieldType.php @@ -24,14 +24,8 @@ class CustomFieldType extends AbstractType */ private $customFieldCompiler; - /** - * @var ObjectManager - */ - private $om; - - public function __construct(ObjectManager $om, CustomFieldProvider $compiler) + public function __construct(private ObjectManager $om, CustomFieldProvider $compiler) { - $this->om = $om; $this->customFieldCompiler = $compiler; } diff --git a/src/Bundle/ChillCustomFieldsBundle/Form/Type/LinkedCustomFieldsType.php b/src/Bundle/ChillCustomFieldsBundle/Form/Type/LinkedCustomFieldsType.php index c8bf19481..5f87bbab0 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Form/Type/LinkedCustomFieldsType.php +++ b/src/Bundle/ChillCustomFieldsBundle/Form/Type/LinkedCustomFieldsType.php @@ -46,14 +46,8 @@ class LinkedCustomFieldsType extends AbstractType */ private $options = []; - /** - * @var TranslatableStringHelper - */ - private $translatableStringHelper; - - public function __construct(TranslatableStringHelper $helper) + public function __construct(private TranslatableStringHelper $translatableStringHelper) { - $this->translatableStringHelper = $helper; } /** diff --git a/src/Bundle/ChillCustomFieldsBundle/Service/CustomFieldsHelper.php b/src/Bundle/ChillCustomFieldsBundle/Service/CustomFieldsHelper.php index 9ffd836e6..be26cd6f3 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Service/CustomFieldsHelper.php +++ b/src/Bundle/ChillCustomFieldsBundle/Service/CustomFieldsHelper.php @@ -22,15 +22,6 @@ use Doctrine\ORM\EntityManagerInterface; */ class CustomFieldsHelper { - /** - * @var EntityManagerInterface The entity manager - */ - private $em; - - /** @var CustomFieldProvider Provider of all the declared custom - * fields */ - private $provider; - /** * Constructor. * @@ -38,12 +29,8 @@ class CustomFieldsHelper * @param CustomFieldProvider $provider The customfield provider that * contains all the declared custom fields */ - public function __construct( - EntityManagerInterface $em, - CustomFieldProvider $provider - ) { - $this->em = $em; - $this->provider = $provider; + public function __construct(private EntityManagerInterface $em, private CustomFieldProvider $provider) + { } public function isEmptyValue(array $fields, CustomField $customField) diff --git a/src/Bundle/ChillCustomFieldsBundle/Templating/Twig/CustomFieldRenderingTwig.php b/src/Bundle/ChillCustomFieldsBundle/Templating/Twig/CustomFieldRenderingTwig.php index ead01ee8f..021999b1d 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Templating/Twig/CustomFieldRenderingTwig.php +++ b/src/Bundle/ChillCustomFieldsBundle/Templating/Twig/CustomFieldRenderingTwig.php @@ -31,11 +31,6 @@ class CustomFieldRenderingTwig extends AbstractExtension implements ContainerAwa */ private $container; - /** - * @var CustomFieldsHelper - */ - private $customFieldsHelper; - /** * @var array The default parameters */ @@ -43,9 +38,8 @@ class CustomFieldRenderingTwig extends AbstractExtension implements ContainerAwa 'label_layout' => 'ChillCustomFieldsBundle:CustomField:render_label.html.twig', ]; - public function __construct(CustomFieldsHelper $customFieldsHelper) + public function __construct(private CustomFieldsHelper $customFieldsHelper) { - $this->customFieldsHelper = $customFieldsHelper; } /** diff --git a/src/Bundle/ChillCustomFieldsBundle/Tests/CustomFields/CustomFieldsChoiceTest.php b/src/Bundle/ChillCustomFieldsBundle/Tests/CustomFields/CustomFieldsChoiceTest.php index 5b905cb4d..68c41aded 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Tests/CustomFields/CustomFieldsChoiceTest.php +++ b/src/Bundle/ChillCustomFieldsBundle/Tests/CustomFields/CustomFieldsChoiceTest.php @@ -400,7 +400,7 @@ final class CustomFieldsChoiceTest extends KernelTestCase * * @param mixed $data deserialized data */ - public function testIsEmptyValueEmpty($data) + public function testIsEmptyValueEmpty(mixed $data) { $customField = $this->generateCustomField([ CustomFieldChoice::ALLOW_OTHER => false, @@ -417,14 +417,12 @@ final class CustomFieldsChoiceTest extends KernelTestCase // test function isEmptyValue // //////////////////////////////////////// - /** * test the not empty with the not-empty data provider. * - * @param mixed $data * @dataProvider serializedRepresentationDataProvider */ - public function testIsEmptyValueNotEmpty($data) + public function testIsEmptyValueNotEmpty(mixed $data) { $customField = $this->generateCustomField([ CustomFieldChoice::ALLOW_OTHER => false, diff --git a/src/Bundle/ChillCustomFieldsBundle/Tests/Templating/Twig/CustomFieldsGroupRenderingTwigTest.php b/src/Bundle/ChillCustomFieldsBundle/Tests/Templating/Twig/CustomFieldsGroupRenderingTwigTest.php index f3b93c390..e9c461e06 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Tests/Templating/Twig/CustomFieldsGroupRenderingTwigTest.php +++ b/src/Bundle/ChillCustomFieldsBundle/Tests/Templating/Twig/CustomFieldsGroupRenderingTwigTest.php @@ -99,12 +99,10 @@ final class CustomFieldsGroupRenderingTwigTest extends KernelTestCase } /** - * @param mixed $slug - * @param mixed $name * * @return CustomField */ - private function getSimpleCustomFieldText($slug, $name) + private function getSimpleCustomFieldText(mixed $slug, mixed $name) { return (new CustomField()) ->setSlug($slug) diff --git a/src/Bundle/ChillDocGeneratorBundle/Context/ContextManager.php b/src/Bundle/ChillDocGeneratorBundle/Context/ContextManager.php index 11fb58028..2e2c9a9fd 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Context/ContextManager.php +++ b/src/Bundle/ChillDocGeneratorBundle/Context/ContextManager.php @@ -17,13 +17,10 @@ use Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate; final class ContextManager implements ContextManagerInterface { /** - * @var DocGeneratorContextInterface[]|iterable + * @param \Chill\DocGeneratorBundle\Context\DocGeneratorContextInterface[] $contexts */ - private iterable $contexts; - - public function __construct(iterable $contexts) + public function __construct(private iterable $contexts) { - $this->contexts = $contexts; } public function getContextByDocGeneratorTemplate(DocGeneratorTemplate $docGeneratorTemplate): DocGeneratorContextInterface diff --git a/src/Bundle/ChillDocGeneratorBundle/Context/Exception/UnexpectedTypeException.php b/src/Bundle/ChillDocGeneratorBundle/Context/Exception/UnexpectedTypeException.php index 53d498eb9..8a6b000b3 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Context/Exception/UnexpectedTypeException.php +++ b/src/Bundle/ChillDocGeneratorBundle/Context/Exception/UnexpectedTypeException.php @@ -21,6 +21,6 @@ class UnexpectedTypeException extends LogicException { public function __construct($value, string $expectedType) { - parent::__construct(sprintf('Expected argument of type "%s", "%s" given', $expectedType, is_object($value) ? get_class($value) : gettype($value))); + parent::__construct(sprintf('Expected argument of type "%s", "%s" given', $expectedType, get_debug_type($value))); } } diff --git a/src/Bundle/ChillDocGeneratorBundle/Controller/AdminDocGeneratorTemplateController.php b/src/Bundle/ChillDocGeneratorBundle/Controller/AdminDocGeneratorTemplateController.php index c365b5e06..58c2b4e57 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Controller/AdminDocGeneratorTemplateController.php +++ b/src/Bundle/ChillDocGeneratorBundle/Controller/AdminDocGeneratorTemplateController.php @@ -22,11 +22,8 @@ use Symfony\Component\Routing\Annotation\Route; class AdminDocGeneratorTemplateController extends CRUDController { - private ContextManager $contextManager; - - public function __construct(ContextManager $contextManager) + public function __construct(private ContextManager $contextManager) { - $this->contextManager = $contextManager; } public function generateTemplateParameter(string $action, $entity, Request $request, array $defaultTemplateParameters = []) diff --git a/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php b/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php index ef2d2d585..7ad660260 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php +++ b/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php @@ -43,32 +43,8 @@ use const JSON_PRETTY_PRINT; final class DocGeneratorTemplateController extends AbstractController { - private ContextManager $contextManager; - - private DocGeneratorTemplateRepository $docGeneratorTemplateRepository; - - private EntityManagerInterface $entityManager; - - private GeneratorInterface $generator; - - private MessageBusInterface $messageBus; - - private PaginatorFactory $paginatorFactory; - - public function __construct( - ContextManager $contextManager, - DocGeneratorTemplateRepository $docGeneratorTemplateRepository, - GeneratorInterface $generator, - MessageBusInterface $messageBus, - PaginatorFactory $paginatorFactory, - EntityManagerInterface $entityManager - ) { - $this->contextManager = $contextManager; - $this->docGeneratorTemplateRepository = $docGeneratorTemplateRepository; - $this->generator = $generator; - $this->messageBus = $messageBus; - $this->paginatorFactory = $paginatorFactory; - $this->entityManager = $entityManager; + public function __construct(private ContextManager $contextManager, private DocGeneratorTemplateRepository $docGeneratorTemplateRepository, private GeneratorInterface $generator, private MessageBusInterface $messageBus, private PaginatorFactory $paginatorFactory, private EntityManagerInterface $entityManager) + { } /** diff --git a/src/Bundle/ChillDocGeneratorBundle/Form/DocGeneratorTemplateType.php b/src/Bundle/ChillDocGeneratorBundle/Form/DocGeneratorTemplateType.php index 5b4a8be30..a92dc67f2 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Form/DocGeneratorTemplateType.php +++ b/src/Bundle/ChillDocGeneratorBundle/Form/DocGeneratorTemplateType.php @@ -24,11 +24,8 @@ use Symfony\Component\OptionsResolver\OptionsResolver; class DocGeneratorTemplateType extends AbstractType { - private ContextManager $contextManager; - - public function __construct(ContextManager $contextManager) + public function __construct(private ContextManager $contextManager) { - $this->contextManager = $contextManager; } public function buildForm(FormBuilderInterface $builder, array $options) diff --git a/src/Bundle/ChillDocGeneratorBundle/GeneratorDriver/Exception/TemplateException.php b/src/Bundle/ChillDocGeneratorBundle/GeneratorDriver/Exception/TemplateException.php index b6a70372b..90de02914 100644 --- a/src/Bundle/ChillDocGeneratorBundle/GeneratorDriver/Exception/TemplateException.php +++ b/src/Bundle/ChillDocGeneratorBundle/GeneratorDriver/Exception/TemplateException.php @@ -20,12 +20,9 @@ use Throwable; */ class TemplateException extends RuntimeException { - private array $errors; - - public function __construct(array $errors, $code = 0, ?Throwable $previous = null) + public function __construct(private array $errors, $code = 0, ?Throwable $previous = null) { parent::__construct('Error while generating document from template', $code, $previous); - $this->errors = $errors; } public function getErrors(): array diff --git a/src/Bundle/ChillDocGeneratorBundle/GeneratorDriver/RelatorioDriver.php b/src/Bundle/ChillDocGeneratorBundle/GeneratorDriver/RelatorioDriver.php index c14b67df7..2166032e1 100644 --- a/src/Bundle/ChillDocGeneratorBundle/GeneratorDriver/RelatorioDriver.php +++ b/src/Bundle/ChillDocGeneratorBundle/GeneratorDriver/RelatorioDriver.php @@ -24,19 +24,13 @@ use Throwable; final class RelatorioDriver implements DriverInterface { - private HttpClientInterface $client; - - private LoggerInterface $logger; - private string $url; public function __construct( - HttpClientInterface $client, + private HttpClientInterface $client, ParameterBagInterface $parameterBag, - LoggerInterface $logger + private LoggerInterface $logger ) { - $this->client = $client; - $this->logger = $logger; $this->url = $parameterBag->get('chill_doc_generator')['driver']['relatorio']['url']; } diff --git a/src/Bundle/ChillDocGeneratorBundle/Menu/AdminMenuBuilder.php b/src/Bundle/ChillDocGeneratorBundle/Menu/AdminMenuBuilder.php index b325e6e12..6f048ae66 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Menu/AdminMenuBuilder.php +++ b/src/Bundle/ChillDocGeneratorBundle/Menu/AdminMenuBuilder.php @@ -18,14 +18,8 @@ use Symfony\Contracts\Translation\TranslatorInterface; class AdminMenuBuilder implements LocalMenuBuilderInterface { - private Security $security; - - private TranslatorInterface $translator; - - public function __construct(TranslatorInterface $translator, Security $security) + public function __construct(private TranslatorInterface $translator, private Security $security) { - $this->translator = $translator; - $this->security = $security; } public function buildMenu($menuId, MenuItem $menu, array $parameters) diff --git a/src/Bundle/ChillDocGeneratorBundle/Repository/DocGeneratorTemplateRepository.php b/src/Bundle/ChillDocGeneratorBundle/Repository/DocGeneratorTemplateRepository.php index c00dc7474..850f9a862 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Repository/DocGeneratorTemplateRepository.php +++ b/src/Bundle/ChillDocGeneratorBundle/Repository/DocGeneratorTemplateRepository.php @@ -21,12 +21,9 @@ final class DocGeneratorTemplateRepository implements ObjectRepository { private EntityRepository $repository; - private RequestStack $requestStack; - - public function __construct(EntityManagerInterface $entityManager, RequestStack $requestStack) + public function __construct(EntityManagerInterface $entityManager, private RequestStack $requestStack) { $this->repository = $entityManager->getRepository(DocGeneratorTemplate::class); - $this->requestStack = $requestStack; } public function countByEntity(string $entity): int diff --git a/src/Bundle/ChillDocGeneratorBundle/Serializer/Helper/NormalizeNullValueHelper.php b/src/Bundle/ChillDocGeneratorBundle/Serializer/Helper/NormalizeNullValueHelper.php index 49e0d4c3f..f35736635 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Serializer/Helper/NormalizeNullValueHelper.php +++ b/src/Bundle/ChillDocGeneratorBundle/Serializer/Helper/NormalizeNullValueHelper.php @@ -19,17 +19,8 @@ use function is_array; class NormalizeNullValueHelper { - private ?string $discriminatorType = null; - - private ?string $discriminatorValue = null; - - private NormalizerInterface $normalizer; - - public function __construct(NormalizerInterface $normalizer, $discriminatorType = null, $discriminatorValue = null) + public function __construct(private NormalizerInterface $normalizer, private ?string $discriminatorType = null, private ?string $discriminatorValue = null) { - $this->normalizer = $normalizer; - $this->discriminatorType = $discriminatorType; - $this->discriminatorValue = $discriminatorValue; } public function normalize(array $attributes, string $format = 'docgen', ?array $context = [], ?ClassMetadata $classMetadata = null) @@ -45,27 +36,13 @@ class NormalizeNullValueHelper if (is_numeric($key)) { $data[$class] = ''; } else { - switch ($class) { - case 'array': - case 'bool': - case 'double': - case 'float': - case 'int': - case 'resource': - case 'string': - case 'null': - $data[$key] = ''; - - break; - - default: - $data[$key] = $this->normalizer->normalize(null, $format, array_merge( - $this->getContextForAttribute($key, $context, $classMetadata), - ['docgen:expects' => $class] - )); - - break; - } + $data[$key] = match ($class) { + 'array', 'bool', 'double', 'float', 'int', 'resource', 'string', 'null' => '', + default => $this->normalizer->normalize(null, $format, array_merge( + $this->getContextForAttribute($key, $context, $classMetadata), + ['docgen:expects' => $class] + )), + }; } } diff --git a/src/Bundle/ChillDocGeneratorBundle/Serializer/Normalizer/DocGenObjectNormalizer.php b/src/Bundle/ChillDocGeneratorBundle/Serializer/Normalizer/DocGenObjectNormalizer.php index 3807ee9ee..bda1fda5c 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Serializer/Normalizer/DocGenObjectNormalizer.php +++ b/src/Bundle/ChillDocGeneratorBundle/Serializer/Normalizer/DocGenObjectNormalizer.php @@ -40,19 +40,13 @@ class DocGenObjectNormalizer implements NormalizerAwareInterface, NormalizerInte { use NormalizerAwareTrait; - private ClassMetadataFactoryInterface $classMetadataFactory; - private PropertyAccessor $propertyAccess; - private TranslatableStringHelperInterface $translatableStringHelper; - public function __construct( - ClassMetadataFactoryInterface $classMetadataFactory, - TranslatableStringHelperInterface $translatableStringHelper + private ClassMetadataFactoryInterface $classMetadataFactory, + private TranslatableStringHelperInterface $translatableStringHelper ) { - $this->classMetadataFactory = $classMetadataFactory; $this->propertyAccess = PropertyAccess::createPropertyAccessor(); - $this->translatableStringHelper = $translatableStringHelper; } public function normalize($object, $format = null, array $context = []) @@ -66,7 +60,7 @@ class DocGenObjectNormalizer implements NormalizerAwareInterface, NormalizerInte if (!$this->classMetadataFactory->hasMetadataFor($classMetadataKey)) { throw new LogicException(sprintf( 'This object does not have metadata: %s. Add groups on this entity to allow to serialize with the format %s and groups %s', - is_object($object) ? get_class($object) : '(todo' /*$context['docgen:expects'],*/ , + is_object($object) ? $object::class : '(todo' /*$context['docgen:expects'],*/ , $format, implode(', ', ($context['groups'] ?? [])) )); @@ -199,10 +193,7 @@ class DocGenObjectNormalizer implements NormalizerAwareInterface, NormalizerInte return $normalizer->normalize($keys, $format, $context, $metadata); } - /** - * @param mixed $format - */ - private function normalizeNullOutputValue($format, array $context, AttributeMetadata $attribute, ReflectionClass $reflection) + private function normalizeNullOutputValue(mixed $format, array $context, AttributeMetadata $attribute, ReflectionClass $reflection) { $type = $this->getExpectedType($attribute, $reflection); diff --git a/src/Bundle/ChillDocGeneratorBundle/Service/Context/BaseContextData.php b/src/Bundle/ChillDocGeneratorBundle/Service/Context/BaseContextData.php index 5aed8554b..ad546a97f 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Service/Context/BaseContextData.php +++ b/src/Bundle/ChillDocGeneratorBundle/Service/Context/BaseContextData.php @@ -19,11 +19,8 @@ use Symfony\Component\Serializer\Normalizer\NormalizerInterface; class BaseContextData { - private NormalizerInterface $normalizer; - - public function __construct(NormalizerInterface $normalizer) + public function __construct(private NormalizerInterface $normalizer) { - $this->normalizer = $normalizer; } public function getData(?User $user = null): array diff --git a/src/Bundle/ChillDocGeneratorBundle/Service/Generator/Generator.php b/src/Bundle/ChillDocGeneratorBundle/Service/Generator/Generator.php index e2e09f349..66136639f 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Service/Generator/Generator.php +++ b/src/Bundle/ChillDocGeneratorBundle/Service/Generator/Generator.php @@ -25,30 +25,10 @@ use Symfony\Component\HttpFoundation\File\File; class Generator implements GeneratorInterface { - private ContextManagerInterface $contextManager; - - private DriverInterface $driver; - - private EntityManagerInterface $entityManager; - - private LoggerInterface $logger; - - private StoredObjectManagerInterface $storedObjectManager; - private const LOG_PREFIX = '[docgen generator] '; - public function __construct( - ContextManagerInterface $contextManager, - DriverInterface $driver, - EntityManagerInterface $entityManager, - LoggerInterface $logger, - StoredObjectManagerInterface $storedObjectManager - ) { - $this->contextManager = $contextManager; - $this->driver = $driver; - $this->entityManager = $entityManager; - $this->logger = $logger; - $this->storedObjectManager = $storedObjectManager; + public function __construct(private ContextManagerInterface $contextManager, private DriverInterface $driver, private EntityManagerInterface $entityManager, private LoggerInterface $logger, private StoredObjectManagerInterface $storedObjectManager) + { } /** diff --git a/src/Bundle/ChillDocGeneratorBundle/Service/Generator/GeneratorException.php b/src/Bundle/ChillDocGeneratorBundle/Service/Generator/GeneratorException.php index 4360413b4..9024db235 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Service/Generator/GeneratorException.php +++ b/src/Bundle/ChillDocGeneratorBundle/Service/Generator/GeneratorException.php @@ -17,13 +17,10 @@ use Throwable; class GeneratorException extends RuntimeException { /** - * @var list + * @param string[] $errors */ - private array $errors; - - public function __construct(array $errors = [], ?Throwable $previous = null) + public function __construct(private array $errors = [], ?Throwable $previous = null) { - $this->errors = $errors; parent::__construct( 'Could not generate the document', 15252, @@ -31,9 +28,6 @@ class GeneratorException extends RuntimeException ); } - /** - * @return array - */ public function getErrors(): array { return $this->errors; diff --git a/src/Bundle/ChillDocGeneratorBundle/Service/Messenger/OnGenerationFails.php b/src/Bundle/ChillDocGeneratorBundle/Service/Messenger/OnGenerationFails.php index 5f20a3e69..7ea3a1dc7 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Service/Messenger/OnGenerationFails.php +++ b/src/Bundle/ChillDocGeneratorBundle/Service/Messenger/OnGenerationFails.php @@ -26,47 +26,10 @@ use Symfony\Contracts\Translation\TranslatorInterface; final class OnGenerationFails implements EventSubscriberInterface { - private DocGeneratorTemplateRepository $docGeneratorTemplateRepository; - - private EntityManagerInterface $entityManager; - - private LoggerInterface $logger; - - private MailerInterface $mailer; - - private StoredObjectRepository $storedObjectRepository; - - private TranslatorInterface $translator; - - private UserRepositoryInterface $userRepository; - public const LOG_PREFIX = '[docgen failed] '; - /** - * @param DocGeneratorTemplateRepository $docGeneratorTemplateRepository - * @param EntityManagerInterface $entityManager - * @param LoggerInterface $logger - * @param MailerInterface $mailer - * @param StoredObjectRepository $storedObjectRepository - * @param TranslatorInterface $translator - * @param UserRepositoryInterface $userRepository - */ - public function __construct( - DocGeneratorTemplateRepository $docGeneratorTemplateRepository, - EntityManagerInterface $entityManager, - LoggerInterface $logger, - MailerInterface $mailer, - StoredObjectRepository $storedObjectRepository, - TranslatorInterface $translator, - UserRepositoryInterface $userRepository - ) { - $this->docGeneratorTemplateRepository = $docGeneratorTemplateRepository; - $this->entityManager = $entityManager; - $this->logger = $logger; - $this->mailer = $mailer; - $this->storedObjectRepository = $storedObjectRepository; - $this->translator = $translator; - $this->userRepository = $userRepository; + public function __construct(private DocGeneratorTemplateRepository $docGeneratorTemplateRepository, private EntityManagerInterface $entityManager, private LoggerInterface $logger, private MailerInterface $mailer, private StoredObjectRepository $storedObjectRepository, private TranslatorInterface $translator, private UserRepositoryInterface $userRepository) + { } @@ -95,7 +58,7 @@ final class OnGenerationFails implements EventSubscriberInterface 'entity_id' => $message->getEntityId(), 'template_id' => $message->getTemplateId(), 'creator_id' => $message->getCreatorId(), - 'throwable_class' => get_class($event->getThrowable()), + 'throwable_class' => $event->getThrowable()::class, ]); $this->markObjectAsFailed($message); diff --git a/src/Bundle/ChillDocGeneratorBundle/Service/Messenger/RequestGenerationHandler.php b/src/Bundle/ChillDocGeneratorBundle/Service/Messenger/RequestGenerationHandler.php index 49c3430ad..99f0854cd 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Service/Messenger/RequestGenerationHandler.php +++ b/src/Bundle/ChillDocGeneratorBundle/Service/Messenger/RequestGenerationHandler.php @@ -26,36 +26,12 @@ use Symfony\Component\Messenger\Handler\MessageHandlerInterface; */ class RequestGenerationHandler implements MessageHandlerInterface { - private StoredObjectRepository $storedObjectRepository; - - private DocGeneratorTemplateRepository $docGeneratorTemplateRepository; - - private EntityManagerInterface $entityManager; - - private Generator $generator; - - private LoggerInterface $logger; - - private UserRepositoryInterface $userRepository; - public const AUTHORIZED_TRIALS = 5; private const LOG_PREFIX = '[docgen message handler] '; - public function __construct( - DocGeneratorTemplateRepository $docGeneratorTemplateRepository, - EntityManagerInterface $entityManager, - Generator $generator, - LoggerInterface $logger, - StoredObjectRepository $storedObjectRepository, - UserRepositoryInterface $userRepository - ) { - $this->docGeneratorTemplateRepository = $docGeneratorTemplateRepository; - $this->entityManager = $entityManager; - $this->generator = $generator; - $this->logger = $logger; - $this->storedObjectRepository = $storedObjectRepository; - $this->userRepository = $userRepository; + public function __construct(private DocGeneratorTemplateRepository $docGeneratorTemplateRepository, private EntityManagerInterface $entityManager, private Generator $generator, private LoggerInterface $logger, private StoredObjectRepository $storedObjectRepository, private UserRepositoryInterface $userRepository) + { } public function __invoke(RequestGenerationMessage $message) diff --git a/src/Bundle/ChillDocGeneratorBundle/Service/Messenger/RequestGenerationMessage.php b/src/Bundle/ChillDocGeneratorBundle/Service/Messenger/RequestGenerationMessage.php index e8734e62b..0bc0ec850 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Service/Messenger/RequestGenerationMessage.php +++ b/src/Bundle/ChillDocGeneratorBundle/Service/Messenger/RequestGenerationMessage.php @@ -21,26 +21,20 @@ class RequestGenerationMessage private int $templateId; - private int $entityId; - private int $destinationStoredObjectId; - private array $contextGenerationData; - private \DateTimeImmutable $createdAt; public function __construct( User $creator, DocGeneratorTemplate $template, - int $entityId, + private int $entityId, StoredObject $destinationStoredObject, - array $contextGenerationData + private array $contextGenerationData ) { $this->creatorId = $creator->getId(); $this->templateId = $template->getId(); - $this->entityId = $entityId; $this->destinationStoredObjectId = $destinationStoredObject->getId(); - $this->contextGenerationData = $contextGenerationData; $this->createdAt = new \DateTimeImmutable('now'); } diff --git a/src/Bundle/ChillDocGeneratorBundle/tests/Serializer/Encoder/DocGenEncoderTest.php b/src/Bundle/ChillDocGeneratorBundle/tests/Serializer/Encoder/DocGenEncoderTest.php index 58208b045..ad0c35ab1 100644 --- a/src/Bundle/ChillDocGeneratorBundle/tests/Serializer/Encoder/DocGenEncoderTest.php +++ b/src/Bundle/ChillDocGeneratorBundle/tests/Serializer/Encoder/DocGenEncoderTest.php @@ -116,11 +116,8 @@ final class DocGenEncoderTest extends TestCase /** * @dataProvider generateEncodeData - * - * @param mixed $expected - * @param mixed $data */ - public function testEncode($expected, $data, string $msg) + public function testEncode(mixed $expected, mixed $data, string $msg) { $generated = $this->encoder->encode($data, 'docgen'); $this->assertEquals($expected, $generated, $msg); diff --git a/src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseController.php b/src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseController.php index 1bc3db221..2c70454b0 100644 --- a/src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseController.php +++ b/src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseController.php @@ -33,31 +33,11 @@ use Symfony\Contracts\Translation\TranslatorInterface; */ class DocumentAccompanyingCourseController extends AbstractController { - protected AuthorizationHelper $authorizationHelper; - - protected EventDispatcherInterface $eventDispatcher; - - protected TranslatorInterface $translator; - - private AccompanyingCourseDocumentRepository $courseRepository; - - private PaginatorFactory $paginatorFactory; - /** * DocumentAccompanyingCourseController constructor. */ - public function __construct( - TranslatorInterface $translator, - EventDispatcherInterface $eventDispatcher, - AuthorizationHelper $authorizationHelper, - PaginatorFactory $paginatorFactory, - AccompanyingCourseDocumentRepository $courseRepository - ) { - $this->translator = $translator; - $this->eventDispatcher = $eventDispatcher; - $this->authorizationHelper = $authorizationHelper; - $this->paginatorFactory = $paginatorFactory; - $this->courseRepository = $courseRepository; + public function __construct(protected TranslatorInterface $translator, protected EventDispatcherInterface $eventDispatcher, protected AuthorizationHelper $authorizationHelper, private PaginatorFactory $paginatorFactory, private AccompanyingCourseDocumentRepository $courseRepository) + { } /** diff --git a/src/Bundle/ChillDocStoreBundle/Controller/DocumentCategoryController.php b/src/Bundle/ChillDocStoreBundle/Controller/DocumentCategoryController.php index ef6bb0c0c..69c146fb0 100644 --- a/src/Bundle/ChillDocStoreBundle/Controller/DocumentCategoryController.php +++ b/src/Bundle/ChillDocStoreBundle/Controller/DocumentCategoryController.php @@ -27,11 +27,8 @@ class DocumentCategoryController extends AbstractController { /** * @Route("/{bundleId}/{idInsideBundle}", name="document_category_delete", methods="DELETE") - * - * @param mixed $bundleId - * @param mixed $idInsideBundle */ - public function delete(Request $request, $bundleId, $idInsideBundle): Response + public function delete(Request $request, mixed $bundleId, mixed $idInsideBundle): Response { $em = $this->getDoctrine()->getManager(); $documentCategory = $em @@ -50,11 +47,8 @@ class DocumentCategoryController extends AbstractController /** * @Route("/{bundleId}/{idInsideBundle}/edit", name="document_category_edit", methods="GET|POST") - * - * @param mixed $bundleId - * @param mixed $idInsideBundle */ - public function edit(Request $request, $bundleId, $idInsideBundle): Response + public function edit(Request $request, mixed $bundleId, mixed $idInsideBundle): Response { $em = $this->getDoctrine()->getManager(); $documentCategory = $em @@ -136,11 +130,8 @@ class DocumentCategoryController extends AbstractController /** * @Route("/{bundleId}/{idInsideBundle}", name="document_category_show", methods="GET") - * - * @param mixed $bundleId - * @param mixed $idInsideBundle */ - public function show($bundleId, $idInsideBundle): Response + public function show(mixed $bundleId, mixed $idInsideBundle): Response { $em = $this->getDoctrine()->getManager(); $documentCategory = $em diff --git a/src/Bundle/ChillDocStoreBundle/Controller/DocumentPersonController.php b/src/Bundle/ChillDocStoreBundle/Controller/DocumentPersonController.php index 6fcb6a8e5..79fb401ea 100644 --- a/src/Bundle/ChillDocStoreBundle/Controller/DocumentPersonController.php +++ b/src/Bundle/ChillDocStoreBundle/Controller/DocumentPersonController.php @@ -39,31 +39,11 @@ use Symfony\Contracts\Translation\TranslatorInterface; */ class DocumentPersonController extends AbstractController { - protected AuthorizationHelper $authorizationHelper; - - protected EventDispatcherInterface $eventDispatcher; - - protected TranslatorInterface $translator; - - private PaginatorFactory $paginatorFactory; - - private PersonDocumentACLAwareRepositoryInterface $personDocumentACLAwareRepository; - /** * DocumentPersonController constructor. */ - public function __construct( - TranslatorInterface $translator, - EventDispatcherInterface $eventDispatcher, - AuthorizationHelper $authorizationHelper, - PaginatorFactory $paginatorFactory, - PersonDocumentACLAwareRepositoryInterface $personDocumentACLAwareRepository - ) { - $this->translator = $translator; - $this->eventDispatcher = $eventDispatcher; - $this->authorizationHelper = $authorizationHelper; - $this->paginatorFactory = $paginatorFactory; - $this->personDocumentACLAwareRepository = $personDocumentACLAwareRepository; + public function __construct(protected TranslatorInterface $translator, protected EventDispatcherInterface $eventDispatcher, protected AuthorizationHelper $authorizationHelper, private PaginatorFactory $paginatorFactory, private PersonDocumentACLAwareRepositoryInterface $personDocumentACLAwareRepository) + { } /** diff --git a/src/Bundle/ChillDocStoreBundle/Controller/StoredObjectApiController.php b/src/Bundle/ChillDocStoreBundle/Controller/StoredObjectApiController.php index a11556e42..b675d6246 100644 --- a/src/Bundle/ChillDocStoreBundle/Controller/StoredObjectApiController.php +++ b/src/Bundle/ChillDocStoreBundle/Controller/StoredObjectApiController.php @@ -20,11 +20,8 @@ use Symfony\Component\Security\Core\Security; class StoredObjectApiController { - private Security $security; - - public function __construct(Security $security) + public function __construct(private Security $security) { - $this->security = $security; } /** diff --git a/src/Bundle/ChillDocStoreBundle/Entity/DocumentCategory.php b/src/Bundle/ChillDocStoreBundle/Entity/DocumentCategory.php index 3d9cc3220..b4cd54e1b 100644 --- a/src/Bundle/ChillDocStoreBundle/Entity/DocumentCategory.php +++ b/src/Bundle/ChillDocStoreBundle/Entity/DocumentCategory.php @@ -19,14 +19,6 @@ use Doctrine\ORM\Mapping as ORM; */ class DocumentCategory { - /** - * @ORM\Id - * @ORM\Column(type="string", name="bundle_id") - * - * @var string The id of the bundle that has create the category (i.e. 'person', 'activity', ....) - */ - private $bundleId; - /** * @ORM\Column(type="string", name="document_class") * @@ -34,23 +26,31 @@ class DocumentCategory */ private $documentClass; - /** - * @ORM\Id - * @ORM\Column(type="integer", name="id_inside_bundle") - * - * @var int The id which is unique inside the bundle - */ - private $idInsideBundle; - /** * @ORM\Column(type="json") */ private $name; - public function __construct($bundleId, $idInsideBundle) - { - $this->bundleId = $bundleId; - $this->idInsideBundle = $idInsideBundle; + /** + * @param string $bundleId + * @param int $idInsideBundle + */ + public function __construct( + /** + * @ORM\Id + * @ORM\Column(type="string", name="bundle_id") + * + * @var string The id of the bundle that has create the category (i.e. 'person', 'activity', ....) + */ + private $bundleId, + /** + * @ORM\Id + * @ORM\Column(type="integer", name="id_inside_bundle") + * + * @var int The id which is unique inside the bundle + */ + private $idInsideBundle + ) { } public function getBundleId() // ::class BundleClass (FQDN) diff --git a/src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php b/src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php index 0583e26b2..fbfd4ef54 100644 --- a/src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php +++ b/src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php @@ -96,12 +96,6 @@ class StoredObject implements AsyncFileInterface, Document, TrackCreationInterfa */ private ?DocGeneratorTemplate $template = null; - /** - * @ORM\Column(type="text", options={"default": "ready"}) - * @Serializer\Groups({"read"}) - */ - private string $status; - /** * Store the number of times a generation has been tryied for this StoredObject. * @@ -115,10 +109,13 @@ class StoredObject implements AsyncFileInterface, Document, TrackCreationInterfa /** * @param StoredObject::STATUS_* $status */ - public function __construct(string $status = "ready") - { + public function __construct(/** + * @ORM\Column(type="text", options={"default": "ready"}) + * @Serializer\Groups({"read"}) + */ + private string $status = "ready" + ) { $this->uuid = Uuid::uuid4(); - $this->status = $status; } public function addGenerationTrial(): self diff --git a/src/Bundle/ChillDocStoreBundle/Form/DocumentCategoryType.php b/src/Bundle/ChillDocStoreBundle/Form/DocumentCategoryType.php index d42bb90d5..8ae67be51 100644 --- a/src/Bundle/ChillDocStoreBundle/Form/DocumentCategoryType.php +++ b/src/Bundle/ChillDocStoreBundle/Form/DocumentCategoryType.php @@ -26,7 +26,7 @@ class DocumentCategoryType extends AbstractType { // TODO faire un service dans CHillMain foreach ($kernelBundles as $key => $value) { - if (substr($key, 0, 5) === 'Chill') { + if (str_starts_with($key, 'Chill')) { $this->chillBundlesFlipped[$value] = $key; } } diff --git a/src/Bundle/ChillDocStoreBundle/Form/PersonDocumentType.php b/src/Bundle/ChillDocStoreBundle/Form/PersonDocumentType.php index 11f73e862..cfe5d5156 100644 --- a/src/Bundle/ChillDocStoreBundle/Form/PersonDocumentType.php +++ b/src/Bundle/ChillDocStoreBundle/Form/PersonDocumentType.php @@ -30,24 +30,8 @@ use Symfony\Component\OptionsResolver\OptionsResolver; class PersonDocumentType extends AbstractType { - private CenterResolverDispatcher $centerResolverDispatcher; - - private ParameterBagInterface $parameterBag; - - private ScopeResolverDispatcher $scopeResolverDispatcher; - - private TranslatableStringHelperInterface $translatableStringHelper; - - public function __construct( - TranslatableStringHelperInterface $translatableStringHelper, - ScopeResolverDispatcher $scopeResolverDispatcher, - ParameterBagInterface $parameterBag, - CenterResolverDispatcher $centerResolverDispatcher - ) { - $this->translatableStringHelper = $translatableStringHelper; - $this->scopeResolverDispatcher = $scopeResolverDispatcher; - $this->parameterBag = $parameterBag; - $this->centerResolverDispatcher = $centerResolverDispatcher; + public function __construct(private TranslatableStringHelperInterface $translatableStringHelper, private ScopeResolverDispatcher $scopeResolverDispatcher, private ParameterBagInterface $parameterBag, private CenterResolverDispatcher $centerResolverDispatcher) + { } public function buildForm(FormBuilderInterface $builder, array $options) diff --git a/src/Bundle/ChillDocStoreBundle/Menu/MenuBuilder.php b/src/Bundle/ChillDocStoreBundle/Menu/MenuBuilder.php index 41d31ced3..49f7723ce 100644 --- a/src/Bundle/ChillDocStoreBundle/Menu/MenuBuilder.php +++ b/src/Bundle/ChillDocStoreBundle/Menu/MenuBuilder.php @@ -21,34 +21,17 @@ use Symfony\Contracts\Translation\TranslatorInterface; final class MenuBuilder implements LocalMenuBuilderInterface { - private Security $security; - - private TranslatorInterface $translator; - - public function __construct( - Security $security, - TranslatorInterface $translator - ) { - $this->security = $security; - $this->translator = $translator; + public function __construct(private Security $security, private TranslatorInterface $translator) + { } public function buildMenu($menuId, MenuItem $menu, array $parameters) { - switch ($menuId) { - case 'accompanyingCourse': - $this->buildMenuAccompanyingCourse($menu, $parameters); - - break; - - case 'person': - $this->buildMenuPerson($menu, $parameters); - - break; - - default: - throw new LogicException("this menuid {$menuId} is not implemented"); - } + match ($menuId) { + 'accompanyingCourse' => $this->buildMenuAccompanyingCourse($menu, $parameters), + 'person' => $this->buildMenuPerson($menu, $parameters), + default => throw new LogicException("this menuid {$menuId} is not implemented"), + }; } public static function getMenuIds(): array diff --git a/src/Bundle/ChillDocStoreBundle/Repository/AccompanyingCourseDocumentRepository.php b/src/Bundle/ChillDocStoreBundle/Repository/AccompanyingCourseDocumentRepository.php index de1958f36..3231bfd79 100644 --- a/src/Bundle/ChillDocStoreBundle/Repository/AccompanyingCourseDocumentRepository.php +++ b/src/Bundle/ChillDocStoreBundle/Repository/AccompanyingCourseDocumentRepository.php @@ -20,13 +20,10 @@ use Doctrine\Persistence\ObjectRepository; class AccompanyingCourseDocumentRepository implements ObjectRepository { - private EntityManagerInterface $em; - private EntityRepository $repository; - public function __construct(EntityManagerInterface $em) + public function __construct(private EntityManagerInterface $em) { - $this->em = $em; $this->repository = $em->getRepository(AccompanyingCourseDocument::class); } diff --git a/src/Bundle/ChillDocStoreBundle/Repository/DocumentCategoryRepository.php b/src/Bundle/ChillDocStoreBundle/Repository/DocumentCategoryRepository.php index 40d134200..9025afd09 100644 --- a/src/Bundle/ChillDocStoreBundle/Repository/DocumentCategoryRepository.php +++ b/src/Bundle/ChillDocStoreBundle/Repository/DocumentCategoryRepository.php @@ -21,13 +21,10 @@ use Doctrine\Persistence\ObjectRepository; */ class DocumentCategoryRepository implements ObjectRepository { - private EntityManagerInterface $em; - private EntityRepository $repository; - public function __construct(EntityManagerInterface $em) + public function __construct(private EntityManagerInterface $em) { - $this->em = $em; $this->repository = $em->getRepository(DocumentCategory::class); } diff --git a/src/Bundle/ChillDocStoreBundle/Repository/PersonDocumentACLAwareRepository.php b/src/Bundle/ChillDocStoreBundle/Repository/PersonDocumentACLAwareRepository.php index 23dcc4e0b..da1809dbb 100644 --- a/src/Bundle/ChillDocStoreBundle/Repository/PersonDocumentACLAwareRepository.php +++ b/src/Bundle/ChillDocStoreBundle/Repository/PersonDocumentACLAwareRepository.php @@ -22,20 +22,8 @@ use Symfony\Component\Security\Core\Security; class PersonDocumentACLAwareRepository implements PersonDocumentACLAwareRepositoryInterface { - private AuthorizationHelperInterface $authorizationHelper; - - private CenterResolverDispatcher $centerResolverDispatcher; - - private EntityManagerInterface $em; - - private Security $security; - - public function __construct(EntityManagerInterface $em, AuthorizationHelperInterface $authorizationHelper, CenterResolverDispatcher $centerResolverDispatcher, Security $security) + public function __construct(private EntityManagerInterface $em, private AuthorizationHelperInterface $authorizationHelper, private CenterResolverDispatcher $centerResolverDispatcher, private Security $security) { - $this->em = $em; - $this->authorizationHelper = $authorizationHelper; - $this->centerResolverDispatcher = $centerResolverDispatcher; - $this->security = $security; } public function buildQueryByPerson(Person $person): QueryBuilder diff --git a/src/Bundle/ChillDocStoreBundle/Security/Authorization/AccompanyingCourseDocumentVoter.php b/src/Bundle/ChillDocStoreBundle/Security/Authorization/AccompanyingCourseDocumentVoter.php index 0ef1d4d49..60bc7060c 100644 --- a/src/Bundle/ChillDocStoreBundle/Security/Authorization/AccompanyingCourseDocumentVoter.php +++ b/src/Bundle/ChillDocStoreBundle/Security/Authorization/AccompanyingCourseDocumentVoter.php @@ -37,19 +37,13 @@ class AccompanyingCourseDocumentVoter extends AbstractChillVoter implements Prov public const UPDATE = 'CHILL_ACCOMPANYING_COURSE_DOCUMENT_UPDATE'; - protected LoggerInterface $logger; - - protected Security $security; - protected VoterHelperInterface $voterHelper; public function __construct( - LoggerInterface $logger, - Security $security, + protected LoggerInterface $logger, + protected Security $security, VoterHelperFactoryInterface $voterHelperFactory ) { - $this->logger = $logger; - $this->security = $security; $this->voterHelper = $voterHelperFactory ->generate(self::class) ->addCheckFor(AccompanyingCourseDocument::class, $this->getRoles()) diff --git a/src/Bundle/ChillDocStoreBundle/Security/Authorization/PersonDocumentVoter.php b/src/Bundle/ChillDocStoreBundle/Security/Authorization/PersonDocumentVoter.php index 059a2c7d9..b4a5de4c5 100644 --- a/src/Bundle/ChillDocStoreBundle/Security/Authorization/PersonDocumentVoter.php +++ b/src/Bundle/ChillDocStoreBundle/Security/Authorization/PersonDocumentVoter.php @@ -35,19 +35,13 @@ class PersonDocumentVoter extends AbstractChillVoter implements ProvideRoleHiera public const UPDATE = 'CHILL_PERSON_DOCUMENT_UPDATE'; - protected LoggerInterface $logger; - - protected Security $security; - protected VoterHelperInterface $voterHelper; public function __construct( - LoggerInterface $logger, - Security $security, + protected LoggerInterface $logger, + protected Security $security, VoterHelperFactoryInterface $voterHelperFactory ) { - $this->logger = $logger; - $this->security = $security; $this->voterHelper = $voterHelperFactory ->generate(self::class) ->addCheckFor(PersonDocument::class, $this->getRoles()) diff --git a/src/Bundle/ChillDocStoreBundle/Serializer/Normalizer/StoredObjectDenormalizer.php b/src/Bundle/ChillDocStoreBundle/Serializer/Normalizer/StoredObjectDenormalizer.php index c9829d3ee..d277c7ec9 100644 --- a/src/Bundle/ChillDocStoreBundle/Serializer/Normalizer/StoredObjectDenormalizer.php +++ b/src/Bundle/ChillDocStoreBundle/Serializer/Normalizer/StoredObjectDenormalizer.php @@ -22,11 +22,8 @@ class StoredObjectDenormalizer implements DenormalizerInterface { use ObjectToPopulateTrait; - private StoredObjectRepository $storedObjectRepository; - - public function __construct(StoredObjectRepository $storedObjectRepository) + public function __construct(private StoredObjectRepository $storedObjectRepository) { - $this->storedObjectRepository = $storedObjectRepository; } public function denormalize($data, $type, $format = null, array $context = []) diff --git a/src/Bundle/ChillDocStoreBundle/Service/StoredObjectManager.php b/src/Bundle/ChillDocStoreBundle/Service/StoredObjectManager.php index a1ef42ff1..5e7a54410 100644 --- a/src/Bundle/ChillDocStoreBundle/Service/StoredObjectManager.php +++ b/src/Bundle/ChillDocStoreBundle/Service/StoredObjectManager.php @@ -33,18 +33,10 @@ final class StoredObjectManager implements StoredObjectManagerInterface { private const ALGORITHM = 'AES-256-CBC'; - private HttpClientInterface $client; - private array $inMemory = []; - private TempUrlGeneratorInterface $tempUrlGenerator; - - public function __construct( - HttpClientInterface $client, - TempUrlGeneratorInterface $tempUrlGenerator - ) { - $this->client = $client; - $this->tempUrlGenerator = $tempUrlGenerator; + public function __construct(private HttpClientInterface $client, private TempUrlGeneratorInterface $tempUrlGenerator) + { } public function getLastModified(StoredObject $document): DateTimeInterface diff --git a/src/Bundle/ChillDocStoreBundle/Templating/WopiEditTwigExtensionRuntime.php b/src/Bundle/ChillDocStoreBundle/Templating/WopiEditTwigExtensionRuntime.php index ec1df1465..89655fc35 100644 --- a/src/Bundle/ChillDocStoreBundle/Templating/WopiEditTwigExtensionRuntime.php +++ b/src/Bundle/ChillDocStoreBundle/Templating/WopiEditTwigExtensionRuntime.php @@ -122,14 +122,8 @@ final class WopiEditTwigExtensionRuntime implements RuntimeExtensionInterface private const TEMPLATE_BUTTON_GROUP = '@ChillDocStore/Button/button_group.html.twig'; - private DiscoveryInterface $discovery; - - private NormalizerInterface $normalizer; - - public function __construct(DiscoveryInterface $discovery, NormalizerInterface $normalizer) + public function __construct(private DiscoveryInterface $discovery, private NormalizerInterface $normalizer) { - $this->discovery = $discovery; - $this->normalizer = $normalizer; } /** diff --git a/src/Bundle/ChillDocStoreBundle/Workflow/AccompanyingCourseDocumentWorkflowHandler.php b/src/Bundle/ChillDocStoreBundle/Workflow/AccompanyingCourseDocumentWorkflowHandler.php index c3285507e..5a7ce406c 100644 --- a/src/Bundle/ChillDocStoreBundle/Workflow/AccompanyingCourseDocumentWorkflowHandler.php +++ b/src/Bundle/ChillDocStoreBundle/Workflow/AccompanyingCourseDocumentWorkflowHandler.php @@ -24,17 +24,14 @@ class AccompanyingCourseDocumentWorkflowHandler implements EntityWorkflowHandler { private EntityRepository $repository; - private TranslatorInterface $translator; - /** * TODO: injecter le repository directement. */ public function __construct( EntityManagerInterface $em, - TranslatorInterface $translator + private TranslatorInterface $translator ) { $this->repository = $em->getRepository(AccompanyingCourseDocument::class); - $this->translator = $translator; } public function getDeletionRoles(): array diff --git a/src/Bundle/ChillEventBundle/Controller/EventController.php b/src/Bundle/ChillEventBundle/Controller/EventController.php index 93ce62f43..f84eeddfb 100644 --- a/src/Bundle/ChillEventBundle/Controller/EventController.php +++ b/src/Bundle/ChillEventBundle/Controller/EventController.php @@ -91,10 +91,8 @@ class EventController extends AbstractController /** * @param $event_id - * - * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response */ - public function deleteAction($event_id, Request $request) + public function deleteAction($event_id, Request $request): \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response { $em = $this->getDoctrine()->getManager(); $event = $em->getRepository(\Chill\EventBundle\Entity\Event::class)->findOneBy([ @@ -345,10 +343,8 @@ class EventController extends AbstractController * Edits an existing Event entity. * * @param $event_id - * - * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response */ - public function updateAction(Request $request, $event_id) + public function updateAction(Request $request, $event_id): \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response { $em = $this->getDoctrine()->getManager(); diff --git a/src/Bundle/ChillEventBundle/Controller/EventTypeController.php b/src/Bundle/ChillEventBundle/Controller/EventTypeController.php index 2e9a45f6f..486b0f7f9 100644 --- a/src/Bundle/ChillEventBundle/Controller/EventTypeController.php +++ b/src/Bundle/ChillEventBundle/Controller/EventTypeController.php @@ -50,10 +50,8 @@ class EventTypeController extends AbstractController /** * Deletes a EventType entity. - * - * @param mixed $id */ - public function deleteAction(Request $request, $id) + public function deleteAction(Request $request, mixed $id) { $form = $this->createDeleteForm($id); $form->handleRequest($request); @@ -75,10 +73,8 @@ class EventTypeController extends AbstractController /** * Displays a form to edit an existing EventType entity. - * - * @param mixed $id */ - public function editAction($id) + public function editAction(mixed $id) { $em = $this->getDoctrine()->getManager(); @@ -128,10 +124,8 @@ class EventTypeController extends AbstractController /** * Finds and displays a EventType entity. - * - * @param mixed $id */ - public function showAction($id) + public function showAction(mixed $id) { $em = $this->getDoctrine()->getManager(); @@ -151,10 +145,8 @@ class EventTypeController extends AbstractController /** * Edits an existing EventType entity. - * - * @param mixed $id */ - public function updateAction(Request $request, $id) + public function updateAction(Request $request, mixed $id) { $em = $this->getDoctrine()->getManager(); @@ -210,7 +202,7 @@ class EventTypeController extends AbstractController * * @return \Symfony\Component\Form\Form The form */ - private function createDeleteForm($id) + private function createDeleteForm(mixed $id) { return $this->createFormBuilder() ->setAction($this->generateUrl( diff --git a/src/Bundle/ChillEventBundle/Controller/ParticipationController.php b/src/Bundle/ChillEventBundle/Controller/ParticipationController.php index 1929beac1..9cd807479 100644 --- a/src/Bundle/ChillEventBundle/Controller/ParticipationController.php +++ b/src/Bundle/ChillEventBundle/Controller/ParticipationController.php @@ -33,23 +33,17 @@ use function count; */ class ParticipationController extends AbstractController { - /** - * @var \Psr\Log\LoggerInterface - */ - private $logger; - /** * ParticipationController constructor. */ - public function __construct(LoggerInterface $logger) + public function __construct(private LoggerInterface $logger) { - $this->logger = $logger; } /** * @return Response|\Symfony\Component\HttpFoundation\RedirectResponse */ - public function createAction(Request $request) + public function createAction(Request $request): \Symfony\Component\HttpFoundation\Response|\Symfony\Component\HttpFoundation\RedirectResponse { // test the request is correct try { @@ -167,7 +161,7 @@ class ParticipationController extends AbstractController /** * @return Response|\Symfony\Component\HttpFoundation\RedirectResponse */ - public function createMultiple(Request $request) + public function createMultiple(Request $request): \Symfony\Component\HttpFoundation\Response|\Symfony\Component\HttpFoundation\RedirectResponse { $participations = $this->handleRequest($request, new Participation(), true); @@ -210,7 +204,7 @@ class ParticipationController extends AbstractController /** * @return Response|\Symfony\Component\HttpFoundation\RedirectResponse */ - public function createSingle(Request $request) + public function createSingle(Request $request): \Symfony\Component\HttpFoundation\Response|\Symfony\Component\HttpFoundation\RedirectResponse { $participation = $this->handleRequest($request, new Participation(), false); @@ -253,7 +247,7 @@ class ParticipationController extends AbstractController * * @return Response|\Symfony\Component\HttpFoundation\RedirectResponse */ - public function deleteAction($participation_id, Request $request) + public function deleteAction($participation_id, Request $request): \Symfony\Component\HttpFoundation\Response|\Symfony\Component\HttpFoundation\RedirectResponse { $em = $this->getDoctrine()->getManager(); $participation = $em->getRepository(\Chill\EventBundle\Entity\Participation::class)->findOneBy([ @@ -332,7 +326,7 @@ class ParticipationController extends AbstractController * * @return Response|\Symfony\Component\HttpFoundation\RedirectResponse */ - public function editMultipleAction($event_id) + public function editMultipleAction($event_id): \Symfony\Component\HttpFoundation\Response|\Symfony\Component\HttpFoundation\RedirectResponse { $event = $this->getDoctrine()->getRepository(\Chill\EventBundle\Entity\Event::class) ->find($event_id); @@ -389,7 +383,7 @@ class ParticipationController extends AbstractController * * @return Response|\Symfony\Component\HttpFoundation\RedirectResponse */ - public function newAction(Request $request) + public function newAction(Request $request): \Symfony\Component\HttpFoundation\Response|\Symfony\Component\HttpFoundation\RedirectResponse { // test the request is correct try { @@ -555,7 +549,7 @@ class ParticipationController extends AbstractController Request $request, Participation $participation, bool $multiple = false - ) { + ): \Chill\EventBundle\Entity\Participation|array { $em = $this->getDoctrine()->getManager(); if ($em->contains($participation)) { @@ -632,7 +626,7 @@ class ParticipationController extends AbstractController * * @return Response|\Symfony\Component\HttpFoundation\RedirectResponse */ - protected function newMultiple(Request $request) + protected function newMultiple(Request $request): \Symfony\Component\HttpFoundation\Response|\Symfony\Component\HttpFoundation\RedirectResponse { $participations = $this->handleRequest($request, new Participation(), true); $ignoredParticipations = $newParticipations = []; diff --git a/src/Bundle/ChillEventBundle/Controller/RoleController.php b/src/Bundle/ChillEventBundle/Controller/RoleController.php index 9ffe0d2d0..f5cc100bf 100644 --- a/src/Bundle/ChillEventBundle/Controller/RoleController.php +++ b/src/Bundle/ChillEventBundle/Controller/RoleController.php @@ -50,10 +50,8 @@ class RoleController extends AbstractController /** * Deletes a Role entity. - * - * @param mixed $id */ - public function deleteAction(Request $request, $id) + public function deleteAction(Request $request, mixed $id) { $form = $this->createDeleteForm($id); $form->handleRequest($request); @@ -75,10 +73,8 @@ class RoleController extends AbstractController /** * Displays a form to edit an existing Role entity. - * - * @param mixed $id */ - public function editAction($id) + public function editAction(mixed $id) { $em = $this->getDoctrine()->getManager(); @@ -128,10 +124,8 @@ class RoleController extends AbstractController /** * Finds and displays a Role entity. - * - * @param mixed $id */ - public function showAction($id) + public function showAction(mixed $id) { $em = $this->getDoctrine()->getManager(); @@ -151,10 +145,8 @@ class RoleController extends AbstractController /** * Edits an existing Role entity. - * - * @param mixed $id */ - public function updateAction(Request $request, $id) + public function updateAction(Request $request, mixed $id) { $em = $this->getDoctrine()->getManager(); @@ -210,7 +202,7 @@ class RoleController extends AbstractController * * @return \Symfony\Component\Form\Form The form */ - private function createDeleteForm($id) + private function createDeleteForm(mixed $id) { return $this->createFormBuilder() ->setAction($this->generateUrl('chill_event_admin_role_delete', ['id' => $id])) diff --git a/src/Bundle/ChillEventBundle/Controller/StatusController.php b/src/Bundle/ChillEventBundle/Controller/StatusController.php index 2b8d97ee6..9e7a7e0a5 100644 --- a/src/Bundle/ChillEventBundle/Controller/StatusController.php +++ b/src/Bundle/ChillEventBundle/Controller/StatusController.php @@ -47,10 +47,8 @@ class StatusController extends AbstractController /** * Deletes a Status entity. - * - * @param mixed $id */ - public function deleteAction(Request $request, $id) + public function deleteAction(Request $request, mixed $id) { $form = $this->createDeleteForm($id); $form->handleRequest($request); @@ -72,10 +70,8 @@ class StatusController extends AbstractController /** * Displays a form to edit an existing Status entity. - * - * @param mixed $id */ - public function editAction($id) + public function editAction(mixed $id) { $em = $this->getDoctrine()->getManager(); @@ -125,10 +121,8 @@ class StatusController extends AbstractController /** * Finds and displays a Status entity. - * - * @param mixed $id */ - public function showAction($id) + public function showAction(mixed $id) { $em = $this->getDoctrine()->getManager(); @@ -148,10 +142,8 @@ class StatusController extends AbstractController /** * Edits an existing Status entity. - * - * @param mixed $id */ - public function updateAction(Request $request, $id) + public function updateAction(Request $request, mixed $id) { $em = $this->getDoctrine()->getManager(); @@ -204,7 +196,7 @@ class StatusController extends AbstractController * * @return \Symfony\Component\Form\Form The form */ - private function createDeleteForm($id) + private function createDeleteForm(mixed $id) { return $this->createFormBuilder() ->setAction($this->generateUrl('chill_event_admin_status_delete', ['id' => $id])) diff --git a/src/Bundle/ChillEventBundle/Entity/Event.php b/src/Bundle/ChillEventBundle/Entity/Event.php index d55a7b8a8..ca1379657 100644 --- a/src/Bundle/ChillEventBundle/Entity/Event.php +++ b/src/Bundle/ChillEventBundle/Entity/Event.php @@ -162,7 +162,7 @@ class Event implements HasCenterInterface, HasScopeInterface /** * @return ArrayIterator|Collection|Traversable */ - public function getParticipations() + public function getParticipations(): \ArrayIterator|\Doctrine\Common\Collections\Collection|\Traversable { return $this->getParticipationsOrdered(); } @@ -172,7 +172,7 @@ class Event implements HasCenterInterface, HasScopeInterface * * @return ArrayIterator|Traversable */ - public function getParticipationsOrdered() + public function getParticipationsOrdered(): \ArrayIterator|\Traversable { $iterator = $this->participations->getIterator(); diff --git a/src/Bundle/ChillEventBundle/Entity/Participation.php b/src/Bundle/ChillEventBundle/Entity/Participation.php index 38c849535..cb63327a6 100644 --- a/src/Bundle/ChillEventBundle/Entity/Participation.php +++ b/src/Bundle/ChillEventBundle/Entity/Participation.php @@ -192,12 +192,7 @@ class Participation implements ArrayAccess, HasCenterInterface, HasScopeInterfac } } - /** - * @param mixed $offset - * - * @return bool - */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return in_array($offset, [ 'person', 'role', 'status', 'event', @@ -205,33 +200,20 @@ class Participation implements ArrayAccess, HasCenterInterface, HasScopeInterfac } /** - * @param mixed $offset - * * @return Event|Person|Role|Status */ - public function offsetGet($offset): mixed + public function offsetGet(mixed $offset): mixed { - switch ($offset) { - case 'person': - return $this->getPerson(); - case 'role': - return $this->getRole(); - case 'status': - return $this->getStatus(); - case 'event': - return $this->getEvent(); - default: - throw new \LogicException("this offset does not exists : " . $offset); - } + return match ($offset) { + 'person' => $this->getPerson(), + 'role' => $this->getRole(), + 'status' => $this->getStatus(), + 'event' => $this->getEvent(), + default => throw new \LogicException("this offset does not exists : " . $offset), + }; } - /** - * @param mixed $offset - * @param mixed $value - * - * @return void - */ - public function offsetSet($offset, $value): void + public function offsetSet(mixed $offset, mixed $value): void { switch ($offset) { case 'person': @@ -256,10 +238,7 @@ class Participation implements ArrayAccess, HasCenterInterface, HasScopeInterfac } } - /** - * @param mixed $offset - */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { $this->offsetSet($offset, null); } diff --git a/src/Bundle/ChillEventBundle/Form/Type/PickEventType.php b/src/Bundle/ChillEventBundle/Form/Type/PickEventType.php index 05436b3e8..2bad90153 100644 --- a/src/Bundle/ChillEventBundle/Form/Type/PickEventType.php +++ b/src/Bundle/ChillEventBundle/Form/Type/PickEventType.php @@ -123,10 +123,7 @@ class PickEventType extends AbstractType ]); } - /** - * @return string|null - */ - public function getParent() + public function getParent(): ?string { return EntityType::class; } diff --git a/src/Bundle/ChillEventBundle/Search/EventSearch.php b/src/Bundle/ChillEventBundle/Search/EventSearch.php index a7ac22592..8a396e5cb 100644 --- a/src/Bundle/ChillEventBundle/Search/EventSearch.php +++ b/src/Bundle/ChillEventBundle/Search/EventSearch.php @@ -40,26 +40,6 @@ class EventSearch extends AbstractSearch { public const NAME = 'event_regular'; - /** - * @var EntityRepository - */ - private $er; - - /** - * @var AuthorizationHelper - */ - private $helper; - - /** - * @var PaginatorFactory - */ - private $paginationFactory; - - /** - * @var TemplatingEngine - */ - private $templating; - /** * @var \Chill\MainBundle\Entity\User */ @@ -67,16 +47,12 @@ class EventSearch extends AbstractSearch public function __construct( TokenStorageInterface $tokenStorage, - EntityRepository $eventRepository, - AuthorizationHelper $authorizationHelper, - TemplatingEngine $templating, - PaginatorFactory $paginatorFactory + private EntityRepository $er, + private AuthorizationHelper $helper, + private TemplatingEngine $templating, + private PaginatorFactory $paginationFactory ) { $this->user = $tokenStorage->getToken()->getUser(); - $this->er = $eventRepository; - $this->helper = $authorizationHelper; - $this->templating = $templating; - $this->paginationFactory = $paginatorFactory; } public function getOrder() diff --git a/src/Bundle/ChillEventBundle/Tests/Controller/ParticipationControllerTest.php b/src/Bundle/ChillEventBundle/Tests/Controller/ParticipationControllerTest.php index d61c1f385..d8766a9ee 100644 --- a/src/Bundle/ChillEventBundle/Tests/Controller/ParticipationControllerTest.php +++ b/src/Bundle/ChillEventBundle/Tests/Controller/ParticipationControllerTest.php @@ -446,12 +446,10 @@ final class ParticipationControllerTest extends WebTestCase } /** - * @param mixed $centerName - * @param mixed $circleName * * @return \Chill\EventBundle\Entity\Event */ - protected function getRandomEvent($centerName = 'Center A', $circleName = 'social') + protected function getRandomEvent(mixed $centerName = 'Center A', mixed $circleName = 'social') { $center = $this->em->getRepository(\Chill\MainBundle\Entity\Center::class) ->findByName($centerName); diff --git a/src/Bundle/ChillFamilyMembersBundle/Config/ConfigRepository.php b/src/Bundle/ChillFamilyMembersBundle/Config/ConfigRepository.php index 1d6ecae67..c361984f0 100644 --- a/src/Bundle/ChillFamilyMembersBundle/Config/ConfigRepository.php +++ b/src/Bundle/ChillFamilyMembersBundle/Config/ConfigRepository.php @@ -20,19 +20,18 @@ class ConfigRepository */ protected $familialSituations; - /** - * @var array - */ - protected $links; - /** * @var array */ protected $professionalSituations; - public function __construct($links, $professionnalSituations, $familialSituations) + /** + * @param mixed[] $links + * @param mixed $professionnalSituations + * @param mixed $familialSituations + */ + public function __construct(protected $links, $professionnalSituations, $familialSituations) { - $this->links = $links; $this->professionalSituations = $professionnalSituations ?? []; $this->familialSituations = $familialSituations ?? []; } diff --git a/src/Bundle/ChillFamilyMembersBundle/Controller/FamilyMemberController.php b/src/Bundle/ChillFamilyMembersBundle/Controller/FamilyMemberController.php index a6358a23d..5892ddbc4 100644 --- a/src/Bundle/ChillFamilyMembersBundle/Controller/FamilyMemberController.php +++ b/src/Bundle/ChillFamilyMembersBundle/Controller/FamilyMemberController.php @@ -28,23 +28,14 @@ use Symfony\Contracts\Translation\TranslatorInterface; class FamilyMemberController extends AbstractController { - protected LoggerInterface $chillMainLogger; - - protected TranslatorInterface $translator; - - private EntityManagerInterface $em; - private FamilyMemberRepository $familyMemberRepository; public function __construct( - EntityManagerInterface $entityManager, - TranslatorInterface $translator, - LoggerInterface $chillMainLogger, + private EntityManagerInterface $em, + protected TranslatorInterface $translator, + protected LoggerInterface $chillMainLogger, FamilyMemberRepository $familyMemberRepository ) { - $this->em = $entityManager; - $this->translator = $translator; - $this->chillMainLogger = $chillMainLogger; $this->familyMemberRepository = $familyMemberRepository; } diff --git a/src/Bundle/ChillFamilyMembersBundle/Form/FamilyMemberType.php b/src/Bundle/ChillFamilyMembersBundle/Form/FamilyMemberType.php index e082ef9c9..4c45691e5 100644 --- a/src/Bundle/ChillFamilyMembersBundle/Form/FamilyMemberType.php +++ b/src/Bundle/ChillFamilyMembersBundle/Form/FamilyMemberType.php @@ -25,22 +25,8 @@ use Symfony\Component\OptionsResolver\OptionsResolver; class FamilyMemberType extends AbstractType { - /** - * @var ConfigRepository - */ - private $configRepository; - - /** - * @var TranslatableStringHelper - */ - private $translatableStringHelper; - - public function __construct( - ConfigRepository $configRepository, - TranslatableStringHelper $translatableStringHelper - ) { - $this->configRepository = $configRepository; - $this->translatableStringHelper = $translatableStringHelper; + public function __construct(private ConfigRepository $configRepository, private TranslatableStringHelper $translatableStringHelper) + { } public function buildForm(FormBuilderInterface $builder, array $options) diff --git a/src/Bundle/ChillMainBundle/CRUD/Controller/AbstractCRUDController.php b/src/Bundle/ChillMainBundle/CRUD/Controller/AbstractCRUDController.php index 4bc9b4d79..56d62bb8a 100644 --- a/src/Bundle/ChillMainBundle/CRUD/Controller/AbstractCRUDController.php +++ b/src/Bundle/ChillMainBundle/CRUD/Controller/AbstractCRUDController.php @@ -36,11 +36,8 @@ abstract class AbstractCRUDController extends AbstractController /** * get the role given from the config. - * - * @param mixed $entity - * @param mixed $_format */ - protected function getRoleFor(string $action, Request $request, $entity, $_format): string + protected function getRoleFor(string $action, Request $request, mixed $entity, mixed $_format): string { $actionConfig = $this->getActionConfig($action); @@ -135,7 +132,7 @@ abstract class AbstractCRUDController extends AbstractController * * @param mixed $_format */ - protected function countEntities(string $action, Request $request, $_format): int + protected function countEntities(string $action, Request $request, mixed $_format): int { return $this->buildQueryEntities($action, $request) ->select('COUNT(e)') @@ -171,10 +168,8 @@ abstract class AbstractCRUDController extends AbstractController * get the instance of the entity with the given id. * * @throw Symfony\Component\HttpKernel\Exception\NotFoundHttpException if the object is not found - * - * @param mixed $action */ - protected function getEntity($action, string $id, Request $request): object + protected function getEntity(mixed $action, string $id, Request $request): object { $e = $this ->getDoctrine() @@ -205,10 +200,8 @@ abstract class AbstractCRUDController extends AbstractController /** * Get the result of the query. - * - * @param mixed $query */ - protected function getQueryResult(string $action, Request $request, string $_format, int $totalItems, PaginatorInterface $paginator, $query) + protected function getQueryResult(string $action, Request $request, string $_format, int $totalItems, PaginatorInterface $paginator, mixed $query) { return $query->getQuery()->getResult(); } @@ -220,41 +213,32 @@ abstract class AbstractCRUDController extends AbstractController /** * Called on post check ACL. - * - * @param mixed $entity */ - protected function onPostCheckACL(string $action, Request $request, string $_format, $entity): ?Response + protected function onPostCheckACL(string $action, Request $request, string $_format, mixed $entity): ?Response { return null; } /** * Called on post fetch entity. - * - * @param mixed $entity - * @param mixed $_format */ - protected function onPostFetchEntity(string $action, Request $request, $entity, $_format): ?Response + protected function onPostFetchEntity(string $action, Request $request, mixed $entity, mixed $_format): ?Response { return null; } /** * Method used by indexAction. - * - * @param mixed $query */ - protected function onPostIndexBuildQuery(string $action, Request $request, string $_format, int $totalItems, PaginatorInterface $paginator, $query): ?Response + protected function onPostIndexBuildQuery(string $action, Request $request, string $_format, int $totalItems, PaginatorInterface $paginator, mixed $query): ?Response { return null; } /** * Method used by indexAction. - * - * @param mixed $entities */ - protected function onPostIndexFetchQuery(string $action, Request $request, string $_format, int $totalItems, PaginatorInterface $paginator, $entities): ?Response + protected function onPostIndexFetchQuery(string $action, Request $request, string $_format, int $totalItems, PaginatorInterface $paginator, mixed $entities): ?Response { return null; } @@ -274,11 +258,8 @@ abstract class AbstractCRUDController extends AbstractController /** * Add ordering fields in the query build by self::queryEntities. - * - * @param mixed $query - * @param mixed $_format */ - protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator, $_format) + protected function orderQuery(string $action, mixed $query, Request $request, PaginatorInterface $paginator, mixed $_format) { return $query; } diff --git a/src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php b/src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php index 645f7525c..c18dfd542 100644 --- a/src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php +++ b/src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php @@ -32,31 +32,18 @@ class ApiController extends AbstractCRUDController /** * Base method for handling api action. * - * @param mixed $id * @param string $_format - * * @return void */ - public function entityApi(Request $request, $id, ?string $_format = 'json'): Response + public function entityApi(Request $request, mixed $id, ?string $_format = 'json'): Response { - switch ($request->getMethod()) { - case Request::METHOD_GET: - case Request::METHOD_HEAD: - return $this->entityGet('_entity', $request, $id, $_format); - - case Request::METHOD_PUT: - case Request::METHOD_PATCH: - return $this->entityPut('_entity', $request, $id, $_format); - - case Request::METHOD_POST: - return $this->entityPostAction('_entity', $request, $id); - - case Request::METHOD_DELETE: - return $this->entityDelete('_entity', $request, $id, $_format); - - default: - throw new BadRequestHttpException('This method is not implemented'); - } + return match ($request->getMethod()) { + Request::METHOD_GET, Request::METHOD_HEAD => $this->entityGet('_entity', $request, $id, $_format), + Request::METHOD_PUT, Request::METHOD_PATCH => $this->entityPut('_entity', $request, $id, $_format), + Request::METHOD_POST => $this->entityPostAction('_entity', $request, $id), + Request::METHOD_DELETE => $this->entityDelete('_entity', $request, $id, $_format), + default => throw new BadRequestHttpException('This method is not implemented'), + }; } public function entityDelete($action, Request $request, $id, string $_format): Response @@ -115,13 +102,10 @@ class ApiController extends AbstractCRUDController public function entityPost(Request $request, $_format): Response { - switch ($request->getMethod()) { - case Request::METHOD_POST: - return $this->entityPostAction('_entity', $request, $_format); - - default: - throw new BadRequestHttpException('This method is not implemented'); - } + return match ($request->getMethod()) { + Request::METHOD_POST => $this->entityPostAction('_entity', $request, $_format), + default => throw new BadRequestHttpException('This method is not implemented'), + }; } public function entityPut($action, Request $request, $id, string $_format): Response @@ -199,14 +183,10 @@ class ApiController extends AbstractCRUDController */ public function indexApi(Request $request, string $_format) { - switch ($request->getMethod()) { - case Request::METHOD_GET: - case REQUEST::METHOD_HEAD: - return $this->indexApiAction('_index', $request, $_format); - - default: - throw $this->createNotFoundException('This method is not supported'); - } + return match ($request->getMethod()) { + Request::METHOD_GET, REQUEST::METHOD_HEAD => $this->indexApiAction('_index', $request, $_format), + default => throw $this->createNotFoundException('This method is not supported'), + }; } public function onBeforeSerialize(string $action, Request $request, $_format, $entity): ?Response @@ -242,7 +222,7 @@ class ApiController extends AbstractCRUDController * @throw BadRequestException if unable to deserialize the posted data * @throw BadRequestException if the method is not POST or DELETE */ - protected function addRemoveSomething(string $action, $id, Request $request, string $_format, string $property, string $postedDataType, array $postedDataContext = [], bool $forcePersist = false): Response + protected function addRemoveSomething(string $action, mixed $id, Request $request, string $_format, string $property, string $postedDataType, array $postedDataContext = [], bool $forcePersist = false): Response { $entity = $this->getEntity($action, $id, $request); @@ -277,23 +257,11 @@ class ApiController extends AbstractCRUDController 'data: %s', $e->getMessage()), $e, 0); } - switch ($request->getMethod()) { - case Request::METHOD_DELETE: - // oups... how to use property accessor to remove element ? - /* @phpstan-ignore-next-line as we do not find a simpler way to do this */ - $entity->{'remove' . ucfirst($property)}($postedData); - - break; - - case Request::METHOD_POST: - /* @phpstan-ignore-next-line as we do not find a simpler way to do this */ - $entity->{'add' . ucfirst($property)}($postedData); - - break; - - default: - throw new BadRequestHttpException('this method is not supported'); - } + match ($request->getMethod()) { + Request::METHOD_DELETE => $entity->{'remove' . ucfirst($property)}($postedData), + Request::METHOD_POST => $entity->{'add' . ucfirst($property)}($postedData), + default => throw new BadRequestHttpException('this method is not supported'), + }; $errors = $this->validate($action, $request, $_format, $entity, [$postedData]); @@ -319,21 +287,16 @@ class ApiController extends AbstractCRUDController if ($response instanceof Response) { return $response; } - - switch ($request->getMethod()) { - case Request::METHOD_DELETE: - return $this->json('', Response::HTTP_OK); - - case Request::METHOD_POST: - return $this->json( - $postedData, - Response::HTTP_OK, - [], - $this->getContextForSerializationPostAlter($action, $request, $_format, $entity, [$postedData]) - ); - } - - throw new Exception('Unable to handle such request method.'); + return match ($request->getMethod()) { + Request::METHOD_DELETE => $this->json('', Response::HTTP_OK), + Request::METHOD_POST => $this->json( + $postedData, + Response::HTTP_OK, + [], + $this->getContextForSerializationPostAlter($action, $request, $_format, $entity, [$postedData]) + ), + default => throw new Exception('Unable to handle such request method.'), + }; } /** @@ -376,7 +339,7 @@ class ApiController extends AbstractCRUDController * @param mixed $id * @param mixed $_format */ - protected function entityGet(string $action, Request $request, $id, $_format = 'html'): Response + protected function entityGet(string $action, Request $request, mixed $id, mixed $_format = 'html'): Response { $entity = $this->getEntity($action, $id, $request); @@ -474,18 +437,11 @@ class ApiController extends AbstractCRUDController protected function getContextForSerialization(string $action, Request $request, string $_format, $entity): array { - switch ($request->getMethod()) { - case Request::METHOD_GET: - return ['groups' => ['read']]; - - case Request::METHOD_PUT: - case Request::METHOD_PATCH: - case Request::METHOD_POST: - return ['groups' => ['write']]; - - default: - throw new LogicException('get context for serialization is not implemented for this method'); - } + return match ($request->getMethod()) { + Request::METHOD_GET => ['groups' => ['read']], + Request::METHOD_PUT, Request::METHOD_PATCH, Request::METHOD_POST => ['groups' => ['write']], + default => throw new LogicException('get context for serialization is not implemented for this method'), + }; } /** @@ -496,7 +452,7 @@ class ApiController extends AbstractCRUDController * * @param mixed $entity */ - protected function getContextForSerializationPostAlter(string $action, Request $request, string $_format, $entity, array $more = []): array + protected function getContextForSerializationPostAlter(string $action, Request $request, string $_format, mixed $entity, array $more = []): array { return ['groups' => ['read']]; } @@ -533,7 +489,7 @@ class ApiController extends AbstractCRUDController * @param string $action * @param mixed $_format */ - protected function indexApiAction($action, Request $request, $_format) + protected function indexApiAction($action, Request $request, mixed $_format) { $this->onPreIndex($action, $request, $_format); @@ -611,10 +567,8 @@ class ApiController extends AbstractCRUDController /** * Serialize collections. - * - * @param mixed $entities */ - protected function serializeCollection(string $action, Request $request, string $_format, PaginatorInterface $paginator, $entities): Response + protected function serializeCollection(string $action, Request $request, string $_format, PaginatorInterface $paginator, mixed $entities): Response { $model = new Collection($entities, $paginator); diff --git a/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php b/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php index 730ac32c1..4f7f3b5f9 100644 --- a/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php +++ b/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php @@ -62,17 +62,15 @@ class CRUDController extends AbstractController * * @param mixed $id */ - public function edit(Request $request, $id): Response + public function edit(Request $request, mixed $id): Response { return $this->formEditAction('edit', $request, $id); } /** * Get the context for the serialization. - * - * @param mixed $entity */ - public function getContextForSerialization(string $action, Request $request, $entity, string $_format): array + public function getContextForSerialization(string $action, Request $request, mixed $entity, string $_format): array { return []; } @@ -125,7 +123,7 @@ class CRUDController extends AbstractController * * @param mixed $id */ - public function view(Request $request, $id): Response + public function view(Request $request, mixed $id): Response { return $this->viewAction('view', $request, $id); } @@ -188,7 +186,7 @@ class CRUDController extends AbstractController * * @throws \Symfony\Component\Security\Core\Exception\AccessDeniedHttpException */ - protected function checkACL(string $action, $entity) + protected function checkACL(string $action, mixed $entity) { $this->denyAccessUnlessGranted($this->getRoleFor($action), $entity); } @@ -228,7 +226,7 @@ class CRUDController extends AbstractController * @param mixed $entity * @param string $formClass */ - protected function createFormFor(string $action, $entity, ?string $formClass = null, array $formOptions = []): FormInterface + protected function createFormFor(string $action, mixed $entity, ?string $formClass = null, array $formOptions = []): FormInterface { $formClass ??= $this->getFormClassFor($action); @@ -491,7 +489,7 @@ class CRUDController extends AbstractController * * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException */ - protected function formEditAction(string $action, Request $request, $id, ?string $formClass = null, array $formOptions = []): Response + protected function formEditAction(string $action, Request $request, mixed $id, ?string $formClass = null, array $formOptions = []): Response { $entity = $this->getEntity($action, $id, $request); @@ -572,29 +570,15 @@ class CRUDController extends AbstractController * Generate a success message when a form could be flushed successfully. * * @param string $action - * @param mixed $entity */ - protected function generateFormSuccessMessage($action, $entity): string + protected function generateFormSuccessMessage($action, mixed $entity): string { - switch ($action) { - case 'edit': - $msg = 'crud.edit.success'; - - break; - - case 'new': - $msg = 'crud.new.success'; - - break; - - case 'delete': - $msg = 'crud.delete.success'; - - break; - - default: - $msg = 'crud.default.success'; - } + $msg = match ($action) { + 'edit' => 'crud.edit.success', + 'new' => 'crud.new.success', + 'delete' => 'crud.delete.success', + default => 'crud.default.success', + }; return $this->getTranslator()->trans($msg); } @@ -652,11 +636,10 @@ class CRUDController extends AbstractController * get the instance of the entity with the given id. * * @param string $id - * @param mixed $action * * @return object */ - protected function getEntity($action, $id, Request $request): ?object + protected function getEntity(mixed $action, $id, Request $request): ?object { return $this->getDoctrine() ->getRepository($this->getEntityClass()) @@ -763,33 +746,22 @@ class CRUDController extends AbstractController * * @return string the path to the template */ - protected function getTemplateFor($action, $entity, Request $request) + protected function getTemplateFor($action, mixed $entity, Request $request) { if ($this->hasCustomTemplate($action, $entity, $request)) { return $this->getActionConfig($action)['template']; } - switch ($action) { - case 'new': - return '@ChillMain/CRUD/new.html.twig'; - - case 'edit': - return '@ChillMain/CRUD/edit.html.twig'; - - case 'index': - return '@ChillMain/CRUD/index.html.twig'; - - case 'view': - return '@ChillMain/CRUD/view.html.twig'; - - case 'delete': - return '@ChillMain/CRUD/delete.html.twig'; - - default: - throw new LogicException("the view for action {$action} is not " - . 'defined. You should override ' . __METHOD__ . ' to add this ' - . 'action'); - } + return match ($action) { + 'new' => '@ChillMain/CRUD/new.html.twig', + 'edit' => '@ChillMain/CRUD/edit.html.twig', + 'index' => '@ChillMain/CRUD/index.html.twig', + 'view' => '@ChillMain/CRUD/view.html.twig', + 'delete' => '@ChillMain/CRUD/delete.html.twig', + default => throw new LogicException("the view for action {$action} is not " + . 'defined. You should override ' . __METHOD__ . ' to add this ' + . 'action'), + }; } protected function getTranslator(): TranslatorInterface @@ -909,22 +881,17 @@ class CRUDController extends AbstractController * * @return \Symfony\Component\HttpFoundation\RedirectResponse */ - protected function onBeforeRedirectAfterSubmission(string $action, $entity, FormInterface $form, Request $request) + protected function onBeforeRedirectAfterSubmission(string $action, mixed $entity, FormInterface $form, Request $request) { $next = $request->request->get('submit', 'save-and-close'); - switch ($next) { - case 'save-and-close': - return $this->redirectToRoute('chill_crud_' . $this->getCrudName() . '_index'); - - case 'save-and-new': - return $this->redirectToRoute('chill_crud_' . $this->getCrudName() . '_new', $request->query->all()); - - default: - return $this->redirectToRoute('chill_crud_' . $this->getCrudName() . '_view', [ - 'id' => $entity->getId(), - ]); - } + return match ($next) { + 'save-and-close' => $this->redirectToRoute('chill_crud_' . $this->getCrudName() . '_index'), + 'save-and-new' => $this->redirectToRoute('chill_crud_' . $this->getCrudName() . '_new', $request->query->all()), + default => $this->redirectToRoute('chill_crud_' . $this->getCrudName() . '_view', [ + 'id' => $entity->getId(), + ]), + }; } protected function onFormValid(string $action, object $entity, FormInterface $form, Request $request) @@ -958,19 +925,15 @@ class CRUDController extends AbstractController /** * method used by indexAction. - * - * @param mixed $query */ - protected function onPostIndexBuildQuery(string $action, Request $request, int $totalItems, PaginatorInterface $paginator, $query) + protected function onPostIndexBuildQuery(string $action, Request $request, int $totalItems, PaginatorInterface $paginator, mixed $query) { } /** * method used by indexAction. - * - * @param mixed $entities */ - protected function onPostIndexFetchQuery(string $action, Request $request, int $totalItems, PaginatorInterface $paginator, $entities) + protected function onPostIndexFetchQuery(string $action, Request $request, int $totalItems, PaginatorInterface $paginator, mixed $entities) { } @@ -1091,7 +1054,7 @@ class CRUDController extends AbstractController * @param mixed $id * @param mixed $_format */ - protected function viewAction(string $action, Request $request, $id, $_format = 'html'): Response + protected function viewAction(string $action, Request $request, mixed $id, mixed $_format = 'html'): Response { $entity = $this->getEntity($action, $id, $request); diff --git a/src/Bundle/ChillMainBundle/CRUD/Routing/CRUDRoutesLoader.php b/src/Bundle/ChillMainBundle/CRUD/Routing/CRUDRoutesLoader.php index 4fbf5961d..f77113579 100644 --- a/src/Bundle/ChillMainBundle/CRUD/Routing/CRUDRoutesLoader.php +++ b/src/Bundle/ChillMainBundle/CRUD/Routing/CRUDRoutesLoader.php @@ -36,17 +36,10 @@ class CRUDRoutesLoader extends Loader Request::METHOD_DELETE, ]; - protected array $apiCrudConfig = []; - - protected array $crudConfig = []; - private bool $isLoaded = false; - public function __construct(array $crudConfig, array $apiCrudConfig) + public function __construct(protected array $crudConfig, protected array $apiCrudConfig) { - $this->crudConfig = $crudConfig; - $this->apiCrudConfig = $apiCrudConfig; - parent::__construct(); } @@ -104,23 +97,11 @@ class CRUDRoutesLoader extends Loader // continue; } - // compute default action - switch ($name) { - case '_entity': - $controllerAction = 'entityApi'; - - break; - - case '_index': - $controllerAction = 'indexApi'; - - break; - - default: - $controllerAction = $name . 'Api'; - - break; - } + $controllerAction = match ($name) { + '_entity' => 'entityApi', + '_index' => 'indexApi', + default => $name . 'Api', + }; $defaults = [ '_controller' => $controller . ':' . ($action['controller_action'] ?? $controllerAction), diff --git a/src/Bundle/ChillMainBundle/Command/ChillImportUsersCommand.php b/src/Bundle/ChillMainBundle/Command/ChillImportUsersCommand.php index e6f49c6b5..d4c3dcb42 100644 --- a/src/Bundle/ChillMainBundle/Command/ChillImportUsersCommand.php +++ b/src/Bundle/ChillMainBundle/Command/ChillImportUsersCommand.php @@ -53,39 +53,23 @@ class ChillImportUsersCommand extends Command protected bool $doChanges = true; - protected EntityManagerInterface $em; - protected array $groupCenters; - protected LoggerInterface $logger; - protected Writer $output; - protected UserPasswordEncoderInterface $passwordEncoder; - protected array $permissionGroups; protected InputInterface $tempInput; protected OutputInterface $tempOutput; - protected UserRepository $userRepository; - - protected ValidatorInterface $validator; - public function __construct( - EntityManagerInterface $em, - LoggerInterface $logger, - UserPasswordEncoderInterface $passwordEncoder, - ValidatorInterface $validator, - UserRepository $userRepository + protected EntityManagerInterface $em, + protected LoggerInterface $logger, + protected UserPasswordEncoderInterface $passwordEncoder, + protected ValidatorInterface $validator, + protected UserRepository $userRepository ) { - $this->em = $em; - $this->passwordEncoder = $passwordEncoder; - $this->validator = $validator; - $this->logger = $logger; - $this->userRepository = $userRepository; - parent::__construct('chill:main:import-users'); } diff --git a/src/Bundle/ChillMainBundle/Command/ChillUserSendRenewPasswordCodeCommand.php b/src/Bundle/ChillMainBundle/Command/ChillUserSendRenewPasswordCodeCommand.php index ce8196aa4..5f62d39ed 100644 --- a/src/Bundle/ChillMainBundle/Command/ChillUserSendRenewPasswordCodeCommand.php +++ b/src/Bundle/ChillMainBundle/Command/ChillUserSendRenewPasswordCodeCommand.php @@ -162,7 +162,7 @@ class ChillUserSendRenewPasswordCodeCommand extends Command if (array_key_exists('email', $row)) { return $userRepository->findOneByUsernameOrEmail(trim($row['email'])); } - } catch (\Doctrine\ORM\NoResultException $e) { + } catch (\Doctrine\ORM\NoResultException) { // continue, we will try username } @@ -170,7 +170,7 @@ class ChillUserSendRenewPasswordCodeCommand extends Command if (array_key_exists('username', $row)) { return $userRepository->findOneByUsernameOrEmail(trim($row['username'])); } - } catch (\Doctrine\ORM\NoResultException $e) { + } catch (\Doctrine\ORM\NoResultException) { return null; } } diff --git a/src/Bundle/ChillMainBundle/Command/ExecuteCronJobCommand.php b/src/Bundle/ChillMainBundle/Command/ExecuteCronJobCommand.php index 0e81177dc..e2d7bd6dd 100644 --- a/src/Bundle/ChillMainBundle/Command/ExecuteCronJobCommand.php +++ b/src/Bundle/ChillMainBundle/Command/ExecuteCronJobCommand.php @@ -19,14 +19,10 @@ use Symfony\Component\Console\Output\OutputInterface; class ExecuteCronJobCommand extends Command { - private CronManagerInterface $cronManager; - public function __construct( - CronManagerInterface $cronManager + private CronManagerInterface $cronManager ) { parent::__construct('chill:cron-job:execute'); - - $this->cronManager = $cronManager; } protected function configure() diff --git a/src/Bundle/ChillMainBundle/Command/LoadAddressesBEFromBestAddressCommand.php b/src/Bundle/ChillMainBundle/Command/LoadAddressesBEFromBestAddressCommand.php index cc26b7687..0335f11ee 100644 --- a/src/Bundle/ChillMainBundle/Command/LoadAddressesBEFromBestAddressCommand.php +++ b/src/Bundle/ChillMainBundle/Command/LoadAddressesBEFromBestAddressCommand.php @@ -20,17 +20,11 @@ use Symfony\Component\Console\Output\OutputInterface; class LoadAddressesBEFromBestAddressCommand extends Command { - private AddressReferenceBEFromBestAddress $addressImporter; - - private PostalCodeBEFromBestAddress $postalCodeBEFromBestAddressImporter; - public function __construct( - AddressReferenceBEFromBestAddress $addressImporter, - PostalCodeBEFromBestAddress $postalCodeBEFromBestAddressImporter + private AddressReferenceBEFromBestAddress $addressImporter, + private PostalCodeBEFromBestAddress $postalCodeBEFromBestAddressImporter ) { parent::__construct(); - $this->addressImporter = $addressImporter; - $this->postalCodeBEFromBestAddressImporter = $postalCodeBEFromBestAddressImporter; } protected function configure() diff --git a/src/Bundle/ChillMainBundle/Command/LoadAddressesFRFromBANOCommand.php b/src/Bundle/ChillMainBundle/Command/LoadAddressesFRFromBANOCommand.php index 40772d52b..732355a44 100644 --- a/src/Bundle/ChillMainBundle/Command/LoadAddressesFRFromBANOCommand.php +++ b/src/Bundle/ChillMainBundle/Command/LoadAddressesFRFromBANOCommand.php @@ -19,12 +19,9 @@ use Symfony\Component\Console\Output\OutputInterface; class LoadAddressesFRFromBANOCommand extends Command { - private AddressReferenceFromBano $addressReferenceFromBano; - - public function __construct(AddressReferenceFromBano $addressReferenceFromBano) + public function __construct(private AddressReferenceFromBano $addressReferenceFromBano) { parent::__construct(); - $this->addressReferenceFromBano = $addressReferenceFromBano; } protected function configure() diff --git a/src/Bundle/ChillMainBundle/Command/LoadAndUpdateLanguagesCommand.php b/src/Bundle/ChillMainBundle/Command/LoadAndUpdateLanguagesCommand.php index 8c5351b07..702a71403 100644 --- a/src/Bundle/ChillMainBundle/Command/LoadAndUpdateLanguagesCommand.php +++ b/src/Bundle/ChillMainBundle/Command/LoadAndUpdateLanguagesCommand.php @@ -34,13 +34,6 @@ class LoadAndUpdateLanguagesCommand extends Command private $ancientToExclude = ['ang', 'egy', 'fro', 'goh', 'grc', 'la', 'non', 'peo', 'pro', 'sga', 'dum', 'enm', 'frm', 'gmh', 'mga', 'akk', 'phn', 'zxx', 'got', 'und', ]; - private $availableLanguages; - - /** - * @var EntityManager - */ - private $entityManager; - // The regional version of language are language with _ in the code // This array contains regional code to not exclude private $regionalVersionToInclude = ['ro_MD']; @@ -50,10 +43,8 @@ class LoadAndUpdateLanguagesCommand extends Command * * @param $availableLanguages */ - public function __construct(EntityManager $entityManager, $availableLanguages) + public function __construct(private EntityManager $entityManager, private $availableLanguages) { - $this->entityManager = $entityManager; - $this->availableLanguages = $availableLanguages; parent::__construct(); } diff --git a/src/Bundle/ChillMainBundle/Command/LoadCountriesCommand.php b/src/Bundle/ChillMainBundle/Command/LoadCountriesCommand.php index 1dd5a603f..01400a9ad 100644 --- a/src/Bundle/ChillMainBundle/Command/LoadCountriesCommand.php +++ b/src/Bundle/ChillMainBundle/Command/LoadCountriesCommand.php @@ -20,22 +20,13 @@ use Symfony\Component\Intl\Intl; class LoadCountriesCommand extends Command { - private $availableLanguages; - - /** - * @var EntityManager - */ - private $entityManager; - /** * LoadCountriesCommand constructor. * * @param $availableLanguages */ - public function __construct(EntityManager $entityManager, $availableLanguages) + public function __construct(private EntityManager $entityManager, private $availableLanguages) { - $this->entityManager = $entityManager; - $this->availableLanguages = $availableLanguages; parent::__construct(); } diff --git a/src/Bundle/ChillMainBundle/Command/LoadPostalCodeFR.php b/src/Bundle/ChillMainBundle/Command/LoadPostalCodeFR.php index 522c36305..6d1999127 100644 --- a/src/Bundle/ChillMainBundle/Command/LoadPostalCodeFR.php +++ b/src/Bundle/ChillMainBundle/Command/LoadPostalCodeFR.php @@ -18,12 +18,8 @@ use Symfony\Component\Console\Output\OutputInterface; class LoadPostalCodeFR extends Command { - private PostalCodeFRFromOpenData $loader; - - public function __construct(PostalCodeFRFromOpenData $loader) + public function __construct(private PostalCodeFRFromOpenData $loader) { - $this->loader = $loader; - parent::__construct(); } diff --git a/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php b/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php index ea42fde78..208f67cab 100644 --- a/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php +++ b/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php @@ -30,14 +30,8 @@ use function strlen; class LoadPostalCodesCommand extends Command { - private EntityManagerInterface $entityManager; - - private ValidatorInterface $validator; - - public function __construct(EntityManagerInterface $entityManager, ValidatorInterface $validator) + public function __construct(private EntityManagerInterface $entityManager, private ValidatorInterface $validator) { - $this->entityManager = $entityManager; - $this->validator = $validator; parent::__construct(); } diff --git a/src/Bundle/ChillMainBundle/Command/SetPasswordCommand.php b/src/Bundle/ChillMainBundle/Command/SetPasswordCommand.php index 1a570c3a9..16619bf54 100644 --- a/src/Bundle/ChillMainBundle/Command/SetPasswordCommand.php +++ b/src/Bundle/ChillMainBundle/Command/SetPasswordCommand.php @@ -26,17 +26,11 @@ use Symfony\Component\Security\Core\Encoder\MessageDigestPasswordEncoder; */ class SetPasswordCommand extends Command { - /** - * @var EntityManager - */ - private $entityManager; - /** * SetPasswordCommand constructor. */ - public function __construct(EntityManager $entityManager) + public function __construct(private EntityManager $entityManager) { - $this->entityManager = $entityManager; parent::__construct(); } diff --git a/src/Bundle/ChillMainBundle/Controller/AddressReferenceAPIController.php b/src/Bundle/ChillMainBundle/Controller/AddressReferenceAPIController.php index 68f6f7f1d..68a0afdb6 100644 --- a/src/Bundle/ChillMainBundle/Controller/AddressReferenceAPIController.php +++ b/src/Bundle/ChillMainBundle/Controller/AddressReferenceAPIController.php @@ -28,14 +28,8 @@ use function trim; final class AddressReferenceAPIController extends ApiController { - private AddressReferenceRepository $addressReferenceRepository; - - private PaginatorFactory $paginatorFactory; - - public function __construct(AddressReferenceRepository $addressReferenceRepository, PaginatorFactory $paginatorFactory) + public function __construct(private AddressReferenceRepository $addressReferenceRepository, private PaginatorFactory $paginatorFactory) { - $this->addressReferenceRepository = $addressReferenceRepository; - $this->paginatorFactory = $paginatorFactory; } /** diff --git a/src/Bundle/ChillMainBundle/Controller/AddressToReferenceMatcherController.php b/src/Bundle/ChillMainBundle/Controller/AddressToReferenceMatcherController.php index aab63aea3..fc92cd299 100644 --- a/src/Bundle/ChillMainBundle/Controller/AddressToReferenceMatcherController.php +++ b/src/Bundle/ChillMainBundle/Controller/AddressToReferenceMatcherController.php @@ -23,20 +23,8 @@ use Symfony\Component\Serializer\SerializerInterface; class AddressToReferenceMatcherController { - private Security $security; - - private EntityManagerInterface $entityManager; - - private SerializerInterface $serializer; - - public function __construct( - Security $security, - EntityManagerInterface $entityManager, - SerializerInterface $serializer - ) { - $this->security = $security; - $this->entityManager = $entityManager; - $this->serializer = $serializer; + public function __construct(private Security $security, private EntityManagerInterface $entityManager, private SerializerInterface $serializer) + { } /** diff --git a/src/Bundle/ChillMainBundle/Controller/CenterController.php b/src/Bundle/ChillMainBundle/Controller/CenterController.php index 64d9a4527..af31c67ea 100644 --- a/src/Bundle/ChillMainBundle/Controller/CenterController.php +++ b/src/Bundle/ChillMainBundle/Controller/CenterController.php @@ -47,10 +47,8 @@ class CenterController extends AbstractController /** * Displays a form to edit an existing Center entity. - * - * @param mixed $id */ - public function editAction($id) + public function editAction(mixed $id) { $em = $this->getDoctrine()->getManager(); @@ -98,10 +96,8 @@ class CenterController extends AbstractController /** * Finds and displays a Center entity. - * - * @param mixed $id */ - public function showAction($id) + public function showAction(mixed $id) { $em = $this->getDoctrine()->getManager(); @@ -118,10 +114,8 @@ class CenterController extends AbstractController /** * Edits an existing Center entity. - * - * @param mixed $id */ - public function updateAction(Request $request, $id) + public function updateAction(Request $request, mixed $id) { $em = $this->getDoctrine()->getManager(); diff --git a/src/Bundle/ChillMainBundle/Controller/ExportController.php b/src/Bundle/ChillMainBundle/Controller/ExportController.php index 6c4ea0269..9e62cacf6 100644 --- a/src/Bundle/ChillMainBundle/Controller/ExportController.php +++ b/src/Bundle/ChillMainBundle/Controller/ExportController.php @@ -47,54 +47,8 @@ use function unserialize; */ class ExportController extends AbstractController { - private EntityManagerInterface $entityManager; - - /** - * @var ExportManager - */ - private $exportManager; - - /** - * @var FormFactoryInterface - */ - private $formFactory; - - /** - * @var LoggerInterface - */ - private $logger; - - /** - * @var ChillRedis - */ - private $redis; - - /** - * @var SessionInterface - */ - private $session; - - /** - * @var TranslatorInterface - */ - private $translator; - - public function __construct( - ChillRedis $chillRedis, - ExportManager $exportManager, - FormFactoryInterface $formFactory, - LoggerInterface $logger, - SessionInterface $session, - TranslatorInterface $translator, - EntityManagerInterface $entityManager - ) { - $this->entityManager = $entityManager; - $this->redis = $chillRedis; - $this->exportManager = $exportManager; - $this->formFactory = $formFactory; - $this->logger = $logger; - $this->session = $session; - $this->translator = $translator; + public function __construct(private ChillRedis $redis, private ExportManager $exportManager, private FormFactoryInterface $formFactory, private LoggerInterface $logger, private SessionInterface $session, private TranslatorInterface $translator, private EntityManagerInterface $entityManager) + { } public function downloadResultAction(Request $request, $alias) @@ -221,22 +175,13 @@ class ExportController extends AbstractController $step = $request->query->getAlpha('step', 'centers'); - switch ($step) { - case 'centers': - return $this->selectCentersStep($request, $export, $alias); - - case 'export': - return $this->exportFormStep($request, $export, $alias); - - case 'formatter': - return $this->formatterFormStep($request, $export, $alias); - - case 'generate': - return $this->forwardToGenerate($request, $export, $alias); - - default: - throw $this->createNotFoundException("The given step '{$step}' is invalid"); - } + return match ($step) { + 'centers' => $this->selectCentersStep($request, $export, $alias), + 'export' => $this->exportFormStep($request, $export, $alias), + 'formatter' => $this->formatterFormStep($request, $export, $alias), + 'generate' => $this->forwardToGenerate($request, $export, $alias), + default => throw $this->createNotFoundException("The given step '{$step}' is invalid"), + }; } /** @@ -284,13 +229,12 @@ class ExportController extends AbstractController * * @param string $alias * @param array $data the data from previous step. Required for steps 'formatter' and 'generate_formatter' - * @param mixed $step */ - protected function createCreateFormExport($alias, $step, $data = []): FormInterface + protected function createCreateFormExport($alias, mixed $step, $data = []): FormInterface { /** @var \Chill\MainBundle\Export\ExportManager $exportManager */ $exportManager = $this->exportManager; - $isGenerate = strpos($step, 'generate_') === 0; + $isGenerate = str_starts_with($step, 'generate_'); $builder = $this->formFactory ->createNamedBuilder(null, FormType::class, [], [ @@ -341,7 +285,7 @@ class ExportController extends AbstractController * * @return \Symfony\Component\HttpFoundation\Response */ - protected function exportFormStep(Request $request, $export, $alias) + protected function exportFormStep(Request $request, \Chill\MainBundle\Export\DirectExportInterface|\Chill\MainBundle\Export\ExportInterface $export, $alias) { $exportManager = $this->exportManager; @@ -405,7 +349,7 @@ class ExportController extends AbstractController * * @return \Symfony\Component\HttpFoundation\Response */ - protected function formatterFormStep(Request $request, $export, $alias) + protected function formatterFormStep(Request $request, \Chill\MainBundle\Export\DirectExportInterface|\Chill\MainBundle\Export\ExportInterface $export, $alias) { // check we have data from the previous step (export step) $data = $this->session->get('export_step', null); @@ -462,7 +406,7 @@ class ExportController extends AbstractController * * @return \Symfony\Component\HttpFoundation\RedirectResponse */ - protected function forwardToGenerate(Request $request, $export, $alias) + protected function forwardToGenerate(Request $request, \Chill\MainBundle\Export\DirectExportInterface|\Chill\MainBundle\Export\ExportInterface $export, $alias) { $dataCenters = $this->session->get('centers_step_raw', null); $dataFormatter = $this->session->get('formatter_step_raw', null); @@ -522,12 +466,10 @@ class ExportController extends AbstractController } /** - * @param \Chill\MainBundle\Export\DirectExportInterface|\Chill\MainBundle\Export\ExportInterface $export * @param string $alias - * * @return Response */ - protected function selectCentersStep(Request $request, $export, $alias) + protected function selectCentersStep(Request $request, \Chill\MainBundle\Export\DirectExportInterface|\Chill\MainBundle\Export\ExportInterface $export, $alias) { /** @var \Chill\MainBundle\Export\ExportManager $exportManager */ $exportManager = $this->exportManager; @@ -608,7 +550,7 @@ class ExportController extends AbstractController * * @return string the next/current step */ - private function getNextStep($step, $export, $reverse = false) + private function getNextStep($step, \Chill\MainBundle\Export\DirectExportInterface|\Chill\MainBundle\Export\ExportInterface $export, $reverse = false) { switch ($step) { case 'centers': diff --git a/src/Bundle/ChillMainBundle/Controller/GeographicalUnitByAddressApiController.php b/src/Bundle/ChillMainBundle/Controller/GeographicalUnitByAddressApiController.php index 988439de5..6ab4a6e3e 100644 --- a/src/Bundle/ChillMainBundle/Controller/GeographicalUnitByAddressApiController.php +++ b/src/Bundle/ChillMainBundle/Controller/GeographicalUnitByAddressApiController.php @@ -24,30 +24,8 @@ use Symfony\Component\Serializer\SerializerInterface; class GeographicalUnitByAddressApiController { - private PaginatorFactory $paginatorFactory; - - private GeographicalUnitRepositoryInterface $geographicalUnitRepository; - - private Security $security; - - private SerializerInterface $serializer; - - /** - * @param PaginatorFactory $paginatorFactory - * @param GeographicalUnitRepositoryInterface $geographicalUnitRepository - * @param Security $security - * @param SerializerInterface $serializer - */ - public function __construct( - PaginatorFactory $paginatorFactory, - GeographicalUnitRepositoryInterface $geographicalUnitRepository, - Security $security, - SerializerInterface $serializer - ) { - $this->paginatorFactory = $paginatorFactory; - $this->geographicalUnitRepository = $geographicalUnitRepository; - $this->security = $security; - $this->serializer = $serializer; + public function __construct(private PaginatorFactory $paginatorFactory, private GeographicalUnitRepositoryInterface $geographicalUnitRepository, private Security $security, private SerializerInterface $serializer) + { } /** diff --git a/src/Bundle/ChillMainBundle/Controller/NotificationApiController.php b/src/Bundle/ChillMainBundle/Controller/NotificationApiController.php index 62a1dd10c..52810cd97 100644 --- a/src/Bundle/ChillMainBundle/Controller/NotificationApiController.php +++ b/src/Bundle/ChillMainBundle/Controller/NotificationApiController.php @@ -33,28 +33,8 @@ use UnexpectedValueException; */ class NotificationApiController { - private EntityManagerInterface $entityManager; - - private NotificationRepository $notificationRepository; - - private PaginatorFactory $paginatorFactory; - - private Security $security; - - private SerializerInterface $serializer; - - public function __construct( - EntityManagerInterface $entityManager, - NotificationRepository $notificationRepository, - PaginatorFactory $paginatorFactory, - Security $security, - SerializerInterface $serializer - ) { - $this->entityManager = $entityManager; - $this->notificationRepository = $notificationRepository; - $this->paginatorFactory = $paginatorFactory; - $this->security = $security; - $this->serializer = $serializer; + public function __construct(private EntityManagerInterface $entityManager, private NotificationRepository $notificationRepository, private PaginatorFactory $paginatorFactory, private Security $security, private SerializerInterface $serializer) + { } /** @@ -116,20 +96,11 @@ class NotificationApiController throw new RuntimeException('not possible to mark as read by this user'); } - switch ($target) { - case 'read': - $notification->markAsReadBy($user); - - break; - - case 'unread': - $notification->markAsUnreadBy($user); - - break; - - default: - throw new UnexpectedValueException("target not supported: {$target}"); - } + match ($target) { + 'read' => $notification->markAsReadBy($user), + 'unread' => $notification->markAsUnreadBy($user), + default => throw new UnexpectedValueException("target not supported: {$target}"), + }; $this->entityManager->flush(); diff --git a/src/Bundle/ChillMainBundle/Controller/NotificationController.php b/src/Bundle/ChillMainBundle/Controller/NotificationController.php index 327a06df6..d2d37ad77 100644 --- a/src/Bundle/ChillMainBundle/Controller/NotificationController.php +++ b/src/Bundle/ChillMainBundle/Controller/NotificationController.php @@ -41,44 +41,8 @@ use function in_array; */ class NotificationController extends AbstractController { - private LoggerInterface $chillLogger; - - private EntityManagerInterface $em; - - private LoggerInterface $logger; - - private NotificationHandlerManager $notificationHandlerManager; - - private NotificationRepository $notificationRepository; - - private PaginatorFactory $paginatorFactory; - - private Security $security; - - private TranslatorInterface $translator; - - private UserRepository $userRepository; - - public function __construct( - EntityManagerInterface $em, - LoggerInterface $chillLogger, - LoggerInterface $logger, - Security $security, - NotificationRepository $notificationRepository, - NotificationHandlerManager $notificationHandlerManager, - PaginatorFactory $paginatorFactory, - TranslatorInterface $translator, - UserRepository $userRepository - ) { - $this->em = $em; - $this->logger = $logger; - $this->chillLogger = $chillLogger; - $this->security = $security; - $this->notificationRepository = $notificationRepository; - $this->notificationHandlerManager = $notificationHandlerManager; - $this->paginatorFactory = $paginatorFactory; - $this->translator = $translator; - $this->userRepository = $userRepository; + public function __construct(private EntityManagerInterface $em, private LoggerInterface $chillLogger, private LoggerInterface $logger, private Security $security, private NotificationRepository $notificationRepository, private NotificationHandlerManager $notificationHandlerManager, private PaginatorFactory $paginatorFactory, private TranslatorInterface $translator, private UserRepository $userRepository) + { } /** @@ -117,7 +81,7 @@ class NotificationController extends AbstractController try { $handler = $this->notificationHandlerManager->getHandler($notification); - } catch (NotificationHandlerNotFound $e) { + } catch (NotificationHandlerNotFound) { throw new BadRequestHttpException('no handler for this notification'); } diff --git a/src/Bundle/ChillMainBundle/Controller/PasswordController.php b/src/Bundle/ChillMainBundle/Controller/PasswordController.php index a9a14b7a1..0151d403e 100644 --- a/src/Bundle/ChillMainBundle/Controller/PasswordController.php +++ b/src/Bundle/ChillMainBundle/Controller/PasswordController.php @@ -96,7 +96,7 @@ class PasswordController extends AbstractController /** * @return Response|\Symfony\Component\HttpFoundation\RedirectResponse */ - public function recoverAction(Request $request) + public function recoverAction(Request $request): \Symfony\Component\HttpFoundation\Response|\Symfony\Component\HttpFoundation\RedirectResponse { if (false === $this->isGranted(PasswordRecoverVoter::ASK_TOKEN)) { return new Response($this->translator->trans('You are not allowed ' @@ -164,7 +164,7 @@ class PasswordController extends AbstractController * * @return Response|\Symfony\Component\HttpFoundation\RedirectResponse */ - public function requestRecoverAction(Request $request) + public function requestRecoverAction(Request $request): \Symfony\Component\HttpFoundation\Response|\Symfony\Component\HttpFoundation\RedirectResponse { if (false === $this->isGranted(PasswordRecoverVoter::ASK_TOKEN)) { return new Response($this->translator->trans('You are not allowed ' diff --git a/src/Bundle/ChillMainBundle/Controller/PermissionApiController.php b/src/Bundle/ChillMainBundle/Controller/PermissionApiController.php index 9f77e06f4..a28ca46f4 100644 --- a/src/Bundle/ChillMainBundle/Controller/PermissionApiController.php +++ b/src/Bundle/ChillMainBundle/Controller/PermissionApiController.php @@ -24,16 +24,8 @@ use function json_decode; class PermissionApiController extends AbstractController { - private DenormalizerInterface $denormalizer; - - private Security $security; - - public function __construct( - DenormalizerInterface $denormalizer, - Security $security - ) { - $this->denormalizer = $denormalizer; - $this->security = $security; + public function __construct(private DenormalizerInterface $denormalizer, private Security $security) + { } /** diff --git a/src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php b/src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php index 5d32a8dbb..f1b485870 100644 --- a/src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php +++ b/src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php @@ -34,46 +34,11 @@ use function array_key_exists; */ class PermissionsGroupController extends AbstractController { - /** - * @var RoleHierarchy - */ - private $roleHierarchy; - - /** - * @var RoleProvider - */ - private $roleProvider; - - /** - * @var TranslatableStringHelper - */ - private $translatableStringHelper; - - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @var ValidatorInterface - */ - private $validator; - /** * PermissionsGroupController constructor. */ - public function __construct( - TranslatableStringHelper $translatableStringHelper, - RoleProvider $roleProvider, - RoleHierarchy $roleHierarchy, - TranslatorInterface $translator, - ValidatorInterface $validator - ) { - $this->translatableStringHelper = $translatableStringHelper; - $this->roleProvider = $roleProvider; - $this->roleHierarchy = $roleHierarchy; - $this->translator = $translator; - $this->validator = $validator; + public function __construct(private TranslatableStringHelper $translatableStringHelper, private RoleProvider $roleProvider, private RoleHierarchy $roleHierarchy, private TranslatorInterface $translator, private ValidatorInterface $validator) + { } /** @@ -214,7 +179,7 @@ class PermissionsGroupController extends AbstractController try { $permissionsGroup->removeRoleScope($roleScope); - } catch (RuntimeException $ex) { + } catch (RuntimeException) { $this->addFlash( 'notice', $this->translator->trans("The role '%role%' and circle " @@ -260,10 +225,8 @@ class PermissionsGroupController extends AbstractController /** * Displays a form to edit an existing PermissionsGroup entity. - * - * @param mixed $id */ - public function editAction($id) + public function editAction(mixed $id) { $em = $this->getDoctrine()->getManager(); @@ -338,10 +301,8 @@ class PermissionsGroupController extends AbstractController /** * Finds and displays a PermissionsGroup entity. - * - * @param mixed $id */ - public function showAction($id) + public function showAction(mixed $id) { $em = $this->getDoctrine()->getManager(); @@ -393,10 +354,8 @@ class PermissionsGroupController extends AbstractController /** * Edits an existing PermissionsGroup entity. - * - * @param mixed $id */ - public function updateAction(Request $request, $id) + public function updateAction(Request $request, mixed $id) { $em = $this->getDoctrine()->getManager(); diff --git a/src/Bundle/ChillMainBundle/Controller/PostalCodeAPIController.php b/src/Bundle/ChillMainBundle/Controller/PostalCodeAPIController.php index 8e679b228..945ad8fcf 100644 --- a/src/Bundle/ChillMainBundle/Controller/PostalCodeAPIController.php +++ b/src/Bundle/ChillMainBundle/Controller/PostalCodeAPIController.php @@ -26,20 +26,8 @@ use Symfony\Component\Serializer\Normalizer\AbstractNormalizer; final class PostalCodeAPIController extends ApiController { - private CountryRepository $countryRepository; - - private PaginatorFactory $paginatorFactory; - - private PostalCodeRepositoryInterface $postalCodeRepository; - - public function __construct( - CountryRepository $countryRepository, - PostalCodeRepositoryInterface $postalCodeRepository, - PaginatorFactory $paginatorFactory - ) { - $this->countryRepository = $countryRepository; - $this->postalCodeRepository = $postalCodeRepository; - $this->paginatorFactory = $paginatorFactory; + public function __construct(private CountryRepository $countryRepository, private PostalCodeRepositoryInterface $postalCodeRepository, private PaginatorFactory $paginatorFactory) + { } /** diff --git a/src/Bundle/ChillMainBundle/Controller/SavedExportController.php b/src/Bundle/ChillMainBundle/Controller/SavedExportController.php index 197fe253d..f5e84c1b3 100644 --- a/src/Bundle/ChillMainBundle/Controller/SavedExportController.php +++ b/src/Bundle/ChillMainBundle/Controller/SavedExportController.php @@ -36,44 +36,8 @@ use function count; class SavedExportController { - private EntityManagerInterface $entityManager; - - private ExportManager $exportManager; - - private FormFactoryInterface $formFactory; - - private SavedExportRepositoryInterface $savedExportRepository; - - private Security $security; - - private SessionInterface $session; - - private EngineInterface $templating; - - private TranslatorInterface $translator; - - private UrlGeneratorInterface $urlGenerator; - - public function __construct( - EngineInterface $templating, - EntityManagerInterface $entityManager, - ExportManager $exportManager, - FormFactoryInterface $formBuilder, - SavedExportRepositoryInterface $savedExportRepository, - Security $security, - SessionInterface $session, - TranslatorInterface $translator, - UrlGeneratorInterface $urlGenerator - ) { - $this->exportManager = $exportManager; - $this->entityManager = $entityManager; - $this->formFactory = $formBuilder; - $this->savedExportRepository = $savedExportRepository; - $this->security = $security; - $this->session = $session; - $this->templating = $templating; - $this->translator = $translator; - $this->urlGenerator = $urlGenerator; + public function __construct(private EngineInterface $templating, private EntityManagerInterface $entityManager, private ExportManager $exportManager, private FormFactoryInterface $formFactory, private SavedExportRepositoryInterface $savedExportRepository, private Security $security, private SessionInterface $session, private TranslatorInterface $translator, private UrlGeneratorInterface $urlGenerator) + { } /** diff --git a/src/Bundle/ChillMainBundle/Controller/ScopeController.php b/src/Bundle/ChillMainBundle/Controller/ScopeController.php index f3b08204d..542efb4ed 100644 --- a/src/Bundle/ChillMainBundle/Controller/ScopeController.php +++ b/src/Bundle/ChillMainBundle/Controller/ScopeController.php @@ -47,10 +47,8 @@ class ScopeController extends AbstractController /** * Displays a form to edit an existing Scope entity. - * - * @param mixed $id */ - public function editAction($id) + public function editAction(mixed $id) { $em = $this->getDoctrine()->getManager(); @@ -98,10 +96,8 @@ class ScopeController extends AbstractController /** * Finds and displays a Scope entity. - * - * @param mixed $id */ - public function showAction($id) + public function showAction(mixed $id) { $em = $this->getDoctrine()->getManager(); @@ -118,10 +114,8 @@ class ScopeController extends AbstractController /** * Edits an existing Scope entity. - * - * @param mixed $id */ - public function updateAction(Request $request, $id) + public function updateAction(Request $request, mixed $id) { $em = $this->getDoctrine()->getManager(); diff --git a/src/Bundle/ChillMainBundle/Controller/SearchController.php b/src/Bundle/ChillMainBundle/Controller/SearchController.php index 7eec60324..dfaaa50d4 100644 --- a/src/Bundle/ChillMainBundle/Controller/SearchController.php +++ b/src/Bundle/ChillMainBundle/Controller/SearchController.php @@ -36,24 +36,8 @@ use function reset; */ class SearchController extends AbstractController { - protected PaginatorFactory $paginatorFactory; - - protected SearchApi $searchApi; - - protected SearchProvider $searchProvider; - - protected TranslatorInterface $translator; - - public function __construct( - SearchProvider $searchProvider, - TranslatorInterface $translator, - PaginatorFactory $paginatorFactory, - SearchApi $searchApi - ) { - $this->searchProvider = $searchProvider; - $this->translator = $translator; - $this->paginatorFactory = $paginatorFactory; - $this->searchApi = $searchApi; + public function __construct(protected SearchProvider $searchProvider, protected TranslatorInterface $translator, protected PaginatorFactory $paginatorFactory, protected SearchApi $searchApi) + { } public function advancedSearchAction($name, Request $request) @@ -64,7 +48,7 @@ class SearchController extends AbstractController /** @var Chill\MainBundle\Search\HasAdvancedSearchFormInterface $variable */ $search = $this->searchProvider ->getHasAdvancedFormByName($name); - } catch (\Chill\MainBundle\Search\UnknowSearchNameException $e) { + } catch (\Chill\MainBundle\Search\UnknowSearchNameException) { throw $this->createNotFoundException('no advanced search for ' . "{$name}"); } diff --git a/src/Bundle/ChillMainBundle/Controller/TimelineCenterController.php b/src/Bundle/ChillMainBundle/Controller/TimelineCenterController.php index c51952b3a..fdb521882 100644 --- a/src/Bundle/ChillMainBundle/Controller/TimelineCenterController.php +++ b/src/Bundle/ChillMainBundle/Controller/TimelineCenterController.php @@ -22,20 +22,8 @@ use function count; class TimelineCenterController extends AbstractController { - protected PaginatorFactory $paginatorFactory; - - protected TimelineBuilder $timelineBuilder; - - private Security $security; - - public function __construct( - TimelineBuilder $timelineBuilder, - PaginatorFactory $paginatorFactory, - Security $security - ) { - $this->timelineBuilder = $timelineBuilder; - $this->paginatorFactory = $paginatorFactory; - $this->security = $security; + public function __construct(protected TimelineBuilder $timelineBuilder, protected PaginatorFactory $paginatorFactory, private Security $security) + { } /** diff --git a/src/Bundle/ChillMainBundle/Controller/UserApiController.php b/src/Bundle/ChillMainBundle/Controller/UserApiController.php index da873e118..0eb6c711c 100644 --- a/src/Bundle/ChillMainBundle/Controller/UserApiController.php +++ b/src/Bundle/ChillMainBundle/Controller/UserApiController.php @@ -28,10 +28,8 @@ class UserApiController extends ApiController * "_format": "json" * } * ) - * - * @param mixed $_format */ - public function currentLocation($_format): JsonResponse + public function currentLocation(mixed $_format): JsonResponse { return $this->json( $this->getUser()->getCurrentLocation(), @@ -49,10 +47,8 @@ class UserApiController extends ApiController * "_format": "json" * } * ) - * - * @param mixed $_format */ - public function whoami($_format): JsonResponse + public function whoami(mixed $_format): JsonResponse { return $this->json( $this->getUser(), diff --git a/src/Bundle/ChillMainBundle/Controller/UserController.php b/src/Bundle/ChillMainBundle/Controller/UserController.php index ecf8a3c9c..f8e512f78 100644 --- a/src/Bundle/ChillMainBundle/Controller/UserController.php +++ b/src/Bundle/ChillMainBundle/Controller/UserController.php @@ -38,37 +38,15 @@ class UserController extends CRUDController { public const FORM_GROUP_CENTER_COMPOSED = 'composed_groupcenter'; - protected ParameterBagInterface $parameterBag; - - private LoggerInterface $logger; - - private UserPasswordEncoderInterface $passwordEncoder; - - private UserRepository $userRepository; - - private ValidatorInterface $validator; - - public function __construct( - LoggerInterface $chillLogger, - ValidatorInterface $validator, - UserPasswordEncoderInterface $passwordEncoder, - UserRepository $userRepository, - ParameterBagInterface $parameterBag - ) { - $this->logger = $chillLogger; - $this->userRepository = $userRepository; - $this->validator = $validator; - $this->passwordEncoder = $passwordEncoder; - $this->parameterBag = $parameterBag; + public function __construct(private LoggerInterface $logger, private ValidatorInterface $validator, private UserPasswordEncoderInterface $passwordEncoder, private UserRepository $userRepository, protected ParameterBagInterface $parameterBag) + { } /** * @Route("/{_locale}/admin/main/user/{uid}/add_link_groupcenter", * name="admin_user_add_groupcenter") - * - * @param mixed $uid */ - public function addLinkGroupCenterAction(Request $request, $uid): Response + public function addLinkGroupCenterAction(Request $request, mixed $uid): Response { $em = $this->getDoctrine()->getManager(); @@ -122,11 +100,8 @@ class UserController extends CRUDController /** * @Route("/{_locale}/admin/main/user/{uid}/delete_link_groupcenter/{gcid}", * name="admin_user_delete_groupcenter") - * - * @param mixed $uid - * @param mixed $gcid */ - public function deleteLinkGroupCenterAction($uid, $gcid, Request $request): RedirectResponse + public function deleteLinkGroupCenterAction(mixed $uid, mixed $gcid, Request $request): RedirectResponse { $em = $this->getDoctrine()->getManager(); @@ -421,10 +396,8 @@ class UserController extends CRUDController /** * Creates a form to delete a link to a GroupCenter. - * - * @param mixed $request */ - private function createDeleteLinkGroupCenterForm(User $user, GroupCenter $groupCenter, $request): FormInterface + private function createDeleteLinkGroupCenterForm(User $user, GroupCenter $groupCenter, mixed $request): FormInterface { $returnPathParams = $request->query->has('returnPath') ? ['returnPath' => $request->query->get('returnPath')] : []; diff --git a/src/Bundle/ChillMainBundle/Controller/WorkflowApiController.php b/src/Bundle/ChillMainBundle/Controller/WorkflowApiController.php index f0e728252..dfb06d3df 100644 --- a/src/Bundle/ChillMainBundle/Controller/WorkflowApiController.php +++ b/src/Bundle/ChillMainBundle/Controller/WorkflowApiController.php @@ -30,28 +30,8 @@ use Symfony\Component\Serializer\SerializerInterface; class WorkflowApiController { - private EntityManagerInterface $entityManager; - - private EntityWorkflowRepository $entityWorkflowRepository; - - private PaginatorFactory $paginatorFactory; - - private Security $security; - - private SerializerInterface $serializer; - - public function __construct( - EntityManagerInterface $entityManager, - EntityWorkflowRepository $entityWorkflowRepository, - PaginatorFactory $paginatorFactory, - Security $security, - SerializerInterface $serializer - ) { - $this->entityManager = $entityManager; - $this->entityWorkflowRepository = $entityWorkflowRepository; - $this->paginatorFactory = $paginatorFactory; - $this->security = $security; - $this->serializer = $serializer; + public function __construct(private EntityManagerInterface $entityManager, private EntityWorkflowRepository $entityWorkflowRepository, private PaginatorFactory $paginatorFactory, private Security $security, private SerializerInterface $serializer) + { } /** @@ -160,46 +140,19 @@ class WorkflowApiController $user = $this->security->getUser(); - switch ($request->query->get('subscribe')) { - case 'final': - switch ($action) { - case 'subscribe': - $entityWorkflow->addSubscriberToFinal($user); - - break; - - case 'unsubscribe': - $entityWorkflow->removeSubscriberToFinal($user); - - break; - - default: - throw new LogicException(); - } - - break; - - case 'step': - switch ($action) { - case 'subscribe': - $entityWorkflow->addSubscriberToStep($user); - - break; - - case 'unsubscribe': - $entityWorkflow->removeSubscriberToStep($user); - - break; - - default: - throw new LogicException(); - } - - break; - - default: - throw new BadRequestHttpException('subscribe parameter must be equal to "step" or "final"'); - } + match ($request->query->get('subscribe')) { + 'final' => match ($action) { + 'subscribe' => $entityWorkflow->addSubscriberToFinal($user), + 'unsubscribe' => $entityWorkflow->removeSubscriberToFinal($user), + default => throw new LogicException(), + }, + 'step' => match ($action) { + 'subscribe' => $entityWorkflow->addSubscriberToStep($user), + 'unsubscribe' => $entityWorkflow->removeSubscriberToStep($user), + default => throw new LogicException(), + }, + default => throw new BadRequestHttpException('subscribe parameter must be equal to "step" or "final"'), + }; $this->entityManager->flush(); diff --git a/src/Bundle/ChillMainBundle/Controller/WorkflowController.php b/src/Bundle/ChillMainBundle/Controller/WorkflowController.php index 36647612b..b3d2ad475 100644 --- a/src/Bundle/ChillMainBundle/Controller/WorkflowController.php +++ b/src/Bundle/ChillMainBundle/Controller/WorkflowController.php @@ -39,32 +39,8 @@ use function count; class WorkflowController extends AbstractController { - private EntityManagerInterface $entityManager; - - private EntityWorkflowManager $entityWorkflowManager; - - private EntityWorkflowRepository $entityWorkflowRepository; - - private PaginatorFactory $paginatorFactory; - - private Registry $registry; - - private Security $security; - - private TranslatorInterface $translator; - - private ValidatorInterface $validator; - - public function __construct(EntityWorkflowManager $entityWorkflowManager, EntityWorkflowRepository $entityWorkflowRepository, ValidatorInterface $validator, PaginatorFactory $paginatorFactory, Registry $registry, EntityManagerInterface $entityManager, TranslatorInterface $translator, Security $security) + public function __construct(private EntityWorkflowManager $entityWorkflowManager, private EntityWorkflowRepository $entityWorkflowRepository, private ValidatorInterface $validator, private PaginatorFactory $paginatorFactory, private Registry $registry, private EntityManagerInterface $entityManager, private TranslatorInterface $translator, private Security $security) { - $this->entityWorkflowManager = $entityWorkflowManager; - $this->entityWorkflowRepository = $entityWorkflowRepository; - $this->validator = $validator; - $this->paginatorFactory = $paginatorFactory; - $this->registry = $registry; - $this->entityManager = $entityManager; - $this->translator = $translator; - $this->security = $security; } /** diff --git a/src/Bundle/ChillMainBundle/Cron/CronManager.php b/src/Bundle/ChillMainBundle/Cron/CronManager.php index f69dcba76..0bf928ee1 100644 --- a/src/Bundle/ChillMainBundle/Cron/CronManager.php +++ b/src/Bundle/ChillMainBundle/Cron/CronManager.php @@ -46,30 +46,11 @@ class CronManager implements CronManagerInterface private const UPDATE_BEFORE_EXEC = 'UPDATE ' . CronJobExecution::class . ' cr SET cr.lastStart = :now WHERE cr.key = :key'; - private CronJobExecutionRepositoryInterface $cronJobExecutionRepository; - - private EntityManagerInterface $entityManager; - - /** - * @var iterable - */ - private iterable $jobs; - - private LoggerInterface $logger; - /** * @param CronJobInterface[] $jobs */ - public function __construct( - CronJobExecutionRepositoryInterface $cronJobExecutionRepository, - EntityManagerInterface $entityManager, - iterable $jobs, - LoggerInterface $logger - ) { - $this->cronJobExecutionRepository = $cronJobExecutionRepository; - $this->entityManager = $entityManager; - $this->jobs = $jobs; - $this->logger = $logger; + public function __construct(private CronJobExecutionRepositoryInterface $cronJobExecutionRepository, private EntityManagerInterface $entityManager, private iterable $jobs, private LoggerInterface $logger) + { } public function run(?string $forceJob = null): void @@ -115,7 +96,7 @@ class CronManager implements CronManagerInterface $this->logger->info(sprintf('%sSuccessfully run job', self::LOG_PREFIX), ['job' => $job->getKey()]); return; - } catch (Exception $e) { + } catch (Exception) { $this->logger->error(sprintf('%sRunning job failed', self::LOG_PREFIX), ['job' => $job->getKey()]); $this->entityManager ->createQuery(self::UPDATE_AFTER_EXEC) diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php index c86a69be2..2da35e7ef 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php @@ -93,10 +93,7 @@ class ChillMainExtension extends Extension implements $this->widgetFactories[] = $factory; } - /** - * @return \Chill\MainBundle\DependencyInjection\Configuration|object|\Symfony\Component\Config\Definition\ConfigurationInterface|null - */ - public function getConfiguration(array $config, ContainerBuilder $container) + public function getConfiguration(array $config, ContainerBuilder $container): \Chill\MainBundle\DependencyInjection\Configuration|object|\Symfony\Component\Config\Definition\ConfigurationInterface|null { return new Configuration($this->widgetFactories, $container); } diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/ACLFlagsCompilerPass.php b/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/ACLFlagsCompilerPass.php index 40baccfc0..70efbf409 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/ACLFlagsCompilerPass.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/ACLFlagsCompilerPass.php @@ -27,21 +27,16 @@ class ACLFlagsCompilerPass implements CompilerPassInterface $reference = new Reference($id); foreach ($tags as $tag) { - switch ($tag['scope']) { - case PermissionsGroupType::FLAG_SCOPE: - $permissionGroupType->addMethodCall('addFlagProvider', [$reference]); - - break; - - default: - throw new LogicException( - sprintf( - "This tag 'scope' is not implemented: %s, on service with id %s", - $tag['scope'], - $id - ) - ); - } + match ($tag['scope']) { + PermissionsGroupType::FLAG_SCOPE => $permissionGroupType->addMethodCall('addFlagProvider', [$reference]), + default => throw new LogicException( + sprintf( + "This tag 'scope' is not implemented: %s, on service with id %s", + $tag['scope'], + $id + ) + ), + }; } } } diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php b/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php index 4605f35ab..0c5fd56c9 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php @@ -24,14 +24,11 @@ class Configuration implements ConfigurationInterface { use AddWidgetConfigurationTrait; - private ContainerBuilder $containerBuilder; - public function __construct( array $widgetFactories, - ContainerBuilder $containerBuilder + private ContainerBuilder $containerBuilder ) { $this->setWidgetFactories($widgetFactories); - $this->containerBuilder = $containerBuilder; } public function getConfigTreeBuilder() diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/Widget/AbstractWidgetsCompilerPass.php b/src/Bundle/ChillMainBundle/DependencyInjection/Widget/AbstractWidgetsCompilerPass.php index d5234bfbe..70a3e2ea1 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/Widget/AbstractWidgetsCompilerPass.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/Widget/AbstractWidgetsCompilerPass.php @@ -153,7 +153,7 @@ abstract class AbstractWidgetsCompilerPass implements CompilerPassInterface $extension, HasWidgetFactoriesExtensionInterface::class, HasWidgetFactoriesExtensionInterface::class, - get_class($extensionClass) + $extensionClass::class )); } @@ -277,7 +277,7 @@ abstract class AbstractWidgetsCompilerPass implements CompilerPassInterface if (empty($alias)) { throw new LogicException(sprintf( 'the widget factory %s returns an empty alias', - get_class($factory) + $factory::class )); } @@ -285,13 +285,13 @@ abstract class AbstractWidgetsCompilerPass implements CompilerPassInterface if (!is_array($factory->getAllowedPlaces())) { throw new UnexpectedValueException("the method 'getAllowedPlaces' " . 'should return a non-empty array. Unexpected value on ' . - get_class($factory)); + $factory::class); } if (count($factory->getAllowedPlaces()) === 0) { throw new LengthException("The method 'getAllowedPlaces' should " . 'return a non-empty array, but returned 0 elements on ' . - get_class($factory) . '::getAllowedPlaces()'); + $factory::class . '::getAllowedPlaces()'); } // check the alias does not exists yet @@ -365,12 +365,10 @@ abstract class AbstractWidgetsCompilerPass implements CompilerPassInterface /** * get the places where the service is allowed. * - * @param mixed $place - * @param mixed $widgetAlias * * @return unknown */ - private function isPlaceAllowedForWidget($place, $widgetAlias, ContainerBuilder $container) + private function isPlaceAllowedForWidget(mixed $place, mixed $widgetAlias, ContainerBuilder $container) { if ($this->widgetServices[$widgetAlias] instanceof WidgetFactoryInterface) { if ( diff --git a/src/Bundle/ChillMainBundle/Doctrine/DQL/OverlapsI.php b/src/Bundle/ChillMainBundle/Doctrine/DQL/OverlapsI.php index 29642dc15..89ba084c4 100644 --- a/src/Bundle/ChillMainBundle/Doctrine/DQL/OverlapsI.php +++ b/src/Bundle/ChillMainBundle/Doctrine/DQL/OverlapsI.php @@ -73,20 +73,11 @@ class OverlapsI extends FunctionNode protected function makeCase($sqlWalker, $part, string $position): string { - switch ($position) { - case 'start': - $p = '-infinity'; - - break; - - case 'end': - $p = 'infinity'; - - break; - - default: - throw new Exception('Unexpected position value.'); - } + $p = match ($position) { + 'start' => '-infinity', + 'end' => 'infinity', + default => throw new Exception('Unexpected position value.'), + }; if ($part instanceof PathExpression) { return sprintf( diff --git a/src/Bundle/ChillMainBundle/Doctrine/Event/TrackCreateUpdateSubscriber.php b/src/Bundle/ChillMainBundle/Doctrine/Event/TrackCreateUpdateSubscriber.php index bf493c344..0c8159df3 100644 --- a/src/Bundle/ChillMainBundle/Doctrine/Event/TrackCreateUpdateSubscriber.php +++ b/src/Bundle/ChillMainBundle/Doctrine/Event/TrackCreateUpdateSubscriber.php @@ -22,11 +22,8 @@ use Symfony\Component\Security\Core\Security; class TrackCreateUpdateSubscriber implements EventSubscriber { - private Security $security; - - public function __construct(Security $security) + public function __construct(private Security $security) { - $this->security = $security; } public function getSubscribedEvents() diff --git a/src/Bundle/ChillMainBundle/Doctrine/Model/Point.php b/src/Bundle/ChillMainBundle/Doctrine/Model/Point.php index 684030ee3..de73bdf5a 100644 --- a/src/Bundle/ChillMainBundle/Doctrine/Model/Point.php +++ b/src/Bundle/ChillMainBundle/Doctrine/Model/Point.php @@ -20,14 +20,8 @@ class Point implements JsonSerializable { public static string $SRID = '4326'; - private ?float $lat; - - private ?float $lon; - - private function __construct(?float $lon, ?float $lat) + private function __construct(private ?float $lon, private ?float $lat) { - $this->lat = $lat; - $this->lon = $lon; } public static function fromArrayGeoJson(array $array): self diff --git a/src/Bundle/ChillMainBundle/Doctrine/Type/NativeDateIntervalType.php b/src/Bundle/ChillMainBundle/Doctrine/Type/NativeDateIntervalType.php index 896ddb600..91033ec0b 100644 --- a/src/Bundle/ChillMainBundle/Doctrine/Type/NativeDateIntervalType.php +++ b/src/Bundle/ChillMainBundle/Doctrine/Type/NativeDateIntervalType.php @@ -91,28 +91,12 @@ class NativeDateIntervalType extends DateIntervalType if (is_numeric($current)) { $next = next($strings); - switch ($next) { - case 'year': - case 'years': - $unit = 'Y'; - - break; - - case 'mon': - case 'mons': - $unit = 'M'; - - break; - - case 'day': - case 'days': - $unit = 'D'; - - break; - - default: - throw $this->createConversionException(implode('', $strings)); - } + $unit = match ($next) { + 'year', 'years' => 'Y', + 'mon', 'mons' => 'M', + 'day', 'days' => 'D', + default => throw $this->createConversionException(implode('', $strings)), + }; return $current . $unit; } diff --git a/src/Bundle/ChillMainBundle/Doctrine/Type/PointType.php b/src/Bundle/ChillMainBundle/Doctrine/Type/PointType.php index 3f74c62a3..e1849574b 100644 --- a/src/Bundle/ChillMainBundle/Doctrine/Type/PointType.php +++ b/src/Bundle/ChillMainBundle/Doctrine/Type/PointType.php @@ -44,10 +44,8 @@ class PointType extends Type /** * @param mixed $value - * - * @return ?Point */ - public function convertToPHPValue($value, AbstractPlatform $platform) + public function convertToPHPValue($value, AbstractPlatform $platform): ?\Chill\MainBundle\Doctrine\Model\Point { if (null === $value) { return null; diff --git a/src/Bundle/ChillMainBundle/Entity/Address.php b/src/Bundle/ChillMainBundle/Entity/Address.php index 1bd1a453a..52e8d7c62 100644 --- a/src/Bundle/ChillMainBundle/Entity/Address.php +++ b/src/Bundle/ChillMainBundle/Entity/Address.php @@ -399,9 +399,6 @@ class Address implements TrackCreationInterface, TrackUpdateInterface return $this->streetNumber; } - /** - * @return DateTime - */ public function getValidFrom(): DateTime { return $this->validFrom; @@ -567,7 +564,6 @@ class Address implements TrackCreationInterface, TrackUpdateInterface * * @param string $streetAddress1 * - * @return Address * @deprecated */ public function setStreetAddress1(?string $streetAddress1): self @@ -582,7 +578,6 @@ class Address implements TrackCreationInterface, TrackUpdateInterface * * @param string $streetAddress2 * @deprecated - * @return Address */ public function setStreetAddress2(?string $streetAddress2): self { diff --git a/src/Bundle/ChillMainBundle/Entity/Center.php b/src/Bundle/ChillMainBundle/Entity/Center.php index 5ca051ec0..e4c42ba7e 100644 --- a/src/Bundle/ChillMainBundle/Entity/Center.php +++ b/src/Bundle/ChillMainBundle/Entity/Center.php @@ -20,7 +20,7 @@ use Symfony\Component\Serializer\Annotation as Serializer; * @ORM\Entity * @ORM\Table(name="centers") */ -class Center implements HasCenterInterface +class Center implements HasCenterInterface, \Stringable { /** * @var Collection @@ -59,7 +59,7 @@ class Center implements HasCenterInterface /** * @return string */ - public function __toString() + public function __toString(): string { return $this->getName(); } @@ -85,7 +85,7 @@ class Center implements HasCenterInterface /** * @return ArrayCollection|Collection */ - public function getGroupCenters() + public function getGroupCenters(): \Doctrine\Common\Collections\ArrayCollection|\Doctrine\Common\Collections\Collection { return $this->groupCenters; } diff --git a/src/Bundle/ChillMainBundle/Entity/Civility.php b/src/Bundle/ChillMainBundle/Entity/Civility.php index 5ed82445c..0263e3b64 100644 --- a/src/Bundle/ChillMainBundle/Entity/Civility.php +++ b/src/Bundle/ChillMainBundle/Entity/Civility.php @@ -79,9 +79,6 @@ class Civility return $this->order; } - /** - * @return Civility - */ public function setAbbreviation(array $abbreviation): self { $this->abbreviation = $abbreviation; diff --git a/src/Bundle/ChillMainBundle/Entity/CronJobExecution.php b/src/Bundle/ChillMainBundle/Entity/CronJobExecution.php index 0cacffac9..ea3d47f72 100644 --- a/src/Bundle/ChillMainBundle/Entity/CronJobExecution.php +++ b/src/Bundle/ChillMainBundle/Entity/CronJobExecution.php @@ -24,12 +24,6 @@ class CronJobExecution public const SUCCESS = 1; - /** - * @ORM\Column(type="text", nullable=false) - * @ORM\Id - */ - private string $key; - /** * @var DateTimeImmutable * @ORM\Column(type="datetime_immutable", nullable=true, options={"default": null}) @@ -46,9 +40,12 @@ class CronJobExecution */ private ?int $lastStatus = null; - public function __construct(string $key) - { - $this->key = $key; + public function __construct(/** + * @ORM\Column(type="text", nullable=false) + * @ORM\Id + */ + private string $key + ) { $this->lastStart = new DateTimeImmutable('now'); } diff --git a/src/Bundle/ChillMainBundle/Entity/GeographicalUnit/SimpleGeographicalUnitDTO.php b/src/Bundle/ChillMainBundle/Entity/GeographicalUnit/SimpleGeographicalUnitDTO.php index 7add53066..987cb05ec 100644 --- a/src/Bundle/ChillMainBundle/Entity/GeographicalUnit/SimpleGeographicalUnitDTO.php +++ b/src/Bundle/ChillMainBundle/Entity/GeographicalUnit/SimpleGeographicalUnitDTO.php @@ -20,39 +20,31 @@ use Symfony\Component\Serializer\Annotation as Serializer; */ class SimpleGeographicalUnitDTO { - /** - * @readonly - * @psalm-readonly - * @Serializer\Groups({"read"}) - */ - public int $id; - - /** - * @readonly - * @psalm-readonly - * @Serializer\Groups({"read"}) - */ - public int $layerId; - - /** - * @readonly - * @psalm-readonly - * @Serializer\Groups({"read"}) - */ - public string $unitName; - - /** - * @readonly - * @psalm-readonly - * @Serializer\Groups({"read"}) - */ - public string $unitRefId; - - public function __construct(int $id, string $unitName, string $unitRefId, int $layerId) - { - $this->id = $id; - $this->unitName = $unitName; - $this->unitRefId = $unitRefId; - $this->layerId = $layerId; + public function __construct( + /** + * @readonly + * @psalm-readonly + * @Serializer\Groups({"read"}) + */ + public int $id, + /** + * @readonly + * @psalm-readonly + * @Serializer\Groups({"read"}) + */ + public string $unitName, + /** + * @readonly + * @psalm-readonly + * @Serializer\Groups({"read"}) + */ + public string $unitRefId, + /** + * @readonly + * @psalm-readonly + * @Serializer\Groups({"read"}) + */ + public int $layerId + ) { } } diff --git a/src/Bundle/ChillMainBundle/Entity/PermissionsGroup.php b/src/Bundle/ChillMainBundle/Entity/PermissionsGroup.php index 6c0d0be5b..a32fa978b 100644 --- a/src/Bundle/ChillMainBundle/Entity/PermissionsGroup.php +++ b/src/Bundle/ChillMainBundle/Entity/PermissionsGroup.php @@ -109,7 +109,7 @@ class PermissionsGroup /** * @return ArrayCollection|Collection */ - public function getRoleScopes() + public function getRoleScopes(): \Doctrine\Common\Collections\ArrayCollection|\Doctrine\Common\Collections\Collection { return $this->roleScopes; } diff --git a/src/Bundle/ChillMainBundle/Entity/User.php b/src/Bundle/ChillMainBundle/Entity/User.php index a8ef88fbe..6ea9b81f8 100644 --- a/src/Bundle/ChillMainBundle/Entity/User.php +++ b/src/Bundle/ChillMainBundle/Entity/User.php @@ -32,7 +32,7 @@ use function in_array; * "user": User::class * }) */ -class User implements UserInterface +class User implements UserInterface, \Stringable { /** * @ORM\Id @@ -158,14 +158,12 @@ class User implements UserInterface /** * @return string */ - public function __toString() + public function __toString(): string { return $this->getLabel(); } /** - * @param \Chill\MainBundle\Entity\GroupCenter $groupCenter - * * @return \Chill\MainBundle\Entity\User */ public function addGroupCenter(GroupCenter $groupCenter) @@ -359,8 +357,6 @@ class User implements UserInterface } /** - * @param \Chill\MainBundle\Entity\GroupCenter $groupCenter - * * @throws RuntimeException if the groupCenter is not in the collection */ public function removeGroupCenter(GroupCenter $groupCenter) diff --git a/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflow.php b/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflow.php index d0f558cd5..8dfc400f7 100644 --- a/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflow.php +++ b/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflow.php @@ -294,7 +294,7 @@ class EntityWorkflow implements TrackCreationInterface, TrackUpdateInterface /** * @return ArrayCollection|Collection */ - public function getSteps() + public function getSteps(): \Doctrine\Common\Collections\ArrayCollection|\Doctrine\Common\Collections\Collection { return $this->steps; } @@ -335,7 +335,7 @@ class EntityWorkflow implements TrackCreationInterface, TrackUpdateInterface /** * @return ArrayCollection|Collection */ - public function getSubscriberToFinal() + public function getSubscriberToFinal(): \Doctrine\Common\Collections\ArrayCollection|\Doctrine\Common\Collections\Collection { return $this->subscriberToFinal; } @@ -343,7 +343,7 @@ class EntityWorkflow implements TrackCreationInterface, TrackUpdateInterface /** * @return ArrayCollection|Collection */ - public function getSubscriberToStep() + public function getSubscriberToStep(): \Doctrine\Common\Collections\ArrayCollection|\Doctrine\Common\Collections\Collection { return $this->subscriberToStep; } diff --git a/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStep.php b/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStep.php index 1f3070eb2..75d055ce3 100644 --- a/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStep.php +++ b/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStep.php @@ -356,8 +356,6 @@ class EntityWorkflowStep } /** - * @return EntityWorkflowStep - * * @internal */ public function setNext(?EntityWorkflowStep $next): self @@ -368,8 +366,6 @@ class EntityWorkflowStep } /** - * @return EntityWorkflowStep - * * @internal */ public function setPrevious(?EntityWorkflowStep $previous): self @@ -409,10 +405,8 @@ class EntityWorkflowStep /** * @Assert\Callback - * - * @param mixed $payload */ - public function validateOnCreation(ExecutionContextInterface $context, $payload): void + public function validateOnCreation(ExecutionContextInterface $context, mixed $payload): void { return; diff --git a/src/Bundle/ChillMainBundle/Export/ExportManager.php b/src/Bundle/ChillMainBundle/Export/ExportManager.php index f39926083..9b8fb340e 100644 --- a/src/Bundle/ChillMainBundle/Export/ExportManager.php +++ b/src/Bundle/ChillMainBundle/Export/ExportManager.php @@ -44,10 +44,6 @@ class ExportManager */ private array $aggregators = []; - private AuthorizationCheckerInterface $authorizationChecker; - - private AuthorizationHelperInterface $authorizationHelper; - /** * Collected Exports, injected by DI. * @@ -69,17 +65,15 @@ class ExportManager */ private array $formatters = []; - private LoggerInterface $logger; - /** * @var \Symfony\Component\Security\Core\User\UserInterface */ private $user; public function __construct( - LoggerInterface $logger, - AuthorizationCheckerInterface $authorizationChecker, - AuthorizationHelperInterface $authorizationHelper, + private LoggerInterface $logger, + private AuthorizationCheckerInterface $authorizationChecker, + private AuthorizationHelperInterface $authorizationHelper, TokenStorageInterface $tokenStorage, iterable $exports, iterable $aggregators, @@ -87,9 +81,6 @@ class ExportManager //iterable $formatters, //iterable $exportElementProvider ) { - $this->logger = $logger; - $this->authorizationChecker = $authorizationChecker; - $this->authorizationHelper = $authorizationHelper; $this->user = $tokenStorage->getToken()->getUser(); $this->exports = iterator_to_array($exports); $this->aggregators = iterator_to_array($aggregators); @@ -163,7 +154,7 @@ class ExportManager } elseif ($element instanceof FormatterInterface) { $this->addFormatter($element, $alias); } else { - throw new LogicException('This element ' . get_class($element) . ' ' + throw new LogicException('This element ' . $element::class . ' ' . 'is not an instance of export element'); } } @@ -468,12 +459,10 @@ class ExportManager * Return true if the current user has access to the ExportElement for every * center, false if the user hasn't access to element for at least one center. * - * @param \Chill\MainBundle\Export\ExportElementInterface $element - * @param DirectExportInterface|ExportInterface $export * * @return bool */ - public function isGrantedForElement(ExportElementInterface $element, ?ExportElementInterface $export = null, ?array $centers = null) + public function isGrantedForElement(ExportElementInterface $element, \Chill\MainBundle\Export\DirectExportInterface|\Chill\MainBundle\Export\ExportInterface $export = null, ?array $centers = null) { if ($element instanceof ExportInterface || $element instanceof DirectExportInterface) { $role = $element->requiredRole(); @@ -506,7 +495,7 @@ class ExportManager //debugging $this->logger->debug('user has no access to element', [ 'method' => __METHOD__, - 'type' => get_class($element), + 'type' => $element::class, 'center' => $center->getName(), 'role' => $role, ]); @@ -577,7 +566,7 @@ class ExportManager private function handleFilters( ExportInterface $export, QueryBuilder $qb, - $data, + mixed $data, array $centers ) { $filters = $this->retrieveUsedFilters($data); @@ -598,11 +587,9 @@ class ExportManager } /** - * @param mixed $data - * * @return AggregatorInterface[] */ - private function retrieveUsedAggregators($data) + private function retrieveUsedAggregators(mixed $data) { if (null === $data) { return []; @@ -616,11 +603,9 @@ class ExportManager } /** - * @param mixed $data - * * @return string[] */ - private function retrieveUsedAggregatorsType($data) + private function retrieveUsedAggregatorsType(mixed $data) { if (null === $data) { return []; @@ -660,7 +645,7 @@ class ExportManager * * @return array an array with types */ - private function retrieveUsedFiltersType($data) + private function retrieveUsedFiltersType(mixed $data) { if (null === $data) { return []; @@ -684,11 +669,10 @@ class ExportManager /** * parse the data to retrieve the used filters and aggregators. * - * @param mixed $data * * @return string[] */ - private function retrieveUsedModifiers($data) + private function retrieveUsedModifiers(mixed $data) { if (null === $data) { return []; diff --git a/src/Bundle/ChillMainBundle/Export/Formatter/CSVFormatter.php b/src/Bundle/ChillMainBundle/Export/Formatter/CSVFormatter.php index c8b20a88b..ef5059e9d 100644 --- a/src/Bundle/ChillMainBundle/Export/Formatter/CSVFormatter.php +++ b/src/Bundle/ChillMainBundle/Export/Formatter/CSVFormatter.php @@ -56,13 +56,10 @@ class CSVFormatter implements FormatterInterface protected $result; - protected TranslatorInterface $translator; - public function __construct( - TranslatorInterface $translator, + protected TranslatorInterface $translator, ExportManager $manager ) { - $this->translator = $translator; $this->exportManager = $manager; } diff --git a/src/Bundle/ChillMainBundle/Export/Formatter/SpreadSheetFormatter.php b/src/Bundle/ChillMainBundle/Export/Formatter/SpreadSheetFormatter.php index dc09c55a1..99af717f8 100644 --- a/src/Bundle/ChillMainBundle/Export/Formatter/SpreadSheetFormatter.php +++ b/src/Bundle/ChillMainBundle/Export/Formatter/SpreadSheetFormatter.php @@ -347,27 +347,12 @@ class SpreadSheetFormatter implements FormatterInterface $line = $this->addContentTable($worksheet, $sortedResult, $line); - switch ($this->formatterData['format']) { - case 'ods': - $writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Ods'); - - break; - - case 'xlsx': - $writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx'); - - break; - - case 'csv': - $writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Csv'); - - break; - - default: - // this should not happen - // throw an exception to ensure that the error is catched - throw new LogicException(); - } + $writer = match ($this->formatterData['format']) { + 'ods' => \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Ods'), + 'xlsx' => \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx'), + 'csv' => \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Csv'), + default => throw new LogicException(), + }; $writer->save($this->tempfile); } @@ -435,11 +420,10 @@ class SpreadSheetFormatter implements FormatterInterface * Get the displayable result. * * @param string $key - * @param mixed $value * * @return string */ - protected function getDisplayableResult($key, $value) + protected function getDisplayableResult($key, mixed $value) { if (false === $this->cacheDisplayableResultIsInitialized) { $this->initializeCache($key); diff --git a/src/Bundle/ChillMainBundle/Export/Helper/DateTimeHelper.php b/src/Bundle/ChillMainBundle/Export/Helper/DateTimeHelper.php index 1c2c99083..6b780715b 100644 --- a/src/Bundle/ChillMainBundle/Export/Helper/DateTimeHelper.php +++ b/src/Bundle/ChillMainBundle/Export/Helper/DateTimeHelper.php @@ -18,11 +18,8 @@ use Symfony\Contracts\Translation\TranslatorInterface; class DateTimeHelper { - private TranslatorInterface $translator; - - public function __construct(TranslatorInterface $translator) + public function __construct(private TranslatorInterface $translator) { - $this->translator = $translator; } public function getLabel($header): callable diff --git a/src/Bundle/ChillMainBundle/Export/Helper/ExportAddressHelper.php b/src/Bundle/ChillMainBundle/Export/Helper/ExportAddressHelper.php index fca338a6f..465fe6608 100644 --- a/src/Bundle/ChillMainBundle/Export/Helper/ExportAddressHelper.php +++ b/src/Bundle/ChillMainBundle/Export/Helper/ExportAddressHelper.php @@ -74,14 +74,6 @@ class ExportAddressHelper 'geographical_units' => ['_unit_names', '_unit_refs'], ]; - private AddressRender $addressRender; - - private AddressRepository $addressRepository; - - private GeographicalUnitLayerRepositoryInterface $geographicalUnitLayerRepository; - - private TranslatableStringHelperInterface $translatableStringHelper; - /** * @var array>|null */ @@ -92,16 +84,8 @@ class ExportAddressHelper */ private ?array $unitRefsKeysCache = []; - public function __construct( - AddressRender $addressRender, - AddressRepository $addressRepository, - GeographicalUnitLayerRepositoryInterface $geographicalUnitLayerRepository, - TranslatableStringHelperInterface $translatableStringHelper - ) { - $this->addressRepository = $addressRepository; - $this->geographicalUnitLayerRepository = $geographicalUnitLayerRepository; - $this->translatableStringHelper = $translatableStringHelper; - $this->addressRender = $addressRender; + public function __construct(private AddressRender $addressRender, private AddressRepository $addressRepository, private GeographicalUnitLayerRepositoryInterface $geographicalUnitLayerRepository, private TranslatableStringHelperInterface $translatableStringHelper) + { } public function addSelectClauses(int $params, QueryBuilder $queryBuilder, $entityName = 'address', $prefix = 'add') @@ -369,16 +353,11 @@ class ExportAddressHelper $decodedValues = json_decode($value, true, 512, JSON_THROW_ON_ERROR); - switch (count($decodedValues)) { - case 0: - return ''; - - case 1: - return $decodedValues[0]; - - default: - return implode('|', $decodedValues); - } + return match (count($decodedValues)) { + 0 => '', + 1 => $decodedValues[0], + default => implode('|', $decodedValues), + }; }; } diff --git a/src/Bundle/ChillMainBundle/Export/Helper/TranslatableStringExportLabelHelper.php b/src/Bundle/ChillMainBundle/Export/Helper/TranslatableStringExportLabelHelper.php index 9b49d476b..37a41325e 100644 --- a/src/Bundle/ChillMainBundle/Export/Helper/TranslatableStringExportLabelHelper.php +++ b/src/Bundle/ChillMainBundle/Export/Helper/TranslatableStringExportLabelHelper.php @@ -21,11 +21,8 @@ use Chill\MainBundle\Templating\TranslatableStringHelperInterface; */ class TranslatableStringExportLabelHelper { - private TranslatableStringHelperInterface $translatableStringHelper; - - public function __construct(TranslatableStringHelperInterface $translatableStringHelper) + public function __construct(private TranslatableStringHelperInterface $translatableStringHelper) { - $this->translatableStringHelper = $translatableStringHelper; } public function getLabel(string $key, array $values, string $header) diff --git a/src/Bundle/ChillMainBundle/Export/Helper/UserHelper.php b/src/Bundle/ChillMainBundle/Export/Helper/UserHelper.php index 2821bf1a6..cb13ac1c9 100644 --- a/src/Bundle/ChillMainBundle/Export/Helper/UserHelper.php +++ b/src/Bundle/ChillMainBundle/Export/Helper/UserHelper.php @@ -18,14 +18,8 @@ use const SORT_NUMERIC; class UserHelper { - private UserRender $userRender; - - private UserRepositoryInterface $userRepository; - - public function __construct(UserRender $userRender, UserRepositoryInterface $userRepository) + public function __construct(private UserRender $userRender, private UserRepositoryInterface $userRepository) { - $this->userRender = $userRender; - $this->userRepository = $userRepository; } public function getLabel($key, array $values, string $header): callable diff --git a/src/Bundle/ChillMainBundle/Form/DataMapper/PrivateCommentDataMapper.php b/src/Bundle/ChillMainBundle/Form/DataMapper/PrivateCommentDataMapper.php index e8c7e6c5a..18fceeb5c 100644 --- a/src/Bundle/ChillMainBundle/Form/DataMapper/PrivateCommentDataMapper.php +++ b/src/Bundle/ChillMainBundle/Form/DataMapper/PrivateCommentDataMapper.php @@ -19,11 +19,8 @@ use Symfony\Component\Security\Core\Security; final class PrivateCommentDataMapper extends AbstractType implements DataMapperInterface { - private Security $security; - - public function __construct(Security $security) + public function __construct(private Security $security) { - $this->security = $security; } public function mapDataToForms($viewData, $forms) diff --git a/src/Bundle/ChillMainBundle/Form/DataMapper/ScopePickerDataMapper.php b/src/Bundle/ChillMainBundle/Form/DataMapper/ScopePickerDataMapper.php index ebae9f2b9..bb5f64895 100644 --- a/src/Bundle/ChillMainBundle/Form/DataMapper/ScopePickerDataMapper.php +++ b/src/Bundle/ChillMainBundle/Form/DataMapper/ScopePickerDataMapper.php @@ -16,14 +16,8 @@ use Symfony\Component\Form\DataMapperInterface; class ScopePickerDataMapper implements DataMapperInterface { - /** - * @var \Chill\MainBundle\Entity\Scope - */ - private $scope; - - public function __construct(?Scope $scope = null) + public function __construct(private ?Scope $scope = null) { - $this->scope = $scope; } public function mapDataToForms($data, $forms) diff --git a/src/Bundle/ChillMainBundle/Form/DataTransformer/IdToEntityDataTransformer.php b/src/Bundle/ChillMainBundle/Form/DataTransformer/IdToEntityDataTransformer.php index 6aa5eee40..48dd0dc7c 100644 --- a/src/Bundle/ChillMainBundle/Form/DataTransformer/IdToEntityDataTransformer.php +++ b/src/Bundle/ChillMainBundle/Form/DataTransformer/IdToEntityDataTransformer.php @@ -31,17 +31,11 @@ class IdToEntityDataTransformer implements DataTransformerInterface { private Closure $getId; - private bool $multiple = false; - - private ObjectRepository $repository; - /** * @param Closure $getId */ - public function __construct(ObjectRepository $repository, bool $multiple = false, ?callable $getId = null) + public function __construct(private ObjectRepository $repository, private bool $multiple = false, ?callable $getId = null) { - $this->repository = $repository; - $this->multiple = $multiple; $this->getId = $getId ?? static fn (object $o) => $o->getId(); } diff --git a/src/Bundle/ChillMainBundle/Form/Event/CustomizeFormEvent.php b/src/Bundle/ChillMainBundle/Form/Event/CustomizeFormEvent.php index 3c58ddc7c..2f64f0699 100644 --- a/src/Bundle/ChillMainBundle/Form/Event/CustomizeFormEvent.php +++ b/src/Bundle/ChillMainBundle/Form/Event/CustomizeFormEvent.php @@ -17,14 +17,8 @@ class CustomizeFormEvent extends \Symfony\Component\EventDispatcher\Event { public const NAME = 'chill_main.customize_form'; - protected FormBuilderInterface $builder; - - protected string $type; - - public function __construct(string $type, FormBuilderInterface $builder) + public function __construct(protected string $type, protected FormBuilderInterface $builder) { - $this->type = $type; - $this->builder = $builder; } public function getBuilder(): FormBuilderInterface diff --git a/src/Bundle/ChillMainBundle/Form/LocationFormType.php b/src/Bundle/ChillMainBundle/Form/LocationFormType.php index ff2c563d3..dd102dfc6 100644 --- a/src/Bundle/ChillMainBundle/Form/LocationFormType.php +++ b/src/Bundle/ChillMainBundle/Form/LocationFormType.php @@ -24,11 +24,8 @@ use Symfony\Component\OptionsResolver\OptionsResolver; final class LocationFormType extends AbstractType { - private TranslatableStringHelper $translatableStringHelper; - - public function __construct(TranslatableStringHelper $translatableStringHelper) + public function __construct(private TranslatableStringHelper $translatableStringHelper) { - $this->translatableStringHelper = $translatableStringHelper; } public function buildForm(FormBuilderInterface $builder, array $options) diff --git a/src/Bundle/ChillMainBundle/Form/Type/ComposedRoleScopeType.php b/src/Bundle/ChillMainBundle/Form/Type/ComposedRoleScopeType.php index 38f1475d5..d9a469dec 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/ComposedRoleScopeType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/ComposedRoleScopeType.php @@ -43,18 +43,12 @@ class ComposedRoleScopeType extends AbstractType */ private $rolesWithoutScope = []; - /** - * @var TranslatableStringHelper - */ - private $translatableStringHelper; - public function __construct( - TranslatableStringHelper $translatableStringHelper, + private TranslatableStringHelper $translatableStringHelper, RoleProvider $roleProvider ) { $this->roles = $roleProvider->getRoles(); $this->rolesWithoutScope = $roleProvider->getRolesWithoutScopes(); - $this->translatableStringHelper = $translatableStringHelper; $this->roleProvider = $roleProvider; } diff --git a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/AddressToIdDataTransformer.php b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/AddressToIdDataTransformer.php index 844834177..a9774d06e 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/AddressToIdDataTransformer.php +++ b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/AddressToIdDataTransformer.php @@ -17,11 +17,8 @@ use Symfony\Component\Form\Exception\TransformationFailedException; final class AddressToIdDataTransformer implements DataTransformerInterface { - private AddressRepository $addressRepository; - - public function __construct(AddressRepository $addressRepository) + public function __construct(private AddressRepository $addressRepository) { - $this->addressRepository = $addressRepository; } public function reverseTransform($value) diff --git a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/CenterTransformer.php b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/CenterTransformer.php index 48807655c..b195a5905 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/CenterTransformer.php +++ b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/CenterTransformer.php @@ -23,16 +23,8 @@ use function count; class CenterTransformer implements DataTransformerInterface { - private CenterRepository $centerRepository; - - private bool $multiple = false; - - public function __construct( - CenterRepository $centerRepository, - bool $multiple = false - ) { - $this->centerRepository = $centerRepository; - $this->multiple = $multiple; + public function __construct(private CenterRepository $centerRepository, private bool $multiple = false) + { } public function reverseTransform($id) diff --git a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php index 529bd9789..109e83b14 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php +++ b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php @@ -25,20 +25,8 @@ use function array_key_exists; class EntityToJsonTransformer implements DataTransformerInterface { - private DenormalizerInterface $denormalizer; - - private bool $multiple; - - private SerializerInterface $serializer; - - private string $type; - - public function __construct(DenormalizerInterface $denormalizer, SerializerInterface $serializer, bool $multiple, string $type) + public function __construct(private DenormalizerInterface $denormalizer, private SerializerInterface $serializer, private bool $multiple, private string $type) { - $this->denormalizer = $denormalizer; - $this->serializer = $serializer; - $this->multiple = $multiple; - $this->type = $type; } public function reverseTransform($value) @@ -87,25 +75,12 @@ class EntityToJsonTransformer implements DataTransformerInterface throw new TransformationFailedException('the key "id" is missing on element'); } - switch ($this->type) { - case 'user': - $class = User::class; - - break; - - case 'person': - $class = Person::class; - - break; - - case 'thirdparty': - $class = ThirdParty::class; - - break; - - default: - throw new UnexpectedValueException('This type is not supported'); - } + $class = match ($this->type) { + 'user' => User::class, + 'person' => Person::class, + 'thirdparty' => ThirdParty::class, + default => throw new UnexpectedValueException('This type is not supported'), + }; return $this->denormalizer->denormalize( diff --git a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/MultipleObjectsToIdTransformer.php b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/MultipleObjectsToIdTransformer.php index a21f49b2c..345df74bd 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/MultipleObjectsToIdTransformer.php +++ b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/MultipleObjectsToIdTransformer.php @@ -17,14 +17,8 @@ use Symfony\Component\Form\DataTransformerInterface; class MultipleObjectsToIdTransformer implements DataTransformerInterface { - private ?string $class; - - private EntityManagerInterface $em; - - public function __construct(EntityManagerInterface $em, ?string $class = null) + public function __construct(private EntityManagerInterface $em, private ?string $class = null) { - $this->em = $em; - $this->class = $class; } /** diff --git a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/ObjectToIdTransformer.php b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/ObjectToIdTransformer.php index 1e4ee2439..fe87fdb6c 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/ObjectToIdTransformer.php +++ b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/ObjectToIdTransformer.php @@ -17,14 +17,8 @@ use Symfony\Component\Form\Exception\TransformationFailedException; class ObjectToIdTransformer implements DataTransformerInterface { - private ?string $class; - - private EntityManagerInterface $em; - - public function __construct(EntityManagerInterface $em, ?string $class = null) + public function __construct(private EntityManagerInterface $em, private ?string $class = null) { - $this->em = $em; - $this->class = $class; } /** @@ -33,10 +27,8 @@ class ObjectToIdTransformer implements DataTransformerInterface * @param string $id * * @throws TransformationFailedException if object is not found. - * - * @return object|null */ - public function reverseTransform($id) + public function reverseTransform($id): ?object { if (null === $id) { return null; diff --git a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/PostalCodeToIdTransformer.php b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/PostalCodeToIdTransformer.php index ca488fe1a..d18e3de8c 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/PostalCodeToIdTransformer.php +++ b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/PostalCodeToIdTransformer.php @@ -20,11 +20,8 @@ use function is_int; class PostalCodeToIdTransformer implements DataTransformerInterface { - private PostalCodeRepositoryInterface $postalCodeRepository; - - public function __construct(PostalCodeRepositoryInterface $postalCodeRepository) + public function __construct(private PostalCodeRepositoryInterface $postalCodeRepository) { - $this->postalCodeRepository = $postalCodeRepository; } public function reverseTransform($value) diff --git a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/ScopeTransformer.php b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/ScopeTransformer.php index 5ae26ec79..bdd981706 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/ScopeTransformer.php +++ b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/ScopeTransformer.php @@ -18,11 +18,8 @@ use Symfony\Component\Form\Exception\TransformationFailedException; class ScopeTransformer implements DataTransformerInterface { - private EntityManagerInterface $em; - - public function __construct(EntityManagerInterface $em) + public function __construct(private EntityManagerInterface $em) { - $this->em = $em; } public function reverseTransform($id) diff --git a/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php b/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php index c89907cf3..ef8dfb62e 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php @@ -33,24 +33,15 @@ final class PickCenterType extends AbstractType { public const CENTERS_IDENTIFIERS = 'c'; - private AuthorizationHelperInterface $authorizationHelper; - - private ExportManager $exportManager; - - private RegroupmentRepository $regroupmentRepository; - private UserInterface $user; public function __construct( TokenStorageInterface $tokenStorage, - ExportManager $exportManager, - RegroupmentRepository $regroupmentRepository, - AuthorizationHelperInterface $authorizationHelper + private ExportManager $exportManager, + private RegroupmentRepository $regroupmentRepository, + private AuthorizationHelperInterface $authorizationHelper ) { - $this->exportManager = $exportManager; $this->user = $tokenStorage->getToken()->getUser(); - $this->authorizationHelper = $authorizationHelper; - $this->regroupmentRepository = $regroupmentRepository; } public function buildForm(FormBuilderInterface $builder, array $options) diff --git a/src/Bundle/ChillMainBundle/Form/Type/Listing/FilterOrderType.php b/src/Bundle/ChillMainBundle/Form/Type/Listing/FilterOrderType.php index aaa6afa24..d0dbfbe53 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/Listing/FilterOrderType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/Listing/FilterOrderType.php @@ -27,11 +27,8 @@ use function count; final class FilterOrderType extends \Symfony\Component\Form\AbstractType { - private RequestStack $requestStack; - - public function __construct(RequestStack $requestStack) + public function __construct(private RequestStack $requestStack) { - $this->requestStack = $requestStack; } public function buildForm(FormBuilderInterface $builder, array $options) diff --git a/src/Bundle/ChillMainBundle/Form/Type/PickAddressType.php b/src/Bundle/ChillMainBundle/Form/Type/PickAddressType.php index 50d6f4eb7..dbbdf502f 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PickAddressType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PickAddressType.php @@ -43,16 +43,8 @@ use function uniqid; */ final class PickAddressType extends AbstractType { - private AddressToIdDataTransformer $addressToIdDataTransformer; - - private TranslatorInterface $translator; - - public function __construct( - AddressToIdDataTransformer $addressToIdDataTransformer, - TranslatorInterface $translator - ) { - $this->addressToIdDataTransformer = $addressToIdDataTransformer; - $this->translator = $translator; + public function __construct(private AddressToIdDataTransformer $addressToIdDataTransformer, private TranslatorInterface $translator) + { } public function buildForm(FormBuilderInterface $builder, array $options) diff --git a/src/Bundle/ChillMainBundle/Form/Type/PickCenterType.php b/src/Bundle/ChillMainBundle/Form/Type/PickCenterType.php index 83e957623..be7c51950 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PickCenterType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PickCenterType.php @@ -38,20 +38,8 @@ use function count; */ class PickCenterType extends AbstractType { - protected AuthorizationHelperInterface $authorizationHelper; - - protected CenterRepository $centerRepository; - - protected Security $security; - - public function __construct( - AuthorizationHelperInterface $authorizationHelper, - Security $security, - CenterRepository $centerRepository - ) { - $this->authorizationHelper = $authorizationHelper; - $this->security = $security; - $this->centerRepository = $centerRepository; + public function __construct(protected AuthorizationHelperInterface $authorizationHelper, protected Security $security, protected CenterRepository $centerRepository) + { } /** diff --git a/src/Bundle/ChillMainBundle/Form/Type/PickCivilityType.php b/src/Bundle/ChillMainBundle/Form/Type/PickCivilityType.php index adb0f2a67..2a7ab259c 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PickCivilityType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PickCivilityType.php @@ -21,11 +21,8 @@ use Symfony\Component\OptionsResolver\OptionsResolver; class PickCivilityType extends AbstractType { - private TranslatableStringHelper $translatableStringHelper; - - public function __construct(TranslatableStringHelper $translatableStringHelper) + public function __construct(private TranslatableStringHelper $translatableStringHelper) { - $this->translatableStringHelper = $translatableStringHelper; } public function configureOptions(OptionsResolver $resolver) diff --git a/src/Bundle/ChillMainBundle/Form/Type/PickLocationTypeType.php b/src/Bundle/ChillMainBundle/Form/Type/PickLocationTypeType.php index 3d993c9f1..cc9737270 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PickLocationTypeType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PickLocationTypeType.php @@ -19,11 +19,8 @@ use Symfony\Component\OptionsResolver\OptionsResolver; class PickLocationTypeType extends AbstractType { - private TranslatableStringHelper $translatableStringHelper; - - public function __construct(TranslatableStringHelper $translatableStringHelper) + public function __construct(private TranslatableStringHelper $translatableStringHelper) { - $this->translatableStringHelper = $translatableStringHelper; } public function configureOptions(OptionsResolver $resolver) diff --git a/src/Bundle/ChillMainBundle/Form/Type/PickPostalCodeType.php b/src/Bundle/ChillMainBundle/Form/Type/PickPostalCodeType.php index d1feacd6a..2ef990704 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PickPostalCodeType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PickPostalCodeType.php @@ -21,11 +21,8 @@ use Symfony\Component\OptionsResolver\OptionsResolver; class PickPostalCodeType extends AbstractType { - private PostalCodeToIdTransformer $postalCodeToIdTransformer; - - public function __construct(PostalCodeToIdTransformer $postalCodeToIdTransformer) + public function __construct(private PostalCodeToIdTransformer $postalCodeToIdTransformer) { - $this->postalCodeToIdTransformer = $postalCodeToIdTransformer; } public function buildForm(FormBuilderInterface $builder, array $options) diff --git a/src/Bundle/ChillMainBundle/Form/Type/PickUserDynamicType.php b/src/Bundle/ChillMainBundle/Form/Type/PickUserDynamicType.php index f6c2b7f4a..1b0a3c6e0 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PickUserDynamicType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PickUserDynamicType.php @@ -27,17 +27,8 @@ use Symfony\Component\Serializer\SerializerInterface; */ class PickUserDynamicType extends AbstractType { - private DenormalizerInterface $denormalizer; - - private NormalizerInterface $normalizer; - - private SerializerInterface $serializer; - - public function __construct(DenormalizerInterface $denormalizer, SerializerInterface $serializer, NormalizerInterface $normalizer) + public function __construct(private DenormalizerInterface $denormalizer, private SerializerInterface $serializer, private NormalizerInterface $normalizer) { - $this->denormalizer = $denormalizer; - $this->serializer = $serializer; - $this->normalizer = $normalizer; } public function buildForm(FormBuilderInterface $builder, array $options) diff --git a/src/Bundle/ChillMainBundle/Form/Type/PickUserLocationType.php b/src/Bundle/ChillMainBundle/Form/Type/PickUserLocationType.php index d78957f29..cc8171c4a 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PickUserLocationType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PickUserLocationType.php @@ -20,14 +20,8 @@ use Symfony\Component\OptionsResolver\OptionsResolver; class PickUserLocationType extends AbstractType { - private LocationRepository $locationRepository; - - private TranslatableStringHelper $translatableStringHelper; - - public function __construct(TranslatableStringHelper $translatableStringHelper, LocationRepository $locationRepository) + public function __construct(private TranslatableStringHelper $translatableStringHelper, private LocationRepository $locationRepository) { - $this->translatableStringHelper = $translatableStringHelper; - $this->locationRepository = $locationRepository; } public function configureOptions(OptionsResolver $resolver) diff --git a/src/Bundle/ChillMainBundle/Form/Type/PrivateCommentType.php b/src/Bundle/ChillMainBundle/Form/Type/PrivateCommentType.php index 5c29f4d42..82b9feade 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PrivateCommentType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PrivateCommentType.php @@ -24,14 +24,11 @@ use Symfony\Component\Security\Core\User\UserInterface; class PrivateCommentType extends AbstractType { - protected PrivateCommentDataMapper $dataMapper; - protected UserInterface $user; - public function __construct(TokenStorageInterface $tokenStorage, PrivateCommentDataMapper $dataMapper) + public function __construct(TokenStorageInterface $tokenStorage, protected PrivateCommentDataMapper $dataMapper) { $this->user = $tokenStorage->getToken()->getUser(); - $this->dataMapper = $dataMapper; } public function buildForm(FormBuilderInterface $builder, array $options) diff --git a/src/Bundle/ChillMainBundle/Form/Type/ScopePickerType.php b/src/Bundle/ChillMainBundle/Form/Type/ScopePickerType.php index c86684a8a..28894a421 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/ScopePickerType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/ScopePickerType.php @@ -42,20 +42,8 @@ use function count; */ class ScopePickerType extends AbstractType { - private AuthorizationHelperInterface $authorizationHelper; - - private Security $security; - - private TranslatableStringHelperInterface $translatableStringHelper; - - public function __construct( - AuthorizationHelperInterface $authorizationHelper, - Security $security, - TranslatableStringHelperInterface $translatableStringHelper - ) { - $this->authorizationHelper = $authorizationHelper; - $this->security = $security; - $this->translatableStringHelper = $translatableStringHelper; + public function __construct(private AuthorizationHelperInterface $authorizationHelper, private Security $security, private TranslatableStringHelperInterface $translatableStringHelper) + { } public function buildForm(FormBuilderInterface $builder, array $options) diff --git a/src/Bundle/ChillMainBundle/Form/Type/Select2CountryType.php b/src/Bundle/ChillMainBundle/Form/Type/Select2CountryType.php index bc4d7d3ef..c22c3f523 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/Select2CountryType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/Select2CountryType.php @@ -29,24 +29,8 @@ use const SORT_STRING; */ class Select2CountryType extends AbstractType { - protected ParameterBagInterface $parameterBag; - - protected TranslatableStringHelper $translatableStringHelper; - - private ObjectManager $em; - - private RequestStack $requestStack; - - public function __construct( - RequestStack $requestStack, - ObjectManager $em, - TranslatableStringHelper $translatableStringHelper, - ParameterBagInterface $parameterBag - ) { - $this->requestStack = $requestStack; - $this->em = $em; - $this->translatableStringHelper = $translatableStringHelper; - $this->parameterBag = $parameterBag; + public function __construct(private RequestStack $requestStack, private ObjectManager $em, protected TranslatableStringHelper $translatableStringHelper, protected ParameterBagInterface $parameterBag) + { } public function buildForm(FormBuilderInterface $builder, array $options) diff --git a/src/Bundle/ChillMainBundle/Form/Type/Select2LanguageType.php b/src/Bundle/ChillMainBundle/Form/Type/Select2LanguageType.php index 328f3c174..7e5adb0cf 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/Select2LanguageType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/Select2LanguageType.php @@ -29,24 +29,8 @@ use const SORT_STRING; */ class Select2LanguageType extends AbstractType { - protected ParameterBagInterface $parameterBag; - - protected TranslatableStringHelper $translatableStringHelper; - - private ObjectManager $em; - - private RequestStack $requestStack; - - public function __construct( - RequestStack $requestStack, - ObjectManager $em, - TranslatableStringHelper $translatableStringHelper, - ParameterBagInterface $parameterBag - ) { - $this->requestStack = $requestStack; - $this->em = $em; - $this->translatableStringHelper = $translatableStringHelper; - $this->parameterBag = $parameterBag; + public function __construct(private RequestStack $requestStack, private ObjectManager $em, protected TranslatableStringHelper $translatableStringHelper, protected ParameterBagInterface $parameterBag) + { } public function buildForm(FormBuilderInterface $builder, array $options) diff --git a/src/Bundle/ChillMainBundle/Form/Type/TranslatableStringFormType.php b/src/Bundle/ChillMainBundle/Form/Type/TranslatableStringFormType.php index ee39ef75e..580f2ca09 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/TranslatableStringFormType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/TranslatableStringFormType.php @@ -24,13 +24,12 @@ use function in_array; class TranslatableStringFormType extends AbstractType { - private $availableLanguages; // The langauges availaible + // The langauges availaible private $frameworkTranslatorFallback; // The langagues used for the translation - public function __construct(array $availableLanguages, Translator $translator) + public function __construct(private array $availableLanguages, Translator $translator) { - $this->availableLanguages = $availableLanguages; $this->frameworkTranslatorFallback = $translator->getFallbackLocales(); } diff --git a/src/Bundle/ChillMainBundle/Form/Type/UserPickerType.php b/src/Bundle/ChillMainBundle/Form/Type/UserPickerType.php index c430a1053..38987d8fb 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/UserPickerType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/UserPickerType.php @@ -44,24 +44,15 @@ class UserPickerType extends AbstractType */ protected $tokenStorage; - protected UserACLAwareRepositoryInterface $userACLAwareRepository; - - protected UserRepository $userRepository; - - private UserRender $userRender; - public function __construct( AuthorizationHelper $authorizationHelper, TokenStorageInterface $tokenStorage, - UserRepository $userRepository, - UserACLAwareRepositoryInterface $userACLAwareRepository, - UserRender $userRender + protected UserRepository $userRepository, + protected UserACLAwareRepositoryInterface $userACLAwareRepository, + private UserRender $userRender ) { $this->authorizationHelper = $authorizationHelper; $this->tokenStorage = $tokenStorage; - $this->userRepository = $userRepository; - $this->userACLAwareRepository = $userACLAwareRepository; - $this->userRender = $userRender; } public function configureOptions(OptionsResolver $resolver) diff --git a/src/Bundle/ChillMainBundle/Form/UserType.php b/src/Bundle/ChillMainBundle/Form/UserType.php index f8485aa99..63f319de4 100644 --- a/src/Bundle/ChillMainBundle/Form/UserType.php +++ b/src/Bundle/ChillMainBundle/Form/UserType.php @@ -35,16 +35,8 @@ use Symfony\Component\Validator\Constraints\Regex; class UserType extends AbstractType { - protected ParameterBagInterface $parameterBag; - - private TranslatableStringHelper $translatableStringHelper; - - public function __construct( - TranslatableStringHelper $translatableStringHelper, - ParameterBagInterface $parameterBag - ) { - $this->translatableStringHelper = $translatableStringHelper; - $this->parameterBag = $parameterBag; + public function __construct(private TranslatableStringHelper $translatableStringHelper, protected ParameterBagInterface $parameterBag) + { } public function buildForm(FormBuilderInterface $builder, array $options) diff --git a/src/Bundle/ChillMainBundle/Form/WorkflowStepType.php b/src/Bundle/ChillMainBundle/Form/WorkflowStepType.php index c6278d133..e967d299f 100644 --- a/src/Bundle/ChillMainBundle/Form/WorkflowStepType.php +++ b/src/Bundle/ChillMainBundle/Form/WorkflowStepType.php @@ -36,17 +36,8 @@ use function array_key_exists; class WorkflowStepType extends AbstractType { - private EntityWorkflowManager $entityWorkflowManager; - - private Registry $registry; - - private TranslatableStringHelperInterface $translatableStringHelper; - - public function __construct(EntityWorkflowManager $entityWorkflowManager, Registry $registry, TranslatableStringHelperInterface $translatableStringHelper) + public function __construct(private EntityWorkflowManager $entityWorkflowManager, private Registry $registry, private TranslatableStringHelperInterface $translatableStringHelper) { - $this->entityWorkflowManager = $entityWorkflowManager; - $this->registry = $registry; - $this->translatableStringHelper = $translatableStringHelper; } public function buildForm(FormBuilderInterface $builder, array $options) diff --git a/src/Bundle/ChillMainBundle/Notification/Counter/NotificationByUserCounter.php b/src/Bundle/ChillMainBundle/Notification/Counter/NotificationByUserCounter.php index a17ffbdae..cbafdcfaf 100644 --- a/src/Bundle/ChillMainBundle/Notification/Counter/NotificationByUserCounter.php +++ b/src/Bundle/ChillMainBundle/Notification/Counter/NotificationByUserCounter.php @@ -25,14 +25,8 @@ use Symfony\Component\Security\Core\User\UserInterface; final class NotificationByUserCounter implements NotificationCounterInterface { - private CacheItemPoolInterface $cacheItemPool; - - private NotificationRepository $notificationRepository; - - public function __construct(CacheItemPoolInterface $cacheItemPool, NotificationRepository $notificationRepository) + public function __construct(private CacheItemPoolInterface $cacheItemPool, private NotificationRepository $notificationRepository) { - $this->cacheItemPool = $cacheItemPool; - $this->notificationRepository = $notificationRepository; } public function addNotification(UserInterface $u): int diff --git a/src/Bundle/ChillMainBundle/Notification/Email/NotificationMailer.php b/src/Bundle/ChillMainBundle/Notification/Email/NotificationMailer.php index 5290492b1..3d63c28a9 100644 --- a/src/Bundle/ChillMainBundle/Notification/Email/NotificationMailer.php +++ b/src/Bundle/ChillMainBundle/Notification/Email/NotificationMailer.php @@ -25,17 +25,8 @@ use Symfony\Contracts\Translation\TranslatorInterface; class NotificationMailer { - private LoggerInterface $logger; - - private MailerInterface $mailer; - - private TranslatorInterface $translator; - - public function __construct(MailerInterface $mailer, LoggerInterface $logger, TranslatorInterface $translator) + public function __construct(private MailerInterface $mailer, private LoggerInterface $logger, private TranslatorInterface $translator) { - $this->mailer = $mailer; - $this->logger = $logger; - $this->translator = $translator; } public function postPersistComment(NotificationComment $comment, PostPersistEventArgs $eventArgs): void diff --git a/src/Bundle/ChillMainBundle/Notification/EventListener/PersistNotificationOnTerminateEventSubscriber.php b/src/Bundle/ChillMainBundle/Notification/EventListener/PersistNotificationOnTerminateEventSubscriber.php index f9e050769..0601f0141 100644 --- a/src/Bundle/ChillMainBundle/Notification/EventListener/PersistNotificationOnTerminateEventSubscriber.php +++ b/src/Bundle/ChillMainBundle/Notification/EventListener/PersistNotificationOnTerminateEventSubscriber.php @@ -19,14 +19,8 @@ use function count; class PersistNotificationOnTerminateEventSubscriber implements EventSubscriberInterface { - private EntityManagerInterface $em; - - private NotificationPersisterInterface $persister; - - public function __construct(EntityManagerInterface $em, NotificationPersisterInterface $persister) + public function __construct(private EntityManagerInterface $em, private NotificationPersisterInterface $persister) { - $this->em = $em; - $this->persister = $persister; } public static function getSubscribedEvents() diff --git a/src/Bundle/ChillMainBundle/Notification/Mailer.php b/src/Bundle/ChillMainBundle/Notification/Mailer.php index 307d5d1df..d0a449787 100644 --- a/src/Bundle/ChillMainBundle/Notification/Mailer.php +++ b/src/Bundle/ChillMainBundle/Notification/Mailer.php @@ -39,11 +39,6 @@ class Mailer */ private $logger; - /** - * @var array - */ - private $routeParameters; - /** * @var RouterInterface */ @@ -62,6 +57,7 @@ class Mailer * Mailer constructor. * * @param $routeParameters + * @param mixed[] $routeParameters */ public function __construct( MailerInterface $mailer, @@ -69,14 +65,13 @@ class Mailer EngineInterface $twig, RouterInterface $router, TranslatorInterface $translator, - $routeParameters + protected $routeParameters ) { $this->logger = $logger; $this->twig = $twig; $this->mailer = $mailer; $this->router = $router; $this->translator = $translator; - $this->routeParameters = $routeParameters; } /** @@ -112,15 +107,13 @@ class Mailer * @param array $subject Subject of the message [ 0 => $message (required), 1 => $parameters (optional), 3 => $domain (optional) ] * @param array $bodies The bodies. An array where keys are the contentType and values the bodies * @param callable $callback a callback to customize the message (add attachment, etc.) - * @param mixed $recipient - * @param mixed $force */ public function sendNotification( - $recipient, + mixed $recipient, array $subject, array $bodies, ?callable $callback = null, - $force = false + mixed $force = false ) { $fromEmail = $this->routeParameters['from_email']; $fromName = $this->routeParameters['from_name']; diff --git a/src/Bundle/ChillMainBundle/Notification/NotificationHandlerManager.php b/src/Bundle/ChillMainBundle/Notification/NotificationHandlerManager.php index 9efe69ffb..d39bc8a00 100644 --- a/src/Bundle/ChillMainBundle/Notification/NotificationHandlerManager.php +++ b/src/Bundle/ChillMainBundle/Notification/NotificationHandlerManager.php @@ -17,16 +17,8 @@ use Doctrine\ORM\EntityManagerInterface; final class NotificationHandlerManager { - private EntityManagerInterface $em; - - private iterable $handlers; - - public function __construct( - iterable $handlers, - EntityManagerInterface $em - ) { - $this->handlers = $handlers; - $this->em = $em; + public function __construct(private iterable $handlers, private EntityManagerInterface $em) + { } /** diff --git a/src/Bundle/ChillMainBundle/Notification/NotificationPresence.php b/src/Bundle/ChillMainBundle/Notification/NotificationPresence.php index c09b845d7..51cb73ccf 100644 --- a/src/Bundle/ChillMainBundle/Notification/NotificationPresence.php +++ b/src/Bundle/ChillMainBundle/Notification/NotificationPresence.php @@ -24,14 +24,8 @@ class NotificationPresence { private array $cache = []; - private NotificationRepository $notificationRepository; - - private Security $security; - - public function __construct(Security $security, NotificationRepository $notificationRepository) + public function __construct(private Security $security, private NotificationRepository $notificationRepository) { - $this->security = $security; - $this->notificationRepository = $notificationRepository; } public function countNotificationsForClassAndEntity(string $relatedEntityClass, int $relatedEntityId): array diff --git a/src/Bundle/ChillMainBundle/Notification/Templating/NotificationTwigExtensionRuntime.php b/src/Bundle/ChillMainBundle/Notification/Templating/NotificationTwigExtensionRuntime.php index 0720c6da6..3c31b7201 100644 --- a/src/Bundle/ChillMainBundle/Notification/Templating/NotificationTwigExtensionRuntime.php +++ b/src/Bundle/ChillMainBundle/Notification/Templating/NotificationTwigExtensionRuntime.php @@ -21,17 +21,8 @@ use Twig\Extension\RuntimeExtensionInterface; class NotificationTwigExtensionRuntime implements RuntimeExtensionInterface { - private FormFactoryInterface $formFactory; - - private NotificationPresence $notificationPresence; - - private UrlGeneratorInterface $urlGenerator; - - public function __construct(FormFactoryInterface $formFactory, NotificationPresence $notificationPresence, UrlGeneratorInterface $urlGenerator) + public function __construct(private FormFactoryInterface $formFactory, private NotificationPresence $notificationPresence, private UrlGeneratorInterface $urlGenerator) { - $this->formFactory = $formFactory; - $this->notificationPresence = $notificationPresence; - $this->urlGenerator = $urlGenerator; } public function counterNotificationFor(Environment $environment, string $relatedEntityClass, int $relatedEntityId, array $options = []): string diff --git a/src/Bundle/ChillMainBundle/Pagination/ChillPaginationTwig.php b/src/Bundle/ChillMainBundle/Pagination/ChillPaginationTwig.php index 2831d9322..2c75ad41a 100644 --- a/src/Bundle/ChillMainBundle/Pagination/ChillPaginationTwig.php +++ b/src/Bundle/ChillMainBundle/Pagination/ChillPaginationTwig.php @@ -48,20 +48,11 @@ class ChillPaginationTwig extends AbstractExtension PaginatorInterface $paginator, $template = '@ChillMain/Pagination/long.html.twig' ) { - switch ($template) { - case 'long': - $t = self::LONG_TEMPLATE; - - break; - - case 'short': - $t = self::SHORT_TEMPLATE; - - break; - - default: - $t = $template; - } + $t = match ($template) { + 'long' => self::LONG_TEMPLATE, + 'short' => self::SHORT_TEMPLATE, + default => $template, + }; return $env->render($t, [ 'paginator' => $paginator, diff --git a/src/Bundle/ChillMainBundle/Pagination/Page.php b/src/Bundle/ChillMainBundle/Pagination/Page.php index d7c47ebbd..597d3d2e5 100644 --- a/src/Bundle/ChillMainBundle/Pagination/Page.php +++ b/src/Bundle/ChillMainBundle/Pagination/Page.php @@ -18,59 +18,36 @@ use Symfony\Component\Routing\Generator\UrlGeneratorInterface; */ class Page implements PageInterface { - /** - * the number of item per page. - * - */ - protected int $itemPerPage; - - /** - * the number of the current page. - * - * @var int - */ - protected int $number; - - /** - * The route for the current page. - * - * @var string - */ - protected string $route; - - /** - * Parameters for the route to the current page. - * - * @var array - */ - protected array $routeParameters; - - /** - * The number of items in the whole iteration. - * - * @var int - */ - protected int $totalItems; - /** * @var UrlGeneratorInterface */ protected $urlGenerator; public function __construct( - int $number, - int $itemPerPage, + /** + * the number of the current page. + */ + protected int $number, + /** + * the number of item per page. + * + */ + protected int $itemPerPage, UrlGeneratorInterface $urlGenerator, - string $route, - array $routeParameters, - int $totalItems + /** + * The route for the current page. + */ + protected string $route, + /** + * Parameters for the route to the current page. + */ + protected array $routeParameters, + /** + * The number of items in the whole iteration. + */ + protected int $totalItems ) { $this->urlGenerator = $urlGenerator; - $this->number = $number; - $this->itemPerPage = $itemPerPage; - $this->route = $route; - $this->routeParameters = $routeParameters; - $this->totalItems = $totalItems; } public function generateUrl(): string diff --git a/src/Bundle/ChillMainBundle/Pagination/PageGenerator.php b/src/Bundle/ChillMainBundle/Pagination/PageGenerator.php index 4a10fde2a..07d89fd1b 100644 --- a/src/Bundle/ChillMainBundle/Pagination/PageGenerator.php +++ b/src/Bundle/ChillMainBundle/Pagination/PageGenerator.php @@ -20,11 +20,8 @@ class PageGenerator implements Iterator { protected int $current = 1; - protected Paginator $paginator; - - public function __construct(Paginator $paginator) + public function __construct(protected Paginator $paginator) { - $this->paginator = $paginator; } public function current(): Page diff --git a/src/Bundle/ChillMainBundle/Pagination/Paginator.php b/src/Bundle/ChillMainBundle/Pagination/Paginator.php index 5427bf46d..b7d5aa9ca 100644 --- a/src/Bundle/ChillMainBundle/Pagination/Paginator.php +++ b/src/Bundle/ChillMainBundle/Pagination/Paginator.php @@ -22,80 +22,43 @@ use Symfony\Component\Routing\Generator\UrlGeneratorInterface; class Paginator implements PaginatorInterface { /** - * The number of the current page. - * - * @var int + * @param string[] $routeParameters */ - protected int $currentPageNumber; - - /** - * the number of items on a single page. - * - * @var int - */ - protected int $itemPerPage; - - /** - * the key in the GET parameter to indicate the number of item per page. - * - * @var string - */ - protected string $itemPerPageKey; - - /** - * the key in the GET parameter to indicate the page number in - * generated routes. - * - * @var string - */ - protected string $pageKey; - - /** - * the route of the pages. - * - * @var string - */ - protected string $route; - - /** - * the parameters of the route. - * - * @var string[] - */ - protected array $routeParameters; - - /** - * The number of total items. - * - * @var int - */ - protected int $totalItems; - - /** - * the generator for url. - * - * @var UrlGeneratorInterface - */ - protected UrlGeneratorInterface $urlGenerator; - public function __construct( - int $totalItems, - int $itemPerPage, - int $currentPageNumber, - string $route, - array $routeParameters, - UrlGeneratorInterface $urlGenerator, - string $pageKey, - string $itemPerPageKey + /** + * The number of total items. + */ + protected int $totalItems, + /** + * the number of items on a single page. + */ + protected int $itemPerPage, + /** + * The number of the current page. + */ + protected int $currentPageNumber, + /** + * the route of the pages. + */ + protected string $route, + /** + * the parameters of the route. + */ + protected array $routeParameters, + /** + * the generator for url. + */ + protected UrlGeneratorInterface $urlGenerator, + /** + * the key in the GET parameter to indicate the page number in + * generated routes. + */ + protected string $pageKey, + /** + * the key in the GET parameter to indicate the number of item per page. + */ + protected string $itemPerPageKey ) { - $this->totalItems = $totalItems; - $this->itemPerPage = $itemPerPage; - $this->currentPageNumber = $currentPageNumber; - $this->route = $route; - $this->routeParameters = $routeParameters; - $this->urlGenerator = $urlGenerator; - $this->pageKey = $pageKey; - $this->itemPerPageKey = $itemPerPageKey; } public function count(): int diff --git a/src/Bundle/ChillMainBundle/Pagination/PaginatorFactory.php b/src/Bundle/ChillMainBundle/Pagination/PaginatorFactory.php index 7f06bf216..60f9a6bc0 100644 --- a/src/Bundle/ChillMainBundle/Pagination/PaginatorFactory.php +++ b/src/Bundle/ChillMainBundle/Pagination/PaginatorFactory.php @@ -26,35 +26,23 @@ class PaginatorFactory public const DEFAULT_PAGE_NUMBER = 1; /** - * the default item per page. This may be overriden by - * the request or inside the paginator. - * - * @var int + * @param int $itemPerPage */ - private $itemPerPage; - - /** - * the request stack. - * - * @var RequestStack - */ - private $requestStack; - - /** - * the router and generator for url. - * - * @var RouterInterface - */ - private $router; - public function __construct( - RequestStack $requestStack, - RouterInterface $router, - $itemPerPage = 20 + /** + * the request stack. + */ + private RequestStack $requestStack, + /** + * the router and generator for url. + */ + private RouterInterface $router, + /** + * the default item per page. This may be overriden by + * the request or inside the paginator. + */ + private $itemPerPage = 20 ) { - $this->itemPerPage = $itemPerPage; - $this->requestStack = $requestStack; - $this->router = $router; } /** @@ -71,7 +59,7 @@ class PaginatorFactory */ public function create( $totalItems, - $route = null, + ?string $route = null, ?array $routeParameters = null ) { return new Paginator( diff --git a/src/Bundle/ChillMainBundle/Phonenumber/PhonenumberHelper.php b/src/Bundle/ChillMainBundle/Phonenumber/PhonenumberHelper.php index a92db39ce..0c6fbbf03 100644 --- a/src/Bundle/ChillMainBundle/Phonenumber/PhonenumberHelper.php +++ b/src/Bundle/ChillMainBundle/Phonenumber/PhonenumberHelper.php @@ -35,25 +35,19 @@ final class PhonenumberHelper implements PhoneNumberHelperInterface public const LOOKUP_URI = 'https://lookups.twilio.com/v1/PhoneNumbers/%s'; - private CacheItemPoolInterface $cachePool; - private array $config; private bool $isConfigured = false; - private LoggerInterface $logger; - private PhonenumberUtil $phoneNumberUtil; private Client $twilioClient; public function __construct( - CacheItemPoolInterface $cacheUserData, + private CacheItemPoolInterface $cachePool, ParameterBagInterface $parameterBag, - LoggerInterface $logger + private LoggerInterface $logger ) { - $this->logger = $logger; - $this->cachePool = $cacheUserData; $this->config = $config = $parameterBag->get('chill_main.phone_helper'); if ( @@ -93,17 +87,11 @@ final class PhonenumberHelper implements PhoneNumberHelperInterface */ public function getType(PhoneNumber $phonenumber): string { - switch ($this->phoneNumberUtil->getNumberType($phonenumber)) { - case PhoneNumberType::MOBILE: - return 'mobile'; - - case PhoneNumberType::FIXED_LINE: - case PhoneNumberType::VOIP: - return 'landline'; - - default: - return 'landline'; - } + return match ($this->phoneNumberUtil->getNumberType($phonenumber)) { + PhoneNumberType::MOBILE => 'mobile', + PhoneNumberType::FIXED_LINE, PhoneNumberType::VOIP => 'landline', + default => 'landline', + }; } /** diff --git a/src/Bundle/ChillMainBundle/Phonenumber/Templating.php b/src/Bundle/ChillMainBundle/Phonenumber/Templating.php index b6304e0de..6f4f09bfd 100644 --- a/src/Bundle/ChillMainBundle/Phonenumber/Templating.php +++ b/src/Bundle/ChillMainBundle/Phonenumber/Templating.php @@ -16,11 +16,8 @@ use Twig\TwigFilter; class Templating extends AbstractExtension { - protected PhonenumberHelper $phonenumberHelper; - - public function __construct(PhonenumberHelper $phonenumberHelper) + public function __construct(protected PhonenumberHelper $phonenumberHelper) { - $this->phonenumberHelper = $phonenumberHelper; } public function formatPhonenumber($phonenumber) diff --git a/src/Bundle/ChillMainBundle/Repository/NotificationRepository.php b/src/Bundle/ChillMainBundle/Repository/NotificationRepository.php index 72f9ea5d1..5677adedb 100644 --- a/src/Bundle/ChillMainBundle/Repository/NotificationRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/NotificationRepository.php @@ -23,16 +23,13 @@ use Doctrine\Persistence\ObjectRepository; final class NotificationRepository implements ObjectRepository { - private EntityManagerInterface $em; - private ?Statement $notificationByRelatedEntityAndUserAssociatedStatement = null; private EntityRepository $repository; - public function __construct(EntityManagerInterface $entityManager) + public function __construct(private EntityManagerInterface $em) { - $this->em = $entityManager; - $this->repository = $entityManager->getRepository(Notification::class); + $this->repository = $em->getRepository(Notification::class); } public function countAllForAttendee(User $addressee): int diff --git a/src/Bundle/ChillMainBundle/Repository/UserACLAwareRepository.php b/src/Bundle/ChillMainBundle/Repository/UserACLAwareRepository.php index 395874deb..a64c77f10 100644 --- a/src/Bundle/ChillMainBundle/Repository/UserACLAwareRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/UserACLAwareRepository.php @@ -19,14 +19,8 @@ use Doctrine\ORM\EntityManagerInterface; class UserACLAwareRepository implements UserACLAwareRepositoryInterface { - private EntityManagerInterface $em; - - private ParentRoleHelper $parentRoleHelper; - - public function __construct(ParentRoleHelper $parentRoleHelper, EntityManagerInterface $em) + public function __construct(private ParentRoleHelper $parentRoleHelper, private EntityManagerInterface $em) { - $this->parentRoleHelper = $parentRoleHelper; - $this->em = $em; } public function findUsersByReachedACL(string $role, $center, $scope = null, bool $onlyEnabled = true): array diff --git a/src/Bundle/ChillMainBundle/Repository/UserRepository.php b/src/Bundle/ChillMainBundle/Repository/UserRepository.php index a26ae04ad..360171f58 100644 --- a/src/Bundle/ChillMainBundle/Repository/UserRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/UserRepository.php @@ -24,13 +24,10 @@ use function count; final class UserRepository implements UserRepositoryInterface { - private EntityManagerInterface $entityManager; - private EntityRepository $repository; - public function __construct(EntityManagerInterface $entityManager) + public function __construct(private EntityManagerInterface $entityManager) { - $this->entityManager = $entityManager; $this->repository = $entityManager->getRepository(User::class); } @@ -150,7 +147,7 @@ final class UserRepository implements UserRepositoryInterface try { return $qb->getQuery()->getSingleResult(); - } catch (NoResultException $e) { + } catch (NoResultException) { return null; } } diff --git a/src/Bundle/ChillMainBundle/Routing/Loader/ChillRoutesLoader.php b/src/Bundle/ChillMainBundle/Routing/Loader/ChillRoutesLoader.php index 112054ee3..ebfb263aa 100644 --- a/src/Bundle/ChillMainBundle/Routing/Loader/ChillRoutesLoader.php +++ b/src/Bundle/ChillMainBundle/Routing/Loader/ChillRoutesLoader.php @@ -22,12 +22,8 @@ use Symfony\Component\Routing\RouteCollection; */ class ChillRoutesLoader extends Loader { - private array $routes; - - public function __construct(array $routes) + public function __construct(private array $routes) { - $this->routes = $routes; - parent::__construct(); } diff --git a/src/Bundle/ChillMainBundle/Routing/MenuBuilder/AdminUserMenuBuilder.php b/src/Bundle/ChillMainBundle/Routing/MenuBuilder/AdminUserMenuBuilder.php index 7bd23c81f..4a2ad04ad 100644 --- a/src/Bundle/ChillMainBundle/Routing/MenuBuilder/AdminUserMenuBuilder.php +++ b/src/Bundle/ChillMainBundle/Routing/MenuBuilder/AdminUserMenuBuilder.php @@ -23,14 +23,11 @@ class AdminUserMenuBuilder implements LocalMenuBuilderInterface */ protected $authorizationChecker; - protected ParameterBagInterface $parameterBag; - public function __construct( AuthorizationCheckerInterface $authorizationChecker, - ParameterBagInterface $parameterBag + protected ParameterBagInterface $parameterBag ) { $this->authorizationChecker = $authorizationChecker; - $this->parameterBag = $parameterBag; } public function buildMenu($menuId, MenuItem $menu, array $parameters) diff --git a/src/Bundle/ChillMainBundle/Routing/MenuBuilder/SectionMenuBuilder.php b/src/Bundle/ChillMainBundle/Routing/MenuBuilder/SectionMenuBuilder.php index 305b944d8..c58c65189 100644 --- a/src/Bundle/ChillMainBundle/Routing/MenuBuilder/SectionMenuBuilder.php +++ b/src/Bundle/ChillMainBundle/Routing/MenuBuilder/SectionMenuBuilder.php @@ -23,20 +23,11 @@ use Symfony\Contracts\Translation\TranslatorInterface; */ class SectionMenuBuilder implements LocalMenuBuilderInterface { - protected AuthorizationCheckerInterface $authorizationChecker; - - protected ParameterBagInterface $parameterBag; - - protected TranslatorInterface $translator; - /** * SectionMenuBuilder constructor. */ - public function __construct(AuthorizationCheckerInterface $authorizationChecker, TranslatorInterface $translator, ParameterBagInterface $parameterBag) + public function __construct(protected AuthorizationCheckerInterface $authorizationChecker, protected TranslatorInterface $translator, protected ParameterBagInterface $parameterBag) { - $this->authorizationChecker = $authorizationChecker; - $this->translator = $translator; - $this->parameterBag = $parameterBag; } /** diff --git a/src/Bundle/ChillMainBundle/Routing/MenuBuilder/UserMenuBuilder.php b/src/Bundle/ChillMainBundle/Routing/MenuBuilder/UserMenuBuilder.php index e4ee3b062..81c84a7a8 100644 --- a/src/Bundle/ChillMainBundle/Routing/MenuBuilder/UserMenuBuilder.php +++ b/src/Bundle/ChillMainBundle/Routing/MenuBuilder/UserMenuBuilder.php @@ -22,32 +22,8 @@ use Symfony\Contracts\Translation\TranslatorInterface; class UserMenuBuilder implements LocalMenuBuilderInterface { - protected ParameterBagInterface $parameterBag; - - private NotificationByUserCounter $notificationByUserCounter; - - private RequestStack $requestStack; - - private Security $security; - - private TranslatorInterface $translator; - - private WorkflowByUserCounter $workflowByUserCounter; - - public function __construct( - NotificationByUserCounter $notificationByUserCounter, - WorkflowByUserCounter $workflowByUserCounter, - Security $security, - TranslatorInterface $translator, - ParameterBagInterface $parameterBag, - RequestStack $requestStack - ) { - $this->notificationByUserCounter = $notificationByUserCounter; - $this->workflowByUserCounter = $workflowByUserCounter; - $this->security = $security; - $this->translator = $translator; - $this->parameterBag = $parameterBag; - $this->requestStack = $requestStack; + public function __construct(private NotificationByUserCounter $notificationByUserCounter, private WorkflowByUserCounter $workflowByUserCounter, private Security $security, private TranslatorInterface $translator, protected ParameterBagInterface $parameterBag, private RequestStack $requestStack) + { } public function buildMenu($menuId, \Knp\Menu\MenuItem $menu, array $parameters) diff --git a/src/Bundle/ChillMainBundle/Routing/MenuComposer.php b/src/Bundle/ChillMainBundle/Routing/MenuComposer.php index 2fc1eb3d0..ed9ff5169 100644 --- a/src/Bundle/ChillMainBundle/Routing/MenuComposer.php +++ b/src/Bundle/ChillMainBundle/Routing/MenuComposer.php @@ -31,22 +31,10 @@ class MenuComposer { private array $localMenuBuilders = []; - private FactoryInterface $menuFactory; - private RouteCollection $routeCollection; - private RouterInterface $router; - - private TranslatorInterface $translator; - - public function __construct( - RouterInterface $router, - FactoryInterface $menuFactory, - TranslatorInterface $translator - ) { - $this->router = $router; - $this->menuFactory = $menuFactory; - $this->translator = $translator; + public function __construct(private RouterInterface $router, private FactoryInterface $menuFactory, private TranslatorInterface $translator) + { } public function addLocalMenuBuilder(LocalMenuBuilderInterface $menuBuilder, $menuId) diff --git a/src/Bundle/ChillMainBundle/Routing/MenuTwig.php b/src/Bundle/ChillMainBundle/Routing/MenuTwig.php index bca9a81c3..b77d4343f 100644 --- a/src/Bundle/ChillMainBundle/Routing/MenuTwig.php +++ b/src/Bundle/ChillMainBundle/Routing/MenuTwig.php @@ -38,14 +38,8 @@ class MenuTwig extends AbstractExtension implements ContainerAwareInterface 'activeRouteKey' => null, ]; - /** - * @var MenuComposer - */ - private $menuComposer; - - public function __construct(MenuComposer $menuComposer) + public function __construct(private MenuComposer $menuComposer) { - $this->menuComposer = $menuComposer; } /** diff --git a/src/Bundle/ChillMainBundle/Search/AbstractSearch.php b/src/Bundle/ChillMainBundle/Search/AbstractSearch.php index 0ddf5cd0a..f65319a09 100644 --- a/src/Bundle/ChillMainBundle/Search/AbstractSearch.php +++ b/src/Bundle/ChillMainBundle/Search/AbstractSearch.php @@ -65,7 +65,7 @@ abstract class AbstractSearch implements SearchInterface foreach ($supportedTerms as $term) { if (array_key_exists($term, $terms) && '_default' !== $term) { $recomposed .= ' ' . $term . ':'; - $containsSpace = strpos($terms[$term], ' ') !== false; + $containsSpace = str_contains($terms[$term], ' '); if ($containsSpace) { $recomposed .= '"'; diff --git a/src/Bundle/ChillMainBundle/Search/Entity/SearchUserApiProvider.php b/src/Bundle/ChillMainBundle/Search/Entity/SearchUserApiProvider.php index 6affc5a5d..397e0b589 100644 --- a/src/Bundle/ChillMainBundle/Search/Entity/SearchUserApiProvider.php +++ b/src/Bundle/ChillMainBundle/Search/Entity/SearchUserApiProvider.php @@ -20,11 +20,8 @@ use function in_array; class SearchUserApiProvider implements SearchApiInterface { - private UserRepository $userRepository; - - public function __construct(UserRepository $userRepository) + public function __construct(private UserRepository $userRepository) { - $this->userRepository = $userRepository; } public function getResult(string $key, array $metadata, float $pertinence) diff --git a/src/Bundle/ChillMainBundle/Search/Model/Result.php b/src/Bundle/ChillMainBundle/Search/Model/Result.php index 33312a961..1ef249c1f 100644 --- a/src/Bundle/ChillMainBundle/Search/Model/Result.php +++ b/src/Bundle/ChillMainBundle/Search/Model/Result.php @@ -13,20 +13,16 @@ namespace Chill\MainBundle\Search\Model; class Result { - private float $relevance; - - /** - * mixed an arbitrary result. - */ - private $result; - /** * @param $result */ - public function __construct(float $relevance, $result) - { - $this->relevance = $relevance; - $this->result = $result; + public function __construct( + private float $relevance, + /** + * mixed an arbitrary result. + */ + private $result + ) { } public function getRelevance(): float diff --git a/src/Bundle/ChillMainBundle/Search/SearchApi.php b/src/Bundle/ChillMainBundle/Search/SearchApi.php index 1fea71c46..e7159db06 100644 --- a/src/Bundle/ChillMainBundle/Search/SearchApi.php +++ b/src/Bundle/ChillMainBundle/Search/SearchApi.php @@ -26,20 +26,8 @@ use function strtr; class SearchApi { - private EntityManagerInterface $em; - - private PaginatorFactory $paginator; - - private iterable $providers; - - public function __construct( - EntityManagerInterface $em, - iterable $providers, - PaginatorFactory $paginator - ) { - $this->em = $em; - $this->providers = $providers; - $this->paginator = $paginator; + public function __construct(private EntityManagerInterface $em, private iterable $providers, private PaginatorFactory $paginator) + { } public function getResults(string $pattern, array $types, array $parameters): Collection diff --git a/src/Bundle/ChillMainBundle/Search/SearchApiNoQueryException.php b/src/Bundle/ChillMainBundle/Search/SearchApiNoQueryException.php index 6a389088d..542e18d7c 100644 --- a/src/Bundle/ChillMainBundle/Search/SearchApiNoQueryException.php +++ b/src/Bundle/ChillMainBundle/Search/SearchApiNoQueryException.php @@ -18,19 +18,16 @@ use function implode; class SearchApiNoQueryException extends RuntimeException { - private array $parameters; - private string $pattern; private array $types; - public function __construct(string $pattern = '', array $types = [], array $parameters = [], $code = 0, ?Throwable $previous = null) + public function __construct(string $pattern = '', array $types = [], private array $parameters = [], $code = 0, ?Throwable $previous = null) { $typesStr = implode(', ', $types); $message = "No query for this search: pattern : {$pattern}, types: {$typesStr}"; $this->pattern = $pattern; $this->types = $types; - $this->parameters = $parameters; parent::__construct($message, $code, $previous); } diff --git a/src/Bundle/ChillMainBundle/Search/SearchApiResult.php b/src/Bundle/ChillMainBundle/Search/SearchApiResult.php index cd0fa06e1..b49c01565 100644 --- a/src/Bundle/ChillMainBundle/Search/SearchApiResult.php +++ b/src/Bundle/ChillMainBundle/Search/SearchApiResult.php @@ -17,13 +17,10 @@ class SearchApiResult { private float $pertinence; - private float $relevance; - private $result; - public function __construct(float $relevance) + public function __construct(private float $relevance) { - $this->relevance = $relevance; } /** diff --git a/src/Bundle/ChillMainBundle/Search/SearchProvider.php b/src/Bundle/ChillMainBundle/Search/SearchProvider.php index 095b749bc..52b484c2d 100644 --- a/src/Bundle/ChillMainBundle/Search/SearchProvider.php +++ b/src/Bundle/ChillMainBundle/Search/SearchProvider.php @@ -62,13 +62,11 @@ class SearchProvider * return search services with a specific name, defined in service * definition. * - * @param mixed $name * * @throws UnknowSearchNameException if not exists - * * @return SearchInterface */ - public function getByName($name) + public function getByName(mixed $name) { if (isset($this->searchServices[$name])) { return $this->searchServices[$name]; diff --git a/src/Bundle/ChillMainBundle/Search/Utils/SearchExtractionResult.php b/src/Bundle/ChillMainBundle/Search/Utils/SearchExtractionResult.php index 0c885de59..20d5948a3 100644 --- a/src/Bundle/ChillMainBundle/Search/Utils/SearchExtractionResult.php +++ b/src/Bundle/ChillMainBundle/Search/Utils/SearchExtractionResult.php @@ -13,14 +13,8 @@ namespace Chill\MainBundle\Search\Utils; class SearchExtractionResult { - private string $filteredSubject; - - private array $found; - - public function __construct(string $filteredSubject, array $found) + public function __construct(private string $filteredSubject, private array $found) { - $this->filteredSubject = $filteredSubject; - $this->found = $found; } public function getFilteredSubject(): string diff --git a/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php b/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php index 1105c9d8a..2ba3865b7 100644 --- a/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php +++ b/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php @@ -34,28 +34,8 @@ use function get_class; */ class AuthorizationHelper implements AuthorizationHelperInterface { - private CenterResolverManagerInterface $centerResolverManager; - - private LoggerInterface $logger; - - private ParentRoleHelper $parentRoleHelper; - - private ScopeResolverDispatcher $scopeResolverDispatcher; - - private UserACLAwareRepositoryInterface $userACLAwareRepository; - - public function __construct( - CenterResolverManagerInterface $centerResolverManager, - LoggerInterface $logger, - ScopeResolverDispatcher $scopeResolverDispatcher, - UserACLAwareRepositoryInterface $userACLAwareRepository, - ParentRoleHelper $parentRoleHelper - ) { - $this->centerResolverManager = $centerResolverManager; - $this->logger = $logger; - $this->scopeResolverDispatcher = $scopeResolverDispatcher; - $this->userACLAwareRepository = $userACLAwareRepository; - $this->parentRoleHelper = $parentRoleHelper; + public function __construct(private CenterResolverManagerInterface $centerResolverManager, private LoggerInterface $logger, private ScopeResolverDispatcher $scopeResolverDispatcher, private UserACLAwareRepositoryInterface $userACLAwareRepository, private ParentRoleHelper $parentRoleHelper) + { } /** @@ -63,9 +43,8 @@ class AuthorizationHelper implements AuthorizationHelperInterface * * @param User $user The user * @param array $centers a list of centers which are going to be filtered - * @param mixed $role */ - public function filterReachableCenters(User $user, array $centers, $role): array + public function filterReachableCenters(User $user, array $centers, mixed $role): array { $results = []; @@ -85,12 +64,10 @@ class AuthorizationHelper implements AuthorizationHelperInterface /** * @deprecated use UserACLAwareRepositoryInterface::findUsersByReachedACL instead * - * @param array|Center|Center[] $center - * @param array|Scope|Scope[]|null $scope * * @return User[] */ - public function findUsersReaching(string $role, $center, $scope = null, bool $onlyEnabled = true): array + public function findUsersReaching(string $role, array|\Chill\MainBundle\Entity\Center $center, array|\Chill\MainBundle\Entity\Scope|null $scope = null, bool $onlyEnabled = true): array { return $this->userACLAwareRepository ->findUsersByReachedACL($role, $center, $scope, $onlyEnabled); @@ -155,12 +132,10 @@ class AuthorizationHelper implements AuthorizationHelperInterface /** * Return all reachable circle for a given user, center and role. * - * @param Role|string $role * @param Center|Center[] $center - * * @return Scope[] */ - public function getReachableCircles(UserInterface $user, $role, $center) + public function getReachableCircles(UserInterface $user, \Symfony\Component\Security\Core\Role\Role|string $role, \Chill\MainBundle\Entity\Center|array $center) { $scopes = []; @@ -210,7 +185,7 @@ class AuthorizationHelper implements AuthorizationHelperInterface * * @param Center|Center[] $center May be an array of center */ - public function userCanReachCenter(User $user, $center): bool + public function userCanReachCenter(User $user, \Chill\MainBundle\Entity\Center|array $center): bool { if ($center instanceof Traversable) { foreach ($center as $c) { @@ -236,7 +211,7 @@ class AuthorizationHelper implements AuthorizationHelperInterface sprintf( 'The entity given is not an instance of %s, %s given', Center::class, - get_class($center) + $center::class ) ); } @@ -252,7 +227,7 @@ class AuthorizationHelper implements AuthorizationHelperInterface * * @return bool true if the user has access */ - public function userHasAccess(User $user, $entity, $attribute) + public function userHasAccess(User $user, mixed $entity, \Symfony\Component\Security\Core\Role\Role|string $attribute) { $centers = $this->centerResolverManager->resolveCenters($entity); diff --git a/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelperForCurrentUser.php b/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelperForCurrentUser.php index 55005fe92..45a1f3095 100644 --- a/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelperForCurrentUser.php +++ b/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelperForCurrentUser.php @@ -17,14 +17,8 @@ use Symfony\Component\Security\Core\Security; class AuthorizationHelperForCurrentUser implements AuthorizationHelperForCurrentUserInterface { - private AuthorizationHelperInterface $authorizationHelper; - - private Security $security; - - public function __construct(AuthorizationHelperInterface $authorizationHelper, Security $security) + public function __construct(private AuthorizationHelperInterface $authorizationHelper, private Security $security) { - $this->authorizationHelper = $authorizationHelper; - $this->security = $security; } public function getReachableCenters(string $role, ?Scope $scope = null): array diff --git a/src/Bundle/ChillMainBundle/Security/Authorization/DefaultVoterHelper.php b/src/Bundle/ChillMainBundle/Security/Authorization/DefaultVoterHelper.php index ec2b2112c..c6ae44d9f 100644 --- a/src/Bundle/ChillMainBundle/Security/Authorization/DefaultVoterHelper.php +++ b/src/Bundle/ChillMainBundle/Security/Authorization/DefaultVoterHelper.php @@ -18,20 +18,8 @@ use function in_array; final class DefaultVoterHelper implements VoterHelperInterface { - private AuthorizationHelper $authorizationHelper; - - private CenterResolverDispatcherInterface $centerResolverDispatcher; - - private array $configuration = []; - - public function __construct( - AuthorizationHelper $authorizationHelper, - CenterResolverDispatcherInterface $centerResolverDispatcher, - array $configuration - ) { - $this->authorizationHelper = $authorizationHelper; - $this->centerResolverDispatcher = $centerResolverDispatcher; - $this->configuration = $configuration; + public function __construct(private AuthorizationHelper $authorizationHelper, private CenterResolverDispatcherInterface $centerResolverDispatcher, private array $configuration) + { } public function supports($attribute, $subject): bool diff --git a/src/Bundle/ChillMainBundle/Security/Authorization/DefaultVoterHelperFactory.php b/src/Bundle/ChillMainBundle/Security/Authorization/DefaultVoterHelperFactory.php index 6fd0b0ef0..d00fc6495 100644 --- a/src/Bundle/ChillMainBundle/Security/Authorization/DefaultVoterHelperFactory.php +++ b/src/Bundle/ChillMainBundle/Security/Authorization/DefaultVoterHelperFactory.php @@ -15,16 +15,8 @@ use Chill\MainBundle\Security\Resolver\CenterResolverDispatcherInterface; class DefaultVoterHelperFactory implements VoterHelperFactoryInterface { - protected AuthorizationHelper $authorizationHelper; - - protected CenterResolverDispatcherInterface $centerResolverDispatcher; - - public function __construct( - AuthorizationHelper $authorizationHelper, - CenterResolverDispatcherInterface $centerResolverDispatcher - ) { - $this->authorizationHelper = $authorizationHelper; - $this->centerResolverDispatcher = $centerResolverDispatcher; + public function __construct(protected AuthorizationHelper $authorizationHelper, protected CenterResolverDispatcherInterface $centerResolverDispatcher) + { } public function generate($context): VoterGeneratorInterface diff --git a/src/Bundle/ChillMainBundle/Security/Authorization/DefaultVoterHelperGenerator.php b/src/Bundle/ChillMainBundle/Security/Authorization/DefaultVoterHelperGenerator.php index 2e56c9856..7844632d8 100644 --- a/src/Bundle/ChillMainBundle/Security/Authorization/DefaultVoterHelperGenerator.php +++ b/src/Bundle/ChillMainBundle/Security/Authorization/DefaultVoterHelperGenerator.php @@ -15,18 +15,10 @@ use Chill\MainBundle\Security\Resolver\CenterResolverDispatcherInterface; final class DefaultVoterHelperGenerator implements VoterGeneratorInterface { - private AuthorizationHelper $authorizationHelper; - - private CenterResolverDispatcherInterface $centerResolverDispatcher; - private array $configuration = []; - public function __construct( - AuthorizationHelper $authorizationHelper, - CenterResolverDispatcherInterface $centerResolverDispatcher - ) { - $this->authorizationHelper = $authorizationHelper; - $this->centerResolverDispatcher = $centerResolverDispatcher; + public function __construct(private AuthorizationHelper $authorizationHelper, private CenterResolverDispatcherInterface $centerResolverDispatcher) + { } public function addCheckFor(?string $subject, array $attributes): self diff --git a/src/Bundle/ChillMainBundle/Security/Authorization/EntityWorkflowVoter.php b/src/Bundle/ChillMainBundle/Security/Authorization/EntityWorkflowVoter.php index ffcc1bb95..5d2bc72a7 100644 --- a/src/Bundle/ChillMainBundle/Security/Authorization/EntityWorkflowVoter.php +++ b/src/Bundle/ChillMainBundle/Security/Authorization/EntityWorkflowVoter.php @@ -29,14 +29,8 @@ class EntityWorkflowVoter extends Voter public const SHOW_ENTITY_LINK = 'CHILL_MAIN_WORKFLOW_LINK_SHOW'; - private EntityWorkflowManager $manager; - - private Security $security; - - public function __construct(EntityWorkflowManager $manager, Security $security) + public function __construct(private EntityWorkflowManager $manager, private Security $security) { - $this->manager = $manager; - $this->security = $security; } protected function supports($attribute, $subject) diff --git a/src/Bundle/ChillMainBundle/Security/Authorization/NotificationVoter.php b/src/Bundle/ChillMainBundle/Security/Authorization/NotificationVoter.php index 9fae2f51a..a1707d7c5 100644 --- a/src/Bundle/ChillMainBundle/Security/Authorization/NotificationVoter.php +++ b/src/Bundle/ChillMainBundle/Security/Authorization/NotificationVoter.php @@ -53,35 +53,22 @@ final class NotificationVoter extends Voter } if ($subject instanceof Notification) { - switch ($attribute) { - case self::COMMENT_ADD: - return false === $subject->isSystem() && ( - $subject->getAddressees()->contains($user) || $subject->getSender() === $user - ); - - case self::NOTIFICATION_SEE: - case self::NOTIFICATION_TOGGLE_READ_STATUS: - return $subject->getSender() === $user || $subject->getAddressees()->contains($user); - - case self::NOTIFICATION_UPDATE: - return $subject->getSender() === $user && false === $subject->isSystem(); - - default: - throw new UnexpectedValueException("this subject {$attribute} is not implemented"); - } + return match ($attribute) { + self::COMMENT_ADD => false === $subject->isSystem() && ( + $subject->getAddressees()->contains($user) || $subject->getSender() === $user + ), + self::NOTIFICATION_SEE, self::NOTIFICATION_TOGGLE_READ_STATUS => $subject->getSender() === $user || $subject->getAddressees()->contains($user), + self::NOTIFICATION_UPDATE => $subject->getSender() === $user && false === $subject->isSystem(), + default => throw new UnexpectedValueException("this subject {$attribute} is not implemented"), + }; } elseif ($subject instanceof NotificationComment) { - switch ($attribute) { - case self::COMMENT_ADD: - return false === $subject->getNotification()->isSystem() && ( - $subject->getNotification()->getAddressees()->contains($user) || $subject->getNotification()->getSender() === $user - ); - - case self::COMMENT_EDIT: - return $subject->getCreatedBy() === $user && false === $subject->getNotification()->isSystem(); - - default: - throw new UnexpectedValueException("this subject {$attribute} is not implemented"); - } + return match ($attribute) { + self::COMMENT_ADD => false === $subject->getNotification()->isSystem() && ( + $subject->getNotification()->getAddressees()->contains($user) || $subject->getNotification()->getSender() === $user + ), + self::COMMENT_EDIT => $subject->getCreatedBy() === $user && false === $subject->getNotification()->isSystem(), + default => throw new UnexpectedValueException("this subject {$attribute} is not implemented"), + }; } throw new UnexpectedValueException(); diff --git a/src/Bundle/ChillMainBundle/Security/Authorization/SavedExportVoter.php b/src/Bundle/ChillMainBundle/Security/Authorization/SavedExportVoter.php index 667bced46..179cada57 100644 --- a/src/Bundle/ChillMainBundle/Security/Authorization/SavedExportVoter.php +++ b/src/Bundle/ChillMainBundle/Security/Authorization/SavedExportVoter.php @@ -38,15 +38,9 @@ class SavedExportVoter extends Voter protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool { - /** @var SavedExport $subject */ - switch ($attribute) { - case self::DELETE: - case self::EDIT: - case self::GENERATE: - return $subject->getUser() === $token->getUser(); - - default: - throw new UnexpectedValueException('attribute not supported: ' . $attribute); - } + return match ($attribute) { + self::DELETE, self::EDIT, self::GENERATE => $subject->getUser() === $token->getUser(), + default => throw new UnexpectedValueException('attribute not supported: ' . $attribute), + }; } } diff --git a/src/Bundle/ChillMainBundle/Security/Authorization/WorkflowEntityDeletionVoter.php b/src/Bundle/ChillMainBundle/Security/Authorization/WorkflowEntityDeletionVoter.php index b75acb7ae..23265306d 100644 --- a/src/Bundle/ChillMainBundle/Security/Authorization/WorkflowEntityDeletionVoter.php +++ b/src/Bundle/ChillMainBundle/Security/Authorization/WorkflowEntityDeletionVoter.php @@ -21,17 +21,11 @@ use function is_object; class WorkflowEntityDeletionVoter extends Voter { - private EntityWorkflowRepository $entityWorkflowRepository; - /** - * @var iterable|EntityWorkflowHandlerInterface[] + * @param \Chill\MainBundle\Workflow\EntityWorkflowHandlerInterface[] $handlers */ - private iterable $handlers; - - public function __construct($handlers, EntityWorkflowRepository $entityWorkflowRepository) + public function __construct(private $handlers, private EntityWorkflowRepository $entityWorkflowRepository) { - $this->handlers = $handlers; - $this->entityWorkflowRepository = $entityWorkflowRepository; } protected function supports($attribute, $subject) diff --git a/src/Bundle/ChillMainBundle/Security/ParentRoleHelper.php b/src/Bundle/ChillMainBundle/Security/ParentRoleHelper.php index f53e49583..65ca6b233 100644 --- a/src/Bundle/ChillMainBundle/Security/ParentRoleHelper.php +++ b/src/Bundle/ChillMainBundle/Security/ParentRoleHelper.php @@ -31,13 +31,10 @@ class ParentRoleHelper */ protected array $hierarchy; - protected RoleHierarchyInterface $roleHierarchy; - public function __construct( - RoleHierarchyInterface $roleHierarchy, + protected RoleHierarchyInterface $roleHierarchy, ParameterBagInterface $parameterBag ) { - $this->roleHierarchy = $roleHierarchy; $this->hierarchy = $parameterBag->get('security.role_hierarchy.roles'); } diff --git a/src/Bundle/ChillMainBundle/Security/PasswordRecover/PasswordRecoverEvent.php b/src/Bundle/ChillMainBundle/Security/PasswordRecover/PasswordRecoverEvent.php index c39c34ebe..8bc23b54a 100644 --- a/src/Bundle/ChillMainBundle/Security/PasswordRecover/PasswordRecoverEvent.php +++ b/src/Bundle/ChillMainBundle/Security/PasswordRecover/PasswordRecoverEvent.php @@ -22,21 +22,11 @@ class PasswordRecoverEvent extends Event public const INVALID_TOKEN = 'chill_main.password_recover_invalid_token'; - /** - * @var string - */ - protected $ip; - /** * @var bool */ protected $safelyGenerated; - /** - * @var string - */ - protected $token; - /** * @var User */ @@ -48,11 +38,9 @@ class PasswordRecoverEvent extends Event * @param type $ip * @param bool $safelyGenerated true if generated safely (from console command, etc.) */ - public function __construct($token = null, ?User $user = null, $ip = null, bool $safelyGenerated = false) + public function __construct(protected $token = null, ?User $user = null, protected $ip = null, bool $safelyGenerated = false) { $this->user = $user; - $this->token = $token; - $this->ip = $ip; $this->safelyGenerated = $safelyGenerated; } @@ -69,10 +57,7 @@ class PasswordRecoverEvent extends Event return $this->token; } - /** - * @return User|null - */ - public function getUser() + public function getUser(): ?\Chill\MainBundle\Entity\User { return $this->user; } diff --git a/src/Bundle/ChillMainBundle/Security/PasswordRecover/PasswordRecoverLocker.php b/src/Bundle/ChillMainBundle/Security/PasswordRecover/PasswordRecoverLocker.php index cc09dbef6..53be72874 100644 --- a/src/Bundle/ChillMainBundle/Security/PasswordRecover/PasswordRecoverLocker.php +++ b/src/Bundle/ChillMainBundle/Security/PasswordRecover/PasswordRecoverLocker.php @@ -80,67 +80,36 @@ class PasswordRecoverLocker */ public static function generateLockKey($usage, int $number, $discriminator = null) { - switch ($usage) { - case 'invalid_token_global': - return sprintf('invalid_token_global_%d', $number); - - case 'invalid_token_by_ip': - return sprintf('invalid_token_ip_%s_%d', $discriminator, $number); - - case 'ask_token_invalid_form_global': - return sprintf('ask_token_invalid_form_global_%d', $number); - - case 'ask_token_invalid_form_by_ip': - return sprintf('ask_token_invalid_form_by_ip_%s_%d', $discriminator, $number); - - case 'ask_token_success_by_user': - return sprintf('ask_token_success_by_user_%s_%d', $discriminator->getId(), $number); - - default: - throw new LogicException('this usage is not implemented'); - } + return match ($usage) { + 'invalid_token_global' => sprintf('invalid_token_global_%d', $number), + 'invalid_token_by_ip' => sprintf('invalid_token_ip_%s_%d', $discriminator, $number), + 'ask_token_invalid_form_global' => sprintf('ask_token_invalid_form_global_%d', $number), + 'ask_token_invalid_form_by_ip' => sprintf('ask_token_invalid_form_by_ip_%s_%d', $discriminator, $number), + 'ask_token_success_by_user' => sprintf('ask_token_success_by_user_%s_%d', $discriminator->getId(), $number), + default => throw new LogicException('this usage is not implemented'), + }; } public function getMax($usage) { - switch ($usage) { - case 'invalid_token_global': - return self::MAX_INVALID_TOKEN_GLOBAL; - - case 'invalid_token_by_ip': - return self::MAX_INVALID_TOKEN_BY_IP; - - case 'ask_token_invalid_form_global': - return self::MAX_ASK_TOKEN_INVALID_FORM_GLOBAL; - - case 'ask_token_invalid_form_by_ip': - return self::MAX_ASK_TOKEN_INVALID_FORM_BY_IP; - - case 'ask_token_success_by_user': - return self::MAX_ASK_TOKEN_BY_USER; - - default: - throw new UnexpectedValueException("this usage '{$usage}' is not yet implemented"); - } + return match ($usage) { + 'invalid_token_global' => self::MAX_INVALID_TOKEN_GLOBAL, + 'invalid_token_by_ip' => self::MAX_INVALID_TOKEN_BY_IP, + 'ask_token_invalid_form_global' => self::MAX_ASK_TOKEN_INVALID_FORM_GLOBAL, + 'ask_token_invalid_form_by_ip' => self::MAX_ASK_TOKEN_INVALID_FORM_BY_IP, + 'ask_token_success_by_user' => self::MAX_ASK_TOKEN_BY_USER, + default => throw new UnexpectedValueException("this usage '{$usage}' is not yet implemented"), + }; } public function getTtl($usage) { - switch ($usage) { - case 'invalid_token_global': - case 'invalid_token_by_ip': - return self::INVALID_TOKEN_TTL; - - case 'ask_token_invalid_form_global': - case 'ask_token_invalid_form_by_ip': - return self::ASK_TOKEN_INVALID_FORM_TTL; - - case 'ask_token_success_by_user': - return self::ASK_TOKEN_INVALID_FORM_TTL * 24; - - default: - throw new UnexpectedValueException("this usage '{$usage}' is not yet implemented"); - } + return match ($usage) { + 'invalid_token_global', 'invalid_token_by_ip' => self::INVALID_TOKEN_TTL, + 'ask_token_invalid_form_global', 'ask_token_invalid_form_by_ip' => self::ASK_TOKEN_INVALID_FORM_TTL, + 'ask_token_success_by_user' => self::ASK_TOKEN_INVALID_FORM_TTL * 24, + default => throw new UnexpectedValueException("this usage '{$usage}' is not yet implemented"), + }; } public function isLocked($usage, $discriminator = null) diff --git a/src/Bundle/ChillMainBundle/Security/PasswordRecover/TokenManager.php b/src/Bundle/ChillMainBundle/Security/PasswordRecover/TokenManager.php index 3d4afb1b3..370c1c521 100644 --- a/src/Bundle/ChillMainBundle/Security/PasswordRecover/TokenManager.php +++ b/src/Bundle/ChillMainBundle/Security/PasswordRecover/TokenManager.php @@ -43,13 +43,10 @@ class TokenManager protected $logger; /** - * @var string + * @param string $secret */ - protected $secret; - - public function __construct($secret, LoggerInterface $logger) + public function __construct(protected $secret, LoggerInterface $logger) { - $this->secret = $secret; $this->logger = $logger; } diff --git a/src/Bundle/ChillMainBundle/Security/Resolver/CenterResolverDispatcher.php b/src/Bundle/ChillMainBundle/Security/Resolver/CenterResolverDispatcher.php index f757efa3a..d01ba6665 100644 --- a/src/Bundle/ChillMainBundle/Security/Resolver/CenterResolverDispatcher.php +++ b/src/Bundle/ChillMainBundle/Security/Resolver/CenterResolverDispatcher.php @@ -14,13 +14,10 @@ namespace Chill\MainBundle\Security\Resolver; final class CenterResolverDispatcher implements CenterResolverDispatcherInterface { /** - * @var CenterResolverInterface[] + * @param \Chill\MainBundle\Security\Resolver\CenterResolverInterface[] $resolvers */ - private iterable $resolvers; - - public function __construct(iterable $resolvers = []) + public function __construct(private iterable $resolvers = []) { - $this->resolvers = $resolvers; } public function resolveCenter($entity, ?array $options = []) diff --git a/src/Bundle/ChillMainBundle/Security/Resolver/CenterResolverManager.php b/src/Bundle/ChillMainBundle/Security/Resolver/CenterResolverManager.php index 65507e610..3ccdd3746 100644 --- a/src/Bundle/ChillMainBundle/Security/Resolver/CenterResolverManager.php +++ b/src/Bundle/ChillMainBundle/Security/Resolver/CenterResolverManager.php @@ -20,13 +20,10 @@ use function is_array; final class CenterResolverManager implements CenterResolverManagerInterface { /** - * @var CenterResolverInterface[] + * @param \Chill\MainBundle\Security\Resolver\CenterResolverInterface[] $resolvers */ - private iterable $resolvers; - - public function __construct(iterable $resolvers = []) + public function __construct(private iterable $resolvers = []) { - $this->resolvers = $resolvers; } public function resolveCenters($entity, ?array $options = []): array @@ -51,7 +48,7 @@ final class CenterResolverManager implements CenterResolverManagerInterface 'the return type of a %s should be an instance of %s, an array or null. Resolver is %s', CenterResolverInterface::class, Center::class, - get_class($resolver) + $resolver::class )); } } diff --git a/src/Bundle/ChillMainBundle/Security/Resolver/ResolverTwigExtension.php b/src/Bundle/ChillMainBundle/Security/Resolver/ResolverTwigExtension.php index 058bea75d..299d8dd2b 100644 --- a/src/Bundle/ChillMainBundle/Security/Resolver/ResolverTwigExtension.php +++ b/src/Bundle/ChillMainBundle/Security/Resolver/ResolverTwigExtension.php @@ -15,14 +15,8 @@ use Twig\TwigFilter; final class ResolverTwigExtension extends \Twig\Extension\AbstractExtension { - private CenterResolverManagerInterface $centerResolverDispatcher; - - private ScopeResolverDispatcher $scopeResolverDispatcher; - - public function __construct(CenterResolverManagerInterface $centerResolverDispatcher, ScopeResolverDispatcher $scopeResolverDispatcher) + public function __construct(private CenterResolverManagerInterface $centerResolverDispatcher, private ScopeResolverDispatcher $scopeResolverDispatcher) { - $this->centerResolverDispatcher = $centerResolverDispatcher; - $this->scopeResolverDispatcher = $scopeResolverDispatcher; } public function getFilters() @@ -45,11 +39,9 @@ final class ResolverTwigExtension extends \Twig\Extension\AbstractExtension } /** - * @param mixed $entity - * * @return Center|Center[]|null */ - public function resolveCenter($entity, ?array $options = []) + public function resolveCenter(mixed $entity, ?array $options = []) { return $this->centerResolverDispatcher->resolveCenters($entity, $options); } @@ -59,7 +51,7 @@ final class ResolverTwigExtension extends \Twig\Extension\AbstractExtension * * @return array|\Chill\MainBundle\Entity\Scope|\Chill\MainBundle\Entity\Scope[] */ - public function resolveScope($entity, ?array $options = []) + public function resolveScope($entity, ?array $options = []): array|\Chill\MainBundle\Entity\Scope { return $this->scopeResolverDispatcher->resolveScope(); } diff --git a/src/Bundle/ChillMainBundle/Security/Resolver/ScopeResolverDispatcher.php b/src/Bundle/ChillMainBundle/Security/Resolver/ScopeResolverDispatcher.php index 308b9aee0..1c40ad282 100644 --- a/src/Bundle/ChillMainBundle/Security/Resolver/ScopeResolverDispatcher.php +++ b/src/Bundle/ChillMainBundle/Security/Resolver/ScopeResolverDispatcher.php @@ -17,13 +17,10 @@ use Doctrine\Common\Collections\Collection; final class ScopeResolverDispatcher { /** - * @var iterable|ScopeResolverInterface[] + * @param \Chill\MainBundle\Security\Resolver\ScopeResolverInterface[] $resolvers */ - private iterable $resolvers; - - public function __construct(iterable $resolvers) + public function __construct(private iterable $resolvers) { - $this->resolvers = $resolvers; } public function isConcerned($entity, ?array $options = []): bool @@ -42,7 +39,7 @@ final class ScopeResolverDispatcher * * @return iterable|Scope|Scope[] */ - public function resolveScope($entity, ?array $options = []) + public function resolveScope($entity, ?array $options = []): iterable|\Chill\MainBundle\Entity\Scope|array { foreach ($this->resolvers as $resolver) { if ($resolver->supports($entity, $options)) { diff --git a/src/Bundle/ChillMainBundle/Security/RoleProvider.php b/src/Bundle/ChillMainBundle/Security/RoleProvider.php index c299ee508..c7e589674 100644 --- a/src/Bundle/ChillMainBundle/Security/RoleProvider.php +++ b/src/Bundle/ChillMainBundle/Security/RoleProvider.php @@ -35,8 +35,6 @@ class RoleProvider * Add a role provider. * * @internal This function is called by the dependency injector: it inject provider - * - * @param \Chill\MainBundle\Security\ProvideRoleInterface $provider */ public function addProvider(ProvideRoleInterface $provider) { diff --git a/src/Bundle/ChillMainBundle/Security/UserProvider/UserProvider.php b/src/Bundle/ChillMainBundle/Security/UserProvider/UserProvider.php index ff0c73fb6..ceee95b56 100644 --- a/src/Bundle/ChillMainBundle/Security/UserProvider/UserProvider.php +++ b/src/Bundle/ChillMainBundle/Security/UserProvider/UserProvider.php @@ -21,11 +21,8 @@ use Symfony\Component\Security\Core\User\UserProviderInterface; class UserProvider implements UserProviderInterface { - protected EntityManagerInterface $em; - - public function __construct(EntityManagerInterface $em) + public function __construct(protected EntityManagerInterface $em) { - $this->em = $em; } public function loadUserByUsername($username): UserInterface diff --git a/src/Bundle/ChillMainBundle/Serializer/Model/Collection.php b/src/Bundle/ChillMainBundle/Serializer/Model/Collection.php index 38b151bb7..4f6248621 100644 --- a/src/Bundle/ChillMainBundle/Serializer/Model/Collection.php +++ b/src/Bundle/ChillMainBundle/Serializer/Model/Collection.php @@ -15,14 +15,8 @@ use Chill\MainBundle\Pagination\PaginatorInterface; class Collection { - private $items; - - private PaginatorInterface $paginator; - - public function __construct($items, PaginatorInterface $paginator) + public function __construct(private $items, private PaginatorInterface $paginator) { - $this->items = $items; - $this->paginator = $paginator; } public function getItems() diff --git a/src/Bundle/ChillMainBundle/Serializer/Model/Counter.php b/src/Bundle/ChillMainBundle/Serializer/Model/Counter.php index 10669c1c5..39a83ee5a 100644 --- a/src/Bundle/ChillMainBundle/Serializer/Model/Counter.php +++ b/src/Bundle/ChillMainBundle/Serializer/Model/Counter.php @@ -15,11 +15,8 @@ use JsonSerializable; class Counter implements JsonSerializable { - private int $counter; - - public function __construct(?int $counter) + public function __construct(private ?int $counter) { - $this->counter = $counter; } public function getCounter(): ?int diff --git a/src/Bundle/ChillMainBundle/Serializer/Normalizer/AddressNormalizer.php b/src/Bundle/ChillMainBundle/Serializer/Normalizer/AddressNormalizer.php index 8018fe951..5e6c8cc05 100644 --- a/src/Bundle/ChillMainBundle/Serializer/Normalizer/AddressNormalizer.php +++ b/src/Bundle/ChillMainBundle/Serializer/Normalizer/AddressNormalizer.php @@ -48,11 +48,8 @@ class AddressNormalizer implements ContextAwareNormalizerInterface, NormalizerAw 'confidential', ]; - private AddressRender $addressRender; - - public function __construct(AddressRender $addressRender) + public function __construct(private AddressRender $addressRender) { - $this->addressRender = $addressRender; } /** diff --git a/src/Bundle/ChillMainBundle/Serializer/Normalizer/CenterNormalizer.php b/src/Bundle/ChillMainBundle/Serializer/Normalizer/CenterNormalizer.php index e0b2a3e96..cfb53e1a1 100644 --- a/src/Bundle/ChillMainBundle/Serializer/Normalizer/CenterNormalizer.php +++ b/src/Bundle/ChillMainBundle/Serializer/Normalizer/CenterNormalizer.php @@ -22,11 +22,8 @@ use function array_key_exists; class CenterNormalizer implements DenormalizerInterface, NormalizerInterface { - private CenterRepository $repository; - - public function __construct(CenterRepository $repository) + public function __construct(private CenterRepository $repository) { - $this->repository = $repository; } public function denormalize($data, $type, $format = null, array $context = []) diff --git a/src/Bundle/ChillMainBundle/Serializer/Normalizer/CommentEmbeddableDocGenNormalizer.php b/src/Bundle/ChillMainBundle/Serializer/Normalizer/CommentEmbeddableDocGenNormalizer.php index a00e6379a..10c865608 100644 --- a/src/Bundle/ChillMainBundle/Serializer/Normalizer/CommentEmbeddableDocGenNormalizer.php +++ b/src/Bundle/ChillMainBundle/Serializer/Normalizer/CommentEmbeddableDocGenNormalizer.php @@ -25,11 +25,8 @@ class CommentEmbeddableDocGenNormalizer implements ContextAwareNormalizerInterfa { use NormalizerAwareTrait; - private UserRepository $userRepository; - - public function __construct(UserRepository $userRepository) + public function __construct(private UserRepository $userRepository) { - $this->userRepository = $userRepository; } /** diff --git a/src/Bundle/ChillMainBundle/Serializer/Normalizer/DateNormalizer.php b/src/Bundle/ChillMainBundle/Serializer/Normalizer/DateNormalizer.php index 8bd0fd3c1..c5032a7b9 100644 --- a/src/Bundle/ChillMainBundle/Serializer/Normalizer/DateNormalizer.php +++ b/src/Bundle/ChillMainBundle/Serializer/Normalizer/DateNormalizer.php @@ -26,14 +26,8 @@ use function is_array; class DateNormalizer implements ContextAwareNormalizerInterface, DenormalizerInterface { - private ParameterBagInterface $parameterBag; - - private RequestStack $requestStack; - - public function __construct(RequestStack $requestStack, ParameterBagInterface $parameterBag) + public function __construct(private RequestStack $requestStack, private ParameterBagInterface $parameterBag) { - $this->requestStack = $requestStack; - $this->parameterBag = $parameterBag; } public function denormalize($data, $type, $format = null, array $context = []) diff --git a/src/Bundle/ChillMainBundle/Serializer/Normalizer/DoctrineExistingEntityNormalizer.php b/src/Bundle/ChillMainBundle/Serializer/Normalizer/DoctrineExistingEntityNormalizer.php index 3f4d0c51f..94c5d400e 100644 --- a/src/Bundle/ChillMainBundle/Serializer/Normalizer/DoctrineExistingEntityNormalizer.php +++ b/src/Bundle/ChillMainBundle/Serializer/Normalizer/DoctrineExistingEntityNormalizer.php @@ -23,14 +23,8 @@ use function is_array; class DoctrineExistingEntityNormalizer implements DenormalizerInterface { - private EntityManagerInterface $em; - - private ClassMetadataFactoryInterface $serializerMetadataFactory; - - public function __construct(EntityManagerInterface $em, ClassMetadataFactoryInterface $serializerMetadataFactory) + public function __construct(private EntityManagerInterface $em, private ClassMetadataFactoryInterface $serializerMetadataFactory) { - $this->em = $em; - $this->serializerMetadataFactory = $serializerMetadataFactory; } public function denormalize($data, $type, $format = null, array $context = []) diff --git a/src/Bundle/ChillMainBundle/Serializer/Normalizer/EntityWorkflowNormalizer.php b/src/Bundle/ChillMainBundle/Serializer/Normalizer/EntityWorkflowNormalizer.php index 4dd6888a0..16553ab29 100644 --- a/src/Bundle/ChillMainBundle/Serializer/Normalizer/EntityWorkflowNormalizer.php +++ b/src/Bundle/ChillMainBundle/Serializer/Normalizer/EntityWorkflowNormalizer.php @@ -23,20 +23,8 @@ class EntityWorkflowNormalizer implements NormalizerInterface, NormalizerAwareIn { use NormalizerAwareTrait; - private EntityWorkflowManager $entityWorkflowManager; - - private MetadataExtractor $metadataExtractor; - - private Registry $registry; - - public function __construct( - EntityWorkflowManager $entityWorkflowManager, - MetadataExtractor $metadataExtractor, - Registry $registry - ) { - $this->entityWorkflowManager = $entityWorkflowManager; - $this->metadataExtractor = $metadataExtractor; - $this->registry = $registry; + public function __construct(private EntityWorkflowManager $entityWorkflowManager, private MetadataExtractor $metadataExtractor, private Registry $registry) + { } /** diff --git a/src/Bundle/ChillMainBundle/Serializer/Normalizer/EntityWorkflowStepNormalizer.php b/src/Bundle/ChillMainBundle/Serializer/Normalizer/EntityWorkflowStepNormalizer.php index 63b2c1141..874faf9c9 100644 --- a/src/Bundle/ChillMainBundle/Serializer/Normalizer/EntityWorkflowStepNormalizer.php +++ b/src/Bundle/ChillMainBundle/Serializer/Normalizer/EntityWorkflowStepNormalizer.php @@ -21,11 +21,8 @@ class EntityWorkflowStepNormalizer implements NormalizerAwareInterface, Normaliz { use NormalizerAwareTrait; - private MetadataExtractor $metadataExtractor; - - public function __construct(MetadataExtractor $metadataExtractor) + public function __construct(private MetadataExtractor $metadataExtractor) { - $this->metadataExtractor = $metadataExtractor; } /** diff --git a/src/Bundle/ChillMainBundle/Serializer/Normalizer/NotificationNormalizer.php b/src/Bundle/ChillMainBundle/Serializer/Normalizer/NotificationNormalizer.php index 589d0b914..98101a86d 100644 --- a/src/Bundle/ChillMainBundle/Serializer/Normalizer/NotificationNormalizer.php +++ b/src/Bundle/ChillMainBundle/Serializer/Normalizer/NotificationNormalizer.php @@ -24,17 +24,8 @@ class NotificationNormalizer implements NormalizerAwareInterface, NormalizerInte { use NormalizerAwareTrait; - private EntityManagerInterface $entityManager; - - private NotificationHandlerManager $notificationHandlerManager; - - private Security $security; - - public function __construct(NotificationHandlerManager $notificationHandlerManager, EntityManagerInterface $entityManager, Security $security) + public function __construct(private NotificationHandlerManager $notificationHandlerManager, private EntityManagerInterface $entityManager, private Security $security) { - $this->notificationHandlerManager = $notificationHandlerManager; - $this->entityManager = $entityManager; - $this->security = $security; } /** diff --git a/src/Bundle/ChillMainBundle/Serializer/Normalizer/PrivateCommentEmbeddableNormalizer.php b/src/Bundle/ChillMainBundle/Serializer/Normalizer/PrivateCommentEmbeddableNormalizer.php index 0049657bb..6a98bc428 100644 --- a/src/Bundle/ChillMainBundle/Serializer/Normalizer/PrivateCommentEmbeddableNormalizer.php +++ b/src/Bundle/ChillMainBundle/Serializer/Normalizer/PrivateCommentEmbeddableNormalizer.php @@ -18,11 +18,8 @@ use Symfony\Component\Serializer\Normalizer\NormalizerInterface; class PrivateCommentEmbeddableNormalizer implements NormalizerInterface, DenormalizerInterface { - private Security $security; - - public function __construct(Security $security) + public function __construct(private Security $security) { - $this->security = $security; } public function denormalize($data, string $type, ?string $format = null, array $context = []): PrivateCommentEmbeddable diff --git a/src/Bundle/ChillMainBundle/Serializer/Normalizer/UserNormalizer.php b/src/Bundle/ChillMainBundle/Serializer/Normalizer/UserNormalizer.php index fde3a3d8e..5f68454fd 100644 --- a/src/Bundle/ChillMainBundle/Serializer/Normalizer/UserNormalizer.php +++ b/src/Bundle/ChillMainBundle/Serializer/Normalizer/UserNormalizer.php @@ -36,11 +36,8 @@ class UserNormalizer implements ContextAwareNormalizerInterface, NormalizerAware 'email' => '', ]; - private UserRender $userRender; - - public function __construct(UserRender $userRender) + public function __construct(private UserRender $userRender) { - $this->userRender = $userRender; } public function normalize($object, $format = null, array $context = []) diff --git a/src/Bundle/ChillMainBundle/Service/AddressGeographicalUnit/RefreshAddressToGeographicalUnitMaterializedViewCronJob.php b/src/Bundle/ChillMainBundle/Service/AddressGeographicalUnit/RefreshAddressToGeographicalUnitMaterializedViewCronJob.php index 9dbb38a3f..b64891695 100644 --- a/src/Bundle/ChillMainBundle/Service/AddressGeographicalUnit/RefreshAddressToGeographicalUnitMaterializedViewCronJob.php +++ b/src/Bundle/ChillMainBundle/Service/AddressGeographicalUnit/RefreshAddressToGeographicalUnitMaterializedViewCronJob.php @@ -20,11 +20,8 @@ use UnexpectedValueException; class RefreshAddressToGeographicalUnitMaterializedViewCronJob implements CronJobInterface { - private Connection $connection; - - public function __construct(Connection $connection) + public function __construct(private Connection $connection) { - $this->connection = $connection; } public function canRun(?CronJobExecution $cronJobExecution): bool diff --git a/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceBEFromBestAddress.php b/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceBEFromBestAddress.php index c06ded0a8..09bc5e3f8 100644 --- a/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceBEFromBestAddress.php +++ b/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceBEFromBestAddress.php @@ -22,20 +22,8 @@ class AddressReferenceBEFromBestAddress { private const RELEASE = 'https://gitea.champs-libres.be/api/v1/repos/Chill-project/belgian-bestaddresses-transform/releases/tags/v1.0.0'; - private AddressReferenceBaseImporter $baseImporter; - - private AddressToReferenceMatcher $addressToReferenceMatcher; - - private HttpClientInterface $client; - - public function __construct( - HttpClientInterface $client, - AddressReferenceBaseImporter $baseImporter, - AddressToReferenceMatcher $addressToReferenceMatcher - ) { - $this->client = $client; - $this->baseImporter = $baseImporter; - $this->addressToReferenceMatcher = $addressToReferenceMatcher; + public function __construct(private HttpClientInterface $client, private AddressReferenceBaseImporter $baseImporter, private AddressToReferenceMatcher $addressToReferenceMatcher) + { } public function import(string $lang, array $lists): void diff --git a/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceBaseImporter.php b/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceBaseImporter.php index c6ddfcf40..9c8f2f705 100644 --- a/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceBaseImporter.php +++ b/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceBaseImporter.php @@ -46,18 +46,12 @@ final class AddressReferenceBaseImporter private ?string $currentSource = null; - private Connection $defaultConnection; - private bool $isInitialized = false; - private LoggerInterface $logger; - private array $waitingForInsert = []; - public function __construct(Connection $defaultConnection, LoggerInterface $logger) + public function __construct(private Connection $defaultConnection, private LoggerInterface $logger) { - $this->defaultConnection = $defaultConnection; - $this->logger = $logger; } public function finalize(): void diff --git a/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceFromBano.php b/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceFromBano.php index d02a846ec..657463dc7 100644 --- a/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceFromBano.php +++ b/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceFromBano.php @@ -20,17 +20,8 @@ use function is_int; class AddressReferenceFromBano { - private AddressReferenceBaseImporter $baseImporter; - - private AddressToReferenceMatcher $addressToReferenceMatcher; - - private HttpClientInterface $client; - - public function __construct(HttpClientInterface $client, AddressReferenceBaseImporter $baseImporter, AddressToReferenceMatcher $addressToReferenceMatcher) + public function __construct(private HttpClientInterface $client, private AddressReferenceBaseImporter $baseImporter, private AddressToReferenceMatcher $addressToReferenceMatcher) { - $this->client = $client; - $this->baseImporter = $baseImporter; - $this->addressToReferenceMatcher = $addressToReferenceMatcher; } public function import(string $departementNo): void diff --git a/src/Bundle/ChillMainBundle/Service/Import/AddressToReferenceMatcher.php b/src/Bundle/ChillMainBundle/Service/Import/AddressToReferenceMatcher.php index eab6858d9..bf9b57a1a 100644 --- a/src/Bundle/ChillMainBundle/Service/Import/AddressToReferenceMatcher.php +++ b/src/Bundle/ChillMainBundle/Service/Import/AddressToReferenceMatcher.php @@ -21,10 +21,6 @@ use Psr\Log\LoggerInterface; */ final class AddressToReferenceMatcher { - private Connection $connection; - - private LoggerInterface $logger; - private const LOG_PREFIX = '[address_to_reference_matcher] '; private const SQL_MARK_TO_REVIEW_ADDRESS_UNMATCHING = <<<'SQL' @@ -68,10 +64,8 @@ final class AddressToReferenceMatcher '{{ reviewed }}' => Address::ADDR_REFERENCE_STATUS_REVIEWED ]; - public function __construct(Connection $connection, LoggerInterface $logger) + public function __construct(private Connection $connection, private LoggerInterface $logger) { - $this->connection = $connection; - $this->logger = $logger; } public function checkAddressesMatchingReferences(): void diff --git a/src/Bundle/ChillMainBundle/Service/Import/GeographicalUnitBaseImporter.php b/src/Bundle/ChillMainBundle/Service/Import/GeographicalUnitBaseImporter.php index 1ec6b70de..c8a229cd7 100644 --- a/src/Bundle/ChillMainBundle/Service/Import/GeographicalUnitBaseImporter.php +++ b/src/Bundle/ChillMainBundle/Service/Import/GeographicalUnitBaseImporter.php @@ -43,18 +43,12 @@ final class GeographicalUnitBaseImporter */ private array $cachingStatements = []; - private Connection $defaultConnection; - private bool $isInitialized = false; - private LoggerInterface $logger; - private array $waitingForInsert = []; - public function __construct(Connection $defaultConnection, LoggerInterface $logger) + public function __construct(private Connection $defaultConnection, private LoggerInterface $logger) { - $this->defaultConnection = $defaultConnection; - $this->logger = $logger; } public function finalize(): void diff --git a/src/Bundle/ChillMainBundle/Service/Import/PostalCodeBEFromBestAddress.php b/src/Bundle/ChillMainBundle/Service/Import/PostalCodeBEFromBestAddress.php index aa04c9ac3..41672e421 100644 --- a/src/Bundle/ChillMainBundle/Service/Import/PostalCodeBEFromBestAddress.php +++ b/src/Bundle/ChillMainBundle/Service/Import/PostalCodeBEFromBestAddress.php @@ -21,17 +21,8 @@ class PostalCodeBEFromBestAddress { private const RELEASE = 'https://gitea.champs-libres.be/api/v1/repos/Chill-project/belgian-bestaddresses-transform/releases/tags/v1.0.0'; - private PostalCodeBaseImporter $baseImporter; - - private HttpClientInterface $client; - - private LoggerInterface $logger; - - public function __construct(PostalCodeBaseImporter $baseImporter, HttpClientInterface $client, LoggerInterface $logger) + public function __construct(private PostalCodeBaseImporter $baseImporter, private HttpClientInterface $client, private LoggerInterface $logger) { - $this->baseImporter = $baseImporter; - $this->client = $client; - $this->logger = $logger; } public function import(string $lang = 'fr'): void diff --git a/src/Bundle/ChillMainBundle/Service/Import/PostalCodeBaseImporter.php b/src/Bundle/ChillMainBundle/Service/Import/PostalCodeBaseImporter.php index 9086e1843..8b5e6d4e1 100644 --- a/src/Bundle/ChillMainBundle/Service/Import/PostalCodeBaseImporter.php +++ b/src/Bundle/ChillMainBundle/Service/Import/PostalCodeBaseImporter.php @@ -55,14 +55,10 @@ class PostalCodeBaseImporter */ private array $cachingStatements = []; - private Connection $defaultConnection; - private array $waitingForInsert = []; - public function __construct( - Connection $defaultConnection - ) { - $this->defaultConnection = $defaultConnection; + public function __construct(private Connection $defaultConnection) + { } public function finalize(): void diff --git a/src/Bundle/ChillMainBundle/Service/Import/PostalCodeFRFromOpenData.php b/src/Bundle/ChillMainBundle/Service/Import/PostalCodeFRFromOpenData.php index e680b8497..23687d558 100644 --- a/src/Bundle/ChillMainBundle/Service/Import/PostalCodeFRFromOpenData.php +++ b/src/Bundle/ChillMainBundle/Service/Import/PostalCodeFRFromOpenData.php @@ -26,20 +26,8 @@ class PostalCodeFRFromOpenData { private const CSV = 'https://datanova.legroupe.laposte.fr/explore/dataset/laposte_hexasmal/download/?format=csv&timezone=Europe/Berlin&lang=fr&use_labels_for_header=true&csv_separator=%3B'; - private PostalCodeBaseImporter $baseImporter; - - private HttpClientInterface $client; - - private LoggerInterface $logger; - - public function __construct( - PostalCodeBaseImporter $baseImporter, - HttpClientInterface $client, - LoggerInterface $logger - ) { - $this->baseImporter = $baseImporter; - $this->client = $client; - $this->logger = $logger; + public function __construct(private PostalCodeBaseImporter $baseImporter, private HttpClientInterface $client, private LoggerInterface $logger) + { } public function import(): void @@ -86,7 +74,7 @@ class PostalCodeFRFromOpenData $ref = trim($record['Code_commune_INSEE']); - if ('987' === substr($ref, 0, 3)) { + if (str_starts_with($ref, '987')) { // some differences in French Polynesia $ref .= '.' . trim($record['Libellé_d_acheminement']); } diff --git a/src/Bundle/ChillMainBundle/Service/Mailer/ChillMailer.php b/src/Bundle/ChillMainBundle/Service/Mailer/ChillMailer.php index 36374c6af..6474ccf9c 100644 --- a/src/Bundle/ChillMainBundle/Service/Mailer/ChillMailer.php +++ b/src/Bundle/ChillMainBundle/Service/Mailer/ChillMailer.php @@ -20,16 +20,10 @@ use Symfony\Component\Mime\RawMessage; class ChillMailer implements MailerInterface { - private LoggerInterface $chillLogger; - - private MailerInterface $initial; - private string $prefix = '[Chill] '; - public function __construct(MailerInterface $initial, LoggerInterface $chillLogger) + public function __construct(private MailerInterface $initial, private LoggerInterface $chillLogger) { - $this->initial = $initial; - $this->chillLogger = $chillLogger; } public function send(RawMessage $message, ?Envelope $envelope = null): void diff --git a/src/Bundle/ChillMainBundle/Service/RollingDate/RollingDate.php b/src/Bundle/ChillMainBundle/Service/RollingDate/RollingDate.php index e8427c62f..32aa7030a 100644 --- a/src/Bundle/ChillMainBundle/Service/RollingDate/RollingDate.php +++ b/src/Bundle/ChillMainBundle/Service/RollingDate/RollingDate.php @@ -63,25 +63,19 @@ class RollingDate public const T_YEAR_PREVIOUS_START = 'year_previous_start'; - private ?DateTimeImmutable $fixedDate; - /** * The pivot date is the date from the rolling is computed. By default, it is "now". */ private DateTimeImmutable $pivotDate; - private string $roll; - /** * @param string|self::T_* $roll * @param DateTimeImmutable|null $pivotDate Will be "now" if null is given * @param DateTimeImmutable|null $fixedDate Only to insert if $roll equals @see{self::T_FIXED_DATE} */ - public function __construct(string $roll, ?DateTimeImmutable $fixedDate = null, ?DateTimeImmutable $pivotDate = null) + public function __construct(private string $roll, private ?\DateTimeImmutable $fixedDate = null, ?DateTimeImmutable $pivotDate = null) { - $this->roll = $roll; $this->pivotDate = $pivotDate ?? new DateTimeImmutable('now'); - $this->fixedDate = $fixedDate; } public function getFixedDate(): ?DateTimeImmutable diff --git a/src/Bundle/ChillMainBundle/Service/RollingDate/RollingDateConverter.php b/src/Bundle/ChillMainBundle/Service/RollingDate/RollingDateConverter.php index 026ff7a8a..0b9d5e4cd 100644 --- a/src/Bundle/ChillMainBundle/Service/RollingDate/RollingDateConverter.php +++ b/src/Bundle/ChillMainBundle/Service/RollingDate/RollingDateConverter.php @@ -82,38 +82,13 @@ class RollingDateConverter implements RollingDateConverterInterface private function toBeginOfQuarter(DateTimeImmutable $date): DateTimeImmutable { - switch ((int) $date->format('n')) { - case 1: - case 2: - case 3: - $month = '01'; - - break; - - case 4: - case 5: - case 6: - $month = '04'; - - break; - - case 7: - case 8: - case 9: - $month = '07'; - - break; - - case 10: - case 11: - case 12: - $month = '10'; - - break; - - default: - throw new LogicException('this month is not valid: ' . $date->format('n')); - } + $month = match ((int) $date->format('n')) { + 1, 2, 3 => '01', + 4, 5, 6 => '04', + 7, 8, 9 => '07', + 10, 11, 12 => '10', + default => throw new LogicException('this month is not valid: ' . $date->format('n')), + }; return DateTimeImmutable::createFromFormat( 'Y-m-d His', diff --git a/src/Bundle/ChillMainBundle/Service/ShortMessage/ShortMessage.php b/src/Bundle/ChillMainBundle/Service/ShortMessage/ShortMessage.php index 145e90593..2a86ddab4 100644 --- a/src/Bundle/ChillMainBundle/Service/ShortMessage/ShortMessage.php +++ b/src/Bundle/ChillMainBundle/Service/ShortMessage/ShortMessage.php @@ -26,17 +26,8 @@ class ShortMessage public const PRIORITY_MEDIUM = 'medium'; - private string $content; - - private PhoneNumber $phoneNumber; - - private string $priority = 'low'; - - public function __construct(string $content, PhoneNumber $phoneNumber, string $priority = 'low') + public function __construct(private string $content, private PhoneNumber $phoneNumber, private string $priority = 'low') { - $this->content = $content; - $this->phoneNumber = $phoneNumber; - $this->priority = $priority; } public function getContent(): string diff --git a/src/Bundle/ChillMainBundle/Service/ShortMessage/ShortMessageHandler.php b/src/Bundle/ChillMainBundle/Service/ShortMessage/ShortMessageHandler.php index 924335ad9..6f8b5427d 100644 --- a/src/Bundle/ChillMainBundle/Service/ShortMessage/ShortMessageHandler.php +++ b/src/Bundle/ChillMainBundle/Service/ShortMessage/ShortMessageHandler.php @@ -25,11 +25,8 @@ use Symfony\Component\Messenger\Handler\MessageHandlerInterface; */ class ShortMessageHandler implements MessageHandlerInterface { - private ShortMessageTransporterInterface $messageTransporter; - - public function __construct(ShortMessageTransporterInterface $messageTransporter) + public function __construct(private ShortMessageTransporterInterface $messageTransporter) { - $this->messageTransporter = $messageTransporter; } public function __invoke(ShortMessage $message): void diff --git a/src/Bundle/ChillMainBundle/Service/ShortMessage/ShortMessageTransporter.php b/src/Bundle/ChillMainBundle/Service/ShortMessage/ShortMessageTransporter.php index 6fdc8b05d..5dfbc9fc0 100644 --- a/src/Bundle/ChillMainBundle/Service/ShortMessage/ShortMessageTransporter.php +++ b/src/Bundle/ChillMainBundle/Service/ShortMessage/ShortMessageTransporter.php @@ -20,12 +20,8 @@ namespace Chill\MainBundle\Service\ShortMessage; class ShortMessageTransporter implements ShortMessageTransporterInterface { - private ShortMessageSenderInterface $sender; - - public function __construct( - ShortMessageSenderInterface $sender // hint: must remain at place 0 for DI - ) { - $this->sender = $sender; + public function __construct(private ShortMessageSenderInterface $sender) + { } public function send(ShortMessage $shortMessage): void diff --git a/src/Bundle/ChillMainBundle/Service/ShortMessageOvh/OvhShortMessageSender.php b/src/Bundle/ChillMainBundle/Service/ShortMessageOvh/OvhShortMessageSender.php index e3273578a..72ef53b85 100644 --- a/src/Bundle/ChillMainBundle/Service/ShortMessageOvh/OvhShortMessageSender.php +++ b/src/Bundle/ChillMainBundle/Service/ShortMessageOvh/OvhShortMessageSender.php @@ -27,28 +27,16 @@ use Psr\Log\LoggerInterface; class OvhShortMessageSender implements ShortMessageSenderInterface { - private Api $api; - - private LoggerInterface $logger; - - private PhoneNumberUtil $phoneNumberUtil; - - private string $sender; - - private string $serviceName; - public function __construct( - Api $api, // for DI, must remains as first argument - string $serviceName, // for di, must remains as second argument - string $sender, // for DI, must remains as third argument - LoggerInterface $logger, - PhoneNumberUtil $phoneNumberUtil + private Api $api, + // for DI, must remains as first argument + private string $serviceName, + // for di, must remains as second argument + private string $sender, + // for DI, must remains as third argument + private LoggerInterface $logger, + private PhoneNumberUtil $phoneNumberUtil ) { - $this->api = $api; - $this->serviceName = $serviceName; - $this->sender = $sender; - $this->logger = $logger; - $this->phoneNumberUtil = $phoneNumberUtil; } public function send(ShortMessage $shortMessage): void diff --git a/src/Bundle/ChillMainBundle/Templating/ChillTwigHelper.php b/src/Bundle/ChillMainBundle/Templating/ChillTwigHelper.php index a503426f0..95b307ed7 100644 --- a/src/Bundle/ChillMainBundle/Templating/ChillTwigHelper.php +++ b/src/Bundle/ChillMainBundle/Templating/ChillTwigHelper.php @@ -65,27 +65,15 @@ class ChillTwigHelper extends AbstractExtension 'time_format' => 'none', ], $options); - switch ($template) { - case 'default': - case 'blockquote': - $t = '@ChillMain/Extensions/PrintOrMessage/' . $template . '_date.html.twig'; - - break; - - default: - $t = $template; - } + $t = match ($template) { + 'default', 'blockquote' => '@ChillMain/Extensions/PrintOrMessage/' . $template . '_date.html.twig', + default => $template, + }; } else { - switch ($template) { - case 'default': - case 'blockquote': - $t = '@ChillMain/Extensions/PrintOrMessage/' . $template . '.html.twig'; - - break; - - default: - $t = $template; - } + $t = match ($template) { + 'default', 'blockquote' => '@ChillMain/Extensions/PrintOrMessage/' . $template . '.html.twig', + default => $template, + }; } return $twig->render($t, array_merge([ diff --git a/src/Bundle/ChillMainBundle/Templating/Entity/AddressRender.php b/src/Bundle/ChillMainBundle/Templating/Entity/AddressRender.php index 132884d60..668f7875a 100644 --- a/src/Bundle/ChillMainBundle/Templating/Entity/AddressRender.php +++ b/src/Bundle/ChillMainBundle/Templating/Entity/AddressRender.php @@ -36,16 +36,8 @@ class AddressRender implements ChillEntityRenderInterface 'extended_infos' => false, ]; - private EngineInterface $templating; - - private TranslatableStringHelperInterface $translatableStringHelper; - - public function __construct( - EngineInterface $templating, - TranslatableStringHelperInterface $translatableStringHelper - ) { - $this->templating = $templating; - $this->translatableStringHelper = $translatableStringHelper; + public function __construct(private EngineInterface $templating, private TranslatableStringHelperInterface $translatableStringHelper) + { } public function renderBox($addr, array $options): string diff --git a/src/Bundle/ChillMainBundle/Templating/Entity/CommentRender.php b/src/Bundle/ChillMainBundle/Templating/Entity/CommentRender.php index 7e567725e..464415848 100644 --- a/src/Bundle/ChillMainBundle/Templating/Entity/CommentRender.php +++ b/src/Bundle/ChillMainBundle/Templating/Entity/CommentRender.php @@ -24,19 +24,9 @@ use function array_merge; class CommentRender implements ChillEntityRenderInterface { use BoxUtilsChillEntityRenderTrait; - /** - * @var EngineInterface - */ - private $engine; - private UserRepositoryInterface $userRepository; - - public function __construct( - UserRepositoryInterface $userRepository, - EngineInterface $engine - ) { - $this->userRepository = $userRepository; - $this->engine = $engine; + public function __construct(private UserRepositoryInterface $userRepository, private EngineInterface $engine) + { } public function renderBox($entity, array $options): string diff --git a/src/Bundle/ChillMainBundle/Templating/Entity/UserRender.php b/src/Bundle/ChillMainBundle/Templating/Entity/UserRender.php index eab014289..e34440491 100644 --- a/src/Bundle/ChillMainBundle/Templating/Entity/UserRender.php +++ b/src/Bundle/ChillMainBundle/Templating/Entity/UserRender.php @@ -30,17 +30,8 @@ class UserRender implements ChillEntityRenderInterface 'absence' => true, ]; - private EngineInterface $engine; - - private TranslatableStringHelper $translatableStringHelper; - - private TranslatorInterface $translator; - - public function __construct(TranslatableStringHelper $translatableStringHelper, EngineInterface $engine, TranslatorInterface $translator) + public function __construct(private TranslatableStringHelper $translatableStringHelper, private EngineInterface $engine, private TranslatorInterface $translator) { - $this->translatableStringHelper = $translatableStringHelper; - $this->engine = $engine; - $this->translator = $translator; } public function renderBox($entity, array $options): string diff --git a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php index 367cc0861..c8b3839c9 100644 --- a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php +++ b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php @@ -26,26 +26,18 @@ class FilterOrderHelper private array $dateRanges = []; - private FormFactoryInterface $formFactory; - private ?string $formName = 'f'; private array $formOptions = []; private string $formType = FilterOrderType::class; - private RequestStack $requestStack; - private ?array $searchBoxFields = null; private ?array $submitted = null; - public function __construct( - FormFactoryInterface $formFactory, - RequestStack $requestStack - ) { - $this->formFactory = $formFactory; - $this->requestStack = $requestStack; + public function __construct(private FormFactoryInterface $formFactory, private RequestStack $requestStack) + { } public function addCheckbox(string $name, array $choices, ?array $default = [], ?array $trans = []): self diff --git a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperBuilder.php b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperBuilder.php index d68c8c37a..770b42cae 100644 --- a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperBuilder.php +++ b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperBuilder.php @@ -21,18 +21,10 @@ class FilterOrderHelperBuilder private array $dateRanges = []; - private FormFactoryInterface $formFactory; - - private RequestStack $requestStack; - private ?array $searchBoxFields = null; - public function __construct( - FormFactoryInterface $formFactory, - RequestStack $requestStack - ) { - $this->formFactory = $formFactory; - $this->requestStack = $requestStack; + public function __construct(private FormFactoryInterface $formFactory, private RequestStack $requestStack) + { } public function addCheckbox(string $name, array $choices, ?array $default = [], ?array $trans = []): self diff --git a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperFactory.php b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperFactory.php index c88c71af5..930da454c 100644 --- a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperFactory.php +++ b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperFactory.php @@ -16,16 +16,8 @@ use Symfony\Component\HttpFoundation\RequestStack; class FilterOrderHelperFactory implements FilterOrderHelperFactoryInterface { - private FormFactoryInterface $formFactory; - - private RequestStack $requestStack; - - public function __construct( - FormFactoryInterface $formFactory, - RequestStack $requestStack - ) { - $this->formFactory = $formFactory; - $this->requestStack = $requestStack; + public function __construct(private FormFactoryInterface $formFactory, private RequestStack $requestStack) + { } public function create(string $context, ?array $options = []): FilterOrderHelperBuilder diff --git a/src/Bundle/ChillMainBundle/Templating/TranslatableStringHelper.php b/src/Bundle/ChillMainBundle/Templating/TranslatableStringHelper.php index 19f9a4d45..6136ffc3e 100644 --- a/src/Bundle/ChillMainBundle/Templating/TranslatableStringHelper.php +++ b/src/Bundle/ChillMainBundle/Templating/TranslatableStringHelper.php @@ -21,14 +21,8 @@ final class TranslatableStringHelper implements TranslatableStringHelperInterfac { private string $defaultLocale; - private RequestStack $requestStack; - - private TranslatorInterface $translator; - - public function __construct(RequestStack $requestStack, TranslatorInterface $translator, ParameterBagInterface $parameterBag) + public function __construct(private RequestStack $requestStack, private TranslatorInterface $translator, ParameterBagInterface $parameterBag) { - $this->requestStack = $requestStack; - $this->translator = $translator; $this->defaultLocale = $parameterBag->get('kernel.default_locale'); } diff --git a/src/Bundle/ChillMainBundle/Templating/TranslatableStringTwig.php b/src/Bundle/ChillMainBundle/Templating/TranslatableStringTwig.php index 61a381f75..aaefdeeae 100644 --- a/src/Bundle/ChillMainBundle/Templating/TranslatableStringTwig.php +++ b/src/Bundle/ChillMainBundle/Templating/TranslatableStringTwig.php @@ -19,17 +19,11 @@ class TranslatableStringTwig extends AbstractExtension { use ContainerAwareTrait; - /** - * @var TranslatableStringHelper - */ - private $helper; - /** * TranslatableStringTwig constructor. */ - public function __construct(TranslatableStringHelper $translatableStringHelper) + public function __construct(private TranslatableStringHelper $helper) { - $this->helper = $translatableStringHelper; } /** diff --git a/src/Bundle/ChillMainBundle/Templating/Widget/WidgetRenderingTwig.php b/src/Bundle/ChillMainBundle/Templating/Widget/WidgetRenderingTwig.php index 39b74a041..9b752c439 100644 --- a/src/Bundle/ChillMainBundle/Templating/Widget/WidgetRenderingTwig.php +++ b/src/Bundle/ChillMainBundle/Templating/Widget/WidgetRenderingTwig.php @@ -82,7 +82,7 @@ class WidgetRenderingTwig extends AbstractExtension * @param WidgetInterface $widget * @param mixed $ordering */ - public function addWidget($place, $ordering, $widget, array $config = []) + public function addWidget($place, mixed $ordering, $widget, array $config = []) { $this->widget[$place][$ordering] = [$widget, $config]; } diff --git a/src/Bundle/ChillMainBundle/Test/Export/AbstractExportTest.php b/src/Bundle/ChillMainBundle/Test/Export/AbstractExportTest.php index 23f6c4b84..89fb69c82 100644 --- a/src/Bundle/ChillMainBundle/Test/Export/AbstractExportTest.php +++ b/src/Bundle/ChillMainBundle/Test/Export/AbstractExportTest.php @@ -294,7 +294,7 @@ abstract class AbstractExportTest extends WebTestCase * @param mixed $acl * @param mixed $data */ - public function testInitiateQuery($modifiers, $acl, $data) + public function testInitiateQuery(mixed $modifiers, mixed $acl, mixed $data) { $query = $this->getExport()->initiateQuery($modifiers, $acl, $data); @@ -390,7 +390,7 @@ abstract class AbstractExportTest extends WebTestCase * @param mixed $acl * @param mixed $data */ - public function testSupportsModifier($modifiers, $acl, $data) + public function testSupportsModifier(mixed $modifiers, mixed $acl, mixed $data) { $export = $this->getExport(); $query = $export->initiateQuery($modifiers, $acl, $data); diff --git a/src/Bundle/ChillMainBundle/Test/Export/AbstractFilterTest.php b/src/Bundle/ChillMainBundle/Test/Export/AbstractFilterTest.php index e1c8665ec..7482476cf 100644 --- a/src/Bundle/ChillMainBundle/Test/Export/AbstractFilterTest.php +++ b/src/Bundle/ChillMainBundle/Test/Export/AbstractFilterTest.php @@ -205,7 +205,7 @@ abstract class AbstractFilterTest extends KernelTestCase sprintf( "This test is incomplete due to %s thrown by 'translator' : %s, " . 'complete stack : %s', - get_class($ex), + $ex::class, $ex->getMessage(), $ex->getTraceAsString() ) diff --git a/src/Bundle/ChillMainBundle/Tests/Controller/UserApiControllerTest.php b/src/Bundle/ChillMainBundle/Tests/Controller/UserApiControllerTest.php index ef421020e..3192a3edb 100644 --- a/src/Bundle/ChillMainBundle/Tests/Controller/UserApiControllerTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Controller/UserApiControllerTest.php @@ -27,10 +27,8 @@ final class UserApiControllerTest extends WebTestCase /** * @depends testIndex - * - * @param mixed $existingUser */ - public function testEntity($existingUser) + public function testEntity(mixed $existingUser) { $client = $this->getClientAuthenticated(); diff --git a/src/Bundle/ChillMainBundle/Tests/Controller/UserControllerTest.php b/src/Bundle/ChillMainBundle/Tests/Controller/UserControllerTest.php index bc14d2604..1cbee3002 100644 --- a/src/Bundle/ChillMainBundle/Tests/Controller/UserControllerTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Controller/UserControllerTest.php @@ -130,10 +130,8 @@ final class UserControllerTest extends WebTestCase /** * @dataProvider dataGenerateUserId - * - * @param mixed $username */ - public function testUpdatePassword(int $userId, $username) + public function testUpdatePassword(int $userId, mixed $username) { $crawler = $this->client->request('GET', "/fr/admin/user/{$userId}/edit_password"); $newPassword = '1234Password!'; diff --git a/src/Bundle/ChillMainBundle/Tests/Cron/CronManagerTest.php b/src/Bundle/ChillMainBundle/Tests/Cron/CronManagerTest.php index 4b812ce2b..98de6891f 100644 --- a/src/Bundle/ChillMainBundle/Tests/Cron/CronManagerTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Cron/CronManagerTest.php @@ -161,11 +161,8 @@ final class CronManagerTest extends TestCase class JobCanRun implements CronJobInterface { - private string $key; - - public function __construct(string $key) + public function __construct(private string $key) { - $this->key = $key; } public function canRun(?CronJobExecution $cronJobExecution): bool diff --git a/src/Bundle/ChillMainBundle/Tests/Export/ExportManagerTest.php b/src/Bundle/ChillMainBundle/Tests/Export/ExportManagerTest.php index f0a57e1b0..1ae052963 100644 --- a/src/Bundle/ChillMainBundle/Tests/Export/ExportManagerTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Export/ExportManagerTest.php @@ -305,17 +305,11 @@ final class ExportManagerTest extends KernelTestCase Argument::is(['cat a', 'cat b']), Argument::is([]) ) - ->willReturn(static function ($value) { - switch ($value) { - case '_header': return 'foo_header'; - - case 'cat a': return 'label cat a'; - - case 'cat b': return 'label cat b'; - - default: - throw new RuntimeException(sprintf('This value (%s) is not valid', $value)); - } + ->willReturn(static fn ($value) => match ($value) { + '_header' => 'foo_header', + 'cat a' => 'label cat a', + 'cat b' => 'label cat b', + default => throw new RuntimeException(sprintf('This value (%s) is not valid', $value)), }); $aggregator->addRole()->willReturn(null); //$aggregator->addRole()->shouldBeCalled(); diff --git a/src/Bundle/ChillMainBundle/Tests/Pagination/PageTest.php b/src/Bundle/ChillMainBundle/Tests/Pagination/PageTest.php index 2ae0ecab7..b2b2c2960 100644 --- a/src/Bundle/ChillMainBundle/Tests/Pagination/PageTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Pagination/PageTest.php @@ -110,17 +110,15 @@ final class PageTest extends KernelTestCase /** * @param int $itemPerPage * @param string $route - * @param mixed $number - * @param mixed $totalItems * * @return Page */ protected function generatePage( - $number = 1, + mixed $number = 1, $itemPerPage = 10, $route = 'route', array $routeParameters = [], - $totalItems = 100 + mixed $totalItems = 100 ) { $urlGenerator = $this->prophet->prophesize(); $urlGenerator->willImplement(UrlGeneratorInterface::class); diff --git a/src/Bundle/ChillMainBundle/Tests/Pagination/PaginatorTest.php b/src/Bundle/ChillMainBundle/Tests/Pagination/PaginatorTest.php index 52f156843..e10c48adb 100644 --- a/src/Bundle/ChillMainBundle/Tests/Pagination/PaginatorTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Pagination/PaginatorTest.php @@ -149,14 +149,13 @@ final class PaginatorTest extends KernelTestCase * @param int $totalItems * @param int $itemPerPage * @param int $currentPage - * @param mixed $expectedHasNextPage * @dataProvider generateHasPreviousPage */ public function testHasPreviousPage( $totalItems, $itemPerPage, $currentPage, - $expectedHasNextPage + mixed $expectedHasNextPage ) { $paginator = $this->generatePaginator($totalItems, $itemPerPage, $currentPage); @@ -215,15 +214,13 @@ final class PaginatorTest extends KernelTestCase /** * @param int $itemPerPage * @param string $route - * @param mixed $totalItems - * @param mixed $currentPageNumber * * @return Paginator */ protected function generatePaginator( - $totalItems, + mixed $totalItems, $itemPerPage, - $currentPageNumber = 1, + mixed $currentPageNumber = 1, $route = '', array $routeParameters = [] ) { diff --git a/src/Bundle/ChillMainBundle/Tests/Search/Utils/ExtractPhonenumberFromPatternTest.php b/src/Bundle/ChillMainBundle/Tests/Search/Utils/ExtractPhonenumberFromPatternTest.php index 962aac450..aa2e1bf30 100644 --- a/src/Bundle/ChillMainBundle/Tests/Search/Utils/ExtractPhonenumberFromPatternTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Search/Utils/ExtractPhonenumberFromPatternTest.php @@ -46,14 +46,8 @@ final class ExtractPhonenumberFromPatternTest extends KernelTestCase /** * @dataProvider provideData - * - * @param mixed $subject - * @param mixed $expectedCount - * @param mixed $expected - * @param mixed $filteredSubject - * @param mixed $msg */ - public function testExtract(string $defaultCarrierCode, $subject, $expectedCount, $expected, $filteredSubject, $msg) + public function testExtract(string $defaultCarrierCode, mixed $subject, mixed $expectedCount, mixed $expected, mixed $filteredSubject, mixed $msg) { $extractor = new ExtractPhonenumberFromPattern(new ParameterBag(['chill_main' => [ 'phone_helper' => ['default_carrier_code' => $defaultCarrierCode], diff --git a/src/Bundle/ChillMainBundle/Tests/Security/Authorization/AuthorizationHelperTest.php b/src/Bundle/ChillMainBundle/Tests/Security/Authorization/AuthorizationHelperTest.php index 8c681bfb0..3f0e6a71d 100644 --- a/src/Bundle/ChillMainBundle/Tests/Security/Authorization/AuthorizationHelperTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Security/Authorization/AuthorizationHelperTest.php @@ -230,12 +230,8 @@ final class AuthorizationHelperTest extends KernelTestCase /** * @dataProvider dataProvider_getReachableCenters - * - * @param mixed $test - * @param mixed $result - * @param mixed $msg */ - public function testGetReachableCenters($test, $result, $msg) + public function testGetReachableCenters(mixed $test, mixed $result, mixed $msg) { $this->assertEquals($test, $result, $msg); } diff --git a/src/Bundle/ChillMainBundle/Tests/Serializer/Normalizer/DateNormalizerTest.php b/src/Bundle/ChillMainBundle/Tests/Serializer/Normalizer/DateNormalizerTest.php index fb8aeae27..f7ef7e986 100644 --- a/src/Bundle/ChillMainBundle/Tests/Serializer/Normalizer/DateNormalizerTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Serializer/Normalizer/DateNormalizerTest.php @@ -68,14 +68,8 @@ final class DateNormalizerTest extends KernelTestCase /** * @dataProvider generateDataNormalize - * - * @param mixed $expected - * @param mixed $date - * @param mixed $format - * @param mixed $locale - * @param mixed $msg */ - public function testNormalize($expected, $date, $format, $locale, $msg) + public function testNormalize(mixed $expected, mixed $date, mixed $format, mixed $locale, mixed $msg) { $this->assertEquals($expected, $this->buildDateNormalizer($locale)->normalize($date, $format, []), $msg); } diff --git a/src/Bundle/ChillMainBundle/Tests/Serializer/Normalizer/DoctrineExistingEntityNormalizerTest.php b/src/Bundle/ChillMainBundle/Tests/Serializer/Normalizer/DoctrineExistingEntityNormalizerTest.php index c7212c8e6..b0363c1c6 100644 --- a/src/Bundle/ChillMainBundle/Tests/Serializer/Normalizer/DoctrineExistingEntityNormalizerTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Serializer/Normalizer/DoctrineExistingEntityNormalizerTest.php @@ -51,10 +51,8 @@ final class DoctrineExistingEntityNormalizerTest extends KernelTestCase /** * @dataProvider dataProviderUserId - * - * @param mixed $userId */ - public function testGetMappedClass($userId) + public function testGetMappedClass(mixed $userId) { $data = ['type' => 'user', 'id' => $userId]; $supports = $this->normalizer->supportsDenormalization($data, User::class); diff --git a/src/Bundle/ChillMainBundle/Tests/Serializer/Normalizer/PhonenumberNormalizerTest.php b/src/Bundle/ChillMainBundle/Tests/Serializer/Normalizer/PhonenumberNormalizerTest.php index af5a28d9f..450eac2b5 100644 --- a/src/Bundle/ChillMainBundle/Tests/Serializer/Normalizer/PhonenumberNormalizerTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Serializer/Normalizer/PhonenumberNormalizerTest.php @@ -38,12 +38,8 @@ final class PhonenumberNormalizerTest extends TestCase /** * @dataProvider dataProviderNormalizePhonenumber - * - * @param mixed $format - * @param mixed $context - * @param mixed $expected */ - public function testNormalize(?Phonenumber $phonenumber, $format, $context, $expected) + public function testNormalize(?Phonenumber $phonenumber, mixed $format, mixed $context, mixed $expected) { $parameterBag = $this->prophesize(ParameterBagInterface::class); $parameterBag->get(Argument::exact('chill_main'))->willReturn(['phone_helper' => ['default_carrier_code' => 'BE']]); diff --git a/src/Bundle/ChillMainBundle/Tests/TestHelper.php b/src/Bundle/ChillMainBundle/Tests/TestHelper.php index 79426270f..bc49e601f 100644 --- a/src/Bundle/ChillMainBundle/Tests/TestHelper.php +++ b/src/Bundle/ChillMainBundle/Tests/TestHelper.php @@ -21,14 +21,12 @@ class TestHelper /** * create a client authenticated with an user. * - * @param mixed $username - * @param mixed $password * * @return \Symfony\Component\BrowserKit\Client authenticated client */ public static function getAuthenticatedClientOptions( - $username = 'center a_social', - $password = 'password' + mixed $username = 'center a_social', + mixed $password = 'password' ) { return [ 'PHP_AUTH_USER' => $username, diff --git a/src/Bundle/ChillMainBundle/Timeline/TimelineBuilder.php b/src/Bundle/ChillMainBundle/Timeline/TimelineBuilder.php index 20fc1b48c..c223bc375 100644 --- a/src/Bundle/ChillMainBundle/Timeline/TimelineBuilder.php +++ b/src/Bundle/ChillMainBundle/Timeline/TimelineBuilder.php @@ -29,11 +29,6 @@ class TimelineBuilder implements ContainerAwareInterface { use \Symfony\Component\DependencyInjection\ContainerAwareTrait; - /** - * @var \Doctrine\ORM\EntityManagerInterface - */ - private $em; - /** * Record provider. * @@ -52,9 +47,8 @@ class TimelineBuilder implements ContainerAwareInterface */ private $providersByContext = []; - public function __construct(EntityManagerInterface $em) + public function __construct(private EntityManagerInterface $em) { - $this->em = $em; } /** @@ -260,13 +254,11 @@ class TimelineBuilder implements ContainerAwareInterface * get the template data from the provider for the given entity, by type. * * @param string $type - * @param mixed $entity * @param string $context * @param mixed[] $args - * * @return array the template data fetched from the provider */ - private function getTemplateData($type, $entity, $context, array $args) + private function getTemplateData($type, mixed $entity, $context, array $args) { foreach ($this->getProvidersByContext($context) as $provider) { if ($provider->supportsType($type)) { diff --git a/src/Bundle/ChillMainBundle/Timeline/TimelineSingleQuery.php b/src/Bundle/ChillMainBundle/Timeline/TimelineSingleQuery.php index 6ea51bd75..519883590 100644 --- a/src/Bundle/ChillMainBundle/Timeline/TimelineSingleQuery.php +++ b/src/Bundle/ChillMainBundle/Timeline/TimelineSingleQuery.php @@ -15,34 +15,10 @@ use function strtr; class TimelineSingleQuery { - private ?string $date; - private bool $distinct = false; - private ?string $from; - - private ?string $id; - - private ?string $key; - - private array $parameters = []; - - private ?string $where; - - public function __construct( - ?string $id = null, - ?string $date = null, - ?string $key = null, - ?string $from = null, - ?string $where = null, - array $parameters = [] - ) { - $this->id = $id; - $this->date = $date; - $this->key = $key; - $this->from = $from; - $this->where = $where; - $this->parameters = $parameters; + public function __construct(private ?string $id = null, private ?string $date = null, private ?string $key = null, private ?string $from = null, private ?string $where = null, private array $parameters = []) + { } public function buildSql(): string diff --git a/src/Bundle/ChillMainBundle/Util/DateRangeCovering.php b/src/Bundle/ChillMainBundle/Util/DateRangeCovering.php index 488bb35b7..7ddecf70c 100644 --- a/src/Bundle/ChillMainBundle/Util/DateRangeCovering.php +++ b/src/Bundle/ChillMainBundle/Util/DateRangeCovering.php @@ -69,21 +69,18 @@ class DateRangeCovering private array $sequence = []; - private DateTimeZone $tz; - private int $uniqueKeyCounter = 0; /** * @param int $minCover the minimum of covering required */ - public function __construct(int $minCover, DateTimeZone $tz) + public function __construct(int $minCover, private DateTimeZone $tz) { if (0 > $minCover) { throw new LogicException('argument minCover cannot be lower than 0'); } $this->minCover = $minCover; - $this->tz = $tz; } public function add(DateTimeInterface $start, ?DateTimeInterface $end = null, $metadata = null): self diff --git a/src/Bundle/ChillMainBundle/Validation/Validator/RoleScopeScopePresence.php b/src/Bundle/ChillMainBundle/Validation/Validator/RoleScopeScopePresence.php index 09620d2a9..1ffb767e3 100644 --- a/src/Bundle/ChillMainBundle/Validation/Validator/RoleScopeScopePresence.php +++ b/src/Bundle/ChillMainBundle/Validation/Validator/RoleScopeScopePresence.php @@ -24,29 +24,8 @@ use function in_array; class RoleScopeScopePresence extends ConstraintValidator { - /** - * @var LoggerInterface - */ - private $logger; - - /** - * @var RoleProvider - */ - private $roleProvider; - - /** - * @var TranslatorInterface - */ - private $translator; - - public function __construct( - RoleProvider $roleProvider, - LoggerInterface $logger, - TranslatorInterface $translator - ) { - $this->roleProvider = $roleProvider; - $this->logger = $logger; - $this->translator = $translator; + public function __construct(private RoleProvider $roleProvider, private LoggerInterface $logger, private TranslatorInterface $translator) + { } public function validate($value, Constraint $constraint) diff --git a/src/Bundle/ChillMainBundle/Validation/Validator/ValidPhonenumber.php b/src/Bundle/ChillMainBundle/Validation/Validator/ValidPhonenumber.php index 9305cbf09..0c9eae2c4 100644 --- a/src/Bundle/ChillMainBundle/Validation/Validator/ValidPhonenumber.php +++ b/src/Bundle/ChillMainBundle/Validation/Validator/ValidPhonenumber.php @@ -19,16 +19,8 @@ use Symfony\Component\Validator\ConstraintValidator; final class ValidPhonenumber extends ConstraintValidator { - private LoggerInterface $logger; - - private PhoneNumberHelperInterface $phonenumberHelper; - - public function __construct( - LoggerInterface $logger, - PhoneNumberHelperInterface $phonenumberHelper - ) { - $this->phonenumberHelper = $phonenumberHelper; - $this->logger = $logger; + public function __construct(private LoggerInterface $logger, private PhoneNumberHelperInterface $phonenumberHelper) + { } /** diff --git a/src/Bundle/ChillMainBundle/Workflow/Counter/WorkflowByUserCounter.php b/src/Bundle/ChillMainBundle/Workflow/Counter/WorkflowByUserCounter.php index 5340ac78b..3dc5928d6 100644 --- a/src/Bundle/ChillMainBundle/Workflow/Counter/WorkflowByUserCounter.php +++ b/src/Bundle/ChillMainBundle/Workflow/Counter/WorkflowByUserCounter.php @@ -22,14 +22,8 @@ use Symfony\Component\Workflow\Event\Event; final class WorkflowByUserCounter implements NotificationCounterInterface, EventSubscriberInterface { - private CacheItemPoolInterface $cacheItemPool; - - private EntityWorkflowStepRepository $workflowStepRepository; - - public function __construct(EntityWorkflowStepRepository $workflowStepRepository, CacheItemPoolInterface $cacheItemPool) + public function __construct(private EntityWorkflowStepRepository $workflowStepRepository, private CacheItemPoolInterface $cacheItemPool) { - $this->workflowStepRepository = $workflowStepRepository; - $this->cacheItemPool = $cacheItemPool; } public function addNotification(UserInterface $u): int diff --git a/src/Bundle/ChillMainBundle/Workflow/EntityWorkflowManager.php b/src/Bundle/ChillMainBundle/Workflow/EntityWorkflowManager.php index 5be5f3fd9..2f5356e6e 100644 --- a/src/Bundle/ChillMainBundle/Workflow/EntityWorkflowManager.php +++ b/src/Bundle/ChillMainBundle/Workflow/EntityWorkflowManager.php @@ -18,16 +18,10 @@ use Symfony\Component\Workflow\Registry; class EntityWorkflowManager { /** - * @var iterable|EntityWorkflowHandlerInterface[] + * @param \Chill\MainBundle\Workflow\EntityWorkflowHandlerInterface[] $handlers */ - private iterable $handlers; - - private Registry $registry; - - public function __construct(iterable $handlers, Registry $registry) + public function __construct(private iterable $handlers, private Registry $registry) { - $this->handlers = $handlers; - $this->registry = $registry; } public function getHandler(EntityWorkflow $entityWorkflow, array $options = []): EntityWorkflowHandlerInterface diff --git a/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/EntityWorkflowTransitionEventSubscriber.php b/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/EntityWorkflowTransitionEventSubscriber.php index f3e04eeca..3657e4f53 100644 --- a/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/EntityWorkflowTransitionEventSubscriber.php +++ b/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/EntityWorkflowTransitionEventSubscriber.php @@ -25,20 +25,8 @@ use function array_key_exists; class EntityWorkflowTransitionEventSubscriber implements EventSubscriberInterface { - private LoggerInterface $chillLogger; - - private Security $security; - - private UserRender $userRender; - - public function __construct( - LoggerInterface $chillLogger, - Security $security, - UserRender $userRender - ) { - $this->chillLogger = $chillLogger; - $this->security = $security; - $this->userRender = $userRender; + public function __construct(private LoggerInterface $chillLogger, private Security $security, private UserRender $userRender) + { } public function addDests(Event $event): void diff --git a/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/NotificationOnTransition.php b/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/NotificationOnTransition.php index 76ad4a4b0..ceeb3023f 100644 --- a/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/NotificationOnTransition.php +++ b/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/NotificationOnTransition.php @@ -25,28 +25,8 @@ use function in_array; class NotificationOnTransition implements EventSubscriberInterface { - private EngineInterface $engine; - - private EntityManagerInterface $entityManager; - - private MetadataExtractor $metadataExtractor; - - private Registry $registry; - - private Security $security; - - public function __construct( - EntityManagerInterface $entityManager, - EngineInterface $engine, - MetadataExtractor $metadataExtractor, - Security $security, - Registry $registry - ) { - $this->entityManager = $entityManager; - $this->engine = $engine; - $this->metadataExtractor = $metadataExtractor; - $this->registry = $registry; - $this->security = $security; + public function __construct(private EntityManagerInterface $entityManager, private EngineInterface $engine, private MetadataExtractor $metadataExtractor, private Security $security, private Registry $registry) + { } public static function getSubscribedEvents(): array diff --git a/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/SendAccessKeyEventSubscriber.php b/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/SendAccessKeyEventSubscriber.php index 7d0ad8280..b1ce5074c 100644 --- a/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/SendAccessKeyEventSubscriber.php +++ b/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/SendAccessKeyEventSubscriber.php @@ -21,23 +21,8 @@ use Symfony\Component\Workflow\Registry; class SendAccessKeyEventSubscriber { - private EngineInterface $engine; - - private EntityWorkflowManager $entityWorkflowManager; - - private MailerInterface $mailer; - - private MetadataExtractor $metadataExtractor; - - private Registry $registry; - - public function __construct(EngineInterface $engine, MetadataExtractor $metadataExtractor, Registry $registry, EntityWorkflowManager $entityWorkflowManager, MailerInterface $mailer) + public function __construct(private EngineInterface $engine, private MetadataExtractor $metadataExtractor, private Registry $registry, private EntityWorkflowManager $entityWorkflowManager, private MailerInterface $mailer) { - $this->engine = $engine; - $this->metadataExtractor = $metadataExtractor; - $this->registry = $registry; - $this->entityWorkflowManager = $entityWorkflowManager; - $this->mailer = $mailer; } public function postPersist(EntityWorkflowStep $step): void diff --git a/src/Bundle/ChillMainBundle/Workflow/Helper/MetadataExtractor.php b/src/Bundle/ChillMainBundle/Workflow/Helper/MetadataExtractor.php index 071b31d35..87026e920 100644 --- a/src/Bundle/ChillMainBundle/Workflow/Helper/MetadataExtractor.php +++ b/src/Bundle/ChillMainBundle/Workflow/Helper/MetadataExtractor.php @@ -20,14 +20,8 @@ use function array_key_exists; class MetadataExtractor { - private Registry $registry; - - private TranslatableStringHelperInterface $translatableStringHelper; - - public function __construct(Registry $registry, TranslatableStringHelperInterface $translatableStringHelper) + public function __construct(private Registry $registry, private TranslatableStringHelperInterface $translatableStringHelper) { - $this->registry = $registry; - $this->translatableStringHelper = $translatableStringHelper; } public function availableWorkflowFor(string $relatedEntityClass, ?int $relatedEntityId = 0): array diff --git a/src/Bundle/ChillMainBundle/Workflow/Notification/WorkflowNotificationHandler.php b/src/Bundle/ChillMainBundle/Workflow/Notification/WorkflowNotificationHandler.php index d3e848d41..9f286508c 100644 --- a/src/Bundle/ChillMainBundle/Workflow/Notification/WorkflowNotificationHandler.php +++ b/src/Bundle/ChillMainBundle/Workflow/Notification/WorkflowNotificationHandler.php @@ -20,20 +20,8 @@ use Symfony\Component\Security\Core\Security; class WorkflowNotificationHandler implements NotificationHandlerInterface { - private EntityWorkflowManager $entityWorkflowManager; - - private EntityWorkflowRepository $entityWorkflowRepository; - - private Security $security; - - public function __construct( - EntityWorkflowRepository $entityWorkflowRepository, - EntityWorkflowManager $entityWorkflowManager, - Security $security - ) { - $this->entityWorkflowRepository = $entityWorkflowRepository; - $this->entityWorkflowManager = $entityWorkflowManager; - $this->security = $security; + public function __construct(private EntityWorkflowRepository $entityWorkflowRepository, private EntityWorkflowManager $entityWorkflowManager, private Security $security) + { } public function getTemplate(Notification $notification, array $options = []): string diff --git a/src/Bundle/ChillMainBundle/Workflow/Templating/WorkflowTwigExtensionRuntime.php b/src/Bundle/ChillMainBundle/Workflow/Templating/WorkflowTwigExtensionRuntime.php index 1ea593b6d..d1381a397 100644 --- a/src/Bundle/ChillMainBundle/Workflow/Templating/WorkflowTwigExtensionRuntime.php +++ b/src/Bundle/ChillMainBundle/Workflow/Templating/WorkflowTwigExtensionRuntime.php @@ -23,28 +23,8 @@ use Twig\Extension\RuntimeExtensionInterface; class WorkflowTwigExtensionRuntime implements RuntimeExtensionInterface { - private EntityWorkflowManager $entityWorkflowManager; - - private MetadataExtractor $metadataExtractor; - - private NormalizerInterface $normalizer; - - private Registry $registry; - - private EntityWorkflowRepository $repository; - - public function __construct( - EntityWorkflowManager $entityWorkflowManager, - Registry $registry, - EntityWorkflowRepository $repository, - MetadataExtractor $metadataExtractor, - NormalizerInterface $normalizer - ) { - $this->entityWorkflowManager = $entityWorkflowManager; - $this->registry = $registry; - $this->repository = $repository; - $this->metadataExtractor = $metadataExtractor; - $this->normalizer = $normalizer; + public function __construct(private EntityWorkflowManager $entityWorkflowManager, private Registry $registry, private EntityWorkflowRepository $repository, private MetadataExtractor $metadataExtractor, private NormalizerInterface $normalizer) + { } public function getTransitionByString(EntityWorkflow $entityWorkflow, string $key): ?Transition diff --git a/src/Bundle/ChillMainBundle/Workflow/Validator/EntityWorkflowCreationValidator.php b/src/Bundle/ChillMainBundle/Workflow/Validator/EntityWorkflowCreationValidator.php index bb3586251..eb035358d 100644 --- a/src/Bundle/ChillMainBundle/Workflow/Validator/EntityWorkflowCreationValidator.php +++ b/src/Bundle/ChillMainBundle/Workflow/Validator/EntityWorkflowCreationValidator.php @@ -22,16 +22,12 @@ use function count; class EntityWorkflowCreationValidator extends \Symfony\Component\Validator\ConstraintValidator { - private EntityWorkflowManager $entityWorkflowManager; - - public function __construct(EntityWorkflowManager $entityWorkflowManager) + public function __construct(private EntityWorkflowManager $entityWorkflowManager) { - $this->entityWorkflowManager = $entityWorkflowManager; } /** * @param EntityWorkflow $value - * @param Constraint|EntityWorkflowCreation $constraint */ public function validate($value, Constraint $constraint) { @@ -45,7 +41,7 @@ class EntityWorkflowCreationValidator extends \Symfony\Component\Validator\Const try { $handler = $this->entityWorkflowManager->getHandler($value); - } catch (HandlerNotFoundException $e) { + } catch (HandlerNotFoundException) { $this->context->buildViolation($constraint->messageHandlerNotFound) ->addViolation(); diff --git a/src/Bundle/ChillMainBundle/Workflow/Validator/StepDestValidValidator.php b/src/Bundle/ChillMainBundle/Workflow/Validator/StepDestValidValidator.php index 2c286fff9..1e0b6868c 100644 --- a/src/Bundle/ChillMainBundle/Workflow/Validator/StepDestValidValidator.php +++ b/src/Bundle/ChillMainBundle/Workflow/Validator/StepDestValidValidator.php @@ -22,7 +22,6 @@ class StepDestValidValidator extends ConstraintValidator { /** * @param EntityWorkflowStep $value - * @param Constraint|StepDestValid $constraint * * @return void */ diff --git a/src/Bundle/ChillMainBundle/migrations/Version20180703191509.php b/src/Bundle/ChillMainBundle/migrations/Version20180703191509.php index 397239e95..b73ee5362 100644 --- a/src/Bundle/ChillMainBundle/migrations/Version20180703191509.php +++ b/src/Bundle/ChillMainBundle/migrations/Version20180703191509.php @@ -34,7 +34,7 @@ final class Version20180703191509 extends AbstractMigration try { $this->addSql('CREATE EXTENSION IF NOT EXISTS pg_trgm'); $this->addSql('CREATE INDEX search_name_code ON chill_main_postal_code USING GIN (LOWER(code) gin_trgm_ops, LOWER(label) gin_trgm_ops)'); - } catch (Exception $e) { + } catch (Exception) { $this->skipIf(true, 'Could not create extension pg_trgm'); } } diff --git a/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Events/PersonAddressMoveEventSubscriber.php b/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Events/PersonAddressMoveEventSubscriber.php index 666febe9d..a24d8adb4 100644 --- a/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Events/PersonAddressMoveEventSubscriber.php +++ b/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Events/PersonAddressMoveEventSubscriber.php @@ -24,24 +24,8 @@ use Symfony\Contracts\Translation\TranslatorInterface; class PersonAddressMoveEventSubscriber implements EventSubscriberInterface { - private EngineInterface $engine; - - private NotificationPersisterInterface $notificationPersister; - - private Security $security; - - private TranslatorInterface $translator; - - public function __construct( - EngineInterface $engine, - NotificationPersisterInterface $notificationPersister, - Security $security, - TranslatorInterface $translator - ) { - $this->engine = $engine; - $this->notificationPersister = $notificationPersister; - $this->security = $security; - $this->translator = $translator; + public function __construct(private EngineInterface $engine, private NotificationPersisterInterface $notificationPersister, private Security $security, private TranslatorInterface $translator) + { } public static function getSubscribedEvents(): array diff --git a/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Events/UserRefEventSubscriber.php b/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Events/UserRefEventSubscriber.php index 8d7249928..cefc348c2 100644 --- a/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Events/UserRefEventSubscriber.php +++ b/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Events/UserRefEventSubscriber.php @@ -24,20 +24,8 @@ use Symfony\Contracts\Translation\TranslatorInterface; class UserRefEventSubscriber implements EventSubscriberInterface { - private EngineInterface $engine; - - private NotificationPersisterInterface $notificationPersister; - - private Security $security; - - private TranslatorInterface $translator; - - public function __construct(Security $security, TranslatorInterface $translator, EngineInterface $engine, NotificationPersisterInterface $notificationPersister) + public function __construct(private Security $security, private TranslatorInterface $translator, private EngineInterface $engine, private NotificationPersisterInterface $notificationPersister) { - $this->security = $security; - $this->translator = $translator; - $this->engine = $engine; - $this->notificationPersister = $notificationPersister; } public static function getSubscribedEvents() diff --git a/src/Bundle/ChillPersonBundle/Actions/ActionEvent.php b/src/Bundle/ChillPersonBundle/Actions/ActionEvent.php index 83623a026..b3a335ce7 100644 --- a/src/Bundle/ChillPersonBundle/Actions/ActionEvent.php +++ b/src/Bundle/ChillPersonBundle/Actions/ActionEvent.php @@ -22,25 +22,6 @@ class ActionEvent extends Event public const MOVE = 'CHILL_PERSON.MOVE_ASSOCIATED_ENTITY'; - /** - * the FQDN class name as recorded in doctrine. - * - * @var string - */ - protected $entity; - - /** - * an array of key value data to describe the movement. - * - * @var array - */ - protected $metadata; - - /** - * @var int - */ - protected $personId; - /** * @var string[] */ @@ -52,18 +33,26 @@ class ActionEvent extends Event protected $preSql = []; /** - * the sql statement. - * - * @var string + * @param string $entity + * @param mixed[] $metadata + * @param int $personId + * @param string $sqlStatement */ - protected $sqlStatement; - - public function __construct($personId, $entity, $sqlStatement, $metadata = []) - { - $this->personId = $personId; - $this->entity = $entity; - $this->sqlStatement = $sqlStatement; - $this->metadata = $metadata; + public function __construct( + protected $personId, + /** + * the FQDN class name as recorded in doctrine. + */ + protected $entity, + /** + * the sql statement. + */ + protected $sqlStatement, + /** + * an array of key value data to describe the movement. + */ + protected $metadata = [] + ) { } /** diff --git a/src/Bundle/ChillPersonBundle/CRUD/Controller/EntityPersonCRUDController.php b/src/Bundle/ChillPersonBundle/CRUD/Controller/EntityPersonCRUDController.php index 7bd337f6b..398114363 100644 --- a/src/Bundle/ChillPersonBundle/CRUD/Controller/EntityPersonCRUDController.php +++ b/src/Bundle/ChillPersonBundle/CRUD/Controller/EntityPersonCRUDController.php @@ -131,25 +131,14 @@ class EntityPersonCRUDController extends CRUDController return $this->getActionConfig($action)['template']; } - switch ($action) { - case 'new': - return '@ChillPerson/CRUD/new.html.twig'; - - case 'edit': - return '@ChillPerson/CRUD/edit.html.twig'; - - case 'view': - return '@ChillPerson/CRUD/view.html.twig'; - - case 'delete': - return '@ChillPerson/CRUD/delete.html.twig'; - - case 'index': - return '@ChillPerson/CRUD/index.html.twig'; - - default: - return parent::getTemplateFor($action, $entity, $request); - } + return match ($action) { + 'new' => '@ChillPerson/CRUD/new.html.twig', + 'edit' => '@ChillPerson/CRUD/edit.html.twig', + 'view' => '@ChillPerson/CRUD/view.html.twig', + 'delete' => '@ChillPerson/CRUD/delete.html.twig', + 'index' => '@ChillPerson/CRUD/index.html.twig', + default => parent::getTemplateFor($action, $entity, $request), + }; } /** @@ -161,28 +150,21 @@ class EntityPersonCRUDController extends CRUDController { $next = $request->request->get('submit', 'save-and-close'); - switch ($next) { - case 'save-and-close': - return $this->redirectToRoute('chill_crud_' . $this->getCrudName() . '_index', [ - 'person_id' => $this->getPerson($request)->getId(), - ]); - - case 'save-and-new': - return $this->redirectToRoute('chill_crud_' . $this->getCrudName() . '_new', [ - 'person_id' => $this->getPerson($request)->getId(), - ]); - - case 'new': - return $this->redirectToRoute('chill_crud_' . $this->getCrudName() . '_view', [ - 'id' => $entity->getId(), - 'person_id' => $this->getPerson($request)->getId(), - ]); - - default: - return $this->redirectToRoute('chill_crud_' . $this->getCrudName() . '_view', [ - 'id' => $entity->getId(), - 'person_id' => $this->getPerson($request)->getId(), - ]); - } + return match ($next) { + 'save-and-close' => $this->redirectToRoute('chill_crud_' . $this->getCrudName() . '_index', [ + 'person_id' => $this->getPerson($request)->getId(), + ]), + 'save-and-new' => $this->redirectToRoute('chill_crud_' . $this->getCrudName() . '_new', [ + 'person_id' => $this->getPerson($request)->getId(), + ]), + 'new' => $this->redirectToRoute('chill_crud_' . $this->getCrudName() . '_view', [ + 'id' => $entity->getId(), + 'person_id' => $this->getPerson($request)->getId(), + ]), + default => $this->redirectToRoute('chill_crud_' . $this->getCrudName() . '_view', [ + 'id' => $entity->getId(), + 'person_id' => $this->getPerson($request)->getId(), + ]), + }; } } diff --git a/src/Bundle/ChillPersonBundle/CRUD/Controller/OneToOneEntityPersonCRUDController.php b/src/Bundle/ChillPersonBundle/CRUD/Controller/OneToOneEntityPersonCRUDController.php index b5f2cfeec..f9c53712a 100644 --- a/src/Bundle/ChillPersonBundle/CRUD/Controller/OneToOneEntityPersonCRUDController.php +++ b/src/Bundle/ChillPersonBundle/CRUD/Controller/OneToOneEntityPersonCRUDController.php @@ -50,21 +50,14 @@ class OneToOneEntityPersonCRUDController extends CRUDController return $this->crudConfig[$action]['template']; } - switch ($action) { - case 'new': - return '@ChillPerson/CRUD/new.html.twig'; - - case 'edit': - return '@ChillPerson/CRUD/edit.html.twig'; - - case 'index': - return '@ChillPerson/CRUD/index.html.twig'; - - default: - throw new LogicException("the view for action {$action} is not " - . 'defined. You should override ' . __METHOD__ . ' to add this ' - . 'action'); - } + return match ($action) { + 'new' => '@ChillPerson/CRUD/new.html.twig', + 'edit' => '@ChillPerson/CRUD/edit.html.twig', + 'index' => '@ChillPerson/CRUD/index.html.twig', + default => throw new LogicException("the view for action {$action} is not " + . 'defined. You should override ' . __METHOD__ . ' to add this ' + . 'action'), + }; } protected function onPostFetchEntity($action, Request $request, $entity): ?Response diff --git a/src/Bundle/ChillPersonBundle/Command/ChillPersonMoveCommand.php b/src/Bundle/ChillPersonBundle/Command/ChillPersonMoveCommand.php index 231f7b27d..42b8f6cac 100644 --- a/src/Bundle/ChillPersonBundle/Command/ChillPersonMoveCommand.php +++ b/src/Bundle/ChillPersonBundle/Command/ChillPersonMoveCommand.php @@ -25,22 +25,12 @@ use function ctype_digit; final class ChillPersonMoveCommand extends Command { - private LoggerInterface $chillLogger; - - private EntityManagerInterface $em; - - private PersonMove $mover; - public function __construct( - PersonMove $mover, - EntityManagerInterface $em, - LoggerInterface $chillLogger + private PersonMove $mover, + private EntityManagerInterface $em, + private LoggerInterface $chillLogger ) { parent::__construct('chill:person:move'); - - $this->mover = $mover; - $this->em = $em; - $this->chillLogger = $chillLogger; } protected function buildLoggingContext(Person $from, Person $to, $deleteEntities, $sqls) diff --git a/src/Bundle/ChillPersonBundle/Command/ImportSocialWorkMetadata.php b/src/Bundle/ChillPersonBundle/Command/ImportSocialWorkMetadata.php index 91615935c..643e176c4 100644 --- a/src/Bundle/ChillPersonBundle/Command/ImportSocialWorkMetadata.php +++ b/src/Bundle/ChillPersonBundle/Command/ImportSocialWorkMetadata.php @@ -27,17 +27,10 @@ final class ImportSocialWorkMetadata extends Command { protected EntityManagerInterface $em; - /** - * @var LoggerInterface - */ - protected ChillImporter $importer; - public function __construct( - SocialWorkMetadataInterface $socialWorkMetadata + protected SocialWorkMetadataInterface $importer ) { parent::__construct('chill:person:import-socialwork'); - - $this->importer = $socialWorkMetadata; } protected function configure() diff --git a/src/Bundle/ChillPersonBundle/Command/RemoveOldDraftAccompanyingPeriodCommand.php b/src/Bundle/ChillPersonBundle/Command/RemoveOldDraftAccompanyingPeriodCommand.php index 8d43df0d3..ac6551bd2 100644 --- a/src/Bundle/ChillPersonBundle/Command/RemoveOldDraftAccompanyingPeriodCommand.php +++ b/src/Bundle/ChillPersonBundle/Command/RemoveOldDraftAccompanyingPeriodCommand.php @@ -22,16 +22,9 @@ use Symfony\Component\Console\Output\OutputInterface; class RemoveOldDraftAccompanyingPeriodCommand extends Command { - private LoggerInterface $logger; - - private OldDraftAccompanyingPeriodRemoverInterface $remover; - - public function __construct(LoggerInterface $logger, OldDraftAccompanyingPeriodRemoverInterface $remover) + public function __construct(private LoggerInterface $logger, private OldDraftAccompanyingPeriodRemoverInterface $remover) { parent::__construct('chill:person:remove-old-draft-period'); - - $this->logger = $logger; - $this->remover = $remover; } protected function configure(): void diff --git a/src/Bundle/ChillPersonBundle/Config/ConfigPersonAltNamesHelper.php b/src/Bundle/ChillPersonBundle/Config/ConfigPersonAltNamesHelper.php index 8c4be9477..b3180792e 100644 --- a/src/Bundle/ChillPersonBundle/Config/ConfigPersonAltNamesHelper.php +++ b/src/Bundle/ChillPersonBundle/Config/ConfigPersonAltNamesHelper.php @@ -17,15 +17,14 @@ namespace Chill\PersonBundle\Config; class ConfigPersonAltNamesHelper { /** - * the raw config, directly from the container parameter. - * - * @var array + * @param mixed[] $config */ - private $config = []; - - public function __construct($config) - { - $this->config = $config; + public function __construct( + /** + * the raw config, directly from the container parameter. + */ + private $config + ) { } /** diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php index 181f60a02..10329a87c 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php @@ -51,32 +51,8 @@ use function count; final class AccompanyingCourseApiController extends ApiController { - private AccompanyingPeriodACLAwareRepository $accompanyingPeriodACLAwareRepository; - - private AccompanyingPeriodRepository $accompanyingPeriodRepository; - - private EventDispatcherInterface $eventDispatcher; - - private ReferralsSuggestionInterface $referralAvailable; - - private Registry $registry; - - private ValidatorInterface $validator; - - public function __construct( - AccompanyingPeriodRepository $accompanyingPeriodRepository, - AccompanyingPeriodACLAwareRepository $accompanyingPeriodACLAwareRepository, - EventDispatcherInterface $eventDispatcher, - ReferralsSuggestionInterface $referralAvailable, - Registry $registry, - ValidatorInterface $validator - ) { - $this->accompanyingPeriodRepository = $accompanyingPeriodRepository; - $this->accompanyingPeriodACLAwareRepository = $accompanyingPeriodACLAwareRepository; - $this->eventDispatcher = $eventDispatcher; - $this->referralAvailable = $referralAvailable; - $this->registry = $registry; - $this->validator = $validator; + public function __construct(private AccompanyingPeriodRepository $accompanyingPeriodRepository, private AccompanyingPeriodACLAwareRepository $accompanyingPeriodACLAwareRepository, private EventDispatcherInterface $eventDispatcher, private ReferralsSuggestionInterface $referralAvailable, private Registry $registry, private ValidatorInterface $validator) + { } public function commentApi($id, Request $request, string $_format): Response @@ -190,20 +166,11 @@ final class AccompanyingCourseApiController extends ApiController // $this->onPostCheckACL('participation', $request, $_format, $accompanyingPeriod); - switch ($request->getMethod()) { - case Request::METHOD_POST: - $participation = $accompanyingPeriod->createParticipationFor($person); - - break; - - case Request::METHOD_DELETE: - $participation = $accompanyingPeriod->closeParticipationFor($person); - - break; - - default: - throw new BadRequestHttpException('This method is not supported'); - } + $participation = match ($request->getMethod()) { + Request::METHOD_POST => $accompanyingPeriod->createParticipationFor($person), + Request::METHOD_DELETE => $accompanyingPeriod->closeParticipationFor($person), + default => throw new BadRequestHttpException('This method is not supported'), + }; $errors = $this->validator->validate($accompanyingPeriod); @@ -320,10 +287,8 @@ final class AccompanyingCourseApiController extends ApiController /** * @Route("/api/1.0/person/accompanying-course/{id}/confidential.json", name="chill_api_person_accompanying_period_confidential") * @ParamConverter("accompanyingCourse", options={"id": "id"}) - * - * @param mixed $id */ - public function toggleConfidentialApi(AccompanyingPeriod $accompanyingCourse, $id, Request $request) + public function toggleConfidentialApi(AccompanyingPeriod $accompanyingCourse, mixed $id, Request $request) { if ($request->getMethod() === 'POST') { $this->denyAccessUnlessGranted(AccompanyingPeriodVoter::TOGGLE_CONFIDENTIAL, $accompanyingCourse); diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseCommentController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseCommentController.php index 5a6946696..99608d640 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseCommentController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseCommentController.php @@ -32,20 +32,8 @@ use Symfony\Contracts\Translation\TranslatorInterface; class AccompanyingCourseCommentController extends AbstractController { - private EntityManagerInterface $entityManager; - - private FormFactoryInterface $formFactory; - - private TranslatorInterface $translator; - - public function __construct( - EntityManagerInterface $entityManager, - FormFactoryInterface $formFactory, - TranslatorInterface $translator - ) { - $this->entityManager = $entityManager; - $this->formFactory = $formFactory; - $this->translator = $translator; + public function __construct(private EntityManagerInterface $entityManager, private FormFactoryInterface $formFactory, private TranslatorInterface $translator) + { } /** diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php index f7e3b3800..41e4a9b90 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php @@ -41,32 +41,8 @@ use function is_array; */ class AccompanyingCourseController extends Controller { - protected EventDispatcherInterface $dispatcher; - - protected SerializerInterface $serializer; - - protected ValidatorInterface $validator; - - private Registry $registry; - - private TranslatorInterface $translator; - - private AccompanyingPeriodWorkRepository $workRepository; - - public function __construct( - SerializerInterface $serializer, - EventDispatcherInterface $dispatcher, - ValidatorInterface $validator, - AccompanyingPeriodWorkRepository $workRepository, - Registry $registry, - TranslatorInterface $translator - ) { - $this->serializer = $serializer; - $this->dispatcher = $dispatcher; - $this->validator = $validator; - $this->workRepository = $workRepository; - $this->registry = $registry; - $this->translator = $translator; + public function __construct(protected SerializerInterface $serializer, protected EventDispatcherInterface $dispatcher, protected ValidatorInterface $validator, private AccompanyingPeriodWorkRepository $workRepository, private Registry $registry, private TranslatorInterface $translator) + { } /** diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkApiController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkApiController.php index b7c189155..f57ad0c56 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkApiController.php @@ -23,11 +23,8 @@ use Symfony\Component\Routing\Annotation\Route; class AccompanyingCourseWorkApiController extends ApiController { - private AccompanyingPeriodWorkRepository $accompanyingPeriodWorkRepository; - - public function __construct(AccompanyingPeriodWorkRepository $accompanyingPeriodWorkRepository) + public function __construct(private AccompanyingPeriodWorkRepository $accompanyingPeriodWorkRepository) { - $this->accompanyingPeriodWorkRepository = $accompanyingPeriodWorkRepository; } /** diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php index 8d15ca30f..a36ad67b0 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php @@ -28,28 +28,8 @@ use Symfony\Contracts\Translation\TranslatorInterface; class AccompanyingCourseWorkController extends AbstractController { - private LoggerInterface $chillLogger; - - private PaginatorFactory $paginator; - - private SerializerInterface $serializer; - - private TranslatorInterface $trans; - - private AccompanyingPeriodWorkRepository $workRepository; - - public function __construct( - TranslatorInterface $trans, - SerializerInterface $serializer, - AccompanyingPeriodWorkRepository $workRepository, - PaginatorFactory $paginator, - LoggerInterface $chillLogger - ) { - $this->trans = $trans; - $this->serializer = $serializer; - $this->workRepository = $workRepository; - $this->paginator = $paginator; - $this->chillLogger = $chillLogger; + public function __construct(private TranslatorInterface $trans, private SerializerInterface $serializer, private AccompanyingPeriodWorkRepository $workRepository, private PaginatorFactory $paginator, private LoggerInterface $chillLogger) + { } /** diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodController.php index b32454387..a75785ce0 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodController.php @@ -36,8 +36,6 @@ use function count; */ class AccompanyingPeriodController extends AbstractController { - protected AccompanyingPeriodACLAwareRepositoryInterface $accompanyingPeriodACLAwareRepository; - /** * @var EventDispatcherInterface */ @@ -49,11 +47,10 @@ class AccompanyingPeriodController extends AbstractController protected $validator; public function __construct( - AccompanyingPeriodACLAwareRepositoryInterface $accompanyingPeriodACLAwareRepository, + protected AccompanyingPeriodACLAwareRepositoryInterface $accompanyingPeriodACLAwareRepository, EventDispatcherInterface $eventDispatcher, ValidatorInterface $validator ) { - $this->accompanyingPeriodACLAwareRepository = $accompanyingPeriodACLAwareRepository; $this->eventDispatcher = $eventDispatcher; $this->validator = $validator; } diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodRegulationListController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodRegulationListController.php index 6bbb6c368..34aeb835a 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodRegulationListController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodRegulationListController.php @@ -32,26 +32,8 @@ use Symfony\Component\Templating\EngineInterface; class AccompanyingPeriodRegulationListController { - private AccompanyingPeriodACLAwareRepositoryInterface $accompanyingPeriodACLAwareRepository; - - private EngineInterface $engine; - - private FormFactoryInterface $formFactory; - - private PaginatorFactory $paginatorFactory; - - private Security $security; - - private TranslatableStringHelperInterface $translatableStringHelper; - - public function __construct(AccompanyingPeriodACLAwareRepositoryInterface $accompanyingPeriodACLAwareRepository, EngineInterface $engine, FormFactoryInterface $formFactory, PaginatorFactory $paginatorFactory, Security $security, TranslatableStringHelperInterface $translatableStringHelper) + public function __construct(private AccompanyingPeriodACLAwareRepositoryInterface $accompanyingPeriodACLAwareRepository, private EngineInterface $engine, private FormFactoryInterface $formFactory, private PaginatorFactory $paginatorFactory, private Security $security, private TranslatableStringHelperInterface $translatableStringHelper) { - $this->accompanyingPeriodACLAwareRepository = $accompanyingPeriodACLAwareRepository; - $this->engine = $engine; - $this->formFactory = $formFactory; - $this->paginatorFactory = $paginatorFactory; - $this->security = $security; - $this->translatableStringHelper = $translatableStringHelper; } /** diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodWorkEvaluationApiController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodWorkEvaluationApiController.php index e41ab07c7..9a4b5e15a 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodWorkEvaluationApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodWorkEvaluationApiController.php @@ -32,28 +32,8 @@ use function in_array; class AccompanyingPeriodWorkEvaluationApiController { - private AccompanyingPeriodWorkEvaluationRepository $accompanyingPeriodWorkEvaluationRepository; - - private DocGeneratorTemplateRepository $docGeneratorTemplateRepository; - - private PaginatorFactory $paginatorFactory; - - private Security $security; - - private SerializerInterface $serializer; - - public function __construct( - AccompanyingPeriodWorkEvaluationRepository $accompanyingPeriodWorkEvaluationRepository, - DocGeneratorTemplateRepository $docGeneratorTemplateRepository, - SerializerInterface $serializer, - PaginatorFactory $paginatorFactory, - Security $security - ) { - $this->accompanyingPeriodWorkEvaluationRepository = $accompanyingPeriodWorkEvaluationRepository; - $this->docGeneratorTemplateRepository = $docGeneratorTemplateRepository; - $this->serializer = $serializer; - $this->paginatorFactory = $paginatorFactory; - $this->security = $security; + public function __construct(private AccompanyingPeriodWorkEvaluationRepository $accompanyingPeriodWorkEvaluationRepository, private DocGeneratorTemplateRepository $docGeneratorTemplateRepository, private SerializerInterface $serializer, private PaginatorFactory $paginatorFactory, private Security $security) + { } /** diff --git a/src/Bundle/ChillPersonBundle/Controller/HouseholdApiController.php b/src/Bundle/ChillPersonBundle/Controller/HouseholdApiController.php index 19080923e..695caa976 100644 --- a/src/Bundle/ChillPersonBundle/Controller/HouseholdApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/HouseholdApiController.php @@ -35,20 +35,8 @@ use function array_values; class HouseholdApiController extends ApiController { - private EventDispatcherInterface $eventDispatcher; - - private HouseholdACLAwareRepositoryInterface $householdACLAwareRepository; - - private HouseholdRepository $householdRepository; - - public function __construct( - EventDispatcherInterface $eventDispatcher, - HouseholdRepository $householdRepository, - HouseholdACLAwareRepositoryInterface $householdACLAwareRepository - ) { - $this->eventDispatcher = $eventDispatcher; - $this->householdRepository = $householdRepository; - $this->householdACLAwareRepository = $householdACLAwareRepository; + public function __construct(private EventDispatcherInterface $eventDispatcher, private HouseholdRepository $householdRepository, private HouseholdACLAwareRepositoryInterface $householdACLAwareRepository) + { } /** diff --git a/src/Bundle/ChillPersonBundle/Controller/HouseholdCompositionController.php b/src/Bundle/ChillPersonBundle/Controller/HouseholdCompositionController.php index 61e030322..1abb6290f 100644 --- a/src/Bundle/ChillPersonBundle/Controller/HouseholdCompositionController.php +++ b/src/Bundle/ChillPersonBundle/Controller/HouseholdCompositionController.php @@ -36,53 +36,14 @@ use Symfony\Contracts\Translation\TranslatorInterface; class HouseholdCompositionController extends AbstractController { - private EngineInterface $engine; - - private EntityManagerInterface $entityManager; - - private FormFactoryInterface $formFactory; - - private HouseholdCompositionRepository $householdCompositionRepository; - - private HouseholdRepository $householdRepository; - - private PaginatorFactory $paginatorFactory; - - private Security $security; - - private TranslatorInterface $translator; - - private UrlGeneratorInterface $urlGenerator; - - public function __construct( - Security $security, - HouseholdCompositionRepository $householdCompositionRepository, - HouseholdRepository $householdRepository, - PaginatorFactory $paginatorFactory, - FormFactoryInterface $formFactory, - EntityManagerInterface $entityManager, - TranslatorInterface $translator, - EngineInterface $engine, - UrlGeneratorInterface $urlGenerator - ) { - $this->security = $security; - $this->householdCompositionRepository = $householdCompositionRepository; - $this->paginatorFactory = $paginatorFactory; - $this->formFactory = $formFactory; - $this->entityManager = $entityManager; - $this->translator = $translator; - $this->engine = $engine; - $this->urlGenerator = $urlGenerator; - $this->householdRepository = $householdRepository; + public function __construct(private Security $security, private HouseholdCompositionRepository $householdCompositionRepository, private HouseholdRepository $householdRepository, private PaginatorFactory $paginatorFactory, private FormFactoryInterface $formFactory, private EntityManagerInterface $entityManager, private TranslatorInterface $translator, private EngineInterface $engine, private UrlGeneratorInterface $urlGenerator) + { } /** * @Route("/{_locale}/person/household/{household_id}/composition/{composition_id}/delete", name="chill_person_household_composition_delete") - * - * @param mixed $household_id - * @param mixed $composition_id */ - public function deleteAction(Request $request, $household_id, $composition_id): Response + public function deleteAction(Request $request, mixed $household_id, mixed $composition_id): Response { $composition = $this->householdCompositionRepository->find($composition_id); $household = $this->householdRepository->find($household_id); diff --git a/src/Bundle/ChillPersonBundle/Controller/HouseholdCompositionTypeApiController.php b/src/Bundle/ChillPersonBundle/Controller/HouseholdCompositionTypeApiController.php index dc332acdd..4e07e4004 100644 --- a/src/Bundle/ChillPersonBundle/Controller/HouseholdCompositionTypeApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/HouseholdCompositionTypeApiController.php @@ -23,14 +23,9 @@ class HouseholdCompositionTypeApiController extends ApiController */ protected function customizeQuery(string $action, Request $request, $query): void { - switch ($action) { - case '_index': - $query->andWhere($query->expr()->eq('e.active', "'TRUE'")); - - break; - - default: - throw new UnexpectedValueException('unexepcted action: ' . $action); - } + match ($action) { + '_index' => $query->andWhere($query->expr()->eq('e.active', "'TRUE'")), + default => throw new UnexpectedValueException('unexepcted action: ' . $action), + }; } } diff --git a/src/Bundle/ChillPersonBundle/Controller/HouseholdController.php b/src/Bundle/ChillPersonBundle/Controller/HouseholdController.php index 42092249b..9c4ae1441 100644 --- a/src/Bundle/ChillPersonBundle/Controller/HouseholdController.php +++ b/src/Bundle/ChillPersonBundle/Controller/HouseholdController.php @@ -37,24 +37,8 @@ use function count; */ class HouseholdController extends AbstractController { - private PositionRepository $positionRepository; - - private Security $security; - - private SerializerInterface $serializer; - - private TranslatorInterface $translator; - - public function __construct( - TranslatorInterface $translator, - PositionRepository $positionRepository, - SerializerInterface $serializer, - Security $security - ) { - $this->translator = $translator; - $this->positionRepository = $positionRepository; - $this->serializer = $serializer; - $this->security = $security; + public function __construct(private TranslatorInterface $translator, private PositionRepository $positionRepository, private SerializerInterface $serializer, private Security $security) + { } /** diff --git a/src/Bundle/ChillPersonBundle/Controller/HouseholdMemberController.php b/src/Bundle/ChillPersonBundle/Controller/HouseholdMemberController.php index d286cb270..24cda5fc1 100644 --- a/src/Bundle/ChillPersonBundle/Controller/HouseholdMemberController.php +++ b/src/Bundle/ChillPersonBundle/Controller/HouseholdMemberController.php @@ -32,20 +32,8 @@ use function count; class HouseholdMemberController extends ApiController { - private UrlGeneratorInterface $generator; - - private AccompanyingPeriodRepository $periodRepository; - - private TranslatorInterface $translator; - - public function __construct( - UrlGeneratorInterface $generator, - TranslatorInterface $translator, - AccompanyingPeriodRepository $periodRepository - ) { - $this->generator = $generator; - $this->translator = $translator; - $this->periodRepository = $periodRepository; + public function __construct(private UrlGeneratorInterface $generator, private TranslatorInterface $translator, private AccompanyingPeriodRepository $periodRepository) + { } /** @@ -175,10 +163,8 @@ class HouseholdMemberController extends ApiController * "/api/1.0/person/household/members/move.{_format}", * name="chill_api_person_household_members_move" * ) - * - * @param mixed $_format */ - public function move(Request $request, $_format): Response + public function move(Request $request, mixed $_format): Response { try { /** @var MembersEditor $editor */ diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonAddressController.php b/src/Bundle/ChillPersonBundle/Controller/PersonAddressController.php index 59ef949cf..133daf3be 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonAddressController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonAddressController.php @@ -287,8 +287,6 @@ class PersonAddressController extends AbstractController } /** - * @param Chill\PersonBundle\Entity\Person $person - * * @return \Symfony\Component\Validator\ConstraintViolationListInterface */ private function validatePerson(Person $person) diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php b/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php index 505f307e6..a3513fc1a 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php @@ -27,19 +27,13 @@ use function in_array; class PersonApiController extends ApiController { - private AuthorizedCenterOnPersonCreationInterface $authorizedCenterOnPersonCreation; - - private ConfigPersonAltNamesHelper $configPersonAltNameHelper; - private bool $showCenters; public function __construct( - AuthorizedCenterOnPersonCreationInterface $authorizedCenterOnPersonCreation, - ConfigPersonAltNamesHelper $configPersonAltNameHelper, + private AuthorizedCenterOnPersonCreationInterface $authorizedCenterOnPersonCreation, + private ConfigPersonAltNamesHelper $configPersonAltNameHelper, ParameterBagInterface $parameterBag ) { - $this->authorizedCenterOnPersonCreation = $authorizedCenterOnPersonCreation; - $this->configPersonAltNameHelper = $configPersonAltNameHelper; $this->showCenters = $parameterBag->get('chill_main')['acl']['form_show_centers']; } diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonController.php b/src/Bundle/ChillPersonBundle/Controller/PersonController.php index 2d4732289..016577130 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonController.php @@ -47,68 +47,20 @@ use function is_array; final class PersonController extends AbstractController { - private AuthorizationHelperInterface $authorizationHelper; - - /** - * @var ConfigPersonAltNamesHelper - */ - protected $configPersonAltNameHelper; - - /** - * @var EventDispatcherInterface - */ - protected $eventDispatcher; - - /** - * @var PersonRepository; - */ - protected $personRepository; - - /** - * @var SimilarPersonMatcher - */ - protected $similarPersonMatcher; - - /** - * @var TranslatorInterface - */ - protected $translator; - - /** - * @var EntityManagerInterface - */ - private $em; - - /** - * @var \Psr\Log\LoggerInterface - */ - private $logger; - - /** - * @var ValidatorInterface - */ - private $validator; - public function __construct( - AuthorizationHelperInterface $authorizationHelper, - SimilarPersonMatcher $similarPersonMatcher, - TranslatorInterface $translator, - EventDispatcherInterface $eventDispatcher, - PersonRepository $personRepository, - ConfigPersonAltNamesHelper $configPersonAltNameHelper, - LoggerInterface $logger, - ValidatorInterface $validator, - EntityManagerInterface $em, + private AuthorizationHelperInterface $authorizationHelper, + protected SimilarPersonMatcher $similarPersonMatcher, + protected TranslatorInterface $translator, + protected EventDispatcherInterface $eventDispatcher, + /** + * @var PersonRepository; + */ + protected PersonRepository $personRepository, + protected ConfigPersonAltNamesHelper $configPersonAltNameHelper, + private LoggerInterface $logger, + private ValidatorInterface $validator, + private EntityManagerInterface $em ) { - $this->authorizationHelper = $authorizationHelper; - $this->similarPersonMatcher = $similarPersonMatcher; - $this->translator = $translator; - $this->eventDispatcher = $eventDispatcher; - $this->configPersonAltNameHelper = $configPersonAltNameHelper; - $this->personRepository = $personRepository; - $this->logger = $logger; - $this->validator = $validator; - $this->em = $em; } public function editAction($person_id, Request $request) @@ -335,11 +287,10 @@ final class PersonController extends AbstractController /** * easy getting a person by his id. * - * @param mixed $id * * @return \Chill\PersonBundle\Entity\Person */ - private function _getPerson($id) + private function _getPerson(mixed $id) { return $this->personRepository->find($id); } diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php b/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php index 928112d2e..d699937f4 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php @@ -34,43 +34,8 @@ use function count; class PersonDuplicateController extends Controller { - /** - * @var \Symfony\Component\EventDispatcher\EventDispatcherInterface - */ - private $eventDispatcher; - - /** - * @var \Chill\PersonBundle\Actions\Remove\PersonMove - */ - private $personMove; - - /** - * @var \Chill\PersonBundle\Repository\PersonRepository - */ - private $personRepository; - - /** - * @var \Chill\PersonBundle\Search\SimilarPersonMatcher - */ - private $similarPersonMatcher; - - /** - * @var \Symfony\Component\Translation\TranslatorInterface - */ - private $translator; - - public function __construct( - SimilarPersonMatcher $similarPersonMatcher, - TranslatorInterface $translator, - PersonRepository $personRepository, - PersonMove $personMove, - EventDispatcherInterface $eventDispatcher - ) { - $this->similarPersonMatcher = $similarPersonMatcher; - $this->translator = $translator; - $this->personRepository = $personRepository; - $this->personMove = $personMove; - $this->eventDispatcher = $eventDispatcher; + public function __construct(private SimilarPersonMatcher $similarPersonMatcher, private TranslatorInterface $translator, private PersonRepository $personRepository, private PersonMove $personMove, private EventDispatcherInterface $eventDispatcher) + { } public function confirmAction($person1_id, $person2_id, Request $request) @@ -279,10 +244,8 @@ class PersonDuplicateController extends Controller /** * easy getting a person by his id. - * - * @param mixed $id */ - private function _getPerson($id): ?Person + private function _getPerson(mixed $id): ?Person { return $this->personRepository->find($id); } diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonResourceController.php b/src/Bundle/ChillPersonBundle/Controller/PersonResourceController.php index 6ba9ca558..a1b852ba0 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonResourceController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonResourceController.php @@ -25,24 +25,8 @@ use Symfony\Contracts\Translation\TranslatorInterface; final class PersonResourceController extends AbstractController { - private EntityManagerInterface $em; - - private PersonRepository $personRepository; - - private PersonResourceRepository $personResourceRepository; - - private TranslatorInterface $translator; - - public function __construct( - PersonResourceRepository $personResourceRepository, - PersonRepository $personRepository, - EntityManagerInterface $em, - TranslatorInterface $translator - ) { - $this->personResourceRepository = $personResourceRepository; - $this->personRepository = $personRepository; - $this->em = $em; - $this->translator = $translator; + public function __construct(private PersonResourceRepository $personResourceRepository, private PersonRepository $personRepository, private EntityManagerInterface $em, private TranslatorInterface $translator) + { } public function deleteAction(Request $request, $person_id, $resource_id): Response diff --git a/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php b/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php index bafc4b1cb..2a90c57a8 100644 --- a/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php +++ b/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php @@ -40,44 +40,8 @@ use function is_int; class ReassignAccompanyingPeriodController extends AbstractController { - private AccompanyingPeriodACLAwareRepositoryInterface $accompanyingPeriodACLAwareRepository; - - private AccompanyingPeriodRepository $courseRepository; - - private EntityManagerInterface $em; - - private EngineInterface $engine; - - private FormFactoryInterface $formFactory; - - private PaginatorFactory $paginatorFactory; - - private Security $security; - - private UserRender $userRender; - - private UserRepository $userRepository; - - public function __construct( - AccompanyingPeriodACLAwareRepositoryInterface $accompanyingPeriodACLAwareRepository, - UserRepository $userRepository, - AccompanyingPeriodRepository $courseRepository, - EngineInterface $engine, - FormFactoryInterface $formFactory, - PaginatorFactory $paginatorFactory, - Security $security, - UserRender $userRender, - EntityManagerInterface $em - ) { - $this->accompanyingPeriodACLAwareRepository = $accompanyingPeriodACLAwareRepository; - $this->engine = $engine; - $this->formFactory = $formFactory; - $this->paginatorFactory = $paginatorFactory; - $this->security = $security; - $this->userRepository = $userRepository; - $this->userRender = $userRender; - $this->courseRepository = $courseRepository; - $this->em = $em; + public function __construct(private AccompanyingPeriodACLAwareRepositoryInterface $accompanyingPeriodACLAwareRepository, private UserRepository $userRepository, private AccompanyingPeriodRepository $courseRepository, private EngineInterface $engine, private FormFactoryInterface $formFactory, private PaginatorFactory $paginatorFactory, private Security $security, private UserRender $userRender, private EntityManagerInterface $em) + { } /** diff --git a/src/Bundle/ChillPersonBundle/Controller/RelationshipApiController.php b/src/Bundle/ChillPersonBundle/Controller/RelationshipApiController.php index 572deb896..4d11e2620 100644 --- a/src/Bundle/ChillPersonBundle/Controller/RelationshipApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/RelationshipApiController.php @@ -21,14 +21,8 @@ use Symfony\Component\Validator\Validator\ValidatorInterface; class RelationshipApiController extends ApiController { - private RelationshipRepository $repository; - - private ValidatorInterface $validator; - - public function __construct(ValidatorInterface $validator, RelationshipRepository $repository) + public function __construct(private ValidatorInterface $validator, private RelationshipRepository $repository) { - $this->validator = $validator; - $this->repository = $repository; } /** diff --git a/src/Bundle/ChillPersonBundle/Controller/ResidentialAddressController.php b/src/Bundle/ChillPersonBundle/Controller/ResidentialAddressController.php index e128b1486..7daf926fc 100644 --- a/src/Bundle/ChillPersonBundle/Controller/ResidentialAddressController.php +++ b/src/Bundle/ChillPersonBundle/Controller/ResidentialAddressController.php @@ -27,20 +27,8 @@ use Symfony\Contracts\Translation\TranslatorInterface; final class ResidentialAddressController extends AbstractController { - private UrlGeneratorInterface $generator; - - private ResidentialAddressRepository $residentialAddressRepository; - - private TranslatorInterface $translator; - - public function __construct( - UrlGeneratorInterface $generator, - TranslatorInterface $translator, - ResidentialAddressRepository $residentialAddressRepository - ) { - $this->generator = $generator; - $this->translator = $translator; - $this->residentialAddressRepository = $residentialAddressRepository; + public function __construct(private UrlGeneratorInterface $generator, private TranslatorInterface $translator, private ResidentialAddressRepository $residentialAddressRepository) + { } /** diff --git a/src/Bundle/ChillPersonBundle/Controller/SocialWorkEvaluationApiController.php b/src/Bundle/ChillPersonBundle/Controller/SocialWorkEvaluationApiController.php index bd12ec8c2..8bfc90c0b 100644 --- a/src/Bundle/ChillPersonBundle/Controller/SocialWorkEvaluationApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/SocialWorkEvaluationApiController.php @@ -22,11 +22,8 @@ use Symfony\Component\Routing\Annotation\Route; class SocialWorkEvaluationApiController extends AbstractController { - private PaginatorFactory $paginatorFactory; - - public function __construct(PaginatorFactory $paginatorFactory) + public function __construct(private PaginatorFactory $paginatorFactory) { - $this->paginatorFactory = $paginatorFactory; } /** diff --git a/src/Bundle/ChillPersonBundle/Controller/SocialWorkGoalApiController.php b/src/Bundle/ChillPersonBundle/Controller/SocialWorkGoalApiController.php index 716aa0b2e..45165eec4 100644 --- a/src/Bundle/ChillPersonBundle/Controller/SocialWorkGoalApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/SocialWorkGoalApiController.php @@ -21,14 +21,8 @@ use Symfony\Component\HttpFoundation\Response; class SocialWorkGoalApiController extends ApiController { - private GoalRepository $goalRepository; - - private PaginatorFactory $paginator; - - public function __construct(GoalRepository $goalRepository, PaginatorFactory $paginator) + public function __construct(private GoalRepository $goalRepository, private PaginatorFactory $paginator) { - $this->goalRepository = $goalRepository; - $this->paginator = $paginator; } public function listBySocialAction(Request $request, SocialAction $action): Response diff --git a/src/Bundle/ChillPersonBundle/Controller/SocialWorkResultApiController.php b/src/Bundle/ChillPersonBundle/Controller/SocialWorkResultApiController.php index eee01a351..397164707 100644 --- a/src/Bundle/ChillPersonBundle/Controller/SocialWorkResultApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/SocialWorkResultApiController.php @@ -21,11 +21,8 @@ use Symfony\Component\HttpFoundation\Response; class SocialWorkResultApiController extends ApiController { - private ResultRepository $resultRepository; - - public function __construct(ResultRepository $resultRepository) + public function __construct(private ResultRepository $resultRepository) { - $this->resultRepository = $resultRepository; } public function listByGoal(Request $request, Goal $goal): Response diff --git a/src/Bundle/ChillPersonBundle/Controller/SocialWorkSocialActionApiController.php b/src/Bundle/ChillPersonBundle/Controller/SocialWorkSocialActionApiController.php index 4fe877a72..09f34dce9 100644 --- a/src/Bundle/ChillPersonBundle/Controller/SocialWorkSocialActionApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/SocialWorkSocialActionApiController.php @@ -23,14 +23,8 @@ use function count; class SocialWorkSocialActionApiController extends ApiController { - private PaginatorFactory $paginator; - - private SocialIssueRepository $socialIssueRepository; - - public function __construct(SocialIssueRepository $socialIssueRepository, PaginatorFactory $paginator) + public function __construct(private SocialIssueRepository $socialIssueRepository, private PaginatorFactory $paginator) { - $this->socialIssueRepository = $socialIssueRepository; - $this->paginator = $paginator; } public function listBySocialIssueApi($id, Request $request) diff --git a/src/Bundle/ChillPersonBundle/Controller/TimelinePersonController.php b/src/Bundle/ChillPersonBundle/Controller/TimelinePersonController.php index 95446e59b..b736715e4 100644 --- a/src/Bundle/ChillPersonBundle/Controller/TimelinePersonController.php +++ b/src/Bundle/ChillPersonBundle/Controller/TimelinePersonController.php @@ -22,20 +22,8 @@ use Symfony\Component\HttpFoundation\Request; class TimelinePersonController extends AbstractController { - protected EventDispatcherInterface $eventDispatcher; - - protected PaginatorFactory $paginatorFactory; - - protected TimelineBuilder $timelineBuilder; - - public function __construct( - EventDispatcherInterface $eventDispatcher, - TimelineBuilder $timelineBuilder, - PaginatorFactory $paginatorFactory - ) { - $this->eventDispatcher = $eventDispatcher; - $this->timelineBuilder = $timelineBuilder; - $this->paginatorFactory = $paginatorFactory; + public function __construct(protected EventDispatcherInterface $eventDispatcher, protected TimelineBuilder $timelineBuilder, protected PaginatorFactory $paginatorFactory) + { } public function personAction(Request $request, $person_id) diff --git a/src/Bundle/ChillPersonBundle/Controller/UserAccompanyingPeriodController.php b/src/Bundle/ChillPersonBundle/Controller/UserAccompanyingPeriodController.php index 658fdb7be..4a8580d30 100644 --- a/src/Bundle/ChillPersonBundle/Controller/UserAccompanyingPeriodController.php +++ b/src/Bundle/ChillPersonBundle/Controller/UserAccompanyingPeriodController.php @@ -19,14 +19,8 @@ use Symfony\Component\Routing\Annotation\Route; class UserAccompanyingPeriodController extends AbstractController { - private AccompanyingPeriodRepository $accompanyingPeriodRepository; - - private PaginatorFactory $paginatorFactory; - - public function __construct(AccompanyingPeriodRepository $accompanyingPeriodRepository, PaginatorFactory $paginatorFactory) + public function __construct(private AccompanyingPeriodRepository $accompanyingPeriodRepository, private PaginatorFactory $paginatorFactory) { - $this->accompanyingPeriodRepository = $accompanyingPeriodRepository; - $this->paginatorFactory = $paginatorFactory; } /** diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadAccompanyingPeriodWork.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadAccompanyingPeriodWork.php index 94c907689..06e1aab71 100644 --- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadAccompanyingPeriodWork.php +++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadAccompanyingPeriodWork.php @@ -31,16 +31,8 @@ class LoadAccompanyingPeriodWork extends \Doctrine\Bundle\FixturesBundle\Fixture */ private array $cacheEvaluations = []; - private EvaluationRepository $evaluationRepository; - - private AccompanyingPeriodRepository $periodRepository; - - public function __construct( - AccompanyingPeriodRepository $periodRepository, - EvaluationRepository $evaluationRepository - ) { - $this->periodRepository = $periodRepository; - $this->evaluationRepository = $evaluationRepository; + public function __construct(private AccompanyingPeriodRepository $periodRepository, private EvaluationRepository $evaluationRepository) + { } public function getDependencies() diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadCustomFields.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadCustomFields.php index 78180adff..e229fb877 100644 --- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadCustomFields.php +++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadCustomFields.php @@ -46,25 +46,11 @@ class LoadCustomFields extends AbstractFixture implements */ private $customFieldText; - /** - * @var TranslatableStringHelper - */ - private $translatableStringHelper; - - /** - * @var TranslatorInterface - */ - private $translator; - /** * LoadCustomFields constructor. */ - public function __construct( - TranslatableStringHelper $translatableStringHelper, - TranslatorInterface $translator - ) { - $this->translatableStringHelper = $translatableStringHelper; - $this->translator = $translator; + public function __construct(private TranslatableStringHelper $translatableStringHelper, private TranslatorInterface $translator) + { } //put your code here diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadHousehold.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadHousehold.php index 342dfb020..b619de76d 100644 --- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadHousehold.php +++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadHousehold.php @@ -37,18 +37,12 @@ class LoadHousehold extends Fixture implements DependentFixtureInterface { private const NUMBER_OF_HOUSEHOLD = 10; - private MembersEditorFactory $editorFactory; - - private EntityManagerInterface $em; - private NativeLoader $loader; private array $personIds; - public function __construct(MembersEditorFactory $editorFactory, EntityManagerInterface $em) + public function __construct(private MembersEditorFactory $editorFactory, private EntityManagerInterface $em) { - $this->editorFactory = $editorFactory; - $this->em = $em; $this->loader = new NativeLoader(); } diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadPeople.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadPeople.php index 4f43879fd..c658a6510 100644 --- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadPeople.php +++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadPeople.php @@ -86,24 +86,10 @@ class LoadPeople extends AbstractFixture implements ContainerAwareInterface, Ord */ protected array $cacheUsers = []; - protected CenterRepository $centerRepository; - - protected CountryRepository $countryRepository; - protected Generator $faker; protected NativeLoader $loader; - protected MaritalStatusRepository $maritalStatusRepository; - - protected ScopeRepository $scopeRepository; - - protected SocialIssueRepository $socialIssueRepository; - - protected UserRepository $userRepository; - - protected Registry $workflowRegistry; - private $genders = [Person::MALE_GENDER, Person::FEMALE_GENDER, Person::BOTH_GENDER]; private $peoples = [ @@ -243,24 +229,17 @@ class LoadPeople extends AbstractFixture implements ContainerAwareInterface, Ord ]; public function __construct( - Registry $workflowRegistry, - SocialIssueRepository $socialIssueRepository, - CenterRepository $centerRepository, - CountryRepository $countryRepository, - MaritalStatusRepository $maritalStatusRepository, - ScopeRepository $scopeRepository, - UserRepository $userRepository + protected Registry $workflowRegistry, + protected SocialIssueRepository $socialIssueRepository, + protected CenterRepository $centerRepository, + protected CountryRepository $countryRepository, + protected MaritalStatusRepository $maritalStatusRepository, + protected ScopeRepository $scopeRepository, + protected UserRepository $userRepository ) { $this->faker = Factory::create('fr_FR'); $this->faker->addProvider($this); - $this->workflowRegistry = $workflowRegistry; - $this->socialIssueRepository = $socialIssueRepository; - $this->centerRepository = $centerRepository; - $this->countryRepository = $countryRepository; - $this->maritalStatusRepository = $maritalStatusRepository; $this->loader = new NativeLoader($this->faker); - $this->scopeRepository = $scopeRepository; - $this->userRepository = $userRepository; } public function getOrder() diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelationships.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelationships.php index 6b5cf0696..65d79b243 100644 --- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelationships.php +++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelationships.php @@ -28,11 +28,8 @@ class LoadRelationships extends Fixture implements DependentFixtureInterface { use PersonRandomHelper; - private EntityManagerInterface $em; - - public function __construct(EntityManagerInterface $em) + public function __construct(private EntityManagerInterface $em) { - $this->em = $em; } public function getDependencies(): array diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadSocialWorkMetadata.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadSocialWorkMetadata.php index 12c85c59d..9605ce6f6 100644 --- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadSocialWorkMetadata.php +++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadSocialWorkMetadata.php @@ -21,11 +21,8 @@ use Throwable; class LoadSocialWorkMetadata extends Fixture implements OrderedFixtureInterface { - private SocialWorkMetadata $importer; - - public function __construct(SocialWorkMetadata $importer) + public function __construct(private SocialWorkMetadata $importer) { - $this->importer = $importer; } public function getOrder() diff --git a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php index 6a2dc924e..daa71754f 100644 --- a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php +++ b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php @@ -1081,17 +1081,10 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac $container->setParameter('chill_person.person_fields', $config); foreach ($config as $key => $value) { - switch ($key) { - case 'accompanying_period': - $container->setParameter('chill_person.accompanying_period', $value); - - break; - - default: - $container->setParameter('chill_person.person_fields.' . $key, $value); - - break; - } + match ($key) { + 'accompanying_period' => $container->setParameter('chill_person.accompanying_period', $value), + default => $container->setParameter('chill_person.person_fields.' . $key, $value), + }; } } } diff --git a/src/Bundle/ChillPersonBundle/DependencyInjection/Configuration.php b/src/Bundle/ChillPersonBundle/DependencyInjection/Configuration.php index a591663ad..f84fd49e1 100644 --- a/src/Bundle/ChillPersonBundle/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillPersonBundle/DependencyInjection/Configuration.php @@ -49,7 +49,7 @@ class Configuration implements ConfigurationInterface ->ifTrue(static function ($period) { try { $interval = new DateInterval($period); - } catch (Exception $ex) { + } catch (Exception) { return true; } @@ -139,17 +139,10 @@ class Configuration implements ConfigurationInterface $tree = new TreeBuilder($key, 'enum'); $node = $tree->getRootNode(); - switch ($key) { - case 'accompanying_period': - $info = 'If the accompanying periods are shown'; - - break; - - default: - $info = "If the field {$key} must be shown"; - - break; - } + $info = match ($key) { + 'accompanying_period' => 'If the accompanying periods are shown', + default => "If the field {$key} must be shown", + }; $node ->values(['hidden', 'visible']) diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php index a0f6e7d7e..15970471a 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php @@ -571,7 +571,7 @@ class AccompanyingPeriod implements * * @param mixed $person */ - public function closeParticipationFor($person): ?AccompanyingPeriodParticipation + public function closeParticipationFor(mixed $person): ?AccompanyingPeriodParticipation { $participation = $this->getOpenParticipationContainsPerson($person); @@ -950,10 +950,9 @@ class AccompanyingPeriod implements } /** - * @return Person|ThirdParty * @Groups({"read"}) */ - public function getRequestor() + public function getRequestor(): \Chill\PersonBundle\Entity\Person|\Chill\ThirdPartyBundle\Entity\ThirdParty { return $this->requestorPerson ?? $this->requestorThirdParty; } @@ -1215,7 +1214,7 @@ class AccompanyingPeriod implements * * @return AccompanyingPeriod */ - public function setClosingDate($closingDate) + public function setClosingDate(mixed $closingDate) { $this->closingDate = $closingDate; @@ -1274,11 +1273,10 @@ class AccompanyingPeriod implements /** * Set openingDate. * - * @param mixed $openingDate * * @return AccompanyingPeriod */ - public function setOpeningDate($openingDate) + public function setOpeningDate(mixed $openingDate) { if ($this->openingDate !== $openingDate) { $this->openingDate = $openingDate; diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php index 8780f7d17..26df8f9ea 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php @@ -365,11 +365,9 @@ class AccompanyingPeriodWorkEvaluation implements TrackCreationInterface, TrackU /** * Arbitrary data, used for client. * - * @param mixed $key * - * @return AccompanyingPeriodWorkEvaluation */ - public function setKey($key): self + public function setKey(mixed $key): self { $this->key = $key; diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationDocument.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationDocument.php index 1b2bbea44..b3ad86ed6 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationDocument.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationDocument.php @@ -147,11 +147,9 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct } /** - * @param mixed $key - * * @return AccompanyingPeriodWorkEvaluationDocument */ - public function setKey($key) + public function setKey(mixed $key) { $this->key = $key; diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Resource.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Resource.php index aa8a16229..48479782a 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Resource.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Resource.php @@ -94,10 +94,9 @@ class Resource } /** - * @return Person|ThirdParty * @Groups({"read"}) */ - public function getResource() + public function getResource(): \Chill\PersonBundle\Entity\Person|\Chill\ThirdPartyBundle\Entity\ThirdParty { return $this->person ?? $this->thirdParty; } diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/UserHistory.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/UserHistory.php index 2e073e50e..e2325aaa0 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/UserHistory.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/UserHistory.php @@ -26,12 +26,6 @@ class UserHistory implements TrackCreationInterface { use TrackCreationTrait; - /** - * @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class, inversedBy="userHistories") - * @ORM\JoinColumn(nullable=false) - */ - private ?AccompanyingPeriod $accompanyingPeriod; - /** * @ORM\Column(type="datetime_immutable", nullable=true, options={"default": null}) */ @@ -49,17 +43,18 @@ class UserHistory implements TrackCreationInterface */ private DateTimeImmutable $startDate; - /** + public function __construct(/** + * @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class, inversedBy="userHistories") + * @ORM\JoinColumn(nullable=false) + */ + private ?\Chill\PersonBundle\Entity\AccompanyingPeriod $accompanyingPeriod, /** * @ORM\ManyToOne(targetEntity=User::class) * @ORM\JoinColumn(nullable=false) */ - private User $user; - - public function __construct(AccompanyingPeriod $accompanyingPeriod, User $user, ?DateTimeImmutable $startDate = null) - { + private User $user, + ?DateTimeImmutable $startDate = null + ) { $this->startDate = $startDate ?? new DateTimeImmutable('now'); - $this->accompanyingPeriod = $accompanyingPeriod; - $this->user = $user; } public function getAccompanyingPeriod(): AccompanyingPeriod diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriodParticipation.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriodParticipation.php index 9e5174217..2f3b0798e 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriodParticipation.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriodParticipation.php @@ -28,12 +28,6 @@ use Symfony\Component\Serializer\Annotation\Groups; */ class AccompanyingPeriodParticipation { - /** - * @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class, inversedBy="participations", cascade={"persist"}) - * @ORM\JoinColumn(name="accompanyingperiod_id", referencedColumnName="id", nullable=false) - */ - private ?AccompanyingPeriod $accompanyingPeriod = null; - /** * @ORM\Column(type="date", nullable=true) * @Groups({"read", "docgen:read"}) @@ -48,24 +42,24 @@ class AccompanyingPeriodParticipation */ private ?int $id = null; - /** - * @ORM\ManyToOne(targetEntity=Person::class, inversedBy="accompanyingPeriodParticipations") - * @ORM\JoinColumn(name="person_id", referencedColumnName="id", nullable=false) - * @Groups({"read", "docgen:read"}) - */ - private ?Person $person = null; - /** * @ORM\Column(type="date", nullable=false) * @Groups({"read", "docgen:read"}) */ private ?DateTime $startDate = null; - public function __construct(AccompanyingPeriod $accompanyingPeriod, Person $person) - { + public function __construct(/** + * @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class, inversedBy="participations", cascade={"persist"}) + * @ORM\JoinColumn(name="accompanyingperiod_id", referencedColumnName="id", nullable=false) + */ + private ?\Chill\PersonBundle\Entity\AccompanyingPeriod $accompanyingPeriod, /** + * @ORM\ManyToOne(targetEntity=Person::class, inversedBy="accompanyingPeriodParticipations") + * @ORM\JoinColumn(name="person_id", referencedColumnName="id", nullable=false) + * @Groups({"read", "docgen:read"}) + */ + private ?\Chill\PersonBundle\Entity\Person $person + ) { $this->startDate = new DateTime('now'); - $this->accompanyingPeriod = $accompanyingPeriod; - $this->person = $person; $person->getAccompanyingPeriodParticipations()->add($this); } diff --git a/src/Bundle/ChillPersonBundle/Entity/MaritalStatus.php b/src/Bundle/ChillPersonBundle/Entity/MaritalStatus.php index e23038715..cce546802 100644 --- a/src/Bundle/ChillPersonBundle/Entity/MaritalStatus.php +++ b/src/Bundle/ChillPersonBundle/Entity/MaritalStatus.php @@ -60,8 +60,6 @@ class MaritalStatus /** * Set id. - * - * @return MaritalStatus */ public function setId(string $id): self { @@ -74,8 +72,6 @@ class MaritalStatus * Set name. * * @param string array $name - * - * @return MaritalStatus */ public function setName(array $name): self { diff --git a/src/Bundle/ChillPersonBundle/Entity/Person.php b/src/Bundle/ChillPersonBundle/Entity/Person.php index af8e7f92b..ac8988c26 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person.php @@ -74,7 +74,7 @@ use function in_array; * groups={"household_memberships"} * ) */ -class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateInterface +class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateInterface, \Stringable { public const BOTH_GENDER = 'both'; @@ -554,7 +554,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI /** * @return string */ - public function __toString() + public function __toString(): string { return $this->getLabel(); } @@ -631,7 +631,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * @return true | array True if the accompanying periods are not collapsing, * an array with data for displaying the error */ - public function checkAccompanyingPeriodsAreNotCollapsing() + public function checkAccompanyingPeriodsAreNotCollapsing(): bool|array { $periods = $this->getAccompanyingPeriodsOrdered(); $periodsNbr = count($periods); @@ -1165,19 +1165,12 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI */ public function getGenderNumeric() { - switch ($this->getGender()) { - case self::FEMALE_GENDER: - return 1; - - case self::MALE_GENDER: - return 0; - - case self::BOTH_GENDER: - return 2; - - default: - return -1; - } + return match ($this->getGender()) { + self::FEMALE_GENDER => 1, + self::MALE_GENDER => 0, + self::BOTH_GENDER => 2, + default => -1, + }; } public function getHouseholdAddresses(): Collection @@ -1360,7 +1353,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI /** * @return PersonResource[]|Collection */ - public function getResources() + public function getResources(): array|\Doctrine\Common\Collections\Collection { return $this->resources; } @@ -1606,9 +1599,6 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI return $this; } - /** - * @return Person - */ public function setCFData(?array $cFData): self { $this->cFData = $cFData; @@ -1824,16 +1814,11 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI $histories = $this->centerHistory->matching($criteria); - switch ($histories->count()) { - case 0: - return null; - - case 1: - return $histories->first(); - - default: - throw new UnexpectedValueException('It should not contains more than one center at a time'); - } + return match ($histories->count()) { + 0 => null, + 1 => $histories->first(), + default => throw new UnexpectedValueException('It should not contains more than one center at a time'), + }; } /** diff --git a/src/Bundle/ChillPersonBundle/Entity/Person/PersonCenterHistory.php b/src/Bundle/ChillPersonBundle/Entity/Person/PersonCenterHistory.php index 034ab81ec..0ce396e10 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person/PersonCenterHistory.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person/PersonCenterHistory.php @@ -32,11 +32,6 @@ class PersonCenterHistory implements TrackCreationInterface, TrackUpdateInterfac use TrackUpdateTrait; - /** - * @ORM\ManyToOne(targetEntity=Center::class) - */ - private ?Center $center = null; - /** * @ORM\Column(type="date_immutable", nullable=true, options={"default": null}) */ @@ -49,21 +44,20 @@ class PersonCenterHistory implements TrackCreationInterface, TrackUpdateInterfac */ private ?int $id = null; - /** - * @ORM\ManyToOne(targetEntity=Person::class, inversedBy="centerHistory") - */ - private ?Person $person = null; - - /** - * @ORM\Column(type="date_immutable", nullable=false) - */ - private ?DateTimeImmutable $startDate = null; - - public function __construct(?Person $person = null, ?Center $center = null, ?DateTimeImmutable $startDate = null) - { - $this->person = $person; - $this->center = $center; - $this->startDate = $startDate; + public function __construct( + /** + * @ORM\ManyToOne(targetEntity=Person::class, inversedBy="centerHistory") + */ + private ?\Chill\PersonBundle\Entity\Person $person = null, + /** + * @ORM\ManyToOne(targetEntity=Center::class) + */ + private ?\Chill\MainBundle\Entity\Center $center = null, + /** + * @ORM\Column(type="date_immutable", nullable=false) + */ + private ?\DateTimeImmutable $startDate = null + ) { } public function getCenter(): ?Center diff --git a/src/Bundle/ChillPersonBundle/Entity/Person/PersonResource.php b/src/Bundle/ChillPersonBundle/Entity/Person/PersonResource.php index a4b6cf085..87e7620c9 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person/PersonResource.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person/PersonResource.php @@ -221,10 +221,8 @@ class PersonResource implements TrackCreationInterface, TrackUpdateInterface /** * @Assert\Callback - * - * @param mixed $payload */ - public function validate(ExecutionContextInterface $context, $payload) + public function validate(ExecutionContextInterface $context, mixed $payload) { if (null === $this->person && null === $this->thirdParty && (null === $this->freeText || '' === $this->freeText)) { $context->buildViolation('You must associate at least one entity') diff --git a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php index a8c68c8ce..0c7120caf 100644 --- a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php +++ b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php @@ -151,7 +151,7 @@ class SocialAction * * @return Collection|SocialAction[] a list with the elements of the given list which are parent of other elements in the given list */ - public static function findAncestorSocialActions(Collection $socialActions): Collection + public static function findAncestorSocialActions(\Doctrine\Common\Collections\Collection|array $socialActions): Collection { $ancestors = new ArrayCollection(); @@ -231,7 +231,7 @@ class SocialAction /** * @param Collection|SocialAction[] $socialActions */ - public static function getDescendantsWithThisForActions($socialActions): Collection + public static function getDescendantsWithThisForActions(\Doctrine\Common\Collections\Collection|array $socialActions): Collection { $unique = []; diff --git a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php index 675a1a923..a36fa48d7 100644 --- a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php +++ b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php @@ -74,7 +74,6 @@ class SocialIssue /** * @internal use @see{SocialIssue::setParent} instead * - * @param SocialIssue $child * * @return $this */ @@ -109,7 +108,7 @@ class SocialIssue * * @return Collection|SocialIssue[] */ - public static function findAncestorSocialIssues(Collection $socialIssues): Collection + public static function findAncestorSocialIssues(\Doctrine\Common\Collections\Collection|array $socialIssues): Collection { $ancestors = new ArrayCollection(); diff --git a/src/Bundle/ChillPersonBundle/Event/Person/PersonAddressMoveEvent.php b/src/Bundle/ChillPersonBundle/Event/Person/PersonAddressMoveEvent.php index f4a8f6520..1242e61ef 100644 --- a/src/Bundle/ChillPersonBundle/Event/Person/PersonAddressMoveEvent.php +++ b/src/Bundle/ChillPersonBundle/Event/Person/PersonAddressMoveEvent.php @@ -27,16 +27,12 @@ class PersonAddressMoveEvent extends Event private ?HouseholdMember $nextMembership = null; - private Person $person; - private ?Address $previousAddress = null; private ?HouseholdMember $previousMembership = null; - public function __construct( - Person $person - ) { - $this->person = $person; + public function __construct(private Person $person) + { } /** diff --git a/src/Bundle/ChillPersonBundle/EventListener/AccompanyingPeriodWorkEventListener.php b/src/Bundle/ChillPersonBundle/EventListener/AccompanyingPeriodWorkEventListener.php index 2e3a3aaef..2776faf43 100644 --- a/src/Bundle/ChillPersonBundle/EventListener/AccompanyingPeriodWorkEventListener.php +++ b/src/Bundle/ChillPersonBundle/EventListener/AccompanyingPeriodWorkEventListener.php @@ -17,11 +17,8 @@ use Symfony\Component\Security\Core\Security; class AccompanyingPeriodWorkEventListener { - private Security $security; - - public function __construct(Security $security) + public function __construct(private Security $security) { - $this->security = $security; } public function prePersistAccompanyingPeriodWork(AccompanyingPeriodWork $work): void diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/AdministrativeLocationAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/AdministrativeLocationAggregator.php index 96deac574..d01190ba4 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/AdministrativeLocationAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/AdministrativeLocationAggregator.php @@ -21,16 +21,8 @@ use function in_array; class AdministrativeLocationAggregator implements AggregatorInterface { - private LocationRepository $locationRepository; - - private TranslatableStringHelper $translatableStringHelper; - - public function __construct( - LocationRepository $locationRepository, - TranslatableStringHelper $translatableStringHelper - ) { - $this->locationRepository = $locationRepository; - $this->translatableStringHelper = $translatableStringHelper; + public function __construct(private LocationRepository $locationRepository, private TranslatableStringHelper $translatableStringHelper) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregator.php index 342958361..b2703836e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregator.php @@ -20,16 +20,8 @@ use Symfony\Component\Form\FormBuilderInterface; class ClosingMotiveAggregator implements AggregatorInterface { - private ClosingMotiveRepositoryInterface $motiveRepository; - - private TranslatableStringHelper $translatableStringHelper; - - public function __construct( - ClosingMotiveRepositoryInterface $motiveRepository, - TranslatableStringHelper $translatableStringHelper - ) { - $this->motiveRepository = $motiveRepository; - $this->translatableStringHelper = $translatableStringHelper; + public function __construct(private ClosingMotiveRepositoryInterface $motiveRepository, private TranslatableStringHelper $translatableStringHelper) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ConfidentialAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ConfidentialAggregator.php index e9b9e28fa..a4279fc05 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ConfidentialAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ConfidentialAggregator.php @@ -20,12 +20,8 @@ use Symfony\Contracts\Translation\TranslatorInterface; class ConfidentialAggregator implements AggregatorInterface { - private TranslatorInterface $translator; - - public function __construct( - TranslatorInterface $translator - ) { - $this->translator = $translator; + public function __construct(private TranslatorInterface $translator) + { } public function addRole(): ?string @@ -56,16 +52,11 @@ class ConfidentialAggregator implements AggregatorInterface return 'Confidentiality'; } - switch ($value) { - case true: - return $this->translator->trans('is confidential'); - - case false: - return $this->translator->trans('is not confidential'); - - default: - throw new LogicException(sprintf('The value %s is not valid', $value)); - } + return match ($value) { + true => $this->translator->trans('is confidential'), + false => $this->translator->trans('is not confidential'), + default => throw new LogicException(sprintf('The value %s is not valid', $value)), + }; }; } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/CreatorJobAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/CreatorJobAggregator.php index c336a8887..87e119419 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/CreatorJobAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/CreatorJobAggregator.php @@ -21,16 +21,8 @@ use function in_array; class CreatorJobAggregator implements AggregatorInterface { - private UserJobRepository $jobRepository; - - private TranslatableStringHelper $translatableStringHelper; - - public function __construct( - UserJobRepository $jobRepository, - TranslatableStringHelper $translatableStringHelper - ) { - $this->jobRepository = $jobRepository; - $this->translatableStringHelper = $translatableStringHelper; + public function __construct(private UserJobRepository $jobRepository, private TranslatableStringHelper $translatableStringHelper) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/DurationAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/DurationAggregator.php index 0dc66e81e..ce61739f0 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/DurationAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/DurationAggregator.php @@ -28,11 +28,8 @@ final class DurationAggregator implements AggregatorInterface 'day', ]; - private TranslatorInterface $translator; - - public function __construct(TranslatorInterface $translator) + public function __construct(private TranslatorInterface $translator) { - $this->translator = $translator; } public function addRole(): ?string @@ -42,26 +39,13 @@ final class DurationAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - switch ($data['precision']) { - case 'day': - $qb->addSelect('(COALESCE(acp.closingDate, :now) - acp.openingDate) AS duration_aggregator'); - - break; - - case 'week': - $qb->addSelect('(COALESCE(acp.closingDate, :now) - acp.openingDate) / 7 AS duration_aggregator'); - - break; - - case 'month': - $qb->addSelect('(EXTRACT (MONTH FROM AGE(COALESCE(acp.closingDate, :now), acp.openingDate)) * 12 + - EXTRACT (MONTH FROM AGE(COALESCE(acp.closingDate, :now), acp.openingDate))) AS duration_aggregator'); - - break; - - default: - throw new LogicException('precision not supported: ' . $data['precision']); - } + match ($data['precision']) { + 'day' => $qb->addSelect('(COALESCE(acp.closingDate, :now) - acp.openingDate) AS duration_aggregator'), + 'week' => $qb->addSelect('(COALESCE(acp.closingDate, :now) - acp.openingDate) / 7 AS duration_aggregator'), + 'month' => $qb->addSelect('(EXTRACT (MONTH FROM AGE(COALESCE(acp.closingDate, :now), acp.openingDate)) * 12 + + EXTRACT (MONTH FROM AGE(COALESCE(acp.closingDate, :now), acp.openingDate))) AS duration_aggregator'), + default => throw new LogicException('precision not supported: ' . $data['precision']), + }; $qb ->setParameter('now', new DateTimeImmutable('now')) diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EmergencyAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EmergencyAggregator.php index 02f9f5cd9..aeb369b5a 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EmergencyAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EmergencyAggregator.php @@ -20,12 +20,8 @@ use Symfony\Contracts\Translation\TranslatorInterface; class EmergencyAggregator implements AggregatorInterface { - private TranslatorInterface $translator; - - public function __construct( - TranslatorInterface $translator - ) { - $this->translator = $translator; + public function __construct(private TranslatorInterface $translator) + { } public function addRole(): ?string @@ -56,16 +52,11 @@ class EmergencyAggregator implements AggregatorInterface return 'Emergency'; } - switch ($value) { - case true: - return $this->translator->trans('is emergency'); - - case false: - return $this->translator->trans('is not emergency'); - - default: - throw new LogicException(sprintf('The value %s is not valid', $value)); - } + return match ($value) { + true => $this->translator->trans('is emergency'), + false => $this->translator->trans('is not emergency'), + default => throw new LogicException(sprintf('The value %s is not valid', $value)), + }; }; } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EvaluationAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EvaluationAggregator.php index b6436efc0..47656c1d0 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EvaluationAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EvaluationAggregator.php @@ -21,16 +21,8 @@ use function in_array; final class EvaluationAggregator implements AggregatorInterface { - private EvaluationRepository $evaluationRepository; - - private TranslatableStringHelper $translatableStringHelper; - - public function __construct( - EvaluationRepository $evaluationRepository, - TranslatableStringHelper $translatableStringHelper - ) { - $this->evaluationRepository = $evaluationRepository; - $this->translatableStringHelper = $translatableStringHelper; + public function __construct(private EvaluationRepository $evaluationRepository, private TranslatableStringHelper $translatableStringHelper) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php index 4ac96aac1..3395247de 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php @@ -29,20 +29,8 @@ use UnexpectedValueException; final class GeographicalUnitStatAggregator implements AggregatorInterface { - private GeographicalUnitLayerRepositoryInterface $geographicalUnitLayerRepository; - - private RollingDateConverterInterface $rollingDateConverter; - - private TranslatableStringHelperInterface $translatableStringHelper; - - public function __construct( - GeographicalUnitLayerRepositoryInterface $geographicalUnitLayerRepository, - TranslatableStringHelperInterface $translatableStringHelper, - RollingDateConverterInterface $rollingDateConverter - ) { - $this->geographicalUnitLayerRepository = $geographicalUnitLayerRepository; - $this->translatableStringHelper = $translatableStringHelper; - $this->rollingDateConverter = $rollingDateConverter; + public function __construct(private GeographicalUnitLayerRepositoryInterface $geographicalUnitLayerRepository, private TranslatableStringHelperInterface $translatableStringHelper, private RollingDateConverterInterface $rollingDateConverter) + { } public function addRole(): ?string @@ -134,36 +122,31 @@ final class GeographicalUnitStatAggregator implements AggregatorInterface public function getLabels($key, array $values, $data) { - switch ($key) { - case 'acp_geog_agg_unitname': - return static function ($value): string { - if ('_header' === $value) { - return 'acp_geog_agg_unitname'; - } + return match ($key) { + 'acp_geog_agg_unitname' => static function ($value): string { + if ('_header' === $value) { + return 'acp_geog_agg_unitname'; + } - if (null === $value || '' === $value) { - return ''; - } + if (null === $value || '' === $value) { + return ''; + } - return $value; - }; + return $value; + }, + 'acp_geog_agg_unitrefid' => static function ($value): string { + if ('_header' === $value) { + return 'acp_geog_agg_unitrefid'; + } - case 'acp_geog_agg_unitrefid': - return static function ($value): string { - if ('_header' === $value) { - return 'acp_geog_agg_unitrefid'; - } + if (null === $value) { + return ''; + } - if (null === $value) { - return ''; - } - - return $value; - }; - - default: - throw new UnexpectedValueException('this value should not happens'); - } + return $value; + }, + default => throw new UnexpectedValueException('this value should not happens'), + }; } public function getQueryKeys($data): array diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/IntensityAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/IntensityAggregator.php index a3618f40f..2d9adc801 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/IntensityAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/IntensityAggregator.php @@ -20,12 +20,8 @@ use Symfony\Contracts\Translation\TranslatorInterface; class IntensityAggregator implements AggregatorInterface { - private TranslatorInterface $translator; - - public function __construct( - TranslatorInterface $translator - ) { - $this->translator = $translator; + public function __construct(private TranslatorInterface $translator) + { } public function addRole(): ?string @@ -56,16 +52,11 @@ class IntensityAggregator implements AggregatorInterface return 'Intensity'; } - switch ($value) { - case 'occasional': - return $this->translator->trans('is occasional'); - - case 'regular': - return $this->translator->trans('is regular'); - - default: - throw new LogicException(sprintf('The value %s is not valid', $value)); - } + return match ($value) { + 'occasional' => $this->translator->trans('is occasional'), + 'regular' => $this->translator->trans('is regular'), + default => throw new LogicException(sprintf('The value %s is not valid', $value)), + }; }; } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/OriginAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/OriginAggregator.php index 37d0c7b20..e6cb9cac6 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/OriginAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/OriginAggregator.php @@ -25,14 +25,11 @@ final class OriginAggregator implements AggregatorInterface { private EntityRepository $repository; - private TranslatableStringHelper $translatableStringHelper; - public function __construct( EntityManagerInterface $em, - TranslatableStringHelper $translatableStringHelper + private TranslatableStringHelper $translatableStringHelper ) { $this->repository = $em->getRepository(Origin::class); - $this->translatableStringHelper = $translatableStringHelper; } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerAggregator.php index a09097fd2..db12bbb0c 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerAggregator.php @@ -27,20 +27,8 @@ final class ReferrerAggregator implements AggregatorInterface private const P = 'acp_ref_agg_date'; - private RollingDateConverterInterface $rollingDateConverter; - - private UserRender $userRender; - - private UserRepository $userRepository; - - public function __construct( - UserRepository $userRepository, - UserRender $userRender, - RollingDateConverterInterface $rollingDateConverter - ) { - $this->userRepository = $userRepository; - $this->userRender = $userRender; - $this->rollingDateConverter = $rollingDateConverter; + public function __construct(private UserRepository $userRepository, private UserRender $userRender, private RollingDateConverterInterface $rollingDateConverter) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerScopeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerScopeAggregator.php index ccbd21da1..6e788d714 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerScopeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerScopeAggregator.php @@ -26,20 +26,8 @@ class ReferrerScopeAggregator implements AggregatorInterface { private const SCOPE_KEY = 'acp_agg_refscope_user_history_ref_scope_name'; - private RollingDateConverterInterface $rollingDateConverter; - - private ScopeRepositoryInterface $scopeRepository; - - private TranslatableStringHelperInterface $translatableStringHelper; - - public function __construct( - ScopeRepositoryInterface $scopeRepository, - TranslatableStringHelperInterface $translatableStringHelper, - RollingDateConverterInterface $rollingDateConverter - ) { - $this->scopeRepository = $scopeRepository; - $this->translatableStringHelper = $translatableStringHelper; - $this->rollingDateConverter = $rollingDateConverter; + public function __construct(private ScopeRepositoryInterface $scopeRepository, private TranslatableStringHelperInterface $translatableStringHelper, private RollingDateConverterInterface $rollingDateConverter) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/RequestorAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/RequestorAggregator.php index 7b5cf0edd..5555671d3 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/RequestorAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/RequestorAggregator.php @@ -20,12 +20,8 @@ use function in_array; final class RequestorAggregator implements AggregatorInterface { - private TranslatorInterface $translator; - - public function __construct( - TranslatorInterface $translator - ) { - $this->translator = $translator; + public function __construct(private TranslatorInterface $translator) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ScopeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ScopeAggregator.php index 8f34661bb..d3f7783f3 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ScopeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ScopeAggregator.php @@ -21,16 +21,8 @@ use function in_array; final class ScopeAggregator implements AggregatorInterface { - private ScopeRepository $scopeRepository; - - private TranslatableStringHelper $translatableStringHelper; - - public function __construct( - ScopeRepository $scopeRepository, - TranslatableStringHelper $translatableStringHelper - ) { - $this->scopeRepository = $scopeRepository; - $this->translatableStringHelper = $translatableStringHelper; + public function __construct(private ScopeRepository $scopeRepository, private TranslatableStringHelper $translatableStringHelper) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialActionAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialActionAggregator.php index 3bdd6549e..e088be7ce 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialActionAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialActionAggregator.php @@ -21,16 +21,8 @@ use function in_array; final class SocialActionAggregator implements AggregatorInterface { - private SocialActionRender $actionRender; - - private SocialActionRepository $actionRepository; - - public function __construct( - SocialActionRender $actionRender, - SocialActionRepository $actionRepository - ) { - $this->actionRender = $actionRender; - $this->actionRepository = $actionRepository; + public function __construct(private SocialActionRender $actionRender, private SocialActionRepository $actionRepository) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialIssueAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialIssueAggregator.php index 12fa5a454..4ce7dfcd0 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialIssueAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialIssueAggregator.php @@ -21,16 +21,8 @@ use function in_array; final class SocialIssueAggregator implements AggregatorInterface { - private SocialIssueRender $issueRender; - - private SocialIssueRepository $issueRepository; - - public function __construct( - SocialIssueRepository $issueRepository, - SocialIssueRender $issueRender - ) { - $this->issueRepository = $issueRepository; - $this->issueRender = $issueRender; + public function __construct(private SocialIssueRepository $issueRepository, private SocialIssueRender $issueRender) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/StepAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/StepAggregator.php index 84dbd4e69..4fb7a38b8 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/StepAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/StepAggregator.php @@ -28,16 +28,8 @@ final class StepAggregator implements AggregatorInterface private const P = 'acp_step_agg_date'; - private RollingDateConverterInterface $rollingDateConverter; - - private TranslatorInterface $translator; - - public function __construct( - RollingDateConverterInterface $rollingDateConverter, - TranslatorInterface $translator - ) { - $this->rollingDateConverter = $rollingDateConverter; - $this->translator = $translator; + public function __construct(private RollingDateConverterInterface $rollingDateConverter, private TranslatorInterface $translator) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/UserJobAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/UserJobAggregator.php index a8acdcf12..97a8b228e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/UserJobAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/UserJobAggregator.php @@ -21,16 +21,8 @@ use function in_array; final class UserJobAggregator implements AggregatorInterface { - private UserJobRepository $jobRepository; - - private TranslatableStringHelper $translatableStringHelper; - - public function __construct( - UserJobRepository $jobRepository, - TranslatableStringHelper $translatableStringHelper - ) { - $this->jobRepository = $jobRepository; - $this->translatableStringHelper = $translatableStringHelper; + public function __construct(private UserJobRepository $jobRepository, private TranslatableStringHelper $translatableStringHelper) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByEndDateAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByEndDateAggregator.php index 2f4275c49..c8dd3b611 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByEndDateAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByEndDateAggregator.php @@ -38,25 +38,12 @@ class ByEndDateAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - switch ($data['frequency']) { - case 'week': - $fmt = 'YYYY-IW'; - - break; - - case 'month': - $fmt = 'YYYY-MM'; - - break; - - case 'year': - $fmt = 'YYYY'; - - break; - - default: - throw new LogicException(sprintf("The frequency data '%s' is invalid.", $data['frequency'])); - } + $fmt = match ($data['frequency']) { + 'week' => 'YYYY-IW', + 'month' => 'YYYY-MM', + 'year' => 'YYYY', + default => throw new LogicException(sprintf("The frequency data '%s' is invalid.", $data['frequency'])), + }; $qb->addSelect(sprintf("TO_CHAR(workeval.endDate, '%s') AS eval_by_end_date_aggregator", $fmt)); $qb->addGroupBy(' eval_by_end_date_aggregator'); diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByMaxDateAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByMaxDateAggregator.php index 9283fd9dc..07498f026 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByMaxDateAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByMaxDateAggregator.php @@ -38,25 +38,12 @@ class ByMaxDateAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - switch ($data['frequency']) { - case 'week': - $fmt = 'YYYY-IW'; - - break; - - case 'month': - $fmt = 'YYYY-MM'; - - break; - - case 'year': - $fmt = 'YYYY'; - - break; - - default: - throw new LogicException(sprintf("The frequency data '%s' is invalid.", $data['frequency'])); - } + $fmt = match ($data['frequency']) { + 'week' => 'YYYY-IW', + 'month' => 'YYYY-MM', + 'year' => 'YYYY', + default => throw new LogicException(sprintf("The frequency data '%s' is invalid.", $data['frequency'])), + }; $qb->addSelect(sprintf("TO_CHAR(workeval.maxDate, '%s') AS eval_by_max_date_aggregator", $fmt)); $qb->addGroupBy(' eval_by_max_date_aggregator'); diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByStartDateAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByStartDateAggregator.php index cd183b25e..d5317feb6 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByStartDateAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByStartDateAggregator.php @@ -38,25 +38,12 @@ class ByStartDateAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - switch ($data['frequency']) { - case 'week': - $fmt = 'YYYY-IW'; - - break; - - case 'month': - $fmt = 'YYYY-MM'; - - break; - - case 'year': - $fmt = 'YYYY'; - - break; - - default: - throw new LogicException(sprintf("The frequency data '%s' is invalid.", $data['frequency'])); - } + $fmt = match ($data['frequency']) { + 'week' => 'YYYY-IW', + 'month' => 'YYYY-MM', + 'year' => 'YYYY', + default => throw new LogicException(sprintf("The frequency data '%s' is invalid.", $data['frequency'])), + }; $qb->addSelect(sprintf("TO_CHAR(workeval.startDate, '%s') AS eval_by_start_date_aggregator", $fmt)); $qb->addGroupBy(' eval_by_start_date_aggregator'); diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/EvaluationTypeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/EvaluationTypeAggregator.php index 0c13611cb..2201cd747 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/EvaluationTypeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/EvaluationTypeAggregator.php @@ -20,16 +20,8 @@ use Symfony\Component\Form\FormBuilderInterface; class EvaluationTypeAggregator implements AggregatorInterface { - private EvaluationRepository $evaluationRepository; - - private TranslatableStringHelper $translatableStringHelper; - - public function __construct( - EvaluationRepository $evaluationRepository, - TranslatableStringHelper $translatableStringHelper - ) { - $this->evaluationRepository = $evaluationRepository; - $this->translatableStringHelper = $translatableStringHelper; + public function __construct(private EvaluationRepository $evaluationRepository, private TranslatableStringHelper $translatableStringHelper) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/HavingEndDateAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/HavingEndDateAggregator.php index e33bb326f..9bc91f099 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/HavingEndDateAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/HavingEndDateAggregator.php @@ -20,11 +20,8 @@ use Symfony\Contracts\Translation\TranslatorInterface; class HavingEndDateAggregator implements AggregatorInterface { - private TranslatorInterface $translator; - - public function __construct(TranslatorInterface $translator) + public function __construct(private TranslatorInterface $translator) { - $this->translator = $translator; } public function addRole(): ?string @@ -56,16 +53,11 @@ class HavingEndDateAggregator implements AggregatorInterface return 'export.aggregator.eval.by_end_date.Has end date ?'; } - switch ($value) { - case true: - return $this->translator->trans('export.aggregator.eval.by_end_date.enddate is specified'); - - case false: - return $this->translator->trans('export.aggregator.eval.by_end_date.enddate is not specified'); - - default: - throw new LogicException(sprintf('The value %s is not valid', $value)); - } + return match ($value) { + true => $this->translator->trans('export.aggregator.eval.by_end_date.enddate is specified'), + false => $this->translator->trans('export.aggregator.eval.by_end_date.enddate is not specified'), + default => throw new LogicException(sprintf('The value %s is not valid', $value)), + }; }; } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/ChildrenNumberAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/ChildrenNumberAggregator.php index 0c9bc623f..7b4b3c646 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/ChildrenNumberAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/ChildrenNumberAggregator.php @@ -24,16 +24,8 @@ use function in_array; class ChildrenNumberAggregator implements AggregatorInterface { - private RollingDateConverterInterface $rollingDateConverter; - - private TranslatorInterface $translator; - - public function __construct( - TranslatorInterface $translator, - RollingDateConverterInterface $rollingDateConverter - ) { - $this->translator = $translator; - $this->rollingDateConverter = $rollingDateConverter; + public function __construct(private TranslatorInterface $translator, private RollingDateConverterInterface $rollingDateConverter) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/CompositionAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/CompositionAggregator.php index 52bcd88e5..1d38dddd4 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/CompositionAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/CompositionAggregator.php @@ -25,20 +25,8 @@ use function in_array; class CompositionAggregator implements AggregatorInterface { - private RollingDateConverterInterface $rollingDateConverter; - - private TranslatableStringHelper $translatableStringHelper; - - private HouseholdCompositionTypeRepository $typeRepository; - - public function __construct( - HouseholdCompositionTypeRepository $typeRepository, - TranslatableStringHelper $translatableStringHelper, - RollingDateConverterInterface $rollingDateConverter - ) { - $this->typeRepository = $typeRepository; - $this->translatableStringHelper = $translatableStringHelper; - $this->rollingDateConverter = $rollingDateConverter; + public function __construct(private HouseholdCompositionTypeRepository $typeRepository, private TranslatableStringHelper $translatableStringHelper, private RollingDateConverterInterface $rollingDateConverter) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/AgeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/AgeAggregator.php index 365a73704..88cf2363a 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/AgeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/AgeAggregator.php @@ -22,11 +22,8 @@ use Symfony\Contracts\Translation\TranslatorInterface; final class AgeAggregator implements AggregatorInterface, ExportElementValidatedInterface { - private TranslatorInterface $translator; - - public function __construct(TranslatorInterface $translator) + public function __construct(private TranslatorInterface $translator) { - $this->translator = $translator; } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/ByHouseholdCompositionAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/ByHouseholdCompositionAggregator.php index 80f0faa17..ccb4710e0 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/ByHouseholdCompositionAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/ByHouseholdCompositionAggregator.php @@ -27,20 +27,8 @@ class ByHouseholdCompositionAggregator implements AggregatorInterface { private const PREFIX = 'acp_by_household_compo_agg'; - private HouseholdCompositionTypeRepositoryInterface $householdCompositionTypeRepository; - - private RollingDateConverterInterface $rollingDateConverter; - - private TranslatableStringHelperInterface $translatableStringHelper; - - public function __construct( - RollingDateConverterInterface $rollingDateConverter, - HouseholdCompositionTypeRepositoryInterface $householdCompositionTypeRepository, - TranslatableStringHelperInterface $translatableStringHelper - ) { - $this->householdCompositionTypeRepository = $householdCompositionTypeRepository; - $this->translatableStringHelper = $translatableStringHelper; - $this->rollingDateConverter = $rollingDateConverter; + public function __construct(private RollingDateConverterInterface $rollingDateConverter, private HouseholdCompositionTypeRepositoryInterface $householdCompositionTypeRepository, private TranslatableStringHelperInterface $translatableStringHelper) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/CountryOfBirthAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/CountryOfBirthAggregator.php index 3d785b586..25b01b3f7 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/CountryOfBirthAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/CountryOfBirthAggregator.php @@ -27,20 +27,8 @@ use function in_array; final class CountryOfBirthAggregator implements AggregatorInterface, ExportElementValidatedInterface { - private CountryRepository $countriesRepository; - - private TranslatableStringHelper $translatableStringHelper; - - private TranslatorInterface $translator; - - public function __construct( - CountryRepository $countriesRepository, - TranslatableStringHelper $translatableStringHelper, - TranslatorInterface $translator - ) { - $this->countriesRepository = $countriesRepository; - $this->translatableStringHelper = $translatableStringHelper; - $this->translator = $translator; + public function __construct(private CountryRepository $countriesRepository, private TranslatableStringHelper $translatableStringHelper, private TranslatorInterface $translator) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GenderAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GenderAggregator.php index f76420047..60ab87fed 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GenderAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GenderAggregator.php @@ -21,11 +21,8 @@ use Symfony\Contracts\Translation\TranslatorInterface; final class GenderAggregator implements AggregatorInterface { - private TranslatorInterface $translator; - - public function __construct(TranslatorInterface $translator) + public function __construct(private TranslatorInterface $translator) { - $this->translator = $translator; } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GeographicalUnitAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GeographicalUnitAggregator.php index ff72994ba..e86524670 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GeographicalUnitAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GeographicalUnitAggregator.php @@ -26,20 +26,8 @@ use Symfony\Component\Form\FormBuilderInterface; class GeographicalUnitAggregator implements AggregatorInterface { - private GeographicalUnitLayerRepositoryInterface $geographicalUnitLayerRepository; - - private RollingDateConverterInterface $rollingDateConverter; - - private TranslatableStringHelperInterface $translatableStringHelper; - - public function __construct( - GeographicalUnitLayerRepositoryInterface $geographicalUnitLayerRepository, - TranslatableStringHelperInterface $translatableStringHelper, - RollingDateConverterInterface $rollingDateConverter - ) { - $this->geographicalUnitLayerRepository = $geographicalUnitLayerRepository; - $this->translatableStringHelper = $translatableStringHelper; - $this->rollingDateConverter = $rollingDateConverter; + public function __construct(private GeographicalUnitLayerRepositoryInterface $geographicalUnitLayerRepository, private TranslatableStringHelperInterface $translatableStringHelper, private RollingDateConverterInterface $rollingDateConverter) + { } public function addRole(): ?string @@ -111,36 +99,31 @@ class GeographicalUnitAggregator implements AggregatorInterface public function getLabels($key, array $values, $data) { - switch ($key) { - case 'geog_unit_name': - return static function ($value): string { - if ('_header' === $value) { - return 'acp_geog_agg_unitname'; - } + return match ($key) { + 'geog_unit_name' => static function ($value): string { + if ('_header' === $value) { + return 'acp_geog_agg_unitname'; + } - if (null === $value) { - return ''; - } + if (null === $value) { + return ''; + } - return $value; - }; + return $value; + }, + 'geog_unit_key' => static function ($value): string { + if ('_header' === $value) { + return 'acp_geog_agg_unitrefid'; + } - case 'geog_unit_key': - return static function ($value): string { - if ('_header' === $value) { - return 'acp_geog_agg_unitrefid'; - } + if (null === $value) { + return ''; + } - if (null === $value) { - return ''; - } - - return $value; - }; - - default: - throw new LogicException('key not supported'); - } + return $value; + }, + default => throw new LogicException('key not supported'), + }; } public function getQueryKeys($data) diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/HouseholdPositionAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/HouseholdPositionAggregator.php index 107634803..48a08b190 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/HouseholdPositionAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/HouseholdPositionAggregator.php @@ -29,24 +29,8 @@ use function in_array; final class HouseholdPositionAggregator implements AggregatorInterface, ExportElementValidatedInterface { - private PositionRepository $positionRepository; - - private RollingDateConverterInterface $rollingDateConverter; - - private TranslatableStringHelper $translatableStringHelper; - - private TranslatorInterface $translator; - - public function __construct( - TranslatorInterface $translator, - TranslatableStringHelper $translatableStringHelper, - PositionRepository $positionRepository, - RollingDateConverterInterface $rollingDateConverter - ) { - $this->translator = $translator; - $this->positionRepository = $positionRepository; - $this->translatableStringHelper = $translatableStringHelper; - $this->rollingDateConverter = $rollingDateConverter; + public function __construct(private TranslatorInterface $translator, private TranslatableStringHelper $translatableStringHelper, private PositionRepository $positionRepository, private RollingDateConverterInterface $rollingDateConverter) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/MaritalStatusAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/MaritalStatusAggregator.php index 08bde4bda..98049357a 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/MaritalStatusAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/MaritalStatusAggregator.php @@ -21,14 +21,8 @@ use function in_array; final class MaritalStatusAggregator implements AggregatorInterface { - private MaritalStatusRepository $maritalStatusRepository; - - private TranslatableStringHelper $translatableStringHelper; - - public function __construct(MaritalStatusRepository $maritalStatusRepository, TranslatableStringHelper $translatableStringHelper) + public function __construct(private MaritalStatusRepository $maritalStatusRepository, private TranslatableStringHelper $translatableStringHelper) { - $this->maritalStatusRepository = $maritalStatusRepository; - $this->translatableStringHelper = $translatableStringHelper; } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/NationalityAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/NationalityAggregator.php index d7c4097af..14f5a5dd5 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/NationalityAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/NationalityAggregator.php @@ -25,20 +25,8 @@ use Symfony\Contracts\Translation\TranslatorInterface; final class NationalityAggregator implements AggregatorInterface, ExportElementValidatedInterface { - private CountryRepository $countriesRepository; - - private TranslatableStringHelper $translatableStringHelper; - - private TranslatorInterface $translator; - - public function __construct( - CountryRepository $countriesRepository, - TranslatableStringHelper $translatableStringHelper, - TranslatorInterface $translator - ) { - $this->countriesRepository = $countriesRepository; - $this->translatableStringHelper = $translatableStringHelper; - $this->translator = $translator; + public function __construct(private CountryRepository $countriesRepository, private TranslatableStringHelper $translatableStringHelper, private TranslatorInterface $translator) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregator.php index c1fccb968..a1b384ffa 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregator.php @@ -24,24 +24,8 @@ use function in_array; final class ActionTypeAggregator implements AggregatorInterface { - private SocialActionRender $actionRender; - - private SocialActionRepository $socialActionRepository; - - private SocialIssueRender $socialIssueRender; - - private SocialIssueRepository $socialIssueRepository; - - public function __construct( - SocialActionRepository $socialActionRepository, - SocialActionRender $actionRender, - SocialIssueRender $socialIssueRender, - SocialIssueRepository $socialIssueRepository - ) { - $this->socialActionRepository = $socialActionRepository; - $this->actionRender = $actionRender; - $this->socialIssueRender = $socialIssueRender; - $this->socialIssueRepository = $socialIssueRepository; + public function __construct(private SocialActionRepository $socialActionRepository, private SocialActionRender $actionRender, private SocialIssueRender $socialIssueRender, private SocialIssueRepository $socialIssueRepository) + { } public function addRole(): ?string @@ -78,36 +62,31 @@ final class ActionTypeAggregator implements AggregatorInterface public function getLabels($key, array $values, $data) { - switch ($key) { - case 'action_type_aggregator': - return function ($value): string { - if ('_header' === $value) { - return 'Social Action Type'; - } + return match ($key) { + 'action_type_aggregator' => function ($value): string { + if ('_header' === $value) { + return 'Social Action Type'; + } - if (null === $value || '' === $value || null === $sa = $this->socialActionRepository->find($value)) { - return ''; - } + if (null === $value || '' === $value || null === $sa = $this->socialActionRepository->find($value)) { + return ''; + } - return $this->actionRender->renderString($sa, []); - }; + return $this->actionRender->renderString($sa, []); + }, + 'social_action_type_aggregator' => function ($value): string { + if ('_header' === $value) { + return 'Social Issue'; + } - case 'social_action_type_aggregator': - return function ($value): string { - if ('_header' === $value) { - return 'Social Issue'; - } + if (null === $value || null === $si = $this->socialIssueRepository->find($value)) { + return ''; + } - if (null === $value || null === $si = $this->socialIssueRepository->find($value)) { - return ''; - } - - return $this->socialIssueRender->renderString($si, []); - }; - - default: - throw new LogicException('this key is not supported: ' . $key); - } + return $this->socialIssueRender->renderString($si, []); + }, + default => throw new LogicException('this key is not supported: ' . $key), + }; } public function getQueryKeys($data) diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CurrentActionAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CurrentActionAggregator.php index 58fcb2874..30d272c15 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CurrentActionAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CurrentActionAggregator.php @@ -20,11 +20,8 @@ use Symfony\Contracts\Translation\TranslatorInterface; class CurrentActionAggregator implements AggregatorInterface { - private TranslatorInterface $translator; - - public function __construct(TranslatorInterface $translator) + public function __construct(private TranslatorInterface $translator) { - $this->translator = $translator; } public function addRole(): ?string @@ -59,16 +56,11 @@ class CurrentActionAggregator implements AggregatorInterface return 'export.aggregator.course_work.by_current_action.Current action ?'; } - switch ($value) { - case true: - return $this->translator->trans('export.aggregator.course_work.by_current_action.Current action'); - - case false: - return $this->translator->trans('export.aggregator.course_work.by_current_action.Not current action'); - - default: - throw new LogicException(sprintf('The value %s is not valid', $value)); - } + return match ($value) { + true => $this->translator->trans('export.aggregator.course_work.by_current_action.Current action'), + false => $this->translator->trans('export.aggregator.course_work.by_current_action.Not current action'), + default => throw new LogicException(sprintf('The value %s is not valid', $value)), + }; }; } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalAggregator.php index 8cc6a25da..a63580cf7 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalAggregator.php @@ -21,14 +21,8 @@ use function in_array; final class GoalAggregator implements AggregatorInterface { - private GoalRepository $goalRepository; - - private TranslatableStringHelper $translatableStringHelper; - - public function __construct(GoalRepository $goalRepository, TranslatableStringHelper $translatableStringHelper) + public function __construct(private GoalRepository $goalRepository, private TranslatableStringHelper $translatableStringHelper) { - $this->goalRepository = $goalRepository; - $this->translatableStringHelper = $translatableStringHelper; } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalResultAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalResultAggregator.php index 17b263d7e..7d3610c71 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalResultAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalResultAggregator.php @@ -23,20 +23,8 @@ use function in_array; class GoalResultAggregator implements AggregatorInterface { - private GoalRepository $goalRepository; - - private ResultRepository $resultRepository; - - private TranslatableStringHelper $translatableStringHelper; - - public function __construct( - ResultRepository $resultRepository, - GoalRepository $goalRepository, - TranslatableStringHelper $translatableStringHelper - ) { - $this->resultRepository = $resultRepository; - $this->goalRepository = $goalRepository; - $this->translatableStringHelper = $translatableStringHelper; + public function __construct(private ResultRepository $resultRepository, private GoalRepository $goalRepository, private TranslatableStringHelper $translatableStringHelper) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/JobAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/JobAggregator.php index cbf07091f..314149829 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/JobAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/JobAggregator.php @@ -21,16 +21,8 @@ use function in_array; final class JobAggregator implements AggregatorInterface { - private UserJobRepository $jobRepository; - - private TranslatableStringHelper $translatableStringHelper; - - public function __construct( - UserJobRepository $jobRepository, - TranslatableStringHelper $translatableStringHelper - ) { - $this->jobRepository = $jobRepository; - $this->translatableStringHelper = $translatableStringHelper; + public function __construct(private UserJobRepository $jobRepository, private TranslatableStringHelper $translatableStringHelper) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ReferrerAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ReferrerAggregator.php index 0fe53b707..a7adf6802 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ReferrerAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ReferrerAggregator.php @@ -21,16 +21,8 @@ use function in_array; final class ReferrerAggregator implements AggregatorInterface { - private UserRender $userRender; - - private UserRepository $userRepository; - - public function __construct( - UserRepository $userRepository, - UserRender $userRender - ) { - $this->userRepository = $userRepository; - $this->userRender = $userRender; + public function __construct(private UserRepository $userRepository, private UserRender $userRender) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ResultAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ResultAggregator.php index 2e46673da..c621b0899 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ResultAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ResultAggregator.php @@ -21,14 +21,8 @@ use function in_array; final class ResultAggregator implements AggregatorInterface { - private ResultRepository $resultRepository; - - private TranslatableStringHelper $translatableStringHelper; - - public function __construct(ResultRepository $resultRepository, TranslatableStringHelper $translatableStringHelper) + public function __construct(private ResultRepository $resultRepository, private TranslatableStringHelper $translatableStringHelper) { - $this->resultRepository = $resultRepository; - $this->translatableStringHelper = $translatableStringHelper; } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ScopeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ScopeAggregator.php index 243263b83..1a085828f 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ScopeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ScopeAggregator.php @@ -21,16 +21,8 @@ use function in_array; final class ScopeAggregator implements AggregatorInterface { - private ScopeRepository $scopeRepository; - - private TranslatableStringHelper $translatableStringHelper; - - public function __construct( - ScopeRepository $scopeRepository, - TranslatableStringHelper $translatableStringHelper - ) { - $this->scopeRepository = $scopeRepository; - $this->translatableStringHelper = $translatableStringHelper; + public function __construct(private ScopeRepository $scopeRepository, private TranslatableStringHelper $translatableStringHelper) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingPeriodWork.php b/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingPeriodWork.php index 122ee14d9..df89fc8d4 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingPeriodWork.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingPeriodWork.php @@ -26,12 +26,8 @@ use Symfony\Component\Form\FormBuilderInterface; class CountAccompanyingPeriodWork implements ExportInterface, GroupedExportInterface { - protected EntityManagerInterface $em; - - public function __construct( - EntityManagerInterface $em - ) { - $this->em = $em; + public function __construct(protected EntityManagerInterface $em) + { } public function buildForm(FormBuilderInterface $builder): void diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php b/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php index 1613b63d3..74d4bb4ff 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php @@ -25,12 +25,8 @@ use Symfony\Component\Form\FormBuilderInterface; class CountEvaluation implements ExportInterface, GroupedExportInterface { - private EntityManagerInterface $entityManager; - - public function __construct( - EntityManagerInterface $em - ) { - $this->entityManager = $em; + public function __construct(private EntityManagerInterface $entityManager) + { } public function buildForm(FormBuilderInterface $builder) diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php b/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php index 0b693b9d8..778f19812 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php @@ -30,16 +30,8 @@ class CountHousehold implements ExportInterface, GroupedExportInterface { private const TR_PREFIX = 'export.export.nb_household_with_course.'; - private EntityManagerInterface $entityManager; - - private RollingDateConverterInterface $rollingDateConverter; - - public function __construct( - EntityManagerInterface $em, - RollingDateConverterInterface $rollingDateConverter - ) { - $this->entityManager = $em; - $this->rollingDateConverter = $rollingDateConverter; + public function __construct(private EntityManagerInterface $entityManager, private RollingDateConverterInterface $rollingDateConverter) + { } public function buildForm(FormBuilderInterface $builder) @@ -71,16 +63,11 @@ class CountHousehold implements ExportInterface, GroupedExportInterface { return static function ($value) use ($key) { if ('_header' === $value) { - switch ($key) { - case 'household_export_result': - return self::TR_PREFIX . 'Count households'; - - case 'acp_export_result': - return self::TR_PREFIX . 'Count accompanying periods'; - - default: - throw new LogicException('Key not supported: ' . $key); - } + return match ($key) { + 'household_export_result' => self::TR_PREFIX . 'Count households', + 'acp_export_result' => self::TR_PREFIX . 'Count accompanying periods', + default => throw new LogicException('Key not supported: ' . $key), + }; } if (null === $value) { diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountPerson.php b/src/Bundle/ChillPersonBundle/Export/Export/CountPerson.php index 60429ae55..9901af716 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountPerson.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountPerson.php @@ -25,12 +25,8 @@ use Symfony\Component\Form\FormBuilderInterface; class CountPerson implements ExportInterface, GroupedExportInterface { - protected PersonRepository $personRepository; - - public function __construct( - PersonRepository $personRepository - ) { - $this->personRepository = $personRepository; + public function __construct(protected PersonRepository $personRepository) + { } public function buildForm(FormBuilderInterface $builder) diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php index 045039930..57e92f818 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php @@ -78,56 +78,8 @@ class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface 'updatedBy', ]; - private ExportAddressHelper $addressHelper; - - private DateTimeHelper $dateTimeHelper; - - private EntityManagerInterface $entityManager; - - private PersonRenderInterface $personRender; - - private PersonRepository $personRepository; - - private RollingDateConverterInterface $rollingDateConverter; - - private SocialIssueRender $socialIssueRender; - - private SocialIssueRepository $socialIssueRepository; - - private ThirdPartyRender $thirdPartyRender; - - private ThirdPartyRepository $thirdPartyRepository; - - private TranslatableStringHelperInterface $translatableStringHelper; - - private UserHelper $userHelper; - - public function __construct( - ExportAddressHelper $addressHelper, - DateTimeHelper $dateTimeHelper, - EntityManagerInterface $entityManager, - PersonRenderInterface $personRender, - PersonRepository $personRepository, - ThirdPartyRepository $thirdPartyRepository, - ThirdPartyRender $thirdPartyRender, - SocialIssueRepository $socialIssueRepository, - SocialIssueRender $socialIssueRender, - TranslatableStringHelperInterface $translatableStringHelper, - RollingDateConverterInterface $rollingDateConverter, - UserHelper $userHelper - ) { - $this->addressHelper = $addressHelper; - $this->dateTimeHelper = $dateTimeHelper; - $this->entityManager = $entityManager; - $this->personRender = $personRender; - $this->personRepository = $personRepository; - $this->socialIssueRender = $socialIssueRender; - $this->socialIssueRepository = $socialIssueRepository; - $this->thirdPartyRender = $thirdPartyRender; - $this->thirdPartyRepository = $thirdPartyRepository; - $this->translatableStringHelper = $translatableStringHelper; - $this->rollingDateConverter = $rollingDateConverter; - $this->userHelper = $userHelper; + public function __construct(private ExportAddressHelper $addressHelper, private DateTimeHelper $dateTimeHelper, private EntityManagerInterface $entityManager, private PersonRenderInterface $personRender, private PersonRepository $personRepository, private ThirdPartyRepository $thirdPartyRepository, private ThirdPartyRender $thirdPartyRender, private SocialIssueRepository $socialIssueRepository, private SocialIssueRender $socialIssueRender, private TranslatableStringHelperInterface $translatableStringHelper, private RollingDateConverterInterface $rollingDateConverter, private UserHelper $userHelper) + { } public function buildForm(FormBuilderInterface $builder) @@ -157,112 +109,91 @@ class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface public function getLabels($key, array $values, $data) { - if (substr($key, 0, strlen('address_fields')) === 'address_fields') { + if (str_starts_with($key, 'address_fields')) { return $this->addressHelper->getLabel($key, $values, $data, 'address_fields'); } - switch ($key) { - case 'stepSince': - case 'openingDate': - case 'closingDate': - case 'referrerSince': - case 'createdAt': - case 'updatedAt': - return $this->dateTimeHelper->getLabel('export.list.acp.' . $key); + return match ($key) { + 'stepSince', 'openingDate', 'closingDate', 'referrerSince', 'createdAt', 'updatedAt' => $this->dateTimeHelper->getLabel('export.list.acp.' . $key), + 'origin', 'closingMotive', 'job' => function ($value) use ($key) { + if ('_header' === $value) { + return 'export.list.acp.' . $key; + } - case 'origin': - case 'closingMotive': - case 'job': - return function ($value) use ($key) { - if ('_header' === $value) { - return 'export.list.acp.' . $key; - } + if (null === $value) { + return ''; + } - if (null === $value) { - return ''; - } + return $this->translatableStringHelper->localize(json_decode($value, true, 512, JSON_THROW_ON_ERROR)); + }, + 'locationPersonName', 'requestorPerson' => function ($value) use ($key) { + if ('_header' === $value) { + return 'export.list.acp.' . $key; + } - return $this->translatableStringHelper->localize(json_decode($value, true, 512, JSON_THROW_ON_ERROR)); - }; + if (null === $value || null === $person = $this->personRepository->find($value)) { + return ''; + } - case 'locationPersonName': - case 'requestorPerson': - return function ($value) use ($key) { - if ('_header' === $value) { - return 'export.list.acp.' . $key; - } + return $this->personRender->renderString($person, []); + }, + 'requestorThirdParty' => function ($value) use ($key) { + if ('_header' === $value) { + return 'export.list.acp.' . $key; + } - if (null === $value || null === $person = $this->personRepository->find($value)) { - return ''; - } + if (null === $value || null === $thirdparty = $this->thirdPartyRepository->find($value)) { + return ''; + } - return $this->personRender->renderString($person, []); - }; + return $this->thirdPartyRender->renderString($thirdparty, []); + }, + 'scopes' => function ($value) use ($key) { + if ('_header' === $value) { + return 'export.list.acp.' . $key; + } - case 'requestorThirdParty': - return function ($value) use ($key) { - if ('_header' === $value) { - return 'export.list.acp.' . $key; - } + if (null === $value) { + return ''; + } - if (null === $value || null === $thirdparty = $this->thirdPartyRepository->find($value)) { - return ''; - } + return implode( + '|', + array_map( + fn ($s) => $this->translatableStringHelper->localize($s), + json_decode($value, true, 512, JSON_THROW_ON_ERROR) + ) + ); + }, + 'socialIssues' => function ($value) use ($key) { + if ('_header' === $value) { + return 'export.list.acp.' . $key; + } - return $this->thirdPartyRender->renderString($thirdparty, []); - }; + if (null === $value) { + return ''; + } - case 'scopes': - return function ($value) use ($key) { - if ('_header' === $value) { - return 'export.list.acp.' . $key; - } + return implode( + '|', + array_map( + fn ($s) => $this->socialIssueRender->renderString($this->socialIssueRepository->find($s), []), + json_decode($value, true, 512, JSON_THROW_ON_ERROR) + ) + ); + }, + default => static function ($value) use ($key) { + if ('_header' === $value) { + return 'export.list.acp.' . $key; + } - if (null === $value) { - return ''; - } + if (null === $value) { + return ''; + } - return implode( - '|', - array_map( - fn ($s) => $this->translatableStringHelper->localize($s), - json_decode($value, true, 512, JSON_THROW_ON_ERROR) - ) - ); - }; - - case 'socialIssues': - return function ($value) use ($key) { - if ('_header' === $value) { - return 'export.list.acp.' . $key; - } - - if (null === $value) { - return ''; - } - - return implode( - '|', - array_map( - fn ($s) => $this->socialIssueRender->renderString($this->socialIssueRepository->find($s), []), - json_decode($value, true, 512, JSON_THROW_ON_ERROR) - ) - ); - }; - - default: - return static function ($value) use ($key) { - if ('_header' === $value) { - return 'export.list.acp.' . $key; - } - - if (null === $value) { - return ''; - } - - return $value; - }; - } + return $value; + }, + }; } public function getQueryKeys($data) diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriodWork.php b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriodWork.php index 00fa8adb1..0625d1552 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriodWork.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriodWork.php @@ -76,56 +76,8 @@ class ListAccompanyingPeriodWork implements ListInterface, GroupedExportInterfac 'updatedBy', ]; - private AggregateStringHelper $aggregateStringHelper; - - private DateTimeHelper $dateTimeHelper; - - private EntityManagerInterface $entityManager; - - private LabelPersonHelper $personHelper; - - private RollingDateConverterInterface $rollingDateConverter; - - private SocialActionRender $socialActionRender; - - private SocialActionRepository $socialActionRepository; - - private SocialIssueRender $socialIssueRender; - - private SocialIssueRepository $socialIssueRepository; - - private LabelThirdPartyHelper $thirdPartyHelper; - - private TranslatableStringExportLabelHelper $translatableStringExportLabelHelper; - - private UserHelper $userHelper; - - public function __construct( - EntityManagerInterface $entityManager, - DateTimeHelper $dateTimeHelper, - UserHelper $userHelper, - LabelPersonHelper $personHelper, - LabelThirdPartyHelper $thirdPartyHelper, - TranslatableStringExportLabelHelper $translatableStringExportLabelHelper, - SocialIssueRender $socialIssueRender, - SocialIssueRepository $socialIssueRepository, - SocialActionRender $socialActionRender, - RollingDateConverterInterface $rollingDateConverter, - AggregateStringHelper $aggregateStringHelper, - SocialActionRepository $socialActionRepository - ) { - $this->entityManager = $entityManager; - $this->dateTimeHelper = $dateTimeHelper; - $this->userHelper = $userHelper; - $this->personHelper = $personHelper; - $this->thirdPartyHelper = $thirdPartyHelper; - $this->translatableStringExportLabelHelper = $translatableStringExportLabelHelper; - $this->socialIssueRender = $socialIssueRender; - $this->socialIssueRepository = $socialIssueRepository; - $this->socialActionRender = $socialActionRender; - $this->rollingDateConverter = $rollingDateConverter; - $this->aggregateStringHelper = $aggregateStringHelper; - $this->socialActionRepository = $socialActionRepository; + public function __construct(private EntityManagerInterface $entityManager, private DateTimeHelper $dateTimeHelper, private UserHelper $userHelper, private LabelPersonHelper $personHelper, private LabelThirdPartyHelper $thirdPartyHelper, private TranslatableStringExportLabelHelper $translatableStringExportLabelHelper, private SocialIssueRender $socialIssueRender, private SocialIssueRepository $socialIssueRepository, private SocialActionRender $socialActionRender, private RollingDateConverterInterface $rollingDateConverter, private AggregateStringHelper $aggregateStringHelper, private SocialActionRepository $socialActionRepository) + { } public function buildForm(FormBuilderInterface $builder) @@ -156,89 +108,55 @@ class ListAccompanyingPeriodWork implements ListInterface, GroupedExportInterfac public function getLabels($key, array $values, $data) { - switch ($key) { - case 'startDate': - case 'endDate': - case 'createdAt': - case 'updatedAt': - return $this->dateTimeHelper->getLabel('export.list.acpw.' . $key); + return match ($key) { + 'startDate', 'endDate', 'createdAt', 'updatedAt' => $this->dateTimeHelper->getLabel('export.list.acpw.' . $key), + 'socialAction' => function ($value) use ($key) { + if ('_header' === $value) { + return 'export.list.acpw.' . $key; + } - case 'socialAction': - return function ($value) use ($key) { - if ('_header' === $value) { - return 'export.list.acpw.' . $key; - } + if (null === $value) { + return ''; + } - if (null === $value) { - return ''; - } + return $this->socialActionRender->renderString( + $this->socialActionRepository->find($value), + [] + ); + }, + 'socialIssue' => function ($value) use ($key) { + if ('_header' === $value) { + return 'export.list.acpw.' . $key; + } - return $this->socialActionRender->renderString( - $this->socialActionRepository->find($value), - [] - ); - }; + if (null === $value) { + return ''; + } - case 'socialIssue': - return function ($value) use ($key) { - if ('_header' === $value) { - return 'export.list.acpw.' . $key; - } + return $this->socialIssueRender->renderString( + $this->socialIssueRepository->find($value), + [] + ); + }, + 'createdBy', 'updatedBy', 'acp_user' => $this->userHelper->getLabel($key, $values, 'export.list.acpw.' . $key), + 'referrers' => $this->userHelper->getLabel($key, $values, 'export.list.acpw.' . $key), + 'personsName' => $this->personHelper->getLabelMulti($key, $values, 'export.list.acpw.' . $key), + 'handlingThierParty' => $this->thirdPartyHelper->getLabel($key, $values, 'export.list.acpw.' . $key), + 'thirdParties' => $this->thirdPartyHelper->getLabelMulti($key, $values, 'export.list.acpw.' . $key), + 'personsId', 'goalsId', 'goalResultsId', 'resultsId', 'evaluationsId' => $this->aggregateStringHelper->getLabelMulti($key, $values, 'export.list.acpw.' . $key), + 'goalsTitle', 'goalResultsTitle', 'resultsTitle', 'evaluationsTitle' => $this->translatableStringExportLabelHelper->getLabelMulti($key, $values, 'export.list.acpw.' . $key), + default => static function ($value) use ($key) { + if ('_header' === $value) { + return 'export.list.acpw.' . $key; + } - if (null === $value) { - return ''; - } + if (null === $value) { + return ''; + } - return $this->socialIssueRender->renderString( - $this->socialIssueRepository->find($value), - [] - ); - }; - - case 'createdBy': - case 'updatedBy': - case 'acp_user': - return $this->userHelper->getLabel($key, $values, 'export.list.acpw.' . $key); - - case 'referrers': - //$date = $this->rollDateConverter->convert($data['calc_date'])->format('d/m/Y'); - return $this->userHelper->getLabel($key, $values, 'export.list.acpw.' . $key); - - case 'personsName': - return $this->personHelper->getLabelMulti($key, $values, 'export.list.acpw.' . $key); - - case 'handlingThierParty': - return $this->thirdPartyHelper->getLabel($key, $values, 'export.list.acpw.' . $key); - - case 'thirdParties': - return $this->thirdPartyHelper->getLabelMulti($key, $values, 'export.list.acpw.' . $key); - - case 'personsId': - case 'goalsId': - case 'goalResultsId': - case 'resultsId': - case 'evaluationsId': - return $this->aggregateStringHelper->getLabelMulti($key, $values, 'export.list.acpw.' . $key); - - case 'goalsTitle': - case 'goalResultsTitle': - case 'resultsTitle': - case 'evaluationsTitle': - return $this->translatableStringExportLabelHelper->getLabelMulti($key, $values, 'export.list.acpw.' . $key); - - default: - return static function ($value) use ($key) { - if ('_header' === $value) { - return 'export.list.acpw.' . $key; - } - - if (null === $value) { - return ''; - } - - return $value; - }; - } + return $value; + }, + }; } public function getQueryKeys($data) diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListEvaluation.php b/src/Bundle/ChillPersonBundle/Export/Export/ListEvaluation.php index f0985436b..ebe3911a9 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListEvaluation.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListEvaluation.php @@ -68,52 +68,8 @@ class ListEvaluation implements ListInterface, GroupedExportInterface 'updatedBy', ]; - private AggregateStringHelper $aggregateStringHelper; - - private DateTimeHelper $dateTimeHelper; - - private EntityManagerInterface $entityManager; - - private LabelPersonHelper $personHelper; - - private RollingDateConverterInterface $rollingDateConverter; - - private SocialActionRender $socialActionRender; - - private SocialActionRepository $socialActionRepository; - - private SocialIssueRender $socialIssueRender; - - private SocialIssueRepository $socialIssueRepository; - - private TranslatableStringExportLabelHelper $translatableStringExportLabelHelper; - - private UserHelper $userHelper; - - public function __construct( - EntityManagerInterface $entityManager, - SocialIssueRender $socialIssueRender, - SocialIssueRepository $socialIssueRepository, - SocialActionRender $socialActionRender, - SocialActionRepository $socialActionRepository, - UserHelper $userHelper, - LabelPersonHelper $personHelper, - DateTimeHelper $dateTimeHelper, - TranslatableStringExportLabelHelper $translatableStringExportLabelHelper, - AggregateStringHelper $aggregateStringHelper, - RollingDateConverterInterface $rollingDateConverter - ) { - $this->entityManager = $entityManager; - $this->socialIssueRender = $socialIssueRender; - $this->socialIssueRepository = $socialIssueRepository; - $this->socialActionRender = $socialActionRender; - $this->socialActionRepository = $socialActionRepository; - $this->userHelper = $userHelper; - $this->personHelper = $personHelper; - $this->dateTimeHelper = $dateTimeHelper; - $this->translatableStringExportLabelHelper = $translatableStringExportLabelHelper; - $this->aggregateStringHelper = $aggregateStringHelper; - $this->rollingDateConverter = $rollingDateConverter; + public function __construct(private EntityManagerInterface $entityManager, private SocialIssueRender $socialIssueRender, private SocialIssueRepository $socialIssueRepository, private SocialActionRender $socialActionRender, private SocialActionRepository $socialActionRepository, private UserHelper $userHelper, private LabelPersonHelper $personHelper, private DateTimeHelper $dateTimeHelper, private TranslatableStringExportLabelHelper $translatableStringExportLabelHelper, private AggregateStringHelper $aggregateStringHelper, private RollingDateConverterInterface $rollingDateConverter) + { } public function buildForm(FormBuilderInterface $builder) @@ -144,79 +100,54 @@ class ListEvaluation implements ListInterface, GroupedExportInterface public function getLabels($key, array $values, $data) { - switch ($key) { - case 'startDate': - case 'endDate': - case 'maxDate': - case 'acpw_startDate': - case 'acpw_endDate': - case 'createdAt': - case 'updatedAt': - return $this->dateTimeHelper->getLabel('export.list.eval.' . $key); + return match ($key) { + 'startDate', 'endDate', 'maxDate', 'acpw_startDate', 'acpw_endDate', 'createdAt', 'updatedAt' => $this->dateTimeHelper->getLabel('export.list.eval.' . $key), + 'acpw_socialaction' => function ($value) use ($key) { + if ('_header' === $value) { + return 'export.list.eval.' . $key; + } - case 'acpw_socialaction': - return function ($value) use ($key) { - if ('_header' === $value) { - return 'export.list.eval.' . $key; - } + if (null === $value || '' === $value) { + return ''; + } - if (null === $value || '' === $value) { - return ''; - } + return $this->socialActionRender->renderString( + $this->socialActionRepository->find($value), + [] + ); + }, + 'acpw_socialissue' => function ($value) use ($key) { + if ('_header' === $value) { + return 'export.list.eval.' . $key; + } - return $this->socialActionRender->renderString( - $this->socialActionRepository->find($value), - [] - ); - }; + if (null === $value || '' === $value) { + return ''; + } - case 'acpw_socialissue': - return function ($value) use ($key) { - if ('_header' === $value) { - return 'export.list.eval.' . $key; - } + return $this->socialIssueRender->renderString( + $this->socialIssueRepository->find($value), + [] + ); + }, + 'createdBy', 'updatedBy', 'acpw_acp_user' => $this->userHelper->getLabel($key, $values, 'export.list.eval.' . $key), + 'acpw_referrers' => $this->userHelper->getLabel($key, $values, 'export.list.eval.' . $key), + 'acpw_persons_id' => $this->aggregateStringHelper->getLabelMulti($key, $values, 'export.list.eval.' . $key), + 'acpw_persons' => $this->personHelper->getLabelMulti($key, $values, 'export.list.eval.' . $key), + 'eval_title' => $this->translatableStringExportLabelHelper + ->getLabel($key, $values, 'export.list.eval.' . $key), + default => static function ($value) use ($key) { + if ('_header' === $value) { + return 'export.list.eval.' . $key; + } - if (null === $value || '' === $value) { - return ''; - } + if (null === $value) { + return ''; + } - return $this->socialIssueRender->renderString( - $this->socialIssueRepository->find($value), - [] - ); - }; - - case 'createdBy': - case 'updatedBy': - case 'acpw_acp_user': - return $this->userHelper->getLabel($key, $values, 'export.list.eval.' . $key); - - case 'acpw_referrers': - return $this->userHelper->getLabel($key, $values, 'export.list.eval.' . $key); - - case 'acpw_persons_id': - return $this->aggregateStringHelper->getLabelMulti($key, $values, 'export.list.eval.' . $key); - - case 'acpw_persons': - return $this->personHelper->getLabelMulti($key, $values, 'export.list.eval.' . $key); - - case 'eval_title': - return $this->translatableStringExportLabelHelper - ->getLabel($key, $values, 'export.list.eval.' . $key); - - default: - return static function ($value) use ($key) { - if ('_header' === $value) { - return 'export.list.eval.' . $key; - } - - if (null === $value) { - return ''; - } - - return $value; - }; - } + return $value; + }, + }; } public function getQueryKeys($data) diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListHouseholdInPeriod.php b/src/Bundle/ChillPersonBundle/Export/Export/ListHouseholdInPeriod.php index 24d929c00..06d79d6fc 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListHouseholdInPeriod.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListHouseholdInPeriod.php @@ -45,28 +45,8 @@ class ListHouseholdInPeriod implements ListInterface, GroupedExportInterface 'compositionType', ]; - private ExportAddressHelper $addressHelper; - - private AggregateStringHelper $aggregateStringHelper; - - private EntityManagerInterface $entityManager; - - private RollingDateConverterInterface $rollingDateConverter; - - private TranslatableStringExportLabelHelper $translatableStringHelper; - - public function __construct( - ExportAddressHelper $addressHelper, - AggregateStringHelper $aggregateStringHelper, - EntityManagerInterface $entityManager, - RollingDateConverterInterface $rollingDateConverter, - TranslatableStringExportLabelHelper $translatableStringHelper - ) { - $this->addressHelper = $addressHelper; - $this->aggregateStringHelper = $aggregateStringHelper; - $this->entityManager = $entityManager; - $this->rollingDateConverter = $rollingDateConverter; - $this->translatableStringHelper = $translatableStringHelper; + public function __construct(private ExportAddressHelper $addressHelper, private AggregateStringHelper $aggregateStringHelper, private EntityManagerInterface $entityManager, private RollingDateConverterInterface $rollingDateConverter, private TranslatableStringExportLabelHelper $translatableStringHelper) + { } public function buildForm(FormBuilderInterface $builder) @@ -97,28 +77,21 @@ class ListHouseholdInPeriod implements ListInterface, GroupedExportInterface public function getLabels($key, array $values, $data) { - if (substr($key, 0, strlen('address_fields')) === 'address_fields') { + if (str_starts_with($key, 'address_fields')) { return $this->addressHelper->getLabel($key, $values, $data, 'address_fields'); } - switch ($key) { - case 'membersId': - case 'membersName': - return $this->aggregateStringHelper->getLabelMulti($key, $values, 'export.list.household.' . $key); + return match ($key) { + 'membersId', 'membersName' => $this->aggregateStringHelper->getLabelMulti($key, $values, 'export.list.household.' . $key), + 'compositionType' => $this->translatableStringHelper->getLabel($key, $values, 'export.list.household.' . $key), + default => static function ($value) use ($key) { + if ('_header' === $value) { + return 'export.list.household.' . $key; + } - case 'compositionType': - //dump($values); - return $this->translatableStringHelper->getLabel($key, $values, 'export.list.household.' . $key); - - default: - return static function ($value) use ($key) { - if ('_header' === $value) { - return 'export.list.household.' . $key; - } - - return (string) $value; - }; - } + return (string) $value; + }, + }; } public function getQueryKeys($data): array diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php b/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php index 8145fd658..02c0722d4 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php @@ -48,30 +48,10 @@ use function uniqid; */ class ListPerson implements ExportElementValidatedInterface, ListInterface, GroupedExportInterface { - private ExportAddressHelper $addressHelper; - - private CustomFieldProvider $customFieldProvider; - - private EntityManagerInterface $entityManager; - - private ListPersonHelper $listPersonHelper; - private $slugs = []; - private TranslatableStringHelper $translatableStringHelper; - - public function __construct( - ExportAddressHelper $addressHelper, - CustomFieldProvider $customFieldProvider, - ListPersonHelper $listPersonHelper, - EntityManagerInterface $em, - TranslatableStringHelper $translatableStringHelper - ) { - $this->addressHelper = $addressHelper; - $this->customFieldProvider = $customFieldProvider; - $this->listPersonHelper = $listPersonHelper; - $this->entityManager = $em; - $this->translatableStringHelper = $translatableStringHelper; + public function __construct(private ExportAddressHelper $addressHelper, private CustomFieldProvider $customFieldProvider, private ListPersonHelper $listPersonHelper, private EntityManagerInterface $entityManager, private TranslatableStringHelper $translatableStringHelper) + { } public function buildForm(FormBuilderInterface $builder) @@ -92,7 +72,7 @@ class ListPerson implements ExportElementValidatedInterface, ListInterface, Grou 'label' => 'Fields to include in export', 'choice_attr' => static function (string $val): array { // add a 'data-display-target' for address fields - if (substr($val, 0, 7) === 'address' || 'center' === $val || 'household' === $val) { + if (str_starts_with($val, 'address') || 'center' === $val || 'household' === $val) { return ['data-display-target' => 'address_date']; } @@ -152,7 +132,7 @@ class ListPerson implements ExportElementValidatedInterface, ListInterface, Grou continue; } - if (substr($key, 0, strlen('address_fields')) === 'address_fields') { + if (str_starts_with($key, 'address_fields')) { $fields = array_merge($fields, $this->addressHelper->getKeys(ExportAddressHelper::F_ALL, 'address_fields')); continue; @@ -264,7 +244,7 @@ class ListPerson implements ExportElementValidatedInterface, ListInterface, Grou // get the field starting with address_ $addressFields = array_filter( ListPersonHelper::FIELDS, - static fn (string $el): bool => substr($el, 0, 8) === 'address_' + static fn (string $el): bool => str_starts_with($el, 'address_') ); // check if there is one field starting with address in data @@ -285,11 +265,9 @@ class ListPerson implements ExportElementValidatedInterface, ListInterface, Grou } /** - * @param mixed $slug - * * @return array An array with keys = 'slug', 'type', 'additionnalInfo' */ - private function extractInfosFromSlug($slug): array + private function extractInfosFromSlug(mixed $slug): array { return $this->slugs[$slug]; } diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListPersonDuplicate.php b/src/Bundle/ChillPersonBundle/Export/Export/ListPersonDuplicate.php index e40ffccce..4181098b2 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListPersonDuplicate.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListPersonDuplicate.php @@ -47,25 +47,13 @@ class ListPersonDuplicate implements DirectExportInterface, ExportElementValidat */ protected $entityManager; - /** - * @var \Symfony\Component\Routing\Generator\UrlGeneratorInterface - */ - private $router; - - /** - * @var \Symfony\Component\Translation\TranslatorInterface - */ - private $translator; - public function __construct( EntityManagerInterface $em, - TranslatorInterface $translator, - UrlGeneratorInterface $router, + private TranslatorInterface $translator, + private UrlGeneratorInterface $router, $routeParameters ) { $this->entityManager = $em; - $this->translator = $translator; - $this->router = $router; $this->baseUrl = $routeParameters['scheme'] . '://' . $routeParameters['host']; } diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriod.php index 7cb066e87..9676a9437 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriod.php @@ -37,20 +37,8 @@ use function strlen; class ListPersonWithAccompanyingPeriod implements ExportElementValidatedInterface, ListInterface, GroupedExportInterface { - private ExportAddressHelper $addressHelper; - - private EntityManagerInterface $entityManager; - - private ListPersonHelper $listPersonHelper; - - public function __construct( - ExportAddressHelper $addressHelper, - ListPersonHelper $listPersonHelper, - EntityManagerInterface $em - ) { - $this->addressHelper = $addressHelper; - $this->listPersonHelper = $listPersonHelper; - $this->entityManager = $em; + public function __construct(private ExportAddressHelper $addressHelper, private ListPersonHelper $listPersonHelper, private EntityManagerInterface $entityManager) + { } public function buildForm(FormBuilderInterface $builder) @@ -65,7 +53,7 @@ class ListPersonWithAccompanyingPeriod implements ExportElementValidatedInterfac 'label' => 'Fields to include in export', 'choice_attr' => static function (string $val): array { // add a 'data-display-target' for address fields - if (substr($val, 0, 7) === 'address' || 'center' === $val || 'household' === $val) { + if (str_starts_with($val, 'address') || 'center' === $val || 'household' === $val) { return ['data-display-target' => 'address_date']; } @@ -121,7 +109,7 @@ class ListPersonWithAccompanyingPeriod implements ExportElementValidatedInterfac continue; } - if (substr($key, 0, strlen('address_fields')) === 'address_fields') { + if (str_starts_with($key, 'address_fields')) { $fields = array_merge($fields, $this->addressHelper->getKeys(ExportAddressHelper::F_ALL, 'address_fields')); continue; @@ -201,7 +189,7 @@ class ListPersonWithAccompanyingPeriod implements ExportElementValidatedInterfac // get the field starting with address_ $addressFields = array_filter( ListPersonHelper::FIELDS, - static fn (string $el): bool => substr($el, 0, 8) === 'address_' + static fn (string $el): bool => str_starts_with($el, 'address_') ); // check if there is one field starting with address in data diff --git a/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php b/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php index 31ca41cbb..1d0161b24 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php @@ -64,22 +64,13 @@ class StatAccompanyingCourseDuration implements ExportInterface, GroupedExportIn { return static function ($value) use ($key) { if ('_header' === $value) { - switch ($key) { - case 'avg_export_result': - return 'export.export.acp_stats.avg_duration'; - - case 'count_acppart_export_result': - return 'export.export.acp_stats.count_participations'; - - case 'count_acp_export_result': - return 'export.export.acp_stats.count_acps'; - - case 'count_pers_export_result': - return 'export.export.acp_stats.count_persons'; - - default: - throw new LogicException('key not supported: ' . $key); - } + return match ($key) { + 'avg_export_result' => 'export.export.acp_stats.avg_duration', + 'count_acppart_export_result' => 'export.export.acp_stats.count_participations', + 'count_acp_export_result' => 'export.export.acp_stats.count_acps', + 'count_pers_export_result' => 'export.export.acp_stats.count_persons', + default => throw new LogicException('key not supported: ' . $key), + }; } if (null === $value) { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOnDateFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOnDateFilter.php index 3fa8d711f..3f5a25053 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOnDateFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOnDateFilter.php @@ -22,11 +22,8 @@ use Symfony\Component\Form\FormBuilderInterface; class ActiveOnDateFilter implements FilterInterface { - private RollingDateConverterInterface $rollingDateConverter; - - public function __construct(RollingDateConverterInterface $rollingDateConverter) + public function __construct(private RollingDateConverterInterface $rollingDateConverter) { - $this->rollingDateConverter = $rollingDateConverter; } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOneDayBetweenDatesFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOneDayBetweenDatesFilter.php index f713e8a97..ff1ac7653 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOneDayBetweenDatesFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOneDayBetweenDatesFilter.php @@ -21,11 +21,8 @@ use Symfony\Component\Form\FormBuilderInterface; class ActiveOneDayBetweenDatesFilter implements FilterInterface { - private RollingDateConverterInterface $rollingDateConverter; - - public function __construct(RollingDateConverterInterface $rollingDateConverter) + public function __construct(private RollingDateConverterInterface $rollingDateConverter) { - $this->rollingDateConverter = $rollingDateConverter; } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/AdministrativeLocationFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/AdministrativeLocationFilter.php index c74e309b2..d4e74d165 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/AdministrativeLocationFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/AdministrativeLocationFilter.php @@ -20,12 +20,8 @@ use Symfony\Component\Form\FormBuilderInterface; class AdministrativeLocationFilter implements FilterInterface { - private TranslatableStringHelper $translatableStringHelper; - - public function __construct( - TranslatableStringHelper $translatableStringHelper - ) { - $this->translatableStringHelper = $translatableStringHelper; + public function __construct(private TranslatableStringHelper $translatableStringHelper) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ClosingMotiveFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ClosingMotiveFilter.php index e57370f30..a8fb0b48e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ClosingMotiveFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ClosingMotiveFilter.php @@ -22,12 +22,8 @@ use Symfony\Component\Form\FormBuilderInterface; class ClosingMotiveFilter implements FilterInterface { - private TranslatableStringHelper $translatableStringHelper; - - public function __construct( - TranslatableStringHelper $translatableStringHelper - ) { - $this->translatableStringHelper = $translatableStringHelper; + public function __construct(private TranslatableStringHelper $translatableStringHelper) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ConfidentialFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ConfidentialFilter.php index 8fcd874fe..1803e8067 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ConfidentialFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ConfidentialFilter.php @@ -28,11 +28,8 @@ class ConfidentialFilter implements FilterInterface private const DEFAULT_CHOICE = false; - private TranslatorInterface $translator; - - public function __construct(TranslatorInterface $translator) + public function __construct(private TranslatorInterface $translator) { - $this->translator = $translator; } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorJobFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorJobFilter.php index f585cfafb..79412bb61 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorJobFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorJobFilter.php @@ -23,16 +23,8 @@ use function in_array; class CreatorJobFilter implements FilterInterface { - private TranslatableStringHelper $translatableStringHelper; - - private UserJobRepositoryInterface $userJobRepository; - - public function __construct( - TranslatableStringHelper $translatableStringHelper, - UserJobRepositoryInterface $userJobRepository - ) { - $this->translatableStringHelper = $translatableStringHelper; - $this->userJobRepository = $userJobRepository; + public function __construct(private TranslatableStringHelper $translatableStringHelper, private UserJobRepositoryInterface $userJobRepository) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EmergencyFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EmergencyFilter.php index afdb717f0..b680299a1 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EmergencyFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EmergencyFilter.php @@ -28,11 +28,8 @@ class EmergencyFilter implements FilterInterface private const DEFAULT_CHOICE = false; - private TranslatorInterface $translator; - - public function __construct(TranslatorInterface $translator) + public function __construct(private TranslatorInterface $translator) { - $this->translator = $translator; } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EvaluationFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EvaluationFilter.php index ab7f4257e..e4e895555 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EvaluationFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EvaluationFilter.php @@ -23,16 +23,8 @@ use function in_array; class EvaluationFilter implements FilterInterface { - private EvaluationRepositoryInterface $evaluationRepository; - - private TranslatableStringHelper $translatableStringHelper; - - public function __construct( - EvaluationRepositoryInterface $evaluationRepository, - TranslatableStringHelper $translatableStringHelper - ) { - $this->evaluationRepository = $evaluationRepository; - $this->translatableStringHelper = $translatableStringHelper; + public function __construct(private EvaluationRepositoryInterface $evaluationRepository, private TranslatableStringHelper $translatableStringHelper) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php index d35565c80..31a449a35 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php @@ -32,24 +32,8 @@ use Symfony\Component\Form\FormBuilderInterface; */ class GeographicalUnitStatFilter implements FilterInterface { - private GeographicalUnitLayerRepositoryInterface $geographicalUnitLayerRepository; - - private GeographicalUnitRepositoryInterface $geographicalUnitRepository; - - private RollingDateConverterInterface $rollingDateConverter; - - private TranslatableStringHelperInterface $translatableStringHelper; - - public function __construct( - GeographicalUnitRepositoryInterface $geographicalUnitRepository, - GeographicalUnitLayerRepositoryInterface $geographicalUnitLayerRepository, - TranslatableStringHelperInterface $translatableStringHelper, - RollingDateConverterInterface $rollingDateConverter - ) { - $this->geographicalUnitRepository = $geographicalUnitRepository; - $this->geographicalUnitLayerRepository = $geographicalUnitLayerRepository; - $this->translatableStringHelper = $translatableStringHelper; - $this->rollingDateConverter = $rollingDateConverter; + public function __construct(private GeographicalUnitRepositoryInterface $geographicalUnitRepository, private GeographicalUnitLayerRepositoryInterface $geographicalUnitLayerRepository, private TranslatableStringHelperInterface $translatableStringHelper, private RollingDateConverterInterface $rollingDateConverter) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasNoReferrerFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasNoReferrerFilter.php index 4c682a56a..43503a6b9 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasNoReferrerFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasNoReferrerFilter.php @@ -22,12 +22,8 @@ use Symfony\Component\Form\FormBuilderInterface; class HasNoReferrerFilter implements FilterInterface { - private RollingDateConverterInterface $rollingDateConverter; - - public function __construct( - RollingDateConverterInterface $rollingDateConverter - ) { - $this->rollingDateConverter = $rollingDateConverter; + public function __construct(private RollingDateConverterInterface $rollingDateConverter) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasTemporaryLocationFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasTemporaryLocationFilter.php index 615ace4c6..9ef7f012f 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasTemporaryLocationFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasTemporaryLocationFilter.php @@ -23,12 +23,8 @@ use Symfony\Component\Form\FormBuilderInterface; class HasTemporaryLocationFilter implements FilterInterface { - private RollingDateConverterInterface $rollingDateConverter; - - public function __construct( - RollingDateConverterInterface $rollingDateConverter - ) { - $this->rollingDateConverter = $rollingDateConverter; + public function __construct(private RollingDateConverterInterface $rollingDateConverter) + { } public function addRole(): ?string @@ -47,20 +43,11 @@ class HasTemporaryLocationFilter implements FilterInterface $this->rollingDateConverter->convert($data['calc_date']) ); - switch ($data['having_temporarily']) { - case true: - $qb->andWhere('acp_having_temporarily_location.addressLocation IS NOT NULL'); - - break; - - case false: - $qb->andWhere('acp_having_temporarily_location.personLocation IS NOT NULL'); - - break; - - default: - throw new LogicException('value not supported'); - } + match ($data['having_temporarily']) { + true => $qb->andWhere('acp_having_temporarily_location.addressLocation IS NOT NULL'), + false => $qb->andWhere('acp_having_temporarily_location.personLocation IS NOT NULL'), + default => throw new LogicException('value not supported'), + }; } public function applyOn(): string @@ -77,17 +64,10 @@ class HasTemporaryLocationFilter implements FilterInterface 'export.filter.course.having_temporarily.Having a temporarily location' => true, 'export.filter.course.having_temporarily.Having a person\'s location' => false, ], - 'choice_label' => static function ($choice) { - switch ($choice) { - case true: - return 'export.filter.course.having_temporarily.Having a temporarily location'; - - case false: - return 'export.filter.course.having_temporarily.Having a person\'s location'; - - default: - throw new LogicException('this choice is not supported'); - } + 'choice_label' => static fn ($choice) => match ($choice) { + true => 'export.filter.course.having_temporarily.Having a temporarily location', + false => 'export.filter.course.having_temporarily.Having a person\'s location', + default => throw new LogicException('this choice is not supported'), }, ]) ->add('calc_date', PickRollingDateType::class, [ @@ -98,16 +78,11 @@ class HasTemporaryLocationFilter implements FilterInterface public function describeAction($data, $format = 'string'): array { - switch ($data['having_temporarily']) { - case true: - return ['export.filter.course.having_temporarily.Having a temporarily location', []]; - - case false: - return ['export.filter.course.having_temporarily.Having a person\'s location', []]; - - default: - throw new LogicException('value not supported'); - } + return match ($data['having_temporarily']) { + true => ['export.filter.course.having_temporarily.Having a temporarily location', []], + false => ['export.filter.course.having_temporarily.Having a person\'s location', []], + default => throw new LogicException('value not supported'), + }; } public function getTitle(): string diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/IntensityFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/IntensityFilter.php index b0c2205a0..1f215bce9 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/IntensityFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/IntensityFilter.php @@ -28,11 +28,8 @@ class IntensityFilter implements FilterInterface private const DEFAULT_CHOICE = 'occasional'; - private TranslatorInterface $translator; - - public function __construct(TranslatorInterface $translator) + public function __construct(private TranslatorInterface $translator) { - $this->translator = $translator; } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OpenBetweenDatesFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OpenBetweenDatesFilter.php index 07ca1de75..23823467f 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OpenBetweenDatesFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OpenBetweenDatesFilter.php @@ -22,11 +22,8 @@ use Symfony\Component\Form\FormBuilderInterface; class OpenBetweenDatesFilter implements FilterInterface { - private RollingDateConverterInterface $rollingDateConverter; - - public function __construct(RollingDateConverterInterface $rollingDateConverter) + public function __construct(private RollingDateConverterInterface $rollingDateConverter) { - $this->rollingDateConverter = $rollingDateConverter; } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OriginFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OriginFilter.php index 00febc640..f3b927f68 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OriginFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OriginFilter.php @@ -22,12 +22,8 @@ use Symfony\Component\Form\FormBuilderInterface; class OriginFilter implements FilterInterface { - private TranslatableStringHelper $translatableStringHelper; - - public function __construct( - TranslatableStringHelper $translatableStringHelper - ) { - $this->translatableStringHelper = $translatableStringHelper; + public function __construct(private TranslatableStringHelper $translatableStringHelper) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ReferrerFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ReferrerFilter.php index 2a3e5d17e..ee79ca8f8 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ReferrerFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ReferrerFilter.php @@ -29,12 +29,8 @@ class ReferrerFilter implements FilterInterface private const PU = 'acp_referrer_filter_users'; - private RollingDateConverterInterface $rollingDateConverter; - - public function __construct( - RollingDateConverterInterface $rollingDateConverter - ) { - $this->rollingDateConverter = $rollingDateConverter; + public function __construct(private RollingDateConverterInterface $rollingDateConverter) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/RequestorFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/RequestorFilter.php index 3295a5b57..60fc9e5ec 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/RequestorFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/RequestorFilter.php @@ -33,16 +33,8 @@ final class RequestorFilter implements FilterInterface 'no requestor' => 'no_requestor', ]; - private EntityManagerInterface $em; - - private TranslatorInterface $translator; - - public function __construct( - TranslatorInterface $translator, - EntityManagerInterface $em - ) { - $this->translator = $translator; - $this->em = $em; + public function __construct(private TranslatorInterface $translator, private EntityManagerInterface $em) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php index bc1f368da..fd4d4ac64 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php @@ -23,16 +23,8 @@ use function in_array; class SocialActionFilter implements FilterInterface { - private SocialActionRender $actionRender; - - private TranslatableStringHelper $translatableStringHelper; - - public function __construct( - TranslatableStringHelper $translatableStringHelper, - SocialActionRender $actionRender - ) { - $this->translatableStringHelper = $translatableStringHelper; - $this->actionRender = $actionRender; + public function __construct(private TranslatableStringHelper $translatableStringHelper, private SocialActionRender $actionRender) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php index 917e129bf..ee9ebfc79 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php @@ -28,14 +28,11 @@ class SocialIssueFilter implements FilterInterface */ protected $translator; - private SocialIssueRender $socialIssueRender; - public function __construct( TranslatorInterface $translator, - SocialIssueRender $socialIssueRender + private SocialIssueRender $socialIssueRender ) { $this->translator = $translator; - $this->socialIssueRender = $socialIssueRender; } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/StepFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/StepFilter.php index 240b093b5..e217cdab0 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/StepFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/StepFilter.php @@ -37,19 +37,8 @@ class StepFilter implements FilterInterface 'Closed' => AccompanyingPeriod::STEP_CLOSED, ]; - private RollingDateConverterInterface $rollingDateConverter; - - /** - * @var TranslatorInterface - */ - private $translator; - - public function __construct( - RollingDateConverterInterface $rollingDateConverter, - TranslatorInterface $translator - ) { - $this->rollingDateConverter = $rollingDateConverter; - $this->translator = $translator; + public function __construct(private RollingDateConverterInterface $rollingDateConverter, private TranslatorInterface $translator) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserJobFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserJobFilter.php index 05d84d7b2..7e8a3ecc3 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserJobFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserJobFilter.php @@ -34,20 +34,8 @@ class UserJobFilter implements FilterInterface private const PJ = 'acp_ujob_filter_job'; - private RollingDateConverterInterface $rollingDateConverter; - - private TranslatableStringHelper $translatableStringHelper; - - private UserJobRepositoryInterface $userJobRepository; - - public function __construct( - TranslatableStringHelper $translatableStringHelper, - UserJobRepositoryInterface $userJobRepository, - RollingDateConverterInterface $rollingDateConverter - ) { - $this->translatableStringHelper = $translatableStringHelper; - $this->userJobRepository = $userJobRepository; - $this->rollingDateConverter = $rollingDateConverter; + public function __construct(private TranslatableStringHelper $translatableStringHelper, private UserJobRepositoryInterface $userJobRepository, private RollingDateConverterInterface $rollingDateConverter) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserScopeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserScopeFilter.php index bbffa4bca..58a935a0e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserScopeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserScopeFilter.php @@ -35,24 +35,8 @@ class UserScopeFilter implements FilterInterface private const PS = 'acp_uscope_filter_scopes'; - private RollingDateConverterInterface $rollingDateConverter; - - private ScopeRepositoryInterface $scopeRepository; - - private Security $security; - - private TranslatableStringHelper $translatableStringHelper; - - public function __construct( - ScopeRepositoryInterface $scopeRepository, - Security $security, - TranslatableStringHelper $translatableStringHelper, - RollingDateConverterInterface $rollingDateConverter - ) { - $this->scopeRepository = $scopeRepository; - $this->security = $security; - $this->translatableStringHelper = $translatableStringHelper; - $this->rollingDateConverter = $rollingDateConverter; + public function __construct(private ScopeRepositoryInterface $scopeRepository, private Security $security, private TranslatableStringHelper $translatableStringHelper, private RollingDateConverterInterface $rollingDateConverter) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/ByEndDateFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/ByEndDateFilter.php index de86604e6..553e58a39 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/ByEndDateFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/ByEndDateFilter.php @@ -21,11 +21,8 @@ use Symfony\Component\Form\FormBuilderInterface; class ByEndDateFilter implements FilterInterface { - private RollingDateConverterInterface $rollingDateConverter; - - public function __construct(RollingDateConverterInterface $rollingDateConverter) + public function __construct(private RollingDateConverterInterface $rollingDateConverter) { - $this->rollingDateConverter = $rollingDateConverter; } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/ByStartDateFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/ByStartDateFilter.php index 27518599c..7485020ce 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/ByStartDateFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/ByStartDateFilter.php @@ -21,11 +21,8 @@ use Symfony\Component\Form\FormBuilderInterface; class ByStartDateFilter implements FilterInterface { - private RollingDateConverterInterface $rollingDateConverter; - - public function __construct(RollingDateConverterInterface $rollingDateConverter) + public function __construct(private RollingDateConverterInterface $rollingDateConverter) { - $this->rollingDateConverter = $rollingDateConverter; } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/EvaluationTypeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/EvaluationTypeFilter.php index 6a0c71d55..1062b8a12 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/EvaluationTypeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/EvaluationTypeFilter.php @@ -22,12 +22,8 @@ use Symfony\Component\Form\FormBuilderInterface; final class EvaluationTypeFilter implements FilterInterface { - private TranslatableStringHelper $translatableStringHelper; - - public function __construct( - TranslatableStringHelper $translatableStringHelper - ) { - $this->translatableStringHelper = $translatableStringHelper; + public function __construct(private TranslatableStringHelper $translatableStringHelper) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/MaxDateFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/MaxDateFilter.php index 4a65452a1..1ca3f3f99 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/MaxDateFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/MaxDateFilter.php @@ -25,11 +25,8 @@ class MaxDateFilter implements FilterInterface 'maxdate is not specified' => false, ]; - private TranslatorInterface $translator; - - public function __construct(TranslatorInterface $translator) + public function __construct(private TranslatorInterface $translator) { - $this->translator = $translator; } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/HouseholdFilters/CompositionFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/HouseholdFilters/CompositionFilter.php index 22761c158..dcf98f307 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/HouseholdFilters/CompositionFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/HouseholdFilters/CompositionFilter.php @@ -26,16 +26,8 @@ use function in_array; class CompositionFilter implements FilterInterface { - private RollingDateConverterInterface $rollingDateConverter; - - private TranslatableStringHelper $translatableStringHelper; - - public function __construct( - TranslatableStringHelper $translatableStringHelper, - RollingDateConverterInterface $rollingDateConverter - ) { - $this->translatableStringHelper = $translatableStringHelper; - $this->rollingDateConverter = $rollingDateConverter; + public function __construct(private TranslatableStringHelper $translatableStringHelper, private RollingDateConverterInterface $rollingDateConverter) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AddressRefStatusFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AddressRefStatusFilter.php index 7580a37a3..b4001b3c4 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AddressRefStatusFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AddressRefStatusFilter.php @@ -24,13 +24,8 @@ use Symfony\Component\Form\FormBuilderInterface; class AddressRefStatusFilter implements \Chill\MainBundle\Export\FilterInterface { - private RollingDateConverterInterface $rollingDateConverter; - - - public function __construct( - RollingDateConverterInterface $rollingDateConverter - ) { - $this->rollingDateConverter = $rollingDateConverter; + public function __construct(private RollingDateConverterInterface $rollingDateConverter) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AgeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AgeFilter.php index c05f97ca8..da3c4a7f2 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AgeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AgeFilter.php @@ -26,11 +26,8 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface; class AgeFilter implements ExportElementValidatedInterface, FilterInterface { - private RollingDateConverterInterface $rollingDateConverter; - - public function __construct(RollingDateConverterInterface $rollingDateConverter) + public function __construct(private RollingDateConverterInterface $rollingDateConverter) { - $this->rollingDateConverter = $rollingDateConverter; } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/BirthdateFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/BirthdateFilter.php index 7ae22ddd8..46946e41e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/BirthdateFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/BirthdateFilter.php @@ -24,11 +24,8 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface; class BirthdateFilter implements ExportElementValidatedInterface, FilterInterface { - private RollingDateConverterInterface $rollingDateConverter; - - public function __construct(RollingDateConverterInterface $rollingDateConverter) + public function __construct(private RollingDateConverterInterface $rollingDateConverter) { - $this->rollingDateConverter = $rollingDateConverter; } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ByHouseholdCompositionFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ByHouseholdCompositionFilter.php index 9b59549f1..63ee441af 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ByHouseholdCompositionFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ByHouseholdCompositionFilter.php @@ -28,20 +28,8 @@ use Symfony\Component\Form\FormBuilderInterface; class ByHouseholdCompositionFilter implements FilterInterface { - private HouseholdCompositionTypeRepositoryInterface $householdCompositionTypeRepository; - - private RollingDateConverterInterface $rollingDateConverter; - - private TranslatableStringHelperInterface $translatableStringHelper; - - public function __construct( - HouseholdCompositionTypeRepositoryInterface $householdCompositionTypeRepository, - RollingDateConverterInterface $rollingDateConverter, - TranslatableStringHelperInterface $translatableStringHelper - ) { - $this->householdCompositionTypeRepository = $householdCompositionTypeRepository; - $this->rollingDateConverter = $rollingDateConverter; - $this->translatableStringHelper = $translatableStringHelper; + public function __construct(private HouseholdCompositionTypeRepositoryInterface $householdCompositionTypeRepository, private RollingDateConverterInterface $rollingDateConverter, private TranslatableStringHelperInterface $translatableStringHelper) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/DeadOrAliveFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/DeadOrAliveFilter.php index 384d6698a..7daf1c9e1 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/DeadOrAliveFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/DeadOrAliveFilter.php @@ -23,12 +23,8 @@ use Symfony\Component\Form\FormBuilderInterface; class DeadOrAliveFilter implements FilterInterface { - private RollingDateConverterInterface $rollingDateConverter; - - public function __construct( - RollingDateConverterInterface $rollingDateConverter - ) { - $this->rollingDateConverter = $rollingDateConverter; + public function __construct(private RollingDateConverterInterface $rollingDateConverter) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/DeathdateFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/DeathdateFilter.php index 0ac4b3173..04675054f 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/DeathdateFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/DeathdateFilter.php @@ -24,12 +24,8 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface; class DeathdateFilter implements ExportElementValidatedInterface, FilterInterface { - private RollingDateConverterInterface $rollingDateConverter; - - public function __construct( - RollingDateConverterInterface $rollingDateConverter - ) { - $this->rollingDateConverter = $rollingDateConverter; + public function __construct(private RollingDateConverterInterface $rollingDateConverter) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GeographicalUnitFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GeographicalUnitFilter.php index 79f5cb2d4..509bb3ab0 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GeographicalUnitFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GeographicalUnitFilter.php @@ -26,24 +26,8 @@ use Symfony\Component\Form\FormBuilderInterface; class GeographicalUnitFilter implements \Chill\MainBundle\Export\FilterInterface { - private GeographicalUnitLayerRepositoryInterface $geographicalUnitLayerRepository; - - private GeographicalUnitRepositoryInterface $geographicalUnitRepository; - - private RollingDateConverterInterface $rollingDateConverter; - - private TranslatableStringHelperInterface $translatableStringHelper; - - public function __construct( - GeographicalUnitRepositoryInterface $geographicalUnitRepository, - GeographicalUnitLayerRepositoryInterface $geographicalUnitLayerRepository, - TranslatableStringHelperInterface $translatableStringHelper, - RollingDateConverterInterface $rollingDateConverter - ) { - $this->geographicalUnitRepository = $geographicalUnitRepository; - $this->geographicalUnitLayerRepository = $geographicalUnitLayerRepository; - $this->translatableStringHelper = $translatableStringHelper; - $this->rollingDateConverter = $rollingDateConverter; + public function __construct(private GeographicalUnitRepositoryInterface $geographicalUnitRepository, private GeographicalUnitLayerRepositoryInterface $geographicalUnitLayerRepository, private TranslatableStringHelperInterface $translatableStringHelper, private RollingDateConverterInterface $rollingDateConverter) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/MaritalStatusFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/MaritalStatusFilter.php index 47a75871c..279b693f6 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/MaritalStatusFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/MaritalStatusFilter.php @@ -19,12 +19,8 @@ use Symfony\Bridge\Doctrine\Form\Type\EntityType; class MaritalStatusFilter implements FilterInterface { - private TranslatableStringHelper $translatableStringHelper; - - public function __construct( - TranslatableStringHelper $translatableStringHelper - ) { - $this->translatableStringHelper = $translatableStringHelper; + public function __construct(private TranslatableStringHelper $translatableStringHelper) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/NationalityFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/NationalityFilter.php index b1d77d60e..4463f433f 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/NationalityFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/NationalityFilter.php @@ -26,14 +26,8 @@ class NationalityFilter implements ExportElementValidatedInterface, FilterInterface { - /** - * @var TranslatableStringHelper - */ - private $translatableStringHelper; - - public function __construct(TranslatableStringHelper $helper) + public function __construct(private TranslatableStringHelper $translatableStringHelper) { - $this->translatableStringHelper = $helper; } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php index 21bb40947..4afc3fd71 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php @@ -27,16 +27,8 @@ use function in_array; class ResidentialAddressAtThirdpartyFilter implements FilterInterface { - private RollingDateConverterInterface $rollingDateConverter; - - private TranslatableStringHelper $translatableStringHelper; - - public function __construct( - RollingDateConverterInterface $rollingDateConverter, - TranslatableStringHelper $translatableStringHelper - ) { - $this->translatableStringHelper = $translatableStringHelper; - $this->rollingDateConverter = $rollingDateConverter; + public function __construct(private RollingDateConverterInterface $rollingDateConverter, private TranslatableStringHelper $translatableStringHelper) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtUserFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtUserFilter.php index bd55c5b80..e6b55904e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtUserFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtUserFilter.php @@ -24,12 +24,8 @@ use function in_array; class ResidentialAddressAtUserFilter implements FilterInterface { - private RollingDateConverterInterface $rollingDateConverter; - - public function __construct( - RollingDateConverterInterface $rollingDateConverter - ) { - $this->rollingDateConverter = $rollingDateConverter; + public function __construct(private RollingDateConverterInterface $rollingDateConverter) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/WithoutHouseholdComposition.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/WithoutHouseholdComposition.php index c4644fc11..702b8a7b0 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/WithoutHouseholdComposition.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/WithoutHouseholdComposition.php @@ -24,12 +24,8 @@ use Symfony\Component\Form\FormBuilderInterface; class WithoutHouseholdComposition implements FilterInterface { - private RollingDateConverterInterface $rollingDateConverter; - - public function __construct( - RollingDateConverterInterface $rollingDateConverter - ) { - $this->rollingDateConverter = $rollingDateConverter; + public function __construct(private RollingDateConverterInterface $rollingDateConverter) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/JobFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/JobFilter.php index 144bf3260..36b671d54 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/JobFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/JobFilter.php @@ -24,16 +24,8 @@ use function in_array; class JobFilter implements FilterInterface { - protected TranslatorInterface $translator; - - private TranslatableStringHelper $translatableStringHelper; - - public function __construct( - TranslatorInterface $translator, - TranslatableStringHelper $translatableStringHelper - ) { - $this->translator = $translator; - $this->translatableStringHelper = $translatableStringHelper; + public function __construct(protected TranslatorInterface $translator, private TranslatableStringHelper $translatableStringHelper) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ScopeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ScopeFilter.php index 315025722..f393354b1 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ScopeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ScopeFilter.php @@ -24,16 +24,8 @@ use function in_array; class ScopeFilter implements FilterInterface { - protected TranslatorInterface $translator; - - private TranslatableStringHelper $translatableStringHelper; - - public function __construct( - TranslatorInterface $translator, - TranslatableStringHelper $translatableStringHelper - ) { - $this->translator = $translator; - $this->translatableStringHelper = $translatableStringHelper; + public function __construct(protected TranslatorInterface $translator, private TranslatableStringHelper $translatableStringHelper) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/SocialWorkTypeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/SocialWorkTypeFilter.php index 11fd0ed9d..83fea8223 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/SocialWorkTypeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/SocialWorkTypeFilter.php @@ -28,20 +28,8 @@ use function in_array; class SocialWorkTypeFilter implements FilterInterface { - private EntityManagerInterface $em; - - private SocialActionRender $socialActionRender; - - private TranslatableStringHelper $translatableStringHelper; - - public function __construct( - SocialActionRender $socialActionRender, - TranslatableStringHelper $translatableStringHelper, - EntityManagerInterface $em - ) { - $this->socialActionRender = $socialActionRender; - $this->translatableStringHelper = $translatableStringHelper; - $this->em = $em; + public function __construct(private SocialActionRender $socialActionRender, private TranslatableStringHelper $translatableStringHelper, private EntityManagerInterface $em) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Export/Helper/LabelPersonHelper.php b/src/Bundle/ChillPersonBundle/Export/Helper/LabelPersonHelper.php index fc196dd50..5afde9986 100644 --- a/src/Bundle/ChillPersonBundle/Export/Helper/LabelPersonHelper.php +++ b/src/Bundle/ChillPersonBundle/Export/Helper/LabelPersonHelper.php @@ -18,14 +18,8 @@ use const SORT_NUMERIC; class LabelPersonHelper { - private PersonRenderInterface $personRender; - - private PersonRepository $personRepository; - - public function __construct(PersonRepository $personRepository, PersonRenderInterface $personRender) + public function __construct(private PersonRepository $personRepository, private PersonRenderInterface $personRender) { - $this->personRepository = $personRepository; - $this->personRender = $personRender; } public function getLabelMulti(string $key, array $values, string $header): callable diff --git a/src/Bundle/ChillPersonBundle/Export/Helper/ListPersonHelper.php b/src/Bundle/ChillPersonBundle/Export/Helper/ListPersonHelper.php index 77a1d9c86..600aaa60b 100644 --- a/src/Bundle/ChillPersonBundle/Export/Helper/ListPersonHelper.php +++ b/src/Bundle/ChillPersonBundle/Export/Helper/ListPersonHelper.php @@ -73,44 +73,8 @@ class ListPersonHelper 'lifecycleUpdate', ]; - private ExportAddressHelper $addressHelper; - - private CenterRepositoryInterface $centerRepository; - - private CivilityRepositoryInterface $civilityRepository; - - private CountryRepository $countryRepository; - - private LanguageRepositoryInterface $languageRepository; - - private MaritalStatusRepositoryInterface $maritalStatusRepository; - - private TranslatableStringHelper $translatableStringHelper; - - private TranslatorInterface $translator; - - private UserRepositoryInterface $userRepository; - - public function __construct( - ExportAddressHelper $addressHelper, - CenterRepositoryInterface $centerRepository, - CivilityRepositoryInterface $civilityRepository, - CountryRepository $countryRepository, - LanguageRepositoryInterface $languageRepository, - MaritalStatusRepositoryInterface $maritalStatusRepository, - TranslatableStringHelper $translatableStringHelper, - TranslatorInterface $translator, - UserRepositoryInterface $userRepository - ) { - $this->addressHelper = $addressHelper; - $this->centerRepository = $centerRepository; - $this->civilityRepository = $civilityRepository; - $this->countryRepository = $countryRepository; - $this->languageRepository = $languageRepository; - $this->maritalStatusRepository = $maritalStatusRepository; - $this->translatableStringHelper = $translatableStringHelper; - $this->translator = $translator; - $this->userRepository = $userRepository; + public function __construct(private ExportAddressHelper $addressHelper, private CenterRepositoryInterface $centerRepository, private CivilityRepositoryInterface $civilityRepository, private CountryRepository $countryRepository, private LanguageRepositoryInterface $languageRepository, private MaritalStatusRepositoryInterface $maritalStatusRepository, private TranslatableStringHelper $translatableStringHelper, private TranslatorInterface $translator, private UserRepositoryInterface $userRepository) + { } /** @@ -237,7 +201,7 @@ class ListPersonHelper public function getLabels($key, array $values, $data): callable { - if (substr($key, 0, strlen('address_fields')) === 'address_fields') { + if (str_starts_with($key, 'address_fields')) { return $this->addressHelper->getLabel($key, $values, $data, 'address_fields'); } diff --git a/src/Bundle/ChillPersonBundle/Form/ChoiceLoader/PersonChoiceLoader.php b/src/Bundle/ChillPersonBundle/Form/ChoiceLoader/PersonChoiceLoader.php index 03db7c156..05e720243 100644 --- a/src/Bundle/ChillPersonBundle/Form/ChoiceLoader/PersonChoiceLoader.php +++ b/src/Bundle/ChillPersonBundle/Form/ChoiceLoader/PersonChoiceLoader.php @@ -30,19 +30,15 @@ class PersonChoiceLoader implements ChoiceLoaderInterface protected array $lazyLoadedPersons = []; - protected PersonRepository $personRepository; - /** * PersonChoiceLoader constructor. * * @param EntityRepository $personRepository */ public function __construct( - PersonRepository $personRepository, + protected PersonRepository $personRepository, ?array $centers = null ) { - $this->personRepository = $personRepository; - if (null !== $centers) { $this->centers = $centers; } diff --git a/src/Bundle/ChillPersonBundle/Form/CreationPersonType.php b/src/Bundle/ChillPersonBundle/Form/CreationPersonType.php index 5548d6c5e..8f1f0ba43 100644 --- a/src/Bundle/ChillPersonBundle/Form/CreationPersonType.php +++ b/src/Bundle/ChillPersonBundle/Form/CreationPersonType.php @@ -42,17 +42,11 @@ final class CreationPersonType extends AbstractType private bool $askCenters; - private ConfigPersonAltNamesHelper $configPersonAltNamesHelper; - - private EventDispatcherInterface $dispatcher; - public function __construct( - ConfigPersonAltNamesHelper $configPersonAltNamesHelper, - EventDispatcherInterface $dispatcher, + private ConfigPersonAltNamesHelper $configPersonAltNamesHelper, + private EventDispatcherInterface $dispatcher, ParameterBagInterface $parameterBag ) { - $this->configPersonAltNamesHelper = $configPersonAltNamesHelper; - $this->dispatcher = $dispatcher; $this->askCenters = $parameterBag->get('chill_main')['acl']['form_show_centers']; } diff --git a/src/Bundle/ChillPersonBundle/Form/HouseholdCompositionType.php b/src/Bundle/ChillPersonBundle/Form/HouseholdCompositionType.php index a63b008c6..4dc2e1a73 100644 --- a/src/Bundle/ChillPersonBundle/Form/HouseholdCompositionType.php +++ b/src/Bundle/ChillPersonBundle/Form/HouseholdCompositionType.php @@ -22,14 +22,8 @@ use Symfony\Component\Form\FormBuilderInterface; class HouseholdCompositionType extends AbstractType { - private HouseholdCompositionTypeRepository $householdCompositionTypeRepository; - - private TranslatableStringHelperInterface $translatableStringHelper; - - public function __construct(HouseholdCompositionTypeRepository $householdCompositionTypeRepository, TranslatableStringHelperInterface $translatableStringHelper) + public function __construct(private HouseholdCompositionTypeRepository $householdCompositionTypeRepository, private TranslatableStringHelperInterface $translatableStringHelper) { - $this->householdCompositionTypeRepository = $householdCompositionTypeRepository; - $this->translatableStringHelper = $translatableStringHelper; } public function buildForm(FormBuilderInterface $builder, array $options) diff --git a/src/Bundle/ChillPersonBundle/Form/PersonResourceType.php b/src/Bundle/ChillPersonBundle/Form/PersonResourceType.php index 8427dec13..3790cb03a 100644 --- a/src/Bundle/ChillPersonBundle/Form/PersonResourceType.php +++ b/src/Bundle/ChillPersonBundle/Form/PersonResourceType.php @@ -29,20 +29,8 @@ use Symfony\Contracts\Translation\TranslatorInterface; final class PersonResourceType extends AbstractType { - private PersonRenderInterface $personRender; - - private ResourceKindRender $resourceKindRender; - - private ThirdPartyRender $thirdPartyRender; - - private TranslatorInterface $translator; - - public function __construct(ResourceKindRender $resourceKindRender, PersonRenderInterface $personRender, ThirdPartyRender $thirdPartyRender, TranslatorInterface $translator) + public function __construct(private ResourceKindRender $resourceKindRender, private PersonRenderInterface $personRender, private ThirdPartyRender $thirdPartyRender, private TranslatorInterface $translator) { - $this->resourceKindRender = $resourceKindRender; - $this->personRender = $personRender; - $this->thirdPartyRender = $thirdPartyRender; - $this->translator = $translator; } public function buildForm(FormBuilderInterface $builder, array $options) diff --git a/src/Bundle/ChillPersonBundle/Form/PersonType.php b/src/Bundle/ChillPersonBundle/Form/PersonType.php index 927812929..db5635f97 100644 --- a/src/Bundle/ChillPersonBundle/Form/PersonType.php +++ b/src/Bundle/ChillPersonBundle/Form/PersonType.php @@ -57,23 +57,17 @@ class PersonType extends AbstractType */ protected $configAltNamesHelper; - protected TranslatableStringHelper $translatableStringHelper; - - private ParameterBagInterface $parameterBag; - /** * @param string[] $personFieldsConfiguration configuration of visibility of some fields */ public function __construct( array $personFieldsConfiguration, ConfigPersonAltNamesHelper $configAltNamesHelper, - TranslatableStringHelperInterface $translatableStringHelper, - ParameterBagInterface $parameterBag + protected TranslatableStringHelperInterface $translatableStringHelper, + private ParameterBagInterface $parameterBag ) { $this->config = $personFieldsConfiguration; $this->configAltNamesHelper = $configAltNamesHelper; - $this->translatableStringHelper = $translatableStringHelper; - $this->parameterBag = $parameterBag; } public function buildForm(FormBuilderInterface $builder, array $options) diff --git a/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialIssueType.php b/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialIssueType.php index 0435b5573..cce3ca46d 100644 --- a/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialIssueType.php +++ b/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialIssueType.php @@ -23,12 +23,8 @@ use Symfony\Component\OptionsResolver\OptionsResolver; class SocialIssueType extends AbstractType { - protected TranslatableStringHelperInterface $translatableStringHelper; - - public function __construct( - TranslatableStringHelperInterface $translatableStringHelper - ) { - $this->translatableStringHelper = $translatableStringHelper; + public function __construct(protected TranslatableStringHelperInterface $translatableStringHelper) + { } public function buildForm(FormBuilderInterface $builder, array $options) diff --git a/src/Bundle/ChillPersonBundle/Form/Type/ClosingMotivePickerType.php b/src/Bundle/ChillPersonBundle/Form/Type/ClosingMotivePickerType.php index 240bcfbb4..49e23f7c6 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/ClosingMotivePickerType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/ClosingMotivePickerType.php @@ -78,10 +78,7 @@ class ClosingMotivePickerType extends AbstractType return 'closing_motive'; } - /** - * @return string|null - */ - public function getParent() + public function getParent(): ?string { return EntityType::class; } diff --git a/src/Bundle/ChillPersonBundle/Form/Type/PersonAltNameType.php b/src/Bundle/ChillPersonBundle/Form/Type/PersonAltNameType.php index e2f144b2a..0c7efe647 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/PersonAltNameType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/PersonAltNameType.php @@ -21,22 +21,8 @@ use Symfony\Component\OptionsResolver\OptionsResolver; class PersonAltNameType extends AbstractType { - /** - * @var ConfigPersonAltNamesHelper - */ - private $configHelper; - - /** - * @var TranslatableStringHelper - */ - private $translatableStringHelper; - - public function __construct( - ConfigPersonAltNamesHelper $configHelper, - TranslatableStringHelper $translatableStringHelper - ) { - $this->configHelper = $configHelper; - $this->translatableStringHelper = $translatableStringHelper; + public function __construct(private ConfigPersonAltNamesHelper $configHelper, private TranslatableStringHelper $translatableStringHelper) + { } public function buildForm(FormBuilderInterface $builder, array $options) diff --git a/src/Bundle/ChillPersonBundle/Form/Type/PersonPhoneType.php b/src/Bundle/ChillPersonBundle/Form/Type/PersonPhoneType.php index 1c31d2b64..db51d507a 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/PersonPhoneType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/PersonPhoneType.php @@ -24,14 +24,8 @@ use Symfony\Component\OptionsResolver\OptionsResolver; class PersonPhoneType extends AbstractType { - private EntityManagerInterface $em; - - private PhonenumberHelper $phonenumberHelper; - - public function __construct(PhonenumberHelper $phonenumberHelper, EntityManagerInterface $em) + public function __construct(private PhonenumberHelper $phonenumberHelper, private EntityManagerInterface $em) { - $this->phonenumberHelper = $phonenumberHelper; - $this->em = $em; } public function buildForm(FormBuilderInterface $builder, array $options) diff --git a/src/Bundle/ChillPersonBundle/Form/Type/PickPersonDynamicType.php b/src/Bundle/ChillPersonBundle/Form/Type/PickPersonDynamicType.php index 8ed0b7f37..4c3139c8e 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/PickPersonDynamicType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/PickPersonDynamicType.php @@ -26,20 +26,8 @@ use Symfony\Component\Serializer\SerializerInterface; */ class PickPersonDynamicType extends AbstractType { - private DenormalizerInterface $denormalizer; - - private NormalizerInterface $normalizer; - - private SerializerInterface $serializer; - - public function __construct( - DenormalizerInterface $denormalizer, - SerializerInterface $serializer, - NormalizerInterface $normalizer - ) { - $this->denormalizer = $denormalizer; - $this->serializer = $serializer; - $this->normalizer = $normalizer; + public function __construct(private DenormalizerInterface $denormalizer, private SerializerInterface $serializer, private NormalizerInterface $normalizer) + { } public function buildForm(FormBuilderInterface $builder, array $options) diff --git a/src/Bundle/ChillPersonBundle/Form/Type/PickSocialActionType.php b/src/Bundle/ChillPersonBundle/Form/Type/PickSocialActionType.php index fd947e9cd..b2e3c6d9b 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/PickSocialActionType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/PickSocialActionType.php @@ -20,16 +20,8 @@ use Symfony\Component\OptionsResolver\OptionsResolver; class PickSocialActionType extends AbstractType { - private SocialActionRender $actionRender; - - private SocialActionRepository $actionRepository; - - public function __construct( - SocialActionRender $actionRender, - SocialActionRepository $actionRepository - ) { - $this->actionRender = $actionRender; - $this->actionRepository = $actionRepository; + public function __construct(private SocialActionRender $actionRender, private SocialActionRepository $actionRepository) + { } public function configureOptions(OptionsResolver $resolver) diff --git a/src/Bundle/ChillPersonBundle/Form/Type/PickSocialIssueType.php b/src/Bundle/ChillPersonBundle/Form/Type/PickSocialIssueType.php index b560337ac..31cd44ab1 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/PickSocialIssueType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/PickSocialIssueType.php @@ -20,16 +20,8 @@ use Symfony\Component\OptionsResolver\OptionsResolver; class PickSocialIssueType extends AbstractType { - private SocialIssueRender $issueRender; - - private SocialIssueRepository $issueRepository; - - public function __construct( - SocialIssueRender $issueRender, - SocialIssueRepository $issueRepository - ) { - $this->issueRender = $issueRender; - $this->issueRepository = $issueRepository; + public function __construct(private SocialIssueRender $issueRender, private SocialIssueRepository $issueRepository) + { } public function configureOptions(OptionsResolver $resolver) diff --git a/src/Bundle/ChillPersonBundle/Form/Type/Select2MaritalStatusType.php b/src/Bundle/ChillPersonBundle/Form/Type/Select2MaritalStatusType.php index f057bc1d1..a4e6c46c9 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/Select2MaritalStatusType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/Select2MaritalStatusType.php @@ -28,14 +28,8 @@ use const SORT_STRING; */ class Select2MaritalStatusType extends AbstractType { - private EntityManagerInterface $em; - - private TranslatableStringHelper $translatableStringHelper; - - public function __construct(TranslatableStringHelper $translatableStringHelper, EntityManagerInterface $em) + public function __construct(private TranslatableStringHelper $translatableStringHelper, private EntityManagerInterface $em) { - $this->translatableStringHelper = $translatableStringHelper; - $this->em = $em; } public function buildForm(FormBuilderInterface $builder, array $options) diff --git a/src/Bundle/ChillPersonBundle/Household/MembersEditor.php b/src/Bundle/ChillPersonBundle/Household/MembersEditor.php index 2b2564091..92f1bba5c 100644 --- a/src/Bundle/ChillPersonBundle/Household/MembersEditor.php +++ b/src/Bundle/ChillPersonBundle/Household/MembersEditor.php @@ -34,25 +34,16 @@ class MembersEditor public const VALIDATION_GROUP_CREATED = 'household_memberships_created'; - private EventDispatcherInterface $eventDispatcher; - private array $events = []; - private ?Household $household = null; - private array $membershipsAffected = []; private array $oldMembershipsHashes = []; private array $persistables = []; - private ValidatorInterface $validator; - - public function __construct(ValidatorInterface $validator, ?Household $household, EventDispatcherInterface $eventDispatcher) + public function __construct(private ValidatorInterface $validator, private ?\Chill\PersonBundle\Entity\Household\Household $household, private EventDispatcherInterface $eventDispatcher) { - $this->validator = $validator; - $this->household = $household; - $this->eventDispatcher = $eventDispatcher; } public function addMovement(DateTimeImmutable $date, Person $person, ?Position $position, ?bool $holder = false, ?string $comment = null): self diff --git a/src/Bundle/ChillPersonBundle/Household/MembersEditorFactory.php b/src/Bundle/ChillPersonBundle/Household/MembersEditorFactory.php index 07a917d6b..9fae0dc82 100644 --- a/src/Bundle/ChillPersonBundle/Household/MembersEditorFactory.php +++ b/src/Bundle/ChillPersonBundle/Household/MembersEditorFactory.php @@ -17,16 +17,8 @@ use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; class MembersEditorFactory { - private EventDispatcherInterface $eventDispatcher; - - private ValidatorInterface $validator; - - public function __construct( - EventDispatcherInterface $eventDispatcher, - ValidatorInterface $validator - ) { - $this->validator = $validator; - $this->eventDispatcher = $eventDispatcher; + public function __construct(private EventDispatcherInterface $eventDispatcher, private ValidatorInterface $validator) + { } public function createEditor(?Household $household = null): MembersEditor diff --git a/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php b/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php index c956f78b6..79cd19db9 100644 --- a/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php +++ b/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php @@ -25,20 +25,14 @@ use Symfony\Contracts\Translation\TranslatorInterface; */ class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface { - protected Registry $registry; - - protected Security $security; - /** * @var TranslatorInterface */ protected $translator; - public function __construct(TranslatorInterface $translator, Registry $registry, Security $security) + public function __construct(TranslatorInterface $translator, protected Registry $registry, protected Security $security) { $this->translator = $translator; - $this->registry = $registry; - $this->security = $security; } public function buildMenu($menuId, MenuItem $menu, array $parameters): void diff --git a/src/Bundle/ChillPersonBundle/Menu/PersonMenuBuilder.php b/src/Bundle/ChillPersonBundle/Menu/PersonMenuBuilder.php index 39ac557fb..dde404de0 100644 --- a/src/Bundle/ChillPersonBundle/Menu/PersonMenuBuilder.php +++ b/src/Bundle/ChillPersonBundle/Menu/PersonMenuBuilder.php @@ -38,27 +38,17 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface */ protected $showAccompanyingPeriod; - protected TranslatorInterface $translator; - - private ResidentialAddressRepository $residentialAddressRepo; - - private Security $security; - public function __construct( ParameterBagInterface $parameterBag, - Security $security, - TranslatorInterface $translator, - ResidentialAddressRepository $residentialAddressRepo + private Security $security, + protected TranslatorInterface $translator, + private ResidentialAddressRepository $residentialAddressRepo ) { $this->showAccompanyingPeriod = $parameterBag->get('chill_person.accompanying_period'); - $this->security = $security; - $this->translator = $translator; - $this->residentialAddressRepo = $residentialAddressRepo; } /** * @param $menuId - * @param MenuItem $menu * @param array{person: Person} $parameters * @return void */ diff --git a/src/Bundle/ChillPersonBundle/Menu/SectionMenuBuilder.php b/src/Bundle/ChillPersonBundle/Menu/SectionMenuBuilder.php index 396d67912..acbdd6d3c 100644 --- a/src/Bundle/ChillPersonBundle/Menu/SectionMenuBuilder.php +++ b/src/Bundle/ChillPersonBundle/Menu/SectionMenuBuilder.php @@ -25,20 +25,11 @@ use Symfony\Contracts\Translation\TranslatorInterface; */ class SectionMenuBuilder implements LocalMenuBuilderInterface { - protected ParameterBagInterface $parameterBag; - - protected TranslatorInterface $translator; - - private Security $security; - /** * SectionMenuBuilder constructor. */ - public function __construct(ParameterBagInterface $parameterBag, Security $security, TranslatorInterface $translator) + public function __construct(protected ParameterBagInterface $parameterBag, private Security $security, protected TranslatorInterface $translator) { - $this->parameterBag = $parameterBag; - $this->security = $security; - $this->translator = $translator; } /** diff --git a/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodNotificationHandler.php b/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodNotificationHandler.php index 486209453..85e18633d 100644 --- a/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodNotificationHandler.php +++ b/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodNotificationHandler.php @@ -18,11 +18,8 @@ use Chill\PersonBundle\Repository\AccompanyingPeriodRepository; final class AccompanyingPeriodNotificationHandler implements NotificationHandlerInterface { - private AccompanyingPeriodRepository $accompanyingPeriodRepository; - - public function __construct(AccompanyingPeriodRepository $accompanyingPeriodRepository) + public function __construct(private AccompanyingPeriodRepository $accompanyingPeriodRepository) { - $this->accompanyingPeriodRepository = $accompanyingPeriodRepository; } public function getTemplate(Notification $notification, array $options = []): string diff --git a/src/Bundle/ChillPersonBundle/Privacy/AccompanyingPeriodPrivacyEvent.php b/src/Bundle/ChillPersonBundle/Privacy/AccompanyingPeriodPrivacyEvent.php index eb22a671d..957461b55 100644 --- a/src/Bundle/ChillPersonBundle/Privacy/AccompanyingPeriodPrivacyEvent.php +++ b/src/Bundle/ChillPersonBundle/Privacy/AccompanyingPeriodPrivacyEvent.php @@ -38,14 +38,8 @@ class AccompanyingPeriodPrivacyEvent extends Event { public const ACCOMPANYING_PERIOD_PRIVACY_EVENT = 'chill_person.accompanying_period_privacy_event'; - protected array $args; - - protected AccompanyingPeriod $period; - - public function __construct($period, $args = []) + public function __construct(protected $period, protected $args = []) { - $this->period = $period; - $this->args = $args; } public function getArgs(): array diff --git a/src/Bundle/ChillPersonBundle/Privacy/PrivacyEvent.php b/src/Bundle/ChillPersonBundle/Privacy/PrivacyEvent.php index b691c4e89..27861944c 100644 --- a/src/Bundle/ChillPersonBundle/Privacy/PrivacyEvent.php +++ b/src/Bundle/ChillPersonBundle/Privacy/PrivacyEvent.php @@ -46,16 +46,6 @@ class PrivacyEvent extends Event { public const PERSON_PRIVACY_EVENT = 'chill_person.privacy_event'; - /** - * @var array - */ - private $args; - - /** - * @var Person - */ - private $person; - /** * @var array */ @@ -64,10 +54,8 @@ class PrivacyEvent extends Event /** * PrivacyEvent constructor. */ - public function __construct(Person $person, array $args = ['action' => 'show']) + public function __construct(private Person $person, private array $args = ['action' => 'show']) { - $this->person = $person; - $this->args = $args; } public function addPerson(Person $person) diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php index bf2d34aae..85c382a49 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php @@ -25,14 +25,11 @@ use Doctrine\Persistence\ObjectRepository; final class AccompanyingPeriodWorkRepository implements ObjectRepository { - private EntityManagerInterface $em; - private EntityRepository $repository; - public function __construct(EntityManagerInterface $entityManager) + public function __construct(private EntityManagerInterface $em) { - $this->em = $entityManager; - $this->repository = $entityManager->getRepository(AccompanyingPeriodWork::class); + $this->repository = $em->getRepository(AccompanyingPeriodWork::class); } public function countByAccompanyingPeriod(AccompanyingPeriod $period): int diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/ClosingMotiveRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/ClosingMotiveRepository.php index 6422c7e0e..7983596c7 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/ClosingMotiveRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/ClosingMotiveRepository.php @@ -18,13 +18,10 @@ use Doctrine\ORM\Query\ResultSetMappingBuilder; final class ClosingMotiveRepository implements ClosingMotiveRepositoryInterface { - private EntityManagerInterface $entityManager; - private EntityRepository $repository; - public function __construct(EntityManagerInterface $entityManager) + public function __construct(private EntityManagerInterface $entityManager) { - $this->entityManager = $entityManager; $this->repository = $entityManager->getRepository(ClosingMotive::class); } diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php index 0aaabd05f..2b70da0a1 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php @@ -35,24 +35,8 @@ use function count; final class AccompanyingPeriodACLAwareRepository implements AccompanyingPeriodACLAwareRepositoryInterface { - private AccompanyingPeriodRepository $accompanyingPeriodRepository; - - private AuthorizationHelper $authorizationHelper; - - private CenterResolverDispatcherInterface $centerResolverDispatcher; - - private Security $security; - - public function __construct( - AccompanyingPeriodRepository $accompanyingPeriodRepository, - Security $security, - AuthorizationHelper $authorizationHelper, - CenterResolverDispatcherInterface $centerResolverDispatcher - ) { - $this->accompanyingPeriodRepository = $accompanyingPeriodRepository; - $this->security = $security; - $this->authorizationHelper = $authorizationHelper; - $this->centerResolverDispatcher = $centerResolverDispatcher; + public function __construct(private AccompanyingPeriodRepository $accompanyingPeriodRepository, private Security $security, private AuthorizationHelper $authorizationHelper, private CenterResolverDispatcherInterface $centerResolverDispatcher) + { } /** diff --git a/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdACLAwareRepository.php b/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdACLAwareRepository.php index a8cc9d069..33a17dfa1 100644 --- a/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdACLAwareRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdACLAwareRepository.php @@ -22,17 +22,8 @@ use Symfony\Component\Security\Core\Security; final class HouseholdACLAwareRepository implements HouseholdACLAwareRepositoryInterface { - private AuthorizationHelper $authorizationHelper; - - private EntityManagerInterface $em; - - private Security $security; - - public function __construct(EntityManagerInterface $em, AuthorizationHelper $authorizationHelper, Security $security) + public function __construct(private EntityManagerInterface $em, private AuthorizationHelper $authorizationHelper, private Security $security) { - $this->em = $em; - $this->authorizationHelper = $authorizationHelper; - $this->security = $security; } public function addACL(QueryBuilder $qb, string $alias = 'h'): QueryBuilder diff --git a/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepository.php b/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepository.php index 30c79147c..dd82b6b96 100644 --- a/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepository.php @@ -34,24 +34,8 @@ use function implode; final class PersonACLAwareRepository implements PersonACLAwareRepositoryInterface { - private AuthorizationHelperInterface $authorizationHelper; - - private CountryRepository $countryRepository; - - private EntityManagerInterface $em; - - private Security $security; - - public function __construct( - Security $security, - EntityManagerInterface $em, - CountryRepository $countryRepository, - AuthorizationHelperInterface $authorizationHelper - ) { - $this->security = $security; - $this->em = $em; - $this->countryRepository = $countryRepository; - $this->authorizationHelper = $authorizationHelper; + public function __construct(private Security $security, private EntityManagerInterface $em, private CountryRepository $countryRepository, private AuthorizationHelperInterface $authorizationHelper) + { } public function buildAuthorizedQuery( diff --git a/src/Bundle/ChillPersonBundle/Search/PersonSearch.php b/src/Bundle/ChillPersonBundle/Search/PersonSearch.php index dabc79475..05b55dd23 100644 --- a/src/Bundle/ChillPersonBundle/Search/PersonSearch.php +++ b/src/Bundle/ChillPersonBundle/Search/PersonSearch.php @@ -45,28 +45,8 @@ class PersonSearch extends AbstractSearch implements HasAdvancedSearchFormInterf 'birthdate-after', 'gender', 'nationality', 'phonenumber', 'city', ]; - private ExtractDateFromPattern $extractDateFromPattern; - - private ExtractPhonenumberFromPattern $extractPhonenumberFromPattern; - - private PaginatorFactory $paginatorFactory; - - private PersonACLAwareRepositoryInterface $personACLAwareRepository; - - private EngineInterface $templating; - - public function __construct( - EngineInterface $templating, - ExtractDateFromPattern $extractDateFromPattern, - ExtractPhonenumberFromPattern $extractPhonenumberFromPattern, - PaginatorFactory $paginatorFactory, - PersonACLAwareRepositoryInterface $personACLAwareRepository - ) { - $this->templating = $templating; - $this->extractDateFromPattern = $extractDateFromPattern; - $this->extractPhonenumberFromPattern = $extractPhonenumberFromPattern; - $this->paginatorFactory = $paginatorFactory; - $this->personACLAwareRepository = $personACLAwareRepository; + public function __construct(private EngineInterface $templating, private ExtractDateFromPattern $extractDateFromPattern, private ExtractPhonenumberFromPattern $extractPhonenumberFromPattern, private PaginatorFactory $paginatorFactory, private PersonACLAwareRepositoryInterface $personACLAwareRepository) + { } public function buildForm(FormBuilderInterface $builder) @@ -121,7 +101,7 @@ class PersonSearch extends AbstractSearch implements HasAdvancedSearchFormInterf foreach (['firstname', 'lastname', 'gender', 'city'] as $key) { $string .= !isset($data[$key]) ? '' : $key . ':' . // add quote if contains spaces - (strpos($data[$key], ' ') !== false ? '"' . $data[$key] . '"' : $data[$key]) + (str_contains($data[$key], ' ') ? '"' . $data[$key] . '"' : $data[$key]) . ' '; } diff --git a/src/Bundle/ChillPersonBundle/Search/SearchHouseholdApiProvider.php b/src/Bundle/ChillPersonBundle/Search/SearchHouseholdApiProvider.php index 819554252..5dcb3e7b3 100644 --- a/src/Bundle/ChillPersonBundle/Search/SearchHouseholdApiProvider.php +++ b/src/Bundle/ChillPersonBundle/Search/SearchHouseholdApiProvider.php @@ -26,32 +26,8 @@ use function in_array; class SearchHouseholdApiProvider implements SearchApiInterface { - private AuthorizationHelperInterface $authorizationHelper; - - private ExtractDateFromPattern $extractDateFromPattern; - - private ExtractPhonenumberFromPattern $extractPhonenumberFromPattern; - - private HouseholdRepository $householdRepository; - - private PersonACLAwareRepositoryInterface $personACLAwareRepository; - - private Security $security; - - public function __construct( - HouseholdRepository $householdRepository, - PersonACLAwareRepositoryInterface $personACLAwareRepository, - Security $security, - AuthorizationHelperInterface $authorizationHelper, - ExtractDateFromPattern $extractDateFromPattern, - ExtractPhonenumberFromPattern $extractPhonenumberFromPattern - ) { - $this->householdRepository = $householdRepository; - $this->personACLAwareRepository = $personACLAwareRepository; - $this->security = $security; - $this->authorizationHelper = $authorizationHelper; - $this->extractDateFromPattern = $extractDateFromPattern; - $this->extractPhonenumberFromPattern = $extractPhonenumberFromPattern; + public function __construct(private HouseholdRepository $householdRepository, private PersonACLAwareRepositoryInterface $personACLAwareRepository, private Security $security, private AuthorizationHelperInterface $authorizationHelper, private ExtractDateFromPattern $extractDateFromPattern, private ExtractPhonenumberFromPattern $extractPhonenumberFromPattern) + { } public function getResult(string $key, array $metadata, float $pertinence) diff --git a/src/Bundle/ChillPersonBundle/Search/SearchPersonApiProvider.php b/src/Bundle/ChillPersonBundle/Search/SearchPersonApiProvider.php index cbf77910b..9e2e9d6f5 100644 --- a/src/Bundle/ChillPersonBundle/Search/SearchPersonApiProvider.php +++ b/src/Bundle/ChillPersonBundle/Search/SearchPersonApiProvider.php @@ -26,32 +26,8 @@ use function in_array; class SearchPersonApiProvider implements SearchApiInterface { - private AuthorizationHelperInterface $authorizationHelper; - - private ExtractDateFromPattern $extractDateFromPattern; - - private ExtractPhonenumberFromPattern $extractPhonenumberFromPattern; - - private PersonACLAwareRepositoryInterface $personACLAwareRepository; - - private PersonRepository $personRepository; - - private Security $security; - - public function __construct( - PersonRepository $personRepository, - PersonACLAwareRepositoryInterface $personACLAwareRepository, - Security $security, - AuthorizationHelperInterface $authorizationHelper, - ExtractDateFromPattern $extractDateFromPattern, - ExtractPhonenumberFromPattern $extractPhonenumberFromPattern - ) { - $this->personRepository = $personRepository; - $this->personACLAwareRepository = $personACLAwareRepository; - $this->security = $security; - $this->authorizationHelper = $authorizationHelper; - $this->extractDateFromPattern = $extractDateFromPattern; - $this->extractPhonenumberFromPattern = $extractPhonenumberFromPattern; + public function __construct(private PersonRepository $personRepository, private PersonACLAwareRepositoryInterface $personACLAwareRepository, private Security $security, private AuthorizationHelperInterface $authorizationHelper, private ExtractDateFromPattern $extractDateFromPattern, private ExtractPhonenumberFromPattern $extractPhonenumberFromPattern) + { } public function getResult(string $key, array $metadata, float $pertinence) diff --git a/src/Bundle/ChillPersonBundle/Search/SimilarPersonMatcher.php b/src/Bundle/ChillPersonBundle/Search/SimilarPersonMatcher.php index c77c0758e..4da00c5fa 100644 --- a/src/Bundle/ChillPersonBundle/Search/SimilarPersonMatcher.php +++ b/src/Bundle/ChillPersonBundle/Search/SimilarPersonMatcher.php @@ -37,10 +37,6 @@ class SimilarPersonMatcher */ protected $em; - protected PersonNotDuplicateRepository $personNotDuplicateRepository; - - protected PersonRenderInterface $personRender; - /** * @var TokenStorageInterface */ @@ -50,14 +46,12 @@ class SimilarPersonMatcher EntityManagerInterface $em, AuthorizationHelper $authorizationHelper, TokenStorageInterface $tokenStorage, - PersonNotDuplicateRepository $personNotDuplicateRepository, - PersonRenderInterface $personRender + protected PersonNotDuplicateRepository $personNotDuplicateRepository, + protected PersonRenderInterface $personRender ) { $this->em = $em; $this->authorizationHelper = $authorizationHelper; $this->tokenStorage = $tokenStorage; - $this->personNotDuplicateRepository = $personNotDuplicateRepository; - $this->personRender = $personRender; } public function matchPerson( diff --git a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodCommentVoter.php b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodCommentVoter.php index 1174bc2a0..e8a06a8b3 100644 --- a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodCommentVoter.php +++ b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodCommentVoter.php @@ -23,11 +23,8 @@ class AccompanyingPeriodCommentVoter extends Voter public const EDIT = 'CHILL_PERSON_ACCOMPANYING_PERIOD_COMMENT_EDIT'; - private Security $security; - - public function __construct(Security $security) + public function __construct(private Security $security) { - $this->security = $security; } protected function supports($attribute, $subject) @@ -37,16 +34,10 @@ class AccompanyingPeriodCommentVoter extends Voter protected function voteOnAttribute($attribute, $subject, TokenInterface $token) { - /** @var Comment $subject */ - switch ($attribute) { - case self::EDIT: - return $this->security->isGranted(AccompanyingPeriodVoter::EDIT, $subject->getAccompanyingPeriod()); - - case self::DELETE: - return $this->security->isGranted(AccompanyingPeriodVoter::EDIT, $subject->getAccompanyingPeriod()); - - default: - throw new UnexpectedValueException("This attribute {$attribute} is not supported"); - } + return match ($attribute) { + self::EDIT => $this->security->isGranted(AccompanyingPeriodVoter::EDIT, $subject->getAccompanyingPeriod()), + self::DELETE => $this->security->isGranted(AccompanyingPeriodVoter::EDIT, $subject->getAccompanyingPeriod()), + default => throw new UnexpectedValueException("This attribute {$attribute} is not supported"), + }; } } diff --git a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodResourceVoter.php b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodResourceVoter.php index 9ffd90efa..432c142fe 100644 --- a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodResourceVoter.php +++ b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodResourceVoter.php @@ -21,11 +21,8 @@ class AccompanyingPeriodResourceVoter extends Voter { public const EDIT = 'CHILL_PERSON_ACCOMPANYING_PERIOD_RESOURCE_EDIT'; - private AccessDecisionManagerInterface $accessDecisionManager; - - public function __construct(AccessDecisionManagerInterface $accessDecisionManager) + public function __construct(private AccessDecisionManagerInterface $accessDecisionManager) { - $this->accessDecisionManager = $accessDecisionManager; } protected function supports($attribute, $subject) @@ -35,17 +32,13 @@ class AccompanyingPeriodResourceVoter extends Voter protected function voteOnAttribute($attribute, $subject, TokenInterface $token) { - /** @var \Chill\PersonBundle\Entity\AccompanyingPeriod\Resource $subject */ - switch ($attribute) { - case self::EDIT: - return $this->accessDecisionManager->decide( - $token, - [AccompanyingPeriodVoter::EDIT], - $subject->getAccompanyingPeriod() - ); - - default: - throw new UnexpectedValueException("attribute not supported: {$attribute}"); - } + return match ($attribute) { + self::EDIT => $this->accessDecisionManager->decide( + $token, + [AccompanyingPeriodVoter::EDIT], + $subject->getAccompanyingPeriod() + ), + default => throw new UnexpectedValueException("attribute not supported: {$attribute}"), + }; } } diff --git a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php index ea32326a4..817873738 100644 --- a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php +++ b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php @@ -106,15 +106,12 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH */ public const TOGGLE_INTENSITY = 'CHILL_PERSON_ACCOMPANYING_PERIOD_TOGGLE_INTENSITY'; - private Security $security; - private VoterHelperInterface $voterHelper; public function __construct( - Security $security, + private Security $security, VoterHelperFactoryInterface $voterHelperFactory ) { - $this->security = $security; $this->voterHelper = $voterHelperFactory ->generate(self::class) ->addCheckFor(null, [self::CREATE, self::REASSIGN_BULK]) diff --git a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodWorkEvaluationDocumentVoter.php b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodWorkEvaluationDocumentVoter.php index 98de820da..8591a044f 100644 --- a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodWorkEvaluationDocumentVoter.php +++ b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodWorkEvaluationDocumentVoter.php @@ -26,11 +26,8 @@ class AccompanyingPeriodWorkEvaluationDocumentVoter extends Voter { public const SEE = 'CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_EVALUATION_DOCUMENT_SHOW'; - private AccessDecisionManagerInterface $accessDecisionManager; - - public function __construct(AccessDecisionManagerInterface $accessDecisionManager) + public function __construct(private AccessDecisionManagerInterface $accessDecisionManager) { - $this->accessDecisionManager = $accessDecisionManager; } protected function supports($attribute, $subject) @@ -47,16 +44,13 @@ class AccompanyingPeriodWorkEvaluationDocumentVoter extends Voter */ protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool { - switch ($attribute) { - case self::SEE: - return $this->accessDecisionManager->decide( - $token, - [AccompanyingPeriodWorkEvaluationVoter::SEE], - $subject->getAccompanyingPeriodWorkEvaluation() - ); - - default: - throw new UnexpectedValueException("The attribute {$attribute} is not supported"); - } + return match ($attribute) { + self::SEE => $this->accessDecisionManager->decide( + $token, + [AccompanyingPeriodWorkEvaluationVoter::SEE], + $subject->getAccompanyingPeriodWorkEvaluation() + ), + default => throw new UnexpectedValueException("The attribute {$attribute} is not supported"), + }; } } diff --git a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodWorkEvaluationVoter.php b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodWorkEvaluationVoter.php index cfa867266..955d199ff 100644 --- a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodWorkEvaluationVoter.php +++ b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodWorkEvaluationVoter.php @@ -30,11 +30,8 @@ class AccompanyingPeriodWorkEvaluationVoter extends Voter implements ChillVoterI public const STATS = 'CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_EVALUATION_STATS'; - private Security $security; - - public function __construct(Security $security) + public function __construct(private Security $security) { - $this->security = $security; } protected function supports($attribute, $subject) @@ -49,15 +46,10 @@ class AccompanyingPeriodWorkEvaluationVoter extends Voter implements ChillVoterI */ protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool { - switch ($attribute) { - case self::STATS: - return $this->security->isGranted(AccompanyingPeriodVoter::STATS, $subject); - - case self::SEE: - return $this->security->isGranted(AccompanyingPeriodWorkVoter::SEE, $subject->getAccompanyingPeriodWork()); - - default: - throw new UnexpectedValueException("attribute {$attribute} is not supported"); - } + return match ($attribute) { + self::STATS => $this->security->isGranted(AccompanyingPeriodVoter::STATS, $subject), + self::SEE => $this->security->isGranted(AccompanyingPeriodWorkVoter::SEE, $subject->getAccompanyingPeriodWork()), + default => throw new UnexpectedValueException("attribute {$attribute} is not supported"), + }; } } diff --git a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodWorkVoter.php b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodWorkVoter.php index 84f31c202..43a99e7e1 100644 --- a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodWorkVoter.php +++ b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodWorkVoter.php @@ -42,15 +42,12 @@ class AccompanyingPeriodWorkVoter extends Voter implements ProvideRoleHierarchyI public const UPDATE = 'CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_UPDATE'; - private Security $security; - private VoterHelperInterface $voterHelper; public function __construct( - Security $security, + private Security $security, VoterHelperFactoryInterface $voterHelperFactory ) { - $this->security = $security; $this->voterHelper = $voterHelperFactory ->generate(self::class) ->addCheckFor(null, [self::CREATE]) @@ -98,34 +95,22 @@ class AccompanyingPeriodWorkVoter extends Voter implements ProvideRoleHierarchyI protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool { if ($subject instanceof AccompanyingPeriodWork) { - switch ($attribute) { - case self::SEE: - return $this->security->isGranted(AccompanyingPeriodVoter::SEE_DETAILS, $subject->getAccompanyingPeriod()); - - case self::CREATE: - case self::UPDATE: - case self::DELETE: - return $this->security->isGranted(AccompanyingPeriodVoter::EDIT, $subject->getAccompanyingPeriod()); - - default: - throw new UnexpectedValueException("attribute {$attribute} is not supported"); - } + return match ($attribute) { + self::SEE => $this->security->isGranted(AccompanyingPeriodVoter::SEE_DETAILS, $subject->getAccompanyingPeriod()), + self::CREATE, self::UPDATE, self::DELETE => $this->security->isGranted(AccompanyingPeriodVoter::EDIT, $subject->getAccompanyingPeriod()), + default => throw new UnexpectedValueException("attribute {$attribute} is not supported"), + }; } elseif ($subject instanceof AccompanyingPeriod) { - switch ($attribute) { - case self::SEE: - return $this->security->isGranted(AccompanyingPeriodVoter::SEE_DETAILS, $subject); - - case self::CREATE: - return $this->security->isGranted(AccompanyingPeriodVoter::CREATE, $subject); - - default: - throw new UnexpectedValueException(sprintf( - "attribute {$attribute} is not supported on instance %s", - AccompanyingPeriod::class - )); - } + return match ($attribute) { + self::SEE => $this->security->isGranted(AccompanyingPeriodVoter::SEE_DETAILS, $subject), + self::CREATE => $this->security->isGranted(AccompanyingPeriodVoter::CREATE, $subject), + default => throw new UnexpectedValueException(sprintf( + "attribute {$attribute} is not supported on instance %s", + AccompanyingPeriod::class + )), + }; } - throw new UnexpectedValueException(sprintf("attribute {$attribute} on instance %s is not supported", get_class($subject))); + throw new UnexpectedValueException(sprintf("attribute {$attribute} on instance %s is not supported", $subject::class)); } } diff --git a/src/Bundle/ChillPersonBundle/Security/Authorization/HouseholdVoter.php b/src/Bundle/ChillPersonBundle/Security/Authorization/HouseholdVoter.php index 6ba1ac1a9..74eee07f6 100644 --- a/src/Bundle/ChillPersonBundle/Security/Authorization/HouseholdVoter.php +++ b/src/Bundle/ChillPersonBundle/Security/Authorization/HouseholdVoter.php @@ -45,11 +45,8 @@ class HouseholdVoter extends Voter implements ProvideRoleHierarchyInterface, Chi private VoterHelperInterface $helper; - private Security $security; - - public function __construct(Security $security, VoterHelperFactoryInterface $voterHelperFactory) + public function __construct(private Security $security, VoterHelperFactoryInterface $voterHelperFactory) { - $this->security = $security; $this->helper = $voterHelperFactory ->generate(self::class) ->addCheckFor(Center::class, [self::STATS]) @@ -80,19 +77,12 @@ class HouseholdVoter extends Voter implements ProvideRoleHierarchyInterface, Chi protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool { - switch ($attribute) { - case self::SEE: - return $this->checkAssociatedMembersRole($subject, PersonVoter::SEE); - - case self::EDIT: - return $this->checkAssociatedMembersRole($subject, PersonVoter::UPDATE); - - case self::STATS: - return $this->voteOnAttribute($attribute, $subject, $token); - - default: - throw new UnexpectedValueException('attribute not supported'); - } + return match ($attribute) { + self::SEE => $this->checkAssociatedMembersRole($subject, PersonVoter::SEE), + self::EDIT => $this->checkAssociatedMembersRole($subject, PersonVoter::UPDATE), + self::STATS => $this->voteOnAttribute($attribute, $subject, $token), + default => throw new UnexpectedValueException('attribute not supported'), + }; } private function checkAssociatedMembersRole(Household $household, string $attribute): bool diff --git a/src/Bundle/ChillPersonBundle/Security/AuthorizedCenterOnPersonCreation.php b/src/Bundle/ChillPersonBundle/Security/AuthorizedCenterOnPersonCreation.php index 1244f921f..8b649f8f0 100644 --- a/src/Bundle/ChillPersonBundle/Security/AuthorizedCenterOnPersonCreation.php +++ b/src/Bundle/ChillPersonBundle/Security/AuthorizedCenterOnPersonCreation.php @@ -17,13 +17,10 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; class AuthorizedCenterOnPersonCreation implements AuthorizedCenterOnPersonCreationInterface { - private AuthorizationHelperForCurrentUserInterface $authorizationHelperForCurrentUser; - private bool $showCenters; - public function __construct(AuthorizationHelperForCurrentUserInterface $authorizationHelperForCurrentUser, ParameterBagInterface $parameterBag) + public function __construct(private AuthorizationHelperForCurrentUserInterface $authorizationHelperForCurrentUser, ParameterBagInterface $parameterBag) { - $this->authorizationHelperForCurrentUser = $authorizationHelperForCurrentUser; $this->showCenters = $parameterBag->get('chill_main')['acl']['form_show_centers']; } diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodDocGenNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodDocGenNormalizer.php index bc13dec66..0bb3d68b6 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodDocGenNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodDocGenNormalizer.php @@ -74,28 +74,8 @@ class AccompanyingPeriodDocGenNormalizer implements ContextAwareNormalizerInterf 'pinnedComment' => AccompanyingPeriod\Comment::class, ]; - private ClosingMotiveRender $closingMotiveRender; - - private ScopeResolverDispatcher $scopeResolverDispatcher; - - private SocialIssueRender $socialIssueRender; - - private TranslatableStringHelper $translatableStringHelper; - - private TranslatorInterface $translator; - - public function __construct( - TranslatorInterface $translator, - TranslatableStringHelper $translatableStringHelper, - SocialIssueRender $socialIssueRender, - ClosingMotiveRender $closingMotiveRender, - ScopeResolverDispatcher $scopeResolverDispatcher - ) { - $this->translator = $translator; - $this->translatableStringHelper = $translatableStringHelper; - $this->socialIssueRender = $socialIssueRender; - $this->closingMotiveRender = $closingMotiveRender; - $this->scopeResolverDispatcher = $scopeResolverDispatcher; + public function __construct(private TranslatorInterface $translator, private TranslatableStringHelper $translatableStringHelper, private SocialIssueRender $socialIssueRender, private ClosingMotiveRender $closingMotiveRender, private ScopeResolverDispatcher $scopeResolverDispatcher) + { } /** diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodResourceNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodResourceNormalizer.php index 665671145..c2a723274 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodResourceNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodResourceNormalizer.php @@ -32,11 +32,8 @@ class AccompanyingPeriodResourceNormalizer implements DenormalizerAwareInterface use ObjectToPopulateTrait; - private ResourceRepository $repository; - - public function __construct(ResourceRepository $repository) + public function __construct(private ResourceRepository $repository) { - $this->repository = $repository; } public function denormalize($data, $type, $format = null, array $context = []) diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkDenormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkDenormalizer.php index 4d9cfceca..e0697a6fd 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkDenormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkDenormalizer.php @@ -40,16 +40,8 @@ class AccompanyingPeriodWorkDenormalizer implements ContextAwareDenormalizerInte public const GROUP_EDIT = 'accompanying_period_work:edit'; - private EntityManagerInterface $em; - - private AccompanyingPeriodWorkRepository $workRepository; - - public function __construct( - AccompanyingPeriodWorkRepository $workRepository, - EntityManagerInterface $em - ) { - $this->workRepository = $workRepository; - $this->em = $em; + public function __construct(private AccompanyingPeriodWorkRepository $workRepository, private EntityManagerInterface $em) + { } public function denormalize($data, $type, $format = null, array $context = []) diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationDocumentNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationDocumentNormalizer.php index fb87df96c..7850cc1c8 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationDocumentNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationDocumentNormalizer.php @@ -26,17 +26,8 @@ class AccompanyingPeriodWorkEvaluationDocumentNormalizer implements ContextAware private const SKIP = 'accompanying_period_work_evaluation_document_skip'; - private EntityWorkflowRepository $entityWorkflowRepository; - - private MetadataExtractor $metadataExtractor; - - private Registry $registry; - - public function __construct(EntityWorkflowRepository $entityWorkflowRepository, MetadataExtractor $metadataExtractor, Registry $registry) + public function __construct(private EntityWorkflowRepository $entityWorkflowRepository, private MetadataExtractor $metadataExtractor, private Registry $registry) { - $this->entityWorkflowRepository = $entityWorkflowRepository; - $this->metadataExtractor = $metadataExtractor; - $this->registry = $registry; } public function normalize($object, ?string $format = null, array $context = []): array diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationNormalizer.php index a0268ae31..512dc6370 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationNormalizer.php @@ -27,17 +27,8 @@ class AccompanyingPeriodWorkEvaluationNormalizer implements ContextAwareNormaliz private const IGNORE_EVALUATION = 'evaluation:ignore'; - private EntityWorkflowRepository $entityWorkflowRepository; - - private MetadataExtractor $metadataExtractor; - - private Registry $registry; - - public function __construct(Registry $registry, EntityWorkflowRepository $entityWorkflowRepository, MetadataExtractor $metadataExtractor) + public function __construct(private Registry $registry, private EntityWorkflowRepository $entityWorkflowRepository, private MetadataExtractor $metadataExtractor) { - $this->registry = $registry; - $this->entityWorkflowRepository = $entityWorkflowRepository; - $this->metadataExtractor = $metadataExtractor; } /** diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkNormalizer.php index 18c716fd7..12652ce2a 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkNormalizer.php @@ -30,27 +30,16 @@ class AccompanyingPeriodWorkNormalizer implements ContextAwareNormalizerInterfac private const IGNORE_WORK = 'ignore:work'; - private EntityWorkflowRepository $entityWorkflowRepository; - - private MetadataExtractor $metadataExtractor; - - private Registry $registry; - - public function __construct(Registry $registry, EntityWorkflowRepository $entityWorkflowRepository, MetadataExtractor $metadataExtractor) + public function __construct(private Registry $registry, private EntityWorkflowRepository $entityWorkflowRepository, private MetadataExtractor $metadataExtractor) { - $this->registry = $registry; - $this->entityWorkflowRepository = $entityWorkflowRepository; - $this->metadataExtractor = $metadataExtractor; } /** * @param AccompanyingPeriodWork $object * * @throws ExceptionInterface - * - * @return array|ArrayObject|bool|float|int|string|null */ - public function normalize($object, ?string $format = null, array $context = []) + public function normalize($object, ?string $format = null, array $context = []): array|\ArrayObject|bool|float|int|string|null { $initial = $this->normalizer->normalize($object, $format, array_merge( $context, diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/MembersEditorNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/MembersEditorNormalizer.php index 740ea808c..6185c018d 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/MembersEditorNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/MembersEditorNormalizer.php @@ -31,11 +31,8 @@ class MembersEditorNormalizer implements DenormalizerAwareInterface, Denormalize { use DenormalizerAwareTrait; - private MembersEditorFactory $factory; - - public function __construct(MembersEditorFactory $factory) + public function __construct(private MembersEditorFactory $factory) { - $this->factory = $factory; } public function denormalize($data, $type, $format = null, array $context = []) diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonDocGenNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonDocGenNormalizer.php index 7b500e6bb..390d938d9 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonDocGenNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonDocGenNormalizer.php @@ -47,35 +47,15 @@ class PersonDocGenNormalizer implements private const CIRCULAR_KEY = 'person:circular'; - private PersonRenderInterface $personRender; - - private RelationshipRepository $relationshipRepository; - - private SummaryBudgetInterface $summaryBudget; - - private TranslatableStringHelper $translatableStringHelper; - - private TranslatorInterface $translator; - - public function __construct( - PersonRenderInterface $personRender, - RelationshipRepository $relationshipRepository, - TranslatorInterface $translator, - TranslatableStringHelper $translatableStringHelper, - SummaryBudgetInterface $summaryBudget - ) { - $this->personRender = $personRender; - $this->relationshipRepository = $relationshipRepository; - $this->translator = $translator; - $this->translatableStringHelper = $translatableStringHelper; - $this->summaryBudget = $summaryBudget; + public function __construct(private PersonRenderInterface $personRender, private RelationshipRepository $relationshipRepository, private TranslatorInterface $translator, private TranslatableStringHelper $translatableStringHelper, private SummaryBudgetInterface $summaryBudget) + { } public function normalize($person, $format = null, array $context = []) { try { $context = $this->addCircularToContext($person, $context); - } catch (CircularReferenceException $circularReferenceException) { + } catch (CircularReferenceException) { return [ 'isNull' => true, 'isCircular' => true, diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php index 2cadd0c75..57f666f05 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php @@ -47,28 +47,14 @@ class PersonJsonNormalizer implements DenormalizerAwareInterface, NormalizerAwar use ObjectToPopulateTrait; - private CenterResolverManagerInterface $centerResolverManager; - - private PhoneNumberHelperInterface $phoneNumberHelper; - - private ChillEntityRenderExtension $render; - - private PersonRepository $repository; - - private ResidentialAddressRepository $residentialAddressRepository; - public function __construct( - ChillEntityRenderExtension $render, /* TODO: replace by PersonRenderInterface, as sthis is the only one required */ - PersonRepository $repository, - CenterResolverManagerInterface $centerResolverManager, - ResidentialAddressRepository $residentialAddressRepository, - PhoneNumberHelperInterface $phoneNumberHelper /* TODO maybe not necessayr any more */ + private ChillEntityRenderExtension $render, + /* TODO: replace by PersonRenderInterface, as sthis is the only one required */ + private PersonRepository $repository, + private CenterResolverManagerInterface $centerResolverManager, + private ResidentialAddressRepository $residentialAddressRepository, + private PhoneNumberHelperInterface $phoneNumberHelper ) { - $this->render = $render; - $this->repository = $repository; - $this->centerResolverManager = $centerResolverManager; - $this->residentialAddressRepository = $residentialAddressRepository; - $this->phoneNumberHelper = $phoneNumberHelper; } public function denormalize($data, $type, $format = null, array $context = []) diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/RelationshipDocGenNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/RelationshipDocGenNormalizer.php index 0e4633580..42bccba06 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/RelationshipDocGenNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/RelationshipDocGenNormalizer.php @@ -22,11 +22,8 @@ class RelationshipDocGenNormalizer implements ContextAwareNormalizerInterface, N { use NormalizerAwareTrait; - private TranslatableStringHelperInterface $translatableStringHelper; - - public function __construct(TranslatableStringHelperInterface $translatableStringHelper) + public function __construct(private TranslatableStringHelperInterface $translatableStringHelper) { - $this->translatableStringHelper = $translatableStringHelper; } /** diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialActionNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialActionNormalizer.php index c7d214b04..494c82735 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialActionNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialActionNormalizer.php @@ -21,11 +21,8 @@ class SocialActionNormalizer implements NormalizerAwareInterface, NormalizerInte { use NormalizerAwareTrait; - private SocialActionRender $render; - - public function __construct(SocialActionRender $render) + public function __construct(private SocialActionRender $render) { - $this->render = $render; } public function normalize($socialAction, $format = null, array $context = []) diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialIssueNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialIssueNormalizer.php index 32b1635c4..7c8c8b226 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialIssueNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialIssueNormalizer.php @@ -21,11 +21,8 @@ class SocialIssueNormalizer implements ContextAwareNormalizerInterface, Normaliz { use NormalizerAwareTrait; - private SocialIssueRender $render; - - public function __construct(SocialIssueRender $render) + public function __construct(private SocialIssueRender $render) { - $this->render = $render; } public function normalize($socialIssue, $format = null, array $context = []) diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/WorkflowNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/WorkflowNormalizer.php index 14b50403a..b5cbeda07 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/WorkflowNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/WorkflowNormalizer.php @@ -27,14 +27,8 @@ class WorkflowNormalizer implements ContextAwareNormalizerInterface, NormalizerA private const IGNORE_ENTITY_WORKFLOW = 'ignore:entity_workflow'; - private MetadataExtractor $metadataExtractor; - - private Registry $registry; - - public function __construct(Registry $registry, MetadataExtractor $metadataExtractor) + public function __construct(private Registry $registry, private MetadataExtractor $metadataExtractor) { - $this->registry = $registry; - $this->metadataExtractor = $metadataExtractor; } /** diff --git a/src/Bundle/ChillPersonBundle/Service/AccompanyingPeriod/OldDraftAccompanyingPeriodRemover.php b/src/Bundle/ChillPersonBundle/Service/AccompanyingPeriod/OldDraftAccompanyingPeriodRemover.php index a5663050a..745568ed7 100644 --- a/src/Bundle/ChillPersonBundle/Service/AccompanyingPeriod/OldDraftAccompanyingPeriodRemover.php +++ b/src/Bundle/ChillPersonBundle/Service/AccompanyingPeriod/OldDraftAccompanyingPeriodRemover.php @@ -22,14 +22,8 @@ use Psr\Log\LoggerInterface; class OldDraftAccompanyingPeriodRemover implements OldDraftAccompanyingPeriodRemoverInterface { - private EntityManagerInterface $em; - - private LoggerInterface $logger; - - public function __construct(EntityManagerInterface $em, LoggerInterface $logger) + public function __construct(private EntityManagerInterface $em, private LoggerInterface $logger) { - $this->em = $em; - $this->logger = $logger; } public function remove(DateInterval $interval): void diff --git a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php index a42765c12..f4c161a98 100644 --- a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php +++ b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php @@ -46,40 +46,8 @@ class AccompanyingPeriodContext implements DocGeneratorContextWithAdminFormInterface, DocGeneratorContextWithPublicFormInterface { - private BaseContextData $baseContextData; - - private DocumentCategoryRepository $documentCategoryRepository; - - private EntityManagerInterface $em; - - private NormalizerInterface $normalizer; - - private PersonRenderInterface $personRender; - - private PersonRepository $personRepository; - - private TranslatableStringHelperInterface $translatableStringHelper; - - private TranslatorInterface $translator; - - public function __construct( - DocumentCategoryRepository $documentCategoryRepository, - NormalizerInterface $normalizer, - TranslatableStringHelperInterface $translatableStringHelper, - EntityManagerInterface $em, - PersonRenderInterface $personRender, - PersonRepository $personRepository, - TranslatorInterface $translator, - BaseContextData $baseContextData - ) { - $this->documentCategoryRepository = $documentCategoryRepository; - $this->normalizer = $normalizer; - $this->translatableStringHelper = $translatableStringHelper; - $this->em = $em; - $this->personRender = $personRender; - $this->personRepository = $personRepository; - $this->translator = $translator; - $this->baseContextData = $baseContextData; + public function __construct(private DocumentCategoryRepository $documentCategoryRepository, private NormalizerInterface $normalizer, private TranslatableStringHelperInterface $translatableStringHelper, private EntityManagerInterface $em, private PersonRenderInterface $personRender, private PersonRepository $personRepository, private TranslatorInterface $translator, private BaseContextData $baseContextData) + { } public function adminFormReverseTransform(array $data): array diff --git a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkContext.php b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkContext.php index ad1952596..0bc61d19f 100644 --- a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkContext.php +++ b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkContext.php @@ -29,16 +29,8 @@ use Symfony\Component\Serializer\Normalizer\NormalizerInterface; */ class AccompanyingPeriodWorkContext implements DocGeneratorContextWithPublicFormInterface { - private NormalizerInterface $normalizer; - - private AccompanyingPeriodContext $periodContext; - - public function __construct( - AccompanyingPeriodContext $periodContext, - NormalizerInterface $normalizer - ) { - $this->periodContext = $periodContext; - $this->normalizer = $normalizer; + public function __construct(private AccompanyingPeriodContext $periodContext, private NormalizerInterface $normalizer) + { } public function adminFormReverseTransform(array $data): array diff --git a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php index 34b339822..209251cd0 100644 --- a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php +++ b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php @@ -33,28 +33,8 @@ class AccompanyingPeriodWorkEvaluationContext implements DocGeneratorContextWithAdminFormInterface, DocGeneratorContextWithPublicFormInterface { - private AccompanyingPeriodWorkContext $accompanyingPeriodWorkContext; - - private EntityManagerInterface $em; - - private EvaluationRepository $evaluationRepository; - - private NormalizerInterface $normalizer; - - private TranslatableStringHelperInterface $translatableStringHelper; - - public function __construct( - AccompanyingPeriodWorkContext $accompanyingPeriodWorkContext, - EntityManagerInterface $em, - EvaluationRepository $evaluationRepository, - NormalizerInterface $normalizer, - TranslatableStringHelperInterface $translatableStringHelper - ) { - $this->accompanyingPeriodWorkContext = $accompanyingPeriodWorkContext; - $this->em = $em; - $this->evaluationRepository = $evaluationRepository; - $this->normalizer = $normalizer; - $this->translatableStringHelper = $translatableStringHelper; + public function __construct(private AccompanyingPeriodWorkContext $accompanyingPeriodWorkContext, private EntityManagerInterface $em, private EvaluationRepository $evaluationRepository, private NormalizerInterface $normalizer, private TranslatableStringHelperInterface $translatableStringHelper) + { } public function adminFormReverseTransform(array $data): array diff --git a/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php b/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php index 1fdfd23d9..ecbbe28db 100644 --- a/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php +++ b/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php @@ -45,52 +45,22 @@ use function count; final class PersonContext implements PersonContextInterface { - private AuthorizationHelperInterface $authorizationHelper; - - private BaseContextData $baseContextData; - - private CenterResolverManagerInterface $centerResolverManager; - - private DocumentCategoryRepository $documentCategoryRepository; - - private EntityManagerInterface $em; - - private NormalizerInterface $normalizer; - - private ScopeRepositoryInterface $scopeRepository; - - private Security $security; - private bool $showScopes; - private TranslatableStringHelperInterface $translatableStringHelper; - - private TranslatorInterface $translator; - public function __construct( - AuthorizationHelperInterface $authorizationHelper, - BaseContextData $baseContextData, - CenterResolverManagerInterface $centerResolverManager, - DocumentCategoryRepository $documentCategoryRepository, - EntityManagerInterface $em, - NormalizerInterface $normalizer, + private AuthorizationHelperInterface $authorizationHelper, + private BaseContextData $baseContextData, + private CenterResolverManagerInterface $centerResolverManager, + private DocumentCategoryRepository $documentCategoryRepository, + private EntityManagerInterface $em, + private NormalizerInterface $normalizer, ParameterBagInterface $parameterBag, - ScopeRepositoryInterface $scopeRepository, - Security $security, - TranslatorInterface $translator, - TranslatableStringHelperInterface $translatableStringHelper + private ScopeRepositoryInterface $scopeRepository, + private Security $security, + private TranslatorInterface $translator, + private TranslatableStringHelperInterface $translatableStringHelper ) { - $this->authorizationHelper = $authorizationHelper; - $this->centerResolverManager = $centerResolverManager; - $this->baseContextData = $baseContextData; - $this->documentCategoryRepository = $documentCategoryRepository; - $this->em = $em; - $this->normalizer = $normalizer; - $this->scopeRepository = $scopeRepository; - $this->security = $security; $this->showScopes = $parameterBag->get('chill_main')['acl']['form_show_scopes']; - $this->translator = $translator; - $this->translatableStringHelper = $translatableStringHelper; } public function adminFormReverseTransform(array $data): array diff --git a/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContextWithThirdParty.php b/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContextWithThirdParty.php index 53f8064a3..c8e15be12 100644 --- a/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContextWithThirdParty.php +++ b/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContextWithThirdParty.php @@ -27,20 +27,8 @@ use Symfony\Component\Serializer\Normalizer\NormalizerInterface; */ class PersonContextWithThirdParty implements DocGeneratorContextWithAdminFormInterface, DocGeneratorContextWithPublicFormInterface { - private NormalizerInterface $normalizer; - - private PersonContextInterface $personContext; - - private ThirdPartyRepository $thirdPartyRepository; - - public function __construct( - PersonContextInterface $personContext, - NormalizerInterface $normalizer, - ThirdPartyRepository $thirdPartyRepository - ) { - $this->personContext = $personContext; - $this->normalizer = $normalizer; - $this->thirdPartyRepository = $thirdPartyRepository; + public function __construct(private PersonContextInterface $personContext, private NormalizerInterface $normalizer, private ThirdPartyRepository $thirdPartyRepository) + { } public function adminFormReverseTransform(array $data): array diff --git a/src/Bundle/ChillPersonBundle/Service/Import/SocialWorkMetadata.php b/src/Bundle/ChillPersonBundle/Service/Import/SocialWorkMetadata.php index 3d7b60254..017c90b73 100644 --- a/src/Bundle/ChillPersonBundle/Service/Import/SocialWorkMetadata.php +++ b/src/Bundle/ChillPersonBundle/Service/Import/SocialWorkMetadata.php @@ -30,32 +30,8 @@ use function count; final class SocialWorkMetadata implements SocialWorkMetadataInterface { - private EntityManagerInterface $entityManager; - - private EvaluationRepository $evaluationRepository; - - private GoalRepository $goalRepository; - - private ResultRepository $resultRepository; - - private SocialActionRepository $socialActionRepository; - - private SocialIssueRepository $socialIssueRepository; - - public function __construct( - SocialIssueRepository $socialIssueRepository, - SocialActionRepository $socialActionRepository, - GoalRepository $goalRepository, - ResultRepository $resultRepository, - EvaluationRepository $evaluationRepository, - EntityManagerInterface $entityManager - ) { - $this->socialIssueRepository = $socialIssueRepository; - $this->socialActionRepository = $socialActionRepository; - $this->goalRepository = $goalRepository; - $this->resultRepository = $resultRepository; - $this->evaluationRepository = $evaluationRepository; - $this->entityManager = $entityManager; + public function __construct(private SocialIssueRepository $socialIssueRepository, private SocialActionRepository $socialActionRepository, private GoalRepository $goalRepository, private ResultRepository $resultRepository, private EvaluationRepository $evaluationRepository, private EntityManagerInterface $entityManager) + { } /** diff --git a/src/Bundle/ChillPersonBundle/Templating/Entity/ClosingMotiveRender.php b/src/Bundle/ChillPersonBundle/Templating/Entity/ClosingMotiveRender.php index 0064a53d5..8ebc89c04 100644 --- a/src/Bundle/ChillPersonBundle/Templating/Entity/ClosingMotiveRender.php +++ b/src/Bundle/ChillPersonBundle/Templating/Entity/ClosingMotiveRender.php @@ -27,14 +27,8 @@ class ClosingMotiveRender implements ChillEntityRenderInterface use BoxUtilsChillEntityRenderTrait; private const SEPARATOR = ' > '; - /** - * @var TranslatableStringHelper - */ - private $translatableStringHelper; - - public function __construct(TranslatableStringHelper $translatableStringHelper) + public function __construct(private TranslatableStringHelper $translatableStringHelper) { - $this->translatableStringHelper = $translatableStringHelper; } public function renderBox($entity, array $options): string diff --git a/src/Bundle/ChillPersonBundle/Templating/Entity/PersonRender.php b/src/Bundle/ChillPersonBundle/Templating/Entity/PersonRender.php index 05d9b3009..8d50f03ac 100644 --- a/src/Bundle/ChillPersonBundle/Templating/Entity/PersonRender.php +++ b/src/Bundle/ChillPersonBundle/Templating/Entity/PersonRender.php @@ -27,20 +27,9 @@ use function array_key_exists; class PersonRender implements PersonRenderInterface { use BoxUtilsChillEntityRenderTrait; - private ConfigPersonAltNamesHelper $configAltNamesHelper; - private EngineInterface $engine; - - private TranslatorInterface $translator; - - public function __construct( - ConfigPersonAltNamesHelper $configAltNamesHelper, - EngineInterface $engine, - TranslatorInterface $translator - ) { - $this->configAltNamesHelper = $configAltNamesHelper; - $this->engine = $engine; - $this->translator = $translator; + public function __construct(private ConfigPersonAltNamesHelper $configAltNamesHelper, private EngineInterface $engine, private TranslatorInterface $translator) + { } public function renderBox($person, array $options): string diff --git a/src/Bundle/ChillPersonBundle/Templating/Entity/ResourceKindRender.php b/src/Bundle/ChillPersonBundle/Templating/Entity/ResourceKindRender.php index 61c674b76..925c174cc 100644 --- a/src/Bundle/ChillPersonBundle/Templating/Entity/ResourceKindRender.php +++ b/src/Bundle/ChillPersonBundle/Templating/Entity/ResourceKindRender.php @@ -20,11 +20,8 @@ use Chill\PersonBundle\Entity\Person\PersonResourceKind; */ final class ResourceKindRender implements ChillEntityRenderInterface { - private TranslatableStringHelper $translatableStringHelper; - - public function __construct(TranslatableStringHelper $translatableStringHelper) + public function __construct(private TranslatableStringHelper $translatableStringHelper) { - $this->translatableStringHelper = $translatableStringHelper; } public function renderBox($entity, array $options): string diff --git a/src/Bundle/ChillPersonBundle/Templating/Entity/SocialActionRender.php b/src/Bundle/ChillPersonBundle/Templating/Entity/SocialActionRender.php index dd8083878..2d8b1ea92 100644 --- a/src/Bundle/ChillPersonBundle/Templating/Entity/SocialActionRender.php +++ b/src/Bundle/ChillPersonBundle/Templating/Entity/SocialActionRender.php @@ -47,20 +47,8 @@ class SocialActionRender implements ChillEntityRenderInterface */ public const SHOW_AND_CHILDREN = 'show_and_children'; - private EngineInterface $engine; - - private TranslatableStringHelper $translatableStringHelper; - - private TranslatorInterface $translator; - - public function __construct( - TranslatableStringHelper $translatableStringHelper, - EngineInterface $engine, - TranslatorInterface $translator - ) { - $this->translatableStringHelper = $translatableStringHelper; - $this->engine = $engine; - $this->translator = $translator; + public function __construct(private TranslatableStringHelper $translatableStringHelper, private EngineInterface $engine, private TranslatorInterface $translator) + { } public function renderBox($socialAction, array $options): string diff --git a/src/Bundle/ChillPersonBundle/Templating/Entity/SocialIssueRender.php b/src/Bundle/ChillPersonBundle/Templating/Entity/SocialIssueRender.php index f3962535b..381f80ef9 100644 --- a/src/Bundle/ChillPersonBundle/Templating/Entity/SocialIssueRender.php +++ b/src/Bundle/ChillPersonBundle/Templating/Entity/SocialIssueRender.php @@ -40,20 +40,8 @@ final class SocialIssueRender implements ChillEntityRenderInterface */ public const SHOW_AND_CHILDREN = 'show_and_children'; - private EngineInterface $engine; - - private TranslatableStringHelper $translatableStringHelper; - - private TranslatorInterface $translator; - - public function __construct( - TranslatableStringHelper $translatableStringHelper, - EngineInterface $engine, - TranslatorInterface $translator - ) { - $this->translatableStringHelper = $translatableStringHelper; - $this->engine = $engine; - $this->translator = $translator; + public function __construct(private TranslatableStringHelper $translatableStringHelper, private EngineInterface $engine, private TranslatorInterface $translator) + { } public function renderBox($socialIssue, array $options): string diff --git a/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/SocialIssueConsistency/AccompanyingPeriodSocialIssueConsistencyEntityListenerTest.php b/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/SocialIssueConsistency/AccompanyingPeriodSocialIssueConsistencyEntityListenerTest.php index 8ac092647..68100a1b3 100644 --- a/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/SocialIssueConsistency/AccompanyingPeriodSocialIssueConsistencyEntityListenerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/SocialIssueConsistency/AccompanyingPeriodSocialIssueConsistencyEntityListenerTest.php @@ -115,14 +115,8 @@ final class AccompanyingPeriodSocialIssueConsistencyEntityListenerTest extends T protected function generateClass(AccompanyingPeriod $period, Collection $socialIssues): AccompanyingPeriodLinkedWithSocialIssuesEntityInterface { return new class ($period, $socialIssues) implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterface { - public Collection $socialIssues; - - public AccompanyingPeriod $period; - - public function __construct($period, $socialIssues) + public function __construct(public $period, public $socialIssues) { - $this->period = $period; - $this->socialIssues = $socialIssues; } public function getAccompanyingPeriod(): AccompanyingPeriod diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseApiControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseApiControllerTest.php index ac722f2f6..560928bff 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseApiControllerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseApiControllerTest.php @@ -472,11 +472,8 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase /** * @dataProvider dataGenerateRandomRequestorValidData - * - * @param mixed $personId - * @param mixed $thirdPartyId */ - public function testCommentWithValidData(AccompanyingPeriod $period, $personId, $thirdPartyId) + public function testCommentWithValidData(AccompanyingPeriod $period, mixed $personId, mixed $thirdPartyId) { $this->markTestIncomplete('fix test with validation'); $em = self::$container->get(EntityManagerInterface::class); @@ -550,11 +547,8 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase /** * @dataProvider dataGenerateRandomRequestorValidData - * - * @param mixed $personId - * @param mixed $thirdPartyId */ - public function testRequestorWithValidData(AccompanyingPeriod $period, $personId, $thirdPartyId) + public function testRequestorWithValidData(AccompanyingPeriod $period, mixed $personId, mixed $thirdPartyId) { $this->markTestIncomplete('fix test with validation'); $em = self::$container->get(EntityManagerInterface::class); @@ -634,11 +628,8 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase /** * @dataProvider dataGenerateRandomRequestorValidData - * - * @param mixed $personId - * @param mixed $thirdPartyId */ - public function testResourceWithValidData(AccompanyingPeriod $period, $personId, $thirdPartyId) + public function testResourceWithValidData(AccompanyingPeriod $period, mixed $personId, mixed $thirdPartyId) { $this->markTestIncomplete('fix test with validation'); $em = self::$container->get(EntityManagerInterface::class); diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseControllerTest.php index b475cca4c..a7d98bd97 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseControllerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseControllerTest.php @@ -75,11 +75,8 @@ final class AccompanyingCourseControllerTest extends WebTestCase /** * @dataProvider dataGenerateRandomUsers - * - * @param mixed $personId0 - * @param mixed $personId1 */ - public function testWithNewUsers($personId0, $personId1) + public function testWithNewUsers(mixed $personId0, mixed $personId1) { $this->client->request('GET', '/fr/person/parcours/new', [ 'person_id' => [ diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdControllerTest.php index 772fee3b1..5cc3d0643 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdControllerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdControllerTest.php @@ -64,10 +64,8 @@ final class HouseholdControllerTest extends WebTestCase /** * @dataProvider generateValidHouseholdIds - * - * @param mixed $householdId */ - public function testAddresses($householdId) + public function testAddresses(mixed $householdId) { $this->client->request( Request::METHOD_GET, @@ -79,10 +77,8 @@ final class HouseholdControllerTest extends WebTestCase /** * @dataProvider generateValidHouseholdIds - * - * @param mixed $householdId */ - public function testAddressMove($householdId) + public function testAddressMove(mixed $householdId) { $this->client->request( Request::METHOD_GET, @@ -96,10 +92,8 @@ final class HouseholdControllerTest extends WebTestCase /** * @dataProvider generateValidHouseholdIds - * - * @param mixed $householdId */ - public function testEditMetadata($householdId) + public function testEditMetadata(mixed $householdId) { $crawler = $this->client->request( Request::METHOD_GET, @@ -126,10 +120,8 @@ final class HouseholdControllerTest extends WebTestCase /** * @dataProvider generateValidHouseholdIds - * - * @param mixed $householdId */ - public function testSummary($householdId) + public function testSummary(mixed $householdId) { $this->client->request( Request::METHOD_GET, diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdMemberControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdMemberControllerTest.php index 56000c3e0..4986d5b9a 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdMemberControllerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdMemberControllerTest.php @@ -110,10 +110,8 @@ final class HouseholdMemberControllerTest extends WebTestCase /** * @dataProvider provideValidDataEditMember - * - * @param mixed $memberId */ - public function testEditMember($memberId) + public function testEditMember(mixed $memberId) { $client = $this->getClientAuthenticated(); @@ -134,12 +132,8 @@ final class HouseholdMemberControllerTest extends WebTestCase /** * @dataProvider provideValidDataMove - * - * @param mixed $personId - * @param mixed $householdId - * @param mixed $positionId */ - public function testLeaveWithoutHousehold($personId, $householdId, $positionId, DateTimeInterface $date) + public function testLeaveWithoutHousehold(mixed $personId, mixed $householdId, mixed $positionId, DateTimeInterface $date) { $client = $this->getClientAuthenticated(); @@ -186,12 +180,8 @@ final class HouseholdMemberControllerTest extends WebTestCase /** * @dataProvider provideValidDataMove - * - * @param mixed $personId - * @param mixed $householdId - * @param mixed $positionId */ - public function testMoveMember($personId, $householdId, $positionId, DateTimeInterface $date) + public function testMoveMember(mixed $personId, mixed $householdId, mixed $positionId, DateTimeInterface $date) { $client = $this->getClientAuthenticated(); @@ -237,12 +227,8 @@ final class HouseholdMemberControllerTest extends WebTestCase /** * @dataProvider provideValidDataMove - * - * @param mixed $personId - * @param mixed $householdId - * @param mixed $positionId */ - public function testMoveMemberToNewHousehold($personId, $householdId, $positionId, DateTimeInterface $date) + public function testMoveMemberToNewHousehold(mixed $personId, mixed $householdId, mixed $positionId, DateTimeInterface $date) { $client = $this->getClientAuthenticated(); diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonApiControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonApiControllerTest.php index 0de312d84..cb91d2ccf 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonApiControllerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonApiControllerTest.php @@ -71,10 +71,8 @@ final class PersonApiControllerTest extends WebTestCase /** * @dataProvider dataGetPersonFromCenterA - * - * @param mixed $personId */ - public function testPersonAddressSuggestion($personId): void + public function testPersonAddressSuggestion(mixed $personId): void { $client = $this->getClientAuthenticated(); @@ -85,10 +83,8 @@ final class PersonApiControllerTest extends WebTestCase /** * @dataProvider dataGetPersonFromCenterB - * - * @param mixed $personId */ - public function testPersonAddressSuggestionUnauthorized($personId): void + public function testPersonAddressSuggestionUnauthorized(mixed $personId): void { $client = $this->getClientAuthenticated(); @@ -100,10 +96,8 @@ final class PersonApiControllerTest extends WebTestCase /** * @dataProvider dataGetPersonFromCenterA - * - * @param mixed $personId */ - public function testPersonGet($personId): void + public function testPersonGet(mixed $personId): void { $client = $this->getClientAuthenticated(); @@ -122,10 +116,8 @@ final class PersonApiControllerTest extends WebTestCase /** * @dataProvider dataGetPersonFromCenterB - * - * @param mixed $personId */ - public function testPersonGetUnauthorized($personId): void + public function testPersonGetUnauthorized(mixed $personId): void { $client = $this->getClientAuthenticated(); diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerCreateTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerCreateTest.php index 6f92c864b..0e7b2c9f1 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerCreateTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerCreateTest.php @@ -141,7 +141,7 @@ final class PersonControllerCreateTest extends WebTestCase * @param int|string $personId The is of the person * @depends testValidForm */ - public function testPersonViewAccessible($personId) + public function testPersonViewAccessible(int|string $personId) { $client = $this->client; $client->request('GET', '/fr/person/' . $personId . '/general'); diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/RelationshipApiControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/RelationshipApiControllerTest.php index d6fb7a8da..7851c782d 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/RelationshipApiControllerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/RelationshipApiControllerTest.php @@ -103,10 +103,8 @@ final class RelationshipApiControllerTest extends WebTestCase /** * @dataProvider personProvider - * - * @param mixed $personId */ - public function testGetRelationshipByPerson($personId) + public function testGetRelationshipByPerson(mixed $personId) { $this->client->request(Request::METHOD_GET, sprintf('/api/1.0/relations/relationship/by-person/%d.json', $personId)); @@ -116,13 +114,8 @@ final class RelationshipApiControllerTest extends WebTestCase /** * @dataProvider relationProvider - * - * @param mixed $fromPersonId - * @param mixed $toPersonId - * @param mixed $relationId - * @param mixed $isReverse */ - public function testPostRelationship($fromPersonId, $toPersonId, $relationId, $isReverse): void + public function testPostRelationship(mixed $fromPersonId, mixed $toPersonId, mixed $relationId, mixed $isReverse): void { $this->client->request( Request::METHOD_POST, diff --git a/src/Bundle/ChillPersonBundle/Tests/EventListener/PersonCreateEventTest.php b/src/Bundle/ChillPersonBundle/Tests/EventListener/PersonCreateEventTest.php index 724777c83..974dc0ed9 100644 --- a/src/Bundle/ChillPersonBundle/Tests/EventListener/PersonCreateEventTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/EventListener/PersonCreateEventTest.php @@ -46,11 +46,8 @@ final class PersonCreateEventTest extends TestCase /** * @dataProvider generateAltNames - * - * @param mixed $altname - * @param mixed $altnameExpected */ - public function testAltNamesOnPrePersist($altname, $altnameExpected) + public function testAltNamesOnPrePersist(mixed $altname, mixed $altnameExpected) { $listener = new PersonEventListener(); @@ -65,13 +62,8 @@ final class PersonCreateEventTest extends TestCase /** * @dataProvider generateNames - * - * @param mixed $firstname - * @param mixed $firstnameExpected - * @param mixed $lastname - * @param mixed $lastnameExpected */ - public function testOnPrePersist($firstname, $firstnameExpected, $lastname, $lastnameExpected) + public function testOnPrePersist(mixed $firstname, mixed $firstnameExpected, mixed $lastname, mixed $lastnameExpected) { $listener = new PersonEventListener(); diff --git a/src/Bundle/ChillPersonBundle/Tests/Search/PersonSearchTest.php b/src/Bundle/ChillPersonBundle/Tests/Search/PersonSearchTest.php index 9d200beee..64143e7db 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Search/PersonSearchTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Search/PersonSearchTest.php @@ -225,11 +225,9 @@ final class PersonSearchTest extends WebTestCase } /** - * @param mixed $username - * * @return \Symfony\Component\BrowserKit\Client */ - private function getAuthenticatedClient($username = 'center a_social') + private function getAuthenticatedClient(mixed $username = 'center a_social') { return self::createClient([], [ 'PHP_AUTH_USER' => $username, diff --git a/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/PersonDocGenNormalizerTest.php b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/PersonDocGenNormalizerTest.php index f7a05f7ce..90ceddb04 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/PersonDocGenNormalizerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/PersonDocGenNormalizerTest.php @@ -108,10 +108,8 @@ final class PersonDocGenNormalizerTest extends KernelTestCase /** * @dataProvider dataGeneratorNormalizationNullOrNotNullHaveSameKeys - * - * @param mixed $context */ - public function testNormalizationNullOrNotNullHaveSameKeys($context) + public function testNormalizationNullOrNotNullHaveSameKeys(mixed $context) { $period = new Person(); $notNullData = $this->buildPersonNormalizer()->normalize($period, 'docgen', $context); @@ -126,11 +124,8 @@ final class PersonDocGenNormalizerTest extends KernelTestCase /** * @dataProvider generateData - * - * @param mixed $expected - * @param mixed $msg */ - public function testNormalize(?Person $person, $expected, $msg) + public function testNormalize(?Person $person, mixed $expected, mixed $msg) { $normalized = $this->normalizer->normalize($person, 'docgen', [ 'docgen:expects' => Person::class, @@ -229,11 +224,8 @@ final class PersonDocGenNormalizerTest extends KernelTestCase * serializers. * * @dataProvider generateData - * - * @param mixed $expected - * @param mixed $msg */ - public function testNormalizeUsingNormalizer(?Person $person, $expected, $msg) + public function testNormalizeUsingNormalizer(?Person $person, mixed $expected, mixed $msg) { $normalizer = $this->buildNormalizer(); diff --git a/src/Bundle/ChillPersonBundle/Tests/Timeline/TimelineAccompanyingPeriodTest.php b/src/Bundle/ChillPersonBundle/Tests/Timeline/TimelineAccompanyingPeriodTest.php index ebc6d4b40..be368e28c 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Timeline/TimelineAccompanyingPeriodTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Timeline/TimelineAccompanyingPeriodTest.php @@ -58,10 +58,8 @@ final class TimelineAccompanyingPeriodTest extends WebTestCase /** * @dataProvider provideDataPersonWithAccompanyingPeriod - * - * @param mixed $personId */ - public function testEntriesAreShown($personId) + public function testEntriesAreShown(mixed $personId) { $this->markTestSkipped('page does not work'); diff --git a/src/Bundle/ChillPersonBundle/Tests/Validator/Household/MaxHolderValidatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Validator/Household/MaxHolderValidatorTest.php index de9769175..ac7530fca 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Validator/Household/MaxHolderValidatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Validator/Household/MaxHolderValidatorTest.php @@ -61,10 +61,8 @@ final class MaxHolderValidatorTest extends ConstraintValidatorTestCase /** * @dataProvider provideInvalidHousehold - * - * @param mixed $parameters */ - public function testHouseholdInvalid(Household $household, $parameters) + public function testHouseholdInvalid(Household $household, mixed $parameters) { $constraint = $this->getConstraint(); diff --git a/src/Bundle/ChillPersonBundle/Timeline/AbstractTimelineAccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Timeline/AbstractTimelineAccompanyingPeriod.php index fe2947f60..2e11a4f4f 100644 --- a/src/Bundle/ChillPersonBundle/Timeline/AbstractTimelineAccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Timeline/AbstractTimelineAccompanyingPeriod.php @@ -35,17 +35,8 @@ abstract class AbstractTimelineAccompanyingPeriod implements TimelineProviderInt { private const SUPPORTED_CONTEXTS = ['person', 'center']; - protected EntityManager $em; - - private AuthorizationHelper $authorizationHelper; - - private Security $security; - - public function __construct(EntityManager $em, Security $security, AuthorizationHelper $authorizationHelper) + public function __construct(protected EntityManager $em, private Security $security, private AuthorizationHelper $authorizationHelper) { - $this->em = $em; - $this->security = $security; - $this->authorizationHelper = $authorizationHelper; } public function getEntities(array $ids) @@ -125,12 +116,10 @@ abstract class AbstractTimelineAccompanyingPeriod implements TimelineProviderInt * return the expected response for TimelineProviderInterface::getEntityTemplate. * * @param string $template the template for rendering - * @param mixed $entity * @param string $context - * * @return array */ - protected function getBasicEntityTemplate($template, $entity, $context, array $args) + protected function getBasicEntityTemplate($template, mixed $entity, $context, array $args) { return [ 'template' => $template, diff --git a/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/AccompanyingPeriodValidityValidator.php b/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/AccompanyingPeriodValidityValidator.php index ed0337f1f..f7d533d0e 100644 --- a/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/AccompanyingPeriodValidityValidator.php +++ b/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/AccompanyingPeriodValidityValidator.php @@ -25,17 +25,8 @@ use function in_array; class AccompanyingPeriodValidityValidator extends ConstraintValidator { - private ActivityRepository $activityRepository; - - private SocialIssueRender $socialIssueRender; - - private TokenStorageInterface $token; - - public function __construct(ActivityRepository $activityRepository, SocialIssueRender $socialIssueRender, TokenStorageInterface $token) + public function __construct(private ActivityRepository $activityRepository, private SocialIssueRender $socialIssueRender, private TokenStorageInterface $token) { - $this->activityRepository = $activityRepository; - $this->socialIssueRender = $socialIssueRender; - $this->token = $token; } public function validate($period, Constraint $constraint) diff --git a/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/LocationValidityValidator.php b/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/LocationValidityValidator.php index df5b88fc6..50ef5059c 100644 --- a/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/LocationValidityValidator.php +++ b/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/LocationValidityValidator.php @@ -20,11 +20,8 @@ use Symfony\Component\Validator\Exception\UnexpectedValueException; class LocationValidityValidator extends ConstraintValidator { - private PersonRenderInterface $render; - - public function __construct(PersonRenderInterface $render) + public function __construct(private PersonRenderInterface $render) { - $this->render = $render; } public function validate($period, Constraint $constraint) diff --git a/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/ParticipationOverlapValidator.php b/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/ParticipationOverlapValidator.php index 67ee00756..2589a1751 100644 --- a/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/ParticipationOverlapValidator.php +++ b/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/ParticipationOverlapValidator.php @@ -26,14 +26,8 @@ class ParticipationOverlapValidator extends ConstraintValidator { private const MAX_PARTICIPATION = 1; - private PersonRenderInterface $personRender; - - private ThirdPartyRender $thirdpartyRender; - - public function __construct(PersonRenderInterface $personRender, ThirdPartyRender $thirdPartyRender) + public function __construct(private PersonRenderInterface $personRender, private ThirdPartyRender $thirdpartyRender) { - $this->personRender = $personRender; - $this->thirdpartyRender = $thirdPartyRender; } public function validate($participations, Constraint $constraint) diff --git a/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/ResourceDuplicateCheckValidator.php b/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/ResourceDuplicateCheckValidator.php index 5813945ab..a9d339286 100644 --- a/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/ResourceDuplicateCheckValidator.php +++ b/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/ResourceDuplicateCheckValidator.php @@ -24,14 +24,8 @@ use function in_array; class ResourceDuplicateCheckValidator extends ConstraintValidator { - private PersonRenderInterface $personRender; - - private ThirdPartyRender $thirdpartyRender; - - public function __construct(PersonRenderInterface $personRender, ThirdPartyRender $thirdPartyRender) + public function __construct(private PersonRenderInterface $personRender, private ThirdPartyRender $thirdpartyRender) { - $this->personRender = $personRender; - $this->thirdpartyRender = $thirdPartyRender; } public function validate($resources, Constraint $constraint) diff --git a/src/Bundle/ChillPersonBundle/Validator/Constraints/Household/HouseholdMembershipSequentialValidator.php b/src/Bundle/ChillPersonBundle/Validator/Constraints/Household/HouseholdMembershipSequentialValidator.php index a57b47325..edabface7 100644 --- a/src/Bundle/ChillPersonBundle/Validator/Constraints/Household/HouseholdMembershipSequentialValidator.php +++ b/src/Bundle/ChillPersonBundle/Validator/Constraints/Household/HouseholdMembershipSequentialValidator.php @@ -26,11 +26,8 @@ use function count; */ class HouseholdMembershipSequentialValidator extends ConstraintValidator { - private PersonRenderInterface $render; - - public function __construct(PersonRenderInterface $render) + public function __construct(private PersonRenderInterface $render) { - $this->render = $render; } public function validate($person, Constraint $constraint) diff --git a/src/Bundle/ChillPersonBundle/Validator/Constraints/Person/BirthdateValidator.php b/src/Bundle/ChillPersonBundle/Validator/Constraints/Person/BirthdateValidator.php index 7845e33e6..51b3db76f 100644 --- a/src/Bundle/ChillPersonBundle/Validator/Constraints/Person/BirthdateValidator.php +++ b/src/Bundle/ChillPersonBundle/Validator/Constraints/Person/BirthdateValidator.php @@ -23,11 +23,8 @@ use function is_object; class BirthdateValidator extends ConstraintValidator { - private $interval_spec; - - public function __construct($interval_spec = null) + public function __construct(private $interval_spec = null) { - $this->interval_spec = $interval_spec; } public function validate($value, Constraint $constraint) @@ -38,7 +35,7 @@ class BirthdateValidator extends ConstraintValidator if (!$value instanceof DateTime) { throw new LogicException('The input should a be a \DateTime interface,' - . (is_object($value) ? get_class($value) : gettype($value))); + . (get_debug_type($value))); } $limitDate = $this->getLimitDate(); diff --git a/src/Bundle/ChillPersonBundle/Validator/Constraints/Person/PersonHasCenterValidator.php b/src/Bundle/ChillPersonBundle/Validator/Constraints/Person/PersonHasCenterValidator.php index 278f80962..48fab3787 100644 --- a/src/Bundle/ChillPersonBundle/Validator/Constraints/Person/PersonHasCenterValidator.php +++ b/src/Bundle/ChillPersonBundle/Validator/Constraints/Person/PersonHasCenterValidator.php @@ -22,12 +22,9 @@ class PersonHasCenterValidator extends ConstraintValidator { private bool $centerRequired; - private CenterResolverManagerInterface $centerResolverManager; - - public function __construct(ParameterBagInterface $parameterBag, CenterResolverManagerInterface $centerResolverManager) + public function __construct(ParameterBagInterface $parameterBag, private CenterResolverManagerInterface $centerResolverManager) { $this->centerRequired = $parameterBag->get('chill_person')['validation']['center_required']; - $this->centerResolverManager = $centerResolverManager; } public function validate($person, Constraint $constraint) diff --git a/src/Bundle/ChillPersonBundle/Validator/Constraints/Relationship/RelationshipNoDuplicateValidator.php b/src/Bundle/ChillPersonBundle/Validator/Constraints/Relationship/RelationshipNoDuplicateValidator.php index 10e651b56..bec92b9c0 100644 --- a/src/Bundle/ChillPersonBundle/Validator/Constraints/Relationship/RelationshipNoDuplicateValidator.php +++ b/src/Bundle/ChillPersonBundle/Validator/Constraints/Relationship/RelationshipNoDuplicateValidator.php @@ -20,11 +20,8 @@ use Symfony\Component\Validator\Exception\UnexpectedValueException; class RelationshipNoDuplicateValidator extends ConstraintValidator { - private RelationshipRepository $relationshipRepository; - - public function __construct(RelationshipRepository $relationshipRepository) + public function __construct(private RelationshipRepository $relationshipRepository) { - $this->relationshipRepository = $relationshipRepository; } public function validate($value, Constraint $constraint) diff --git a/src/Bundle/ChillPersonBundle/Widget/PersonListWidget.php b/src/Bundle/ChillPersonBundle/Widget/PersonListWidget.php index f2ea66653..0db3eb429 100644 --- a/src/Bundle/ChillPersonBundle/Widget/PersonListWidget.php +++ b/src/Bundle/ChillPersonBundle/Widget/PersonListWidget.php @@ -39,26 +39,10 @@ use function count; */ class PersonListWidget implements WidgetInterface { - protected AuthorizationHelperInterface $authorizationHelper; - - protected EntityManagerInterface $entityManager; - - protected PersonRepository $personRepository; - - protected TokenStorageInterface $tokenStorage; - protected UserInterface $user; - public function __construct( - PersonRepository $personRepostory, - EntityManagerInterface $em, - AuthorizationHelperInterface $authorizationHelper, - TokenStorageInterface $tokenStorage - ) { - $this->personRepository = $personRepostory; - $this->authorizationHelper = $authorizationHelper; - $this->tokenStorage = $tokenStorage; - $this->entityManager = $em; + public function __construct(protected PersonRepository $personRepository, protected EntityManagerInterface $entityManager, protected AuthorizationHelperInterface $authorizationHelper, protected TokenStorageInterface $tokenStorage) + { } /** diff --git a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler.php b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler.php index 500daab6f..c224cb166 100644 --- a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler.php +++ b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler.php @@ -21,20 +21,8 @@ use Symfony\Contracts\Translation\TranslatorInterface; class AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler implements EntityWorkflowHandlerInterface { - private AccompanyingPeriodWorkEvaluationDocumentRepository $repository; - - private TranslatableStringHelperInterface $translatableStringHelper; - - private TranslatorInterface $translator; - - public function __construct( - AccompanyingPeriodWorkEvaluationDocumentRepository $repository, - TranslatableStringHelperInterface $translatableStringHelper, - TranslatorInterface $translator - ) { - $this->repository = $repository; - $this->translatableStringHelper = $translatableStringHelper; - $this->translator = $translator; + public function __construct(private AccompanyingPeriodWorkEvaluationDocumentRepository $repository, private TranslatableStringHelperInterface $translatableStringHelper, private TranslatorInterface $translator) + { } public function getDeletionRoles(): array diff --git a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationWorkflowHandler.php b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationWorkflowHandler.php index db67ef045..b5869c35f 100644 --- a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationWorkflowHandler.php +++ b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationWorkflowHandler.php @@ -22,20 +22,8 @@ use Symfony\Contracts\Translation\TranslatorInterface; class AccompanyingPeriodWorkEvaluationWorkflowHandler implements EntityWorkflowHandlerInterface { - private AccompanyingPeriodWorkEvaluationRepository $repository; - - private TranslatableStringHelperInterface $translatableStringHelper; - - private TranslatorInterface $translator; - - public function __construct( - AccompanyingPeriodWorkEvaluationRepository $repository, - TranslatableStringHelperInterface $translatableStringHelper, - TranslatorInterface $translator - ) { - $this->repository = $repository; - $this->translatableStringHelper = $translatableStringHelper; - $this->translator = $translator; + public function __construct(private AccompanyingPeriodWorkEvaluationRepository $repository, private TranslatableStringHelperInterface $translatableStringHelper, private TranslatorInterface $translator) + { } public function getDeletionRoles(): array diff --git a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkWorkflowHandler.php b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkWorkflowHandler.php index 3cdf23f88..203fd60d2 100644 --- a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkWorkflowHandler.php +++ b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkWorkflowHandler.php @@ -23,20 +23,8 @@ use Symfony\Contracts\Translation\TranslatorInterface; class AccompanyingPeriodWorkWorkflowHandler implements EntityWorkflowHandlerInterface { - private AccompanyingPeriodWorkRepository $repository; - - private TranslatableStringHelperInterface $translatableStringHelper; - - private TranslatorInterface $translator; - - public function __construct( - AccompanyingPeriodWorkRepository $repository, - TranslatableStringHelperInterface $translatableStringHelper, - TranslatorInterface $translator - ) { - $this->repository = $repository; - $this->translatableStringHelper = $translatableStringHelper; - $this->translator = $translator; + public function __construct(private AccompanyingPeriodWorkRepository $repository, private TranslatableStringHelperInterface $translatableStringHelper, private TranslatorInterface $translator) + { } public function getDeletionRoles(): array diff --git a/src/Bundle/ChillReportBundle/Controller/ReportController.php b/src/Bundle/ChillReportBundle/Controller/ReportController.php index da39aedec..864ad8c62 100644 --- a/src/Bundle/ChillReportBundle/Controller/ReportController.php +++ b/src/Bundle/ChillReportBundle/Controller/ReportController.php @@ -135,7 +135,7 @@ class ReportController extends AbstractController * * @return Response The web page. */ - public function editAction($person_id, $report_id) + public function editAction(int|string $person_id, int|string $report_id) { $em = $this->getDoctrine()->getManager(); @@ -542,11 +542,10 @@ class ReportController extends AbstractController * Creates a form to create a Report entity. * * @param Report $entity The entity - * @param mixed $cFGroup * * @return \Symfony\Component\Form\Form The form */ - private function createCreateForm(Report $entity, Person $person, $cFGroup) + private function createCreateForm(Report $entity, Person $person, mixed $cFGroup) { return $this->createForm(ReportType::class, $entity, [ 'action' => $this->generateUrl( diff --git a/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReports.php b/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReports.php index db4646eed..ae35e9eac 100644 --- a/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReports.php +++ b/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReports.php @@ -168,7 +168,7 @@ class LoadReports extends AbstractFixture implements ContainerAwareInterface, Or * * @return string|string[] the array of slug if multiple, a single slug otherwise */ - private function getRandomChoice(CustomField $field) + private function getRandomChoice(CustomField $field): string|array { $choices = $field->getOptions()['choices']; $multiple = $field->getOptions()['multiple']; diff --git a/src/Bundle/ChillReportBundle/Export/Export/ReportList.php b/src/Bundle/ChillReportBundle/Export/Export/ReportList.php index 9adae0097..dbaa1abea 100644 --- a/src/Bundle/ChillReportBundle/Export/Export/ReportList.php +++ b/src/Bundle/ChillReportBundle/Export/Export/ReportList.php @@ -49,12 +49,6 @@ use function uniqid; class ReportList implements ExportElementValidatedInterface, ListInterface { - protected CustomFieldProvider $customFieldProvider; - - protected CustomFieldsGroup $customfieldsGroup; - - protected EntityManagerInterface $em; - protected array $fields = [ 'person_id', 'person_firstName', 'person_lastName', 'person_birthdate', 'person_placeOfBirth', 'person_gender', 'person_memo', 'person_email', 'person_phonenumber', @@ -66,22 +60,8 @@ class ReportList implements ExportElementValidatedInterface, ListInterface protected array $slugs = []; - protected TranslatableStringHelper $translatableStringHelper; - - protected TranslatorInterface $translator; - - public function __construct( - CustomFieldsGroup $customfieldsGroup, - TranslatableStringHelper $translatableStringHelper, - TranslatorInterface $translator, - CustomFieldProvider $customFieldProvider, - EntityManagerInterface $em - ) { - $this->customfieldsGroup = $customfieldsGroup; - $this->translatableStringHelper = $translatableStringHelper; - $this->translator = $translator; - $this->customFieldProvider = $customFieldProvider; - $this->em = $em; + public function __construct(protected CustomFieldsGroup $customfieldsGroup, protected TranslatableStringHelper $translatableStringHelper, protected TranslatorInterface $translator, protected CustomFieldProvider $customFieldProvider, protected EntityManagerInterface $em) + { } public function buildForm(FormBuilderInterface $builder) @@ -102,26 +82,19 @@ class ReportList implements ExportElementValidatedInterface, ListInterface 'label' => 'Fields to include in export', 'choice_attr' => static function ($val, $key, $index) { // add a 'data-display-target' for address fields - if (substr($val, 0, 8) === 'address_') { + if (str_starts_with($val, 'address_')) { return ['data-display-target' => 'address_date']; } return []; }, - 'choice_label' => function (string $key, string $label): string { - switch (substr($key, 0, 7)) { - case 'person_': - return $this->translator->trans(substr($key, 7, strlen($key) - 7)) . - ' (' . $this->translator->trans('Person') . ')'; - - case 'report_': - return $this->translator->trans(ucfirst(substr($key, 7, strlen($key) - 7))) . - ' (' . $this->translator->trans('Report') . ')'; - - default: - return $label . - ' (' . $this->translator->trans("Report's question") . ')'; - } + 'choice_label' => fn (string $key, string $label): string => match (substr($key, 0, 7)) { + 'person_' => $this->translator->trans(substr($key, 7, strlen($key) - 7)) . + ' (' . $this->translator->trans('Person') . ')', + 'report_' => $this->translator->trans(ucfirst(substr($key, 7, strlen($key) - 7))) . + ' (' . $this->translator->trans('Report') . ')', + default => $label . + ' (' . $this->translator->trans("Report's question") . ')', }, 'constraints' => [new Callback([ 'callback' => static function ($selected, ExecutionContextInterface $context) { @@ -391,21 +364,13 @@ class ReportList implements ExportElementValidatedInterface, ListInterface $prefix = substr($f, 0, 7); $suffix = substr($f, 7); - switch ($prefix) { - case 'person_': - $qb->addSelect(sprintf('person.%s as %s', $suffix, $f)); - - break; - - case 'report_': - $qb->addSelect(sprintf('report.%s as %s', $suffix, $f)); - - break; - - default: - throw new LogicException("this prefix {$prefix} should " - . "not be encountered. Full field: {$f}"); - } + match ($prefix) { + 'person_' => $qb->addSelect(sprintf('person.%s as %s', $suffix, $f)), + 'report_' => $qb->addSelect(sprintf('report.%s as %s', $suffix, $f)), + // no break + default => throw new LogicException("this prefix {$prefix} should " + . "not be encountered. Full field: {$f}"), + }; } } @@ -470,7 +435,7 @@ class ReportList implements ExportElementValidatedInterface, ListInterface // get the field starting with address_ $addressFields = array_filter( $this->fields, - static fn (string $el): bool => substr($el, 0, 8) === 'address_' + static fn (string $el): bool => str_starts_with($el, 'address_') ); // check if there is one field starting with address in data diff --git a/src/Bundle/ChillReportBundle/Export/Filter/ReportDateFilter.php b/src/Bundle/ChillReportBundle/Export/Filter/ReportDateFilter.php index 79bad4f52..6117d2f48 100644 --- a/src/Bundle/ChillReportBundle/Export/Filter/ReportDateFilter.php +++ b/src/Bundle/ChillReportBundle/Export/Filter/ReportDateFilter.php @@ -19,12 +19,8 @@ use Doctrine\ORM\Query\Expr; class ReportDateFilter implements FilterInterface { - private RollingDateConverterInterface $rollingDateConverter; - - public function __construct( - RollingDateConverterInterface $rollingDateConverter - ) { - $this->rollingDateConverter = $rollingDateConverter; + public function __construct(private RollingDateConverterInterface $rollingDateConverter) + { } public function addRole(): ?string diff --git a/src/Bundle/ChillReportBundle/Search/ReportSearch.php b/src/Bundle/ChillReportBundle/Search/ReportSearch.php index b08e01ee5..8fbc24e16 100644 --- a/src/Bundle/ChillReportBundle/Search/ReportSearch.php +++ b/src/Bundle/ChillReportBundle/Search/ReportSearch.php @@ -31,29 +31,16 @@ class ReportSearch extends AbstractSearch implements ContainerAwareInterface { use \Symfony\Component\DependencyInjection\ContainerAwareTrait; - /** - * @var EntityManagerInterface - */ - private $em; - - /** - * @var AuthorizationHelper - */ - private $helper; - /** * @var \Chill\MainBundle\Entity\User */ private $user; public function __construct( - EntityManagerInterface $em, - AuthorizationHelper $helper, + private EntityManagerInterface $em, + private AuthorizationHelper $helper, TokenStorageInterface $tokenStorage ) { - $this->em = $em; - $this->helper = $helper; - if (!$tokenStorage->getToken()->getUser() instanceof \Chill\MainBundle\Entity\User) { throw new RuntimeException('an user must be associated with token'); } diff --git a/src/Bundle/ChillReportBundle/Tests/Search/ReportSearchTest.php b/src/Bundle/ChillReportBundle/Tests/Search/ReportSearchTest.php index 294eccd03..dc20b1704 100644 --- a/src/Bundle/ChillReportBundle/Tests/Search/ReportSearchTest.php +++ b/src/Bundle/ChillReportBundle/Tests/Search/ReportSearchTest.php @@ -103,11 +103,9 @@ final class ReportSearchTest extends WebTestCase } /** - * @param mixed $username - * * @return \Symfony\Component\BrowserKit\Client */ - private function getAuthenticatedClient($username = 'center a_social') + private function getAuthenticatedClient(mixed $username = 'center a_social') { return self::createClient([], [ 'PHP_AUTH_USER' => $username, diff --git a/src/Bundle/ChillReportBundle/Timeline/TimelineReportProvider.php b/src/Bundle/ChillReportBundle/Timeline/TimelineReportProvider.php index 0e28fffa9..d2e856131 100644 --- a/src/Bundle/ChillReportBundle/Timeline/TimelineReportProvider.php +++ b/src/Bundle/ChillReportBundle/Timeline/TimelineReportProvider.php @@ -35,28 +35,8 @@ use function strtr; */ class TimelineReportProvider implements TimelineProviderInterface { - protected CustomFieldsHelper $customFieldsHelper; - - protected EntityManager $em; - - protected AuthorizationHelper $helper; - - protected bool $showEmptyValues; - - private Security $security; - - public function __construct( - EntityManager $em, - AuthorizationHelper $helper, - Security $security, - CustomFieldsHelper $customFieldsHelper, - $showEmptyValues - ) { - $this->em = $em; - $this->helper = $helper; - $this->security = $security; - $this->customFieldsHelper = $customFieldsHelper; - $this->showEmptyValues = $showEmptyValues; + public function __construct(protected EntityManager $em, protected AuthorizationHelper $helper, private Security $security, protected CustomFieldsHelper $customFieldsHelper, protected $showEmptyValues) + { } public function fetchQuery($context, array $args) @@ -212,16 +192,11 @@ class TimelineReportProvider implements TimelineProviderInterface private function getWhereClause(string $context, array $args): array { - switch ($context) { - case 'person': - return $this->getWhereClauseForPerson($context, $args); - - case 'center': - return $this->getWhereClauseForCenter($context, $args); - - default: - throw new UnexpectedValueException("This context {$context} is not implemented"); - } + return match ($context) { + 'person' => $this->getWhereClauseForPerson($context, $args), + 'center' => $this->getWhereClauseForCenter($context, $args), + default => throw new UnexpectedValueException("This context {$context} is not implemented"), + }; } private function getWhereClauseForCenter(string $context, array $args): array diff --git a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php index 2ba9488b6..ec523ad43 100644 --- a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php +++ b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php @@ -47,40 +47,8 @@ use function array_merge; final class SingleTaskController extends AbstractController { - private CenterResolverDispatcherInterface $centerResolverDispatcher; - - private EventDispatcherInterface $eventDispatcher; - - private FilterOrderHelperFactoryInterface $filterOrderHelperFactory; - - private LoggerInterface $logger; - - private PaginatorFactory $paginatorFactory; - - private SingleTaskAclAwareRepositoryInterface $singleTaskAclAwareRepository; - - private TimelineBuilder $timelineBuilder; - - private TranslatorInterface $translator; - - public function __construct( - CenterResolverDispatcherInterface $centerResolverDispatcher, - PaginatorFactory $paginatorFactory, - SingleTaskAclAwareRepositoryInterface $singleTaskAclAwareRepository, - TranslatorInterface $translator, - EventDispatcherInterface $eventDispatcher, - TimelineBuilder $timelineBuilder, - LoggerInterface $logger, - FilterOrderHelperFactoryInterface $filterOrderHelperFactory - ) { - $this->eventDispatcher = $eventDispatcher; - $this->timelineBuilder = $timelineBuilder; - $this->logger = $logger; - $this->translator = $translator; - $this->centerResolverDispatcher = $centerResolverDispatcher; - $this->paginatorFactory = $paginatorFactory; - $this->singleTaskAclAwareRepository = $singleTaskAclAwareRepository; - $this->filterOrderHelperFactory = $filterOrderHelperFactory; + public function __construct(private CenterResolverDispatcherInterface $centerResolverDispatcher, private PaginatorFactory $paginatorFactory, private SingleTaskAclAwareRepositoryInterface $singleTaskAclAwareRepository, private TranslatorInterface $translator, private EventDispatcherInterface $eventDispatcher, private TimelineBuilder $timelineBuilder, private LoggerInterface $logger, private FilterOrderHelperFactoryInterface $filterOrderHelperFactory) + { } /** @@ -88,10 +56,8 @@ final class SingleTaskController extends AbstractController * "/{_locale}/task/single-task/{id}/delete", * name="chill_task_single_task_delete" * ) - * - * @param mixed $id */ - public function deleteAction(Request $request, $id) + public function deleteAction(Request $request, mixed $id) { $course = null; $em = $this->getDoctrine()->getManager(); @@ -593,24 +559,19 @@ final class SingleTaskController extends AbstractController } } - switch ($entityType) { - case 'person': - return $this->render('@ChillTask/SingleTask/Person/new.html.twig', [ - 'form' => $form->createView(), - 'task' => $task, - 'person' => $task->getPerson(), - ]); - - case 'course': - return $this->render('@ChillTask/SingleTask/AccompanyingCourse/new.html.twig', [ - 'form' => $form->createView(), - 'task' => $task, - 'accompanyingCourse' => $task->getCourse(), - ]); - - default: - throw new LogicException('entity context not supported'); - } + return match ($entityType) { + 'person' => $this->render('@ChillTask/SingleTask/Person/new.html.twig', [ + 'form' => $form->createView(), + 'task' => $task, + 'person' => $task->getPerson(), + ]), + 'course' => $this->render('@ChillTask/SingleTask/AccompanyingCourse/new.html.twig', [ + 'form' => $form->createView(), + 'task' => $task, + 'accompanyingCourse' => $task->getCourse(), + ]), + default => throw new LogicException('entity context not supported'), + }; } /** @@ -687,7 +648,7 @@ final class SingleTaskController extends AbstractController * Creates a form to delete a Task entity by id. * @param mixed $id */ - private function createDeleteForm($id): FormInterface + private function createDeleteForm(mixed $id): FormInterface { return $this->createFormBuilder() ->setAction($this->generateUrl( diff --git a/src/Bundle/ChillTaskBundle/Event/UI/UIEvent.php b/src/Bundle/ChillTaskBundle/Event/UI/UIEvent.php index 1acfe0562..ac88a1d3a 100644 --- a/src/Bundle/ChillTaskBundle/Event/UI/UIEvent.php +++ b/src/Bundle/ChillTaskBundle/Event/UI/UIEvent.php @@ -30,11 +30,6 @@ class UIEvent extends Event */ protected $form; - /** - * @var string - */ - protected $kind; - /** * @var Response|null */ @@ -50,16 +45,15 @@ class UIEvent extends Event */ protected $transition; - public function __construct($kind, AbstractTask $task) + /** + * @param string $kind + */ + public function __construct(protected $kind, AbstractTask $task) { - $this->kind = $kind; $this->task = $task; } - /** - * @return FormInterface|null - */ - public function getForm() + public function getForm(): ?\Symfony\Component\Form\FormInterface { return $this->form; } diff --git a/src/Bundle/ChillTaskBundle/Form/SingleTaskListType.php b/src/Bundle/ChillTaskBundle/Form/SingleTaskListType.php index 2af71810d..1fb0dda1f 100644 --- a/src/Bundle/ChillTaskBundle/Form/SingleTaskListType.php +++ b/src/Bundle/ChillTaskBundle/Form/SingleTaskListType.php @@ -230,11 +230,10 @@ class SingleTaskListType extends AbstractType /** * Return a list of user having a task assigned. * - * @param mixed $options * * @return User[] */ - protected function getUsersAssigneedToTask($options) + protected function getUsersAssigneedToTask(mixed $options) { $qb = $this->em->createQueryBuilder(); $user = $this->tokenStorage->getToken()->getUser(); diff --git a/src/Bundle/ChillTaskBundle/Form/SingleTaskType.php b/src/Bundle/ChillTaskBundle/Form/SingleTaskType.php index d27a2aa06..4378696d0 100644 --- a/src/Bundle/ChillTaskBundle/Form/SingleTaskType.php +++ b/src/Bundle/ChillTaskBundle/Form/SingleTaskType.php @@ -28,20 +28,8 @@ use Symfony\Component\Security\Core\Role\Role; class SingleTaskType extends AbstractType { - private CenterResolverDispatcherInterface $centerResolverDispatcher; - - private ParameterBagInterface $parameterBag; - - private ScopeResolverDispatcher $scopeResolverDispatcher; - - public function __construct( - ParameterBagInterface $parameterBag, - CenterResolverDispatcherInterface $centerResolverDispatcher, - ScopeResolverDispatcher $scopeResolverDispatcher - ) { - $this->parameterBag = $parameterBag; - $this->centerResolverDispatcher = $centerResolverDispatcher; - $this->scopeResolverDispatcher = $scopeResolverDispatcher; + public function __construct(private ParameterBagInterface $parameterBag, private CenterResolverDispatcherInterface $centerResolverDispatcher, private ScopeResolverDispatcher $scopeResolverDispatcher) + { } public function buildForm(FormBuilderInterface $builder, array $options) diff --git a/src/Bundle/ChillTaskBundle/Menu/MenuBuilder.php b/src/Bundle/ChillTaskBundle/Menu/MenuBuilder.php index 2ecd2f5de..ef0ae2428 100644 --- a/src/Bundle/ChillTaskBundle/Menu/MenuBuilder.php +++ b/src/Bundle/ChillTaskBundle/Menu/MenuBuilder.php @@ -59,25 +59,12 @@ class MenuBuilder implements LocalMenuBuilderInterface public function buildMenu($menuId, MenuItem $menu, array $parameters) { - switch ($menuId) { - case 'person': - $this->buildPersonMenu($menu, $parameters); - - break; - - case 'accompanyingCourse': - $this->buildAccompanyingCourseMenu($menu, $parameters); - - break; - - case 'section': - $menu->setExtras('icons'); - - break; - - default: - throw new LogicException("this menuid {$menuId} is not implemented"); - } + match ($menuId) { + 'person' => $this->buildPersonMenu($menu, $parameters), + 'accompanyingCourse' => $this->buildAccompanyingCourseMenu($menu, $parameters), + 'section' => $menu->setExtras('icons'), + default => throw new LogicException("this menuid {$menuId} is not implemented"), + }; } public function buildPersonMenu($menu, $parameters) diff --git a/src/Bundle/ChillTaskBundle/Repository/SingleTaskAclAwareRepository.php b/src/Bundle/ChillTaskBundle/Repository/SingleTaskAclAwareRepository.php index 0efc16085..8c95aa9ee 100644 --- a/src/Bundle/ChillTaskBundle/Repository/SingleTaskAclAwareRepository.php +++ b/src/Bundle/ChillTaskBundle/Repository/SingleTaskAclAwareRepository.php @@ -29,24 +29,8 @@ use function substr; final class SingleTaskAclAwareRepository implements SingleTaskAclAwareRepositoryInterface { - private AuthorizationHelperInterface $authorizationHelper; - - private CenterResolverManagerInterface $centerResolverDispatcher; - - private EntityManagerInterface $em; - - private Security $security; - - public function __construct( - CenterResolverManagerInterface $centerResolverDispatcher, - EntityManagerInterface $em, - Security $security, - AuthorizationHelperInterface $authorizationHelper - ) { - $this->centerResolverDispatcher = $centerResolverDispatcher; - $this->em = $em; - $this->security = $security; - $this->authorizationHelper = $authorizationHelper; + public function __construct(private CenterResolverManagerInterface $centerResolverDispatcher, private EntityManagerInterface $em, private Security $security, private AuthorizationHelperInterface $authorizationHelper) + { } public function buildBaseQuery( @@ -119,7 +103,7 @@ final class SingleTaskAclAwareRepository implements SingleTaskAclAwareRepository break; - case substr($flag, 0, 6) === 'state_': + case str_starts_with($flag, 'state_'): $state = substr($flag, 6); $orXState ->add( diff --git a/src/Bundle/ChillTaskBundle/Security/Authorization/AuthorizationEvent.php b/src/Bundle/ChillTaskBundle/Security/Authorization/AuthorizationEvent.php index f6ae64592..eac97c8e2 100644 --- a/src/Bundle/ChillTaskBundle/Security/Authorization/AuthorizationEvent.php +++ b/src/Bundle/ChillTaskBundle/Security/Authorization/AuthorizationEvent.php @@ -18,16 +18,6 @@ class AuthorizationEvent extends Event { public const VOTE = 'chill_task.vote'; - /** - * @var string - */ - protected $attribute; - - /** - * @var \Chill\PersonBundle\Entity\Person|Chill\TaskBundle\Entity\AbstractTask|null - */ - protected $subject; - /** * @var TokenInterface */ @@ -38,13 +28,15 @@ class AuthorizationEvent extends Event */ protected $vote; + /** + * @param string $attribute + * @param \Chill\PersonBundle\Entity\Person|\Chill\TaskBundle\Entity\AbstractTask|null $subject + */ public function __construct( - $subject, - $attribute, + protected \Chill\PersonBundle\Entity\Person|\Chill\TaskBundle\Security\Authorization\Chill\TaskBundle\Entity\AbstractTask|null $subject, + protected $attribute, TokenInterface $token ) { - $this->subject = $subject; - $this->attribute = $attribute; $this->token = $token; } diff --git a/src/Bundle/ChillTaskBundle/Security/Authorization/TaskVoter.php b/src/Bundle/ChillTaskBundle/Security/Authorization/TaskVoter.php index f21249453..6031f64d1 100644 --- a/src/Bundle/ChillTaskBundle/Security/Authorization/TaskVoter.php +++ b/src/Bundle/ChillTaskBundle/Security/Authorization/TaskVoter.php @@ -48,24 +48,14 @@ final class TaskVoter extends AbstractChillVoter implements ProvideRoleHierarchy public const UPDATE = 'CHILL_TASK_TASK_UPDATE'; - private AccessDecisionManagerInterface $accessDecisionManager; - - private EventDispatcherInterface $eventDispatcher; - - private LoggerInterface $logger; - private VoterHelperInterface $voter; public function __construct( - AccessDecisionManagerInterface $accessDecisionManager, - EventDispatcherInterface $eventDispatcher, - LoggerInterface $logger, + private AccessDecisionManagerInterface $accessDecisionManager, + private EventDispatcherInterface $eventDispatcher, + private LoggerInterface $logger, VoterHelperFactoryInterface $voterFactory ) { - $this->accessDecisionManager = $accessDecisionManager; - $this->eventDispatcher = $eventDispatcher; - $this->logger = $logger; - $this->voter = $voterFactory ->generate(AbstractTask::class) ->addCheckFor(AbstractTask::class, self::ROLES) diff --git a/src/Bundle/ChillTaskBundle/Tests/Controller/SingleTaskControllerTest.php b/src/Bundle/ChillTaskBundle/Tests/Controller/SingleTaskControllerTest.php index 2ff7092f0..80f213a92 100644 --- a/src/Bundle/ChillTaskBundle/Tests/Controller/SingleTaskControllerTest.php +++ b/src/Bundle/ChillTaskBundle/Tests/Controller/SingleTaskControllerTest.php @@ -76,11 +76,9 @@ final class SingleTaskControllerTest extends WebTestCase } /** - * @param mixed $centerName - * * @return \Chill\PersonBundle\Entity\Person */ - protected function getRandomPerson($centerName) + protected function getRandomPerson(mixed $centerName) { $em = self::$kernel ->getContainer() diff --git a/src/Bundle/ChillTaskBundle/Timeline/TaskLifeCycleEventTimelineProvider.php b/src/Bundle/ChillTaskBundle/Timeline/TaskLifeCycleEventTimelineProvider.php index aa8776aa2..4efe57c7c 100644 --- a/src/Bundle/ChillTaskBundle/Timeline/TaskLifeCycleEventTimelineProvider.php +++ b/src/Bundle/ChillTaskBundle/Timeline/TaskLifeCycleEventTimelineProvider.php @@ -40,24 +40,8 @@ class TaskLifeCycleEventTimelineProvider implements TimelineProviderInterface { public const TYPE = 'chill_task.transition'; - protected AuthorizationHelper $authorizationHelper; - - protected EntityManagerInterface $em; - - protected Registry $registry; - - protected Security $security; - - public function __construct( - EntityManagerInterface $em, - Registry $registry, - AuthorizationHelper $authorizationHelper, - Security $security - ) { - $this->em = $em; - $this->registry = $registry; - $this->authorizationHelper = $authorizationHelper; - $this->security = $security; + public function __construct(protected EntityManagerInterface $em, protected Registry $registry, protected AuthorizationHelper $authorizationHelper, protected Security $security) + { } public function fetchQuery($context, $args) @@ -65,20 +49,11 @@ class TaskLifeCycleEventTimelineProvider implements TimelineProviderInterface $metadata = $this->em ->getClassMetadata(SingleTaskPlaceEvent::class); - switch ($context) { - case 'person': - [ $where, $parameters ] = $this->getWhereClauseForPerson($args['person']); - - break; - - case 'center': - [ $where, $parameters ] = $this->getWhereClauseForCenter($args['centers']); - - break; - - default: - throw new UnexpectedValueException("context {$context} is not supported"); - } + [ $where, $parameters ] = match ($context) { + 'person' => $this->getWhereClauseForPerson($args['person']), + 'center' => $this->getWhereClauseForCenter($args['centers']), + default => throw new UnexpectedValueException("context {$context} is not supported"), + }; return TimelineSingleQuery::fromArray([ 'id' => sprintf('%s.%s.%s', $metadata->getSchemaName(), $metadata->getTableName(), $metadata->getColumnName('id')), diff --git a/src/Bundle/ChillThirdPartyBundle/Controller/ThirdPartyController.php b/src/Bundle/ChillThirdPartyBundle/Controller/ThirdPartyController.php index bc7a9effd..da806a750 100644 --- a/src/Bundle/ChillThirdPartyBundle/Controller/ThirdPartyController.php +++ b/src/Bundle/ChillThirdPartyBundle/Controller/ThirdPartyController.php @@ -32,31 +32,16 @@ use function array_merge; final class ThirdPartyController extends CRUDController { - protected AuthorizationHelper $authorizationHelper; - - protected PaginatorFactory $paginatorFactory; - - protected RequestStack $requestStack; - - protected ThirdPartyACLAwareRepositoryInterface $thirdPartyACLAwareRepository; - - protected TranslatorInterface $translator; - private bool $askCenter; public function __construct( - AuthorizationHelper $authorizationHelper, - TranslatorInterface $translator, - PaginatorFactory $paginatorFactory, - RequestStack $requestStack, - ThirdPartyACLAwareRepositoryInterface $thirdPartyACLAwareRepository, + protected AuthorizationHelper $authorizationHelper, + protected TranslatorInterface $translator, + protected PaginatorFactory $paginatorFactory, + protected RequestStack $requestStack, + protected ThirdPartyACLAwareRepositoryInterface $thirdPartyACLAwareRepository, ParameterBagInterface $parameterBag ) { - $this->authorizationHelper = $authorizationHelper; - $this->translator = $translator; - $this->paginatorFactory = $paginatorFactory; - $this->requestStack = $requestStack; - $this->thirdPartyACLAwareRepository = $thirdPartyACLAwareRepository; $this->askCenter = $parameterBag->get('chill_main')['acl']['form_show_centers']; } diff --git a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php index 09b8ba516..b8ea8126c 100644 --- a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php +++ b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php @@ -88,7 +88,7 @@ use function spl_object_hash; * "thirdparty": ThirdParty::class * }) */ -class ThirdParty implements TrackCreationInterface, TrackUpdateInterface +class ThirdParty implements TrackCreationInterface, TrackUpdateInterface, \Stringable { public const KIND_CHILD = 'child'; @@ -293,7 +293,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface /** * @return string */ - public function __toString() + public function __toString(): string { return $this->getName(); } @@ -437,10 +437,8 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface /** * Get comment. - * - * @return string|null */ - public function getComment() + public function getComment(): ?string { return $this->comment; } @@ -488,9 +486,6 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface return $this->parent; } - /** - * @return string - */ public function getProfession(): string { return $this->profession; @@ -506,10 +501,8 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface /** * Get type. - * - * @return array|null */ - public function getThirdPartyTypes() + public function getThirdPartyTypes(): ?array { return $this->thirdPartyTypes ?? []; } @@ -649,8 +642,6 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface /** * @param string $acronym - * - * @return $this */ public function setAcronym(?string $acronym = null): ThirdParty { @@ -701,9 +692,6 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface return $this; } - /** - * @return $this - */ public function setCivility(?Civility $civility): ThirdParty { $this->civility = $civility; @@ -714,11 +702,10 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface /** * Set comment. * - * @param string|null $comment * * @return ThirdParty */ - public function setComment($comment = null) + public function setComment(?string $comment = null) { $this->comment = $comment; @@ -754,11 +741,10 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface /** * Set email. * - * @param string|null $email * * @return ThirdParty */ - public function setEmail($email = null) + public function setEmail(?string $email = null) { $this->email = trim((string) $email); @@ -796,9 +782,6 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface return $this; } - /** - * @return $this - */ public function setParent(?ThirdParty $parent): ThirdParty { $this->parent = $parent; diff --git a/src/Bundle/ChillThirdPartyBundle/Export/Helper/LabelThirdPartyHelper.php b/src/Bundle/ChillThirdPartyBundle/Export/Helper/LabelThirdPartyHelper.php index 2e7a20840..61fb03226 100644 --- a/src/Bundle/ChillThirdPartyBundle/Export/Helper/LabelThirdPartyHelper.php +++ b/src/Bundle/ChillThirdPartyBundle/Export/Helper/LabelThirdPartyHelper.php @@ -18,14 +18,8 @@ use const SORT_NUMERIC; class LabelThirdPartyHelper { - private ThirdPartyRender $thirdPartyRender; - - private ThirdPartyRepository $thirdPartyRepository; - - public function __construct(ThirdPartyRender $thirdPartyRender, ThirdPartyRepository $thirdPartyRepository) + public function __construct(private ThirdPartyRender $thirdPartyRender, private ThirdPartyRepository $thirdPartyRepository) { - $this->thirdPartyRender = $thirdPartyRender; - $this->thirdPartyRepository = $thirdPartyRepository; } public function getLabel(string $key, array $values, string $header): callable diff --git a/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php b/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php index b1446a543..91e915e09 100644 --- a/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php +++ b/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php @@ -38,31 +38,16 @@ use function array_key_exists; class ThirdPartyType extends AbstractType { - protected AuthorizationHelper $authorizationHelper; - - protected EntityManagerInterface $om; - - protected TokenStorageInterface $tokenStorage; - - protected TranslatableStringHelper $translatableStringHelper; - - protected ThirdPartyTypeManager $typesManager; - private bool $askCenter; public function __construct( - AuthorizationHelper $authorizationHelper, - TokenStorageInterface $tokenStorage, - ThirdPartyTypeManager $typesManager, - TranslatableStringHelper $translatableStringHelper, - EntityManagerInterface $om, + protected AuthorizationHelper $authorizationHelper, + protected TokenStorageInterface $tokenStorage, + protected ThirdPartyTypeManager $typesManager, + protected TranslatableStringHelper $translatableStringHelper, + protected EntityManagerInterface $om, ParameterBagInterface $parameterBag ) { - $this->authorizationHelper = $authorizationHelper; - $this->tokenStorage = $tokenStorage; - $this->typesManager = $typesManager; - $this->translatableStringHelper = $translatableStringHelper; - $this->om = $om; $this->askCenter = $parameterBag->get('chill_main')['acl']['form_show_centers']; } diff --git a/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdPartyTypeCategoryType.php b/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdPartyTypeCategoryType.php index 26cb0ae2e..a02785545 100644 --- a/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdPartyTypeCategoryType.php +++ b/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdPartyTypeCategoryType.php @@ -30,24 +30,8 @@ class PickThirdPartyTypeCategoryType extends \Symfony\Component\Form\AbstractTyp { private const PREFIX_TYPE = 'chill_3party.key_label.'; - private ThirdPartyCategoryRepository $thirdPartyCategoryRepository; - - private ThirdPartyTypeManager $thirdPartyTypeManager; - - private TranslatableStringHelper $translatableStringHelper; - - private TranslatorInterface $translator; - - public function __construct( - ThirdPartyCategoryRepository $thirdPartyCategoryRepository, - ThirdPartyTypeManager $thirdPartyTypeManager, - TranslatableStringHelper $translatableStringHelper, - TranslatorInterface $translator - ) { - $this->thirdPartyCategoryRepository = $thirdPartyCategoryRepository; - $this->thirdPartyTypeManager = $thirdPartyTypeManager; - $this->translatableStringHelper = $translatableStringHelper; - $this->translator = $translator; + public function __construct(private ThirdPartyCategoryRepository $thirdPartyCategoryRepository, private ThirdPartyTypeManager $thirdPartyTypeManager, private TranslatableStringHelper $translatableStringHelper, private TranslatorInterface $translator) + { } public function configureOptions(OptionsResolver $resolver) diff --git a/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdpartyDynamicType.php b/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdpartyDynamicType.php index eb9e7e5ea..8ae1702ce 100644 --- a/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdpartyDynamicType.php +++ b/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdpartyDynamicType.php @@ -26,17 +26,8 @@ use Symfony\Component\Serializer\SerializerInterface; */ class PickThirdpartyDynamicType extends AbstractType { - private DenormalizerInterface $denormalizer; - - private NormalizerInterface $normalizer; - - private SerializerInterface $serializer; - - public function __construct(DenormalizerInterface $denormalizer, SerializerInterface $serializer, NormalizerInterface $normalizer) + public function __construct(private DenormalizerInterface $denormalizer, private SerializerInterface $serializer, private NormalizerInterface $normalizer) { - $this->denormalizer = $denormalizer; - $this->serializer = $serializer; - $this->normalizer = $normalizer; } public function buildForm(FormBuilderInterface $builder, array $options) diff --git a/src/Bundle/ChillThirdPartyBundle/Repository/ThirdPartyACLAwareRepository.php b/src/Bundle/ChillThirdPartyBundle/Repository/ThirdPartyACLAwareRepository.php index 9200bc6ed..283622e56 100644 --- a/src/Bundle/ChillThirdPartyBundle/Repository/ThirdPartyACLAwareRepository.php +++ b/src/Bundle/ChillThirdPartyBundle/Repository/ThirdPartyACLAwareRepository.php @@ -17,17 +17,8 @@ use Symfony\Component\Security\Core\Security; final class ThirdPartyACLAwareRepository implements ThirdPartyACLAwareRepositoryInterface { - private AuthorizationHelper $authorizationHelper; - - private Security $security; - - private ThirdPartyRepository $thirdPartyRepository; - - public function __construct(Security $security, AuthorizationHelper $authorizationHelper, ThirdPartyRepository $thirdPartyRepository) + public function __construct(private Security $security, private AuthorizationHelper $authorizationHelper, private ThirdPartyRepository $thirdPartyRepository) { - $this->security = $security; - $this->authorizationHelper = $authorizationHelper; - $this->thirdPartyRepository = $thirdPartyRepository; } public function buildQuery(?string $filterString = null): QueryBuilder diff --git a/src/Bundle/ChillThirdPartyBundle/Search/ThirdPartyApiSearch.php b/src/Bundle/ChillThirdPartyBundle/Search/ThirdPartyApiSearch.php index 86c0fa9db..8b0a26849 100644 --- a/src/Bundle/ChillThirdPartyBundle/Search/ThirdPartyApiSearch.php +++ b/src/Bundle/ChillThirdPartyBundle/Search/ThirdPartyApiSearch.php @@ -49,11 +49,8 @@ FROM rows, searches */ class ThirdPartyApiSearch implements SearchApiInterface { - private ThirdPartyRepository $thirdPartyRepository; - - public function __construct(ThirdPartyRepository $thirdPartyRepository) + public function __construct(private ThirdPartyRepository $thirdPartyRepository) { - $this->thirdPartyRepository = $thirdPartyRepository; } public function getResult(string $key, array $metadata, float $pertinence) diff --git a/src/Bundle/ChillThirdPartyBundle/Search/ThirdPartySearch.php b/src/Bundle/ChillThirdPartyBundle/Search/ThirdPartySearch.php index 2c7948a2d..0421d0f34 100644 --- a/src/Bundle/ChillThirdPartyBundle/Search/ThirdPartySearch.php +++ b/src/Bundle/ChillThirdPartyBundle/Search/ThirdPartySearch.php @@ -48,20 +48,17 @@ class ThirdPartySearch implements SearchInterface */ protected $tokenStorage; - private ThirdPartyRepository $thirdPartyRepository; - public function __construct( EntityManagerInterface $em, TokenStorageInterface $tokenStorage, AuthorizationHelper $authorizationHelper, PaginatorFactory $paginatorFactory, - ThirdPartyRepository $thirdPartyRepository + private ThirdPartyRepository $thirdPartyRepository ) { $this->em = $em; $this->tokenStorage = $tokenStorage; $this->authorizationHelper = $authorizationHelper; $this->paginatorFactory = $paginatorFactory; - $this->thirdPartyRepository = $thirdPartyRepository; } public function getOrder(): int diff --git a/src/Bundle/ChillThirdPartyBundle/Serializer/Normalizer/ThirdPartyNormalizer.php b/src/Bundle/ChillThirdPartyBundle/Serializer/Normalizer/ThirdPartyNormalizer.php index 7b2721511..b3f898a76 100644 --- a/src/Bundle/ChillThirdPartyBundle/Serializer/Normalizer/ThirdPartyNormalizer.php +++ b/src/Bundle/ChillThirdPartyBundle/Serializer/Normalizer/ThirdPartyNormalizer.php @@ -24,16 +24,8 @@ class ThirdPartyNormalizer implements NormalizerAwareInterface, NormalizerInterf { use NormalizerAwareTrait; - private ThirdPartyRender $thirdPartyRender; - - private TranslatableStringHelperInterface $translatableStringHelper; - - public function __construct( - ThirdPartyRender $thirdPartyRender, - TranslatableStringHelperInterface $translatableStringHelper - ) { - $this->thirdPartyRender = $thirdPartyRender; - $this->translatableStringHelper = $translatableStringHelper; + public function __construct(private ThirdPartyRender $thirdPartyRender, private TranslatableStringHelperInterface $translatableStringHelper) + { } public function normalize($thirdParty, $format = null, array $context = []) diff --git a/src/Bundle/ChillThirdPartyBundle/Templating/Entity/ThirdPartyRender.php b/src/Bundle/ChillThirdPartyBundle/Templating/Entity/ThirdPartyRender.php index ece12f5c9..4432c5045 100644 --- a/src/Bundle/ChillThirdPartyBundle/Templating/Entity/ThirdPartyRender.php +++ b/src/Bundle/ChillThirdPartyBundle/Templating/Entity/ThirdPartyRender.php @@ -24,16 +24,9 @@ use Symfony\Component\Templating\EngineInterface; class ThirdPartyRender implements ChillEntityRenderInterface { use BoxUtilsChillEntityRenderTrait; - protected EngineInterface $engine; - protected TranslatableStringHelper $translatableStringHelper; - - public function __construct( - EngineInterface $engine, - TranslatableStringHelper $translatableStringHelper - ) { - $this->engine = $engine; - $this->translatableStringHelper = $translatableStringHelper; + public function __construct(protected EngineInterface $engine, protected TranslatableStringHelper $translatableStringHelper) + { } public function renderBox($entity, array $options): string diff --git a/src/Bundle/ChillWopiBundle/src/Controller/Convert.php b/src/Bundle/ChillWopiBundle/src/Controller/Convert.php index b3697aafd..d7e90e46a 100644 --- a/src/Bundle/ChillWopiBundle/src/Controller/Convert.php +++ b/src/Bundle/ChillWopiBundle/src/Controller/Convert.php @@ -37,32 +37,17 @@ class Convert private string $collaboraDomain; - private HttpClientInterface $httpClient; - - private LoggerInterface $logger; - - private RequestStack $requestStack; - - private Security $security; - - private StoredObjectManagerInterface $storedObjectManager; - /** * @param StoredObjectManager $storedObjectManager */ public function __construct( - HttpClientInterface $httpClient, - RequestStack $requestStack, - Security $security, - StoredObjectManagerInterface $storedObjectManager, - LoggerInterface $logger, + private HttpClientInterface $httpClient, + private RequestStack $requestStack, + private Security $security, + private StoredObjectManagerInterface $storedObjectManager, + private LoggerInterface $logger, ParameterBagInterface $parameters ) { - $this->httpClient = $httpClient; - $this->requestStack = $requestStack; - $this->security = $security; - $this->storedObjectManager = $storedObjectManager; - $this->logger = $logger; $this->collaboraDomain = $parameters->get('wopi')['server']; } diff --git a/src/Bundle/ChillWopiBundle/src/Controller/Editor.php b/src/Bundle/ChillWopiBundle/src/Controller/Editor.php index ab4276ec4..ec10cc973 100644 --- a/src/Bundle/ChillWopiBundle/src/Controller/Editor.php +++ b/src/Bundle/ChillWopiBundle/src/Controller/Editor.php @@ -38,48 +38,8 @@ use Twig\Environment; */ final class Editor { - private DocumentManagerInterface $documentManager; - - private EngineInterface $engine; - - private JWTTokenManagerInterface $JWTTokenManager; - - private Psr17Interface $psr17; - - private ResponderInterface $responder; - - private RouterInterface $router; - - private Security $security; - - private ConfigurationInterface $wopiConfiguration; - - private DiscoveryInterface $wopiDiscovery; - - private NormalizerInterface $normalizer; - - public function __construct( - ConfigurationInterface $wopiConfiguration, - DiscoveryInterface $wopiDiscovery, - DocumentManagerInterface $documentManager, - EngineInterface $engine, - JWTTokenManagerInterface $JWTTokenManager, - NormalizerInterface $normalizer, - ResponderInterface $responder, - Security $security, - Psr17Interface $psr17, - RouterInterface $router - ) { - $this->documentManager = $documentManager; - $this->engine = $engine; - $this->JWTTokenManager = $JWTTokenManager; - $this->normalizer = $normalizer; - $this->wopiConfiguration = $wopiConfiguration; - $this->wopiDiscovery = $wopiDiscovery; - $this->responder = $responder; - $this->security = $security; - $this->psr17 = $psr17; - $this->router = $router; + public function __construct(private ConfigurationInterface $wopiConfiguration, private DiscoveryInterface $wopiDiscovery, private DocumentManagerInterface $documentManager, private EngineInterface $engine, private JWTTokenManagerInterface $JWTTokenManager, private NormalizerInterface $normalizer, private ResponderInterface $responder, private Security $security, private Psr17Interface $psr17, private RouterInterface $router) + { } public function __invoke(string $fileId, Request $request): Response diff --git a/src/Bundle/ChillWopiBundle/src/Service/Controller/Responder.php b/src/Bundle/ChillWopiBundle/src/Service/Controller/Responder.php index 78033e111..af22cf952 100644 --- a/src/Bundle/ChillWopiBundle/src/Service/Controller/Responder.php +++ b/src/Bundle/ChillWopiBundle/src/Service/Controller/Responder.php @@ -22,20 +22,8 @@ use Twig\Environment; final class Responder implements ResponderInterface { - private SerializerInterface $serializer; - - private Environment $twig; - - private UrlGeneratorInterface $urlGenerator; - - public function __construct( - Environment $twig, - UrlGeneratorInterface $urlGenerator, - SerializerInterface $serializer - ) { - $this->twig = $twig; - $this->urlGenerator = $urlGenerator; - $this->serializer = $serializer; + public function __construct(private Environment $twig, private UrlGeneratorInterface $urlGenerator, private SerializerInterface $serializer) + { } public function file( diff --git a/src/Bundle/ChillWopiBundle/src/Service/Wopi/AuthorizationManager.php b/src/Bundle/ChillWopiBundle/src/Service/Wopi/AuthorizationManager.php index 24ea00982..08cdec97e 100644 --- a/src/Bundle/ChillWopiBundle/src/Service/Wopi/AuthorizationManager.php +++ b/src/Bundle/ChillWopiBundle/src/Service/Wopi/AuthorizationManager.php @@ -19,14 +19,8 @@ use Symfony\Component\Security\Core\Security; class AuthorizationManager implements \ChampsLibres\WopiBundle\Contracts\AuthorizationManagerInterface { - private Security $security; - - private JWTTokenManagerInterface $tokenManager; - - public function __construct(JWTTokenManagerInterface $tokenManager, Security $security) + public function __construct(private JWTTokenManagerInterface $tokenManager, private Security $security) { - $this->tokenManager = $tokenManager; - $this->security = $security; } public function isRestrictedWebViewOnly(string $accessToken, Document $document, RequestInterface $request): bool diff --git a/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillDocumentLockManager.php b/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillDocumentLockManager.php index fce25de58..358831f87 100644 --- a/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillDocumentLockManager.php +++ b/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillDocumentLockManager.php @@ -26,11 +26,8 @@ class ChillDocumentLockManager implements DocumentLockManagerInterface */ private const LOCK_GRACEFUL_DURATION_TIME = 3; - private ChillRedis $redis; - - public function __construct(ChillRedis $redis) + public function __construct(private ChillRedis $redis) { - $this->redis = $redis; } public function deleteLock(Document $document, RequestInterface $request): bool diff --git a/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillDocumentManager.php b/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillDocumentManager.php index ce75cafa8..6084d4785 100644 --- a/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillDocumentManager.php +++ b/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillDocumentManager.php @@ -34,33 +34,18 @@ use function strlen; final class ChillDocumentManager implements DocumentManagerInterface { - private DocumentLockManagerInterface $documentLockManager; - - private EntityManagerInterface $entityManager; - - private Psr17Interface $psr17; - private RequestInterface $request; - private StoredObjectManagerInterface $storedObjectManager; - - private StoredObjectRepository $storedObjectRepository; - public function __construct( - DocumentLockManagerInterface $documentLockManager, - EntityManagerInterface $entityManager, + private DocumentLockManagerInterface $documentLockManager, + private EntityManagerInterface $entityManager, HttpMessageFactoryInterface $httpMessageFactory, - Psr17Interface $psr17, + private Psr17Interface $psr17, RequestStack $requestStack, - StoredObjectManagerInterface $storedObjectManager, - StoredObjectRepository $storedObjectRepository + private StoredObjectManagerInterface $storedObjectManager, + private StoredObjectRepository $storedObjectRepository ) { - $this->documentLockManager = $documentLockManager; - $this->entityManager = $entityManager; - $this->psr17 = $psr17; $this->request = $httpMessageFactory->createRequest($requestStack->getCurrentRequest()); - $this->storedObjectManager = $storedObjectManager; - $this->storedObjectRepository = $storedObjectRepository; } public function create(array $data): Document diff --git a/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillWopi.php b/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillWopi.php index 82dbadf7b..88f863cd1 100644 --- a/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillWopi.php +++ b/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillWopi.php @@ -17,12 +17,8 @@ use Psr\Http\Message\ResponseInterface; final class ChillWopi implements WopiInterface { - private WopiInterface $wopi; - - public function __construct( - WopiInterface $wopi - ) { - $this->wopi = $wopi; + public function __construct(private WopiInterface $wopi) + { } public function checkFileInfo( diff --git a/src/Bundle/ChillWopiBundle/src/Service/Wopi/UserManager.php b/src/Bundle/ChillWopiBundle/src/Service/Wopi/UserManager.php index 3fb3b544e..96ed5c651 100644 --- a/src/Bundle/ChillWopiBundle/src/Service/Wopi/UserManager.php +++ b/src/Bundle/ChillWopiBundle/src/Service/Wopi/UserManager.php @@ -17,11 +17,8 @@ use Symfony\Component\Security\Core\Security; class UserManager implements \ChampsLibres\WopiBundle\Contracts\UserManagerInterface { - private Security $security; - - public function __construct(Security $security) + public function __construct(private Security $security) { - $this->security = $security; } public function getUserFriendlyName(string $accessToken, string $fileId, RequestInterface $request): ?string From 9027cbd196b4988cb058a07805c90bbf49f14808 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 17 Apr 2023 15:25:09 +0200 Subject: [PATCH 050/724] DX: rector config: up to PHP8 [ci-skip][wip] --- rector.php | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/rector.php b/rector.php index ec9a0c684..5e304c8b4 100644 --- a/rector.php +++ b/rector.php @@ -21,7 +21,7 @@ return static function (RectorConfig $rectorConfig): void { //define sets of rules $rectorConfig->sets([ - LevelSetList::UP_TO_PHP_74 + LevelSetList::UP_TO_PHP_80 ]); // skip some path... @@ -36,25 +36,25 @@ return static function (RectorConfig $rectorConfig): void { \Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector::class, // remove all PHP80 rules, in order to activate them one by one - \Rector\Php80\Rector\ClassMethod\AddParamBasedOnParentClassMethodRector::class, - \Rector\Php80\Rector\Class_\AnnotationToAttributeRector::class, - \Rector\Php80\Rector\Switch_\ChangeSwitchToMatchRector::class, - \Rector\Php80\Rector\FuncCall\ClassOnObjectRector::class, - \Rector\Php80\Rector\ClassConstFetch\ClassOnThisVariableObjectRector::class, - \Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector::class, - \Rector\Php80\Rector\Class_\DoctrineAnnotationClassToAttributeRector::class, - \Rector\Php80\Rector\ClassMethod\FinalPrivateToPrivateVisibilityRector::class, - \Rector\Php80\Rector\Ternary\GetDebugTypeRector::class, - \Rector\Php80\Rector\FunctionLike\MixedTypeRector::class, - \Rector\Php80\Rector\Property\NestedAnnotationToAttributeRector::class, - \Rector\Php80\Rector\FuncCall\Php8ResourceReturnToObjectRector::class, - \Rector\Php80\Rector\Catch_\RemoveUnusedVariableInCatchRector::class, - \Rector\Php80\Rector\ClassMethod\SetStateToStaticRector::class, - \Rector\Php80\Rector\NotIdentical\StrContainsRector::class, - \Rector\Php80\Rector\Identical\StrEndsWithRector::class, - \Rector\Php80\Rector\Identical\StrStartsWithRector::class, - \Rector\Php80\Rector\Class_\StringableForToStringRector::class, - \Rector\Php80\Rector\FuncCall\TokenGetAllToObjectRector::class, - \Rector\Php80\Rector\FunctionLike\UnionTypesRector::class +// \Rector\Php80\Rector\ClassMethod\AddParamBasedOnParentClassMethodRector::class, +// \Rector\Php80\Rector\Class_\AnnotationToAttributeRector::class, +// \Rector\Php80\Rector\Switch_\ChangeSwitchToMatchRector::class, +// \Rector\Php80\Rector\FuncCall\ClassOnObjectRector::class, +// \Rector\Php80\Rector\ClassConstFetch\ClassOnThisVariableObjectRector::class, +// \Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector::class, +// \Rector\Php80\Rector\Class_\DoctrineAnnotationClassToAttributeRector::class, +// \Rector\Php80\Rector\ClassMethod\FinalPrivateToPrivateVisibilityRector::class, +// \Rector\Php80\Rector\Ternary\GetDebugTypeRector::class, +// \Rector\Php80\Rector\FunctionLike\MixedTypeRector::class, +// \Rector\Php80\Rector\Property\NestedAnnotationToAttributeRector::class, +// \Rector\Php80\Rector\FuncCall\Php8ResourceReturnToObjectRector::class, +// \Rector\Php80\Rector\Catch_\RemoveUnusedVariableInCatchRector::class, +// \Rector\Php80\Rector\ClassMethod\SetStateToStaticRector::class, +// \Rector\Php80\Rector\NotIdentical\StrContainsRector::class, +// \Rector\Php80\Rector\Identical\StrEndsWithRector::class, +// \Rector\Php80\Rector\Identical\StrStartsWithRector::class, +// \Rector\Php80\Rector\Class_\StringableForToStringRector::class, +// \Rector\Php80\Rector\FuncCall\TokenGetAllToObjectRector::class, +// \Rector\Php80\Rector\FunctionLike\UnionTypesRector::class ]); }; From c35994203d7022c215b3b897ebb7ae0ec60c5285 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 28 Apr 2023 22:55:01 +0200 Subject: [PATCH 051/724] fix phpstan issues --- .../Export/Export/ListActivityHelper.php | 1 - .../Controller/CustomFieldController.php | 3 --- .../CustomFields/CustomFieldLongChoice.php | 9 ++++++-- .../CRUD/Controller/ApiController.php | 2 ++ .../Authorization/AuthorizationHelper.php | 4 ++-- .../PasswordRecover/PasswordRecoverEvent.php | 22 +++++-------------- .../RollingDate/RollingDateConverter.php | 1 - .../Form/ChoiceLoader/PersonChoiceLoader.php | 5 ----- .../DataFixtures/ORM/LoadReports.php | 2 ++ .../Authorization/AuthorizationEvent.php | 18 +++++---------- 10 files changed, 24 insertions(+), 43 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Export/Export/ListActivityHelper.php b/src/Bundle/ChillActivityBundle/Export/Export/ListActivityHelper.php index 5af351b28..43c9f4688 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/ListActivityHelper.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/ListActivityHelper.php @@ -113,7 +113,6 @@ class ListActivityHelper 'usersIds' => self::MSG_KEY . 'users ids', 'thirdPartiesIds' => self::MSG_KEY . 'third parties ids', 'personsIds' => self::MSG_KEY . 'persons ids', - default => throw new LogicException('key not supported'), }; } diff --git a/src/Bundle/ChillCustomFieldsBundle/Controller/CustomFieldController.php b/src/Bundle/ChillCustomFieldsBundle/Controller/CustomFieldController.php index bc7bcfd65..a188ed277 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Controller/CustomFieldController.php +++ b/src/Bundle/ChillCustomFieldsBundle/Controller/CustomFieldController.php @@ -162,9 +162,6 @@ class CustomFieldController extends AbstractController /** * Creates a form to create a CustomField entity. * - * @param CustomField $entity The entity - * @param string - * * @return \Symfony\Component\Form\Form The form */ private function createCreateForm(CustomField $entity, mixed $type) diff --git a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldLongChoice.php b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldLongChoice.php index 23f7b36bb..aa73af462 100644 --- a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldLongChoice.php +++ b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldLongChoice.php @@ -15,6 +15,7 @@ use Chill\CustomFieldsBundle\Entity\CustomField; use Chill\CustomFieldsBundle\Entity\CustomFieldLongChoice\Option; use Chill\CustomFieldsBundle\EntityRepository\CustomFieldLongChoice\OptionRepository; use Chill\CustomFieldsBundle\Form\DataTransformer\CustomFieldDataTransformer; +use Chill\FamilyMembersBundle\Templating\Twig; use Chill\MainBundle\Form\Type\Select2ChoiceType; use Chill\MainBundle\Templating\TranslatableStringHelper; use LogicException; @@ -22,6 +23,7 @@ use Symfony\Bridge\Twig\TwigEngine; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\FormBuilderInterface; +use Symfony\Component\Templating\EngineInterface; use function get_class; use function gettype; use function is_object; @@ -30,8 +32,11 @@ class CustomFieldLongChoice extends AbstractCustomField { public const KEY = 'key'; - public function __construct(private OptionRepository $optionRepository, private TranslatableStringHelper $translatableStringHelper, private TwigEngine $templating) - { + public function __construct( + private OptionRepository $optionRepository, + private TranslatableStringHelper $translatableStringHelper, + private EngineInterface $templating, + ) { } public function buildForm(FormBuilderInterface $builder, CustomField $customField) diff --git a/src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php b/src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php index c18dfd542..41a37d7ca 100644 --- a/src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php +++ b/src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php @@ -258,7 +258,9 @@ class ApiController extends AbstractCRUDController } match ($request->getMethod()) { + /* @phpstan-ignore-next-line */ Request::METHOD_DELETE => $entity->{'remove' . ucfirst($property)}($postedData), + /* @phpstan-ignore-next-line */ Request::METHOD_POST => $entity->{'add' . ucfirst($property)}($postedData), default => throw new BadRequestHttpException('this method is not supported'), }; diff --git a/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php b/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php index 2ba3865b7..c431c4492 100644 --- a/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php +++ b/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php @@ -209,9 +209,9 @@ class AuthorizationHelper implements AuthorizationHelperInterface throw new UnexpectedValueException( sprintf( - 'The entity given is not an instance of %s, %s given', + 'The entity given is not an instance of %s or an array of centers, %s given', Center::class, - $center::class + gettype($center) ) ); } diff --git a/src/Bundle/ChillMainBundle/Security/PasswordRecover/PasswordRecoverEvent.php b/src/Bundle/ChillMainBundle/Security/PasswordRecover/PasswordRecoverEvent.php index 8bc23b54a..5c8a01e1d 100644 --- a/src/Bundle/ChillMainBundle/Security/PasswordRecover/PasswordRecoverEvent.php +++ b/src/Bundle/ChillMainBundle/Security/PasswordRecover/PasswordRecoverEvent.php @@ -23,25 +23,15 @@ class PasswordRecoverEvent extends Event public const INVALID_TOKEN = 'chill_main.password_recover_invalid_token'; /** - * @var bool - */ - protected $safelyGenerated; - - /** - * @var User - */ - protected $user; - - /** - * @param type $token - * @param User $user - * @param type $ip * @param bool $safelyGenerated true if generated safely (from console command, etc.) */ - public function __construct(protected $token = null, ?User $user = null, protected $ip = null, bool $safelyGenerated = false) + public function __construct( + private ?string $token = null, + private ?User $user = null, + private $ip = null, + private bool $safelyGenerated = false, + ) { - $this->user = $user; - $this->safelyGenerated = $safelyGenerated; } public function getIp() diff --git a/src/Bundle/ChillMainBundle/Service/RollingDate/RollingDateConverter.php b/src/Bundle/ChillMainBundle/Service/RollingDate/RollingDateConverter.php index 0b9d5e4cd..da59e9e2b 100644 --- a/src/Bundle/ChillMainBundle/Service/RollingDate/RollingDateConverter.php +++ b/src/Bundle/ChillMainBundle/Service/RollingDate/RollingDateConverter.php @@ -87,7 +87,6 @@ class RollingDateConverter implements RollingDateConverterInterface 4, 5, 6 => '04', 7, 8, 9 => '07', 10, 11, 12 => '10', - default => throw new LogicException('this month is not valid: ' . $date->format('n')), }; return DateTimeImmutable::createFromFormat( diff --git a/src/Bundle/ChillPersonBundle/Form/ChoiceLoader/PersonChoiceLoader.php b/src/Bundle/ChillPersonBundle/Form/ChoiceLoader/PersonChoiceLoader.php index 05e720243..684914618 100644 --- a/src/Bundle/ChillPersonBundle/Form/ChoiceLoader/PersonChoiceLoader.php +++ b/src/Bundle/ChillPersonBundle/Form/ChoiceLoader/PersonChoiceLoader.php @@ -30,11 +30,6 @@ class PersonChoiceLoader implements ChoiceLoaderInterface protected array $lazyLoadedPersons = []; - /** - * PersonChoiceLoader constructor. - * - * @param EntityRepository $personRepository - */ public function __construct( protected PersonRepository $personRepository, ?array $centers = null diff --git a/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReports.php b/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReports.php index ae35e9eac..2dcf69c50 100644 --- a/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReports.php +++ b/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReports.php @@ -211,6 +211,8 @@ class LoadReports extends AbstractFixture implements ContainerAwareInterface, Or return $result; } } + + throw new \LogicException("should not happens"); } /** diff --git a/src/Bundle/ChillTaskBundle/Security/Authorization/AuthorizationEvent.php b/src/Bundle/ChillTaskBundle/Security/Authorization/AuthorizationEvent.php index eac97c8e2..1607ec56c 100644 --- a/src/Bundle/ChillTaskBundle/Security/Authorization/AuthorizationEvent.php +++ b/src/Bundle/ChillTaskBundle/Security/Authorization/AuthorizationEvent.php @@ -11,6 +11,8 @@ declare(strict_types=1); namespace Chill\TaskBundle\Security\Authorization; +use Chill\PersonBundle\Entity\Person; +use Chill\TaskBundle\Entity\AbstractTask; use Symfony\Component\EventDispatcher\Event; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; @@ -18,26 +20,16 @@ class AuthorizationEvent extends Event { public const VOTE = 'chill_task.vote'; - /** - * @var TokenInterface - */ - protected $token; - /** * @var bool */ protected $vote; - /** - * @param string $attribute - * @param \Chill\PersonBundle\Entity\Person|\Chill\TaskBundle\Entity\AbstractTask|null $subject - */ public function __construct( - protected \Chill\PersonBundle\Entity\Person|\Chill\TaskBundle\Security\Authorization\Chill\TaskBundle\Entity\AbstractTask|null $subject, - protected $attribute, - TokenInterface $token + private Person|AbstractTask|null $subject, + private string $attribute, + private TokenInterface $token ) { - $this->token = $token; } public function getAttribute() From 7e194198616f08670202002c7c8a3842d86e3351 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 28 Apr 2023 23:03:36 +0200 Subject: [PATCH 052/724] fixes for last rebase and fixes for runtime --- .../CustomFieldsGroupController.php | 4 +-- .../Config/ConfigRepository.php | 4 +-- .../Controller/FamilyMemberController.php | 11 ++---- .../ChillMainExtension.php | 2 +- .../ChillMainBundle/Notification/Mailer.php | 34 ++----------------- .../PasswordRecover/RecoverPasswordHelper.php | 22 ++---------- .../Resolver/ScopeResolverDispatcher.php | 2 +- .../Controller/SingleTaskController.php | 1 - 8 files changed, 11 insertions(+), 69 deletions(-) diff --git a/src/Bundle/ChillCustomFieldsBundle/Controller/CustomFieldsGroupController.php b/src/Bundle/ChillCustomFieldsBundle/Controller/CustomFieldsGroupController.php index 68ccb9904..2ae552b01 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Controller/CustomFieldsGroupController.php +++ b/src/Bundle/ChillCustomFieldsBundle/Controller/CustomFieldsGroupController.php @@ -36,7 +36,7 @@ class CustomFieldsGroupController extends AbstractController /** * CustomFieldsGroupController constructor. */ - public function __construct(private CustomFieldProvider $customfieldProvider, private TranslatorInterface $translator) + public function __construct(private CustomFieldProvider $customFieldProvider, private TranslatorInterface $translator) { } @@ -283,7 +283,7 @@ class CustomFieldsGroupController extends AbstractController { $fieldChoices = []; - foreach ($this->customfieldProvider->getAllFields() + foreach ($this->customFieldProvider->getAllFields() as $key => $customType) { $fieldChoices[$key] = $customType->getName(); } diff --git a/src/Bundle/ChillFamilyMembersBundle/Config/ConfigRepository.php b/src/Bundle/ChillFamilyMembersBundle/Config/ConfigRepository.php index c361984f0..7fc9c6c47 100644 --- a/src/Bundle/ChillFamilyMembersBundle/Config/ConfigRepository.php +++ b/src/Bundle/ChillFamilyMembersBundle/Config/ConfigRepository.php @@ -27,10 +27,8 @@ class ConfigRepository /** * @param mixed[] $links - * @param mixed $professionnalSituations - * @param mixed $familialSituations */ - public function __construct(protected $links, $professionnalSituations, $familialSituations) + public function __construct(protected $links, mixed $professionnalSituations, mixed $familialSituations) { $this->professionalSituations = $professionnalSituations ?? []; $this->familialSituations = $familialSituations ?? []; diff --git a/src/Bundle/ChillFamilyMembersBundle/Controller/FamilyMemberController.php b/src/Bundle/ChillFamilyMembersBundle/Controller/FamilyMemberController.php index 5892ddbc4..34a83dfcb 100644 --- a/src/Bundle/ChillFamilyMembersBundle/Controller/FamilyMemberController.php +++ b/src/Bundle/ChillFamilyMembersBundle/Controller/FamilyMemberController.php @@ -28,15 +28,8 @@ use Symfony\Contracts\Translation\TranslatorInterface; class FamilyMemberController extends AbstractController { - private FamilyMemberRepository $familyMemberRepository; - - public function __construct( - private EntityManagerInterface $em, - protected TranslatorInterface $translator, - protected LoggerInterface $chillMainLogger, - FamilyMemberRepository $familyMemberRepository - ) { - $this->familyMemberRepository = $familyMemberRepository; + public function __construct(private EntityManagerInterface $em, protected TranslatorInterface $translator, protected LoggerInterface $chillMainLogger, private FamilyMemberRepository $familyMemberRepository) + { } /** diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php index 2da35e7ef..dd74b2c09 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php @@ -93,7 +93,7 @@ class ChillMainExtension extends Extension implements $this->widgetFactories[] = $factory; } - public function getConfiguration(array $config, ContainerBuilder $container): \Chill\MainBundle\DependencyInjection\Configuration|object|\Symfony\Component\Config\Definition\ConfigurationInterface|null + public function getConfiguration(array $config, ContainerBuilder $container): \Chill\MainBundle\DependencyInjection\Configuration { return new Configuration($this->widgetFactories, $container); } diff --git a/src/Bundle/ChillMainBundle/Notification/Mailer.php b/src/Bundle/ChillMainBundle/Notification/Mailer.php index d0a449787..b65d29c8d 100644 --- a/src/Bundle/ChillMainBundle/Notification/Mailer.php +++ b/src/Bundle/ChillMainBundle/Notification/Mailer.php @@ -34,44 +34,14 @@ use function call_user_func; */ class Mailer { - /** - * @var LoggerInterface - */ - private $logger; - - /** - * @var RouterInterface - */ - private $router; - - /** - * @var TranslatorInterface - */ - private $translator; - - private EngineInterface $twig; - - private MailerInterface $mailer; - /** * Mailer constructor. * * @param $routeParameters * @param mixed[] $routeParameters */ - public function __construct( - MailerInterface $mailer, - LoggerInterface $logger, - EngineInterface $twig, - RouterInterface $router, - TranslatorInterface $translator, - protected $routeParameters - ) { - $this->logger = $logger; - $this->twig = $twig; - $this->mailer = $mailer; - $this->router = $router; - $this->translator = $translator; + public function __construct(private MailerInterface $mailer, private LoggerInterface $logger, private EngineInterface $twig, private RouterInterface $router, private TranslatorInterface $translator, protected $routeParameters) + { } /** diff --git a/src/Bundle/ChillMainBundle/Security/PasswordRecover/RecoverPasswordHelper.php b/src/Bundle/ChillMainBundle/Security/PasswordRecover/RecoverPasswordHelper.php index 42881e291..4598f6199 100644 --- a/src/Bundle/ChillMainBundle/Security/PasswordRecover/RecoverPasswordHelper.php +++ b/src/Bundle/ChillMainBundle/Security/PasswordRecover/RecoverPasswordHelper.php @@ -24,26 +24,8 @@ class RecoverPasswordHelper { public const RECOVER_PASSWORD_ROUTE = 'password_recover'; - private MailerInterface $mailer; - - /** - * @var TokenManager - */ - private $tokenManager; - - /** - * @var UrlGeneratorInterface - */ - private $urlGenerator; - - public function __construct( - TokenManager $tokenManager, - UrlGeneratorInterface $urlGenerator, - MailerInterface $mailer, - ) { - $this->tokenManager = $tokenManager; - $this->urlGenerator = $urlGenerator; - $this->mailer = $mailer; + public function __construct(private TokenManager $tokenManager, private UrlGeneratorInterface $urlGenerator, private MailerInterface $mailer) + { } /** diff --git a/src/Bundle/ChillMainBundle/Security/Resolver/ScopeResolverDispatcher.php b/src/Bundle/ChillMainBundle/Security/Resolver/ScopeResolverDispatcher.php index 1c40ad282..151754ae7 100644 --- a/src/Bundle/ChillMainBundle/Security/Resolver/ScopeResolverDispatcher.php +++ b/src/Bundle/ChillMainBundle/Security/Resolver/ScopeResolverDispatcher.php @@ -39,7 +39,7 @@ final class ScopeResolverDispatcher * * @return iterable|Scope|Scope[] */ - public function resolveScope($entity, ?array $options = []): iterable|\Chill\MainBundle\Entity\Scope|array + public function resolveScope($entity, ?array $options = []): iterable|\Chill\MainBundle\Entity\Scope { foreach ($this->resolvers as $resolver) { if ($resolver->supports($entity, $options)) { diff --git a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php index ec523ad43..a1085657a 100644 --- a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php +++ b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php @@ -646,7 +646,6 @@ final class SingleTaskController extends AbstractController /** * Creates a form to delete a Task entity by id. - * @param mixed $id */ private function createDeleteForm(mixed $id): FormInterface { From 24c33b306b5c01c654e71b91d1e078717555d9ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 28 Apr 2023 23:16:13 +0200 Subject: [PATCH 053/724] Fix: urgent fix for EntityToJsonTransformer The throw on error flag imposes us to propose a valid json string for decoding --- .../Form/Type/DataTransformer/EntityToJsonTransformer.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php index 109e83b14..9ab91222c 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php +++ b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php @@ -31,6 +31,10 @@ class EntityToJsonTransformer implements DataTransformerInterface public function reverseTransform($value) { + if ("" === $value) { + return null; + } + $denormalized = json_decode($value, true, 512, JSON_THROW_ON_ERROR); if ($this->multiple) { @@ -44,10 +48,6 @@ class EntityToJsonTransformer implements DataTransformerInterface ); } - if ('' === $value) { - return null; - } - return $this->denormalizeOne($denormalized); } From 1c7d90a6efbc1a099d6dc5a0df369fbcc44f629d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 28 Apr 2023 23:17:41 +0200 Subject: [PATCH 054/724] fixes from a first test --- .../CustomFields/CustomFieldChoice.php | 8 +------- .../ChillPersonBundle/Entity/AccompanyingPeriod.php | 2 +- .../Security/Authorization/AuthorizationEvent.php | 3 ++- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldChoice.php b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldChoice.php index 88ef15e3e..8add4b995 100644 --- a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldChoice.php +++ b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldChoice.php @@ -370,14 +370,8 @@ class CustomFieldChoice extends AbstractCustomField * * If the value had an 'allow_other' = true option, the returned value * **is not** the content of the _other field, but the `_other` string. - * - * @param array|string $value - * - * @throws LogicException if the case is not covered by this - * - * @return mixed */ - private function guessValue(array|string $value) + private function guessValue(array|string|null $value) { if (null === $value) { return null; diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php index 15970471a..f4c36e7b7 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php @@ -952,7 +952,7 @@ class AccompanyingPeriod implements /** * @Groups({"read"}) */ - public function getRequestor(): \Chill\PersonBundle\Entity\Person|\Chill\ThirdPartyBundle\Entity\ThirdParty + public function getRequestor(): Person|ThirdParty|null { return $this->requestorPerson ?? $this->requestorThirdParty; } diff --git a/src/Bundle/ChillTaskBundle/Security/Authorization/AuthorizationEvent.php b/src/Bundle/ChillTaskBundle/Security/Authorization/AuthorizationEvent.php index 1607ec56c..d7ccc0db9 100644 --- a/src/Bundle/ChillTaskBundle/Security/Authorization/AuthorizationEvent.php +++ b/src/Bundle/ChillTaskBundle/Security/Authorization/AuthorizationEvent.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\TaskBundle\Security\Authorization; +use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\Person; use Chill\TaskBundle\Entity\AbstractTask; use Symfony\Component\EventDispatcher\Event; @@ -26,7 +27,7 @@ class AuthorizationEvent extends Event protected $vote; public function __construct( - private Person|AbstractTask|null $subject, + private Person|AbstractTask|AccompanyingPeriod|null $subject, private string $attribute, private TokenInterface $token ) { From 07c681fcec5df8c4065e7b48aff389b6e198825f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 28 Apr 2023 23:19:05 +0200 Subject: [PATCH 055/724] DX: update rector config --- rector.php | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/rector.php b/rector.php index 5e304c8b4..55de05fcd 100644 --- a/rector.php +++ b/rector.php @@ -34,27 +34,5 @@ return static function (RectorConfig $rectorConfig): void { // must merge MR500 and review a typing of "ArrayCollection" in entities \Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector::class, - - // remove all PHP80 rules, in order to activate them one by one -// \Rector\Php80\Rector\ClassMethod\AddParamBasedOnParentClassMethodRector::class, -// \Rector\Php80\Rector\Class_\AnnotationToAttributeRector::class, -// \Rector\Php80\Rector\Switch_\ChangeSwitchToMatchRector::class, -// \Rector\Php80\Rector\FuncCall\ClassOnObjectRector::class, -// \Rector\Php80\Rector\ClassConstFetch\ClassOnThisVariableObjectRector::class, -// \Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector::class, -// \Rector\Php80\Rector\Class_\DoctrineAnnotationClassToAttributeRector::class, -// \Rector\Php80\Rector\ClassMethod\FinalPrivateToPrivateVisibilityRector::class, -// \Rector\Php80\Rector\Ternary\GetDebugTypeRector::class, -// \Rector\Php80\Rector\FunctionLike\MixedTypeRector::class, -// \Rector\Php80\Rector\Property\NestedAnnotationToAttributeRector::class, -// \Rector\Php80\Rector\FuncCall\Php8ResourceReturnToObjectRector::class, -// \Rector\Php80\Rector\Catch_\RemoveUnusedVariableInCatchRector::class, -// \Rector\Php80\Rector\ClassMethod\SetStateToStaticRector::class, -// \Rector\Php80\Rector\NotIdentical\StrContainsRector::class, -// \Rector\Php80\Rector\Identical\StrEndsWithRector::class, -// \Rector\Php80\Rector\Identical\StrStartsWithRector::class, -// \Rector\Php80\Rector\Class_\StringableForToStringRector::class, -// \Rector\Php80\Rector\FuncCall\TokenGetAllToObjectRector::class, -// \Rector\Php80\Rector\FunctionLike\UnionTypesRector::class ]); }; From 2554da9dd81b9fc94b12ee44a8d9bfbe6b468274 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 28 Apr 2023 23:16:13 +0200 Subject: [PATCH 056/724] Fix: urgent fix for EntityToJsonTransformer The throw on error flag imposes us to propose a valid json string for decoding --- .../Form/Type/DataTransformer/EntityToJsonTransformer.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php index 529bd9789..7dff8d672 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php +++ b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php @@ -43,6 +43,10 @@ class EntityToJsonTransformer implements DataTransformerInterface public function reverseTransform($value) { + if ("" === $value) { + return null; + } + $denormalized = json_decode($value, true, 512, JSON_THROW_ON_ERROR); if ($this->multiple) { @@ -56,10 +60,6 @@ class EntityToJsonTransformer implements DataTransformerInterface ); } - if ('' === $value) { - return null; - } - return $this->denormalizeOne($denormalized); } From 737f5f927510fb550a34a2c509ee4d1f2e5c58b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 1 May 2023 21:22:56 +0200 Subject: [PATCH 057/724] fixes --- .../Controller/ActivityController.php | 18 ++++++++++++- .../Entity/ActivityReason.php | 27 ++++--------------- 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php index 3ea61c0cf..69d3f3312 100644 --- a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php +++ b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php @@ -47,7 +47,23 @@ use function array_key_exists; final class ActivityController extends AbstractController { - public function __construct(private ActivityACLAwareRepositoryInterface $activityACLAwareRepository, private ActivityTypeRepositoryInterface $activityTypeRepository, private ActivityTypeCategoryRepository $activityTypeCategoryRepository, private PersonRepository $personRepository, private ThirdPartyRepository $thirdPartyRepository, private LocationRepository $locationRepository, private ActivityRepository $activityRepository, private AccompanyingPeriodRepository $accompanyingPeriodRepository, private EntityManagerInterface $entityManager, private EventDispatcherInterface $eventDispatcher, private LoggerInterface $logger, private SerializerInterface $serializer, private UserRepositoryInterface $userRepository, private CenterResolverManagerInterface $centerResolver, private TranslatorInterface $translator) + public function __construct( + private ActivityACLAwareRepositoryInterface $activityACLAwareRepository, + private ActivityTypeRepositoryInterface $activityTypeRepository, + private ActivityTypeCategoryRepository $activityTypeCategoryRepository, + private PersonRepository $personRepository, + private ThirdPartyRepository $thirdPartyRepository, + private LocationRepository $locationRepository, + private ActivityRepository $activityRepository, + private AccompanyingPeriodRepository $accompanyingPeriodRepository, + private EntityManagerInterface $entityManager, + private EventDispatcherInterface $eventDispatcher, + private LoggerInterface $logger, + private SerializerInterface $serializer, + private UserRepositoryInterface $userRepository, + private CenterResolverManagerInterface $centerResolver, + private TranslatorInterface $translator, + ) { } diff --git a/src/Bundle/ChillActivityBundle/Entity/ActivityReason.php b/src/Bundle/ChillActivityBundle/Entity/ActivityReason.php index 9d1e88409..99504f469 100644 --- a/src/Bundle/ChillActivityBundle/Entity/ActivityReason.php +++ b/src/Bundle/ChillActivityBundle/Entity/ActivityReason.php @@ -23,10 +23,9 @@ use Doctrine\ORM\Mapping as ORM; class ActivityReason { /** - * @var bool * @ORM\Column(type="boolean") */ - private $active = true; + private bool $active = true; /** * @var ActivityReasonCategory @@ -34,7 +33,7 @@ class ActivityReason * targetEntity="Chill\ActivityBundle\Entity\ActivityReasonCategory", * inversedBy="reasons") */ - private $category; + private ?ActivityReasonCategory $category = null; /** * @var int @@ -43,13 +42,13 @@ class ActivityReason * @ORM\Column(name="id", type="integer") * @ORM\GeneratedValue(strategy="AUTO") */ - private $id; + private ?int $id = null; /** * @var array * @ORM\Column(type="json") */ - private $name; + private array $name; /** * Get active. @@ -81,25 +80,9 @@ class ActivityReason /** * Get name. - * - * @param mixed|null $locale */ - public function getName($locale = null): array|string + public function getName(): array { - if ($locale) { - if (isset($this->name[$locale])) { - return $this->name[$locale]; - } - - foreach ($this->name as $name) { - if (!empty($name)) { - return $name; - } - } - - return ''; - } - return $this->name; } From 81e8928344511f9e27b6d3dbd360620c6857e5d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 1 May 2023 21:39:27 +0200 Subject: [PATCH 058/724] DX: configure rector up to php82 --- rector.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rector.php b/rector.php index 55de05fcd..00147e460 100644 --- a/rector.php +++ b/rector.php @@ -21,7 +21,7 @@ return static function (RectorConfig $rectorConfig): void { //define sets of rules $rectorConfig->sets([ - LevelSetList::UP_TO_PHP_80 + LevelSetList::UP_TO_PHP_82 ]); // skip some path... From 6d63177ff4769fb60c5bf5ec85f283498536477c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 1 May 2023 21:39:45 +0200 Subject: [PATCH 059/724] apply rules rector up to php82 --- .../widgets/ChillMainConfiguration.php | 2 +- .../Controller/ActivityController.php | 33 +++++++-------- .../Controller/ActivityReasonController.php | 2 +- .../DataFixtures/ORM/LoadActivity.php | 2 +- .../ChillActivityBundle/Entity/Activity.php | 4 +- .../Entity/ActivityType.php | 6 +-- .../EntityListener/ActivityEntityListener.php | 2 +- .../ACPAggregators/ByCreatorAggregator.php | 2 +- .../BySocialActionAggregator.php | 2 +- .../BySocialIssueAggregator.php | 2 +- .../ACPAggregators/ByThirdpartyAggregator.php | 2 +- .../ACPAggregators/CreatorScopeAggregator.php | 2 +- .../ACPAggregators/DateAggregator.php | 2 +- .../ACPAggregators/LocationTypeAggregator.php | 2 +- .../Aggregator/ActivityTypeAggregator.php | 2 +- .../Aggregator/ActivityUserAggregator.php | 4 +- .../Aggregator/ActivityUsersAggregator.php | 2 +- .../Aggregator/ActivityUsersJobAggregator.php | 2 +- .../ActivityUsersScopeAggregator.php | 2 +- .../Aggregator/SentReceivedAggregator.php | 2 +- .../Export/Declarations.php | 6 +-- .../Export/LinkedToACP/ListActivity.php | 2 +- .../Export/LinkedToPerson/ListActivity.php | 2 +- .../LinkedToPerson/StatActivityDuration.php | 4 +- .../Export/Export/ListActivityHelper.php | 4 +- .../Filter/ACPFilters/ActivityTypeFilter.php | 2 +- .../Filter/ACPFilters/ByCreatorFilter.php | 2 +- .../ACPFilters/BySocialActionFilter.php | 2 +- .../Filter/ACPFilters/BySocialIssueFilter.php | 2 +- .../Filter/ACPFilters/EmergencyFilter.php | 2 +- .../Filter/ACPFilters/LocationTypeFilter.php | 2 +- .../Filter/ACPFilters/SentReceivedFilter.php | 2 +- .../Export/Filter/ACPFilters/UserFilter.php | 2 +- .../Filter/ACPFilters/UserScopeFilter.php | 2 +- .../Export/Filter/ActivityDateFilter.php | 2 +- .../Export/Filter/ActivityUsersFilter.php | 2 +- .../Export/Filter/UsersJobFilter.php | 2 +- .../Export/Filter/UsersScopeFilter.php | 2 +- .../Form/ActivityTypeType.php | 2 +- .../Form/Type/PickActivityReasonType.php | 2 +- ...TranslatableActivityReasonCategoryType.php | 2 +- .../Menu/AdminMenuBuilder.php | 2 +- .../ActivityNotificationHandler.php | 2 +- .../Repository/ActivityACLAwareRepository.php | 2 +- .../Repository/ActivityPresenceRepository.php | 2 +- .../Repository/ActivityReasonRepository.php | 2 +- .../Repository/ActivityTypeRepository.php | 2 +- .../Authorization/ActivityStatsVoter.php | 4 +- .../Security/Authorization/ActivityVoter.php | 16 +++---- .../Service/DocGenerator/ActivityContext.php | 2 +- ...tActivitiesByAccompanyingPeriodContext.php | 2 +- .../Controller/ActivityControllerTest.php | 2 +- .../ActivityReasonCategoryControllerTest.php | 2 +- .../ActivityReasonControllerTest.php | 2 +- .../Controller/ActivityTypeControllerTest.php | 2 +- .../Type/TranslatableActivityReasonTest.php | 2 +- .../Tests/Timeline/TimelineProviderTest.php | 2 +- .../Constraints/ActivityValidity.php | 4 +- .../Controller/AsideActivityController.php | 2 +- .../DataFixtures/ORM/LoadAsideActivity.php | 2 +- .../Aggregator/ByActivityTypeAggregator.php | 2 +- .../Export/Aggregator/ByUserJobAggregator.php | 2 +- .../Aggregator/ByUserScopeAggregator.php | 2 +- .../src/Export/Declarations.php | 2 +- .../Export/AvgAsideActivityDuration.php | 2 +- .../src/Export/Export/CountAsideActivity.php | 2 +- .../src/Export/Export/ListAsideActivity.php | 2 +- .../Export/SumAsideActivityDuration.php | 2 +- .../Export/Filter/ByActivityTypeFilter.php | 2 +- .../src/Export/Filter/ByDateFilter.php | 2 +- .../src/Export/Filter/ByUserFilter.php | 2 +- .../src/Export/Filter/ByUserJobFilter.php | 2 +- .../src/Export/Filter/ByUserScopeFilter.php | 2 +- .../src/Form/AsideActivityCategoryType.php | 2 +- .../src/Form/AsideActivityFormType.php | 10 +---- .../Type/PickAsideActivityCategoryType.php | 2 +- .../src/Menu/AdminMenuBuilder.php | 2 +- .../AsideActivityCategoryRepository.php | 2 +- .../src/Security/AsideActivityVoter.php | 4 +- .../src/Templating/Entity/CategoryRender.php | 2 +- .../Calculator/CalculatorResult.php | 6 +-- .../Controller/ElementController.php | 2 +- .../ChillBudgetBundle/Entity/Charge.php | 10 ++--- .../ChillBudgetBundle/Form/ChargeType.php | 2 +- .../ChillBudgetBundle/Form/ResourceType.php | 2 +- .../Menu/AdminMenuBuilder.php | 2 +- .../Repository/ChargeKindRepository.php | 2 +- .../Repository/ResourceKindRepository.php | 2 +- .../Authorization/BudgetElementVoter.php | 10 ++--- .../Service/Summary/SummaryBudget.php | 2 +- .../Templating/BudgetElementTypeRender.php | 2 +- .../Service/Summary/SummaryBudgetTest.php | 4 +- .../AzureGrantAdminConsentAndAcquireToken.php | 2 +- .../MapAndSubscribeUserCalendarCommand.php | 10 ++--- .../SendShortMessageOnEligibleCalendar.php | 2 +- .../SendTestShortMessageOnCalendarCommand.php | 12 +++--- .../Controller/CalendarAPIController.php | 2 +- .../Controller/CalendarController.php | 2 +- .../Controller/CalendarDocController.php | 4 +- .../Controller/CalendarRangeAPIController.php | 2 +- .../Controller/InviteApiController.php | 2 +- .../RemoteCalendarConnectAzureController.php | 2 +- .../RemoteCalendarMSGraphSyncController.php | 2 +- .../RemoteCalendarProxyController.php | 2 +- .../DataFixtures/ORM/LoadCalendarRange.php | 2 +- .../ChillCalendarBundle/Entity/Calendar.php | 12 +++--- .../Entity/CancelReason.php | 6 +-- .../ChillCalendarBundle/Entity/Invite.php | 10 ++--- .../Event/ListenToActivityCreate.php | 2 +- .../Export/Aggregator/AgentAggregator.php | 2 +- .../Aggregator/CancelReasonAggregator.php | 2 +- .../Export/Aggregator/JobAggregator.php | 2 +- .../Export/Aggregator/LocationAggregator.php | 2 +- .../Aggregator/LocationTypeAggregator.php | 2 +- .../Export/Aggregator/ScopeAggregator.php | 2 +- .../Export/Aggregator/UrgencyAggregator.php | 2 +- .../Export/Declarations.php | 2 +- .../Export/Export/CountCalendars.php | 2 +- .../Export/Export/StatCalendarAvgDuration.php | 2 +- .../Export/Export/StatCalendarSumDuration.php | 2 +- .../Export/Filter/AgentFilter.php | 2 +- .../Export/Filter/BetweenDatesFilter.php | 2 +- .../Export/Filter/CalendarRangeFilter.php | 2 +- .../Export/Filter/JobFilter.php | 2 +- .../Export/Filter/ScopeFilter.php | 2 +- .../ChillCalendarBundle/Form/CalendarType.php | 2 +- .../Menu/AccompanyingCourseMenuBuilder.php | 2 +- .../Menu/PersonMenuBuilder.php | 2 +- .../Menu/UserMenuBuilder.php | 2 +- .../Doctrine/CalendarEntityListener.php | 2 +- .../Doctrine/CalendarRangeEntityListener.php | 2 +- .../CalendarRangeRemoveToRemoteHandler.php | 2 +- .../Handler/CalendarRangeToRemoteHandler.php | 2 +- .../Handler/CalendarRemoveHandler.php | 2 +- .../Handler/CalendarToRemoteHandler.php | 2 +- .../Messenger/Handler/InviteUpdateHandler.php | 2 +- .../MSGraphChangeNotificationHandler.php | 2 +- .../Messenger/Message/CalendarMessage.php | 10 ++--- .../Message/CalendarRangeMessage.php | 8 ++-- .../Message/CalendarRangeRemovedMessage.php | 6 +-- .../Message/CalendarRemovedMessage.php | 6 +-- .../Messenger/Message/InviteUpdateMessage.php | 4 +- .../MSGraphChangeNotificationMessage.php | 2 +- .../Connector/MSGraph/AddressConverter.php | 2 +- .../EventsOnUserSubscriptionCreator.php | 2 +- .../Connector/MSGraph/LocationConverter.php | 2 +- .../MSGraph/MSGraphUserRepository.php | 2 +- .../Connector/MSGraph/MachineHttpClient.php | 4 +- .../Connector/MSGraph/MachineTokenStorage.php | 2 +- .../Connector/MSGraph/MapCalendarToUser.php | 10 ++--- .../MSGraph/OnBehalfOfUserHttpClient.php | 4 +- .../MSGraph/OnBehalfOfUserTokenStorage.php | 4 +- .../MSGraph/RemoteEventConverter.php | 18 ++++---- .../RemoteToLocalSync/CalendarRangeSyncer.php | 2 +- .../RemoteToLocalSync/CalendarSyncer.php | 4 +- .../MSGraphRemoteCalendarConnector.php | 2 +- .../Repository/CalendarACLAwareRepository.php | 2 +- .../Repository/CalendarDocRepository.php | 2 +- .../Repository/CalendarRangeRepository.php | 4 +- .../Repository/CalendarRepository.php | 4 +- .../Repository/InviteRepository.php | 2 +- .../Security/Voter/CalendarDocVoter.php | 6 +-- .../Security/Voter/CalendarVoter.php | 16 +++---- .../Security/Voter/InviteVoter.php | 2 +- .../Service/DocGenerator/CalendarContext.php | 2 +- .../BulkCalendarShortMessageSender.php | 2 +- .../CalendarForShortMessageProvider.php | 2 +- .../DefaultShortMessageForCalendarBuilder.php | 2 +- .../Tests/Form/CalendarTypeTest.php | 2 +- .../Command/CreateFieldsOnGroupCommand.php | 10 ++--- .../CustomFieldsGroupController.php | 2 +- .../CustomFields/CustomFieldChoice.php | 14 +++---- .../CustomFields/CustomFieldDate.php | 10 ++--- .../CustomFields/CustomFieldLongChoice.php | 8 ++-- .../CustomFields/CustomFieldNumber.php | 10 ++--- .../CustomFields/CustomFieldText.php | 10 ++--- .../CustomFields/CustomFieldTitle.php | 12 +++--- .../Entity/CustomField.php | 4 +- .../Form/CustomFieldType.php | 2 +- .../Form/CustomFieldsGroupType.php | 4 +- .../CustomFieldDataTransformer.php | 2 +- .../CustomFieldsGroupToIdTransformer.php | 2 +- .../JsonCustomFieldToArrayTransformer.php | 18 ++++---- .../Form/Type/CustomFieldType.php | 2 +- .../Form/Type/LinkedCustomFieldsType.php | 4 +- .../Service/CustomFieldsHelper.php | 2 +- .../Twig/CustomFieldRenderingTwig.php | 17 ++------ .../Twig/CustomFieldsGroupRenderingTwig.php | 5 +-- .../Context/ContextManager.php | 2 +- .../AdminDocGeneratorTemplateController.php | 2 +- .../DocGeneratorTemplateController.php | 2 +- .../Form/DocGeneratorTemplateType.php | 2 +- .../Exception/TemplateException.php | 2 +- .../GeneratorDriver/RelatorioDriver.php | 6 +-- .../Menu/AdminMenuBuilder.php | 2 +- .../DocGeneratorTemplateRepository.php | 4 +- .../Helper/NormalizeNullValueHelper.php | 2 +- .../Normalizer/DocGenObjectNormalizer.php | 6 +-- .../Service/Context/BaseContextData.php | 2 +- .../Service/Generator/Generator.php | 2 +- .../Service/Generator/GeneratorException.php | 2 +- .../Service/Messenger/OnGenerationFails.php | 2 +- .../Messenger/RequestGenerationHandler.php | 4 +- .../Messenger/RequestGenerationMessage.php | 12 +++--- .../Normalizer/DocGenObjectNormalizerTest.php | 4 +- .../DocumentAccompanyingCourseController.php | 2 +- .../Controller/DocumentPersonController.php | 2 +- .../Controller/StoredObjectApiController.php | 2 +- .../Entity/StoredObject.php | 6 +-- .../Form/DocumentCategoryType.php | 2 +- .../Form/PersonDocumentType.php | 2 +- .../Form/StoredObjectType.php | 14 +++---- .../ChillDocStoreBundle/Menu/MenuBuilder.php | 2 +- .../AccompanyingCourseDocumentRepository.php | 4 +- .../Repository/DocumentCategoryRepository.php | 4 +- .../PersonDocumentACLAwareRepository.php | 2 +- .../Repository/StoredObjectRepository.php | 2 +- .../AccompanyingCourseDocumentVoter.php | 10 ++--- .../Authorization/PersonDocumentVoter.php | 10 ++--- .../Normalizer/StoredObjectDenormalizer.php | 2 +- .../Service/StoredObjectManager.php | 2 +- .../WopiEditTwigExtensionRuntime.php | 4 +- ...ompanyingCourseDocumentWorkflowHandler.php | 4 +- .../Controller/ParticipationController.php | 6 +-- src/Bundle/ChillEventBundle/Entity/Event.php | 2 +- .../ChillEventBundle/Search/EventSearch.php | 10 ++--- .../Security/Authorization/EventVoter.php | 10 ++--- .../Authorization/ParticipationVoter.php | 10 ++--- .../Tests/Controller/EventControllerTest.php | 2 +- .../Controller/EventTypeControllerTest.php | 2 +- .../Tests/Controller/RoleControllerTest.php | 2 +- .../Tests/Controller/StatusControllerTest.php | 2 +- .../Tests/Search/EventSearchTest.php | 2 +- .../Controller/FamilyMemberController.php | 2 +- .../Form/FamilyMemberType.php | 2 +- .../Security/Voter/FamilyMemberVoter.php | 10 ++--- .../Templating/Twig.php | 10 ++--- .../CRUD/Resolver/Resolver.php | 6 +-- .../CRUD/Templating/TwigCRUDResolver.php | 4 +- .../Command/ChillImportUsersCommand.php | 4 +- .../ChillUserSendRenewPasswordCodeCommand.php | 4 +- .../Command/ExecuteCronJobCommand.php | 2 +- .../LoadAddressesBEFromBestAddressCommand.php | 4 +- .../LoadAddressesFRFromBANOCommand.php | 2 +- .../Command/LoadAndUpdateLanguagesCommand.php | 6 +-- .../Command/LoadCountriesCommand.php | 2 +- .../Command/LoadPostalCodeFR.php | 2 +- .../Command/LoadPostalCodesCommand.php | 6 +-- .../Command/SetPasswordCommand.php | 2 +- .../AddressReferenceAPIController.php | 4 +- .../AddressToReferenceMatcherController.php | 2 +- .../Controller/ExportController.php | 4 +- ...GeographicalUnitByAddressApiController.php | 2 +- .../Controller/NotificationApiController.php | 2 +- .../Controller/NotificationController.php | 2 +- .../Controller/PermissionApiController.php | 2 +- .../Controller/PermissionsGroupController.php | 2 +- .../Controller/PostalCodeAPIController.php | 4 +- .../Controller/SavedExportController.php | 2 +- .../Controller/SearchController.php | 2 +- .../Controller/TimelineCenterController.php | 2 +- .../Controller/UserController.php | 4 +- .../Controller/WorkflowApiController.php | 2 +- .../Controller/WorkflowController.php | 2 +- .../ChillMainBundle/Cron/CronManager.php | 2 +- .../DataFixtures/ORM/LoadUsers.php | 2 +- .../CompilerPass/ShortMessageCompilerPass.php | 2 +- .../DependencyInjection/Configuration.php | 2 +- .../Event/TrackCreateUpdateSubscriber.php | 2 +- .../ChillMainBundle/Doctrine/Model/Point.php | 2 +- .../Doctrine/Type/NativeDateIntervalType.php | 8 ++-- .../Doctrine/Type/PointType.php | 2 +- src/Bundle/ChillMainBundle/Entity/Address.php | 6 +-- .../Entity/CronJobExecution.php | 4 +- .../ChillMainBundle/Entity/LocationType.php | 10 ++--- .../ChillMainBundle/Export/ExportManager.php | 6 +-- .../Export/Helper/DateTimeHelper.php | 2 +- .../Export/Helper/ExportAddressHelper.php | 24 +++++------ .../TranslatableStringExportLabelHelper.php | 2 +- .../Export/Helper/UserHelper.php | 2 +- .../DataMapper/PrivateCommentDataMapper.php | 2 +- .../Form/DataMapper/ScopePickerDataMapper.php | 2 +- .../IdToEntityDataTransformer.php | 4 +- .../Form/Event/CustomizeFormEvent.php | 2 +- .../ChillMainBundle/Form/LocationFormType.php | 2 +- .../Form/PermissionsGroupType.php | 2 +- .../Form/Type/ChillPhoneNumberType.php | 4 +- .../Form/Type/ComposedRoleScopeType.php | 2 +- .../AddressToIdDataTransformer.php | 2 +- .../DataTransformer/CenterTransformer.php | 4 +- .../EntityToJsonTransformer.php | 4 +- .../MultipleObjectsToIdTransformer.php | 2 +- .../DataTransformer/ObjectToIdTransformer.php | 2 +- .../PostalCodeToIdTransformer.php | 2 +- .../Type/DataTransformer/ScopeTransformer.php | 2 +- .../Form/Type/Export/ExportType.php | 8 ++-- .../Form/Type/Export/FilterType.php | 2 +- .../Form/Type/Export/PickCenterType.php | 8 ++-- .../Form/Type/Listing/FilterOrderType.php | 2 +- .../Form/Type/PickAddressType.php | 2 +- .../Form/Type/PickCivilityType.php | 2 +- .../Form/Type/PickLocationTypeType.php | 2 +- .../Form/Type/PickPostalCodeType.php | 2 +- .../Form/Type/PickRollingDateType.php | 2 +- .../Form/Type/PickUserDynamicType.php | 2 +- .../Form/Type/PickUserLocationType.php | 2 +- .../Form/Type/ScopePickerType.php | 2 +- .../Form/Type/Select2CountryType.php | 2 +- .../Form/Type/Select2LanguageType.php | 2 +- .../Form/Type/TranslatableStringFormType.php | 2 +- .../Form/Type/UserPickerType.php | 2 +- src/Bundle/ChillMainBundle/Form/UserType.php | 2 +- .../ChillMainBundle/Form/WorkflowStepType.php | 2 +- .../Counter/NotificationByUserCounter.php | 2 +- .../Notification/Email/NotificationMailer.php | 2 +- ...NotificationOnTerminateEventSubscriber.php | 2 +- .../ChillMainBundle/Notification/Mailer.php | 2 +- .../NotificationHandlerManager.php | 2 +- .../Notification/NotificationPresence.php | 2 +- .../NotificationTwigExtensionRuntime.php | 2 +- .../Pagination/ChillItemsPerPageTwig.php | 2 +- .../Pagination/ChillPaginationTwig.php | 6 +-- .../Pagination/PaginatorFactory.php | 10 ++--- .../Phonenumber/PhonenumberHelper.php | 12 +++--- .../Phonenumber/Templating.php | 2 +- .../Redis/RedisConnectionFactory.php | 8 ++-- .../Repository/AddressReferenceRepository.php | 4 +- .../Repository/AddressRepository.php | 2 +- .../Repository/CenterRepository.php | 2 +- .../Repository/CivilityRepository.php | 2 +- .../Repository/CountryRepository.php | 2 +- .../Repository/CronJobExecutionRepository.php | 2 +- .../GeographicalUnitLayerLayerRepository.php | 2 +- .../Repository/GeographicalUnitRepository.php | 2 +- .../Repository/GroupCenterRepository.php | 2 +- .../Repository/LanguageRepository.php | 2 +- .../Repository/NotificationRepository.php | 4 +- .../Repository/PermissionsGroupRepository.php | 2 +- .../Repository/PostalCodeRepository.php | 4 +- .../Repository/RegroupmentRepository.php | 2 +- .../Repository/RoleScopeRepository.php | 2 +- .../Repository/SavedExportRepository.php | 2 +- .../Repository/ScopeRepository.php | 2 +- .../Repository/UserACLAwareRepository.php | 2 +- .../Repository/UserJobRepository.php | 2 +- .../Repository/UserRepository.php | 2 +- .../Workflow/EntityWorkflowRepository.php | 2 +- .../Workflow/EntityWorkflowStepRepository.php | 2 +- .../Routing/Loader/ChillRoutesLoader.php | 2 +- .../Routing/MenuBuilder/UserMenuBuilder.php | 2 +- .../ChillMainBundle/Routing/MenuComposer.php | 2 +- .../ChillMainBundle/Routing/MenuTwig.php | 4 +- .../ChillMainBundle/Search/AbstractSearch.php | 4 +- .../Search/Entity/SearchUserApiProvider.php | 2 +- .../ChillMainBundle/Search/Model/Result.php | 2 +- .../ChillMainBundle/Search/SearchApi.php | 2 +- .../Search/SearchApiNoQueryException.php | 6 +-- .../Search/SearchApiResult.php | 4 +- .../ChillMainBundle/Search/SearchProvider.php | 8 ++-- .../Utils/ExtractPhonenumberFromPattern.php | 2 +- .../Search/Utils/SearchExtractionResult.php | 2 +- .../Authorization/AuthorizationHelper.php | 2 +- .../AuthorizationHelperForCurrentUser.php | 2 +- .../Authorization/ChillExportVoter.php | 4 +- .../Authorization/DefaultVoterHelper.php | 2 +- .../DefaultVoterHelperGenerator.php | 2 +- .../Authorization/EntityWorkflowVoter.php | 10 ++--- .../Authorization/SavedExportVoter.php | 6 +-- .../WorkflowEntityDeletionVoter.php | 2 +- .../PasswordRecover/PasswordRecoverEvent.php | 15 ++++--- .../PasswordRecover/PasswordRecoverLocker.php | 14 +++---- .../PasswordRecover/PasswordRecoverVoter.php | 4 +- .../PasswordRecover/RecoverPasswordHelper.php | 4 +- .../Security/PasswordRecover/TokenManager.php | 12 +++--- .../Resolver/CenterResolverDispatcher.php | 2 +- .../Resolver/CenterResolverManager.php | 2 +- .../Resolver/ResolverTwigExtension.php | 8 ++-- .../Resolver/ScopeResolverDispatcher.php | 2 +- .../Serializer/Model/Collection.php | 2 +- .../Normalizer/AddressNormalizer.php | 2 +- .../Normalizer/CenterNormalizer.php | 2 +- .../CommentEmbeddableDocGenNormalizer.php | 2 +- .../Serializer/Normalizer/DateNormalizer.php | 2 +- .../DiscriminatedObjectDenormalizer.php | 4 +- .../DoctrineExistingEntityNormalizer.php | 2 +- .../Normalizer/EntityWorkflowNormalizer.php | 2 +- .../EntityWorkflowStepNormalizer.php | 2 +- .../Normalizer/NotificationNormalizer.php | 2 +- .../Normalizer/PhonenumberNormalizer.php | 4 +- .../PrivateCommentEmbeddableNormalizer.php | 2 +- .../Serializer/Normalizer/UserNormalizer.php | 13 ++---- ...eographicalUnitMaterializedViewCronJob.php | 2 +- .../AddressReferenceBEFromBestAddress.php | 2 +- .../Import/AddressReferenceBaseImporter.php | 2 +- .../Import/AddressReferenceFromBano.php | 2 +- .../Import/AddressToReferenceMatcher.php | 2 +- .../Import/GeographicalUnitBaseImporter.php | 2 +- .../Import/PostalCodeBEFromBestAddress.php | 6 +-- .../Service/Import/PostalCodeBaseImporter.php | 2 +- .../Import/PostalCodeFRFromOpenData.php | 10 ++--- .../Service/Mailer/ChillMailer.php | 2 +- .../Service/RollingDate/RollingDate.php | 42 ++++++++----------- .../Service/ShortMessage/ShortMessage.php | 4 +- .../ShortMessage/ShortMessageHandler.php | 2 +- .../ShortMessage/ShortMessageTransporter.php | 2 +- .../ShortMessageOvh/OvhShortMessageSender.php | 10 ++--- .../Templating/CSVCellTwig.php | 2 +- .../ChillMarkdownRenderExtension.php | 2 +- .../Templating/ChillTwigHelper.php | 2 +- .../Templating/ChillTwigRoutingHelper.php | 8 ++-- .../Templating/Entity/AddressRender.php | 4 +- .../Entity/ChillEntityRenderExtension.php | 4 +- .../Templating/Entity/CommentRender.php | 2 +- .../Templating/Entity/UserRender.php | 4 +- .../Events/DelegatedBlockRenderingEvent.php | 4 +- .../Templating/Listing/FilterOrderHelper.php | 2 +- .../Listing/FilterOrderHelperBuilder.php | 2 +- .../Listing/FilterOrderHelperFactory.php | 2 +- .../Templating/Listing/Templating.php | 2 +- .../Templating/TranslatableStringHelper.php | 4 +- .../Templating/TranslatableStringTwig.php | 4 +- .../Templating/Widget/WidgetRenderingTwig.php | 4 +- .../PermissionsGroupControllerTest.php | 2 +- .../Tests/Cron/CronManagerTest.php | 2 +- .../Tests/Form/Type/PickCenterTypeTest.php | 6 +-- .../Tests/Search/AbstractSearchTest.php | 2 +- .../GeographicalUnitBaseImporterTest.php | 4 +- .../Timeline/TimelineBuilder.php | 2 +- .../Util/DateRangeCovering.php | 4 +- .../Validator/RoleScopeScopePresence.php | 2 +- .../Validation/Validator/ValidPhonenumber.php | 2 +- .../Counter/WorkflowByUserCounter.php | 2 +- .../Workflow/EntityWorkflowManager.php | 2 +- ...ntityWorkflowTransitionEventSubscriber.php | 2 +- .../NotificationOnTransition.php | 2 +- .../SendAccessKeyEventSubscriber.php | 2 +- .../Workflow/Helper/MetadataExtractor.php | 2 +- .../WorkflowNotificationHandler.php | 2 +- .../WorkflowTwigExtensionRuntime.php | 2 +- .../EntityWorkflowCreationValidator.php | 2 +- .../PersonAddressMoveEventSubscriber.php | 2 +- .../Events/UserRefEventSubscriber.php | 2 +- .../ChillPersonBundle/Actions/ActionEvent.php | 4 +- .../OneToOneEntityPersonCRUDController.php | 2 +- .../Command/ChillPersonMoveCommand.php | 8 ++-- ...emoveOldDraftAccompanyingPeriodCommand.php | 2 +- .../AccompanyingCourseApiController.php | 2 +- .../AccompanyingCourseCommentController.php | 2 +- .../AccompanyingCourseController.php | 2 +- .../AccompanyingCourseWorkApiController.php | 2 +- .../AccompanyingCourseWorkController.php | 2 +- ...mpanyingPeriodRegulationListController.php | 2 +- ...nyingPeriodWorkEvaluationApiController.php | 2 +- .../Controller/HouseholdApiController.php | 2 +- .../HouseholdCompositionController.php | 2 +- .../Controller/HouseholdController.php | 2 +- .../Controller/HouseholdMemberController.php | 2 +- .../Controller/PersonApiController.php | 6 +-- .../Controller/PersonController.php | 8 ++-- .../Controller/PersonDuplicateController.php | 2 +- .../Controller/PersonResourceController.php | 2 +- .../ReassignAccompanyingPeriodController.php | 4 +- .../Controller/RelationshipApiController.php | 2 +- .../ResidentialAddressController.php | 2 +- .../SocialWorkEvaluationApiController.php | 2 +- .../SocialWorkGoalApiController.php | 2 +- .../SocialWorkResultApiController.php | 2 +- .../SocialWorkSocialActionApiController.php | 2 +- .../UserAccompanyingPeriodController.php | 2 +- .../ORM/LoadAccompanyingPeriodOrigin.php | 2 +- .../ORM/LoadAccompanyingPeriodWork.php | 2 +- .../DataFixtures/ORM/LoadCustomFields.php | 2 +- .../DataFixtures/ORM/LoadHousehold.php | 4 +- .../ORM/LoadHouseholdCompositionType.php | 2 +- .../ORM/LoadHouseholdPosition.php | 8 ++-- .../DataFixtures/ORM/LoadPeople.php | 2 +- .../DataFixtures/ORM/LoadRelations.php | 4 +- .../DataFixtures/ORM/LoadRelationships.php | 2 +- .../ORM/LoadSocialWorkMetadata.php | 2 +- .../Entity/AccompanyingPeriod.php | 12 +++--- .../Entity/AccompanyingPeriod/UserHistory.php | 26 +++++------- .../ChillPersonBundle/Entity/Person.php | 12 +++--- .../Event/Person/PersonAddressMoveEvent.php | 4 +- .../AccompanyingPeriodWorkEventListener.php | 2 +- .../AdministrativeLocationAggregator.php | 2 +- .../ClosingMotiveAggregator.php | 2 +- .../ConfidentialAggregator.php | 2 +- .../CreatorJobAggregator.php | 2 +- .../DurationAggregator.php | 2 +- .../EmergencyAggregator.php | 2 +- .../EvaluationAggregator.php | 2 +- .../GeographicalUnitStatAggregator.php | 2 +- .../IntensityAggregator.php | 2 +- .../OriginAggregator.php | 4 +- .../ReferrerAggregator.php | 2 +- .../ReferrerScopeAggregator.php | 2 +- .../RequestorAggregator.php | 2 +- .../ScopeAggregator.php | 2 +- .../SocialActionAggregator.php | 2 +- .../SocialIssueAggregator.php | 2 +- .../StepAggregator.php | 2 +- .../UserJobAggregator.php | 2 +- .../ByEndDateAggregator.php | 2 - .../ByMaxDateAggregator.php | 2 - .../ByStartDateAggregator.php | 2 - .../EvaluationTypeAggregator.php | 2 +- .../HavingEndDateAggregator.php | 2 +- .../ChildrenNumberAggregator.php | 2 +- .../CompositionAggregator.php | 2 +- .../PersonAggregators/AgeAggregator.php | 2 +- .../ByHouseholdCompositionAggregator.php | 2 +- .../CountryOfBirthAggregator.php | 2 +- .../PersonAggregators/GenderAggregator.php | 2 +- .../GeographicalUnitAggregator.php | 2 +- .../HouseholdPositionAggregator.php | 2 +- .../MaritalStatusAggregator.php | 2 +- .../NationalityAggregator.php | 2 +- .../ActionTypeAggregator.php | 2 +- .../CurrentActionAggregator.php | 2 +- .../SocialWorkAggregators/GoalAggregator.php | 2 +- .../GoalResultAggregator.php | 2 +- .../SocialWorkAggregators/JobAggregator.php | 2 +- .../ReferrerAggregator.php | 2 +- .../ResultAggregator.php | 2 +- .../SocialWorkAggregators/ScopeAggregator.php | 2 +- .../ChillPersonBundle/Export/Declarations.php | 12 +++--- .../Export/Export/CountEvaluation.php | 2 +- .../Export/Export/CountHousehold.php | 2 +- .../CountPersonWithAccompanyingCourse.php | 2 +- .../Export/Export/ListAccompanyingPeriod.php | 2 +- .../Export/ListAccompanyingPeriodWork.php | 2 +- .../Export/Export/ListEvaluation.php | 2 +- .../Export/Export/ListHouseholdInPeriod.php | 2 +- .../Export/Export/ListPerson.php | 2 +- .../Export/Export/ListPersonDuplicate.php | 4 +- .../ListPersonWithAccompanyingPeriod.php | 2 +- .../Export/StatAccompanyingCourseDuration.php | 2 +- .../ActiveOnDateFilter.php | 2 +- .../ActiveOneDayBetweenDatesFilter.php | 2 +- .../AdministrativeLocationFilter.php | 2 +- .../ClosingMotiveFilter.php | 2 +- .../ConfidentialFilter.php | 2 +- .../CreatorJobFilter.php | 2 +- .../EmergencyFilter.php | 2 +- .../EvaluationFilter.php | 2 +- .../GeographicalUnitStatFilter.php | 2 +- .../HasNoReferrerFilter.php | 2 +- .../HasTemporaryLocationFilter.php | 2 +- .../IntensityFilter.php | 2 +- .../OpenBetweenDatesFilter.php | 2 +- .../OriginFilter.php | 2 +- .../ReferrerFilter.php | 2 +- .../RequestorFilter.php | 2 +- .../SocialActionFilter.php | 2 +- .../SocialIssueFilter.php | 2 +- .../AccompanyingCourseFilters/StepFilter.php | 2 +- .../UserJobFilter.php | 2 +- .../UserScopeFilter.php | 2 +- .../EvaluationFilters/ByEndDateFilter.php | 2 +- .../EvaluationFilters/ByStartDateFilter.php | 2 +- .../EvaluationTypeFilter.php | 2 +- .../EvaluationFilters/MaxDateFilter.php | 2 +- .../HouseholdFilters/CompositionFilter.php | 2 +- .../PersonFilters/AddressRefStatusFilter.php | 2 +- .../Export/Filter/PersonFilters/AgeFilter.php | 2 +- .../Filter/PersonFilters/BirthdateFilter.php | 2 +- .../ByHouseholdCompositionFilter.php | 2 +- .../PersonFilters/DeadOrAliveFilter.php | 2 +- .../Filter/PersonFilters/DeathdateFilter.php | 2 +- .../PersonFilters/GeographicalUnitFilter.php | 2 +- .../PersonFilters/MaritalStatusFilter.php | 2 +- .../PersonFilters/NationalityFilter.php | 2 +- .../ResidentialAddressAtThirdpartyFilter.php | 2 +- .../ResidentialAddressAtUserFilter.php | 2 +- .../WithoutHouseholdComposition.php | 2 +- .../Filter/SocialWorkFilters/JobFilter.php | 2 +- .../Filter/SocialWorkFilters/ScopeFilter.php | 2 +- .../SocialWorkTypeFilter.php | 2 +- .../Export/Helper/LabelPersonHelper.php | 2 +- .../Export/Helper/ListPersonHelper.php | 6 +-- .../Form/CreationPersonType.php | 8 ++-- .../Form/HouseholdCompositionType.php | 2 +- .../Form/PersonResourceType.php | 2 +- .../ChillPersonBundle/Form/PersonType.php | 2 +- .../Form/Type/PersonAltNameType.php | 2 +- .../Form/Type/PersonPhoneType.php | 2 +- .../Form/Type/PickPersonDynamicType.php | 2 +- .../Form/Type/PickSocialActionType.php | 2 +- .../Form/Type/PickSocialIssueType.php | 2 +- .../Form/Type/Select2MaritalStatusType.php | 2 +- .../Household/MembersEditor.php | 8 ++-- .../Household/MembersEditorFactory.php | 2 +- .../Menu/PersonMenuBuilder.php | 4 +- .../Menu/SectionMenuBuilder.php | 2 +- .../AccompanyingPeriodNotificationHandler.php | 2 +- .../AccompanyingPeriodPrivacyEvent.php | 2 +- .../Privacy/PrivacyEvent.php | 4 +- ...PeriodWorkEvaluationDocumentRepository.php | 2 +- ...mpanyingPeriodWorkEvaluationRepository.php | 2 +- .../AccompanyingPeriodWorkGoalRepository.php | 2 +- .../AccompanyingPeriodWorkRepository.php | 2 +- .../ClosingMotiveRepository.php | 2 +- .../AccompanyingPeriod/CommentRepository.php | 2 +- .../AccompanyingPeriod/OriginRepository.php | 2 +- .../AccompanyingPeriod/ResourceRepository.php | 2 +- .../AccompanyingPeriodACLAwareRepository.php | 2 +- ...ompanyingPeriodParticipationRepository.php | 2 +- .../AccompanyingPeriodRepository.php | 2 +- .../Household/HouseholdACLAwareRepository.php | 2 +- .../HouseholdCompositionRepository.php | 2 +- .../HouseholdCompositionTypeRepository.php | 2 +- .../Household/HouseholdMembersRepository.php | 2 +- .../Household/HouseholdRepository.php | 4 +- .../PersonHouseholdAddressRepository.php | 2 +- .../Household/PositionRepository.php | 2 +- .../Repository/MaritalStatusRepository.php | 2 +- .../Person/PersonCenterHistoryRepository.php | 2 +- .../Repository/PersonACLAwareRepository.php | 2 +- .../Repository/PersonAltNameRepository.php | 2 +- .../PersonNotDuplicateRepository.php | 2 +- .../Repository/PersonRepository.php | 2 +- .../Repository/PersonResourceRepository.php | 2 +- .../Relationships/RelationRepository.php | 2 +- .../Relationships/RelationshipRepository.php | 4 +- .../SocialWork/EvaluationRepository.php | 2 +- .../Repository/SocialWork/GoalRepository.php | 2 +- .../SocialWork/ResultRepository.php | 2 +- .../SocialWork/SocialActionRepository.php | 2 +- .../SocialWork/SocialIssueRepository.php | 2 +- .../ChillPersonBundle/Search/PersonSearch.php | 6 +-- .../Search/SearchHouseholdApiProvider.php | 2 +- .../Search/SearchPersonApiProvider.php | 2 +- .../Search/SimilarPersonMatcher.php | 4 +- .../AccompanyingPeriodCommentVoter.php | 6 +-- .../AccompanyingPeriodResourceVoter.php | 4 +- .../Authorization/AccompanyingPeriodVoter.php | 32 +++++++------- ...nyingPeriodWorkEvaluationDocumentVoter.php | 4 +- .../AccompanyingPeriodWorkEvaluationVoter.php | 8 ++-- .../AccompanyingPeriodWorkVoter.php | 14 +++---- .../Security/Authorization/HouseholdVoter.php | 12 +++--- .../Security/Authorization/PersonVoter.php | 12 +++--- .../AuthorizedCenterOnPersonCreation.php | 4 +- .../AccompanyingPeriodDocGenNormalizer.php | 2 +- .../AccompanyingPeriodResourceNormalizer.php | 2 +- .../AccompanyingPeriodWorkDenormalizer.php | 6 +-- ...PeriodWorkEvaluationDocumentNormalizer.php | 2 +- ...mpanyingPeriodWorkEvaluationNormalizer.php | 2 +- .../AccompanyingPeriodWorkNormalizer.php | 2 +- .../Normalizer/MembersEditorNormalizer.php | 2 +- .../Normalizer/PersonDocGenNormalizer.php | 2 +- .../Normalizer/PersonJsonNormalizer.php | 21 ++++------ .../RelationshipDocGenNormalizer.php | 2 +- .../Normalizer/SocialActionNormalizer.php | 2 +- .../Normalizer/SocialIssueNormalizer.php | 2 +- .../Normalizer/WorkflowNormalizer.php | 2 +- .../OldDraftAccompanyingPeriodRemover.php | 2 +- .../AccompanyingPeriodContext.php | 2 +- .../AccompanyingPeriodWorkContext.php | 2 +- ...ccompanyingPeriodWorkEvaluationContext.php | 2 +- .../Service/DocGenerator/PersonContext.php | 22 +++++----- .../PersonContextWithThirdParty.php | 2 +- .../Service/Import/SocialWorkMetadata.php | 2 +- .../Templating/Entity/ClosingMotiveRender.php | 2 +- .../Templating/Entity/PersonRender.php | 2 +- .../Templating/Entity/ResourceKindRender.php | 2 +- .../Templating/Entity/SocialActionRender.php | 12 +++--- .../Templating/Entity/SocialIssueRender.php | 2 +- .../AccompanyingPeriodConfidentialTest.php | 2 +- .../AccompanyingCourseApiControllerTest.php | 22 +++++----- .../AccompanyingCourseControllerTest.php | 4 +- .../AccompanyingPeriodControllerTest.php | 6 +-- ...rsonControllerViewWithHiddenFieldsTest.php | 2 +- .../Tests/Form/Type/PickPersonTypeTest.php | 4 +- .../Tests/Search/PersonSearchTest.php | 12 +++--- ...ngPeriodWorkEvaluationDenormalizerTest.php | 2 +- .../Normalizer/HouseholdNormalizerTest.php | 2 +- .../Normalizer/PersonDocGenNormalizerTest.php | 6 +-- .../TimelineAccompanyingPeriodTest.php | 2 +- .../AbstractTimelineAccompanyingPeriod.php | 2 +- .../AccompanyingPeriodValidityValidator.php | 2 +- .../LocationValidityValidator.php | 2 +- .../ParticipationOverlapValidator.php | 2 +- .../ResourceDuplicateCheckValidator.php | 2 +- ...HouseholdMembershipSequentialValidator.php | 2 +- .../Constraints/Person/Birthdate.php | 2 +- .../Person/PersonHasCenterValidator.php | 4 +- .../RelationshipNoDuplicateValidator.php | 2 +- ...dWorkEvaluationDocumentWorkflowHandler.php | 2 +- ...ingPeriodWorkEvaluationWorkflowHandler.php | 2 +- .../AccompanyingPeriodWorkWorkflowHandler.php | 2 +- .../Export/Export/ReportList.php | 8 ++-- .../Export/Filter/ReportDateFilter.php | 2 +- .../ChillReportBundle/Search/ReportSearch.php | 4 +- .../Security/Authorization/ReportVoter.php | 8 ++-- .../Tests/Controller/ReportControllerTest.php | 4 +- .../Timeline/TimelineReportProvider.php | 2 +- .../Controller/SingleTaskController.php | 2 +- .../ChillTaskBundle/Event/TaskEvent.php | 2 +- .../ChillTaskBundle/Event/UI/UIEvent.php | 6 +-- .../ChillTaskBundle/Form/SingleTaskType.php | 2 +- .../SingleTaskAclAwareRepository.php | 6 +-- .../Repository/SingleTaskRepository.php | 10 ++--- .../Authorization/AuthorizationEvent.php | 8 ++-- .../Security/Authorization/TaskVoter.php | 8 ++-- .../Templating/TaskTwigExtension.php | 2 +- .../Templating/UI/CountNotificationTask.php | 4 +- .../SingleTaskACLAwareRepositoryTest.php | 2 +- ...TaskTaskLifeCycleEventTimelineProvider.php | 2 +- .../TaskLifeCycleEventTimelineProvider.php | 2 +- .../Definition/DefaultTaskDefinition.php | 4 +- .../Controller/ThirdPartyController.php | 2 +- .../DataFixtures/ORM/LoadThirdParty.php | 2 +- .../ThirdPartyTypeCompilerPass.php | 2 +- .../Entity/ThirdParty.php | 6 +-- .../Export/Helper/LabelThirdPartyHelper.php | 2 +- .../Form/ThirdPartyType.php | 2 +- .../Type/PickThirdPartyTypeCategoryType.php | 2 +- .../Form/Type/PickThirdpartyDynamicType.php | 2 +- .../ThirdPartyACLAwareRepository.php | 2 +- .../Repository/ThirdPartyRepository.php | 2 +- .../Search/ThirdPartyApiSearch.php | 2 +- .../Search/ThirdPartySearch.php | 4 +- .../Security/Voter/ThirdPartyVoter.php | 6 +-- .../Normalizer/ThirdPartyNormalizer.php | 2 +- .../ThirdPartyType/ThirdPartyTypeManager.php | 2 +- .../src/Controller/Convert.php | 12 +++--- .../ChillWopiBundle/src/Controller/Editor.php | 2 +- .../src/Service/Controller/Responder.php | 9 +--- .../src/Service/Wopi/AuthorizationManager.php | 2 +- .../Service/Wopi/ChillDocumentLockManager.php | 2 +- .../src/Service/Wopi/ChillDocumentManager.php | 12 +++--- .../src/Service/Wopi/ChillWopi.php | 2 +- .../src/Service/Wopi/UserManager.php | 2 +- 733 files changed, 1257 insertions(+), 1322 deletions(-) diff --git a/docs/source/development/user-interface/widgets/ChillMainConfiguration.php b/docs/source/development/user-interface/widgets/ChillMainConfiguration.php index b4567729c..14588a487 100644 --- a/docs/source/development/user-interface/widgets/ChillMainConfiguration.php +++ b/docs/source/development/user-interface/widgets/ChillMainConfiguration.php @@ -25,7 +25,7 @@ class ChillMainConfiguration implements ConfigurationInterface public function __construct( array $widgetFactories, - private ContainerBuilder $containerBuilder + private readonly ContainerBuilder $containerBuilder ) { // we register here widget factories (see below) $this->setWidgetFactories($widgetFactories); diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php index 69d3f3312..75f393bc0 100644 --- a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php +++ b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php @@ -48,23 +48,22 @@ use function array_key_exists; final class ActivityController extends AbstractController { public function __construct( - private ActivityACLAwareRepositoryInterface $activityACLAwareRepository, - private ActivityTypeRepositoryInterface $activityTypeRepository, - private ActivityTypeCategoryRepository $activityTypeCategoryRepository, - private PersonRepository $personRepository, - private ThirdPartyRepository $thirdPartyRepository, - private LocationRepository $locationRepository, - private ActivityRepository $activityRepository, - private AccompanyingPeriodRepository $accompanyingPeriodRepository, - private EntityManagerInterface $entityManager, - private EventDispatcherInterface $eventDispatcher, - private LoggerInterface $logger, - private SerializerInterface $serializer, - private UserRepositoryInterface $userRepository, - private CenterResolverManagerInterface $centerResolver, - private TranslatorInterface $translator, - ) - { + private readonly ActivityACLAwareRepositoryInterface $activityACLAwareRepository, + private readonly ActivityTypeRepositoryInterface $activityTypeRepository, + private readonly ActivityTypeCategoryRepository $activityTypeCategoryRepository, + private readonly PersonRepository $personRepository, + private readonly ThirdPartyRepository $thirdPartyRepository, + private readonly LocationRepository $locationRepository, + private readonly ActivityRepository $activityRepository, + private readonly AccompanyingPeriodRepository $accompanyingPeriodRepository, + private readonly EntityManagerInterface $entityManager, + private readonly EventDispatcherInterface $eventDispatcher, + private readonly LoggerInterface $logger, + private readonly SerializerInterface $serializer, + private readonly UserRepositoryInterface $userRepository, + private readonly CenterResolverManagerInterface $centerResolver, + private readonly TranslatorInterface $translator, + ) { } /** diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityReasonController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityReasonController.php index 60a7636e4..226177d7f 100644 --- a/src/Bundle/ChillActivityBundle/Controller/ActivityReasonController.php +++ b/src/Bundle/ChillActivityBundle/Controller/ActivityReasonController.php @@ -24,7 +24,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; */ class ActivityReasonController extends AbstractController { - public function __construct(private ActivityReasonRepository $activityReasonRepository) + public function __construct(private readonly ActivityReasonRepository $activityReasonRepository) { } diff --git a/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivity.php b/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivity.php index 74eb4f8d3..9f0c59784 100644 --- a/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivity.php +++ b/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivity.php @@ -30,7 +30,7 @@ class LoadActivity extends AbstractFixture implements OrderedFixtureInterface */ private $faker; - public function __construct(private EntityManagerInterface $em) + public function __construct(private readonly EntityManagerInterface $em) { $this->faker = FakerFactory::create('fr_FR'); } diff --git a/src/Bundle/ChillActivityBundle/Entity/Activity.php b/src/Bundle/ChillActivityBundle/Entity/Activity.php index 32ceb2e74..c697cdf9b 100644 --- a/src/Bundle/ChillActivityBundle/Entity/Activity.php +++ b/src/Bundle/ChillActivityBundle/Entity/Activity.php @@ -65,9 +65,9 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac use TrackUpdateTrait; - public const SENTRECEIVED_RECEIVED = 'received'; + final public const SENTRECEIVED_RECEIVED = 'received'; - public const SENTRECEIVED_SENT = 'sent'; + final public const SENTRECEIVED_SENT = 'sent'; /** * @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod") diff --git a/src/Bundle/ChillActivityBundle/Entity/ActivityType.php b/src/Bundle/ChillActivityBundle/Entity/ActivityType.php index f49297f02..aa6598b0b 100644 --- a/src/Bundle/ChillActivityBundle/Entity/ActivityType.php +++ b/src/Bundle/ChillActivityBundle/Entity/ActivityType.php @@ -27,11 +27,11 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface; */ class ActivityType { - public const FIELD_INVISIBLE = 0; + final public const FIELD_INVISIBLE = 0; - public const FIELD_OPTIONAL = 1; + final public const FIELD_OPTIONAL = 1; - public const FIELD_REQUIRED = 2; + final public const FIELD_REQUIRED = 2; /** * @deprecated not in use diff --git a/src/Bundle/ChillActivityBundle/EntityListener/ActivityEntityListener.php b/src/Bundle/ChillActivityBundle/EntityListener/ActivityEntityListener.php index fb2fb8a1c..8ae053728 100644 --- a/src/Bundle/ChillActivityBundle/EntityListener/ActivityEntityListener.php +++ b/src/Bundle/ChillActivityBundle/EntityListener/ActivityEntityListener.php @@ -22,7 +22,7 @@ use function in_array; class ActivityEntityListener { - public function __construct(private EntityManagerInterface $em, private AccompanyingPeriodWorkRepository $workRepository) + public function __construct(private readonly EntityManagerInterface $em, private readonly AccompanyingPeriodWorkRepository $workRepository) { } diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByCreatorAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByCreatorAggregator.php index 60cff42f8..5e20bd6ab 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByCreatorAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByCreatorAggregator.php @@ -20,7 +20,7 @@ use Symfony\Component\Form\FormBuilderInterface; class ByCreatorAggregator implements AggregatorInterface { - public function __construct(private UserRepositoryInterface $userRepository, private UserRender $userRender) + public function __construct(private readonly UserRepositoryInterface $userRepository, private readonly UserRender $userRender) { } diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialActionAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialActionAggregator.php index a09c254eb..c3f205543 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialActionAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialActionAggregator.php @@ -21,7 +21,7 @@ use function in_array; class BySocialActionAggregator implements AggregatorInterface { - public function __construct(private SocialActionRender $actionRender, private SocialActionRepository $actionRepository) + public function __construct(private readonly SocialActionRender $actionRender, private readonly SocialActionRepository $actionRepository) { } diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialIssueAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialIssueAggregator.php index 111bdcf4b..a54049e13 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialIssueAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialIssueAggregator.php @@ -21,7 +21,7 @@ use function in_array; class BySocialIssueAggregator implements AggregatorInterface { - public function __construct(private SocialIssueRepository $issueRepository, private SocialIssueRender $issueRender) + public function __construct(private readonly SocialIssueRepository $issueRepository, private readonly SocialIssueRender $issueRender) { } diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByThirdpartyAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByThirdpartyAggregator.php index 83c4a5d2a..7b0996eb4 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByThirdpartyAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByThirdpartyAggregator.php @@ -21,7 +21,7 @@ use function in_array; class ByThirdpartyAggregator implements AggregatorInterface { - public function __construct(private ThirdPartyRepository $thirdPartyRepository, private ThirdPartyRender $thirdPartyRender) + public function __construct(private readonly ThirdPartyRepository $thirdPartyRepository, private readonly ThirdPartyRender $thirdPartyRender) { } diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/CreatorScopeAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/CreatorScopeAggregator.php index 3014352ad..249bb0a5d 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/CreatorScopeAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/CreatorScopeAggregator.php @@ -21,7 +21,7 @@ use function in_array; class CreatorScopeAggregator implements AggregatorInterface { - public function __construct(private ScopeRepository $scopeRepository, private TranslatableStringHelper $translatableStringHelper) + public function __construct(private readonly ScopeRepository $scopeRepository, private readonly TranslatableStringHelper $translatableStringHelper) { } diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/DateAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/DateAggregator.php index a4f93e3b3..461fac62d 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/DateAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/DateAggregator.php @@ -29,7 +29,7 @@ class DateAggregator implements AggregatorInterface private const DEFAULT_CHOICE = 'year'; - public function __construct(private TranslatorInterface $translator) + public function __construct(private readonly TranslatorInterface $translator) { } diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/LocationTypeAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/LocationTypeAggregator.php index fa2c7f7c2..6c023692e 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/LocationTypeAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/LocationTypeAggregator.php @@ -21,7 +21,7 @@ use function in_array; class LocationTypeAggregator implements AggregatorInterface { - public function __construct(private LocationTypeRepository $locationTypeRepository, private TranslatableStringHelper $translatableStringHelper) + public function __construct(private readonly LocationTypeRepository $locationTypeRepository, private readonly TranslatableStringHelper $translatableStringHelper) { } diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php index 272727d55..f262c8b58 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php @@ -22,7 +22,7 @@ use function in_array; class ActivityTypeAggregator implements AggregatorInterface { - public const KEY = 'activity_type_aggregator'; + final public const KEY = 'activity_type_aggregator'; public function __construct(protected ActivityTypeRepositoryInterface $activityTypeRepository, protected TranslatableStringHelperInterface $translatableStringHelper) { diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUserAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUserAggregator.php index 228ab8500..a79cfcffd 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUserAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUserAggregator.php @@ -21,9 +21,9 @@ use Symfony\Component\Form\FormBuilderInterface; class ActivityUserAggregator implements AggregatorInterface { - public const KEY = 'activity_user_id'; + final public const KEY = 'activity_user_id'; - public function __construct(private UserRepository $userRepository, private UserRender $userRender) + public function __construct(private readonly UserRepository $userRepository, private readonly UserRender $userRender) { } diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersAggregator.php index c1b2ff845..b04fd9321 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersAggregator.php @@ -21,7 +21,7 @@ use function in_array; class ActivityUsersAggregator implements AggregatorInterface { - public function __construct(private UserRepositoryInterface $userRepository, private UserRender $userRender) + public function __construct(private readonly UserRepositoryInterface $userRepository, private readonly UserRender $userRender) { } diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersJobAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersJobAggregator.php index 1b8cb7e1c..d02017feb 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersJobAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersJobAggregator.php @@ -20,7 +20,7 @@ use function in_array; class ActivityUsersJobAggregator implements \Chill\MainBundle\Export\AggregatorInterface { - public function __construct(private UserJobRepositoryInterface $userJobRepository, private TranslatableStringHelperInterface $translatableStringHelper) + public function __construct(private readonly UserJobRepositoryInterface $userJobRepository, private readonly TranslatableStringHelperInterface $translatableStringHelper) { } diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersScopeAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersScopeAggregator.php index 1f39ccf82..a83a7375a 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersScopeAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersScopeAggregator.php @@ -20,7 +20,7 @@ use function in_array; class ActivityUsersScopeAggregator implements \Chill\MainBundle\Export\AggregatorInterface { - public function __construct(private ScopeRepositoryInterface $scopeRepository, private TranslatableStringHelperInterface $translatableStringHelper) + public function __construct(private readonly ScopeRepositoryInterface $scopeRepository, private readonly TranslatableStringHelperInterface $translatableStringHelper) { } diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/SentReceivedAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/SentReceivedAggregator.php index 7ff94aaca..ec0c00648 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/SentReceivedAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/SentReceivedAggregator.php @@ -20,7 +20,7 @@ use Symfony\Contracts\Translation\TranslatorInterface; class SentReceivedAggregator implements AggregatorInterface { - public function __construct(private TranslatorInterface $translator) + public function __construct(private readonly TranslatorInterface $translator) { } diff --git a/src/Bundle/ChillActivityBundle/Export/Declarations.php b/src/Bundle/ChillActivityBundle/Export/Declarations.php index 79afb09c8..210988770 100644 --- a/src/Bundle/ChillActivityBundle/Export/Declarations.php +++ b/src/Bundle/ChillActivityBundle/Export/Declarations.php @@ -16,9 +16,9 @@ namespace Chill\ActivityBundle\Export; */ abstract class Declarations { - public const ACTIVITY = 'activity'; + final public const ACTIVITY = 'activity'; - public const ACTIVITY_ACP = 'activity_linked_to_acp'; + final public const ACTIVITY_ACP = 'activity_linked_to_acp'; - public const ACTIVITY_PERSON = 'activity_linked_to_person'; + final public const ACTIVITY_PERSON = 'activity_linked_to_person'; } diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php index 6e98565c6..9dd8b1e4f 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php @@ -24,7 +24,7 @@ use Symfony\Component\Form\FormBuilderInterface; class ListActivity implements ListInterface, GroupedExportInterface { - public function __construct(private ListActivityHelper $helper, private EntityManagerInterface $entityManager, private TranslatableStringExportLabelHelper $translatableStringExportLabelHelper) + public function __construct(private readonly ListActivityHelper $helper, private readonly EntityManagerInterface $entityManager, private readonly TranslatableStringExportLabelHelper $translatableStringExportLabelHelper) { } diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php index ff4d4fa47..21c85260b 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php @@ -50,7 +50,7 @@ class ListActivity implements ListInterface, GroupedExportInterface 'person_id', ]; - public function __construct(protected EntityManagerInterface $entityManager, protected TranslatorInterface $translator, protected TranslatableStringHelperInterface $translatableStringHelper, private ActivityRepository $activityRepository) + public function __construct(protected EntityManagerInterface $entityManager, protected TranslatorInterface $translator, protected TranslatableStringHelperInterface $translatableStringHelper, private readonly ActivityRepository $activityRepository) { } diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/StatActivityDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/StatActivityDuration.php index bb8be00ff..da1669756 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/StatActivityDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/StatActivityDuration.php @@ -30,13 +30,13 @@ use Symfony\Component\Form\FormBuilderInterface; */ class StatActivityDuration implements ExportInterface, GroupedExportInterface { - public const SUM = 'sum'; + final public const SUM = 'sum'; /** * @param string $action the stat to perform */ public function __construct( - private ActivityRepository $activityRepository, + private readonly ActivityRepository $activityRepository, /** * The action for this report. */ diff --git a/src/Bundle/ChillActivityBundle/Export/Export/ListActivityHelper.php b/src/Bundle/ChillActivityBundle/Export/Export/ListActivityHelper.php index 43c9f4688..79d297851 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/ListActivityHelper.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/ListActivityHelper.php @@ -30,9 +30,9 @@ use const SORT_NUMERIC; class ListActivityHelper { - public const MSG_KEY = 'export.list.activity.'; + final public const MSG_KEY = 'export.list.activity.'; - public function __construct(private ActivityPresenceRepositoryInterface $activityPresenceRepository, private ActivityTypeRepositoryInterface $activityTypeRepository, private DateTimeHelper $dateTimeHelper, private LabelPersonHelper $labelPersonHelper, private LabelThirdPartyHelper $labelThirdPartyHelper, private TranslatorInterface $translator, private TranslatableStringHelperInterface $translatableStringHelper, private TranslatableStringExportLabelHelper $translatableStringLabelHelper, private UserHelper $userHelper) + public function __construct(private readonly ActivityPresenceRepositoryInterface $activityPresenceRepository, private readonly ActivityTypeRepositoryInterface $activityTypeRepository, private readonly DateTimeHelper $dateTimeHelper, private readonly LabelPersonHelper $labelPersonHelper, private readonly LabelThirdPartyHelper $labelThirdPartyHelper, private readonly TranslatorInterface $translator, private readonly TranslatableStringHelperInterface $translatableStringHelper, private readonly TranslatableStringExportLabelHelper $translatableStringLabelHelper, private readonly UserHelper $userHelper) { } diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php index a1f2bc786..163ac4208 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php @@ -23,7 +23,7 @@ use Symfony\Component\Form\FormBuilderInterface; class ActivityTypeFilter implements FilterInterface { - public function __construct(private ActivityTypeRepositoryInterface $activityTypeRepository, private TranslatableStringHelperInterface $translatableStringHelper) + public function __construct(private readonly ActivityTypeRepositoryInterface $activityTypeRepository, private readonly TranslatableStringHelperInterface $translatableStringHelper) { } diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ByCreatorFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ByCreatorFilter.php index 28264c919..3c8df8df6 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ByCreatorFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ByCreatorFilter.php @@ -20,7 +20,7 @@ use Symfony\Component\Form\FormBuilderInterface; class ByCreatorFilter implements FilterInterface { - public function __construct(private UserRender $userRender) + public function __construct(private readonly UserRender $userRender) { } diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialActionFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialActionFilter.php index 89330728f..08ffdb638 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialActionFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialActionFilter.php @@ -22,7 +22,7 @@ use function in_array; class BySocialActionFilter implements FilterInterface { - public function __construct(private SocialActionRender $actionRender) + public function __construct(private readonly SocialActionRender $actionRender) { } diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialIssueFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialIssueFilter.php index d78efbde0..e3163798d 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialIssueFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialIssueFilter.php @@ -22,7 +22,7 @@ use function in_array; class BySocialIssueFilter implements FilterInterface { - public function __construct(private SocialIssueRender $issueRender) + public function __construct(private readonly SocialIssueRender $issueRender) { } diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/EmergencyFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/EmergencyFilter.php index aff224bf3..ea2a70a77 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/EmergencyFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/EmergencyFilter.php @@ -28,7 +28,7 @@ class EmergencyFilter implements FilterInterface private const DEFAULT_CHOICE = false; - public function __construct(private TranslatorInterface $translator) + public function __construct(private readonly TranslatorInterface $translator) { } diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationTypeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationTypeFilter.php index 800381416..40835d367 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationTypeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationTypeFilter.php @@ -22,7 +22,7 @@ use function in_array; class LocationTypeFilter implements FilterInterface { - public function __construct(private TranslatableStringHelper $translatableStringHelper) + public function __construct(private readonly TranslatableStringHelper $translatableStringHelper) { } diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/SentReceivedFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/SentReceivedFilter.php index b901ebde7..6a44414a3 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/SentReceivedFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/SentReceivedFilter.php @@ -29,7 +29,7 @@ class SentReceivedFilter implements FilterInterface private const DEFAULT_CHOICE = Activity::SENTRECEIVED_SENT; - public function __construct(private TranslatorInterface $translator) + public function __construct(private readonly TranslatorInterface $translator) { } diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserFilter.php index 1a5d28059..f1537bfb2 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserFilter.php @@ -21,7 +21,7 @@ use Symfony\Component\Form\FormBuilderInterface; class UserFilter implements FilterInterface { - public function __construct(private UserRender $userRender) + public function __construct(private readonly UserRender $userRender) { } diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserScopeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserScopeFilter.php index 47445a012..5cc872aea 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserScopeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserScopeFilter.php @@ -23,7 +23,7 @@ use function in_array; class UserScopeFilter implements FilterInterface { - public function __construct(private TranslatableStringHelper $translatableStringHelper) + public function __construct(private readonly TranslatableStringHelper $translatableStringHelper) { } diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityDateFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityDateFilter.php index 1ea273c64..30c625a39 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityDateFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityDateFilter.php @@ -27,7 +27,7 @@ use Symfony\Contracts\Translation\TranslatorInterface; class ActivityDateFilter implements FilterInterface { - public function __construct(protected TranslatorInterface $translator, private RollingDateConverterInterface $rollingDateConverter) + public function __construct(protected TranslatorInterface $translator, private readonly RollingDateConverterInterface $rollingDateConverter) { } diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityUsersFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityUsersFilter.php index 735b66a31..43163b5ab 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityUsersFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityUsersFilter.php @@ -20,7 +20,7 @@ use Symfony\Component\Form\FormBuilderInterface; class ActivityUsersFilter implements FilterInterface { - public function __construct(private UserRender $userRender) + public function __construct(private readonly UserRender $userRender) { } diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/UsersJobFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/UsersJobFilter.php index c9e942816..6f35e98b6 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/UsersJobFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/UsersJobFilter.php @@ -22,7 +22,7 @@ use Symfony\Component\Form\FormBuilderInterface; class UsersJobFilter implements FilterInterface { - public function __construct(private TranslatableStringHelperInterface $translatableStringHelper) + public function __construct(private readonly TranslatableStringHelperInterface $translatableStringHelper) { } diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/UsersScopeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/UsersScopeFilter.php index f93f982aa..58533cae4 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/UsersScopeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/UsersScopeFilter.php @@ -23,7 +23,7 @@ use Symfony\Component\Form\FormBuilderInterface; class UsersScopeFilter implements FilterInterface { - public function __construct(private ScopeRepositoryInterface $scopeRepository, private TranslatableStringHelperInterface $translatableStringHelper) + public function __construct(private readonly ScopeRepositoryInterface $scopeRepository, private readonly TranslatableStringHelperInterface $translatableStringHelper) { } diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php b/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php index 6288486f7..63b1ab6c8 100644 --- a/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php +++ b/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php @@ -25,7 +25,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver; class ActivityTypeType extends AbstractType { - public function __construct(private TranslatableStringHelper $translatableStringHelper) + public function __construct(private readonly TranslatableStringHelper $translatableStringHelper) { } diff --git a/src/Bundle/ChillActivityBundle/Form/Type/PickActivityReasonType.php b/src/Bundle/ChillActivityBundle/Form/Type/PickActivityReasonType.php index 4709b3010..392019ec9 100644 --- a/src/Bundle/ChillActivityBundle/Form/Type/PickActivityReasonType.php +++ b/src/Bundle/ChillActivityBundle/Form/Type/PickActivityReasonType.php @@ -24,7 +24,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver; */ class PickActivityReasonType extends AbstractType { - public function __construct(private ActivityReasonRepository $activityReasonRepository, private ActivityReasonRender $reasonRender, private TranslatableStringHelperInterface $translatableStringHelper) + public function __construct(private readonly ActivityReasonRepository $activityReasonRepository, private readonly ActivityReasonRender $reasonRender, private readonly TranslatableStringHelperInterface $translatableStringHelper) { } diff --git a/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityReasonCategoryType.php b/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityReasonCategoryType.php index 8ccdf42c8..37bc90b0c 100644 --- a/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityReasonCategoryType.php +++ b/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityReasonCategoryType.php @@ -23,7 +23,7 @@ use Symfony\Contracts\Translation\TranslatorInterface; */ class TranslatableActivityReasonCategoryType extends AbstractType { - public function __construct(private TranslatableStringHelperInterface $translatableStringHelper, private TranslatorInterface $translator) + public function __construct(private readonly TranslatableStringHelperInterface $translatableStringHelper, private readonly TranslatorInterface $translator) { } diff --git a/src/Bundle/ChillActivityBundle/Menu/AdminMenuBuilder.php b/src/Bundle/ChillActivityBundle/Menu/AdminMenuBuilder.php index bdffafcb2..8337a3582 100644 --- a/src/Bundle/ChillActivityBundle/Menu/AdminMenuBuilder.php +++ b/src/Bundle/ChillActivityBundle/Menu/AdminMenuBuilder.php @@ -18,7 +18,7 @@ use Symfony\Component\Security\Core\Security; /** * @implements LocalMenuBuilderInterface */ -final class AdminMenuBuilder implements LocalMenuBuilderInterface +final readonly class AdminMenuBuilder implements LocalMenuBuilderInterface { public function __construct(private Security $security) { diff --git a/src/Bundle/ChillActivityBundle/Notification/ActivityNotificationHandler.php b/src/Bundle/ChillActivityBundle/Notification/ActivityNotificationHandler.php index 4b8566484..3356e7107 100644 --- a/src/Bundle/ChillActivityBundle/Notification/ActivityNotificationHandler.php +++ b/src/Bundle/ChillActivityBundle/Notification/ActivityNotificationHandler.php @@ -16,7 +16,7 @@ use Chill\ActivityBundle\Repository\ActivityRepository; use Chill\MainBundle\Entity\Notification; use Chill\MainBundle\Notification\NotificationHandlerInterface; -final class ActivityNotificationHandler implements NotificationHandlerInterface +final readonly class ActivityNotificationHandler implements NotificationHandlerInterface { public function __construct(private ActivityRepository $activityRepository) { diff --git a/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php b/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php index c4eae39f0..06a74a1f0 100644 --- a/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php +++ b/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php @@ -33,7 +33,7 @@ use Symfony\Component\Security\Core\Security; use function count; use function in_array; -final class ActivityACLAwareRepository implements ActivityACLAwareRepositoryInterface +final readonly class ActivityACLAwareRepository implements ActivityACLAwareRepositoryInterface { public function __construct(private AuthorizationHelper $authorizationHelper, private CenterResolverDispatcherInterface $centerResolverDispatcher, private TokenStorageInterface $tokenStorage, private ActivityRepository $repository, private EntityManagerInterface $em, private Security $security) { diff --git a/src/Bundle/ChillActivityBundle/Repository/ActivityPresenceRepository.php b/src/Bundle/ChillActivityBundle/Repository/ActivityPresenceRepository.php index 2cf9f9470..3ed96074b 100644 --- a/src/Bundle/ChillActivityBundle/Repository/ActivityPresenceRepository.php +++ b/src/Bundle/ChillActivityBundle/Repository/ActivityPresenceRepository.php @@ -17,7 +17,7 @@ use Doctrine\ORM\EntityRepository; class ActivityPresenceRepository implements ActivityPresenceRepositoryInterface { - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct(EntityManagerInterface $entityManager) { diff --git a/src/Bundle/ChillActivityBundle/Repository/ActivityReasonRepository.php b/src/Bundle/ChillActivityBundle/Repository/ActivityReasonRepository.php index 33c36693e..47a7b35e8 100644 --- a/src/Bundle/ChillActivityBundle/Repository/ActivityReasonRepository.php +++ b/src/Bundle/ChillActivityBundle/Repository/ActivityReasonRepository.php @@ -25,7 +25,7 @@ class ActivityReasonRepository extends ServiceEntityRepository { public function __construct( ManagerRegistry $registry, - private RequestStack $requestStack + private readonly RequestStack $requestStack ) { parent::__construct($registry, ActivityReason::class); } diff --git a/src/Bundle/ChillActivityBundle/Repository/ActivityTypeRepository.php b/src/Bundle/ChillActivityBundle/Repository/ActivityTypeRepository.php index fd5d52fce..99adf4fe0 100644 --- a/src/Bundle/ChillActivityBundle/Repository/ActivityTypeRepository.php +++ b/src/Bundle/ChillActivityBundle/Repository/ActivityTypeRepository.php @@ -17,7 +17,7 @@ use Doctrine\ORM\EntityRepository; final class ActivityTypeRepository implements ActivityTypeRepositoryInterface { - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct(EntityManagerInterface $em) { diff --git a/src/Bundle/ChillActivityBundle/Security/Authorization/ActivityStatsVoter.php b/src/Bundle/ChillActivityBundle/Security/Authorization/ActivityStatsVoter.php index 2e55f862c..27f4b07a6 100644 --- a/src/Bundle/ChillActivityBundle/Security/Authorization/ActivityStatsVoter.php +++ b/src/Bundle/ChillActivityBundle/Security/Authorization/ActivityStatsVoter.php @@ -20,9 +20,9 @@ use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; class ActivityStatsVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface { - public const LISTS = 'CHILL_ACTIVITY_LIST'; + final public const LISTS = 'CHILL_ACTIVITY_LIST'; - public const STATS = 'CHILL_ACTIVITY_STATS'; + final public const STATS = 'CHILL_ACTIVITY_STATS'; protected VoterHelperInterface $helper; diff --git a/src/Bundle/ChillActivityBundle/Security/Authorization/ActivityVoter.php b/src/Bundle/ChillActivityBundle/Security/Authorization/ActivityVoter.php index a036c9784..06cbb7145 100644 --- a/src/Bundle/ChillActivityBundle/Security/Authorization/ActivityVoter.php +++ b/src/Bundle/ChillActivityBundle/Security/Authorization/ActivityVoter.php @@ -35,7 +35,7 @@ class ActivityVoter extends AbstractChillVoter implements ProvideRoleHierarchyIn * * It is safe for usage in template and controller */ - public const CREATE = 'CHILL_ACTIVITY_CREATE'; + final public const CREATE = 'CHILL_ACTIVITY_CREATE'; /** * role to allow to create an activity associated win an accompanying course. @@ -44,7 +44,7 @@ class ActivityVoter extends AbstractChillVoter implements ProvideRoleHierarchyIn * * @internal */ - public const CREATE_ACCOMPANYING_COURSE = 'CHILL_ACTIVITY_CREATE_ACCOMPANYING_COURSE'; + final public const CREATE_ACCOMPANYING_COURSE = 'CHILL_ACTIVITY_CREATE_ACCOMPANYING_COURSE'; /** * role to allow to create an activity associated with a person. @@ -53,17 +53,17 @@ class ActivityVoter extends AbstractChillVoter implements ProvideRoleHierarchyIn * * @internal */ - public const CREATE_PERSON = 'CHILL_ACTIVITY_CREATE_PERSON'; + final public const CREATE_PERSON = 'CHILL_ACTIVITY_CREATE_PERSON'; - public const DELETE = 'CHILL_ACTIVITY_DELETE'; + final public const DELETE = 'CHILL_ACTIVITY_DELETE'; - public const FULL = 'CHILL_ACTIVITY_FULL'; + final public const FULL = 'CHILL_ACTIVITY_FULL'; - public const SEE = 'CHILL_ACTIVITY_SEE'; + final public const SEE = 'CHILL_ACTIVITY_SEE'; - public const SEE_DETAILS = 'CHILL_ACTIVITY_SEE_DETAILS'; + final public const SEE_DETAILS = 'CHILL_ACTIVITY_SEE_DETAILS'; - public const UPDATE = 'CHILL_ACTIVITY_UPDATE'; + final public const UPDATE = 'CHILL_ACTIVITY_UPDATE'; private const ALL = [ self::CREATE, diff --git a/src/Bundle/ChillActivityBundle/Service/DocGenerator/ActivityContext.php b/src/Bundle/ChillActivityBundle/Service/DocGenerator/ActivityContext.php index 95a5a4b10..e1bcd7677 100644 --- a/src/Bundle/ChillActivityBundle/Service/DocGenerator/ActivityContext.php +++ b/src/Bundle/ChillActivityBundle/Service/DocGenerator/ActivityContext.php @@ -39,7 +39,7 @@ class ActivityContext implements DocGeneratorContextWithAdminFormInterface, DocGeneratorContextWithPublicFormInterface { - public function __construct(private DocumentCategoryRepository $documentCategoryRepository, private NormalizerInterface $normalizer, private TranslatableStringHelperInterface $translatableStringHelper, private EntityManagerInterface $em, private PersonRenderInterface $personRender, private PersonRepository $personRepository, private TranslatorInterface $translator, private BaseContextData $baseContextData) + public function __construct(private readonly DocumentCategoryRepository $documentCategoryRepository, private readonly NormalizerInterface $normalizer, private readonly TranslatableStringHelperInterface $translatableStringHelper, private readonly EntityManagerInterface $em, private readonly PersonRenderInterface $personRender, private readonly PersonRepository $personRepository, private readonly TranslatorInterface $translator, private readonly BaseContextData $baseContextData) { } diff --git a/src/Bundle/ChillActivityBundle/Service/DocGenerator/ListActivitiesByAccompanyingPeriodContext.php b/src/Bundle/ChillActivityBundle/Service/DocGenerator/ListActivitiesByAccompanyingPeriodContext.php index dc895782a..4d049515c 100644 --- a/src/Bundle/ChillActivityBundle/Service/DocGenerator/ListActivitiesByAccompanyingPeriodContext.php +++ b/src/Bundle/ChillActivityBundle/Service/DocGenerator/ListActivitiesByAccompanyingPeriodContext.php @@ -48,7 +48,7 @@ class ListActivitiesByAccompanyingPeriodContext implements DocGeneratorContextWithAdminFormInterface, DocGeneratorContextWithPublicFormInterface { - public function __construct(private AccompanyingPeriodContext $accompanyingPeriodContext, private ActivityACLAwareRepositoryInterface $activityACLAwareRepository, private NormalizerInterface $normalizer, private PersonRepository $personRepository, private SocialActionRepository $socialActionRepository, private SocialIssueRepository $socialIssueRepository, private ThirdPartyRepository $thirdPartyRepository, private TranslatableStringHelperInterface $translatableStringHelper, private UserRepository $userRepository) + public function __construct(private readonly AccompanyingPeriodContext $accompanyingPeriodContext, private readonly ActivityACLAwareRepositoryInterface $activityACLAwareRepository, private readonly NormalizerInterface $normalizer, private readonly PersonRepository $personRepository, private readonly SocialActionRepository $socialActionRepository, private readonly SocialIssueRepository $socialIssueRepository, private readonly ThirdPartyRepository $thirdPartyRepository, private readonly TranslatableStringHelperInterface $translatableStringHelper, private readonly UserRepository $userRepository) { } diff --git a/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityControllerTest.php b/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityControllerTest.php index b90a5018e..30fb72fb9 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityControllerTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityControllerTest.php @@ -214,7 +214,7 @@ final class ActivityControllerTest extends WebTestCase ->setName('social without activity'); //copy role scopes where ACTIVITY is not present foreach ($socialPermissionGroup->getRoleScopes() as $roleScope) { - if (!strpos($roleScope->getRole(), 'ACTIVITY')) { + if (!strpos((string) $roleScope->getRole(), 'ACTIVITY')) { $withoutActivityPermissionGroup->addRoleScope($roleScope); } } diff --git a/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityReasonCategoryControllerTest.php b/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityReasonCategoryControllerTest.php index 14f75e863..88d6535d2 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityReasonCategoryControllerTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityReasonCategoryControllerTest.php @@ -19,7 +19,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; */ final class ActivityReasonCategoryControllerTest extends WebTestCase { - public function testToWrite() + public function testToWrite(): never { $this->markTestSkipped(); } diff --git a/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityReasonControllerTest.php b/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityReasonControllerTest.php index 47de677a3..eafa7ed0b 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityReasonControllerTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityReasonControllerTest.php @@ -19,7 +19,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; */ final class ActivityReasonControllerTest extends WebTestCase { - public function testToWrite() + public function testToWrite(): never { $this->markTestSkipped(); } diff --git a/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityTypeControllerTest.php b/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityTypeControllerTest.php index b2276f427..49c0c6a08 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityTypeControllerTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityTypeControllerTest.php @@ -19,7 +19,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; */ final class ActivityTypeControllerTest extends WebTestCase { - public function testToWrite() + public function testToWrite(): never { $this->markTestSkipped(); } diff --git a/src/Bundle/ChillActivityBundle/Tests/Form/Type/TranslatableActivityReasonTest.php b/src/Bundle/ChillActivityBundle/Tests/Form/Type/TranslatableActivityReasonTest.php index a8d85daa6..82750a751 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Form/Type/TranslatableActivityReasonTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Form/Type/TranslatableActivityReasonTest.php @@ -34,7 +34,7 @@ final class TranslatableActivityReasonTest extends TypeTestCase parent::setUp(); } - public function testSimple() + public function testSimple(): never { $translatableActivityReasonType = new PickActivityReasonType( $this->getTranslatableStringHelper() diff --git a/src/Bundle/ChillActivityBundle/Tests/Timeline/TimelineProviderTest.php b/src/Bundle/ChillActivityBundle/Tests/Timeline/TimelineProviderTest.php index 664196ad4..ff6f46567 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Timeline/TimelineProviderTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Timeline/TimelineProviderTest.php @@ -19,7 +19,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; */ final class TimelineProviderTest extends WebTestCase { - public function testAnActivityIsShownOnTimeline() + public function testAnActivityIsShownOnTimeline(): never { $this->markTestSkipped('we have to write fixtures before writing this tests'); } diff --git a/src/Bundle/ChillActivityBundle/Validator/Constraints/ActivityValidity.php b/src/Bundle/ChillActivityBundle/Validator/Constraints/ActivityValidity.php index 393b33322..bb1dbc9d3 100644 --- a/src/Bundle/ChillActivityBundle/Validator/Constraints/ActivityValidity.php +++ b/src/Bundle/ChillActivityBundle/Validator/Constraints/ActivityValidity.php @@ -18,9 +18,9 @@ use Symfony\Component\Validator\Constraint; */ class ActivityValidity extends Constraint { - public const IS_REQUIRED_MESSAGE = ' is required'; + final public const IS_REQUIRED_MESSAGE = ' is required'; - public const ROOT_MESSAGE = 'For this type of activity, '; + final public const ROOT_MESSAGE = 'For this type of activity, '; public $noPersonsMessage = 'For this type of activity, you must add at least one person'; diff --git a/src/Bundle/ChillAsideActivityBundle/src/Controller/AsideActivityController.php b/src/Bundle/ChillAsideActivityBundle/src/Controller/AsideActivityController.php index 281585bb9..1aa53db4e 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Controller/AsideActivityController.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Controller/AsideActivityController.php @@ -21,7 +21,7 @@ use Symfony\Component\HttpFoundation\Request; final class AsideActivityController extends CRUDController { - public function __construct(private AsideActivityCategoryRepository $categoryRepository) + public function __construct(private readonly AsideActivityCategoryRepository $categoryRepository) { } diff --git a/src/Bundle/ChillAsideActivityBundle/src/DataFixtures/ORM/LoadAsideActivity.php b/src/Bundle/ChillAsideActivityBundle/src/DataFixtures/ORM/LoadAsideActivity.php index e39813009..fdf035682 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/DataFixtures/ORM/LoadAsideActivity.php +++ b/src/Bundle/ChillAsideActivityBundle/src/DataFixtures/ORM/LoadAsideActivity.php @@ -24,7 +24,7 @@ use function random_int; class LoadAsideActivity extends Fixture implements DependentFixtureInterface { - public function __construct(private UserRepository $userRepository) + public function __construct(private readonly UserRepository $userRepository) { } diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByActivityTypeAggregator.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByActivityTypeAggregator.php index 86a1360dc..aed5f95a0 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByActivityTypeAggregator.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByActivityTypeAggregator.php @@ -20,7 +20,7 @@ use Symfony\Component\Form\FormBuilderInterface; class ByActivityTypeAggregator implements AggregatorInterface { - public function __construct(private AsideActivityCategoryRepository $asideActivityCategoryRepository, private TranslatableStringHelper $translatableStringHelper) + public function __construct(private readonly AsideActivityCategoryRepository $asideActivityCategoryRepository, private readonly TranslatableStringHelper $translatableStringHelper) { } diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserJobAggregator.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserJobAggregator.php index a911ad163..aa4e57481 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserJobAggregator.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserJobAggregator.php @@ -22,7 +22,7 @@ use function in_array; class ByUserJobAggregator implements AggregatorInterface { - public function __construct(private UserJobRepositoryInterface $userJobRepository, private TranslatableStringHelperInterface $translatableStringHelper) + public function __construct(private readonly UserJobRepositoryInterface $userJobRepository, private readonly TranslatableStringHelperInterface $translatableStringHelper) { } diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserScopeAggregator.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserScopeAggregator.php index 553e2f77b..47c0b6826 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserScopeAggregator.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserScopeAggregator.php @@ -22,7 +22,7 @@ use function in_array; class ByUserScopeAggregator implements AggregatorInterface { - public function __construct(private ScopeRepositoryInterface $scopeRepository, private TranslatableStringHelperInterface $translatableStringHelper) + public function __construct(private readonly ScopeRepositoryInterface $scopeRepository, private readonly TranslatableStringHelperInterface $translatableStringHelper) { } diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Declarations.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Declarations.php index 8c808ea37..f86f78866 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Declarations.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Declarations.php @@ -16,5 +16,5 @@ namespace Chill\AsideActivityBundle\Export; */ abstract class Declarations { - public const ASIDE_ACTIVITY_TYPE = 'aside_activity'; + final public const ASIDE_ACTIVITY_TYPE = 'aside_activity'; } diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/AvgAsideActivityDuration.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/AvgAsideActivityDuration.php index 75d221b70..62b37b870 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/AvgAsideActivityDuration.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/AvgAsideActivityDuration.php @@ -23,7 +23,7 @@ use Symfony\Component\Form\FormBuilderInterface; class AvgAsideActivityDuration implements ExportInterface, GroupedExportInterface { - public function __construct(private AsideActivityRepository $repository) + public function __construct(private readonly AsideActivityRepository $repository) { } diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/CountAsideActivity.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/CountAsideActivity.php index e9c4932f3..7e4d40bef 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/CountAsideActivity.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/CountAsideActivity.php @@ -23,7 +23,7 @@ use Symfony\Component\Form\FormBuilderInterface; class CountAsideActivity implements ExportInterface, GroupedExportInterface { - public function __construct(private AsideActivityRepository $repository) + public function __construct(private readonly AsideActivityRepository $repository) { } diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/ListAsideActivity.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/ListAsideActivity.php index a59962829..b6772dbb0 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/ListAsideActivity.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/ListAsideActivity.php @@ -32,7 +32,7 @@ use Doctrine\ORM\QueryBuilder; use LogicException; use Symfony\Component\Form\FormBuilderInterface; -final class ListAsideActivity implements ListInterface, GroupedExportInterface +final readonly class ListAsideActivity implements ListInterface, GroupedExportInterface { public function __construct(private EntityManagerInterface $em, private DateTimeHelper $dateTimeHelper, private UserHelper $userHelper, private ScopeRepositoryInterface $scopeRepository, private CenterRepositoryInterface $centerRepository, private AsideActivityCategoryRepository $asideActivityCategoryRepository, private CategoryRender $categoryRender, private TranslatableStringHelperInterface $translatableStringHelper) { diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/SumAsideActivityDuration.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/SumAsideActivityDuration.php index 278fd7b91..7aca79004 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/SumAsideActivityDuration.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/SumAsideActivityDuration.php @@ -23,7 +23,7 @@ use Symfony\Component\Form\FormBuilderInterface; class SumAsideActivityDuration implements ExportInterface, GroupedExportInterface { - public function __construct(private AsideActivityRepository $repository) + public function __construct(private readonly AsideActivityRepository $repository) { } diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByActivityTypeFilter.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByActivityTypeFilter.php index 535ee04bb..13b60ab7e 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByActivityTypeFilter.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByActivityTypeFilter.php @@ -23,7 +23,7 @@ use Symfony\Component\Form\FormBuilderInterface; class ByActivityTypeFilter implements FilterInterface { - public function __construct(private CategoryRender $categoryRender, private TranslatableStringHelperInterface $translatableStringHelper, private AsideActivityCategoryRepository $asideActivityTypeRepository) + public function __construct(private readonly CategoryRender $categoryRender, private readonly TranslatableStringHelperInterface $translatableStringHelper, private readonly AsideActivityCategoryRepository $asideActivityTypeRepository) { } diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByDateFilter.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByDateFilter.php index 05bf46889..226caaba1 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByDateFilter.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByDateFilter.php @@ -26,7 +26,7 @@ use Symfony\Contracts\Translation\TranslatorInterface; class ByDateFilter implements FilterInterface { - public function __construct(private RollingDateConverterInterface $rollingDateConverter, protected TranslatorInterface $translator) + public function __construct(private readonly RollingDateConverterInterface $rollingDateConverter, protected TranslatorInterface $translator) { } diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserFilter.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserFilter.php index 809ec1250..6b7f19601 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserFilter.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserFilter.php @@ -20,7 +20,7 @@ use Symfony\Component\Form\FormBuilderInterface; class ByUserFilter implements FilterInterface { - public function __construct(private UserRender $userRender) + public function __construct(private readonly UserRender $userRender) { } diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserJobFilter.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserJobFilter.php index 8b7b1c662..5b3f3cf62 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserJobFilter.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserJobFilter.php @@ -22,7 +22,7 @@ use Symfony\Component\Form\FormBuilderInterface; class ByUserJobFilter implements FilterInterface { - public function __construct(private TranslatableStringHelperInterface $translatableStringHelper) + public function __construct(private readonly TranslatableStringHelperInterface $translatableStringHelper) { } diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserScopeFilter.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserScopeFilter.php index b7b7edfe4..6269ff562 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserScopeFilter.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserScopeFilter.php @@ -23,7 +23,7 @@ use Symfony\Component\Form\FormBuilderInterface; class ByUserScopeFilter implements FilterInterface { - public function __construct(private ScopeRepositoryInterface $scopeRepository, private TranslatableStringHelperInterface $translatableStringHelper) + public function __construct(private readonly ScopeRepositoryInterface $scopeRepository, private readonly TranslatableStringHelperInterface $translatableStringHelper) { } diff --git a/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityCategoryType.php b/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityCategoryType.php index 584c528e4..c285f0f9b 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityCategoryType.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityCategoryType.php @@ -22,7 +22,7 @@ use Symfony\Component\Form\FormBuilderInterface; final class AsideActivityCategoryType extends AbstractType { - public function __construct(private CategoryRender $categoryRender) + public function __construct(private readonly CategoryRender $categoryRender) { } diff --git a/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityFormType.php b/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityFormType.php index 727287972..dee87061c 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityFormType.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityFormType.php @@ -33,7 +33,7 @@ use function in_array; final class AsideActivityFormType extends AbstractType { - private array $timeChoices; + private readonly array $timeChoices; public function __construct( ParameterBagInterface $parameterBag, @@ -105,13 +105,7 @@ final class AsideActivityFormType extends AbstractType if (!in_array($data->getTimestamp(), $timeChoices, true)) { // the data are not in the possible values. add them $timeChoices[$data->format('H:i')] = $data->getTimestamp(); - $form = $builder->create($fieldName, ChoiceType::class, array_merge( - $durationTimeOptions, - [ - 'choices' => $timeChoices, - 'auto_initialize' => false, - ] - )); + $form = $builder->create($fieldName, ChoiceType::class, [...$durationTimeOptions, 'choices' => $timeChoices, 'auto_initialize' => false]); $form->addModelTransformer($durationTimeTransformer); $formEvent->getForm()->getParent()->add($form->getForm()); } diff --git a/src/Bundle/ChillAsideActivityBundle/src/Form/Type/PickAsideActivityCategoryType.php b/src/Bundle/ChillAsideActivityBundle/src/Form/Type/PickAsideActivityCategoryType.php index 63f6372d8..8341d8595 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Form/Type/PickAsideActivityCategoryType.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Form/Type/PickAsideActivityCategoryType.php @@ -20,7 +20,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver; final class PickAsideActivityCategoryType extends AbstractType { - public function __construct(private CategoryRender $categoryRender) + public function __construct(private readonly CategoryRender $categoryRender) { } diff --git a/src/Bundle/ChillAsideActivityBundle/src/Menu/AdminMenuBuilder.php b/src/Bundle/ChillAsideActivityBundle/src/Menu/AdminMenuBuilder.php index dcf5c6720..d0a593dab 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Menu/AdminMenuBuilder.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Menu/AdminMenuBuilder.php @@ -14,7 +14,7 @@ namespace Chill\AsideActivityBundle\Menu; use Knp\Menu\MenuItem; use Symfony\Component\Security\Core\Security; -final class AdminMenuBuilder implements \Chill\MainBundle\Routing\LocalMenuBuilderInterface +final readonly class AdminMenuBuilder implements \Chill\MainBundle\Routing\LocalMenuBuilderInterface { public function __construct(private Security $security) { diff --git a/src/Bundle/ChillAsideActivityBundle/src/Repository/AsideActivityCategoryRepository.php b/src/Bundle/ChillAsideActivityBundle/src/Repository/AsideActivityCategoryRepository.php index 918cec586..6735606ce 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Repository/AsideActivityCategoryRepository.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Repository/AsideActivityCategoryRepository.php @@ -18,7 +18,7 @@ use Doctrine\Persistence\ObjectRepository; class AsideActivityCategoryRepository implements ObjectRepository { - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct(EntityManagerInterface $entityManager) { diff --git a/src/Bundle/ChillAsideActivityBundle/src/Security/AsideActivityVoter.php b/src/Bundle/ChillAsideActivityBundle/src/Security/AsideActivityVoter.php index 6b308b5f2..e15abd439 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Security/AsideActivityVoter.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Security/AsideActivityVoter.php @@ -21,9 +21,9 @@ use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; class AsideActivityVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface { - public const STATS = 'CHILL_ASIDE_ACTIVITY_STATS'; + final public const STATS = 'CHILL_ASIDE_ACTIVITY_STATS'; - private VoterHelperInterface $voterHelper; + private readonly VoterHelperInterface $voterHelper; public function __construct( VoterHelperFactoryInterface $voterHelperFactory diff --git a/src/Bundle/ChillAsideActivityBundle/src/Templating/Entity/CategoryRender.php b/src/Bundle/ChillAsideActivityBundle/src/Templating/Entity/CategoryRender.php index f4a7c4977..9094169c2 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Templating/Entity/CategoryRender.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Templating/Entity/CategoryRender.php @@ -19,7 +19,7 @@ use Symfony\Component\Templating\EngineInterface; /** * @implements ChillEntityRenderInterface */ -final class CategoryRender implements ChillEntityRenderInterface +final readonly class CategoryRender implements ChillEntityRenderInterface { public const DEFAULT_ARGS = [ self::SEPERATOR_KEY => ' > ', diff --git a/src/Bundle/ChillBudgetBundle/Calculator/CalculatorResult.php b/src/Bundle/ChillBudgetBundle/Calculator/CalculatorResult.php index 380e641a6..052045f7e 100644 --- a/src/Bundle/ChillBudgetBundle/Calculator/CalculatorResult.php +++ b/src/Bundle/ChillBudgetBundle/Calculator/CalculatorResult.php @@ -13,11 +13,11 @@ namespace Chill\BudgetBundle\Calculator; class CalculatorResult { - public const TYPE_CURRENCY = 'currency'; + final public const TYPE_CURRENCY = 'currency'; - public const TYPE_PERCENTAGE = 'percentage'; + final public const TYPE_PERCENTAGE = 'percentage'; - public const TYPE_RATE = 'rate'; + final public const TYPE_RATE = 'rate'; public $label; diff --git a/src/Bundle/ChillBudgetBundle/Controller/ElementController.php b/src/Bundle/ChillBudgetBundle/Controller/ElementController.php index 20f05a8ca..c949342b9 100644 --- a/src/Bundle/ChillBudgetBundle/Controller/ElementController.php +++ b/src/Bundle/ChillBudgetBundle/Controller/ElementController.php @@ -31,7 +31,7 @@ use function count; class ElementController extends AbstractController { - public function __construct(private CalculatorManager $calculator, private ResourceRepository $resourceRepository, private ChargeRepository $chargeRepository) + public function __construct(private readonly CalculatorManager $calculator, private readonly ResourceRepository $resourceRepository, private readonly ChargeRepository $chargeRepository) { } diff --git a/src/Bundle/ChillBudgetBundle/Entity/Charge.php b/src/Bundle/ChillBudgetBundle/Entity/Charge.php index 056e4abff..50602e849 100644 --- a/src/Bundle/ChillBudgetBundle/Entity/Charge.php +++ b/src/Bundle/ChillBudgetBundle/Entity/Charge.php @@ -24,15 +24,15 @@ use Doctrine\ORM\Mapping as ORM; */ class Charge extends AbstractElement implements HasCentersInterface { - public const HELP_ASKED = 'running'; + final public const HELP_ASKED = 'running'; - public const HELP_NO = 'no'; + final public const HELP_NO = 'no'; - public const HELP_NOT_RELEVANT = 'not-relevant'; + final public const HELP_NOT_RELEVANT = 'not-relevant'; - public const HELP_YES = 'yes'; + final public const HELP_YES = 'yes'; - public const HELPS = [ + final public const HELPS = [ self::HELP_ASKED, self::HELP_NO, self::HELP_YES, diff --git a/src/Bundle/ChillBudgetBundle/Form/ChargeType.php b/src/Bundle/ChillBudgetBundle/Form/ChargeType.php index 778866cb3..c2f2e4b67 100644 --- a/src/Bundle/ChillBudgetBundle/Form/ChargeType.php +++ b/src/Bundle/ChillBudgetBundle/Form/ChargeType.php @@ -27,7 +27,7 @@ use Symfony\Contracts\Translation\TranslatorInterface; class ChargeType extends AbstractType { - public function __construct(protected TranslatableStringHelperInterface $translatableStringHelper, private ChargeKindRepository $repository, private TranslatorInterface $translator) + public function __construct(protected TranslatableStringHelperInterface $translatableStringHelper, private readonly ChargeKindRepository $repository, private readonly TranslatorInterface $translator) { } diff --git a/src/Bundle/ChillBudgetBundle/Form/ResourceType.php b/src/Bundle/ChillBudgetBundle/Form/ResourceType.php index c98301597..3896b0dd8 100644 --- a/src/Bundle/ChillBudgetBundle/Form/ResourceType.php +++ b/src/Bundle/ChillBudgetBundle/Form/ResourceType.php @@ -26,7 +26,7 @@ use Symfony\Contracts\Translation\TranslatorInterface; class ResourceType extends AbstractType { - public function __construct(protected TranslatableStringHelperInterface $translatableStringHelper, private ResourceKindRepository $repository, private TranslatorInterface $translator) + public function __construct(protected TranslatableStringHelperInterface $translatableStringHelper, private readonly ResourceKindRepository $repository, private readonly TranslatorInterface $translator) { } diff --git a/src/Bundle/ChillBudgetBundle/Menu/AdminMenuBuilder.php b/src/Bundle/ChillBudgetBundle/Menu/AdminMenuBuilder.php index 787980862..805ad865d 100644 --- a/src/Bundle/ChillBudgetBundle/Menu/AdminMenuBuilder.php +++ b/src/Bundle/ChillBudgetBundle/Menu/AdminMenuBuilder.php @@ -15,7 +15,7 @@ use Chill\MainBundle\Routing\LocalMenuBuilderInterface; use Knp\Menu\MenuItem; use Symfony\Component\Security\Core\Security; -final class AdminMenuBuilder implements LocalMenuBuilderInterface +final readonly class AdminMenuBuilder implements LocalMenuBuilderInterface { public function __construct(private Security $security) { diff --git a/src/Bundle/ChillBudgetBundle/Repository/ChargeKindRepository.php b/src/Bundle/ChillBudgetBundle/Repository/ChargeKindRepository.php index 9aaf68ddf..a0c23a4ad 100644 --- a/src/Bundle/ChillBudgetBundle/Repository/ChargeKindRepository.php +++ b/src/Bundle/ChillBudgetBundle/Repository/ChargeKindRepository.php @@ -17,7 +17,7 @@ use Doctrine\ORM\EntityRepository; final class ChargeKindRepository implements ChargeKindRepositoryInterface { - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct(EntityManagerInterface $entityManager) { diff --git a/src/Bundle/ChillBudgetBundle/Repository/ResourceKindRepository.php b/src/Bundle/ChillBudgetBundle/Repository/ResourceKindRepository.php index 1f9f99753..1ac419e30 100644 --- a/src/Bundle/ChillBudgetBundle/Repository/ResourceKindRepository.php +++ b/src/Bundle/ChillBudgetBundle/Repository/ResourceKindRepository.php @@ -17,7 +17,7 @@ use Doctrine\ORM\EntityRepository; final class ResourceKindRepository implements ResourceKindRepositoryInterface { - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct(EntityManagerInterface $entityManager) { diff --git a/src/Bundle/ChillBudgetBundle/Security/Authorization/BudgetElementVoter.php b/src/Bundle/ChillBudgetBundle/Security/Authorization/BudgetElementVoter.php index 5203f9092..11d465421 100644 --- a/src/Bundle/ChillBudgetBundle/Security/Authorization/BudgetElementVoter.php +++ b/src/Bundle/ChillBudgetBundle/Security/Authorization/BudgetElementVoter.php @@ -24,20 +24,20 @@ use UnexpectedValueException; class BudgetElementVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface { - public const CREATE = 'CHILL_BUDGET_ELEMENT_CREATE'; + final public const CREATE = 'CHILL_BUDGET_ELEMENT_CREATE'; - public const DELETE = 'CHILL_BUDGET_ELEMENT_DELETE'; + final public const DELETE = 'CHILL_BUDGET_ELEMENT_DELETE'; - public const ROLES = [ + final public const ROLES = [ self::CREATE, self::DELETE, self::SEE, self::UPDATE, ]; - public const SEE = 'CHILL_BUDGET_ELEMENT_SEE'; + final public const SEE = 'CHILL_BUDGET_ELEMENT_SEE'; - public const UPDATE = 'CHILL_BUDGET_ELEMENT_UPDATE'; + final public const UPDATE = 'CHILL_BUDGET_ELEMENT_UPDATE'; protected VoterHelperInterface $voter; diff --git a/src/Bundle/ChillBudgetBundle/Service/Summary/SummaryBudget.php b/src/Bundle/ChillBudgetBundle/Service/Summary/SummaryBudget.php index 17e80bd63..70348da30 100644 --- a/src/Bundle/ChillBudgetBundle/Service/Summary/SummaryBudget.php +++ b/src/Bundle/ChillBudgetBundle/Service/Summary/SummaryBudget.php @@ -27,7 +27,7 @@ use function count; /** * Helps to find a summary of the budget: the sum of resources and charges. */ -final class SummaryBudget implements SummaryBudgetInterface +final readonly class SummaryBudget implements SummaryBudgetInterface { private const QUERY_CHARGE_BY_HOUSEHOLD = 'select SUM(amount) AS sum, string_agg(comment, \'|\') AS comment, charge_id AS kind_id FROM chill_budget.charge WHERE (person_id IN (_ids_) OR household_id = ?) AND NOW() BETWEEN startdate AND COALESCE(enddate, \'infinity\'::timestamp) GROUP BY charge_id'; diff --git a/src/Bundle/ChillBudgetBundle/Templating/BudgetElementTypeRender.php b/src/Bundle/ChillBudgetBundle/Templating/BudgetElementTypeRender.php index 336d69c66..c48c952a1 100644 --- a/src/Bundle/ChillBudgetBundle/Templating/BudgetElementTypeRender.php +++ b/src/Bundle/ChillBudgetBundle/Templating/BudgetElementTypeRender.php @@ -20,7 +20,7 @@ use Symfony\Component\Templating\EngineInterface; /** * @implements ChillEntityRenderInterface */ -final class BudgetElementTypeRender implements ChillEntityRenderInterface +final readonly class BudgetElementTypeRender implements ChillEntityRenderInterface { public function __construct(private TranslatableStringHelperInterface $translatableStringHelper, private EngineInterface $engine) { diff --git a/src/Bundle/ChillBudgetBundle/Tests/Service/Summary/SummaryBudgetTest.php b/src/Bundle/ChillBudgetBundle/Tests/Service/Summary/SummaryBudgetTest.php index 4190341d0..7d90bf575 100644 --- a/src/Bundle/ChillBudgetBundle/Tests/Service/Summary/SummaryBudgetTest.php +++ b/src/Bundle/ChillBudgetBundle/Tests/Service/Summary/SummaryBudgetTest.php @@ -66,11 +66,11 @@ final class SummaryBudgetTest extends TestCase $em = $this->prophesize(EntityManagerInterface::class); $em->createNativeQuery(Argument::type('string'), Argument::type(Query\ResultSetMapping::class)) ->will(static function ($args) use ($queryResources, $queryCharges) { - if (str_contains($args[0], 'chill_budget.resource')) { + if (str_contains((string) $args[0], 'chill_budget.resource')) { return $queryResources->reveal(); } - if (str_contains($args[0], 'chill_budget.charge')) { + if (str_contains((string) $args[0], 'chill_budget.charge')) { return $queryCharges->reveal(); } diff --git a/src/Bundle/ChillCalendarBundle/Command/AzureGrantAdminConsentAndAcquireToken.php b/src/Bundle/ChillCalendarBundle/Command/AzureGrantAdminConsentAndAcquireToken.php index d71439314..de9b5477f 100644 --- a/src/Bundle/ChillCalendarBundle/Command/AzureGrantAdminConsentAndAcquireToken.php +++ b/src/Bundle/ChillCalendarBundle/Command/AzureGrantAdminConsentAndAcquireToken.php @@ -29,7 +29,7 @@ use TheNetworg\OAuth2\Client\Provider\Azure; class AzureGrantAdminConsentAndAcquireToken extends Command { - public function __construct(private Azure $azure, private ClientRegistry $clientRegistry, private MachineTokenStorage $machineTokenStorage) + public function __construct(private readonly Azure $azure, private readonly ClientRegistry $clientRegistry, private readonly MachineTokenStorage $machineTokenStorage) { parent::__construct('chill:calendar:msgraph-grant-admin-consent'); } diff --git a/src/Bundle/ChillCalendarBundle/Command/MapAndSubscribeUserCalendarCommand.php b/src/Bundle/ChillCalendarBundle/Command/MapAndSubscribeUserCalendarCommand.php index 48b9242fd..35517ec9e 100644 --- a/src/Bundle/ChillCalendarBundle/Command/MapAndSubscribeUserCalendarCommand.php +++ b/src/Bundle/ChillCalendarBundle/Command/MapAndSubscribeUserCalendarCommand.php @@ -33,11 +33,11 @@ use Symfony\Component\Console\Output\OutputInterface; class MapAndSubscribeUserCalendarCommand extends Command { public function __construct( - private EntityManagerInterface $em, - private EventsOnUserSubscriptionCreator $eventsOnUserSubscriptionCreator, - private LoggerInterface $logger, - private MapCalendarToUser $mapCalendarToUser, - private MSGraphUserRepository $userRepository + private readonly EntityManagerInterface $em, + private readonly EventsOnUserSubscriptionCreator $eventsOnUserSubscriptionCreator, + private readonly LoggerInterface $logger, + private readonly MapCalendarToUser $mapCalendarToUser, + private readonly MSGraphUserRepository $userRepository ) { parent::__construct('chill:calendar:msgraph-user-map-subscribe'); } diff --git a/src/Bundle/ChillCalendarBundle/Command/SendShortMessageOnEligibleCalendar.php b/src/Bundle/ChillCalendarBundle/Command/SendShortMessageOnEligibleCalendar.php index de5f43102..8222d0ace 100644 --- a/src/Bundle/ChillCalendarBundle/Command/SendShortMessageOnEligibleCalendar.php +++ b/src/Bundle/ChillCalendarBundle/Command/SendShortMessageOnEligibleCalendar.php @@ -25,7 +25,7 @@ use Symfony\Component\Console\Output\OutputInterface; class SendShortMessageOnEligibleCalendar extends Command { - public function __construct(private BulkCalendarShortMessageSender $messageSender) + public function __construct(private readonly BulkCalendarShortMessageSender $messageSender) { parent::__construct(); } diff --git a/src/Bundle/ChillCalendarBundle/Command/SendTestShortMessageOnCalendarCommand.php b/src/Bundle/ChillCalendarBundle/Command/SendTestShortMessageOnCalendarCommand.php index 882277c91..e39ff2d75 100644 --- a/src/Bundle/ChillCalendarBundle/Command/SendTestShortMessageOnCalendarCommand.php +++ b/src/Bundle/ChillCalendarBundle/Command/SendTestShortMessageOnCalendarCommand.php @@ -44,12 +44,12 @@ use function count; class SendTestShortMessageOnCalendarCommand extends Command { public function __construct( - private PersonRepository $personRepository, - private PhoneNumberUtil $phoneNumberUtil, - private PhoneNumberHelperInterface $phoneNumberHelper, - private ShortMessageForCalendarBuilderInterface $messageForCalendarBuilder, - private ShortMessageTransporterInterface $transporter, - private UserRepositoryInterface $userRepository + private readonly PersonRepository $personRepository, + private readonly PhoneNumberUtil $phoneNumberUtil, + private readonly PhoneNumberHelperInterface $phoneNumberHelper, + private readonly ShortMessageForCalendarBuilderInterface $messageForCalendarBuilder, + private readonly ShortMessageTransporterInterface $transporter, + private readonly UserRepositoryInterface $userRepository ) { parent::__construct(); } diff --git a/src/Bundle/ChillCalendarBundle/Controller/CalendarAPIController.php b/src/Bundle/ChillCalendarBundle/Controller/CalendarAPIController.php index b426dabd8..65d8301a8 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/CalendarAPIController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/CalendarAPIController.php @@ -24,7 +24,7 @@ use Symfony\Component\Routing\Annotation\Route; class CalendarAPIController extends ApiController { - public function __construct(private CalendarRepository $calendarRepository) + public function __construct(private readonly CalendarRepository $calendarRepository) { } diff --git a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php index 34481facb..aaa4d7832 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php @@ -49,7 +49,7 @@ use Symfony\Contracts\Translation\TranslatorInterface; class CalendarController extends AbstractController { - public function __construct(private CalendarACLAwareRepositoryInterface $calendarACLAwareRepository, private DocGeneratorTemplateRepository $docGeneratorTemplateRepository, private FilterOrderHelperFactoryInterface $filterOrderHelperFactory, private LoggerInterface $logger, private PaginatorFactory $paginator, private RemoteCalendarConnectorInterface $remoteCalendarConnector, private SerializerInterface $serializer, private TranslatableStringHelperInterface $translatableStringHelper, private PersonRepository $personRepository, private AccompanyingPeriodRepository $accompanyingPeriodRepository, private UserRepositoryInterface $userRepository, private TranslatorInterface $translator) + public function __construct(private readonly CalendarACLAwareRepositoryInterface $calendarACLAwareRepository, private readonly DocGeneratorTemplateRepository $docGeneratorTemplateRepository, private readonly FilterOrderHelperFactoryInterface $filterOrderHelperFactory, private readonly LoggerInterface $logger, private readonly PaginatorFactory $paginator, private readonly RemoteCalendarConnectorInterface $remoteCalendarConnector, private readonly SerializerInterface $serializer, private readonly TranslatableStringHelperInterface $translatableStringHelper, private readonly PersonRepository $personRepository, private readonly AccompanyingPeriodRepository $accompanyingPeriodRepository, private readonly UserRepositoryInterface $userRepository, private readonly TranslatorInterface $translator) { } diff --git a/src/Bundle/ChillCalendarBundle/Controller/CalendarDocController.php b/src/Bundle/ChillCalendarBundle/Controller/CalendarDocController.php index 16d1c942c..6542f5c97 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/CalendarDocController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/CalendarDocController.php @@ -33,9 +33,7 @@ use UnexpectedValueException; class CalendarDocController { - private SerializerInterface $serializer; - - public function __construct(private DocGeneratorTemplateRepository $docGeneratorTemplateRepository, private EngineInterface $engine, private EntityManagerInterface $entityManager, private FormFactoryInterface $formFactory, private Security $security, private UrlGeneratorInterface $urlGenerator) + public function __construct(private readonly DocGeneratorTemplateRepository $docGeneratorTemplateRepository, private readonly EngineInterface $engine, private readonly EntityManagerInterface $entityManager, private readonly FormFactoryInterface $formFactory, private readonly Security $security, private readonly UrlGeneratorInterface $urlGenerator) { } diff --git a/src/Bundle/ChillCalendarBundle/Controller/CalendarRangeAPIController.php b/src/Bundle/ChillCalendarBundle/Controller/CalendarRangeAPIController.php index 1b967a9ee..443c88e7e 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/CalendarRangeAPIController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/CalendarRangeAPIController.php @@ -25,7 +25,7 @@ use Symfony\Component\Routing\Annotation\Route; class CalendarRangeAPIController extends ApiController { - public function __construct(private CalendarRangeRepository $calendarRangeRepository) + public function __construct(private readonly CalendarRangeRepository $calendarRangeRepository) { } diff --git a/src/Bundle/ChillCalendarBundle/Controller/InviteApiController.php b/src/Bundle/ChillCalendarBundle/Controller/InviteApiController.php index 6e4930cdb..b230010e3 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/InviteApiController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/InviteApiController.php @@ -35,7 +35,7 @@ use function in_array; class InviteApiController { - public function __construct(private EntityManagerInterface $entityManager, private MessageBusInterface $messageBus, private Security $security) + public function __construct(private readonly EntityManagerInterface $entityManager, private readonly MessageBusInterface $messageBus, private readonly Security $security) { } diff --git a/src/Bundle/ChillCalendarBundle/Controller/RemoteCalendarConnectAzureController.php b/src/Bundle/ChillCalendarBundle/Controller/RemoteCalendarConnectAzureController.php index d10b5d41a..a8339137a 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/RemoteCalendarConnectAzureController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/RemoteCalendarConnectAzureController.php @@ -30,7 +30,7 @@ use TheNetworg\OAuth2\Client\Token\AccessToken; class RemoteCalendarConnectAzureController { - public function __construct(private ClientRegistry $clientRegistry, private OnBehalfOfUserTokenStorage $MSGraphTokenStorage) + public function __construct(private readonly ClientRegistry $clientRegistry, private readonly OnBehalfOfUserTokenStorage $MSGraphTokenStorage) { } diff --git a/src/Bundle/ChillCalendarBundle/Controller/RemoteCalendarMSGraphSyncController.php b/src/Bundle/ChillCalendarBundle/Controller/RemoteCalendarMSGraphSyncController.php index 33e549b37..9abed89c0 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/RemoteCalendarMSGraphSyncController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/RemoteCalendarMSGraphSyncController.php @@ -29,7 +29,7 @@ use const JSON_THROW_ON_ERROR; class RemoteCalendarMSGraphSyncController { - public function __construct(private MessageBusInterface $messageBus) + public function __construct(private readonly MessageBusInterface $messageBus) { } diff --git a/src/Bundle/ChillCalendarBundle/Controller/RemoteCalendarProxyController.php b/src/Bundle/ChillCalendarBundle/Controller/RemoteCalendarProxyController.php index a2143922f..102157447 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/RemoteCalendarProxyController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/RemoteCalendarProxyController.php @@ -36,7 +36,7 @@ use function count; */ class RemoteCalendarProxyController { - public function __construct(private PaginatorFactory $paginatorFactory, private RemoteCalendarConnectorInterface $remoteCalendarConnector, private SerializerInterface $serializer) + public function __construct(private readonly PaginatorFactory $paginatorFactory, private readonly RemoteCalendarConnectorInterface $remoteCalendarConnector, private readonly SerializerInterface $serializer) { } diff --git a/src/Bundle/ChillCalendarBundle/DataFixtures/ORM/LoadCalendarRange.php b/src/Bundle/ChillCalendarBundle/DataFixtures/ORM/LoadCalendarRange.php index 493a97dec..5dc0cd9f0 100644 --- a/src/Bundle/ChillCalendarBundle/DataFixtures/ORM/LoadCalendarRange.php +++ b/src/Bundle/ChillCalendarBundle/DataFixtures/ORM/LoadCalendarRange.php @@ -29,7 +29,7 @@ class LoadCalendarRange extends Fixture implements FixtureGroupInterface, Ordere { public static array $references = []; - public function __construct(private UserRepository $userRepository) + public function __construct(private readonly UserRepository $userRepository) { } diff --git a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php index dc98c47d9..9fb449115 100644 --- a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php +++ b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php @@ -58,20 +58,20 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente use TrackUpdateTrait; - public const SMS_CANCEL_PENDING = 'sms_cancel_pending'; + final public const SMS_CANCEL_PENDING = 'sms_cancel_pending'; - public const SMS_PENDING = 'sms_pending'; + final public const SMS_PENDING = 'sms_pending'; - public const SMS_SENT = 'sms_sent'; + final public const SMS_SENT = 'sms_sent'; - public const STATUS_CANCELED = 'canceled'; + final public const STATUS_CANCELED = 'canceled'; /** * @deprecated */ - public const STATUS_MOVED = 'moved'; + final public const STATUS_MOVED = 'moved'; - public const STATUS_VALID = 'valid'; + final public const STATUS_VALID = 'valid'; /** * a list of invite which have been added during this session. diff --git a/src/Bundle/ChillCalendarBundle/Entity/CancelReason.php b/src/Bundle/ChillCalendarBundle/Entity/CancelReason.php index a262842c2..3c4d80c94 100644 --- a/src/Bundle/ChillCalendarBundle/Entity/CancelReason.php +++ b/src/Bundle/ChillCalendarBundle/Entity/CancelReason.php @@ -20,11 +20,11 @@ use Doctrine\ORM\Mapping as ORM; */ class CancelReason { - public const CANCELEDBY_DONOTCOUNT = 'CANCELEDBY_DONOTCOUNT'; + final public const CANCELEDBY_DONOTCOUNT = 'CANCELEDBY_DONOTCOUNT'; - public const CANCELEDBY_PERSON = 'CANCELEDBY_PERSON'; + final public const CANCELEDBY_PERSON = 'CANCELEDBY_PERSON'; - public const CANCELEDBY_USER = 'CANCELEDBY_USER'; + final public const CANCELEDBY_USER = 'CANCELEDBY_USER'; /** * @ORM\Column(type="boolean") diff --git a/src/Bundle/ChillCalendarBundle/Entity/Invite.php b/src/Bundle/ChillCalendarBundle/Entity/Invite.php index c2d79aff2..da1b9bb9e 100644 --- a/src/Bundle/ChillCalendarBundle/Entity/Invite.php +++ b/src/Bundle/ChillCalendarBundle/Entity/Invite.php @@ -40,23 +40,23 @@ class Invite implements TrackUpdateInterface, TrackCreationInterface use TrackUpdateTrait; - public const ACCEPTED = 'accepted'; + final public const ACCEPTED = 'accepted'; - public const DECLINED = 'declined'; + final public const DECLINED = 'declined'; - public const PENDING = 'pending'; + final public const PENDING = 'pending'; /** * all statuses in one const. */ - public const STATUSES = [ + final public const STATUSES = [ self::ACCEPTED, self::DECLINED, self::PENDING, self::TENTATIVELY_ACCEPTED, ]; - public const TENTATIVELY_ACCEPTED = 'tentative'; + final public const TENTATIVELY_ACCEPTED = 'tentative'; /** * @ORM\ManyToOne(targetEntity=Calendar::class, inversedBy="invites") diff --git a/src/Bundle/ChillCalendarBundle/Event/ListenToActivityCreate.php b/src/Bundle/ChillCalendarBundle/Event/ListenToActivityCreate.php index b781615ef..6870b5292 100644 --- a/src/Bundle/ChillCalendarBundle/Event/ListenToActivityCreate.php +++ b/src/Bundle/ChillCalendarBundle/Event/ListenToActivityCreate.php @@ -19,7 +19,7 @@ use function array_key_exists; class ListenToActivityCreate { - public function __construct(private RequestStack $requestStack) + public function __construct(private readonly RequestStack $requestStack) { } diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/AgentAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/AgentAggregator.php index bc76dc021..132fbfeed 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/AgentAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/AgentAggregator.php @@ -20,7 +20,7 @@ use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; use function in_array; -final class AgentAggregator implements AggregatorInterface +final readonly class AgentAggregator implements AggregatorInterface { public function __construct(private UserRepository $userRepository, private UserRender $userRender) { diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/CancelReasonAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/CancelReasonAggregator.php index 051150378..5501215b7 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/CancelReasonAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/CancelReasonAggregator.php @@ -22,7 +22,7 @@ use function in_array; class CancelReasonAggregator implements AggregatorInterface { - public function __construct(private CancelReasonRepository $cancelReasonRepository, private TranslatableStringHelper $translatableStringHelper) + public function __construct(private readonly CancelReasonRepository $cancelReasonRepository, private readonly TranslatableStringHelper $translatableStringHelper) { } diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/JobAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/JobAggregator.php index dbda0ad61..5094e05d0 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/JobAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/JobAggregator.php @@ -20,7 +20,7 @@ use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; use function in_array; -final class JobAggregator implements AggregatorInterface +final readonly class JobAggregator implements AggregatorInterface { public function __construct(private UserJobRepository $jobRepository, private TranslatableStringHelper $translatableStringHelper) { diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationAggregator.php index 954175935..36c224603 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationAggregator.php @@ -19,7 +19,7 @@ use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; use function in_array; -final class LocationAggregator implements AggregatorInterface +final readonly class LocationAggregator implements AggregatorInterface { public function __construct(private LocationRepository $locationRepository) { diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationTypeAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationTypeAggregator.php index 489bda8cb..b716fd4e7 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationTypeAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationTypeAggregator.php @@ -20,7 +20,7 @@ use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; use function in_array; -final class LocationTypeAggregator implements AggregatorInterface +final readonly class LocationTypeAggregator implements AggregatorInterface { public function __construct(private LocationTypeRepository $locationTypeRepository, private TranslatableStringHelper $translatableStringHelper) { diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/ScopeAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/ScopeAggregator.php index 6f72648e0..529fa2e92 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/ScopeAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/ScopeAggregator.php @@ -20,7 +20,7 @@ use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; use function in_array; -final class ScopeAggregator implements AggregatorInterface +final readonly class ScopeAggregator implements AggregatorInterface { public function __construct(private ScopeRepository $scopeRepository, private TranslatableStringHelper $translatableStringHelper) { diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/UrgencyAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/UrgencyAggregator.php index c7b03a146..53c6b2cb9 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/UrgencyAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/UrgencyAggregator.php @@ -28,7 +28,7 @@ use Symfony\Contracts\Translation\TranslatorInterface; class UrgencyAggregator implements AggregatorInterface { - public function __construct(private TranslatorInterface $translator) + public function __construct(private readonly TranslatorInterface $translator) { } diff --git a/src/Bundle/ChillCalendarBundle/Export/Declarations.php b/src/Bundle/ChillCalendarBundle/Export/Declarations.php index 0df90749c..a007424e5 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Declarations.php +++ b/src/Bundle/ChillCalendarBundle/Export/Declarations.php @@ -16,5 +16,5 @@ namespace Chill\CalendarBundle\Export; */ abstract class Declarations { - public const CALENDAR_TYPE = 'calendar'; + final public const CALENDAR_TYPE = 'calendar'; } diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php b/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php index 50367ece7..81d519063 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php @@ -25,7 +25,7 @@ use Symfony\Component\Validator\Exception\LogicException; class CountCalendars implements ExportInterface, GroupedExportInterface { - public function __construct(private CalendarRepository $calendarRepository) + public function __construct(private readonly CalendarRepository $calendarRepository) { } diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php index 68ab4fdd3..9964b8638 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php @@ -24,7 +24,7 @@ use Symfony\Component\Form\FormBuilderInterface; class StatCalendarAvgDuration implements ExportInterface, GroupedExportInterface { - public function __construct(private CalendarRepository $calendarRepository) + public function __construct(private readonly CalendarRepository $calendarRepository) { } diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php index fe94cc4e0..2d372f898 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php @@ -24,7 +24,7 @@ use Symfony\Component\Form\FormBuilderInterface; class StatCalendarSumDuration implements ExportInterface, GroupedExportInterface { - public function __construct(private CalendarRepository $calendarRepository) + public function __construct(private readonly CalendarRepository $calendarRepository) { } diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php index 6ae9d8236..2e31388d2 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php @@ -22,7 +22,7 @@ use Symfony\Component\Form\FormBuilderInterface; class AgentFilter implements FilterInterface { - public function __construct(private UserRender $userRender) + public function __construct(private readonly UserRender $userRender) { } diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/BetweenDatesFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/BetweenDatesFilter.php index 9a316208c..62eb1418c 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/BetweenDatesFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/BetweenDatesFilter.php @@ -21,7 +21,7 @@ use Symfony\Component\Form\FormBuilderInterface; class BetweenDatesFilter implements FilterInterface { - public function __construct(private RollingDateConverterInterface $rollingDateConverter) + public function __construct(private readonly RollingDateConverterInterface $rollingDateConverter) { } diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/CalendarRangeFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/CalendarRangeFilter.php index 6795457d9..bee70238a 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/CalendarRangeFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/CalendarRangeFilter.php @@ -35,7 +35,7 @@ class CalendarRangeFilter implements FilterInterface private const DEFAULT_CHOICE = false; - public function __construct(private TranslatorInterface $translator) + public function __construct(private readonly TranslatorInterface $translator) { } diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php index 47482c732..e27de7633 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php @@ -24,7 +24,7 @@ use function in_array; class JobFilter implements FilterInterface { - public function __construct(protected TranslatorInterface $translator, private TranslatableStringHelper $translatableStringHelper) + public function __construct(protected TranslatorInterface $translator, private readonly TranslatableStringHelper $translatableStringHelper) { } diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php index 80cbdec37..1f4f82a8e 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php @@ -24,7 +24,7 @@ use function in_array; class ScopeFilter implements FilterInterface { - public function __construct(protected TranslatorInterface $translator, private TranslatableStringHelper $translatableStringHelper) + public function __construct(protected TranslatorInterface $translator, private readonly TranslatableStringHelper $translatableStringHelper) { } diff --git a/src/Bundle/ChillCalendarBundle/Form/CalendarType.php b/src/Bundle/ChillCalendarBundle/Form/CalendarType.php index e54517ef3..a67d48b0b 100644 --- a/src/Bundle/ChillCalendarBundle/Form/CalendarType.php +++ b/src/Bundle/ChillCalendarBundle/Form/CalendarType.php @@ -32,7 +32,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver; class CalendarType extends AbstractType { - public function __construct(private PersonsToIdDataTransformer $personsToIdDataTransformer, private IdToUserDataTransformer $idToUserDataTransformer, private IdToUsersDataTransformer $idToUsersDataTransformer, private IdToLocationDataTransformer $idToLocationDataTransformer, private ThirdPartiesToIdDataTransformer $partiesToIdDataTransformer, private IdToCalendarRangeDataTransformer $calendarRangeDataTransformer) + public function __construct(private readonly PersonsToIdDataTransformer $personsToIdDataTransformer, private readonly IdToUserDataTransformer $idToUserDataTransformer, private readonly IdToUsersDataTransformer $idToUsersDataTransformer, private readonly IdToLocationDataTransformer $idToLocationDataTransformer, private readonly ThirdPartiesToIdDataTransformer $partiesToIdDataTransformer, private readonly IdToCalendarRangeDataTransformer $calendarRangeDataTransformer) { } diff --git a/src/Bundle/ChillCalendarBundle/Menu/AccompanyingCourseMenuBuilder.php b/src/Bundle/ChillCalendarBundle/Menu/AccompanyingCourseMenuBuilder.php index a81fbdedd..3997c4dad 100644 --- a/src/Bundle/ChillCalendarBundle/Menu/AccompanyingCourseMenuBuilder.php +++ b/src/Bundle/ChillCalendarBundle/Menu/AccompanyingCourseMenuBuilder.php @@ -19,7 +19,7 @@ use Symfony\Contracts\Translation\TranslatorInterface; class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface { - public function __construct(private Security $security, protected TranslatorInterface $translator) + public function __construct(private readonly Security $security, protected TranslatorInterface $translator) { } diff --git a/src/Bundle/ChillCalendarBundle/Menu/PersonMenuBuilder.php b/src/Bundle/ChillCalendarBundle/Menu/PersonMenuBuilder.php index fb1a60a7b..c7bbc756c 100644 --- a/src/Bundle/ChillCalendarBundle/Menu/PersonMenuBuilder.php +++ b/src/Bundle/ChillCalendarBundle/Menu/PersonMenuBuilder.php @@ -19,7 +19,7 @@ use Symfony\Contracts\Translation\TranslatorInterface; class PersonMenuBuilder implements LocalMenuBuilderInterface { - public function __construct(private Security $security, protected TranslatorInterface $translator) + public function __construct(private readonly Security $security, protected TranslatorInterface $translator) { } diff --git a/src/Bundle/ChillCalendarBundle/Menu/UserMenuBuilder.php b/src/Bundle/ChillCalendarBundle/Menu/UserMenuBuilder.php index f8c804519..90b94b08e 100644 --- a/src/Bundle/ChillCalendarBundle/Menu/UserMenuBuilder.php +++ b/src/Bundle/ChillCalendarBundle/Menu/UserMenuBuilder.php @@ -18,7 +18,7 @@ use Symfony\Contracts\Translation\TranslatorInterface; class UserMenuBuilder implements LocalMenuBuilderInterface { - public function __construct(private Security $security, public TranslatorInterface $translator) + public function __construct(private readonly Security $security, public TranslatorInterface $translator) { } diff --git a/src/Bundle/ChillCalendarBundle/Messenger/Doctrine/CalendarEntityListener.php b/src/Bundle/ChillCalendarBundle/Messenger/Doctrine/CalendarEntityListener.php index d940cbeca..6b51b3793 100644 --- a/src/Bundle/ChillCalendarBundle/Messenger/Doctrine/CalendarEntityListener.php +++ b/src/Bundle/ChillCalendarBundle/Messenger/Doctrine/CalendarEntityListener.php @@ -30,7 +30,7 @@ use Symfony\Component\Security\Core\Security; class CalendarEntityListener { - public function __construct(private MessageBusInterface $messageBus, private Security $security) + public function __construct(private readonly MessageBusInterface $messageBus, private readonly Security $security) { } diff --git a/src/Bundle/ChillCalendarBundle/Messenger/Doctrine/CalendarRangeEntityListener.php b/src/Bundle/ChillCalendarBundle/Messenger/Doctrine/CalendarRangeEntityListener.php index cb3d9a763..40da612e5 100644 --- a/src/Bundle/ChillCalendarBundle/Messenger/Doctrine/CalendarRangeEntityListener.php +++ b/src/Bundle/ChillCalendarBundle/Messenger/Doctrine/CalendarRangeEntityListener.php @@ -30,7 +30,7 @@ use Symfony\Component\Security\Core\Security; class CalendarRangeEntityListener { - public function __construct(private MessageBusInterface $messageBus, private Security $security) + public function __construct(private readonly MessageBusInterface $messageBus, private readonly Security $security) { } diff --git a/src/Bundle/ChillCalendarBundle/Messenger/Handler/CalendarRangeRemoveToRemoteHandler.php b/src/Bundle/ChillCalendarBundle/Messenger/Handler/CalendarRangeRemoveToRemoteHandler.php index b814d4cb8..c55bd8144 100644 --- a/src/Bundle/ChillCalendarBundle/Messenger/Handler/CalendarRangeRemoveToRemoteHandler.php +++ b/src/Bundle/ChillCalendarBundle/Messenger/Handler/CalendarRangeRemoveToRemoteHandler.php @@ -31,7 +31,7 @@ use Symfony\Component\Messenger\Handler\MessageHandlerInterface; */ class CalendarRangeRemoveToRemoteHandler implements MessageHandlerInterface { - public function __construct(private RemoteCalendarConnectorInterface $remoteCalendarConnector, private UserRepository $userRepository) + public function __construct(private readonly RemoteCalendarConnectorInterface $remoteCalendarConnector, private readonly UserRepository $userRepository) { } diff --git a/src/Bundle/ChillCalendarBundle/Messenger/Handler/CalendarRangeToRemoteHandler.php b/src/Bundle/ChillCalendarBundle/Messenger/Handler/CalendarRangeToRemoteHandler.php index b94ab6d9d..950ca526d 100644 --- a/src/Bundle/ChillCalendarBundle/Messenger/Handler/CalendarRangeToRemoteHandler.php +++ b/src/Bundle/ChillCalendarBundle/Messenger/Handler/CalendarRangeToRemoteHandler.php @@ -32,7 +32,7 @@ use Symfony\Component\Messenger\Handler\MessageHandlerInterface; */ class CalendarRangeToRemoteHandler implements MessageHandlerInterface { - public function __construct(private CalendarRangeRepository $calendarRangeRepository, private RemoteCalendarConnectorInterface $remoteCalendarConnector, private EntityManagerInterface $entityManager) + public function __construct(private readonly CalendarRangeRepository $calendarRangeRepository, private readonly RemoteCalendarConnectorInterface $remoteCalendarConnector, private readonly EntityManagerInterface $entityManager) { } diff --git a/src/Bundle/ChillCalendarBundle/Messenger/Handler/CalendarRemoveHandler.php b/src/Bundle/ChillCalendarBundle/Messenger/Handler/CalendarRemoveHandler.php index ccc8d0a06..6838d3147 100644 --- a/src/Bundle/ChillCalendarBundle/Messenger/Handler/CalendarRemoveHandler.php +++ b/src/Bundle/ChillCalendarBundle/Messenger/Handler/CalendarRemoveHandler.php @@ -31,7 +31,7 @@ use Symfony\Component\Messenger\Handler\MessageHandlerInterface; */ class CalendarRemoveHandler implements MessageHandlerInterface { - public function __construct(private RemoteCalendarConnectorInterface $remoteCalendarConnector, private CalendarRangeRepository $calendarRangeRepository, private UserRepositoryInterface $userRepository) + public function __construct(private readonly RemoteCalendarConnectorInterface $remoteCalendarConnector, private readonly CalendarRangeRepository $calendarRangeRepository, private readonly UserRepositoryInterface $userRepository) { } diff --git a/src/Bundle/ChillCalendarBundle/Messenger/Handler/CalendarToRemoteHandler.php b/src/Bundle/ChillCalendarBundle/Messenger/Handler/CalendarToRemoteHandler.php index 2698921fc..310e8734b 100644 --- a/src/Bundle/ChillCalendarBundle/Messenger/Handler/CalendarToRemoteHandler.php +++ b/src/Bundle/ChillCalendarBundle/Messenger/Handler/CalendarToRemoteHandler.php @@ -37,7 +37,7 @@ use Symfony\Component\Messenger\Handler\MessageHandlerInterface; */ class CalendarToRemoteHandler implements MessageHandlerInterface { - public function __construct(private CalendarRangeRepository $calendarRangeRepository, private CalendarRepository $calendarRepository, private EntityManagerInterface $entityManager, private InviteRepository $inviteRepository, private RemoteCalendarConnectorInterface $calendarConnector, private UserRepository $userRepository) + public function __construct(private readonly CalendarRangeRepository $calendarRangeRepository, private readonly CalendarRepository $calendarRepository, private readonly EntityManagerInterface $entityManager, private readonly InviteRepository $inviteRepository, private readonly RemoteCalendarConnectorInterface $calendarConnector, private readonly UserRepository $userRepository) { } diff --git a/src/Bundle/ChillCalendarBundle/Messenger/Handler/InviteUpdateHandler.php b/src/Bundle/ChillCalendarBundle/Messenger/Handler/InviteUpdateHandler.php index b917a13ae..1d987c19e 100644 --- a/src/Bundle/ChillCalendarBundle/Messenger/Handler/InviteUpdateHandler.php +++ b/src/Bundle/ChillCalendarBundle/Messenger/Handler/InviteUpdateHandler.php @@ -31,7 +31,7 @@ use Symfony\Component\Messenger\Handler\MessageHandlerInterface; */ class InviteUpdateHandler implements MessageHandlerInterface { - public function __construct(private EntityManagerInterface $em, private InviteRepository $inviteRepository, private RemoteCalendarConnectorInterface $remoteCalendarConnector) + public function __construct(private readonly EntityManagerInterface $em, private readonly InviteRepository $inviteRepository, private readonly RemoteCalendarConnectorInterface $remoteCalendarConnector) { } diff --git a/src/Bundle/ChillCalendarBundle/Messenger/Handler/MSGraphChangeNotificationHandler.php b/src/Bundle/ChillCalendarBundle/Messenger/Handler/MSGraphChangeNotificationHandler.php index f6debd2d5..342180cf1 100644 --- a/src/Bundle/ChillCalendarBundle/Messenger/Handler/MSGraphChangeNotificationHandler.php +++ b/src/Bundle/ChillCalendarBundle/Messenger/Handler/MSGraphChangeNotificationHandler.php @@ -36,7 +36,7 @@ use Symfony\Component\Messenger\Handler\MessageHandlerInterface; */ class MSGraphChangeNotificationHandler implements MessageHandlerInterface { - public function __construct(private CalendarRangeRepository $calendarRangeRepository, private CalendarRangeSyncer $calendarRangeSyncer, private CalendarRepository $calendarRepository, private CalendarSyncer $calendarSyncer, private EntityManagerInterface $em, private LoggerInterface $logger, private MapCalendarToUser $mapCalendarToUser, private UserRepository $userRepository) + public function __construct(private readonly CalendarRangeRepository $calendarRangeRepository, private readonly CalendarRangeSyncer $calendarRangeSyncer, private readonly CalendarRepository $calendarRepository, private readonly CalendarSyncer $calendarSyncer, private readonly EntityManagerInterface $em, private readonly LoggerInterface $logger, private readonly MapCalendarToUser $mapCalendarToUser, private readonly UserRepository $userRepository) { } diff --git a/src/Bundle/ChillCalendarBundle/Messenger/Message/CalendarMessage.php b/src/Bundle/ChillCalendarBundle/Messenger/Message/CalendarMessage.php index 53b20e49e..9bcd81c67 100644 --- a/src/Bundle/ChillCalendarBundle/Messenger/Message/CalendarMessage.php +++ b/src/Bundle/ChillCalendarBundle/Messenger/Message/CalendarMessage.php @@ -24,13 +24,13 @@ use Chill\MainBundle\Entity\User; class CalendarMessage { - public const CALENDAR_PERSIST = 'CHILL_CALENDAR_CALENDAR_PERSIST'; + final public const CALENDAR_PERSIST = 'CHILL_CALENDAR_CALENDAR_PERSIST'; - public const CALENDAR_UPDATE = 'CHILL_CALENDAR_CALENDAR_UPDATE'; + final public const CALENDAR_UPDATE = 'CHILL_CALENDAR_CALENDAR_UPDATE'; - private int $byUserId; + private readonly int $byUserId; - private int $calendarId; + private readonly int $calendarId; private array $newInvitesIds = []; @@ -45,7 +45,7 @@ class CalendarMessage public function __construct( Calendar $calendar, - private string $action, + private readonly string $action, User $byUser ) { $this->calendarId = $calendar->getId(); diff --git a/src/Bundle/ChillCalendarBundle/Messenger/Message/CalendarRangeMessage.php b/src/Bundle/ChillCalendarBundle/Messenger/Message/CalendarRangeMessage.php index 61d006a79..13669a0a2 100644 --- a/src/Bundle/ChillCalendarBundle/Messenger/Message/CalendarRangeMessage.php +++ b/src/Bundle/ChillCalendarBundle/Messenger/Message/CalendarRangeMessage.php @@ -23,15 +23,15 @@ use Chill\MainBundle\Entity\User; class CalendarRangeMessage { - public const CALENDAR_RANGE_PERSIST = 'CHILL_CALENDAR_CALENDAR_RANGE_PERSIST'; + final public const CALENDAR_RANGE_PERSIST = 'CHILL_CALENDAR_CALENDAR_RANGE_PERSIST'; - public const CALENDAR_RANGE_UPDATE = 'CHILL_CALENDAR_CALENDAR_RANGE_UPDATE'; + final public const CALENDAR_RANGE_UPDATE = 'CHILL_CALENDAR_CALENDAR_RANGE_UPDATE'; private ?int $byUserId = null; - private int $calendarRangeId; + private readonly int $calendarRangeId; - public function __construct(CalendarRange $calendarRange, private string $action, ?User $byUser) + public function __construct(CalendarRange $calendarRange, private readonly string $action, ?User $byUser) { $this->calendarRangeId = $calendarRange->getId(); diff --git a/src/Bundle/ChillCalendarBundle/Messenger/Message/CalendarRangeRemovedMessage.php b/src/Bundle/ChillCalendarBundle/Messenger/Message/CalendarRangeRemovedMessage.php index 783484592..eb8be6838 100644 --- a/src/Bundle/ChillCalendarBundle/Messenger/Message/CalendarRangeRemovedMessage.php +++ b/src/Bundle/ChillCalendarBundle/Messenger/Message/CalendarRangeRemovedMessage.php @@ -25,11 +25,11 @@ class CalendarRangeRemovedMessage { private ?int $byUserId = null; - private int $calendarRangeUserId; + private readonly int $calendarRangeUserId; - private array $remoteAttributes; + private readonly array $remoteAttributes; - private string $remoteId; + private readonly string $remoteId; public function __construct(CalendarRange $calendarRange, ?User $byUser) { diff --git a/src/Bundle/ChillCalendarBundle/Messenger/Message/CalendarRemovedMessage.php b/src/Bundle/ChillCalendarBundle/Messenger/Message/CalendarRemovedMessage.php index 65831ebe0..53dcea28c 100644 --- a/src/Bundle/ChillCalendarBundle/Messenger/Message/CalendarRemovedMessage.php +++ b/src/Bundle/ChillCalendarBundle/Messenger/Message/CalendarRemovedMessage.php @@ -27,11 +27,11 @@ class CalendarRemovedMessage private ?int $byUserId = null; - private int $calendarUserId; + private readonly int $calendarUserId; - private array $remoteAttributes; + private readonly array $remoteAttributes; - private string $remoteId; + private readonly string $remoteId; public function __construct(Calendar $calendar, ?User $byUser) { diff --git a/src/Bundle/ChillCalendarBundle/Messenger/Message/InviteUpdateMessage.php b/src/Bundle/ChillCalendarBundle/Messenger/Message/InviteUpdateMessage.php index 35f78fc7d..d18ab8db1 100644 --- a/src/Bundle/ChillCalendarBundle/Messenger/Message/InviteUpdateMessage.php +++ b/src/Bundle/ChillCalendarBundle/Messenger/Message/InviteUpdateMessage.php @@ -23,9 +23,9 @@ use Chill\MainBundle\Entity\User; class InviteUpdateMessage { - private int $byUserId; + private readonly int $byUserId; - private int $inviteId; + private readonly int $inviteId; public function __construct(Invite $invite, User $byUser) { diff --git a/src/Bundle/ChillCalendarBundle/Messenger/Message/MSGraphChangeNotificationMessage.php b/src/Bundle/ChillCalendarBundle/Messenger/Message/MSGraphChangeNotificationMessage.php index 8288787cb..682369e03 100644 --- a/src/Bundle/ChillCalendarBundle/Messenger/Message/MSGraphChangeNotificationMessage.php +++ b/src/Bundle/ChillCalendarBundle/Messenger/Message/MSGraphChangeNotificationMessage.php @@ -20,7 +20,7 @@ namespace Chill\CalendarBundle\Messenger\Message; class MSGraphChangeNotificationMessage { - public function __construct(private array $content, private int $userId) + public function __construct(private readonly array $content, private readonly int $userId) { } diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/AddressConverter.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/AddressConverter.php index 05f116c6b..2764a46e3 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/AddressConverter.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/AddressConverter.php @@ -24,7 +24,7 @@ use Chill\MainBundle\Templating\TranslatableStringHelperInterface; class AddressConverter { - public function __construct(private AddressRender $addressRender, private TranslatableStringHelperInterface $translatableStringHelper) + public function __construct(private readonly AddressRender $addressRender, private readonly TranslatableStringHelperInterface $translatableStringHelper) { } diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/EventsOnUserSubscriptionCreator.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/EventsOnUserSubscriptionCreator.php index 3bbe22161..f6d8cba5a 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/EventsOnUserSubscriptionCreator.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/EventsOnUserSubscriptionCreator.php @@ -30,7 +30,7 @@ use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface; */ class EventsOnUserSubscriptionCreator { - public function __construct(private LoggerInterface $logger, private MachineHttpClient $machineHttpClient, private MapCalendarToUser $mapCalendarToUser, private UrlGeneratorInterface $urlGenerator) + public function __construct(private readonly LoggerInterface $logger, private readonly MachineHttpClient $machineHttpClient, private readonly MapCalendarToUser $mapCalendarToUser, private readonly UrlGeneratorInterface $urlGenerator) { } diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/LocationConverter.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/LocationConverter.php index 5de500b52..cbf97806e 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/LocationConverter.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/LocationConverter.php @@ -22,7 +22,7 @@ use Chill\MainBundle\Entity\Location; class LocationConverter { - public function __construct(private AddressConverter $addressConverter) + public function __construct(private readonly AddressConverter $addressConverter) { } diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MSGraphUserRepository.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MSGraphUserRepository.php index 39fbf6c15..840ecd40f 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MSGraphUserRepository.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MSGraphUserRepository.php @@ -42,7 +42,7 @@ class MSGraphUserRepository ; SQL; - public function __construct(private EntityManagerInterface $entityManager) + public function __construct(private readonly EntityManagerInterface $entityManager) { } diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MachineHttpClient.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MachineHttpClient.php index 8a3f37678..b7b9b4e73 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MachineHttpClient.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MachineHttpClient.php @@ -28,12 +28,12 @@ class MachineHttpClient implements HttpClientInterface { use BearerAuthorizationTrait; - private HttpClientInterface $decoratedClient; + private readonly HttpClientInterface $decoratedClient; /** * @param HttpClientInterface $decoratedClient */ - public function __construct(private MachineTokenStorage $machineTokenStorage, ?HttpClientInterface $decoratedClient = null) + public function __construct(private readonly MachineTokenStorage $machineTokenStorage, ?HttpClientInterface $decoratedClient = null) { $this->decoratedClient = $decoratedClient ?? \Symfony\Component\HttpClient\HttpClient::create(); } diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MachineTokenStorage.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MachineTokenStorage.php index ad7060c1a..f5d25caaf 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MachineTokenStorage.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MachineTokenStorage.php @@ -29,7 +29,7 @@ class MachineTokenStorage private ?AccessTokenInterface $accessToken = null; - public function __construct(private Azure $azure, private ChillRedis $chillRedis) + public function __construct(private readonly Azure $azure, private readonly ChillRedis $chillRedis) { } diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MapCalendarToUser.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MapCalendarToUser.php index 6fcc9d20f..6abe11120 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MapCalendarToUser.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MapCalendarToUser.php @@ -31,15 +31,15 @@ use function array_key_exists; */ class MapCalendarToUser { - public const EXPIRATION_SUBSCRIPTION_EVENT = 'subscription_events_expiration'; + final public const EXPIRATION_SUBSCRIPTION_EVENT = 'subscription_events_expiration'; - public const ID_SUBSCRIPTION_EVENT = 'subscription_events_id'; + final public const ID_SUBSCRIPTION_EVENT = 'subscription_events_id'; - public const METADATA_KEY = 'msgraph'; + final public const METADATA_KEY = 'msgraph'; - public const SECRET_SUBSCRIPTION_EVENT = 'subscription_events_secret'; + final public const SECRET_SUBSCRIPTION_EVENT = 'subscription_events_secret'; - public function __construct(private HttpClientInterface $machineHttpClient, private LoggerInterface $logger) + public function __construct(private readonly HttpClientInterface $machineHttpClient, private readonly LoggerInterface $logger) { } diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/OnBehalfOfUserHttpClient.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/OnBehalfOfUserHttpClient.php index 70a7f1ca0..32f0e5dec 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/OnBehalfOfUserHttpClient.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/OnBehalfOfUserHttpClient.php @@ -28,12 +28,12 @@ class OnBehalfOfUserHttpClient { use BearerAuthorizationTrait; - private HttpClientInterface $decoratedClient; + private readonly HttpClientInterface $decoratedClient; /** * @param HttpClientInterface $decoratedClient */ - public function __construct(private OnBehalfOfUserTokenStorage $tokenStorage, ?HttpClientInterface $decoratedClient = null) + public function __construct(private readonly OnBehalfOfUserTokenStorage $tokenStorage, ?HttpClientInterface $decoratedClient = null) { $this->decoratedClient = $decoratedClient ?? \Symfony\Component\HttpClient\HttpClient::create(); } diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/OnBehalfOfUserTokenStorage.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/OnBehalfOfUserTokenStorage.php index 6bb171248..c40c46fbe 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/OnBehalfOfUserTokenStorage.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/OnBehalfOfUserTokenStorage.php @@ -28,9 +28,9 @@ use TheNetworg\OAuth2\Client\Token\AccessToken; */ class OnBehalfOfUserTokenStorage { - public const MS_GRAPH_ACCESS_TOKEN = 'msgraph_access_token'; + final public const MS_GRAPH_ACCESS_TOKEN = 'msgraph_access_token'; - public function __construct(private Azure $azure, private SessionInterface $session) + public function __construct(private readonly Azure $azure, private readonly SessionInterface $session) { } diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteEventConverter.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteEventConverter.php index 9d96357cd..c4d8e0b70 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteEventConverter.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteEventConverter.php @@ -41,27 +41,27 @@ class RemoteEventConverter * valid when the remote string contains also a timezone, like in * lastModifiedDate. */ - public const REMOTE_DATETIMEZONE_FORMAT = 'Y-m-d\\TH:i:s.u?P'; + final public const REMOTE_DATETIMEZONE_FORMAT = 'Y-m-d\\TH:i:s.u?P'; /** * Same as above, but sometimes the date is expressed with only 6 milliseconds. */ - public const REMOTE_DATETIMEZONE_FORMAT_ALT = 'Y-m-d\\TH:i:s.uP'; + final public const REMOTE_DATETIMEZONE_FORMAT_ALT = 'Y-m-d\\TH:i:s.uP'; private const REMOTE_DATE_FORMAT = 'Y-m-d\TH:i:s.u0'; private const REMOTE_DATETIME_WITHOUT_TZ_FORMAT = 'Y-m-d\TH:i:s.u?'; - private DateTimeZone $defaultDateTimeZone; + private readonly DateTimeZone $defaultDateTimeZone; - private DateTimeZone $remoteDateTimeZone; + private readonly DateTimeZone $remoteDateTimeZone; public function __construct( - private EngineInterface $engine, - private LocationConverter $locationConverter, - private LoggerInterface $logger, - private PersonRenderInterface $personRender, - private TranslatorInterface $translator + private readonly EngineInterface $engine, + private readonly LocationConverter $locationConverter, + private readonly LoggerInterface $logger, + private readonly PersonRenderInterface $personRender, + private readonly TranslatorInterface $translator ) { $this->defaultDateTimeZone = (new DateTimeImmutable())->getTimezone(); $this->remoteDateTimeZone = self::getRemoteTimeZone(); diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteToLocalSync/CalendarRangeSyncer.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteToLocalSync/CalendarRangeSyncer.php index add82d5d9..8df0d8a0b 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteToLocalSync/CalendarRangeSyncer.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteToLocalSync/CalendarRangeSyncer.php @@ -33,7 +33,7 @@ class CalendarRangeSyncer /** * @param MachineHttpClient $machineHttpClient */ - public function __construct(private EntityManagerInterface $em, private LoggerInterface $logger, private HttpClientInterface $machineHttpClient) + public function __construct(private readonly EntityManagerInterface $em, private readonly LoggerInterface $logger, private readonly HttpClientInterface $machineHttpClient) { } diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteToLocalSync/CalendarSyncer.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteToLocalSync/CalendarSyncer.php index 7767c0a8b..470e5d30a 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteToLocalSync/CalendarSyncer.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteToLocalSync/CalendarSyncer.php @@ -32,7 +32,7 @@ use function in_array; class CalendarSyncer { - public function __construct(private LoggerInterface $logger, private HttpClientInterface $machineHttpClient, private UserRepositoryInterface $userRepository) + public function __construct(private readonly LoggerInterface $logger, private readonly HttpClientInterface $machineHttpClient, private readonly UserRepositoryInterface $userRepository) { } @@ -119,7 +119,7 @@ class CalendarSyncer } $email = $attendee['emailAddress']['address']; - $emails[] = strtolower($email); + $emails[] = strtolower((string) $email); $user = $this->userRepository->findOneByUsernameOrEmail($email); if (null === $user) { diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraphRemoteCalendarConnector.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraphRemoteCalendarConnector.php index 9d6dcd65c..0d47eaec4 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraphRemoteCalendarConnector.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraphRemoteCalendarConnector.php @@ -45,7 +45,7 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface { private array $cacheScheduleTimeForUser = []; - public function __construct(private CalendarRepository $calendarRepository, private CalendarRangeRepository $calendarRangeRepository, private HttpClientInterface $machineHttpClient, private MapCalendarToUser $mapCalendarToUser, private LoggerInterface $logger, private OnBehalfOfUserTokenStorage $tokenStorage, private OnBehalfOfUserHttpClient $userHttpClient, private RemoteEventConverter $remoteEventConverter, private TranslatorInterface $translator, private UrlGeneratorInterface $urlGenerator, private Security $security) + public function __construct(private readonly CalendarRepository $calendarRepository, private readonly CalendarRangeRepository $calendarRangeRepository, private readonly HttpClientInterface $machineHttpClient, private readonly MapCalendarToUser $mapCalendarToUser, private readonly LoggerInterface $logger, private readonly OnBehalfOfUserTokenStorage $tokenStorage, private readonly OnBehalfOfUserHttpClient $userHttpClient, private readonly RemoteEventConverter $remoteEventConverter, private readonly TranslatorInterface $translator, private readonly UrlGeneratorInterface $urlGenerator, private readonly Security $security) { } diff --git a/src/Bundle/ChillCalendarBundle/Repository/CalendarACLAwareRepository.php b/src/Bundle/ChillCalendarBundle/Repository/CalendarACLAwareRepository.php index 1fc5dd351..6981f0a4c 100644 --- a/src/Bundle/ChillCalendarBundle/Repository/CalendarACLAwareRepository.php +++ b/src/Bundle/ChillCalendarBundle/Repository/CalendarACLAwareRepository.php @@ -29,7 +29,7 @@ use Doctrine\ORM\QueryBuilder; class CalendarACLAwareRepository implements CalendarACLAwareRepositoryInterface { - public function __construct(private AccompanyingPeriodACLAwareRepositoryInterface $accompanyingPeriodACLAwareRepository, private EntityManagerInterface $em) + public function __construct(private readonly AccompanyingPeriodACLAwareRepositoryInterface $accompanyingPeriodACLAwareRepository, private readonly EntityManagerInterface $em) { } diff --git a/src/Bundle/ChillCalendarBundle/Repository/CalendarDocRepository.php b/src/Bundle/ChillCalendarBundle/Repository/CalendarDocRepository.php index bd1074b5f..dd593bf3c 100644 --- a/src/Bundle/ChillCalendarBundle/Repository/CalendarDocRepository.php +++ b/src/Bundle/ChillCalendarBundle/Repository/CalendarDocRepository.php @@ -18,7 +18,7 @@ use Doctrine\Persistence\ObjectRepository; class CalendarDocRepository implements ObjectRepository, CalendarDocRepositoryInterface { - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct(EntityManagerInterface $entityManager) { diff --git a/src/Bundle/ChillCalendarBundle/Repository/CalendarRangeRepository.php b/src/Bundle/ChillCalendarBundle/Repository/CalendarRangeRepository.php index 69a077e47..b74110c96 100644 --- a/src/Bundle/ChillCalendarBundle/Repository/CalendarRangeRepository.php +++ b/src/Bundle/ChillCalendarBundle/Repository/CalendarRangeRepository.php @@ -24,9 +24,9 @@ use function count; class CalendarRangeRepository implements ObjectRepository { - private EntityRepository $repository; + private readonly EntityRepository $repository; - public function __construct(private EntityManagerInterface $em) + public function __construct(private readonly EntityManagerInterface $em) { $this->repository = $em->getRepository(CalendarRange::class); } diff --git a/src/Bundle/ChillCalendarBundle/Repository/CalendarRepository.php b/src/Bundle/ChillCalendarBundle/Repository/CalendarRepository.php index 4fd9b8a29..91a64c5ec 100644 --- a/src/Bundle/ChillCalendarBundle/Repository/CalendarRepository.php +++ b/src/Bundle/ChillCalendarBundle/Repository/CalendarRepository.php @@ -25,9 +25,9 @@ use function count; class CalendarRepository implements ObjectRepository { - private EntityManagerInterface $em; + private readonly EntityManagerInterface $em; - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct(EntityManagerInterface $entityManager) { diff --git a/src/Bundle/ChillCalendarBundle/Repository/InviteRepository.php b/src/Bundle/ChillCalendarBundle/Repository/InviteRepository.php index f0bd8fe88..8778330f8 100644 --- a/src/Bundle/ChillCalendarBundle/Repository/InviteRepository.php +++ b/src/Bundle/ChillCalendarBundle/Repository/InviteRepository.php @@ -18,7 +18,7 @@ use Doctrine\Persistence\ObjectRepository; class InviteRepository implements ObjectRepository { - private EntityRepository $entityRepository; + private readonly EntityRepository $entityRepository; public function __construct(EntityManagerInterface $em) { diff --git a/src/Bundle/ChillCalendarBundle/Security/Voter/CalendarDocVoter.php b/src/Bundle/ChillCalendarBundle/Security/Voter/CalendarDocVoter.php index 7cd815961..a3e1b91ff 100644 --- a/src/Bundle/ChillCalendarBundle/Security/Voter/CalendarDocVoter.php +++ b/src/Bundle/ChillCalendarBundle/Security/Voter/CalendarDocVoter.php @@ -20,16 +20,16 @@ use function in_array; class CalendarDocVoter extends Voter { - public const EDIT = 'CHILL_CALENDAR_DOC_EDIT'; + final public const EDIT = 'CHILL_CALENDAR_DOC_EDIT'; - public const SEE = 'CHILL_CALENDAR_DOC_SEE'; + final public const SEE = 'CHILL_CALENDAR_DOC_SEE'; private const ALL = [ 'CHILL_CALENDAR_DOC_EDIT', 'CHILL_CALENDAR_DOC_SEE', ]; - public function __construct(private Security $security) + public function __construct(private readonly Security $security) { } diff --git a/src/Bundle/ChillCalendarBundle/Security/Voter/CalendarVoter.php b/src/Bundle/ChillCalendarBundle/Security/Voter/CalendarVoter.php index faf6fb5c8..10370ebbb 100644 --- a/src/Bundle/ChillCalendarBundle/Security/Voter/CalendarVoter.php +++ b/src/Bundle/ChillCalendarBundle/Security/Voter/CalendarVoter.php @@ -34,22 +34,18 @@ use Symfony\Component\Security\Core\Security; class CalendarVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface { - public const CREATE = 'CHILL_CALENDAR_CALENDAR_CREATE'; + final public const CREATE = 'CHILL_CALENDAR_CALENDAR_CREATE'; - public const DELETE = 'CHILL_CALENDAR_CALENDAR_DELETE'; + final public const DELETE = 'CHILL_CALENDAR_CALENDAR_DELETE'; - public const EDIT = 'CHILL_CALENDAR_CALENDAR_EDIT'; + final public const EDIT = 'CHILL_CALENDAR_CALENDAR_EDIT'; - public const SEE = 'CHILL_CALENDAR_CALENDAR_SEE'; + final public const SEE = 'CHILL_CALENDAR_CALENDAR_SEE'; - private AuthorizationHelperInterface $authorizationHelper; - - private CenterResolverManagerInterface $centerResolverManager; - - private VoterHelperInterface $voterHelper; + private readonly VoterHelperInterface $voterHelper; public function __construct( - private Security $security, + private readonly Security $security, VoterHelperFactoryInterface $voterHelperFactory ) { $this->voterHelper = $voterHelperFactory diff --git a/src/Bundle/ChillCalendarBundle/Security/Voter/InviteVoter.php b/src/Bundle/ChillCalendarBundle/Security/Voter/InviteVoter.php index 36ca66d05..72aa806e6 100644 --- a/src/Bundle/ChillCalendarBundle/Security/Voter/InviteVoter.php +++ b/src/Bundle/ChillCalendarBundle/Security/Voter/InviteVoter.php @@ -24,7 +24,7 @@ use Symfony\Component\Security\Core\Authorization\Voter\Voter; class InviteVoter extends Voter { - public const ANSWER = 'CHILL_CALENDAR_INVITE_ANSWER'; + final public const ANSWER = 'CHILL_CALENDAR_INVITE_ANSWER'; protected function supports($attribute, $subject): bool { diff --git a/src/Bundle/ChillCalendarBundle/Service/DocGenerator/CalendarContext.php b/src/Bundle/ChillCalendarBundle/Service/DocGenerator/CalendarContext.php index cb8bb5f7a..88ab41e91 100644 --- a/src/Bundle/ChillCalendarBundle/Service/DocGenerator/CalendarContext.php +++ b/src/Bundle/ChillCalendarBundle/Service/DocGenerator/CalendarContext.php @@ -31,7 +31,7 @@ use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; use function count; -final class CalendarContext implements CalendarContextInterface +final readonly class CalendarContext implements CalendarContextInterface { public function __construct(private BaseContextData $baseContextData, private EntityManagerInterface $entityManager, private NormalizerInterface $normalizer, private PersonRender $personRender, private PersonRepository $personRepository, private ThirdPartyRender $thirdPartyRender, private ThirdPartyRepository $thirdPartyRepository, private TranslatableStringHelperInterface $translatableStringHelper) { diff --git a/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/BulkCalendarShortMessageSender.php b/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/BulkCalendarShortMessageSender.php index f5fc86373..ad558b774 100644 --- a/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/BulkCalendarShortMessageSender.php +++ b/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/BulkCalendarShortMessageSender.php @@ -26,7 +26,7 @@ use Symfony\Component\Messenger\MessageBusInterface; class BulkCalendarShortMessageSender { - public function __construct(private CalendarForShortMessageProvider $provider, private EntityManagerInterface $em, private LoggerInterface $logger, private MessageBusInterface $messageBus, private ShortMessageForCalendarBuilderInterface $messageForCalendarBuilder) + public function __construct(private readonly CalendarForShortMessageProvider $provider, private readonly EntityManagerInterface $em, private readonly LoggerInterface $logger, private readonly MessageBusInterface $messageBus, private readonly ShortMessageForCalendarBuilderInterface $messageForCalendarBuilder) { } diff --git a/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/CalendarForShortMessageProvider.php b/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/CalendarForShortMessageProvider.php index a6a8134ae..d460e6715 100644 --- a/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/CalendarForShortMessageProvider.php +++ b/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/CalendarForShortMessageProvider.php @@ -26,7 +26,7 @@ use function count; class CalendarForShortMessageProvider { - public function __construct(private CalendarRepository $calendarRepository, private EntityManagerInterface $em, private RangeGeneratorInterface $rangeGenerator) + public function __construct(private readonly CalendarRepository $calendarRepository, private readonly EntityManagerInterface $em, private readonly RangeGeneratorInterface $rangeGenerator) { } diff --git a/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/DefaultShortMessageForCalendarBuilder.php b/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/DefaultShortMessageForCalendarBuilder.php index 66de8781c..8177be31a 100644 --- a/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/DefaultShortMessageForCalendarBuilder.php +++ b/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/DefaultShortMessageForCalendarBuilder.php @@ -24,7 +24,7 @@ use Symfony\Component\Templating\EngineInterface; class DefaultShortMessageForCalendarBuilder implements ShortMessageForCalendarBuilderInterface { - public function __construct(private EngineInterface $engine) + public function __construct(private readonly EngineInterface $engine) { } diff --git a/src/Bundle/ChillCalendarBundle/Tests/Form/CalendarTypeTest.php b/src/Bundle/ChillCalendarBundle/Tests/Form/CalendarTypeTest.php index 9195d5eac..f9392ba57 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Form/CalendarTypeTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Form/CalendarTypeTest.php @@ -170,7 +170,7 @@ final class CalendarTypeTest extends TypeTestCase return $obj; }, - explode(',', $args[0]) + explode(',', (string) $args[0]) ); }); diff --git a/src/Bundle/ChillCustomFieldsBundle/Command/CreateFieldsOnGroupCommand.php b/src/Bundle/ChillCustomFieldsBundle/Command/CreateFieldsOnGroupCommand.php index 739cc6c6e..40a946bd2 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Command/CreateFieldsOnGroupCommand.php +++ b/src/Bundle/ChillCustomFieldsBundle/Command/CreateFieldsOnGroupCommand.php @@ -34,9 +34,9 @@ use function count; */ class CreateFieldsOnGroupCommand extends Command { - public const ARG_DELETE = 'delete'; + final public const ARG_DELETE = 'delete'; - public const ARG_PATH = 'path'; + final public const ARG_PATH = 'path'; /** * CreateFieldsOnGroupCommand constructor. @@ -45,9 +45,9 @@ class CreateFieldsOnGroupCommand extends Command * @param $customizablesEntities */ public function __construct( - private CustomFieldProvider $customFieldProvider, - private EntityManager $entityManager, - private ValidatorInterface $validator, + private readonly CustomFieldProvider $customFieldProvider, + private readonly EntityManager $entityManager, + private readonly ValidatorInterface $validator, private $availableLanguages, private $customizablesEntities ) { diff --git a/src/Bundle/ChillCustomFieldsBundle/Controller/CustomFieldsGroupController.php b/src/Bundle/ChillCustomFieldsBundle/Controller/CustomFieldsGroupController.php index 2ae552b01..75935afe7 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Controller/CustomFieldsGroupController.php +++ b/src/Bundle/ChillCustomFieldsBundle/Controller/CustomFieldsGroupController.php @@ -36,7 +36,7 @@ class CustomFieldsGroupController extends AbstractController /** * CustomFieldsGroupController constructor. */ - public function __construct(private CustomFieldProvider $customFieldProvider, private TranslatorInterface $translator) + public function __construct(private readonly CustomFieldProvider $customFieldProvider, private readonly TranslatorInterface $translator) { } diff --git a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldChoice.php b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldChoice.php index 8add4b995..f5a7b0f03 100644 --- a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldChoice.php +++ b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldChoice.php @@ -32,15 +32,15 @@ use function LogicException; class CustomFieldChoice extends AbstractCustomField { - public const ALLOW_OTHER = 'other'; + final public const ALLOW_OTHER = 'other'; - public const CHOICES = 'choices'; + final public const CHOICES = 'choices'; - public const EXPANDED = 'expanded'; + final public const EXPANDED = 'expanded'; - public const MULTIPLE = 'multiple'; + final public const MULTIPLE = 'multiple'; - public const OTHER_VALUE_LABEL = 'otherValueLabel'; + final public const OTHER_VALUE_LABEL = 'otherValueLabel'; private $defaultLocales; @@ -49,11 +49,11 @@ class CustomFieldChoice extends AbstractCustomField */ public function __construct( TranslatorInterface $translator, - private TwigEngine $templating, + private readonly TwigEngine $templating, /** * @var TranslatableStringHelper Helper that find the string in current locale from an array of translation */ - private TranslatableStringHelper $translatableStringHelper + private readonly TranslatableStringHelper $translatableStringHelper ) { $this->defaultLocales = $translator->getFallbackLocales(); } diff --git a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldDate.php b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldDate.php index b8688efb1..ccdbcb199 100644 --- a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldDate.php +++ b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldDate.php @@ -33,18 +33,18 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface; */ class CustomFieldDate extends AbstractCustomField { - public const DATE_FORMAT = DateTime::RFC3339; + final public const DATE_FORMAT = DateTime::RFC3339; - public const FORMAT = 'format'; + final public const FORMAT = 'format'; - public const MAX = 'max'; + final public const MAX = 'max'; /** * key for the minimal value of the field. */ - public const MIN = 'min'; + final public const MIN = 'min'; - public function __construct(private TwigEngine $templating, private TranslatableStringHelper $translatableStringHelper) + public function __construct(private readonly TwigEngine $templating, private readonly TranslatableStringHelper $translatableStringHelper) { } diff --git a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldLongChoice.php b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldLongChoice.php index aa73af462..5f7351372 100644 --- a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldLongChoice.php +++ b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldLongChoice.php @@ -30,12 +30,12 @@ use function is_object; class CustomFieldLongChoice extends AbstractCustomField { - public const KEY = 'key'; + final public const KEY = 'key'; public function __construct( - private OptionRepository $optionRepository, - private TranslatableStringHelper $translatableStringHelper, - private EngineInterface $templating, + private readonly OptionRepository $optionRepository, + private readonly TranslatableStringHelper $translatableStringHelper, + private readonly EngineInterface $templating, ) { } diff --git a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldNumber.php b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldNumber.php index 7c0e17931..69b856db1 100644 --- a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldNumber.php +++ b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldNumber.php @@ -28,18 +28,18 @@ use Symfony\Component\Validator\Constraints\LessThanOrEqual; */ class CustomFieldNumber extends AbstractCustomField { - public const MAX = 'max'; + final public const MAX = 'max'; /** * key for the minimal value of the field. */ - public const MIN = 'min'; + final public const MIN = 'min'; - public const POST_TEXT = 'post_text'; + final public const POST_TEXT = 'post_text'; - public const SCALE = 'scale'; + final public const SCALE = 'scale'; - public function __construct(private TwigEngine $templating, private TranslatableStringHelper $translatableStringHelper) + public function __construct(private readonly TwigEngine $templating, private readonly TranslatableStringHelper $translatableStringHelper) { } diff --git a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldText.php b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldText.php index 389303906..3be0886f6 100644 --- a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldText.php +++ b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldText.php @@ -25,17 +25,17 @@ use function array_key_exists; class CustomFieldText extends AbstractCustomField { - public const MAX_LENGTH = 'maxLength'; + final public const MAX_LENGTH = 'maxLength'; - public const MULTIPLE_CF_INLINE = 'multipleCFInline'; + final public const MULTIPLE_CF_INLINE = 'multipleCFInline'; public function __construct( - private RequestStack $requestStack, - private TwigEngine $templating, + private readonly RequestStack $requestStack, + private readonly TwigEngine $templating, /** * @var TranslatableStringHelper Helper that find the string in current locale from an array of translation */ - private TranslatableStringHelper $translatableStringHelper + private readonly TranslatableStringHelper $translatableStringHelper ) { } diff --git a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldTitle.php b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldTitle.php index 59114a4a5..4fbfe51d9 100644 --- a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldTitle.php +++ b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldTitle.php @@ -21,19 +21,19 @@ use Symfony\Component\HttpFoundation\RequestStack; class CustomFieldTitle extends AbstractCustomField { - public const TYPE = 'type'; + final public const TYPE = 'type'; - public const TYPE_SUBTITLE = 'subtitle'; + final public const TYPE_SUBTITLE = 'subtitle'; - public const TYPE_TITLE = 'title'; + final public const TYPE_TITLE = 'title'; public function __construct( - private RequestStack $requestStack, - private TwigEngine $templating, + private readonly RequestStack $requestStack, + private readonly TwigEngine $templating, /** * @var TranslatableStringHelper Helper that find the string in current locale from an array of translation */ - private TranslatableStringHelper $translatableStringHelper + private readonly TranslatableStringHelper $translatableStringHelper ) { } diff --git a/src/Bundle/ChillCustomFieldsBundle/Entity/CustomField.php b/src/Bundle/ChillCustomFieldsBundle/Entity/CustomField.php index d9f43ed3b..06aeb9f4f 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Entity/CustomField.php +++ b/src/Bundle/ChillCustomFieldsBundle/Entity/CustomField.php @@ -22,9 +22,9 @@ use Doctrine\ORM\Mapping as ORM; */ class CustomField { - public const ONE_TO_MANY = 2; + final public const ONE_TO_MANY = 2; - public const ONE_TO_ONE = 1; + final public const ONE_TO_ONE = 1; /** * @var bool diff --git a/src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldType.php b/src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldType.php index df4e82d5b..29a70bbca 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldType.php +++ b/src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldType.php @@ -30,7 +30,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver; class CustomFieldType extends AbstractType { - public function __construct(private CustomFieldProvider $customFieldProvider, private ObjectManager $om, private TranslatableStringHelper $translatableStringHelper) + public function __construct(private readonly CustomFieldProvider $customFieldProvider, private readonly ObjectManager $om, private readonly TranslatableStringHelper $translatableStringHelper) { } diff --git a/src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldsGroupType.php b/src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldsGroupType.php index e62e85c04..bf0e680c6 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldsGroupType.php +++ b/src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldsGroupType.php @@ -26,9 +26,9 @@ use function count; class CustomFieldsGroupType extends AbstractType { public function __construct( - private array $customizableEntities, + private readonly array $customizableEntities, //TODO : add comment about this variable - private TranslatorInterface $translator + private readonly TranslatorInterface $translator ) { } diff --git a/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/CustomFieldDataTransformer.php b/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/CustomFieldDataTransformer.php index f1df42ff7..3091ea66f 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/CustomFieldDataTransformer.php +++ b/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/CustomFieldDataTransformer.php @@ -17,7 +17,7 @@ use Symfony\Component\Form\DataTransformerInterface; class CustomFieldDataTransformer implements DataTransformerInterface { - public function __construct(private CustomFieldInterface $customFieldDefinition, private CustomField $customField) + public function __construct(private readonly CustomFieldInterface $customFieldDefinition, private readonly CustomField $customField) { } diff --git a/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/CustomFieldsGroupToIdTransformer.php b/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/CustomFieldsGroupToIdTransformer.php index 5cba21068..2364a8087 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/CustomFieldsGroupToIdTransformer.php +++ b/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/CustomFieldsGroupToIdTransformer.php @@ -20,7 +20,7 @@ use function gettype; class CustomFieldsGroupToIdTransformer implements DataTransformerInterface { - public function __construct(private ObjectManager $om) + public function __construct(private readonly ObjectManager $om) { } diff --git a/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/JsonCustomFieldToArrayTransformer.php b/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/JsonCustomFieldToArrayTransformer.php index 1ac3ace19..2827c0a73 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/JsonCustomFieldToArrayTransformer.php +++ b/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/JsonCustomFieldToArrayTransformer.php @@ -24,9 +24,9 @@ use const JSON_THROW_ON_ERROR; */ class JsonCustomFieldToArrayTransformer implements DataTransformerInterface { - private array $customField; + private readonly array $customField; - public function __construct(private ObjectManager $om) + public function __construct(private readonly ObjectManager $om) { $customFields = $this->om ->getRepository(CustomField::class) @@ -68,13 +68,13 @@ class JsonCustomFieldToArrayTransformer implements DataTransformerInterface if (array_key_exists($key, $this->customField)) { $type = $this->customField[$key]->getType(); - if (str_starts_with($type, 'ManyToOne')) { + if (str_starts_with((string) $type, 'ManyToOne')) { // pour le manytoone() faire // un update du form en js ? : http://symfony.com/fr/doc/current/cookbook/form/form_collections.html // //$entityClass = substr($type, 10, -1); //echo $entityClasss; - if (str_starts_with($type, 'ManyToOnePersist')) { + if (str_starts_with((string) $type, 'ManyToOnePersist')) { // PEUT ETRE A FAIRE SI SEULEMENT $value->getId() ne renvoie rien... // // @@ -112,7 +112,7 @@ class JsonCustomFieldToArrayTransformer implements DataTransformerInterface if (null === $customFieldsJSON) { $customFieldsArray = []; } else { - $customFieldsArray = json_decode($customFieldsJSON, true, 512, JSON_THROW_ON_ERROR); + $customFieldsArray = json_decode((string) $customFieldsJSON, true, 512, JSON_THROW_ON_ERROR); } $customFieldsArrayRet = []; @@ -123,11 +123,11 @@ class JsonCustomFieldToArrayTransformer implements DataTransformerInterface if (array_key_exists($key, $this->customField)) { $type = $this->customField[$key]->getType(); - if (str_starts_with($type, 'ManyToOne')) { - if (str_starts_with($type, 'ManyToOnePersist')) { - $entityClass = substr($type, 17, -1); + if (str_starts_with((string) $type, 'ManyToOne')) { + if (str_starts_with((string) $type, 'ManyToOnePersist')) { + $entityClass = substr((string) $type, 17, -1); } else { - $entityClass = substr($type, 10, -1); + $entityClass = substr((string) $type, 10, -1); } $customFieldsArrayRet[$key] = $this->om diff --git a/src/Bundle/ChillCustomFieldsBundle/Form/Type/CustomFieldType.php b/src/Bundle/ChillCustomFieldsBundle/Form/Type/CustomFieldType.php index 93e969e1f..e9da23858 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Form/Type/CustomFieldType.php +++ b/src/Bundle/ChillCustomFieldsBundle/Form/Type/CustomFieldType.php @@ -24,7 +24,7 @@ class CustomFieldType extends AbstractType */ private $customFieldCompiler; - public function __construct(private ObjectManager $om, CustomFieldProvider $compiler) + public function __construct(private readonly ObjectManager $om, CustomFieldProvider $compiler) { $this->customFieldCompiler = $compiler; } diff --git a/src/Bundle/ChillCustomFieldsBundle/Form/Type/LinkedCustomFieldsType.php b/src/Bundle/ChillCustomFieldsBundle/Form/Type/LinkedCustomFieldsType.php index 5f87bbab0..bd75e58b4 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Form/Type/LinkedCustomFieldsType.php +++ b/src/Bundle/ChillCustomFieldsBundle/Form/Type/LinkedCustomFieldsType.php @@ -46,7 +46,7 @@ class LinkedCustomFieldsType extends AbstractType */ private $options = []; - public function __construct(private TranslatableStringHelper $translatableStringHelper) + public function __construct(private readonly TranslatableStringHelper $translatableStringHelper) { } @@ -93,7 +93,7 @@ class LinkedCustomFieldsType extends AbstractType $builder->addEventListener( FormEvents::POST_SET_DATA, - [$this, 'appendChoice'] + $this->appendChoice(...) ); } diff --git a/src/Bundle/ChillCustomFieldsBundle/Service/CustomFieldsHelper.php b/src/Bundle/ChillCustomFieldsBundle/Service/CustomFieldsHelper.php index be26cd6f3..c0bee2301 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Service/CustomFieldsHelper.php +++ b/src/Bundle/ChillCustomFieldsBundle/Service/CustomFieldsHelper.php @@ -29,7 +29,7 @@ class CustomFieldsHelper * @param CustomFieldProvider $provider The customfield provider that * contains all the declared custom fields */ - public function __construct(private EntityManagerInterface $em, private CustomFieldProvider $provider) + public function __construct(private readonly EntityManagerInterface $em, private readonly CustomFieldProvider $provider) { } diff --git a/src/Bundle/ChillCustomFieldsBundle/Templating/Twig/CustomFieldRenderingTwig.php b/src/Bundle/ChillCustomFieldsBundle/Templating/Twig/CustomFieldRenderingTwig.php index 021999b1d..a7949de25 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Templating/Twig/CustomFieldRenderingTwig.php +++ b/src/Bundle/ChillCustomFieldsBundle/Templating/Twig/CustomFieldRenderingTwig.php @@ -38,7 +38,7 @@ class CustomFieldRenderingTwig extends AbstractExtension implements ContainerAwa 'label_layout' => 'ChillCustomFieldsBundle:CustomField:render_label.html.twig', ]; - public function __construct(private CustomFieldsHelper $customFieldsHelper) + public function __construct(private readonly CustomFieldsHelper $customFieldsHelper) { } @@ -50,26 +50,17 @@ class CustomFieldRenderingTwig extends AbstractExtension implements ContainerAwa public function getFunctions() { return [ - new TwigFunction('chill_custom_field_widget', [ - $this, - 'renderWidget', - ], [ + new TwigFunction('chill_custom_field_widget', $this->renderWidget(...), [ 'is_safe' => [ 'html', ], ]), - new TwigFunction('chill_custom_field_label', [ - $this, - 'renderLabel', - ], [ + new TwigFunction('chill_custom_field_label', $this->renderLabel(...), [ 'is_safe' => [ 'html', ], ]), - new TwigFunction('chill_custom_field_is_empty', [ - $this, - 'isEmptyValue', - ]), + new TwigFunction('chill_custom_field_is_empty', $this->isEmptyValue(...)), ]; } diff --git a/src/Bundle/ChillCustomFieldsBundle/Templating/Twig/CustomFieldsGroupRenderingTwig.php b/src/Bundle/ChillCustomFieldsBundle/Templating/Twig/CustomFieldsGroupRenderingTwig.php index 1291f0849..cf6a55604 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Templating/Twig/CustomFieldsGroupRenderingTwig.php +++ b/src/Bundle/ChillCustomFieldsBundle/Templating/Twig/CustomFieldsGroupRenderingTwig.php @@ -53,10 +53,7 @@ class CustomFieldsGroupRenderingTwig extends AbstractExtension implements Contai public function getFunctions() { return [ - new TwigFunction('chill_custom_fields_group_widget', [ - $this, - 'renderWidget', - ], [ + new TwigFunction('chill_custom_fields_group_widget', $this->renderWidget(...), [ 'is_safe' => [ 'html', ], diff --git a/src/Bundle/ChillDocGeneratorBundle/Context/ContextManager.php b/src/Bundle/ChillDocGeneratorBundle/Context/ContextManager.php index 2e2c9a9fd..95419e001 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Context/ContextManager.php +++ b/src/Bundle/ChillDocGeneratorBundle/Context/ContextManager.php @@ -14,7 +14,7 @@ namespace Chill\DocGeneratorBundle\Context; use Chill\DocGeneratorBundle\Context\Exception\ContextNotFoundException; use Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate; -final class ContextManager implements ContextManagerInterface +final readonly class ContextManager implements ContextManagerInterface { /** * @param \Chill\DocGeneratorBundle\Context\DocGeneratorContextInterface[] $contexts diff --git a/src/Bundle/ChillDocGeneratorBundle/Controller/AdminDocGeneratorTemplateController.php b/src/Bundle/ChillDocGeneratorBundle/Controller/AdminDocGeneratorTemplateController.php index 58c2b4e57..ebce55957 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Controller/AdminDocGeneratorTemplateController.php +++ b/src/Bundle/ChillDocGeneratorBundle/Controller/AdminDocGeneratorTemplateController.php @@ -22,7 +22,7 @@ use Symfony\Component\Routing\Annotation\Route; class AdminDocGeneratorTemplateController extends CRUDController { - public function __construct(private ContextManager $contextManager) + public function __construct(private readonly ContextManager $contextManager) { } diff --git a/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php b/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php index 7ad660260..a007ff8ff 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php +++ b/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php @@ -43,7 +43,7 @@ use const JSON_PRETTY_PRINT; final class DocGeneratorTemplateController extends AbstractController { - public function __construct(private ContextManager $contextManager, private DocGeneratorTemplateRepository $docGeneratorTemplateRepository, private GeneratorInterface $generator, private MessageBusInterface $messageBus, private PaginatorFactory $paginatorFactory, private EntityManagerInterface $entityManager) + public function __construct(private readonly ContextManager $contextManager, private readonly DocGeneratorTemplateRepository $docGeneratorTemplateRepository, private readonly GeneratorInterface $generator, private readonly MessageBusInterface $messageBus, private readonly PaginatorFactory $paginatorFactory, private readonly EntityManagerInterface $entityManager) { } diff --git a/src/Bundle/ChillDocGeneratorBundle/Form/DocGeneratorTemplateType.php b/src/Bundle/ChillDocGeneratorBundle/Form/DocGeneratorTemplateType.php index a92dc67f2..8f698cb97 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Form/DocGeneratorTemplateType.php +++ b/src/Bundle/ChillDocGeneratorBundle/Form/DocGeneratorTemplateType.php @@ -24,7 +24,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver; class DocGeneratorTemplateType extends AbstractType { - public function __construct(private ContextManager $contextManager) + public function __construct(private readonly ContextManager $contextManager) { } diff --git a/src/Bundle/ChillDocGeneratorBundle/GeneratorDriver/Exception/TemplateException.php b/src/Bundle/ChillDocGeneratorBundle/GeneratorDriver/Exception/TemplateException.php index 90de02914..5e7227a00 100644 --- a/src/Bundle/ChillDocGeneratorBundle/GeneratorDriver/Exception/TemplateException.php +++ b/src/Bundle/ChillDocGeneratorBundle/GeneratorDriver/Exception/TemplateException.php @@ -20,7 +20,7 @@ use Throwable; */ class TemplateException extends RuntimeException { - public function __construct(private array $errors, $code = 0, ?Throwable $previous = null) + public function __construct(private readonly array $errors, $code = 0, ?Throwable $previous = null) { parent::__construct('Error while generating document from template', $code, $previous); } diff --git a/src/Bundle/ChillDocGeneratorBundle/GeneratorDriver/RelatorioDriver.php b/src/Bundle/ChillDocGeneratorBundle/GeneratorDriver/RelatorioDriver.php index 2166032e1..7dd1dccf0 100644 --- a/src/Bundle/ChillDocGeneratorBundle/GeneratorDriver/RelatorioDriver.php +++ b/src/Bundle/ChillDocGeneratorBundle/GeneratorDriver/RelatorioDriver.php @@ -24,12 +24,12 @@ use Throwable; final class RelatorioDriver implements DriverInterface { - private string $url; + private readonly string $url; public function __construct( - private HttpClientInterface $client, + private readonly HttpClientInterface $client, ParameterBagInterface $parameterBag, - private LoggerInterface $logger + private readonly LoggerInterface $logger ) { $this->url = $parameterBag->get('chill_doc_generator')['driver']['relatorio']['url']; } diff --git a/src/Bundle/ChillDocGeneratorBundle/Menu/AdminMenuBuilder.php b/src/Bundle/ChillDocGeneratorBundle/Menu/AdminMenuBuilder.php index 6f048ae66..a021e1495 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Menu/AdminMenuBuilder.php +++ b/src/Bundle/ChillDocGeneratorBundle/Menu/AdminMenuBuilder.php @@ -18,7 +18,7 @@ use Symfony\Contracts\Translation\TranslatorInterface; class AdminMenuBuilder implements LocalMenuBuilderInterface { - public function __construct(private TranslatorInterface $translator, private Security $security) + public function __construct(private readonly TranslatorInterface $translator, private readonly Security $security) { } diff --git a/src/Bundle/ChillDocGeneratorBundle/Repository/DocGeneratorTemplateRepository.php b/src/Bundle/ChillDocGeneratorBundle/Repository/DocGeneratorTemplateRepository.php index 850f9a862..0f2771b4e 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Repository/DocGeneratorTemplateRepository.php +++ b/src/Bundle/ChillDocGeneratorBundle/Repository/DocGeneratorTemplateRepository.php @@ -19,9 +19,9 @@ use Symfony\Component\HttpFoundation\RequestStack; final class DocGeneratorTemplateRepository implements ObjectRepository { - private EntityRepository $repository; + private readonly EntityRepository $repository; - public function __construct(EntityManagerInterface $entityManager, private RequestStack $requestStack) + public function __construct(EntityManagerInterface $entityManager, private readonly RequestStack $requestStack) { $this->repository = $entityManager->getRepository(DocGeneratorTemplate::class); } diff --git a/src/Bundle/ChillDocGeneratorBundle/Serializer/Helper/NormalizeNullValueHelper.php b/src/Bundle/ChillDocGeneratorBundle/Serializer/Helper/NormalizeNullValueHelper.php index f35736635..0b898d59c 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Serializer/Helper/NormalizeNullValueHelper.php +++ b/src/Bundle/ChillDocGeneratorBundle/Serializer/Helper/NormalizeNullValueHelper.php @@ -19,7 +19,7 @@ use function is_array; class NormalizeNullValueHelper { - public function __construct(private NormalizerInterface $normalizer, private ?string $discriminatorType = null, private ?string $discriminatorValue = null) + public function __construct(private readonly NormalizerInterface $normalizer, private ?string $discriminatorType = null, private readonly ?string $discriminatorValue = null) { } diff --git a/src/Bundle/ChillDocGeneratorBundle/Serializer/Normalizer/DocGenObjectNormalizer.php b/src/Bundle/ChillDocGeneratorBundle/Serializer/Normalizer/DocGenObjectNormalizer.php index bda1fda5c..ef02e0073 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Serializer/Normalizer/DocGenObjectNormalizer.php +++ b/src/Bundle/ChillDocGeneratorBundle/Serializer/Normalizer/DocGenObjectNormalizer.php @@ -40,11 +40,11 @@ class DocGenObjectNormalizer implements NormalizerAwareInterface, NormalizerInte { use NormalizerAwareTrait; - private PropertyAccessor $propertyAccess; + private readonly PropertyAccessor $propertyAccess; public function __construct( - private ClassMetadataFactoryInterface $classMetadataFactory, - private TranslatableStringHelperInterface $translatableStringHelper + private readonly ClassMetadataFactoryInterface $classMetadataFactory, + private readonly TranslatableStringHelperInterface $translatableStringHelper ) { $this->propertyAccess = PropertyAccess::createPropertyAccessor(); } diff --git a/src/Bundle/ChillDocGeneratorBundle/Service/Context/BaseContextData.php b/src/Bundle/ChillDocGeneratorBundle/Service/Context/BaseContextData.php index ad546a97f..afe53c6f9 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Service/Context/BaseContextData.php +++ b/src/Bundle/ChillDocGeneratorBundle/Service/Context/BaseContextData.php @@ -19,7 +19,7 @@ use Symfony\Component\Serializer\Normalizer\NormalizerInterface; class BaseContextData { - public function __construct(private NormalizerInterface $normalizer) + public function __construct(private readonly NormalizerInterface $normalizer) { } diff --git a/src/Bundle/ChillDocGeneratorBundle/Service/Generator/Generator.php b/src/Bundle/ChillDocGeneratorBundle/Service/Generator/Generator.php index 66136639f..2d5108b74 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Service/Generator/Generator.php +++ b/src/Bundle/ChillDocGeneratorBundle/Service/Generator/Generator.php @@ -27,7 +27,7 @@ class Generator implements GeneratorInterface { private const LOG_PREFIX = '[docgen generator] '; - public function __construct(private ContextManagerInterface $contextManager, private DriverInterface $driver, private EntityManagerInterface $entityManager, private LoggerInterface $logger, private StoredObjectManagerInterface $storedObjectManager) + public function __construct(private readonly ContextManagerInterface $contextManager, private readonly DriverInterface $driver, private readonly EntityManagerInterface $entityManager, private readonly LoggerInterface $logger, private readonly StoredObjectManagerInterface $storedObjectManager) { } diff --git a/src/Bundle/ChillDocGeneratorBundle/Service/Generator/GeneratorException.php b/src/Bundle/ChillDocGeneratorBundle/Service/Generator/GeneratorException.php index 9024db235..abed586af 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Service/Generator/GeneratorException.php +++ b/src/Bundle/ChillDocGeneratorBundle/Service/Generator/GeneratorException.php @@ -19,7 +19,7 @@ class GeneratorException extends RuntimeException /** * @param string[] $errors */ - public function __construct(private array $errors = [], ?Throwable $previous = null) + public function __construct(private readonly array $errors = [], ?Throwable $previous = null) { parent::__construct( 'Could not generate the document', diff --git a/src/Bundle/ChillDocGeneratorBundle/Service/Messenger/OnGenerationFails.php b/src/Bundle/ChillDocGeneratorBundle/Service/Messenger/OnGenerationFails.php index 7ea3a1dc7..06d396af2 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Service/Messenger/OnGenerationFails.php +++ b/src/Bundle/ChillDocGeneratorBundle/Service/Messenger/OnGenerationFails.php @@ -24,7 +24,7 @@ use Symfony\Component\Mailer\MailerInterface; use Symfony\Component\Messenger\Event\WorkerMessageFailedEvent; use Symfony\Contracts\Translation\TranslatorInterface; -final class OnGenerationFails implements EventSubscriberInterface +final readonly class OnGenerationFails implements EventSubscriberInterface { public const LOG_PREFIX = '[docgen failed] '; diff --git a/src/Bundle/ChillDocGeneratorBundle/Service/Messenger/RequestGenerationHandler.php b/src/Bundle/ChillDocGeneratorBundle/Service/Messenger/RequestGenerationHandler.php index 99f0854cd..e0f95834b 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Service/Messenger/RequestGenerationHandler.php +++ b/src/Bundle/ChillDocGeneratorBundle/Service/Messenger/RequestGenerationHandler.php @@ -26,11 +26,11 @@ use Symfony\Component\Messenger\Handler\MessageHandlerInterface; */ class RequestGenerationHandler implements MessageHandlerInterface { - public const AUTHORIZED_TRIALS = 5; + final public const AUTHORIZED_TRIALS = 5; private const LOG_PREFIX = '[docgen message handler] '; - public function __construct(private DocGeneratorTemplateRepository $docGeneratorTemplateRepository, private EntityManagerInterface $entityManager, private Generator $generator, private LoggerInterface $logger, private StoredObjectRepository $storedObjectRepository, private UserRepositoryInterface $userRepository) + public function __construct(private readonly DocGeneratorTemplateRepository $docGeneratorTemplateRepository, private readonly EntityManagerInterface $entityManager, private readonly Generator $generator, private readonly LoggerInterface $logger, private readonly StoredObjectRepository $storedObjectRepository, private readonly UserRepositoryInterface $userRepository) { } diff --git a/src/Bundle/ChillDocGeneratorBundle/Service/Messenger/RequestGenerationMessage.php b/src/Bundle/ChillDocGeneratorBundle/Service/Messenger/RequestGenerationMessage.php index 0bc0ec850..092073817 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Service/Messenger/RequestGenerationMessage.php +++ b/src/Bundle/ChillDocGeneratorBundle/Service/Messenger/RequestGenerationMessage.php @@ -17,20 +17,20 @@ use Chill\MainBundle\Entity\User; class RequestGenerationMessage { - private int $creatorId; + private readonly int $creatorId; - private int $templateId; + private readonly int $templateId; - private int $destinationStoredObjectId; + private readonly int $destinationStoredObjectId; - private \DateTimeImmutable $createdAt; + private readonly \DateTimeImmutable $createdAt; public function __construct( User $creator, DocGeneratorTemplate $template, - private int $entityId, + private readonly int $entityId, StoredObject $destinationStoredObject, - private array $contextGenerationData + private readonly array $contextGenerationData ) { $this->creatorId = $creator->getId(); $this->templateId = $template->getId(); diff --git a/src/Bundle/ChillDocGeneratorBundle/tests/Serializer/Normalizer/DocGenObjectNormalizerTest.php b/src/Bundle/ChillDocGeneratorBundle/tests/Serializer/Normalizer/DocGenObjectNormalizerTest.php index 3250d4d5a..4ea289a8c 100644 --- a/src/Bundle/ChillDocGeneratorBundle/tests/Serializer/Normalizer/DocGenObjectNormalizerTest.php +++ b/src/Bundle/ChillDocGeneratorBundle/tests/Serializer/Normalizer/DocGenObjectNormalizerTest.php @@ -135,7 +135,7 @@ final class DocGenObjectNormalizerTest extends KernelTestCase $this->assertEquals($expected, $actual, 'test normalization for a null scope'); } - public function testNormalizeNullObjectWithObjectEmbedded() + public function testNormalizeNullObjectWithObjectEmbedded(): never { $this->markTestIncomplete('test to implement'); $normalized = $this->normalizer->normalize(null, 'docgen', [ @@ -154,7 +154,7 @@ final class DocGenObjectNormalizerTest extends KernelTestCase $this->assertEquals($expected, $normalized, 'test normalization for a null user'); } - public function testNormalizeWithNullValueEmbedded() + public function testNormalizeWithNullValueEmbedded(): never { $this->markTestIncomplete('test to write'); $user = new User(); diff --git a/src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseController.php b/src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseController.php index 2c70454b0..0a3a56fdf 100644 --- a/src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseController.php +++ b/src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseController.php @@ -36,7 +36,7 @@ class DocumentAccompanyingCourseController extends AbstractController /** * DocumentAccompanyingCourseController constructor. */ - public function __construct(protected TranslatorInterface $translator, protected EventDispatcherInterface $eventDispatcher, protected AuthorizationHelper $authorizationHelper, private PaginatorFactory $paginatorFactory, private AccompanyingCourseDocumentRepository $courseRepository) + public function __construct(protected TranslatorInterface $translator, protected EventDispatcherInterface $eventDispatcher, protected AuthorizationHelper $authorizationHelper, private readonly PaginatorFactory $paginatorFactory, private readonly AccompanyingCourseDocumentRepository $courseRepository) { } diff --git a/src/Bundle/ChillDocStoreBundle/Controller/DocumentPersonController.php b/src/Bundle/ChillDocStoreBundle/Controller/DocumentPersonController.php index 79fb401ea..469e5bf7e 100644 --- a/src/Bundle/ChillDocStoreBundle/Controller/DocumentPersonController.php +++ b/src/Bundle/ChillDocStoreBundle/Controller/DocumentPersonController.php @@ -42,7 +42,7 @@ class DocumentPersonController extends AbstractController /** * DocumentPersonController constructor. */ - public function __construct(protected TranslatorInterface $translator, protected EventDispatcherInterface $eventDispatcher, protected AuthorizationHelper $authorizationHelper, private PaginatorFactory $paginatorFactory, private PersonDocumentACLAwareRepositoryInterface $personDocumentACLAwareRepository) + public function __construct(protected TranslatorInterface $translator, protected EventDispatcherInterface $eventDispatcher, protected AuthorizationHelper $authorizationHelper, private readonly PaginatorFactory $paginatorFactory, private readonly PersonDocumentACLAwareRepositoryInterface $personDocumentACLAwareRepository) { } diff --git a/src/Bundle/ChillDocStoreBundle/Controller/StoredObjectApiController.php b/src/Bundle/ChillDocStoreBundle/Controller/StoredObjectApiController.php index b675d6246..6bfb05bfc 100644 --- a/src/Bundle/ChillDocStoreBundle/Controller/StoredObjectApiController.php +++ b/src/Bundle/ChillDocStoreBundle/Controller/StoredObjectApiController.php @@ -20,7 +20,7 @@ use Symfony\Component\Security\Core\Security; class StoredObjectApiController { - public function __construct(private Security $security) + public function __construct(private readonly Security $security) { } diff --git a/src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php b/src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php index fbfd4ef54..bf2808c19 100644 --- a/src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php +++ b/src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php @@ -36,9 +36,9 @@ use Symfony\Component\Serializer\Annotation as Serializer; class StoredObject implements AsyncFileInterface, Document, TrackCreationInterface { use TrackCreationTrait; - public const STATUS_READY = "ready"; - public const STATUS_PENDING = "pending"; - public const STATUS_FAILURE = "failure"; + final public const STATUS_READY = "ready"; + final public const STATUS_PENDING = "pending"; + final public const STATUS_FAILURE = "failure"; /** * @ORM\Column(type="json", name="datas") diff --git a/src/Bundle/ChillDocStoreBundle/Form/DocumentCategoryType.php b/src/Bundle/ChillDocStoreBundle/Form/DocumentCategoryType.php index 8ae67be51..f3506d631 100644 --- a/src/Bundle/ChillDocStoreBundle/Form/DocumentCategoryType.php +++ b/src/Bundle/ChillDocStoreBundle/Form/DocumentCategoryType.php @@ -26,7 +26,7 @@ class DocumentCategoryType extends AbstractType { // TODO faire un service dans CHillMain foreach ($kernelBundles as $key => $value) { - if (str_starts_with($key, 'Chill')) { + if (str_starts_with((string) $key, 'Chill')) { $this->chillBundlesFlipped[$value] = $key; } } diff --git a/src/Bundle/ChillDocStoreBundle/Form/PersonDocumentType.php b/src/Bundle/ChillDocStoreBundle/Form/PersonDocumentType.php index cfe5d5156..5c0b7d501 100644 --- a/src/Bundle/ChillDocStoreBundle/Form/PersonDocumentType.php +++ b/src/Bundle/ChillDocStoreBundle/Form/PersonDocumentType.php @@ -30,7 +30,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver; class PersonDocumentType extends AbstractType { - public function __construct(private TranslatableStringHelperInterface $translatableStringHelper, private ScopeResolverDispatcher $scopeResolverDispatcher, private ParameterBagInterface $parameterBag, private CenterResolverDispatcher $centerResolverDispatcher) + public function __construct(private readonly TranslatableStringHelperInterface $translatableStringHelper, private readonly ScopeResolverDispatcher $scopeResolverDispatcher, private readonly ParameterBagInterface $parameterBag, private readonly CenterResolverDispatcher $centerResolverDispatcher) { } diff --git a/src/Bundle/ChillDocStoreBundle/Form/StoredObjectType.php b/src/Bundle/ChillDocStoreBundle/Form/StoredObjectType.php index 4f3cd315f..c153efae5 100644 --- a/src/Bundle/ChillDocStoreBundle/Form/StoredObjectType.php +++ b/src/Bundle/ChillDocStoreBundle/Form/StoredObjectType.php @@ -57,20 +57,20 @@ class StoredObjectType extends AbstractType $builder ->get('keyInfos') ->addModelTransformer(new CallbackTransformer( - [$this, 'transform'], - [$this, 'reverseTransform'] + $this->transform(...), + $this->reverseTransform(...) )); $builder ->get('iv') ->addModelTransformer(new CallbackTransformer( - [$this, 'transform'], - [$this, 'reverseTransform'] + $this->transform(...), + $this->reverseTransform(...) )); $builder ->addModelTransformer(new CallbackTransformer( - [$this, 'transformObject'], - [$this, 'reverseTransformObject'] + $this->transformObject(...), + $this->reverseTransformObject(...) )); } @@ -95,7 +95,7 @@ class StoredObjectType extends AbstractType return null; } - return json_decode($value, true, 512, JSON_THROW_ON_ERROR); + return json_decode((string) $value, true, 512, JSON_THROW_ON_ERROR); } public function reverseTransformObject($object) diff --git a/src/Bundle/ChillDocStoreBundle/Menu/MenuBuilder.php b/src/Bundle/ChillDocStoreBundle/Menu/MenuBuilder.php index 49f7723ce..1f9268bf1 100644 --- a/src/Bundle/ChillDocStoreBundle/Menu/MenuBuilder.php +++ b/src/Bundle/ChillDocStoreBundle/Menu/MenuBuilder.php @@ -19,7 +19,7 @@ use LogicException; use Symfony\Component\Security\Core\Security; use Symfony\Contracts\Translation\TranslatorInterface; -final class MenuBuilder implements LocalMenuBuilderInterface +final readonly class MenuBuilder implements LocalMenuBuilderInterface { public function __construct(private Security $security, private TranslatorInterface $translator) { diff --git a/src/Bundle/ChillDocStoreBundle/Repository/AccompanyingCourseDocumentRepository.php b/src/Bundle/ChillDocStoreBundle/Repository/AccompanyingCourseDocumentRepository.php index 3231bfd79..2679993c4 100644 --- a/src/Bundle/ChillDocStoreBundle/Repository/AccompanyingCourseDocumentRepository.php +++ b/src/Bundle/ChillDocStoreBundle/Repository/AccompanyingCourseDocumentRepository.php @@ -20,9 +20,9 @@ use Doctrine\Persistence\ObjectRepository; class AccompanyingCourseDocumentRepository implements ObjectRepository { - private EntityRepository $repository; + private readonly EntityRepository $repository; - public function __construct(private EntityManagerInterface $em) + public function __construct(private readonly EntityManagerInterface $em) { $this->repository = $em->getRepository(AccompanyingCourseDocument::class); } diff --git a/src/Bundle/ChillDocStoreBundle/Repository/DocumentCategoryRepository.php b/src/Bundle/ChillDocStoreBundle/Repository/DocumentCategoryRepository.php index 9025afd09..22aeb24d2 100644 --- a/src/Bundle/ChillDocStoreBundle/Repository/DocumentCategoryRepository.php +++ b/src/Bundle/ChillDocStoreBundle/Repository/DocumentCategoryRepository.php @@ -21,9 +21,9 @@ use Doctrine\Persistence\ObjectRepository; */ class DocumentCategoryRepository implements ObjectRepository { - private EntityRepository $repository; + private readonly EntityRepository $repository; - public function __construct(private EntityManagerInterface $em) + public function __construct(private readonly EntityManagerInterface $em) { $this->repository = $em->getRepository(DocumentCategory::class); } diff --git a/src/Bundle/ChillDocStoreBundle/Repository/PersonDocumentACLAwareRepository.php b/src/Bundle/ChillDocStoreBundle/Repository/PersonDocumentACLAwareRepository.php index da1809dbb..128a552a8 100644 --- a/src/Bundle/ChillDocStoreBundle/Repository/PersonDocumentACLAwareRepository.php +++ b/src/Bundle/ChillDocStoreBundle/Repository/PersonDocumentACLAwareRepository.php @@ -22,7 +22,7 @@ use Symfony\Component\Security\Core\Security; class PersonDocumentACLAwareRepository implements PersonDocumentACLAwareRepositoryInterface { - public function __construct(private EntityManagerInterface $em, private AuthorizationHelperInterface $authorizationHelper, private CenterResolverDispatcher $centerResolverDispatcher, private Security $security) + public function __construct(private readonly EntityManagerInterface $em, private readonly AuthorizationHelperInterface $authorizationHelper, private readonly CenterResolverDispatcher $centerResolverDispatcher, private readonly Security $security) { } diff --git a/src/Bundle/ChillDocStoreBundle/Repository/StoredObjectRepository.php b/src/Bundle/ChillDocStoreBundle/Repository/StoredObjectRepository.php index 82e658620..d2e715f7e 100644 --- a/src/Bundle/ChillDocStoreBundle/Repository/StoredObjectRepository.php +++ b/src/Bundle/ChillDocStoreBundle/Repository/StoredObjectRepository.php @@ -18,7 +18,7 @@ use Doctrine\Persistence\ObjectRepository; final class StoredObjectRepository implements ObjectRepository { - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct(EntityManagerInterface $entityManager) { diff --git a/src/Bundle/ChillDocStoreBundle/Security/Authorization/AccompanyingCourseDocumentVoter.php b/src/Bundle/ChillDocStoreBundle/Security/Authorization/AccompanyingCourseDocumentVoter.php index 60bc7060c..f04a6dbf8 100644 --- a/src/Bundle/ChillDocStoreBundle/Security/Authorization/AccompanyingCourseDocumentVoter.php +++ b/src/Bundle/ChillDocStoreBundle/Security/Authorization/AccompanyingCourseDocumentVoter.php @@ -27,15 +27,15 @@ use function in_array; class AccompanyingCourseDocumentVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface { - public const CREATE = 'CHILL_ACCOMPANYING_COURSE_DOCUMENT_CREATE'; + final public const CREATE = 'CHILL_ACCOMPANYING_COURSE_DOCUMENT_CREATE'; - public const DELETE = 'CHILL_ACCOMPANYING_COURSE_DOCUMENT_DELETE'; + final public const DELETE = 'CHILL_ACCOMPANYING_COURSE_DOCUMENT_DELETE'; - public const SEE = 'CHILL_ACCOMPANYING_COURSE_DOCUMENT_SEE'; + final public const SEE = 'CHILL_ACCOMPANYING_COURSE_DOCUMENT_SEE'; - public const SEE_DETAILS = 'CHILL_ACCOMPANYING_COURSE_DOCUMENT_SEE_DETAILS'; + final public const SEE_DETAILS = 'CHILL_ACCOMPANYING_COURSE_DOCUMENT_SEE_DETAILS'; - public const UPDATE = 'CHILL_ACCOMPANYING_COURSE_DOCUMENT_UPDATE'; + final public const UPDATE = 'CHILL_ACCOMPANYING_COURSE_DOCUMENT_UPDATE'; protected VoterHelperInterface $voterHelper; diff --git a/src/Bundle/ChillDocStoreBundle/Security/Authorization/PersonDocumentVoter.php b/src/Bundle/ChillDocStoreBundle/Security/Authorization/PersonDocumentVoter.php index b4a5de4c5..c1c6b1211 100644 --- a/src/Bundle/ChillDocStoreBundle/Security/Authorization/PersonDocumentVoter.php +++ b/src/Bundle/ChillDocStoreBundle/Security/Authorization/PersonDocumentVoter.php @@ -25,15 +25,15 @@ use Symfony\Component\Security\Core\Security; class PersonDocumentVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface { - public const CREATE = 'CHILL_PERSON_DOCUMENT_CREATE'; + final public const CREATE = 'CHILL_PERSON_DOCUMENT_CREATE'; - public const DELETE = 'CHILL_PERSON_DOCUMENT_DELETE'; + final public const DELETE = 'CHILL_PERSON_DOCUMENT_DELETE'; - public const SEE = 'CHILL_PERSON_DOCUMENT_SEE'; + final public const SEE = 'CHILL_PERSON_DOCUMENT_SEE'; - public const SEE_DETAILS = 'CHILL_PERSON_DOCUMENT_SEE_DETAILS'; + final public const SEE_DETAILS = 'CHILL_PERSON_DOCUMENT_SEE_DETAILS'; - public const UPDATE = 'CHILL_PERSON_DOCUMENT_UPDATE'; + final public const UPDATE = 'CHILL_PERSON_DOCUMENT_UPDATE'; protected VoterHelperInterface $voterHelper; diff --git a/src/Bundle/ChillDocStoreBundle/Serializer/Normalizer/StoredObjectDenormalizer.php b/src/Bundle/ChillDocStoreBundle/Serializer/Normalizer/StoredObjectDenormalizer.php index d277c7ec9..822a70597 100644 --- a/src/Bundle/ChillDocStoreBundle/Serializer/Normalizer/StoredObjectDenormalizer.php +++ b/src/Bundle/ChillDocStoreBundle/Serializer/Normalizer/StoredObjectDenormalizer.php @@ -22,7 +22,7 @@ class StoredObjectDenormalizer implements DenormalizerInterface { use ObjectToPopulateTrait; - public function __construct(private StoredObjectRepository $storedObjectRepository) + public function __construct(private readonly StoredObjectRepository $storedObjectRepository) { } diff --git a/src/Bundle/ChillDocStoreBundle/Service/StoredObjectManager.php b/src/Bundle/ChillDocStoreBundle/Service/StoredObjectManager.php index 5e7a54410..56c1e0d9f 100644 --- a/src/Bundle/ChillDocStoreBundle/Service/StoredObjectManager.php +++ b/src/Bundle/ChillDocStoreBundle/Service/StoredObjectManager.php @@ -35,7 +35,7 @@ final class StoredObjectManager implements StoredObjectManagerInterface private array $inMemory = []; - public function __construct(private HttpClientInterface $client, private TempUrlGeneratorInterface $tempUrlGenerator) + public function __construct(private readonly HttpClientInterface $client, private readonly TempUrlGeneratorInterface $tempUrlGenerator) { } diff --git a/src/Bundle/ChillDocStoreBundle/Templating/WopiEditTwigExtensionRuntime.php b/src/Bundle/ChillDocStoreBundle/Templating/WopiEditTwigExtensionRuntime.php index 89655fc35..ad491674d 100644 --- a/src/Bundle/ChillDocStoreBundle/Templating/WopiEditTwigExtensionRuntime.php +++ b/src/Bundle/ChillDocStoreBundle/Templating/WopiEditTwigExtensionRuntime.php @@ -20,7 +20,7 @@ use Twig\Extension\RuntimeExtensionInterface; use function in_array; -final class WopiEditTwigExtensionRuntime implements RuntimeExtensionInterface +final readonly class WopiEditTwigExtensionRuntime implements RuntimeExtensionInterface { public const SUPPORTED_MIMES = [ 'image/svg+xml', @@ -151,7 +151,7 @@ final class WopiEditTwigExtensionRuntime implements RuntimeExtensionInterface 'document_json' => $this->normalizer->normalize($document, 'json', [AbstractNormalizer::GROUPS => ['read']]), 'title' => $title, 'can_edit' => $canEdit, - 'options' => array_merge(self::DEFAULT_OPTIONS_TEMPLATE_BUTTON_GROUP, $options), + 'options' => [...self::DEFAULT_OPTIONS_TEMPLATE_BUTTON_GROUP, ...$options], ]); } diff --git a/src/Bundle/ChillDocStoreBundle/Workflow/AccompanyingCourseDocumentWorkflowHandler.php b/src/Bundle/ChillDocStoreBundle/Workflow/AccompanyingCourseDocumentWorkflowHandler.php index 5a7ce406c..328585c62 100644 --- a/src/Bundle/ChillDocStoreBundle/Workflow/AccompanyingCourseDocumentWorkflowHandler.php +++ b/src/Bundle/ChillDocStoreBundle/Workflow/AccompanyingCourseDocumentWorkflowHandler.php @@ -22,14 +22,14 @@ use Symfony\Contracts\Translation\TranslatorInterface; class AccompanyingCourseDocumentWorkflowHandler implements EntityWorkflowHandlerInterface { - private EntityRepository $repository; + private readonly EntityRepository $repository; /** * TODO: injecter le repository directement. */ public function __construct( EntityManagerInterface $em, - private TranslatorInterface $translator + private readonly TranslatorInterface $translator ) { $this->repository = $em->getRepository(AccompanyingCourseDocument::class); } diff --git a/src/Bundle/ChillEventBundle/Controller/ParticipationController.php b/src/Bundle/ChillEventBundle/Controller/ParticipationController.php index 9cd807479..17550758b 100644 --- a/src/Bundle/ChillEventBundle/Controller/ParticipationController.php +++ b/src/Bundle/ChillEventBundle/Controller/ParticipationController.php @@ -36,7 +36,7 @@ class ParticipationController extends AbstractController /** * ParticipationController constructor. */ - public function __construct(private LoggerInterface $logger) + public function __construct(private readonly LoggerInterface $logger) { } @@ -582,7 +582,7 @@ class ParticipationController extends AbstractController $persons_ids = $request->query->has('person_id') ? [$request->query->getInt('person_id', 0)] // sf4 check: // prevent error: `Argument 2 passed to ::getInt() must be of the type int, null given` - : explode(',', $request->query->get('persons_ids')); + : explode(',', (string) $request->query->get('persons_ids')); $participations = []; foreach ($persons_ids as $person_id) { @@ -746,7 +746,7 @@ class ParticipationController extends AbstractController if (true === $multiple) { $persons_ids = $request->query->get('persons_ids'); - if (!preg_match('/^([0-9]{1,},{0,1}){1,}[0-9]{0,}$/', $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 ','"); } diff --git a/src/Bundle/ChillEventBundle/Entity/Event.php b/src/Bundle/ChillEventBundle/Entity/Event.php index ca1379657..c5a8f953f 100644 --- a/src/Bundle/ChillEventBundle/Entity/Event.php +++ b/src/Bundle/ChillEventBundle/Entity/Event.php @@ -176,7 +176,7 @@ class Event implements HasCenterInterface, HasScopeInterface { $iterator = $this->participations->getIterator(); - $iterator->uasort(static fn ($first, $second) => strnatcasecmp($first->getPerson()->getFirstName(), $second->getPerson()->getFirstName())); + $iterator->uasort(static fn ($first, $second) => strnatcasecmp((string) $first->getPerson()->getFirstName(), (string) $second->getPerson()->getFirstName())); return $iterator; } diff --git a/src/Bundle/ChillEventBundle/Search/EventSearch.php b/src/Bundle/ChillEventBundle/Search/EventSearch.php index 8a396e5cb..6b4192004 100644 --- a/src/Bundle/ChillEventBundle/Search/EventSearch.php +++ b/src/Bundle/ChillEventBundle/Search/EventSearch.php @@ -38,7 +38,7 @@ use function count; */ class EventSearch extends AbstractSearch { - public const NAME = 'event_regular'; + final public const NAME = 'event_regular'; /** * @var \Chill\MainBundle\Entity\User @@ -47,10 +47,10 @@ class EventSearch extends AbstractSearch public function __construct( TokenStorageInterface $tokenStorage, - private EntityRepository $er, - private AuthorizationHelper $helper, - private TemplatingEngine $templating, - private PaginatorFactory $paginationFactory + private readonly EntityRepository $er, + private readonly AuthorizationHelper $helper, + private readonly TemplatingEngine $templating, + private readonly PaginatorFactory $paginationFactory ) { $this->user = $tokenStorage->getToken()->getUser(); } diff --git a/src/Bundle/ChillEventBundle/Security/Authorization/EventVoter.php b/src/Bundle/ChillEventBundle/Security/Authorization/EventVoter.php index ade1b48de..691939120 100644 --- a/src/Bundle/ChillEventBundle/Security/Authorization/EventVoter.php +++ b/src/Bundle/ChillEventBundle/Security/Authorization/EventVoter.php @@ -31,20 +31,20 @@ use function in_array; */ class EventVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface { - public const CREATE = 'CHILL_EVENT_CREATE'; + final public const CREATE = 'CHILL_EVENT_CREATE'; - public const ROLES = [ + final public const ROLES = [ self::SEE, self::SEE_DETAILS, self::CREATE, self::UPDATE, ]; - public const SEE = 'CHILL_EVENT_SEE'; + final public const SEE = 'CHILL_EVENT_SEE'; - public const SEE_DETAILS = 'CHILL_EVENT_SEE_DETAILS'; + final public const SEE_DETAILS = 'CHILL_EVENT_SEE_DETAILS'; - public const UPDATE = 'CHILL_EVENT_UPDATE'; + final public const UPDATE = 'CHILL_EVENT_UPDATE'; /** * @var AccessDecisionManagerInterface diff --git a/src/Bundle/ChillEventBundle/Security/Authorization/ParticipationVoter.php b/src/Bundle/ChillEventBundle/Security/Authorization/ParticipationVoter.php index 12c01ca60..b0c588560 100644 --- a/src/Bundle/ChillEventBundle/Security/Authorization/ParticipationVoter.php +++ b/src/Bundle/ChillEventBundle/Security/Authorization/ParticipationVoter.php @@ -28,20 +28,20 @@ use function in_array; class ParticipationVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface { - public const CREATE = 'CHILL_EVENT_PARTICIPATION_CREATE'; + final public const CREATE = 'CHILL_EVENT_PARTICIPATION_CREATE'; - public const ROLES = [ + final public const ROLES = [ self::SEE, self::SEE_DETAILS, self::CREATE, self::UPDATE, ]; - public const SEE = 'CHILL_EVENT_PARTICIPATION_SEE'; + final public const SEE = 'CHILL_EVENT_PARTICIPATION_SEE'; - public const SEE_DETAILS = 'CHILL_EVENT_PARTICIPATION_SEE_DETAILS'; + final public const SEE_DETAILS = 'CHILL_EVENT_PARTICIPATION_SEE_DETAILS'; - public const UPDATE = 'CHILL_EVENT_PARTICIPATION_UPDATE'; + final public const UPDATE = 'CHILL_EVENT_PARTICIPATION_UPDATE'; /** * @var AccessDecisionManagerInterface diff --git a/src/Bundle/ChillEventBundle/Tests/Controller/EventControllerTest.php b/src/Bundle/ChillEventBundle/Tests/Controller/EventControllerTest.php index 01f5e1b1a..cece09a99 100644 --- a/src/Bundle/ChillEventBundle/Tests/Controller/EventControllerTest.php +++ b/src/Bundle/ChillEventBundle/Tests/Controller/EventControllerTest.php @@ -19,7 +19,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; */ final class EventControllerTest extends WebTestCase { - public function testSkipped() + public function testSkipped(): never { $this->markTestSkipped(); } diff --git a/src/Bundle/ChillEventBundle/Tests/Controller/EventTypeControllerTest.php b/src/Bundle/ChillEventBundle/Tests/Controller/EventTypeControllerTest.php index 23394d43c..8e351066d 100644 --- a/src/Bundle/ChillEventBundle/Tests/Controller/EventTypeControllerTest.php +++ b/src/Bundle/ChillEventBundle/Tests/Controller/EventTypeControllerTest.php @@ -19,7 +19,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; */ final class EventTypeControllerTest extends WebTestCase { - public function testSkipped() + public function testSkipped(): never { $this->markTestSkipped(); } diff --git a/src/Bundle/ChillEventBundle/Tests/Controller/RoleControllerTest.php b/src/Bundle/ChillEventBundle/Tests/Controller/RoleControllerTest.php index 937bf8e49..3839a1647 100644 --- a/src/Bundle/ChillEventBundle/Tests/Controller/RoleControllerTest.php +++ b/src/Bundle/ChillEventBundle/Tests/Controller/RoleControllerTest.php @@ -19,7 +19,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; */ final class RoleControllerTest extends WebTestCase { - public function testSkipped() + public function testSkipped(): never { $this->markTestSkipped(); } diff --git a/src/Bundle/ChillEventBundle/Tests/Controller/StatusControllerTest.php b/src/Bundle/ChillEventBundle/Tests/Controller/StatusControllerTest.php index 04a6e6270..e573edaab 100644 --- a/src/Bundle/ChillEventBundle/Tests/Controller/StatusControllerTest.php +++ b/src/Bundle/ChillEventBundle/Tests/Controller/StatusControllerTest.php @@ -19,7 +19,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; */ final class StatusControllerTest extends WebTestCase { - public function testSkipped() + public function testSkipped(): never { $this->markTestSkipped(); } diff --git a/src/Bundle/ChillEventBundle/Tests/Search/EventSearchTest.php b/src/Bundle/ChillEventBundle/Tests/Search/EventSearchTest.php index 131d6051d..f81804b1b 100644 --- a/src/Bundle/ChillEventBundle/Tests/Search/EventSearchTest.php +++ b/src/Bundle/ChillEventBundle/Tests/Search/EventSearchTest.php @@ -373,7 +373,7 @@ final class EventSearchTest extends WebTestCase // get the second node, which should contains a date $tdDate = $tr->filter('td')->eq(1); // transform the date, which should be in french, into a DateTime object - $parts = explode(' ', $tdDate->text()); + $parts = explode(' ', (string) $tdDate->text()); return DateTime::createFromFormat('Y-m-d', $parts[2] . '-' . $months[$parts[1]] . '-' . $parts[0]); diff --git a/src/Bundle/ChillFamilyMembersBundle/Controller/FamilyMemberController.php b/src/Bundle/ChillFamilyMembersBundle/Controller/FamilyMemberController.php index 34a83dfcb..a886294bb 100644 --- a/src/Bundle/ChillFamilyMembersBundle/Controller/FamilyMemberController.php +++ b/src/Bundle/ChillFamilyMembersBundle/Controller/FamilyMemberController.php @@ -28,7 +28,7 @@ use Symfony\Contracts\Translation\TranslatorInterface; class FamilyMemberController extends AbstractController { - public function __construct(private EntityManagerInterface $em, protected TranslatorInterface $translator, protected LoggerInterface $chillMainLogger, private FamilyMemberRepository $familyMemberRepository) + public function __construct(private readonly EntityManagerInterface $em, protected TranslatorInterface $translator, protected LoggerInterface $chillMainLogger, private readonly FamilyMemberRepository $familyMemberRepository) { } diff --git a/src/Bundle/ChillFamilyMembersBundle/Form/FamilyMemberType.php b/src/Bundle/ChillFamilyMembersBundle/Form/FamilyMemberType.php index 4c45691e5..c317633e7 100644 --- a/src/Bundle/ChillFamilyMembersBundle/Form/FamilyMemberType.php +++ b/src/Bundle/ChillFamilyMembersBundle/Form/FamilyMemberType.php @@ -25,7 +25,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver; class FamilyMemberType extends AbstractType { - public function __construct(private ConfigRepository $configRepository, private TranslatableStringHelper $translatableStringHelper) + public function __construct(private readonly ConfigRepository $configRepository, private readonly TranslatableStringHelper $translatableStringHelper) { } diff --git a/src/Bundle/ChillFamilyMembersBundle/Security/Voter/FamilyMemberVoter.php b/src/Bundle/ChillFamilyMembersBundle/Security/Voter/FamilyMemberVoter.php index 027597cc9..68fd332ff 100644 --- a/src/Bundle/ChillFamilyMembersBundle/Security/Voter/FamilyMemberVoter.php +++ b/src/Bundle/ChillFamilyMembersBundle/Security/Voter/FamilyMemberVoter.php @@ -23,20 +23,20 @@ use function in_array; class FamilyMemberVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface { - public const CREATE = 'CHILL_FAMILY_MEMBERS_FAMILY_MEMBERS_CREATE'; + final public const CREATE = 'CHILL_FAMILY_MEMBERS_FAMILY_MEMBERS_CREATE'; - public const DELETE = 'CHILL_FAMILY_MEMBERS_FAMILY_MEMBERS_DELETE'; + final public const DELETE = 'CHILL_FAMILY_MEMBERS_FAMILY_MEMBERS_DELETE'; - public const ROLES = [ + final public const ROLES = [ self::CREATE, self::DELETE, self::SHOW, self::UPDATE, ]; - public const SHOW = 'CHILL_FAMILY_MEMBERS_FAMILY_MEMBERS_SHOW'; + final public const SHOW = 'CHILL_FAMILY_MEMBERS_FAMILY_MEMBERS_SHOW'; - public const UPDATE = 'CHILL_FAMILY_MEMBERS_FAMILY_MEMBERS_UPDATE'; + final public const UPDATE = 'CHILL_FAMILY_MEMBERS_FAMILY_MEMBERS_UPDATE'; /** * @var AuthorizationHelper diff --git a/src/Bundle/ChillFamilyMembersBundle/Templating/Twig.php b/src/Bundle/ChillFamilyMembersBundle/Templating/Twig.php index a2bed6319..05ccdc493 100644 --- a/src/Bundle/ChillFamilyMembersBundle/Templating/Twig.php +++ b/src/Bundle/ChillFamilyMembersBundle/Templating/Twig.php @@ -73,17 +73,17 @@ class Twig extends AbstractExtension public function getFilters() { return [ - new TwigFilter('chill_family_member_link_display', [$this, 'displayLink'], ['is_safe' => ['html']]), - new TwigFilter('chill_family_member_professional_situation_display', [$this, 'displayProfessionalSituation'], ['is_safe' => ['html']]), - new TwigFilter('chill_family_member_familial_situation_display', [$this, 'displayFamilialSituation'], ['is_safe' => ['html']]), + new TwigFilter('chill_family_member_link_display', $this->displayLink(...), ['is_safe' => ['html']]), + new TwigFilter('chill_family_member_professional_situation_display', $this->displayProfessionalSituation(...), ['is_safe' => ['html']]), + new TwigFilter('chill_family_member_familial_situation_display', $this->displayFamilialSituation(...), ['is_safe' => ['html']]), ]; } public function getFunctions() { return [ - new TwigFunction('chill_family_members_has_professionnal_situation', [$this, 'hasProfessionnalSituation']), - new TwigFunction('chill_family_members_has_familial_situation', [$this, 'hasFamilialSituation']), + new TwigFunction('chill_family_members_has_professionnal_situation', $this->hasProfessionnalSituation(...)), + new TwigFunction('chill_family_members_has_familial_situation', $this->hasFamilialSituation(...)), ]; } diff --git a/src/Bundle/ChillMainBundle/CRUD/Resolver/Resolver.php b/src/Bundle/ChillMainBundle/CRUD/Resolver/Resolver.php index aa06fbf2d..6068a5391 100644 --- a/src/Bundle/ChillMainBundle/CRUD/Resolver/Resolver.php +++ b/src/Bundle/ChillMainBundle/CRUD/Resolver/Resolver.php @@ -25,17 +25,17 @@ class Resolver /** * The key to get the role necessary for the action. */ - public const ROLE = 'role'; + final public const ROLE = 'role'; /** * @deprecated */ - public const ROLE_EDIT = 'role.edit'; + final public const ROLE_EDIT = 'role.edit'; /** * @deprecated */ - public const ROLE_VIEW = 'role.view'; + final public const ROLE_VIEW = 'role.view'; /** * @var array diff --git a/src/Bundle/ChillMainBundle/CRUD/Templating/TwigCRUDResolver.php b/src/Bundle/ChillMainBundle/CRUD/Templating/TwigCRUDResolver.php index afa3eab30..845bc145b 100644 --- a/src/Bundle/ChillMainBundle/CRUD/Templating/TwigCRUDResolver.php +++ b/src/Bundle/ChillMainBundle/CRUD/Templating/TwigCRUDResolver.php @@ -54,12 +54,12 @@ class TwigCRUDResolver extends AbstractExtension return [ new TwigFunction( 'chill_crud_config', - [$this, 'getConfig'], + $this->getConfig(...), ['is_safe' => 'html'] ), new TwigFunction( 'chill_crud_action_exists', - [$this, 'hasAction'], + $this->hasAction(...), [] ), ]; diff --git a/src/Bundle/ChillMainBundle/Command/ChillImportUsersCommand.php b/src/Bundle/ChillMainBundle/Command/ChillImportUsersCommand.php index d4c3dcb42..48d460875 100644 --- a/src/Bundle/ChillMainBundle/Command/ChillImportUsersCommand.php +++ b/src/Bundle/ChillMainBundle/Command/ChillImportUsersCommand.php @@ -138,8 +138,8 @@ class ChillImportUsersCommand extends Command { $user = new User(); $user - ->setEmail(trim($data['email'])) - ->setUsername(trim($data['username'])) + ->setEmail(trim((string) $data['email'])) + ->setUsername(trim((string) $data['username'])) ->setEnabled(true) ->setPassword($this->passwordEncoder->encodePassword( $user, diff --git a/src/Bundle/ChillMainBundle/Command/ChillUserSendRenewPasswordCodeCommand.php b/src/Bundle/ChillMainBundle/Command/ChillUserSendRenewPasswordCodeCommand.php index 5f62d39ed..b7ef472a4 100644 --- a/src/Bundle/ChillMainBundle/Command/ChillUserSendRenewPasswordCodeCommand.php +++ b/src/Bundle/ChillMainBundle/Command/ChillUserSendRenewPasswordCodeCommand.php @@ -160,7 +160,7 @@ class ChillUserSendRenewPasswordCodeCommand extends Command try { if (array_key_exists('email', $row)) { - return $userRepository->findOneByUsernameOrEmail(trim($row['email'])); + return $userRepository->findOneByUsernameOrEmail(trim((string) $row['email'])); } } catch (\Doctrine\ORM\NoResultException) { // continue, we will try username @@ -168,7 +168,7 @@ class ChillUserSendRenewPasswordCodeCommand extends Command try { if (array_key_exists('username', $row)) { - return $userRepository->findOneByUsernameOrEmail(trim($row['username'])); + return $userRepository->findOneByUsernameOrEmail(trim((string) $row['username'])); } } catch (\Doctrine\ORM\NoResultException) { return null; diff --git a/src/Bundle/ChillMainBundle/Command/ExecuteCronJobCommand.php b/src/Bundle/ChillMainBundle/Command/ExecuteCronJobCommand.php index e2d7bd6dd..b3f9a9f4d 100644 --- a/src/Bundle/ChillMainBundle/Command/ExecuteCronJobCommand.php +++ b/src/Bundle/ChillMainBundle/Command/ExecuteCronJobCommand.php @@ -20,7 +20,7 @@ use Symfony\Component\Console\Output\OutputInterface; class ExecuteCronJobCommand extends Command { public function __construct( - private CronManagerInterface $cronManager + private readonly CronManagerInterface $cronManager ) { parent::__construct('chill:cron-job:execute'); } diff --git a/src/Bundle/ChillMainBundle/Command/LoadAddressesBEFromBestAddressCommand.php b/src/Bundle/ChillMainBundle/Command/LoadAddressesBEFromBestAddressCommand.php index 0335f11ee..710dedb8f 100644 --- a/src/Bundle/ChillMainBundle/Command/LoadAddressesBEFromBestAddressCommand.php +++ b/src/Bundle/ChillMainBundle/Command/LoadAddressesBEFromBestAddressCommand.php @@ -21,8 +21,8 @@ use Symfony\Component\Console\Output\OutputInterface; class LoadAddressesBEFromBestAddressCommand extends Command { public function __construct( - private AddressReferenceBEFromBestAddress $addressImporter, - private PostalCodeBEFromBestAddress $postalCodeBEFromBestAddressImporter + private readonly AddressReferenceBEFromBestAddress $addressImporter, + private readonly PostalCodeBEFromBestAddress $postalCodeBEFromBestAddressImporter ) { parent::__construct(); } diff --git a/src/Bundle/ChillMainBundle/Command/LoadAddressesFRFromBANOCommand.php b/src/Bundle/ChillMainBundle/Command/LoadAddressesFRFromBANOCommand.php index 732355a44..8f51a7335 100644 --- a/src/Bundle/ChillMainBundle/Command/LoadAddressesFRFromBANOCommand.php +++ b/src/Bundle/ChillMainBundle/Command/LoadAddressesFRFromBANOCommand.php @@ -19,7 +19,7 @@ use Symfony\Component\Console\Output\OutputInterface; class LoadAddressesFRFromBANOCommand extends Command { - public function __construct(private AddressReferenceFromBano $addressReferenceFromBano) + public function __construct(private readonly AddressReferenceFromBano $addressReferenceFromBano) { parent::__construct(); } diff --git a/src/Bundle/ChillMainBundle/Command/LoadAndUpdateLanguagesCommand.php b/src/Bundle/ChillMainBundle/Command/LoadAndUpdateLanguagesCommand.php index 702a71403..729051ea3 100644 --- a/src/Bundle/ChillMainBundle/Command/LoadAndUpdateLanguagesCommand.php +++ b/src/Bundle/ChillMainBundle/Command/LoadAndUpdateLanguagesCommand.php @@ -26,9 +26,9 @@ use function in_array; */ class LoadAndUpdateLanguagesCommand extends Command { - public const INCLUDE_ANCIENT = 'include_ancient'; + final public const INCLUDE_ANCIENT = 'include_ancient'; - public const INCLUDE_REGIONAL_VERSION = 'include_regional'; + final public const INCLUDE_REGIONAL_VERSION = 'include_regional'; // Array of ancien languages (to exclude) private $ancientToExclude = ['ang', 'egy', 'fro', 'goh', 'grc', 'la', 'non', 'peo', 'pro', 'sga', @@ -43,7 +43,7 @@ class LoadAndUpdateLanguagesCommand extends Command * * @param $availableLanguages */ - public function __construct(private EntityManager $entityManager, private $availableLanguages) + public function __construct(private readonly EntityManager $entityManager, private $availableLanguages) { parent::__construct(); } diff --git a/src/Bundle/ChillMainBundle/Command/LoadCountriesCommand.php b/src/Bundle/ChillMainBundle/Command/LoadCountriesCommand.php index 01400a9ad..c5cbdd78a 100644 --- a/src/Bundle/ChillMainBundle/Command/LoadCountriesCommand.php +++ b/src/Bundle/ChillMainBundle/Command/LoadCountriesCommand.php @@ -25,7 +25,7 @@ class LoadCountriesCommand extends Command * * @param $availableLanguages */ - public function __construct(private EntityManager $entityManager, private $availableLanguages) + public function __construct(private readonly EntityManager $entityManager, private $availableLanguages) { parent::__construct(); } diff --git a/src/Bundle/ChillMainBundle/Command/LoadPostalCodeFR.php b/src/Bundle/ChillMainBundle/Command/LoadPostalCodeFR.php index 6d1999127..be29cad9f 100644 --- a/src/Bundle/ChillMainBundle/Command/LoadPostalCodeFR.php +++ b/src/Bundle/ChillMainBundle/Command/LoadPostalCodeFR.php @@ -18,7 +18,7 @@ use Symfony\Component\Console\Output\OutputInterface; class LoadPostalCodeFR extends Command { - public function __construct(private PostalCodeFRFromOpenData $loader) + public function __construct(private readonly PostalCodeFRFromOpenData $loader) { parent::__construct(); } diff --git a/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php b/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php index 208f67cab..7bda1d672 100644 --- a/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php +++ b/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php @@ -30,7 +30,7 @@ use function strlen; class LoadPostalCodesCommand extends Command { - public function __construct(private EntityManagerInterface $entityManager, private ValidatorInterface $validator) + public function __construct(private readonly EntityManagerInterface $entityManager, private readonly ValidatorInterface $validator) { parent::__construct(); } @@ -90,7 +90,7 @@ class LoadPostalCodesCommand extends Command 0, $input->getOption('delimiter'), $input->getOption('enclosure'), - $input->getOption('escape') + (string) $input->getOption('escape') )) ) { try { @@ -109,7 +109,7 @@ class LoadPostalCodesCommand extends Command private function addPostalCode($row, OutputInterface $output) { - if ('FR' === $row[2] && strlen($row[0]) === 4) { + if ('FR' === $row[2] && strlen((string) $row[0]) === 4) { // CP in FRANCE are on 5 digit // For CP starting with a zero, the starting zero can be remove if stored as number in a csv // add a zero if CP from FR and on 4 digit diff --git a/src/Bundle/ChillMainBundle/Command/SetPasswordCommand.php b/src/Bundle/ChillMainBundle/Command/SetPasswordCommand.php index 16619bf54..c5eec91be 100644 --- a/src/Bundle/ChillMainBundle/Command/SetPasswordCommand.php +++ b/src/Bundle/ChillMainBundle/Command/SetPasswordCommand.php @@ -29,7 +29,7 @@ class SetPasswordCommand extends Command /** * SetPasswordCommand constructor. */ - public function __construct(private EntityManager $entityManager) + public function __construct(private readonly EntityManager $entityManager) { parent::__construct(); } diff --git a/src/Bundle/ChillMainBundle/Controller/AddressReferenceAPIController.php b/src/Bundle/ChillMainBundle/Controller/AddressReferenceAPIController.php index 68a0afdb6..b80bc2524 100644 --- a/src/Bundle/ChillMainBundle/Controller/AddressReferenceAPIController.php +++ b/src/Bundle/ChillMainBundle/Controller/AddressReferenceAPIController.php @@ -28,7 +28,7 @@ use function trim; final class AddressReferenceAPIController extends ApiController { - public function __construct(private AddressReferenceRepository $addressReferenceRepository, private PaginatorFactory $paginatorFactory) + public function __construct(private readonly AddressReferenceRepository $addressReferenceRepository, private readonly PaginatorFactory $paginatorFactory) { } @@ -45,7 +45,7 @@ final class AddressReferenceAPIController extends ApiController $pattern = $request->query->get('q'); - if ('' === trim($pattern)) { + if ('' === trim((string) $pattern)) { throw new BadRequestHttpException('the search pattern is empty'); } diff --git a/src/Bundle/ChillMainBundle/Controller/AddressToReferenceMatcherController.php b/src/Bundle/ChillMainBundle/Controller/AddressToReferenceMatcherController.php index fc92cd299..079f4783b 100644 --- a/src/Bundle/ChillMainBundle/Controller/AddressToReferenceMatcherController.php +++ b/src/Bundle/ChillMainBundle/Controller/AddressToReferenceMatcherController.php @@ -23,7 +23,7 @@ use Symfony\Component\Serializer\SerializerInterface; class AddressToReferenceMatcherController { - public function __construct(private Security $security, private EntityManagerInterface $entityManager, private SerializerInterface $serializer) + public function __construct(private readonly Security $security, private readonly EntityManagerInterface $entityManager, private readonly SerializerInterface $serializer) { } diff --git a/src/Bundle/ChillMainBundle/Controller/ExportController.php b/src/Bundle/ChillMainBundle/Controller/ExportController.php index 9e62cacf6..07d7907f6 100644 --- a/src/Bundle/ChillMainBundle/Controller/ExportController.php +++ b/src/Bundle/ChillMainBundle/Controller/ExportController.php @@ -47,7 +47,7 @@ use function unserialize; */ class ExportController extends AbstractController { - public function __construct(private ChillRedis $redis, private ExportManager $exportManager, private FormFactoryInterface $formFactory, private LoggerInterface $logger, private SessionInterface $session, private TranslatorInterface $translator, private EntityManagerInterface $entityManager) + public function __construct(private readonly ChillRedis $redis, private readonly ExportManager $exportManager, private readonly FormFactoryInterface $formFactory, private readonly LoggerInterface $logger, private readonly SessionInterface $session, private readonly TranslatorInterface $translator, private readonly EntityManagerInterface $entityManager) { } @@ -234,7 +234,7 @@ class ExportController extends AbstractController { /** @var \Chill\MainBundle\Export\ExportManager $exportManager */ $exportManager = $this->exportManager; - $isGenerate = str_starts_with($step, 'generate_'); + $isGenerate = str_starts_with((string) $step, 'generate_'); $builder = $this->formFactory ->createNamedBuilder(null, FormType::class, [], [ diff --git a/src/Bundle/ChillMainBundle/Controller/GeographicalUnitByAddressApiController.php b/src/Bundle/ChillMainBundle/Controller/GeographicalUnitByAddressApiController.php index 6ab4a6e3e..a8a9c0610 100644 --- a/src/Bundle/ChillMainBundle/Controller/GeographicalUnitByAddressApiController.php +++ b/src/Bundle/ChillMainBundle/Controller/GeographicalUnitByAddressApiController.php @@ -24,7 +24,7 @@ use Symfony\Component\Serializer\SerializerInterface; class GeographicalUnitByAddressApiController { - public function __construct(private PaginatorFactory $paginatorFactory, private GeographicalUnitRepositoryInterface $geographicalUnitRepository, private Security $security, private SerializerInterface $serializer) + public function __construct(private readonly PaginatorFactory $paginatorFactory, private readonly GeographicalUnitRepositoryInterface $geographicalUnitRepository, private readonly Security $security, private readonly SerializerInterface $serializer) { } diff --git a/src/Bundle/ChillMainBundle/Controller/NotificationApiController.php b/src/Bundle/ChillMainBundle/Controller/NotificationApiController.php index 52810cd97..1e371b970 100644 --- a/src/Bundle/ChillMainBundle/Controller/NotificationApiController.php +++ b/src/Bundle/ChillMainBundle/Controller/NotificationApiController.php @@ -33,7 +33,7 @@ use UnexpectedValueException; */ class NotificationApiController { - public function __construct(private EntityManagerInterface $entityManager, private NotificationRepository $notificationRepository, private PaginatorFactory $paginatorFactory, private Security $security, private SerializerInterface $serializer) + public function __construct(private readonly EntityManagerInterface $entityManager, private readonly NotificationRepository $notificationRepository, private readonly PaginatorFactory $paginatorFactory, private readonly Security $security, private readonly SerializerInterface $serializer) { } diff --git a/src/Bundle/ChillMainBundle/Controller/NotificationController.php b/src/Bundle/ChillMainBundle/Controller/NotificationController.php index d2d37ad77..5715b2f56 100644 --- a/src/Bundle/ChillMainBundle/Controller/NotificationController.php +++ b/src/Bundle/ChillMainBundle/Controller/NotificationController.php @@ -41,7 +41,7 @@ use function in_array; */ class NotificationController extends AbstractController { - public function __construct(private EntityManagerInterface $em, private LoggerInterface $chillLogger, private LoggerInterface $logger, private Security $security, private NotificationRepository $notificationRepository, private NotificationHandlerManager $notificationHandlerManager, private PaginatorFactory $paginatorFactory, private TranslatorInterface $translator, private UserRepository $userRepository) + public function __construct(private readonly EntityManagerInterface $em, private readonly LoggerInterface $chillLogger, private readonly LoggerInterface $logger, private readonly Security $security, private readonly NotificationRepository $notificationRepository, private readonly NotificationHandlerManager $notificationHandlerManager, private readonly PaginatorFactory $paginatorFactory, private readonly TranslatorInterface $translator, private readonly UserRepository $userRepository) { } diff --git a/src/Bundle/ChillMainBundle/Controller/PermissionApiController.php b/src/Bundle/ChillMainBundle/Controller/PermissionApiController.php index a28ca46f4..60f2d1ffb 100644 --- a/src/Bundle/ChillMainBundle/Controller/PermissionApiController.php +++ b/src/Bundle/ChillMainBundle/Controller/PermissionApiController.php @@ -24,7 +24,7 @@ use function json_decode; class PermissionApiController extends AbstractController { - public function __construct(private DenormalizerInterface $denormalizer, private Security $security) + public function __construct(private readonly DenormalizerInterface $denormalizer, private readonly Security $security) { } diff --git a/src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php b/src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php index f1b485870..bdcaf861a 100644 --- a/src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php +++ b/src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php @@ -37,7 +37,7 @@ class PermissionsGroupController extends AbstractController /** * PermissionsGroupController constructor. */ - public function __construct(private TranslatableStringHelper $translatableStringHelper, private RoleProvider $roleProvider, private RoleHierarchy $roleHierarchy, private TranslatorInterface $translator, private ValidatorInterface $validator) + public function __construct(private readonly TranslatableStringHelper $translatableStringHelper, private readonly RoleProvider $roleProvider, private readonly RoleHierarchy $roleHierarchy, private readonly TranslatorInterface $translator, private readonly ValidatorInterface $validator) { } diff --git a/src/Bundle/ChillMainBundle/Controller/PostalCodeAPIController.php b/src/Bundle/ChillMainBundle/Controller/PostalCodeAPIController.php index 945ad8fcf..e51f74e40 100644 --- a/src/Bundle/ChillMainBundle/Controller/PostalCodeAPIController.php +++ b/src/Bundle/ChillMainBundle/Controller/PostalCodeAPIController.php @@ -26,7 +26,7 @@ use Symfony\Component\Serializer\Normalizer\AbstractNormalizer; final class PostalCodeAPIController extends ApiController { - public function __construct(private CountryRepository $countryRepository, private PostalCodeRepositoryInterface $postalCodeRepository, private PaginatorFactory $paginatorFactory) + public function __construct(private readonly CountryRepository $countryRepository, private readonly PostalCodeRepositoryInterface $postalCodeRepository, private readonly PaginatorFactory $paginatorFactory) { } @@ -43,7 +43,7 @@ final class PostalCodeAPIController extends ApiController $pattern = $request->query->get('q'); - if ('' === trim($pattern)) { + if ('' === trim((string) $pattern)) { throw new BadRequestHttpException('the search pattern is empty'); } diff --git a/src/Bundle/ChillMainBundle/Controller/SavedExportController.php b/src/Bundle/ChillMainBundle/Controller/SavedExportController.php index f5e84c1b3..923394da9 100644 --- a/src/Bundle/ChillMainBundle/Controller/SavedExportController.php +++ b/src/Bundle/ChillMainBundle/Controller/SavedExportController.php @@ -36,7 +36,7 @@ use function count; class SavedExportController { - public function __construct(private EngineInterface $templating, private EntityManagerInterface $entityManager, private ExportManager $exportManager, private FormFactoryInterface $formFactory, private SavedExportRepositoryInterface $savedExportRepository, private Security $security, private SessionInterface $session, private TranslatorInterface $translator, private UrlGeneratorInterface $urlGenerator) + public function __construct(private readonly EngineInterface $templating, private readonly EntityManagerInterface $entityManager, private readonly ExportManager $exportManager, private readonly FormFactoryInterface $formFactory, private readonly SavedExportRepositoryInterface $savedExportRepository, private readonly Security $security, private readonly SessionInterface $session, private readonly TranslatorInterface $translator, private readonly UrlGeneratorInterface $urlGenerator) { } diff --git a/src/Bundle/ChillMainBundle/Controller/SearchController.php b/src/Bundle/ChillMainBundle/Controller/SearchController.php index dfaaa50d4..097b71d0e 100644 --- a/src/Bundle/ChillMainBundle/Controller/SearchController.php +++ b/src/Bundle/ChillMainBundle/Controller/SearchController.php @@ -103,7 +103,7 @@ class SearchController extends AbstractController public function searchAction(Request $request, $_format) { - $pattern = trim($request->query->get('q', '')); + $pattern = trim((string) $request->query->get('q', '')); if ('' === $pattern) { switch ($_format) { diff --git a/src/Bundle/ChillMainBundle/Controller/TimelineCenterController.php b/src/Bundle/ChillMainBundle/Controller/TimelineCenterController.php index fdb521882..f031c8ef1 100644 --- a/src/Bundle/ChillMainBundle/Controller/TimelineCenterController.php +++ b/src/Bundle/ChillMainBundle/Controller/TimelineCenterController.php @@ -22,7 +22,7 @@ use function count; class TimelineCenterController extends AbstractController { - public function __construct(protected TimelineBuilder $timelineBuilder, protected PaginatorFactory $paginatorFactory, private Security $security) + public function __construct(protected TimelineBuilder $timelineBuilder, protected PaginatorFactory $paginatorFactory, private readonly Security $security) { } diff --git a/src/Bundle/ChillMainBundle/Controller/UserController.php b/src/Bundle/ChillMainBundle/Controller/UserController.php index f8e512f78..af7620356 100644 --- a/src/Bundle/ChillMainBundle/Controller/UserController.php +++ b/src/Bundle/ChillMainBundle/Controller/UserController.php @@ -36,9 +36,9 @@ use Symfony\Component\Validator\Validator\ValidatorInterface; class UserController extends CRUDController { - public const FORM_GROUP_CENTER_COMPOSED = 'composed_groupcenter'; + final public const FORM_GROUP_CENTER_COMPOSED = 'composed_groupcenter'; - public function __construct(private LoggerInterface $logger, private ValidatorInterface $validator, private UserPasswordEncoderInterface $passwordEncoder, private UserRepository $userRepository, protected ParameterBagInterface $parameterBag) + public function __construct(private readonly LoggerInterface $logger, private readonly ValidatorInterface $validator, private readonly UserPasswordEncoderInterface $passwordEncoder, private readonly UserRepository $userRepository, protected ParameterBagInterface $parameterBag) { } diff --git a/src/Bundle/ChillMainBundle/Controller/WorkflowApiController.php b/src/Bundle/ChillMainBundle/Controller/WorkflowApiController.php index dfb06d3df..5de0e1252 100644 --- a/src/Bundle/ChillMainBundle/Controller/WorkflowApiController.php +++ b/src/Bundle/ChillMainBundle/Controller/WorkflowApiController.php @@ -30,7 +30,7 @@ use Symfony\Component\Serializer\SerializerInterface; class WorkflowApiController { - public function __construct(private EntityManagerInterface $entityManager, private EntityWorkflowRepository $entityWorkflowRepository, private PaginatorFactory $paginatorFactory, private Security $security, private SerializerInterface $serializer) + public function __construct(private readonly EntityManagerInterface $entityManager, private readonly EntityWorkflowRepository $entityWorkflowRepository, private readonly PaginatorFactory $paginatorFactory, private readonly Security $security, private readonly SerializerInterface $serializer) { } diff --git a/src/Bundle/ChillMainBundle/Controller/WorkflowController.php b/src/Bundle/ChillMainBundle/Controller/WorkflowController.php index b3d2ad475..6b3680b51 100644 --- a/src/Bundle/ChillMainBundle/Controller/WorkflowController.php +++ b/src/Bundle/ChillMainBundle/Controller/WorkflowController.php @@ -39,7 +39,7 @@ use function count; class WorkflowController extends AbstractController { - public function __construct(private EntityWorkflowManager $entityWorkflowManager, private EntityWorkflowRepository $entityWorkflowRepository, private ValidatorInterface $validator, private PaginatorFactory $paginatorFactory, private Registry $registry, private EntityManagerInterface $entityManager, private TranslatorInterface $translator, private Security $security) + public function __construct(private readonly EntityWorkflowManager $entityWorkflowManager, private readonly EntityWorkflowRepository $entityWorkflowRepository, private readonly ValidatorInterface $validator, private readonly PaginatorFactory $paginatorFactory, private readonly Registry $registry, private readonly EntityManagerInterface $entityManager, private readonly TranslatorInterface $translator, private readonly Security $security) { } diff --git a/src/Bundle/ChillMainBundle/Cron/CronManager.php b/src/Bundle/ChillMainBundle/Cron/CronManager.php index 0bf928ee1..da3316b11 100644 --- a/src/Bundle/ChillMainBundle/Cron/CronManager.php +++ b/src/Bundle/ChillMainBundle/Cron/CronManager.php @@ -49,7 +49,7 @@ class CronManager implements CronManagerInterface /** * @param CronJobInterface[] $jobs */ - public function __construct(private CronJobExecutionRepositoryInterface $cronJobExecutionRepository, private EntityManagerInterface $entityManager, private iterable $jobs, private LoggerInterface $logger) + public function __construct(private readonly CronJobExecutionRepositoryInterface $cronJobExecutionRepository, private readonly EntityManagerInterface $entityManager, private readonly iterable $jobs, private readonly LoggerInterface $logger) { } diff --git a/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadUsers.php b/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadUsers.php index 0d3b79fa0..8b6862364 100644 --- a/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadUsers.php +++ b/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadUsers.php @@ -84,7 +84,7 @@ class LoadUsers extends AbstractFixture implements ContainerAwareInterface, Orde ->getEncoder($user) ->encodePassword('password', $user->getSalt()) ) - ->setEmail(sprintf('%s@chill.social', str_replace(' ', '', $username))); + ->setEmail(sprintf('%s@chill.social', str_replace(' ', '', (string) $username))); foreach ($params['groupCenterRefs'] as $groupCenterRef) { $user->addGroupCenter($this->getReference($groupCenterRef)); diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/ShortMessageCompilerPass.php b/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/ShortMessageCompilerPass.php index f9fdb80d0..88d72bddf 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/ShortMessageCompilerPass.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/ShortMessageCompilerPass.php @@ -36,7 +36,7 @@ class ShortMessageCompilerPass implements CompilerPassInterface { $config = $container->resolveEnvPlaceholders($container->getParameter('chill_main.short_messages'), true); // weird fix for special characters - $config['dsn'] = str_replace(['%%'], ['%'], $config['dsn']); + $config['dsn'] = str_replace(['%%'], ['%'], (string) $config['dsn']); $dsn = parse_url($config['dsn']); parse_str($dsn['query'] ?? '', $dsn['queries']); diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php b/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php index 0c5fd56c9..7cfe8cfb6 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php @@ -26,7 +26,7 @@ class Configuration implements ConfigurationInterface public function __construct( array $widgetFactories, - private ContainerBuilder $containerBuilder + private readonly ContainerBuilder $containerBuilder ) { $this->setWidgetFactories($widgetFactories); } diff --git a/src/Bundle/ChillMainBundle/Doctrine/Event/TrackCreateUpdateSubscriber.php b/src/Bundle/ChillMainBundle/Doctrine/Event/TrackCreateUpdateSubscriber.php index 0c8159df3..624167fec 100644 --- a/src/Bundle/ChillMainBundle/Doctrine/Event/TrackCreateUpdateSubscriber.php +++ b/src/Bundle/ChillMainBundle/Doctrine/Event/TrackCreateUpdateSubscriber.php @@ -22,7 +22,7 @@ use Symfony\Component\Security\Core\Security; class TrackCreateUpdateSubscriber implements EventSubscriber { - public function __construct(private Security $security) + public function __construct(private readonly Security $security) { } diff --git a/src/Bundle/ChillMainBundle/Doctrine/Model/Point.php b/src/Bundle/ChillMainBundle/Doctrine/Model/Point.php index de73bdf5a..03f1e7a8e 100644 --- a/src/Bundle/ChillMainBundle/Doctrine/Model/Point.php +++ b/src/Bundle/ChillMainBundle/Doctrine/Model/Point.php @@ -20,7 +20,7 @@ class Point implements JsonSerializable { public static string $SRID = '4326'; - private function __construct(private ?float $lon, private ?float $lat) + private function __construct(private readonly ?float $lon, private readonly ?float $lat) { } diff --git a/src/Bundle/ChillMainBundle/Doctrine/Type/NativeDateIntervalType.php b/src/Bundle/ChillMainBundle/Doctrine/Type/NativeDateIntervalType.php index 91033ec0b..c060dec60 100644 --- a/src/Bundle/ChillMainBundle/Doctrine/Type/NativeDateIntervalType.php +++ b/src/Bundle/ChillMainBundle/Doctrine/Type/NativeDateIntervalType.php @@ -29,7 +29,7 @@ use function reset; */ class NativeDateIntervalType extends DateIntervalType { - public const FORMAT = '%rP%YY%MM%DDT%HH%IM%SS'; + final public const FORMAT = '%rP%YY%MM%DDT%HH%IM%SS'; public function convertToDatabaseValue($value, AbstractPlatform $platform) { @@ -51,7 +51,7 @@ class NativeDateIntervalType extends DateIntervalType } try { - $strings = explode(' ', $value); + $strings = explode(' ', (string) $value); if (count($strings) === 0) { return null; @@ -101,8 +101,8 @@ class NativeDateIntervalType extends DateIntervalType return $current . $unit; } - if (preg_match('/([0-9]{2}\:[0-9]{2}:[0-9]{2})/', $current) === 1) { - $tExploded = explode(':', $current); + if (preg_match('/([0-9]{2}\:[0-9]{2}:[0-9]{2})/', (string) $current) === 1) { + $tExploded = explode(':', (string) $current); $intervalSpec = 'T'; $intervalSpec .= $tExploded[0] . 'H'; $intervalSpec .= $tExploded[1] . 'M'; diff --git a/src/Bundle/ChillMainBundle/Doctrine/Type/PointType.php b/src/Bundle/ChillMainBundle/Doctrine/Type/PointType.php index e1849574b..ce9074592 100644 --- a/src/Bundle/ChillMainBundle/Doctrine/Type/PointType.php +++ b/src/Bundle/ChillMainBundle/Doctrine/Type/PointType.php @@ -21,7 +21,7 @@ use Doctrine\DBAL\Types\Type; */ class PointType extends Type { - public const POINT = 'point'; + final public const POINT = 'point'; public function canRequireSQLConversion() { diff --git a/src/Bundle/ChillMainBundle/Entity/Address.php b/src/Bundle/ChillMainBundle/Entity/Address.php index 52e8d7c62..f753a048a 100644 --- a/src/Bundle/ChillMainBundle/Entity/Address.php +++ b/src/Bundle/ChillMainBundle/Entity/Address.php @@ -40,19 +40,19 @@ class Address implements TrackCreationInterface, TrackUpdateInterface /** * When an Address does match with the AddressReference */ - public const ADDR_REFERENCE_STATUS_MATCH = 'match'; + final public const ADDR_REFERENCE_STATUS_MATCH = 'match'; /** * When an Address does not match with the AddressReference, and * is pending for a review */ - public const ADDR_REFERENCE_STATUS_TO_REVIEW = 'to_review'; + final public const ADDR_REFERENCE_STATUS_TO_REVIEW = 'to_review'; /** * When an Address does not match with the AddressReference, but * is reviewed */ - public const ADDR_REFERENCE_STATUS_REVIEWED = 'reviewed'; + final public const ADDR_REFERENCE_STATUS_REVIEWED = 'reviewed'; /** * @ORM\ManyToOne(targetEntity=AddressReference::class) diff --git a/src/Bundle/ChillMainBundle/Entity/CronJobExecution.php b/src/Bundle/ChillMainBundle/Entity/CronJobExecution.php index ea3d47f72..5b80f41be 100644 --- a/src/Bundle/ChillMainBundle/Entity/CronJobExecution.php +++ b/src/Bundle/ChillMainBundle/Entity/CronJobExecution.php @@ -20,9 +20,9 @@ use Doctrine\ORM\Mapping as ORM; */ class CronJobExecution { - public const FAILURE = 100; + final public const FAILURE = 100; - public const SUCCESS = 1; + final public const SUCCESS = 1; /** * @var DateTimeImmutable diff --git a/src/Bundle/ChillMainBundle/Entity/LocationType.php b/src/Bundle/ChillMainBundle/Entity/LocationType.php index 42d1aa960..902ffce4d 100644 --- a/src/Bundle/ChillMainBundle/Entity/LocationType.php +++ b/src/Bundle/ChillMainBundle/Entity/LocationType.php @@ -27,15 +27,15 @@ use Symfony\Component\Serializer\Annotation\DiscriminatorMap; */ class LocationType { - public const DEFAULT_FOR_3PARTY = 'thirdparty'; + final public const DEFAULT_FOR_3PARTY = 'thirdparty'; - public const DEFAULT_FOR_PERSON = 'person'; + final public const DEFAULT_FOR_PERSON = 'person'; - public const STATUS_NEVER = 'never'; + final public const STATUS_NEVER = 'never'; - public const STATUS_OPTIONAL = 'optional'; + final public const STATUS_OPTIONAL = 'optional'; - public const STATUS_REQUIRED = 'required'; + final public const STATUS_REQUIRED = 'required'; /** * @ORM\Column(type="boolean", nullable=true) diff --git a/src/Bundle/ChillMainBundle/Export/ExportManager.php b/src/Bundle/ChillMainBundle/Export/ExportManager.php index 9b8fb340e..d3295e956 100644 --- a/src/Bundle/ChillMainBundle/Export/ExportManager.php +++ b/src/Bundle/ChillMainBundle/Export/ExportManager.php @@ -71,9 +71,9 @@ class ExportManager private $user; public function __construct( - private LoggerInterface $logger, - private AuthorizationCheckerInterface $authorizationChecker, - private AuthorizationHelperInterface $authorizationHelper, + private readonly LoggerInterface $logger, + private readonly AuthorizationCheckerInterface $authorizationChecker, + private readonly AuthorizationHelperInterface $authorizationHelper, TokenStorageInterface $tokenStorage, iterable $exports, iterable $aggregators, diff --git a/src/Bundle/ChillMainBundle/Export/Helper/DateTimeHelper.php b/src/Bundle/ChillMainBundle/Export/Helper/DateTimeHelper.php index 6b780715b..5c5e24318 100644 --- a/src/Bundle/ChillMainBundle/Export/Helper/DateTimeHelper.php +++ b/src/Bundle/ChillMainBundle/Export/Helper/DateTimeHelper.php @@ -18,7 +18,7 @@ use Symfony\Contracts\Translation\TranslatorInterface; class DateTimeHelper { - public function __construct(private TranslatorInterface $translator) + public function __construct(private readonly TranslatorInterface $translator) { } diff --git a/src/Bundle/ChillMainBundle/Export/Helper/ExportAddressHelper.php b/src/Bundle/ChillMainBundle/Export/Helper/ExportAddressHelper.php index 465fe6608..e96987760 100644 --- a/src/Bundle/ChillMainBundle/Export/Helper/ExportAddressHelper.php +++ b/src/Bundle/ChillMainBundle/Export/Helper/ExportAddressHelper.php @@ -32,25 +32,25 @@ class ExportAddressHelper /** * Compute all the F_* constants. */ - public const F_ALL = + final public const F_ALL = self::F_ATTRIBUTES | self::F_BUILDING | self::F_COUNTRY | self::F_GEOM | self::F_POSTAL_CODE | self::F_STREET | self::F_GEOGRAPHICAL_UNITS; - public const F_AS_STRING = 0b00010000; + final public const F_AS_STRING = 0b00010000; - public const F_ATTRIBUTES = 0b01000000; + final public const F_ATTRIBUTES = 0b01000000; - public const F_BUILDING = 0b00001000; + final public const F_BUILDING = 0b00001000; - public const F_COUNTRY = 0b00000001; + final public const F_COUNTRY = 0b00000001; - public const F_GEOGRAPHICAL_UNITS = 0b1000000000; + final public const F_GEOGRAPHICAL_UNITS = 0b1000000000; - public const F_GEOM = 0b00100000; + final public const F_GEOM = 0b00100000; - public const F_POSTAL_CODE = 0b00000010; + final public const F_POSTAL_CODE = 0b00000010; - public const F_STREET = 0b00000100; + final public const F_STREET = 0b00000100; private const ALL = [ 'country' => self::F_COUNTRY, @@ -84,7 +84,7 @@ class ExportAddressHelper */ private ?array $unitRefsKeysCache = []; - public function __construct(private AddressRender $addressRender, private AddressRepository $addressRepository, private GeographicalUnitLayerRepositoryInterface $geographicalUnitLayerRepository, private TranslatableStringHelperInterface $translatableStringHelper) + public function __construct(private readonly AddressRender $addressRender, private readonly AddressRepository $addressRepository, private readonly GeographicalUnitLayerRepositoryInterface $geographicalUnitLayerRepository, private readonly TranslatableStringHelperInterface $translatableStringHelper) { } @@ -253,7 +253,7 @@ class ExportAddressHelper public function getLabel($key, array $values, $data, string $prefix = '', string $translationPrefix = 'export.address_helper.'): callable { - $sanitizedKey = substr($key, strlen($prefix)); + $sanitizedKey = substr((string) $key, strlen($prefix)); switch ($sanitizedKey) { case 'id': @@ -333,7 +333,7 @@ class ExportAddressHelper }; default: - $layerNamesKeys = array_merge($this->generateKeysForUnitsNames($prefix), $this->generateKeysForUnitsRefs($prefix)); + $layerNamesKeys = [...$this->generateKeysForUnitsNames($prefix), ...$this->generateKeysForUnitsRefs($prefix)]; if (array_key_exists($key, $layerNamesKeys)) { return function ($value) use ($key, $layerNamesKeys) { diff --git a/src/Bundle/ChillMainBundle/Export/Helper/TranslatableStringExportLabelHelper.php b/src/Bundle/ChillMainBundle/Export/Helper/TranslatableStringExportLabelHelper.php index 37a41325e..9077ad8b0 100644 --- a/src/Bundle/ChillMainBundle/Export/Helper/TranslatableStringExportLabelHelper.php +++ b/src/Bundle/ChillMainBundle/Export/Helper/TranslatableStringExportLabelHelper.php @@ -21,7 +21,7 @@ use Chill\MainBundle\Templating\TranslatableStringHelperInterface; */ class TranslatableStringExportLabelHelper { - public function __construct(private TranslatableStringHelperInterface $translatableStringHelper) + public function __construct(private readonly TranslatableStringHelperInterface $translatableStringHelper) { } diff --git a/src/Bundle/ChillMainBundle/Export/Helper/UserHelper.php b/src/Bundle/ChillMainBundle/Export/Helper/UserHelper.php index cb13ac1c9..d77e7190e 100644 --- a/src/Bundle/ChillMainBundle/Export/Helper/UserHelper.php +++ b/src/Bundle/ChillMainBundle/Export/Helper/UserHelper.php @@ -18,7 +18,7 @@ use const SORT_NUMERIC; class UserHelper { - public function __construct(private UserRender $userRender, private UserRepositoryInterface $userRepository) + public function __construct(private readonly UserRender $userRender, private readonly UserRepositoryInterface $userRepository) { } diff --git a/src/Bundle/ChillMainBundle/Form/DataMapper/PrivateCommentDataMapper.php b/src/Bundle/ChillMainBundle/Form/DataMapper/PrivateCommentDataMapper.php index 18fceeb5c..10f9c26e3 100644 --- a/src/Bundle/ChillMainBundle/Form/DataMapper/PrivateCommentDataMapper.php +++ b/src/Bundle/ChillMainBundle/Form/DataMapper/PrivateCommentDataMapper.php @@ -19,7 +19,7 @@ use Symfony\Component\Security\Core\Security; final class PrivateCommentDataMapper extends AbstractType implements DataMapperInterface { - public function __construct(private Security $security) + public function __construct(private readonly Security $security) { } diff --git a/src/Bundle/ChillMainBundle/Form/DataMapper/ScopePickerDataMapper.php b/src/Bundle/ChillMainBundle/Form/DataMapper/ScopePickerDataMapper.php index bb5f64895..267927ff1 100644 --- a/src/Bundle/ChillMainBundle/Form/DataMapper/ScopePickerDataMapper.php +++ b/src/Bundle/ChillMainBundle/Form/DataMapper/ScopePickerDataMapper.php @@ -16,7 +16,7 @@ use Symfony\Component\Form\DataMapperInterface; class ScopePickerDataMapper implements DataMapperInterface { - public function __construct(private ?Scope $scope = null) + public function __construct(private readonly ?Scope $scope = null) { } diff --git a/src/Bundle/ChillMainBundle/Form/DataTransformer/IdToEntityDataTransformer.php b/src/Bundle/ChillMainBundle/Form/DataTransformer/IdToEntityDataTransformer.php index 48dd0dc7c..d392fb90a 100644 --- a/src/Bundle/ChillMainBundle/Form/DataTransformer/IdToEntityDataTransformer.php +++ b/src/Bundle/ChillMainBundle/Form/DataTransformer/IdToEntityDataTransformer.php @@ -29,12 +29,12 @@ use function call_user_func; */ class IdToEntityDataTransformer implements DataTransformerInterface { - private Closure $getId; + private readonly Closure $getId; /** * @param Closure $getId */ - public function __construct(private ObjectRepository $repository, private bool $multiple = false, ?callable $getId = null) + public function __construct(private readonly ObjectRepository $repository, private readonly bool $multiple = false, ?callable $getId = null) { $this->getId = $getId ?? static fn (object $o) => $o->getId(); } diff --git a/src/Bundle/ChillMainBundle/Form/Event/CustomizeFormEvent.php b/src/Bundle/ChillMainBundle/Form/Event/CustomizeFormEvent.php index 2f64f0699..a816e7371 100644 --- a/src/Bundle/ChillMainBundle/Form/Event/CustomizeFormEvent.php +++ b/src/Bundle/ChillMainBundle/Form/Event/CustomizeFormEvent.php @@ -15,7 +15,7 @@ use Symfony\Component\Form\FormBuilderInterface; class CustomizeFormEvent extends \Symfony\Component\EventDispatcher\Event { - public const NAME = 'chill_main.customize_form'; + final public const NAME = 'chill_main.customize_form'; public function __construct(protected string $type, protected FormBuilderInterface $builder) { diff --git a/src/Bundle/ChillMainBundle/Form/LocationFormType.php b/src/Bundle/ChillMainBundle/Form/LocationFormType.php index dd102dfc6..e4748d850 100644 --- a/src/Bundle/ChillMainBundle/Form/LocationFormType.php +++ b/src/Bundle/ChillMainBundle/Form/LocationFormType.php @@ -24,7 +24,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver; final class LocationFormType extends AbstractType { - public function __construct(private TranslatableStringHelper $translatableStringHelper) + public function __construct(private readonly TranslatableStringHelper $translatableStringHelper) { } diff --git a/src/Bundle/ChillMainBundle/Form/PermissionsGroupType.php b/src/Bundle/ChillMainBundle/Form/PermissionsGroupType.php index 16aafeb41..1ff8b2647 100644 --- a/src/Bundle/ChillMainBundle/Form/PermissionsGroupType.php +++ b/src/Bundle/ChillMainBundle/Form/PermissionsGroupType.php @@ -24,7 +24,7 @@ use function count; class PermissionsGroupType extends AbstractType { - public const FLAG_SCOPE = 'permissions_group'; + final public const FLAG_SCOPE = 'permissions_group'; /** * @var PermissionsGroupFlagProvider[] diff --git a/src/Bundle/ChillMainBundle/Form/Type/ChillPhoneNumberType.php b/src/Bundle/ChillMainBundle/Form/Type/ChillPhoneNumberType.php index 159d2ec1e..700726619 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/ChillPhoneNumberType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/ChillPhoneNumberType.php @@ -20,9 +20,9 @@ use Symfony\Component\OptionsResolver\OptionsResolver; class ChillPhoneNumberType extends AbstractType { - private string $defaultCarrierCode; + private readonly string $defaultCarrierCode; - private PhoneNumberUtil $phoneNumberUtil; + private readonly PhoneNumberUtil $phoneNumberUtil; public function __construct(ParameterBagInterface $parameterBag) { diff --git a/src/Bundle/ChillMainBundle/Form/Type/ComposedRoleScopeType.php b/src/Bundle/ChillMainBundle/Form/Type/ComposedRoleScopeType.php index d9a469dec..4b9b95031 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/ComposedRoleScopeType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/ComposedRoleScopeType.php @@ -44,7 +44,7 @@ class ComposedRoleScopeType extends AbstractType private $rolesWithoutScope = []; public function __construct( - private TranslatableStringHelper $translatableStringHelper, + private readonly TranslatableStringHelper $translatableStringHelper, RoleProvider $roleProvider ) { $this->roles = $roleProvider->getRoles(); diff --git a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/AddressToIdDataTransformer.php b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/AddressToIdDataTransformer.php index a9774d06e..c04a4b158 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/AddressToIdDataTransformer.php +++ b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/AddressToIdDataTransformer.php @@ -15,7 +15,7 @@ use Chill\MainBundle\Repository\AddressRepository; use Symfony\Component\Form\DataTransformerInterface; use Symfony\Component\Form\Exception\TransformationFailedException; -final class AddressToIdDataTransformer implements DataTransformerInterface +final readonly class AddressToIdDataTransformer implements DataTransformerInterface { public function __construct(private AddressRepository $addressRepository) { diff --git a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/CenterTransformer.php b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/CenterTransformer.php index b195a5905..e9c745118 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/CenterTransformer.php +++ b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/CenterTransformer.php @@ -23,7 +23,7 @@ use function count; class CenterTransformer implements DataTransformerInterface { - public function __construct(private CenterRepository $centerRepository, private bool $multiple = false) + public function __construct(private readonly CenterRepository $centerRepository, private readonly bool $multiple = false) { } @@ -40,7 +40,7 @@ class CenterTransformer implements DataTransformerInterface $ids = []; if ($this->multiple) { - $ids = explode(',', $id); + $ids = explode(',', (string) $id); } else { $ids[] = (int) $id; } diff --git a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php index 9ab91222c..044946716 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php +++ b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php @@ -25,7 +25,7 @@ use function array_key_exists; class EntityToJsonTransformer implements DataTransformerInterface { - public function __construct(private DenormalizerInterface $denormalizer, private SerializerInterface $serializer, private bool $multiple, private string $type) + public function __construct(private readonly DenormalizerInterface $denormalizer, private readonly SerializerInterface $serializer, private readonly bool $multiple, private readonly string $type) { } @@ -35,7 +35,7 @@ class EntityToJsonTransformer implements DataTransformerInterface return null; } - $denormalized = json_decode($value, true, 512, JSON_THROW_ON_ERROR); + $denormalized = json_decode((string) $value, true, 512, JSON_THROW_ON_ERROR); if ($this->multiple) { if (null === $denormalized) { diff --git a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/MultipleObjectsToIdTransformer.php b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/MultipleObjectsToIdTransformer.php index 345df74bd..1284cbaa8 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/MultipleObjectsToIdTransformer.php +++ b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/MultipleObjectsToIdTransformer.php @@ -17,7 +17,7 @@ use Symfony\Component\Form\DataTransformerInterface; class MultipleObjectsToIdTransformer implements DataTransformerInterface { - public function __construct(private EntityManagerInterface $em, private ?string $class = null) + public function __construct(private readonly EntityManagerInterface $em, private readonly ?string $class = null) { } diff --git a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/ObjectToIdTransformer.php b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/ObjectToIdTransformer.php index fe87fdb6c..23bc4c5ca 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/ObjectToIdTransformer.php +++ b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/ObjectToIdTransformer.php @@ -17,7 +17,7 @@ use Symfony\Component\Form\Exception\TransformationFailedException; class ObjectToIdTransformer implements DataTransformerInterface { - public function __construct(private EntityManagerInterface $em, private ?string $class = null) + public function __construct(private readonly EntityManagerInterface $em, private readonly ?string $class = null) { } diff --git a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/PostalCodeToIdTransformer.php b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/PostalCodeToIdTransformer.php index d18e3de8c..643ac0e62 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/PostalCodeToIdTransformer.php +++ b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/PostalCodeToIdTransformer.php @@ -20,7 +20,7 @@ use function is_int; class PostalCodeToIdTransformer implements DataTransformerInterface { - public function __construct(private PostalCodeRepositoryInterface $postalCodeRepository) + public function __construct(private readonly PostalCodeRepositoryInterface $postalCodeRepository) { } diff --git a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/ScopeTransformer.php b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/ScopeTransformer.php index bdd981706..81179c0be 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/ScopeTransformer.php +++ b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/ScopeTransformer.php @@ -18,7 +18,7 @@ use Symfony\Component\Form\Exception\TransformationFailedException; class ScopeTransformer implements DataTransformerInterface { - public function __construct(private EntityManagerInterface $em) + public function __construct(private readonly EntityManagerInterface $em) { } diff --git a/src/Bundle/ChillMainBundle/Form/Type/Export/ExportType.php b/src/Bundle/ChillMainBundle/Form/Type/Export/ExportType.php index bfb408cca..cf47d528b 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/Export/ExportType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/Export/ExportType.php @@ -20,13 +20,13 @@ use Symfony\Component\OptionsResolver\OptionsResolver; class ExportType extends AbstractType { - public const AGGREGATOR_KEY = 'aggregators'; + final public const AGGREGATOR_KEY = 'aggregators'; - public const EXPORT_KEY = 'export'; + final public const EXPORT_KEY = 'export'; - public const FILTER_KEY = 'filters'; + final public const FILTER_KEY = 'filters'; - public const PICK_FORMATTER_KEY = 'pick_formatter'; + final public const PICK_FORMATTER_KEY = 'pick_formatter'; /** * @var ExportManager diff --git a/src/Bundle/ChillMainBundle/Form/Type/Export/FilterType.php b/src/Bundle/ChillMainBundle/Form/Type/Export/FilterType.php index 153f8946b..6446304a6 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/Export/FilterType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/Export/FilterType.php @@ -19,7 +19,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver; class FilterType extends AbstractType { - public const ENABLED_FIELD = 'enabled'; + final public const ENABLED_FIELD = 'enabled'; public function __construct() { diff --git a/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php b/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php index ef8dfb62e..598d983fb 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php @@ -33,13 +33,13 @@ final class PickCenterType extends AbstractType { public const CENTERS_IDENTIFIERS = 'c'; - private UserInterface $user; + private readonly UserInterface $user; public function __construct( TokenStorageInterface $tokenStorage, - private ExportManager $exportManager, - private RegroupmentRepository $regroupmentRepository, - private AuthorizationHelperInterface $authorizationHelper + private readonly ExportManager $exportManager, + private readonly RegroupmentRepository $regroupmentRepository, + private readonly AuthorizationHelperInterface $authorizationHelper ) { $this->user = $tokenStorage->getToken()->getUser(); } diff --git a/src/Bundle/ChillMainBundle/Form/Type/Listing/FilterOrderType.php b/src/Bundle/ChillMainBundle/Form/Type/Listing/FilterOrderType.php index d0dbfbe53..6a9c57420 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/Listing/FilterOrderType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/Listing/FilterOrderType.php @@ -27,7 +27,7 @@ use function count; final class FilterOrderType extends \Symfony\Component\Form\AbstractType { - public function __construct(private RequestStack $requestStack) + public function __construct(private readonly RequestStack $requestStack) { } diff --git a/src/Bundle/ChillMainBundle/Form/Type/PickAddressType.php b/src/Bundle/ChillMainBundle/Form/Type/PickAddressType.php index dbbdf502f..2bb1dad0e 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PickAddressType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PickAddressType.php @@ -43,7 +43,7 @@ use function uniqid; */ final class PickAddressType extends AbstractType { - public function __construct(private AddressToIdDataTransformer $addressToIdDataTransformer, private TranslatorInterface $translator) + public function __construct(private readonly AddressToIdDataTransformer $addressToIdDataTransformer, private readonly TranslatorInterface $translator) { } diff --git a/src/Bundle/ChillMainBundle/Form/Type/PickCivilityType.php b/src/Bundle/ChillMainBundle/Form/Type/PickCivilityType.php index 2a7ab259c..abe190de5 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PickCivilityType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PickCivilityType.php @@ -21,7 +21,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver; class PickCivilityType extends AbstractType { - public function __construct(private TranslatableStringHelper $translatableStringHelper) + public function __construct(private readonly TranslatableStringHelper $translatableStringHelper) { } diff --git a/src/Bundle/ChillMainBundle/Form/Type/PickLocationTypeType.php b/src/Bundle/ChillMainBundle/Form/Type/PickLocationTypeType.php index cc9737270..7fb50fd4a 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PickLocationTypeType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PickLocationTypeType.php @@ -19,7 +19,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver; class PickLocationTypeType extends AbstractType { - public function __construct(private TranslatableStringHelper $translatableStringHelper) + public function __construct(private readonly TranslatableStringHelper $translatableStringHelper) { } diff --git a/src/Bundle/ChillMainBundle/Form/Type/PickPostalCodeType.php b/src/Bundle/ChillMainBundle/Form/Type/PickPostalCodeType.php index 2ef990704..041176905 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PickPostalCodeType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PickPostalCodeType.php @@ -21,7 +21,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver; class PickPostalCodeType extends AbstractType { - public function __construct(private PostalCodeToIdTransformer $postalCodeToIdTransformer) + public function __construct(private readonly PostalCodeToIdTransformer $postalCodeToIdTransformer) { } diff --git a/src/Bundle/ChillMainBundle/Form/Type/PickRollingDateType.php b/src/Bundle/ChillMainBundle/Form/Type/PickRollingDateType.php index a4492526f..b60401a46 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PickRollingDateType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PickRollingDateType.php @@ -55,7 +55,7 @@ class PickRollingDateType extends AbstractType 'class' => RollingDate::class, 'empty_data' => new RollingDate(RollingDate::T_TODAY), 'constraints' => [ - new Callback([$this, 'validate']), + new Callback($this->validate(...)), ], ]); } diff --git a/src/Bundle/ChillMainBundle/Form/Type/PickUserDynamicType.php b/src/Bundle/ChillMainBundle/Form/Type/PickUserDynamicType.php index 1b0a3c6e0..a12042dab 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PickUserDynamicType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PickUserDynamicType.php @@ -27,7 +27,7 @@ use Symfony\Component\Serializer\SerializerInterface; */ class PickUserDynamicType extends AbstractType { - public function __construct(private DenormalizerInterface $denormalizer, private SerializerInterface $serializer, private NormalizerInterface $normalizer) + public function __construct(private readonly DenormalizerInterface $denormalizer, private readonly SerializerInterface $serializer, private readonly NormalizerInterface $normalizer) { } diff --git a/src/Bundle/ChillMainBundle/Form/Type/PickUserLocationType.php b/src/Bundle/ChillMainBundle/Form/Type/PickUserLocationType.php index cc8171c4a..2fb695e85 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PickUserLocationType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PickUserLocationType.php @@ -20,7 +20,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver; class PickUserLocationType extends AbstractType { - public function __construct(private TranslatableStringHelper $translatableStringHelper, private LocationRepository $locationRepository) + public function __construct(private readonly TranslatableStringHelper $translatableStringHelper, private readonly LocationRepository $locationRepository) { } diff --git a/src/Bundle/ChillMainBundle/Form/Type/ScopePickerType.php b/src/Bundle/ChillMainBundle/Form/Type/ScopePickerType.php index 28894a421..8229d4074 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/ScopePickerType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/ScopePickerType.php @@ -42,7 +42,7 @@ use function count; */ class ScopePickerType extends AbstractType { - public function __construct(private AuthorizationHelperInterface $authorizationHelper, private Security $security, private TranslatableStringHelperInterface $translatableStringHelper) + public function __construct(private readonly AuthorizationHelperInterface $authorizationHelper, private readonly Security $security, private readonly TranslatableStringHelperInterface $translatableStringHelper) { } diff --git a/src/Bundle/ChillMainBundle/Form/Type/Select2CountryType.php b/src/Bundle/ChillMainBundle/Form/Type/Select2CountryType.php index c22c3f523..eaaf0e9b2 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/Select2CountryType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/Select2CountryType.php @@ -29,7 +29,7 @@ use const SORT_STRING; */ class Select2CountryType extends AbstractType { - public function __construct(private RequestStack $requestStack, private ObjectManager $em, protected TranslatableStringHelper $translatableStringHelper, protected ParameterBagInterface $parameterBag) + public function __construct(private readonly RequestStack $requestStack, private readonly ObjectManager $em, protected TranslatableStringHelper $translatableStringHelper, protected ParameterBagInterface $parameterBag) { } diff --git a/src/Bundle/ChillMainBundle/Form/Type/Select2LanguageType.php b/src/Bundle/ChillMainBundle/Form/Type/Select2LanguageType.php index 7e5adb0cf..7e6d1589a 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/Select2LanguageType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/Select2LanguageType.php @@ -29,7 +29,7 @@ use const SORT_STRING; */ class Select2LanguageType extends AbstractType { - public function __construct(private RequestStack $requestStack, private ObjectManager $em, protected TranslatableStringHelper $translatableStringHelper, protected ParameterBagInterface $parameterBag) + public function __construct(private readonly RequestStack $requestStack, private readonly ObjectManager $em, protected TranslatableStringHelper $translatableStringHelper, protected ParameterBagInterface $parameterBag) { } diff --git a/src/Bundle/ChillMainBundle/Form/Type/TranslatableStringFormType.php b/src/Bundle/ChillMainBundle/Form/Type/TranslatableStringFormType.php index 580f2ca09..118b91226 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/TranslatableStringFormType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/TranslatableStringFormType.php @@ -28,7 +28,7 @@ class TranslatableStringFormType extends AbstractType private $frameworkTranslatorFallback; // The langagues used for the translation - public function __construct(private array $availableLanguages, Translator $translator) + public function __construct(private readonly array $availableLanguages, Translator $translator) { $this->frameworkTranslatorFallback = $translator->getFallbackLocales(); } diff --git a/src/Bundle/ChillMainBundle/Form/Type/UserPickerType.php b/src/Bundle/ChillMainBundle/Form/Type/UserPickerType.php index 38987d8fb..791063f0a 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/UserPickerType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/UserPickerType.php @@ -49,7 +49,7 @@ class UserPickerType extends AbstractType TokenStorageInterface $tokenStorage, protected UserRepository $userRepository, protected UserACLAwareRepositoryInterface $userACLAwareRepository, - private UserRender $userRender + private readonly UserRender $userRender ) { $this->authorizationHelper = $authorizationHelper; $this->tokenStorage = $tokenStorage; diff --git a/src/Bundle/ChillMainBundle/Form/UserType.php b/src/Bundle/ChillMainBundle/Form/UserType.php index 63f319de4..c787b1207 100644 --- a/src/Bundle/ChillMainBundle/Form/UserType.php +++ b/src/Bundle/ChillMainBundle/Form/UserType.php @@ -35,7 +35,7 @@ use Symfony\Component\Validator\Constraints\Regex; class UserType extends AbstractType { - public function __construct(private TranslatableStringHelper $translatableStringHelper, protected ParameterBagInterface $parameterBag) + public function __construct(private readonly TranslatableStringHelper $translatableStringHelper, protected ParameterBagInterface $parameterBag) { } diff --git a/src/Bundle/ChillMainBundle/Form/WorkflowStepType.php b/src/Bundle/ChillMainBundle/Form/WorkflowStepType.php index e967d299f..54b1a9fd7 100644 --- a/src/Bundle/ChillMainBundle/Form/WorkflowStepType.php +++ b/src/Bundle/ChillMainBundle/Form/WorkflowStepType.php @@ -36,7 +36,7 @@ use function array_key_exists; class WorkflowStepType extends AbstractType { - public function __construct(private EntityWorkflowManager $entityWorkflowManager, private Registry $registry, private TranslatableStringHelperInterface $translatableStringHelper) + public function __construct(private readonly EntityWorkflowManager $entityWorkflowManager, private readonly Registry $registry, private readonly TranslatableStringHelperInterface $translatableStringHelper) { } diff --git a/src/Bundle/ChillMainBundle/Notification/Counter/NotificationByUserCounter.php b/src/Bundle/ChillMainBundle/Notification/Counter/NotificationByUserCounter.php index cbafdcfaf..50da55240 100644 --- a/src/Bundle/ChillMainBundle/Notification/Counter/NotificationByUserCounter.php +++ b/src/Bundle/ChillMainBundle/Notification/Counter/NotificationByUserCounter.php @@ -23,7 +23,7 @@ use Doctrine\ORM\Event\PreFlushEventArgs; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Security\Core\User\UserInterface; -final class NotificationByUserCounter implements NotificationCounterInterface +final readonly class NotificationByUserCounter implements NotificationCounterInterface { public function __construct(private CacheItemPoolInterface $cacheItemPool, private NotificationRepository $notificationRepository) { diff --git a/src/Bundle/ChillMainBundle/Notification/Email/NotificationMailer.php b/src/Bundle/ChillMainBundle/Notification/Email/NotificationMailer.php index 3d63c28a9..0850e1e4a 100644 --- a/src/Bundle/ChillMainBundle/Notification/Email/NotificationMailer.php +++ b/src/Bundle/ChillMainBundle/Notification/Email/NotificationMailer.php @@ -25,7 +25,7 @@ use Symfony\Contracts\Translation\TranslatorInterface; class NotificationMailer { - public function __construct(private MailerInterface $mailer, private LoggerInterface $logger, private TranslatorInterface $translator) + public function __construct(private readonly MailerInterface $mailer, private readonly LoggerInterface $logger, private readonly TranslatorInterface $translator) { } diff --git a/src/Bundle/ChillMainBundle/Notification/EventListener/PersistNotificationOnTerminateEventSubscriber.php b/src/Bundle/ChillMainBundle/Notification/EventListener/PersistNotificationOnTerminateEventSubscriber.php index 0601f0141..7051ee05e 100644 --- a/src/Bundle/ChillMainBundle/Notification/EventListener/PersistNotificationOnTerminateEventSubscriber.php +++ b/src/Bundle/ChillMainBundle/Notification/EventListener/PersistNotificationOnTerminateEventSubscriber.php @@ -19,7 +19,7 @@ use function count; class PersistNotificationOnTerminateEventSubscriber implements EventSubscriberInterface { - public function __construct(private EntityManagerInterface $em, private NotificationPersisterInterface $persister) + public function __construct(private readonly EntityManagerInterface $em, private readonly NotificationPersisterInterface $persister) { } diff --git a/src/Bundle/ChillMainBundle/Notification/Mailer.php b/src/Bundle/ChillMainBundle/Notification/Mailer.php index b65d29c8d..082bff84c 100644 --- a/src/Bundle/ChillMainBundle/Notification/Mailer.php +++ b/src/Bundle/ChillMainBundle/Notification/Mailer.php @@ -40,7 +40,7 @@ class Mailer * @param $routeParameters * @param mixed[] $routeParameters */ - public function __construct(private MailerInterface $mailer, private LoggerInterface $logger, private EngineInterface $twig, private RouterInterface $router, private TranslatorInterface $translator, protected $routeParameters) + public function __construct(private readonly MailerInterface $mailer, private readonly LoggerInterface $logger, private readonly EngineInterface $twig, private readonly RouterInterface $router, private readonly TranslatorInterface $translator, protected $routeParameters) { } diff --git a/src/Bundle/ChillMainBundle/Notification/NotificationHandlerManager.php b/src/Bundle/ChillMainBundle/Notification/NotificationHandlerManager.php index d39bc8a00..04116a434 100644 --- a/src/Bundle/ChillMainBundle/Notification/NotificationHandlerManager.php +++ b/src/Bundle/ChillMainBundle/Notification/NotificationHandlerManager.php @@ -15,7 +15,7 @@ use Chill\MainBundle\Entity\Notification; use Chill\MainBundle\Notification\Exception\NotificationHandlerNotFound; use Doctrine\ORM\EntityManagerInterface; -final class NotificationHandlerManager +final readonly class NotificationHandlerManager { public function __construct(private iterable $handlers, private EntityManagerInterface $em) { diff --git a/src/Bundle/ChillMainBundle/Notification/NotificationPresence.php b/src/Bundle/ChillMainBundle/Notification/NotificationPresence.php index 51cb73ccf..ad926d4be 100644 --- a/src/Bundle/ChillMainBundle/Notification/NotificationPresence.php +++ b/src/Bundle/ChillMainBundle/Notification/NotificationPresence.php @@ -24,7 +24,7 @@ class NotificationPresence { private array $cache = []; - public function __construct(private Security $security, private NotificationRepository $notificationRepository) + public function __construct(private readonly Security $security, private readonly NotificationRepository $notificationRepository) { } diff --git a/src/Bundle/ChillMainBundle/Notification/Templating/NotificationTwigExtensionRuntime.php b/src/Bundle/ChillMainBundle/Notification/Templating/NotificationTwigExtensionRuntime.php index 3c31b7201..d0f3b0930 100644 --- a/src/Bundle/ChillMainBundle/Notification/Templating/NotificationTwigExtensionRuntime.php +++ b/src/Bundle/ChillMainBundle/Notification/Templating/NotificationTwigExtensionRuntime.php @@ -21,7 +21,7 @@ use Twig\Extension\RuntimeExtensionInterface; class NotificationTwigExtensionRuntime implements RuntimeExtensionInterface { - public function __construct(private FormFactoryInterface $formFactory, private NotificationPresence $notificationPresence, private UrlGeneratorInterface $urlGenerator) + public function __construct(private readonly FormFactoryInterface $formFactory, private readonly NotificationPresence $notificationPresence, private readonly UrlGeneratorInterface $urlGenerator) { } diff --git a/src/Bundle/ChillMainBundle/Pagination/ChillItemsPerPageTwig.php b/src/Bundle/ChillMainBundle/Pagination/ChillItemsPerPageTwig.php index 97d4629c7..d66adb974 100644 --- a/src/Bundle/ChillMainBundle/Pagination/ChillItemsPerPageTwig.php +++ b/src/Bundle/ChillMainBundle/Pagination/ChillItemsPerPageTwig.php @@ -25,7 +25,7 @@ class ChillItemsPerPageTwig extends AbstractExtension return [ new TwigFunction( 'chill_items_per_page', - [$this, 'paginationRender'], + $this->paginationRender(...), [ 'needs_environment' => true, 'is_safe' => ['html'], diff --git a/src/Bundle/ChillMainBundle/Pagination/ChillPaginationTwig.php b/src/Bundle/ChillMainBundle/Pagination/ChillPaginationTwig.php index 2c75ad41a..e5883d593 100644 --- a/src/Bundle/ChillMainBundle/Pagination/ChillPaginationTwig.php +++ b/src/Bundle/ChillMainBundle/Pagination/ChillPaginationTwig.php @@ -20,16 +20,16 @@ use Twig\TwigFunction; */ class ChillPaginationTwig extends AbstractExtension { - public const LONG_TEMPLATE = '@ChillMain/Pagination/long.html.twig'; + final public const LONG_TEMPLATE = '@ChillMain/Pagination/long.html.twig'; - public const SHORT_TEMPLATE = '@ChillMain/Pagination/short.html.twig'; + final public const SHORT_TEMPLATE = '@ChillMain/Pagination/short.html.twig'; public function getFunctions() { return [ new TwigFunction( 'chill_pagination', - [$this, 'paginationRender'], + $this->paginationRender(...), [ 'needs_environment' => true, 'is_safe' => ['html'], diff --git a/src/Bundle/ChillMainBundle/Pagination/PaginatorFactory.php b/src/Bundle/ChillMainBundle/Pagination/PaginatorFactory.php index 60f9a6bc0..c75348910 100644 --- a/src/Bundle/ChillMainBundle/Pagination/PaginatorFactory.php +++ b/src/Bundle/ChillMainBundle/Pagination/PaginatorFactory.php @@ -19,11 +19,11 @@ use Symfony\Component\Routing\RouterInterface; */ class PaginatorFactory { - public const DEFAULT_CURRENT_PAGE_KEY = 'page'; + final public const DEFAULT_CURRENT_PAGE_KEY = 'page'; - public const DEFAULT_ITEM_PER_NUMBER_KEY = 'item_per_page'; + final public const DEFAULT_ITEM_PER_NUMBER_KEY = 'item_per_page'; - public const DEFAULT_PAGE_NUMBER = 1; + final public const DEFAULT_PAGE_NUMBER = 1; /** * @param int $itemPerPage @@ -32,11 +32,11 @@ class PaginatorFactory /** * the request stack. */ - private RequestStack $requestStack, + private readonly RequestStack $requestStack, /** * the router and generator for url. */ - private RouterInterface $router, + private readonly RouterInterface $router, /** * the default item per page. This may be overriden by * the request or inside the paginator. diff --git a/src/Bundle/ChillMainBundle/Phonenumber/PhonenumberHelper.php b/src/Bundle/ChillMainBundle/Phonenumber/PhonenumberHelper.php index 0c6fbbf03..27bd7051d 100644 --- a/src/Bundle/ChillMainBundle/Phonenumber/PhonenumberHelper.php +++ b/src/Bundle/ChillMainBundle/Phonenumber/PhonenumberHelper.php @@ -35,28 +35,28 @@ final class PhonenumberHelper implements PhoneNumberHelperInterface public const LOOKUP_URI = 'https://lookups.twilio.com/v1/PhoneNumbers/%s'; - private array $config; + private readonly array $config; private bool $isConfigured = false; - private PhonenumberUtil $phoneNumberUtil; + private readonly PhonenumberUtil $phoneNumberUtil; private Client $twilioClient; public function __construct( - private CacheItemPoolInterface $cachePool, + private readonly CacheItemPoolInterface $cachePool, ParameterBagInterface $parameterBag, - private LoggerInterface $logger + private readonly LoggerInterface $logger ) { $this->config = $config = $parameterBag->get('chill_main.phone_helper'); if ( array_key_exists('twilio_sid', $config) && !empty($config['twilio_sid']) - && strlen($config['twilio_sid']) > 2 + && strlen((string) $config['twilio_sid']) > 2 && array_key_exists('twilio_secret', $config) && !empty($config['twilio_secret']) - && strlen($config['twilio_secret']) > 2 + && strlen((string) $config['twilio_secret']) > 2 ) { $this->twilioClient = new Client([ 'auth' => [$config['twilio_sid'], $config['twilio_secret']], diff --git a/src/Bundle/ChillMainBundle/Phonenumber/Templating.php b/src/Bundle/ChillMainBundle/Phonenumber/Templating.php index 6f4f09bfd..69da56eca 100644 --- a/src/Bundle/ChillMainBundle/Phonenumber/Templating.php +++ b/src/Bundle/ChillMainBundle/Phonenumber/Templating.php @@ -28,7 +28,7 @@ class Templating extends AbstractExtension public function getFilters() { return [ - new TwigFilter('chill_format_phonenumber', [$this, 'formatPhonenumber']), + new TwigFilter('chill_format_phonenumber', $this->formatPhonenumber(...)), ]; } } diff --git a/src/Bundle/ChillMainBundle/Redis/RedisConnectionFactory.php b/src/Bundle/ChillMainBundle/Redis/RedisConnectionFactory.php index f5a2515c8..fdf81d441 100644 --- a/src/Bundle/ChillMainBundle/Redis/RedisConnectionFactory.php +++ b/src/Bundle/ChillMainBundle/Redis/RedisConnectionFactory.php @@ -16,13 +16,13 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface; final class RedisConnectionFactory implements EventSubscriberInterface { - private string $host; + private readonly string $host; - private int $port; + private readonly int $port; - private ChillRedis $redis; + private readonly ChillRedis $redis; - private int $timeout; + private readonly int $timeout; public function __construct($parameters) { diff --git a/src/Bundle/ChillMainBundle/Repository/AddressReferenceRepository.php b/src/Bundle/ChillMainBundle/Repository/AddressReferenceRepository.php index d301940ae..8cb4b2084 100644 --- a/src/Bundle/ChillMainBundle/Repository/AddressReferenceRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/AddressReferenceRepository.php @@ -28,9 +28,9 @@ use function trim; final class AddressReferenceRepository implements ObjectRepository { - private EntityManagerInterface $entityManager; + private readonly EntityManagerInterface $entityManager; - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct(EntityManagerInterface $entityManager) { diff --git a/src/Bundle/ChillMainBundle/Repository/AddressRepository.php b/src/Bundle/ChillMainBundle/Repository/AddressRepository.php index 622a9cb65..074b1fc32 100644 --- a/src/Bundle/ChillMainBundle/Repository/AddressRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/AddressRepository.php @@ -19,7 +19,7 @@ use Doctrine\Persistence\ObjectRepository; final class AddressRepository implements ObjectRepository { - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct(EntityManagerInterface $entityManager) { diff --git a/src/Bundle/ChillMainBundle/Repository/CenterRepository.php b/src/Bundle/ChillMainBundle/Repository/CenterRepository.php index eaa0a6b1e..1f498a666 100644 --- a/src/Bundle/ChillMainBundle/Repository/CenterRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/CenterRepository.php @@ -17,7 +17,7 @@ use Doctrine\ORM\EntityRepository; final class CenterRepository implements CenterRepositoryInterface { - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct(EntityManagerInterface $entityManager) { diff --git a/src/Bundle/ChillMainBundle/Repository/CivilityRepository.php b/src/Bundle/ChillMainBundle/Repository/CivilityRepository.php index 70b4a2bc4..982d3dd4c 100644 --- a/src/Bundle/ChillMainBundle/Repository/CivilityRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/CivilityRepository.php @@ -17,7 +17,7 @@ use Doctrine\ORM\EntityRepository; class CivilityRepository implements CivilityRepositoryInterface { - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct(EntityManagerInterface $entityManager) { diff --git a/src/Bundle/ChillMainBundle/Repository/CountryRepository.php b/src/Bundle/ChillMainBundle/Repository/CountryRepository.php index 699303bc8..701019dba 100644 --- a/src/Bundle/ChillMainBundle/Repository/CountryRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/CountryRepository.php @@ -19,7 +19,7 @@ use Doctrine\Persistence\ObjectRepository; final class CountryRepository implements ObjectRepository { - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct(EntityManagerInterface $entityManager) { diff --git a/src/Bundle/ChillMainBundle/Repository/CronJobExecutionRepository.php b/src/Bundle/ChillMainBundle/Repository/CronJobExecutionRepository.php index a3c495d7d..1f369ef4e 100644 --- a/src/Bundle/ChillMainBundle/Repository/CronJobExecutionRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/CronJobExecutionRepository.php @@ -17,7 +17,7 @@ use Doctrine\ORM\EntityRepository; class CronJobExecutionRepository implements CronJobExecutionRepositoryInterface { - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct(EntityManagerInterface $entityManager) { diff --git a/src/Bundle/ChillMainBundle/Repository/GeographicalUnitLayerLayerRepository.php b/src/Bundle/ChillMainBundle/Repository/GeographicalUnitLayerLayerRepository.php index 3f7f96407..11a03c209 100644 --- a/src/Bundle/ChillMainBundle/Repository/GeographicalUnitLayerLayerRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/GeographicalUnitLayerLayerRepository.php @@ -17,7 +17,7 @@ use Doctrine\ORM\EntityRepository; final class GeographicalUnitLayerLayerRepository implements GeographicalUnitLayerRepositoryInterface { - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct(EntityManagerInterface $em) { diff --git a/src/Bundle/ChillMainBundle/Repository/GeographicalUnitRepository.php b/src/Bundle/ChillMainBundle/Repository/GeographicalUnitRepository.php index f5e646dba..a59ac9a8c 100644 --- a/src/Bundle/ChillMainBundle/Repository/GeographicalUnitRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/GeographicalUnitRepository.php @@ -20,7 +20,7 @@ use Doctrine\ORM\QueryBuilder; final class GeographicalUnitRepository implements GeographicalUnitRepositoryInterface { - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct(EntityManagerInterface $em) { diff --git a/src/Bundle/ChillMainBundle/Repository/GroupCenterRepository.php b/src/Bundle/ChillMainBundle/Repository/GroupCenterRepository.php index 07bf728a2..2d9ad8c5a 100644 --- a/src/Bundle/ChillMainBundle/Repository/GroupCenterRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/GroupCenterRepository.php @@ -18,7 +18,7 @@ use Doctrine\Persistence\ObjectRepository; final class GroupCenterRepository implements ObjectRepository { - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct(EntityManagerInterface $entityManager) { diff --git a/src/Bundle/ChillMainBundle/Repository/LanguageRepository.php b/src/Bundle/ChillMainBundle/Repository/LanguageRepository.php index 2e972442e..d8c5d54f8 100644 --- a/src/Bundle/ChillMainBundle/Repository/LanguageRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/LanguageRepository.php @@ -17,7 +17,7 @@ use Doctrine\ORM\EntityRepository; final class LanguageRepository implements LanguageRepositoryInterface { - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct(EntityManagerInterface $entityManager) { diff --git a/src/Bundle/ChillMainBundle/Repository/NotificationRepository.php b/src/Bundle/ChillMainBundle/Repository/NotificationRepository.php index 5677adedb..045610f54 100644 --- a/src/Bundle/ChillMainBundle/Repository/NotificationRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/NotificationRepository.php @@ -25,9 +25,9 @@ final class NotificationRepository implements ObjectRepository { private ?Statement $notificationByRelatedEntityAndUserAssociatedStatement = null; - private EntityRepository $repository; + private readonly EntityRepository $repository; - public function __construct(private EntityManagerInterface $em) + public function __construct(private readonly EntityManagerInterface $em) { $this->repository = $em->getRepository(Notification::class); } diff --git a/src/Bundle/ChillMainBundle/Repository/PermissionsGroupRepository.php b/src/Bundle/ChillMainBundle/Repository/PermissionsGroupRepository.php index 64863bf8c..0af942c75 100644 --- a/src/Bundle/ChillMainBundle/Repository/PermissionsGroupRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/PermissionsGroupRepository.php @@ -18,7 +18,7 @@ use Doctrine\Persistence\ObjectRepository; final class PermissionsGroupRepository implements ObjectRepository { - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct(EntityManagerInterface $entityManager) { diff --git a/src/Bundle/ChillMainBundle/Repository/PostalCodeRepository.php b/src/Bundle/ChillMainBundle/Repository/PostalCodeRepository.php index 32c1322be..3d2b2bb11 100644 --- a/src/Bundle/ChillMainBundle/Repository/PostalCodeRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/PostalCodeRepository.php @@ -22,9 +22,9 @@ use RuntimeException; final class PostalCodeRepository implements PostalCodeRepositoryInterface { - private EntityManagerInterface $entityManager; + private readonly EntityManagerInterface $entityManager; - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct(EntityManagerInterface $entityManager) { diff --git a/src/Bundle/ChillMainBundle/Repository/RegroupmentRepository.php b/src/Bundle/ChillMainBundle/Repository/RegroupmentRepository.php index a28f2f341..d05ceb699 100644 --- a/src/Bundle/ChillMainBundle/Repository/RegroupmentRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/RegroupmentRepository.php @@ -18,7 +18,7 @@ use Doctrine\Persistence\ObjectRepository; final class RegroupmentRepository implements ObjectRepository { - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct(EntityManagerInterface $entityManager) { diff --git a/src/Bundle/ChillMainBundle/Repository/RoleScopeRepository.php b/src/Bundle/ChillMainBundle/Repository/RoleScopeRepository.php index 49162310c..ddf52af5b 100644 --- a/src/Bundle/ChillMainBundle/Repository/RoleScopeRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/RoleScopeRepository.php @@ -18,7 +18,7 @@ use Doctrine\Persistence\ObjectRepository; final class RoleScopeRepository implements ObjectRepository { - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct(EntityManagerInterface $entityManager) { diff --git a/src/Bundle/ChillMainBundle/Repository/SavedExportRepository.php b/src/Bundle/ChillMainBundle/Repository/SavedExportRepository.php index 0011c5c43..c56e9927d 100644 --- a/src/Bundle/ChillMainBundle/Repository/SavedExportRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/SavedExportRepository.php @@ -22,7 +22,7 @@ use Doctrine\Persistence\ObjectRepository; */ class SavedExportRepository implements SavedExportRepositoryInterface { - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct(EntityManagerInterface $entityManager) { diff --git a/src/Bundle/ChillMainBundle/Repository/ScopeRepository.php b/src/Bundle/ChillMainBundle/Repository/ScopeRepository.php index 158678fb6..ba4ddae9b 100644 --- a/src/Bundle/ChillMainBundle/Repository/ScopeRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/ScopeRepository.php @@ -18,7 +18,7 @@ use Doctrine\ORM\QueryBuilder; final class ScopeRepository implements ScopeRepositoryInterface { - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct(EntityManagerInterface $entityManager) { diff --git a/src/Bundle/ChillMainBundle/Repository/UserACLAwareRepository.php b/src/Bundle/ChillMainBundle/Repository/UserACLAwareRepository.php index a64c77f10..5b830ce27 100644 --- a/src/Bundle/ChillMainBundle/Repository/UserACLAwareRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/UserACLAwareRepository.php @@ -19,7 +19,7 @@ use Doctrine\ORM\EntityManagerInterface; class UserACLAwareRepository implements UserACLAwareRepositoryInterface { - public function __construct(private ParentRoleHelper $parentRoleHelper, private EntityManagerInterface $em) + public function __construct(private readonly ParentRoleHelper $parentRoleHelper, private readonly EntityManagerInterface $em) { } diff --git a/src/Bundle/ChillMainBundle/Repository/UserJobRepository.php b/src/Bundle/ChillMainBundle/Repository/UserJobRepository.php index 0be3e1b9c..302830cdc 100644 --- a/src/Bundle/ChillMainBundle/Repository/UserJobRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/UserJobRepository.php @@ -17,7 +17,7 @@ use Doctrine\ORM\EntityRepository; class UserJobRepository implements UserJobRepositoryInterface { - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct(EntityManagerInterface $em) { diff --git a/src/Bundle/ChillMainBundle/Repository/UserRepository.php b/src/Bundle/ChillMainBundle/Repository/UserRepository.php index 360171f58..672add512 100644 --- a/src/Bundle/ChillMainBundle/Repository/UserRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/UserRepository.php @@ -22,7 +22,7 @@ use Doctrine\ORM\QueryBuilder; use function count; -final class UserRepository implements UserRepositoryInterface +final readonly class UserRepository implements UserRepositoryInterface { private EntityRepository $repository; diff --git a/src/Bundle/ChillMainBundle/Repository/Workflow/EntityWorkflowRepository.php b/src/Bundle/ChillMainBundle/Repository/Workflow/EntityWorkflowRepository.php index a304ff6d7..3ca56a2a0 100644 --- a/src/Bundle/ChillMainBundle/Repository/Workflow/EntityWorkflowRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/Workflow/EntityWorkflowRepository.php @@ -20,7 +20,7 @@ use Doctrine\Persistence\ObjectRepository; class EntityWorkflowRepository implements ObjectRepository { - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct(EntityManagerInterface $entityManager) { diff --git a/src/Bundle/ChillMainBundle/Repository/Workflow/EntityWorkflowStepRepository.php b/src/Bundle/ChillMainBundle/Repository/Workflow/EntityWorkflowStepRepository.php index d8c3619c3..545ec2873 100644 --- a/src/Bundle/ChillMainBundle/Repository/Workflow/EntityWorkflowStepRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/Workflow/EntityWorkflowStepRepository.php @@ -20,7 +20,7 @@ use Doctrine\Persistence\ObjectRepository; class EntityWorkflowStepRepository implements ObjectRepository { - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct(EntityManagerInterface $entityManager) { diff --git a/src/Bundle/ChillMainBundle/Routing/Loader/ChillRoutesLoader.php b/src/Bundle/ChillMainBundle/Routing/Loader/ChillRoutesLoader.php index ebfb263aa..37faf98ab 100644 --- a/src/Bundle/ChillMainBundle/Routing/Loader/ChillRoutesLoader.php +++ b/src/Bundle/ChillMainBundle/Routing/Loader/ChillRoutesLoader.php @@ -22,7 +22,7 @@ use Symfony\Component\Routing\RouteCollection; */ class ChillRoutesLoader extends Loader { - public function __construct(private array $routes) + public function __construct(private readonly array $routes) { parent::__construct(); } diff --git a/src/Bundle/ChillMainBundle/Routing/MenuBuilder/UserMenuBuilder.php b/src/Bundle/ChillMainBundle/Routing/MenuBuilder/UserMenuBuilder.php index 81c84a7a8..c203df335 100644 --- a/src/Bundle/ChillMainBundle/Routing/MenuBuilder/UserMenuBuilder.php +++ b/src/Bundle/ChillMainBundle/Routing/MenuBuilder/UserMenuBuilder.php @@ -22,7 +22,7 @@ use Symfony\Contracts\Translation\TranslatorInterface; class UserMenuBuilder implements LocalMenuBuilderInterface { - public function __construct(private NotificationByUserCounter $notificationByUserCounter, private WorkflowByUserCounter $workflowByUserCounter, private Security $security, private TranslatorInterface $translator, protected ParameterBagInterface $parameterBag, private RequestStack $requestStack) + public function __construct(private readonly NotificationByUserCounter $notificationByUserCounter, private readonly WorkflowByUserCounter $workflowByUserCounter, private readonly Security $security, private readonly TranslatorInterface $translator, protected ParameterBagInterface $parameterBag, private readonly RequestStack $requestStack) { } diff --git a/src/Bundle/ChillMainBundle/Routing/MenuComposer.php b/src/Bundle/ChillMainBundle/Routing/MenuComposer.php index ed9ff5169..f82ee2eae 100644 --- a/src/Bundle/ChillMainBundle/Routing/MenuComposer.php +++ b/src/Bundle/ChillMainBundle/Routing/MenuComposer.php @@ -33,7 +33,7 @@ class MenuComposer private RouteCollection $routeCollection; - public function __construct(private RouterInterface $router, private FactoryInterface $menuFactory, private TranslatorInterface $translator) + public function __construct(private readonly RouterInterface $router, private readonly FactoryInterface $menuFactory, private readonly TranslatorInterface $translator) { } diff --git a/src/Bundle/ChillMainBundle/Routing/MenuTwig.php b/src/Bundle/ChillMainBundle/Routing/MenuTwig.php index b77d4343f..c46ce9500 100644 --- a/src/Bundle/ChillMainBundle/Routing/MenuTwig.php +++ b/src/Bundle/ChillMainBundle/Routing/MenuTwig.php @@ -38,7 +38,7 @@ class MenuTwig extends AbstractExtension implements ContainerAwareInterface 'activeRouteKey' => null, ]; - public function __construct(private MenuComposer $menuComposer) + public function __construct(private readonly MenuComposer $menuComposer) { } @@ -76,7 +76,7 @@ class MenuTwig extends AbstractExtension implements ContainerAwareInterface { return [new TwigFunction( 'chill_menu', - [$this, 'chillMenu'], + $this->chillMenu(...), [ 'is_safe' => ['html'], 'needs_environment' => true, diff --git a/src/Bundle/ChillMainBundle/Search/AbstractSearch.php b/src/Bundle/ChillMainBundle/Search/AbstractSearch.php index f65319a09..9cd2cbd77 100644 --- a/src/Bundle/ChillMainBundle/Search/AbstractSearch.php +++ b/src/Bundle/ChillMainBundle/Search/AbstractSearch.php @@ -65,12 +65,12 @@ abstract class AbstractSearch implements SearchInterface foreach ($supportedTerms as $term) { if (array_key_exists($term, $terms) && '_default' !== $term) { $recomposed .= ' ' . $term . ':'; - $containsSpace = str_contains($terms[$term], ' '); + $containsSpace = str_contains((string) $terms[$term], ' '); if ($containsSpace) { $recomposed .= '"'; } - $recomposed .= (mb_stristr(' ', $terms[$term]) === false) ? $terms[$term] : '(' . $terms[$term] . ')'; + $recomposed .= (mb_stristr(' ', (string) $terms[$term]) === false) ? $terms[$term] : '(' . $terms[$term] . ')'; if ($containsSpace) { $recomposed .= '"'; diff --git a/src/Bundle/ChillMainBundle/Search/Entity/SearchUserApiProvider.php b/src/Bundle/ChillMainBundle/Search/Entity/SearchUserApiProvider.php index 397e0b589..5928911d9 100644 --- a/src/Bundle/ChillMainBundle/Search/Entity/SearchUserApiProvider.php +++ b/src/Bundle/ChillMainBundle/Search/Entity/SearchUserApiProvider.php @@ -20,7 +20,7 @@ use function in_array; class SearchUserApiProvider implements SearchApiInterface { - public function __construct(private UserRepository $userRepository) + public function __construct(private readonly UserRepository $userRepository) { } diff --git a/src/Bundle/ChillMainBundle/Search/Model/Result.php b/src/Bundle/ChillMainBundle/Search/Model/Result.php index 1ef249c1f..4f20924eb 100644 --- a/src/Bundle/ChillMainBundle/Search/Model/Result.php +++ b/src/Bundle/ChillMainBundle/Search/Model/Result.php @@ -17,7 +17,7 @@ class Result * @param $result */ public function __construct( - private float $relevance, + private readonly float $relevance, /** * mixed an arbitrary result. */ diff --git a/src/Bundle/ChillMainBundle/Search/SearchApi.php b/src/Bundle/ChillMainBundle/Search/SearchApi.php index e7159db06..83cd83194 100644 --- a/src/Bundle/ChillMainBundle/Search/SearchApi.php +++ b/src/Bundle/ChillMainBundle/Search/SearchApi.php @@ -26,7 +26,7 @@ use function strtr; class SearchApi { - public function __construct(private EntityManagerInterface $em, private iterable $providers, private PaginatorFactory $paginator) + public function __construct(private readonly EntityManagerInterface $em, private readonly iterable $providers, private readonly PaginatorFactory $paginator) { } diff --git a/src/Bundle/ChillMainBundle/Search/SearchApiNoQueryException.php b/src/Bundle/ChillMainBundle/Search/SearchApiNoQueryException.php index 542e18d7c..c006b4bee 100644 --- a/src/Bundle/ChillMainBundle/Search/SearchApiNoQueryException.php +++ b/src/Bundle/ChillMainBundle/Search/SearchApiNoQueryException.php @@ -18,11 +18,11 @@ use function implode; class SearchApiNoQueryException extends RuntimeException { - private string $pattern; + private readonly string $pattern; - private array $types; + private readonly array $types; - public function __construct(string $pattern = '', array $types = [], private array $parameters = [], $code = 0, ?Throwable $previous = null) + public function __construct(string $pattern = '', array $types = [], private readonly array $parameters = [], $code = 0, ?Throwable $previous = null) { $typesStr = implode(', ', $types); $message = "No query for this search: pattern : {$pattern}, types: {$typesStr}"; diff --git a/src/Bundle/ChillMainBundle/Search/SearchApiResult.php b/src/Bundle/ChillMainBundle/Search/SearchApiResult.php index b49c01565..218f4697e 100644 --- a/src/Bundle/ChillMainBundle/Search/SearchApiResult.php +++ b/src/Bundle/ChillMainBundle/Search/SearchApiResult.php @@ -15,11 +15,9 @@ use Symfony\Component\Serializer\Annotation as Serializer; class SearchApiResult { - private float $pertinence; - private $result; - public function __construct(private float $relevance) + public function __construct(private readonly float $relevance) { } diff --git a/src/Bundle/ChillMainBundle/Search/SearchProvider.php b/src/Bundle/ChillMainBundle/Search/SearchProvider.php index 52b484c2d..81c3a3969 100644 --- a/src/Bundle/ChillMainBundle/Search/SearchProvider.php +++ b/src/Bundle/ChillMainBundle/Search/SearchProvider.php @@ -252,17 +252,17 @@ class SearchProvider { $terms = []; $matches = []; - preg_match_all('/([a-z\-]+):(([^"][\S\-]+)|"[^"]*")/', $subject, $matches); + preg_match_all('/([a-z\-]+):(([^"][\S\-]+)|"[^"]*")/', (string) $subject, $matches); foreach ($matches[2] as $key => $match) { //remove from search pattern $this->mustBeExtracted[] = $matches[0][$key]; //strip parenthesis if ( - mb_substr($match, 0, 1) === '"' - && mb_substr($match, mb_strlen($match) - 1) === '"' + mb_substr((string) $match, 0, 1) === '"' + && mb_substr((string) $match, mb_strlen((string) $match) - 1) === '"' ) { - $match = trim(mb_substr($match, 1, mb_strlen($match) - 2)); + $match = trim(mb_substr((string) $match, 1, mb_strlen((string) $match) - 2)); } $terms[$matches[1][$key]] = $match; } diff --git a/src/Bundle/ChillMainBundle/Search/Utils/ExtractPhonenumberFromPattern.php b/src/Bundle/ChillMainBundle/Search/Utils/ExtractPhonenumberFromPattern.php index df9934570..ce79a637b 100644 --- a/src/Bundle/ChillMainBundle/Search/Utils/ExtractPhonenumberFromPattern.php +++ b/src/Bundle/ChillMainBundle/Search/Utils/ExtractPhonenumberFromPattern.php @@ -26,7 +26,7 @@ class ExtractPhonenumberFromPattern { private const PATTERN = '([\\+]{0,1}[0-9\\ ]{5,})'; - private string $defaultCarrierCode; + private readonly string $defaultCarrierCode; public function __construct(ParameterBagInterface $parameterBag) { diff --git a/src/Bundle/ChillMainBundle/Search/Utils/SearchExtractionResult.php b/src/Bundle/ChillMainBundle/Search/Utils/SearchExtractionResult.php index 20d5948a3..c753013cb 100644 --- a/src/Bundle/ChillMainBundle/Search/Utils/SearchExtractionResult.php +++ b/src/Bundle/ChillMainBundle/Search/Utils/SearchExtractionResult.php @@ -13,7 +13,7 @@ namespace Chill\MainBundle\Search\Utils; class SearchExtractionResult { - public function __construct(private string $filteredSubject, private array $found) + public function __construct(private readonly string $filteredSubject, private readonly array $found) { } diff --git a/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php b/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php index c431c4492..50cbf3f8d 100644 --- a/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php +++ b/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php @@ -34,7 +34,7 @@ use function get_class; */ class AuthorizationHelper implements AuthorizationHelperInterface { - public function __construct(private CenterResolverManagerInterface $centerResolverManager, private LoggerInterface $logger, private ScopeResolverDispatcher $scopeResolverDispatcher, private UserACLAwareRepositoryInterface $userACLAwareRepository, private ParentRoleHelper $parentRoleHelper) + public function __construct(private readonly CenterResolverManagerInterface $centerResolverManager, private readonly LoggerInterface $logger, private readonly ScopeResolverDispatcher $scopeResolverDispatcher, private readonly UserACLAwareRepositoryInterface $userACLAwareRepository, private readonly ParentRoleHelper $parentRoleHelper) { } diff --git a/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelperForCurrentUser.php b/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelperForCurrentUser.php index 45a1f3095..0a9d837a6 100644 --- a/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelperForCurrentUser.php +++ b/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelperForCurrentUser.php @@ -17,7 +17,7 @@ use Symfony\Component\Security\Core\Security; class AuthorizationHelperForCurrentUser implements AuthorizationHelperForCurrentUserInterface { - public function __construct(private AuthorizationHelperInterface $authorizationHelper, private Security $security) + public function __construct(private readonly AuthorizationHelperInterface $authorizationHelper, private readonly Security $security) { } diff --git a/src/Bundle/ChillMainBundle/Security/Authorization/ChillExportVoter.php b/src/Bundle/ChillMainBundle/Security/Authorization/ChillExportVoter.php index 62ac2b81b..10552d1f7 100644 --- a/src/Bundle/ChillMainBundle/Security/Authorization/ChillExportVoter.php +++ b/src/Bundle/ChillMainBundle/Security/Authorization/ChillExportVoter.php @@ -16,9 +16,9 @@ use Symfony\Component\Security\Core\Authorization\Voter\Voter; class ChillExportVoter extends Voter { - public const EXPORT = 'chill_export'; + final public const EXPORT = 'chill_export'; - private VoterHelperInterface $helper; + private readonly VoterHelperInterface $helper; public function __construct(VoterHelperFactoryInterface $voterHelperFactory) { diff --git a/src/Bundle/ChillMainBundle/Security/Authorization/DefaultVoterHelper.php b/src/Bundle/ChillMainBundle/Security/Authorization/DefaultVoterHelper.php index c6ae44d9f..a9c9f7445 100644 --- a/src/Bundle/ChillMainBundle/Security/Authorization/DefaultVoterHelper.php +++ b/src/Bundle/ChillMainBundle/Security/Authorization/DefaultVoterHelper.php @@ -16,7 +16,7 @@ use Chill\MainBundle\Security\Resolver\CenterResolverDispatcherInterface; use function in_array; -final class DefaultVoterHelper implements VoterHelperInterface +final readonly class DefaultVoterHelper implements VoterHelperInterface { public function __construct(private AuthorizationHelper $authorizationHelper, private CenterResolverDispatcherInterface $centerResolverDispatcher, private array $configuration) { diff --git a/src/Bundle/ChillMainBundle/Security/Authorization/DefaultVoterHelperGenerator.php b/src/Bundle/ChillMainBundle/Security/Authorization/DefaultVoterHelperGenerator.php index 7844632d8..cea60b931 100644 --- a/src/Bundle/ChillMainBundle/Security/Authorization/DefaultVoterHelperGenerator.php +++ b/src/Bundle/ChillMainBundle/Security/Authorization/DefaultVoterHelperGenerator.php @@ -17,7 +17,7 @@ final class DefaultVoterHelperGenerator implements VoterGeneratorInterface { private array $configuration = []; - public function __construct(private AuthorizationHelper $authorizationHelper, private CenterResolverDispatcherInterface $centerResolverDispatcher) + public function __construct(private readonly AuthorizationHelper $authorizationHelper, private readonly CenterResolverDispatcherInterface $centerResolverDispatcher) { } diff --git a/src/Bundle/ChillMainBundle/Security/Authorization/EntityWorkflowVoter.php b/src/Bundle/ChillMainBundle/Security/Authorization/EntityWorkflowVoter.php index 5d2bc72a7..11871b0b3 100644 --- a/src/Bundle/ChillMainBundle/Security/Authorization/EntityWorkflowVoter.php +++ b/src/Bundle/ChillMainBundle/Security/Authorization/EntityWorkflowVoter.php @@ -21,15 +21,15 @@ use function in_array; class EntityWorkflowVoter extends Voter { - public const CREATE = 'CHILL_MAIN_WORKFLOW_CREATE'; + final public const CREATE = 'CHILL_MAIN_WORKFLOW_CREATE'; - public const DELETE = 'CHILL_MAIN_WORKFLOW_DELETE'; + final public const DELETE = 'CHILL_MAIN_WORKFLOW_DELETE'; - public const SEE = 'CHILL_MAIN_WORKFLOW_SEE'; + final public const SEE = 'CHILL_MAIN_WORKFLOW_SEE'; - public const SHOW_ENTITY_LINK = 'CHILL_MAIN_WORKFLOW_LINK_SHOW'; + final public const SHOW_ENTITY_LINK = 'CHILL_MAIN_WORKFLOW_LINK_SHOW'; - public function __construct(private EntityWorkflowManager $manager, private Security $security) + public function __construct(private readonly EntityWorkflowManager $manager, private readonly Security $security) { } diff --git a/src/Bundle/ChillMainBundle/Security/Authorization/SavedExportVoter.php b/src/Bundle/ChillMainBundle/Security/Authorization/SavedExportVoter.php index 179cada57..32281f6dc 100644 --- a/src/Bundle/ChillMainBundle/Security/Authorization/SavedExportVoter.php +++ b/src/Bundle/ChillMainBundle/Security/Authorization/SavedExportVoter.php @@ -19,11 +19,11 @@ use function in_array; class SavedExportVoter extends Voter { - public const DELETE = 'CHLL_MAIN_EXPORT_SAVED_DELETE'; + final public const DELETE = 'CHLL_MAIN_EXPORT_SAVED_DELETE'; - public const EDIT = 'CHLL_MAIN_EXPORT_SAVED_EDIT'; + final public const EDIT = 'CHLL_MAIN_EXPORT_SAVED_EDIT'; - public const GENERATE = 'CHLL_MAIN_EXPORT_SAVED_GENERATE'; + final public const GENERATE = 'CHLL_MAIN_EXPORT_SAVED_GENERATE'; private const ALL = [ self::DELETE, diff --git a/src/Bundle/ChillMainBundle/Security/Authorization/WorkflowEntityDeletionVoter.php b/src/Bundle/ChillMainBundle/Security/Authorization/WorkflowEntityDeletionVoter.php index 23265306d..875288e90 100644 --- a/src/Bundle/ChillMainBundle/Security/Authorization/WorkflowEntityDeletionVoter.php +++ b/src/Bundle/ChillMainBundle/Security/Authorization/WorkflowEntityDeletionVoter.php @@ -24,7 +24,7 @@ class WorkflowEntityDeletionVoter extends Voter /** * @param \Chill\MainBundle\Workflow\EntityWorkflowHandlerInterface[] $handlers */ - public function __construct(private $handlers, private EntityWorkflowRepository $entityWorkflowRepository) + public function __construct(private $handlers, private readonly EntityWorkflowRepository $entityWorkflowRepository) { } diff --git a/src/Bundle/ChillMainBundle/Security/PasswordRecover/PasswordRecoverEvent.php b/src/Bundle/ChillMainBundle/Security/PasswordRecover/PasswordRecoverEvent.php index 5c8a01e1d..96ba1c74f 100644 --- a/src/Bundle/ChillMainBundle/Security/PasswordRecover/PasswordRecoverEvent.php +++ b/src/Bundle/ChillMainBundle/Security/PasswordRecover/PasswordRecoverEvent.php @@ -16,22 +16,21 @@ use Symfony\Component\EventDispatcher\Event; class PasswordRecoverEvent extends Event { - public const ASK_TOKEN_INVALID_FORM = 'chill_main.ask_token_invalid_form'; + final public const ASK_TOKEN_INVALID_FORM = 'chill_main.ask_token_invalid_form'; - public const ASK_TOKEN_SUCCESS = 'chill_main.ask_token_success'; + final public const ASK_TOKEN_SUCCESS = 'chill_main.ask_token_success'; - public const INVALID_TOKEN = 'chill_main.password_recover_invalid_token'; + final public const INVALID_TOKEN = 'chill_main.password_recover_invalid_token'; /** * @param bool $safelyGenerated true if generated safely (from console command, etc.) */ public function __construct( - private ?string $token = null, - private ?User $user = null, + private readonly ?string $token = null, + private readonly ?User $user = null, private $ip = null, - private bool $safelyGenerated = false, - ) - { + private readonly bool $safelyGenerated = false, + ) { } public function getIp() diff --git a/src/Bundle/ChillMainBundle/Security/PasswordRecover/PasswordRecoverLocker.php b/src/Bundle/ChillMainBundle/Security/PasswordRecover/PasswordRecoverLocker.php index 53be72874..1266453e7 100644 --- a/src/Bundle/ChillMainBundle/Security/PasswordRecover/PasswordRecoverLocker.php +++ b/src/Bundle/ChillMainBundle/Security/PasswordRecover/PasswordRecoverLocker.php @@ -18,28 +18,28 @@ use UnexpectedValueException; class PasswordRecoverLocker { - public const ASK_TOKEN_INVALID_FORM_TTL = 3600; + final public const ASK_TOKEN_INVALID_FORM_TTL = 3600; /** * TTL to keep invalid token recorded. */ - public const INVALID_TOKEN_TTL = 3600; + final public const INVALID_TOKEN_TTL = 3600; - public const MAX_ASK_TOKEN_BY_USER = 10; + final public const MAX_ASK_TOKEN_BY_USER = 10; - public const MAX_ASK_TOKEN_INVALID_FORM_BY_IP = 10; + final public const MAX_ASK_TOKEN_INVALID_FORM_BY_IP = 10; - public const MAX_ASK_TOKEN_INVALID_FORM_GLOBAL = 50; + final public const MAX_ASK_TOKEN_INVALID_FORM_GLOBAL = 50; /** * The maximum of invalid token by ip. */ - public const MAX_INVALID_TOKEN_BY_IP = 10; + final public const MAX_INVALID_TOKEN_BY_IP = 10; /** * The maximum of invalid token globally (across all ip). */ - public const MAX_INVALID_TOKEN_GLOBAL = 50; + final public const MAX_INVALID_TOKEN_GLOBAL = 50; /** * @var ChillRedis diff --git a/src/Bundle/ChillMainBundle/Security/PasswordRecover/PasswordRecoverVoter.php b/src/Bundle/ChillMainBundle/Security/PasswordRecover/PasswordRecoverVoter.php index 7ba724618..b2a17d2da 100644 --- a/src/Bundle/ChillMainBundle/Security/PasswordRecover/PasswordRecoverVoter.php +++ b/src/Bundle/ChillMainBundle/Security/PasswordRecover/PasswordRecoverVoter.php @@ -20,9 +20,9 @@ use function in_array; class PasswordRecoverVoter extends Voter { - public const ASK_TOKEN = 'CHILL_PASSWORD_ASK_TOKEN'; + final public const ASK_TOKEN = 'CHILL_PASSWORD_ASK_TOKEN'; - public const TRY_TOKEN = 'CHILL_PASSWORD_TRY_TOKEN'; + final public const TRY_TOKEN = 'CHILL_PASSWORD_TRY_TOKEN'; /** * @var PasswordRecoverLocker diff --git a/src/Bundle/ChillMainBundle/Security/PasswordRecover/RecoverPasswordHelper.php b/src/Bundle/ChillMainBundle/Security/PasswordRecover/RecoverPasswordHelper.php index 4598f6199..a8f8b4300 100644 --- a/src/Bundle/ChillMainBundle/Security/PasswordRecover/RecoverPasswordHelper.php +++ b/src/Bundle/ChillMainBundle/Security/PasswordRecover/RecoverPasswordHelper.php @@ -22,9 +22,9 @@ use function array_merge; class RecoverPasswordHelper { - public const RECOVER_PASSWORD_ROUTE = 'password_recover'; + final public const RECOVER_PASSWORD_ROUTE = 'password_recover'; - public function __construct(private TokenManager $tokenManager, private UrlGeneratorInterface $urlGenerator, private MailerInterface $mailer) + public function __construct(private readonly TokenManager $tokenManager, private readonly UrlGeneratorInterface $urlGenerator, private readonly MailerInterface $mailer) { } diff --git a/src/Bundle/ChillMainBundle/Security/PasswordRecover/TokenManager.php b/src/Bundle/ChillMainBundle/Security/PasswordRecover/TokenManager.php index 370c1c521..f442ae4a7 100644 --- a/src/Bundle/ChillMainBundle/Security/PasswordRecover/TokenManager.php +++ b/src/Bundle/ChillMainBundle/Security/PasswordRecover/TokenManager.php @@ -27,15 +27,15 @@ use function trim; class TokenManager { - public const HASH = 'h'; + final public const HASH = 'h'; - public const TIMESTAMP = 'ts'; + final public const TIMESTAMP = 'ts'; - public const TOKEN = 't'; + final public const TOKEN = 't'; - public const TOKEN_LENGTH = 24; + final public const TOKEN_LENGTH = 24; - public const USERNAME_CANONICAL = 'u'; + final public const USERNAME_CANONICAL = 'u'; /** * @var LoggerInterface @@ -72,7 +72,7 @@ class TokenManager public function verify($hash, $token, User $user, string $timestamp) { - $token = hex2bin(trim($token)); + $token = hex2bin(trim((string) $token)); if (strlen($token) !== self::TOKEN_LENGTH) { return false; diff --git a/src/Bundle/ChillMainBundle/Security/Resolver/CenterResolverDispatcher.php b/src/Bundle/ChillMainBundle/Security/Resolver/CenterResolverDispatcher.php index d01ba6665..9855477fd 100644 --- a/src/Bundle/ChillMainBundle/Security/Resolver/CenterResolverDispatcher.php +++ b/src/Bundle/ChillMainBundle/Security/Resolver/CenterResolverDispatcher.php @@ -11,7 +11,7 @@ declare(strict_types=1); namespace Chill\MainBundle\Security\Resolver; -final class CenterResolverDispatcher implements CenterResolverDispatcherInterface +final readonly class CenterResolverDispatcher implements CenterResolverDispatcherInterface { /** * @param \Chill\MainBundle\Security\Resolver\CenterResolverInterface[] $resolvers diff --git a/src/Bundle/ChillMainBundle/Security/Resolver/CenterResolverManager.php b/src/Bundle/ChillMainBundle/Security/Resolver/CenterResolverManager.php index 3ccdd3746..9c6dc841d 100644 --- a/src/Bundle/ChillMainBundle/Security/Resolver/CenterResolverManager.php +++ b/src/Bundle/ChillMainBundle/Security/Resolver/CenterResolverManager.php @@ -17,7 +17,7 @@ use UnexpectedValueException; use function get_class; use function is_array; -final class CenterResolverManager implements CenterResolverManagerInterface +final readonly class CenterResolverManager implements CenterResolverManagerInterface { /** * @param \Chill\MainBundle\Security\Resolver\CenterResolverInterface[] $resolvers diff --git a/src/Bundle/ChillMainBundle/Security/Resolver/ResolverTwigExtension.php b/src/Bundle/ChillMainBundle/Security/Resolver/ResolverTwigExtension.php index 299d8dd2b..c3c328bd2 100644 --- a/src/Bundle/ChillMainBundle/Security/Resolver/ResolverTwigExtension.php +++ b/src/Bundle/ChillMainBundle/Security/Resolver/ResolverTwigExtension.php @@ -15,16 +15,16 @@ use Twig\TwigFilter; final class ResolverTwigExtension extends \Twig\Extension\AbstractExtension { - public function __construct(private CenterResolverManagerInterface $centerResolverDispatcher, private ScopeResolverDispatcher $scopeResolverDispatcher) + public function __construct(private readonly CenterResolverManagerInterface $centerResolverDispatcher, private readonly ScopeResolverDispatcher $scopeResolverDispatcher) { } public function getFilters() { return [ - new TwigFilter('chill_resolve_center', [$this, 'resolveCenter']), - new TwigFilter('chill_resolve_scope', [$this, 'resolveScope']), - new TwigFilter('chill_is_scope_concerned', [$this, 'isScopeConcerned']), + new TwigFilter('chill_resolve_center', $this->resolveCenter(...)), + new TwigFilter('chill_resolve_scope', $this->resolveScope(...)), + new TwigFilter('chill_is_scope_concerned', $this->isScopeConcerned(...)), ]; } diff --git a/src/Bundle/ChillMainBundle/Security/Resolver/ScopeResolverDispatcher.php b/src/Bundle/ChillMainBundle/Security/Resolver/ScopeResolverDispatcher.php index 151754ae7..e8207406a 100644 --- a/src/Bundle/ChillMainBundle/Security/Resolver/ScopeResolverDispatcher.php +++ b/src/Bundle/ChillMainBundle/Security/Resolver/ScopeResolverDispatcher.php @@ -14,7 +14,7 @@ namespace Chill\MainBundle\Security\Resolver; use Chill\MainBundle\Entity\Scope; use Doctrine\Common\Collections\Collection; -final class ScopeResolverDispatcher +final readonly class ScopeResolverDispatcher { /** * @param \Chill\MainBundle\Security\Resolver\ScopeResolverInterface[] $resolvers diff --git a/src/Bundle/ChillMainBundle/Serializer/Model/Collection.php b/src/Bundle/ChillMainBundle/Serializer/Model/Collection.php index 4f6248621..9d80eabe9 100644 --- a/src/Bundle/ChillMainBundle/Serializer/Model/Collection.php +++ b/src/Bundle/ChillMainBundle/Serializer/Model/Collection.php @@ -15,7 +15,7 @@ use Chill\MainBundle\Pagination\PaginatorInterface; class Collection { - public function __construct(private $items, private PaginatorInterface $paginator) + public function __construct(private $items, private readonly PaginatorInterface $paginator) { } diff --git a/src/Bundle/ChillMainBundle/Serializer/Normalizer/AddressNormalizer.php b/src/Bundle/ChillMainBundle/Serializer/Normalizer/AddressNormalizer.php index 5e6c8cc05..ac3304767 100644 --- a/src/Bundle/ChillMainBundle/Serializer/Normalizer/AddressNormalizer.php +++ b/src/Bundle/ChillMainBundle/Serializer/Normalizer/AddressNormalizer.php @@ -48,7 +48,7 @@ class AddressNormalizer implements ContextAwareNormalizerInterface, NormalizerAw 'confidential', ]; - public function __construct(private AddressRender $addressRender) + public function __construct(private readonly AddressRender $addressRender) { } diff --git a/src/Bundle/ChillMainBundle/Serializer/Normalizer/CenterNormalizer.php b/src/Bundle/ChillMainBundle/Serializer/Normalizer/CenterNormalizer.php index cfb53e1a1..6a4355a08 100644 --- a/src/Bundle/ChillMainBundle/Serializer/Normalizer/CenterNormalizer.php +++ b/src/Bundle/ChillMainBundle/Serializer/Normalizer/CenterNormalizer.php @@ -22,7 +22,7 @@ use function array_key_exists; class CenterNormalizer implements DenormalizerInterface, NormalizerInterface { - public function __construct(private CenterRepository $repository) + public function __construct(private readonly CenterRepository $repository) { } diff --git a/src/Bundle/ChillMainBundle/Serializer/Normalizer/CommentEmbeddableDocGenNormalizer.php b/src/Bundle/ChillMainBundle/Serializer/Normalizer/CommentEmbeddableDocGenNormalizer.php index 10c865608..ba29093ce 100644 --- a/src/Bundle/ChillMainBundle/Serializer/Normalizer/CommentEmbeddableDocGenNormalizer.php +++ b/src/Bundle/ChillMainBundle/Serializer/Normalizer/CommentEmbeddableDocGenNormalizer.php @@ -25,7 +25,7 @@ class CommentEmbeddableDocGenNormalizer implements ContextAwareNormalizerInterfa { use NormalizerAwareTrait; - public function __construct(private UserRepository $userRepository) + public function __construct(private readonly UserRepository $userRepository) { } diff --git a/src/Bundle/ChillMainBundle/Serializer/Normalizer/DateNormalizer.php b/src/Bundle/ChillMainBundle/Serializer/Normalizer/DateNormalizer.php index c5032a7b9..cbd12e15f 100644 --- a/src/Bundle/ChillMainBundle/Serializer/Normalizer/DateNormalizer.php +++ b/src/Bundle/ChillMainBundle/Serializer/Normalizer/DateNormalizer.php @@ -26,7 +26,7 @@ use function is_array; class DateNormalizer implements ContextAwareNormalizerInterface, DenormalizerInterface { - public function __construct(private RequestStack $requestStack, private ParameterBagInterface $parameterBag) + public function __construct(private readonly RequestStack $requestStack, private readonly ParameterBagInterface $parameterBag) { } diff --git a/src/Bundle/ChillMainBundle/Serializer/Normalizer/DiscriminatedObjectDenormalizer.php b/src/Bundle/ChillMainBundle/Serializer/Normalizer/DiscriminatedObjectDenormalizer.php index da2b63faa..58dc7e839 100644 --- a/src/Bundle/ChillMainBundle/Serializer/Normalizer/DiscriminatedObjectDenormalizer.php +++ b/src/Bundle/ChillMainBundle/Serializer/Normalizer/DiscriminatedObjectDenormalizer.php @@ -32,12 +32,12 @@ class DiscriminatedObjectDenormalizer implements ContextAwareDenormalizerInterfa * Should be present in context and contains an array of * allowed types. */ - public const ALLOWED_TYPES = 'denormalize_multi.allowed_types'; + final public const ALLOWED_TYPES = 'denormalize_multi.allowed_types'; /** * The type to set for enabling this type. */ - public const TYPE = '@multi'; + final public const TYPE = '@multi'; public function denormalize($data, $type, $format = null, array $context = []) { diff --git a/src/Bundle/ChillMainBundle/Serializer/Normalizer/DoctrineExistingEntityNormalizer.php b/src/Bundle/ChillMainBundle/Serializer/Normalizer/DoctrineExistingEntityNormalizer.php index 94c5d400e..9c9081ae9 100644 --- a/src/Bundle/ChillMainBundle/Serializer/Normalizer/DoctrineExistingEntityNormalizer.php +++ b/src/Bundle/ChillMainBundle/Serializer/Normalizer/DoctrineExistingEntityNormalizer.php @@ -23,7 +23,7 @@ use function is_array; class DoctrineExistingEntityNormalizer implements DenormalizerInterface { - public function __construct(private EntityManagerInterface $em, private ClassMetadataFactoryInterface $serializerMetadataFactory) + public function __construct(private readonly EntityManagerInterface $em, private readonly ClassMetadataFactoryInterface $serializerMetadataFactory) { } diff --git a/src/Bundle/ChillMainBundle/Serializer/Normalizer/EntityWorkflowNormalizer.php b/src/Bundle/ChillMainBundle/Serializer/Normalizer/EntityWorkflowNormalizer.php index 16553ab29..83e84f7a0 100644 --- a/src/Bundle/ChillMainBundle/Serializer/Normalizer/EntityWorkflowNormalizer.php +++ b/src/Bundle/ChillMainBundle/Serializer/Normalizer/EntityWorkflowNormalizer.php @@ -23,7 +23,7 @@ class EntityWorkflowNormalizer implements NormalizerInterface, NormalizerAwareIn { use NormalizerAwareTrait; - public function __construct(private EntityWorkflowManager $entityWorkflowManager, private MetadataExtractor $metadataExtractor, private Registry $registry) + public function __construct(private readonly EntityWorkflowManager $entityWorkflowManager, private readonly MetadataExtractor $metadataExtractor, private readonly Registry $registry) { } diff --git a/src/Bundle/ChillMainBundle/Serializer/Normalizer/EntityWorkflowStepNormalizer.php b/src/Bundle/ChillMainBundle/Serializer/Normalizer/EntityWorkflowStepNormalizer.php index 874faf9c9..46dbd00cc 100644 --- a/src/Bundle/ChillMainBundle/Serializer/Normalizer/EntityWorkflowStepNormalizer.php +++ b/src/Bundle/ChillMainBundle/Serializer/Normalizer/EntityWorkflowStepNormalizer.php @@ -21,7 +21,7 @@ class EntityWorkflowStepNormalizer implements NormalizerAwareInterface, Normaliz { use NormalizerAwareTrait; - public function __construct(private MetadataExtractor $metadataExtractor) + public function __construct(private readonly MetadataExtractor $metadataExtractor) { } diff --git a/src/Bundle/ChillMainBundle/Serializer/Normalizer/NotificationNormalizer.php b/src/Bundle/ChillMainBundle/Serializer/Normalizer/NotificationNormalizer.php index 98101a86d..241cd83a9 100644 --- a/src/Bundle/ChillMainBundle/Serializer/Normalizer/NotificationNormalizer.php +++ b/src/Bundle/ChillMainBundle/Serializer/Normalizer/NotificationNormalizer.php @@ -24,7 +24,7 @@ class NotificationNormalizer implements NormalizerAwareInterface, NormalizerInte { use NormalizerAwareTrait; - public function __construct(private NotificationHandlerManager $notificationHandlerManager, private EntityManagerInterface $entityManager, private Security $security) + public function __construct(private readonly NotificationHandlerManager $notificationHandlerManager, private readonly EntityManagerInterface $entityManager, private readonly Security $security) { } diff --git a/src/Bundle/ChillMainBundle/Serializer/Normalizer/PhonenumberNormalizer.php b/src/Bundle/ChillMainBundle/Serializer/Normalizer/PhonenumberNormalizer.php index 349f2dace..ec6e3d5e6 100644 --- a/src/Bundle/ChillMainBundle/Serializer/Normalizer/PhonenumberNormalizer.php +++ b/src/Bundle/ChillMainBundle/Serializer/Normalizer/PhonenumberNormalizer.php @@ -21,9 +21,9 @@ use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; class PhonenumberNormalizer implements ContextAwareNormalizerInterface, DenormalizerInterface { - private string $defaultCarrierCode; + private readonly string $defaultCarrierCode; - private PhoneNumberUtil $phoneNumberUtil; + private readonly PhoneNumberUtil $phoneNumberUtil; public function __construct(ParameterBagInterface $parameterBag) { diff --git a/src/Bundle/ChillMainBundle/Serializer/Normalizer/PrivateCommentEmbeddableNormalizer.php b/src/Bundle/ChillMainBundle/Serializer/Normalizer/PrivateCommentEmbeddableNormalizer.php index 6a98bc428..1d7ee43ce 100644 --- a/src/Bundle/ChillMainBundle/Serializer/Normalizer/PrivateCommentEmbeddableNormalizer.php +++ b/src/Bundle/ChillMainBundle/Serializer/Normalizer/PrivateCommentEmbeddableNormalizer.php @@ -18,7 +18,7 @@ use Symfony\Component\Serializer\Normalizer\NormalizerInterface; class PrivateCommentEmbeddableNormalizer implements NormalizerInterface, DenormalizerInterface { - public function __construct(private Security $security) + public function __construct(private readonly Security $security) { } diff --git a/src/Bundle/ChillMainBundle/Serializer/Normalizer/UserNormalizer.php b/src/Bundle/ChillMainBundle/Serializer/Normalizer/UserNormalizer.php index 5f68454fd..5211ff505 100644 --- a/src/Bundle/ChillMainBundle/Serializer/Normalizer/UserNormalizer.php +++ b/src/Bundle/ChillMainBundle/Serializer/Normalizer/UserNormalizer.php @@ -26,7 +26,7 @@ class UserNormalizer implements ContextAwareNormalizerInterface, NormalizerAware { use NormalizerAwareTrait; - public const NULL_USER = [ + final public const NULL_USER = [ 'type' => 'user', 'id' => '', 'username' => '', @@ -36,7 +36,7 @@ class UserNormalizer implements ContextAwareNormalizerInterface, NormalizerAware 'email' => '', ]; - public function __construct(private UserRender $userRender) + public function __construct(private readonly UserRender $userRender) { } @@ -65,14 +65,7 @@ class UserNormalizer implements ContextAwareNormalizerInterface, NormalizerAware ); if (null === $object && 'docgen' === $format) { - return array_merge(self::NULL_USER, [ - 'civility' => $this->normalizer->normalize(null, $format, $civilityContext), - 'user_job' => $this->normalizer->normalize(null, $format, $userJobContext), - 'main_center' => $this->normalizer->normalize(null, $format, $centerContext), - 'main_scope' => $this->normalizer->normalize(null, $format, $scopeContext), - 'current_location' => $this->normalizer->normalize(null, $format, $locationContext), - 'main_location' => $this->normalizer->normalize(null, $format, $locationContext), - ]); + return [...self::NULL_USER, 'civility' => $this->normalizer->normalize(null, $format, $civilityContext), 'user_job' => $this->normalizer->normalize(null, $format, $userJobContext), 'main_center' => $this->normalizer->normalize(null, $format, $centerContext), 'main_scope' => $this->normalizer->normalize(null, $format, $scopeContext), 'current_location' => $this->normalizer->normalize(null, $format, $locationContext), 'main_location' => $this->normalizer->normalize(null, $format, $locationContext)]; } $data = [ diff --git a/src/Bundle/ChillMainBundle/Service/AddressGeographicalUnit/RefreshAddressToGeographicalUnitMaterializedViewCronJob.php b/src/Bundle/ChillMainBundle/Service/AddressGeographicalUnit/RefreshAddressToGeographicalUnitMaterializedViewCronJob.php index b64891695..d17d02f54 100644 --- a/src/Bundle/ChillMainBundle/Service/AddressGeographicalUnit/RefreshAddressToGeographicalUnitMaterializedViewCronJob.php +++ b/src/Bundle/ChillMainBundle/Service/AddressGeographicalUnit/RefreshAddressToGeographicalUnitMaterializedViewCronJob.php @@ -20,7 +20,7 @@ use UnexpectedValueException; class RefreshAddressToGeographicalUnitMaterializedViewCronJob implements CronJobInterface { - public function __construct(private Connection $connection) + public function __construct(private readonly Connection $connection) { } diff --git a/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceBEFromBestAddress.php b/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceBEFromBestAddress.php index 09bc5e3f8..fce6116a8 100644 --- a/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceBEFromBestAddress.php +++ b/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceBEFromBestAddress.php @@ -22,7 +22,7 @@ class AddressReferenceBEFromBestAddress { private const RELEASE = 'https://gitea.champs-libres.be/api/v1/repos/Chill-project/belgian-bestaddresses-transform/releases/tags/v1.0.0'; - public function __construct(private HttpClientInterface $client, private AddressReferenceBaseImporter $baseImporter, private AddressToReferenceMatcher $addressToReferenceMatcher) + public function __construct(private readonly HttpClientInterface $client, private readonly AddressReferenceBaseImporter $baseImporter, private readonly AddressToReferenceMatcher $addressToReferenceMatcher) { } diff --git a/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceBaseImporter.php b/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceBaseImporter.php index 9c8f2f705..68f6287e6 100644 --- a/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceBaseImporter.php +++ b/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceBaseImporter.php @@ -50,7 +50,7 @@ final class AddressReferenceBaseImporter private array $waitingForInsert = []; - public function __construct(private Connection $defaultConnection, private LoggerInterface $logger) + public function __construct(private readonly Connection $defaultConnection, private readonly LoggerInterface $logger) { } diff --git a/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceFromBano.php b/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceFromBano.php index 657463dc7..a908bc31e 100644 --- a/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceFromBano.php +++ b/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceFromBano.php @@ -20,7 +20,7 @@ use function is_int; class AddressReferenceFromBano { - public function __construct(private HttpClientInterface $client, private AddressReferenceBaseImporter $baseImporter, private AddressToReferenceMatcher $addressToReferenceMatcher) + public function __construct(private readonly HttpClientInterface $client, private readonly AddressReferenceBaseImporter $baseImporter, private readonly AddressToReferenceMatcher $addressToReferenceMatcher) { } diff --git a/src/Bundle/ChillMainBundle/Service/Import/AddressToReferenceMatcher.php b/src/Bundle/ChillMainBundle/Service/Import/AddressToReferenceMatcher.php index bf9b57a1a..67ad25fbb 100644 --- a/src/Bundle/ChillMainBundle/Service/Import/AddressToReferenceMatcher.php +++ b/src/Bundle/ChillMainBundle/Service/Import/AddressToReferenceMatcher.php @@ -19,7 +19,7 @@ use Psr\Log\LoggerInterface; * Mark existing addresses as to be reviewed regarding the * address reference */ -final class AddressToReferenceMatcher +final readonly class AddressToReferenceMatcher { private const LOG_PREFIX = '[address_to_reference_matcher] '; diff --git a/src/Bundle/ChillMainBundle/Service/Import/GeographicalUnitBaseImporter.php b/src/Bundle/ChillMainBundle/Service/Import/GeographicalUnitBaseImporter.php index c8a229cd7..ec3203de2 100644 --- a/src/Bundle/ChillMainBundle/Service/Import/GeographicalUnitBaseImporter.php +++ b/src/Bundle/ChillMainBundle/Service/Import/GeographicalUnitBaseImporter.php @@ -47,7 +47,7 @@ final class GeographicalUnitBaseImporter private array $waitingForInsert = []; - public function __construct(private Connection $defaultConnection, private LoggerInterface $logger) + public function __construct(private readonly Connection $defaultConnection, private readonly LoggerInterface $logger) { } diff --git a/src/Bundle/ChillMainBundle/Service/Import/PostalCodeBEFromBestAddress.php b/src/Bundle/ChillMainBundle/Service/Import/PostalCodeBEFromBestAddress.php index 41672e421..b1b5563ec 100644 --- a/src/Bundle/ChillMainBundle/Service/Import/PostalCodeBEFromBestAddress.php +++ b/src/Bundle/ChillMainBundle/Service/Import/PostalCodeBEFromBestAddress.php @@ -21,7 +21,7 @@ class PostalCodeBEFromBestAddress { private const RELEASE = 'https://gitea.champs-libres.be/api/v1/repos/Chill-project/belgian-bestaddresses-transform/releases/tags/v1.0.0'; - public function __construct(private PostalCodeBaseImporter $baseImporter, private HttpClientInterface $client, private LoggerInterface $logger) + public function __construct(private readonly PostalCodeBaseImporter $baseImporter, private readonly HttpClientInterface $client, private readonly LoggerInterface $logger) { } @@ -82,8 +82,8 @@ class PostalCodeBEFromBestAddress { $this->baseImporter->importCode( 'BE', - trim($record['municipality_name']), - trim($record['postal_info_objectid']), + trim((string) $record['municipality_name']), + trim((string) $record['postal_info_objectid']), $record['municipality_objectid'], 'bestaddress', (float) $record['Y'], diff --git a/src/Bundle/ChillMainBundle/Service/Import/PostalCodeBaseImporter.php b/src/Bundle/ChillMainBundle/Service/Import/PostalCodeBaseImporter.php index 8b5e6d4e1..86f00193a 100644 --- a/src/Bundle/ChillMainBundle/Service/Import/PostalCodeBaseImporter.php +++ b/src/Bundle/ChillMainBundle/Service/Import/PostalCodeBaseImporter.php @@ -57,7 +57,7 @@ class PostalCodeBaseImporter private array $waitingForInsert = []; - public function __construct(private Connection $defaultConnection) + public function __construct(private readonly Connection $defaultConnection) { } diff --git a/src/Bundle/ChillMainBundle/Service/Import/PostalCodeFRFromOpenData.php b/src/Bundle/ChillMainBundle/Service/Import/PostalCodeFRFromOpenData.php index 23687d558..3eb178b01 100644 --- a/src/Bundle/ChillMainBundle/Service/Import/PostalCodeFRFromOpenData.php +++ b/src/Bundle/ChillMainBundle/Service/Import/PostalCodeFRFromOpenData.php @@ -26,7 +26,7 @@ class PostalCodeFRFromOpenData { private const CSV = 'https://datanova.legroupe.laposte.fr/explore/dataset/laposte_hexasmal/download/?format=csv&timezone=Europe/Berlin&lang=fr&use_labels_for_header=true&csv_separator=%3B'; - public function __construct(private PostalCodeBaseImporter $baseImporter, private HttpClientInterface $client, private LoggerInterface $logger) + public function __construct(private readonly PostalCodeBaseImporter $baseImporter, private readonly HttpClientInterface $client, private readonly LoggerInterface $logger) { } @@ -72,17 +72,17 @@ class PostalCodeFRFromOpenData $lat = $lon = 0.0; } - $ref = trim($record['Code_commune_INSEE']); + $ref = trim((string) $record['Code_commune_INSEE']); if (str_starts_with($ref, '987')) { // some differences in French Polynesia - $ref .= '.' . trim($record['Libellé_d_acheminement']); + $ref .= '.' . trim((string) $record['Libellé_d_acheminement']); } $this->baseImporter->importCode( 'FR', - trim($record['Libellé_d_acheminement']), - trim($record['Code_postal']), + trim((string) $record['Libellé_d_acheminement']), + trim((string) $record['Code_postal']), $ref, 'INSEE', $lat, diff --git a/src/Bundle/ChillMainBundle/Service/Mailer/ChillMailer.php b/src/Bundle/ChillMainBundle/Service/Mailer/ChillMailer.php index 6474ccf9c..b9b2f026d 100644 --- a/src/Bundle/ChillMainBundle/Service/Mailer/ChillMailer.php +++ b/src/Bundle/ChillMainBundle/Service/Mailer/ChillMailer.php @@ -22,7 +22,7 @@ class ChillMailer implements MailerInterface { private string $prefix = '[Chill] '; - public function __construct(private MailerInterface $initial, private LoggerInterface $chillLogger) + public function __construct(private readonly MailerInterface $initial, private readonly LoggerInterface $chillLogger) { } diff --git a/src/Bundle/ChillMainBundle/Service/RollingDate/RollingDate.php b/src/Bundle/ChillMainBundle/Service/RollingDate/RollingDate.php index 32aa7030a..cc02dc822 100644 --- a/src/Bundle/ChillMainBundle/Service/RollingDate/RollingDate.php +++ b/src/Bundle/ChillMainBundle/Service/RollingDate/RollingDate.php @@ -15,7 +15,7 @@ use DateTimeImmutable; class RollingDate { - public const ALL_T = [ + final public const ALL_T = [ self::T_YEAR_PREVIOUS_START, self::T_QUARTER_PREVIOUS_START, self::T_MONTH_PREVIOUS_START, @@ -35,47 +35,41 @@ class RollingDate /** * A given fixed date. */ - public const T_FIXED_DATE = 'fixed_date'; + final public const T_FIXED_DATE = 'fixed_date'; - public const T_MONTH_CURRENT_START = 'month_current_start'; + final public const T_MONTH_CURRENT_START = 'month_current_start'; - public const T_MONTH_NEXT_START = 'month_next_start'; + final public const T_MONTH_NEXT_START = 'month_next_start'; - public const T_MONTH_PREVIOUS_START = 'month_previous_start'; + final public const T_MONTH_PREVIOUS_START = 'month_previous_start'; - public const T_QUARTER_CURRENT_START = 'quarter_current_start'; + final public const T_QUARTER_CURRENT_START = 'quarter_current_start'; - public const T_QUARTER_NEXT_START = 'quarter_next_start'; + final public const T_QUARTER_NEXT_START = 'quarter_next_start'; - public const T_QUARTER_PREVIOUS_START = 'quarter_previous_start'; + final public const T_QUARTER_PREVIOUS_START = 'quarter_previous_start'; - public const T_TODAY = 'today'; + final public const T_TODAY = 'today'; - public const T_WEEK_CURRENT_START = 'week_current_start'; + final public const T_WEEK_CURRENT_START = 'week_current_start'; - public const T_WEEK_NEXT_START = 'week_next_start'; + final public const T_WEEK_NEXT_START = 'week_next_start'; - public const T_WEEK_PREVIOUS_START = 'week_previous_start'; + final public const T_WEEK_PREVIOUS_START = 'week_previous_start'; - public const T_YEAR_CURRENT_START = 'year_current_start'; + final public const T_YEAR_CURRENT_START = 'year_current_start'; - public const T_YEAR_NEXT_START = 'year_next_start'; + final public const T_YEAR_NEXT_START = 'year_next_start'; - public const T_YEAR_PREVIOUS_START = 'year_previous_start'; + final public const T_YEAR_PREVIOUS_START = 'year_previous_start'; /** - * The pivot date is the date from the rolling is computed. By default, it is "now". - */ - private DateTimeImmutable $pivotDate; - - /** - * @param string|self::T_* $roll - * @param DateTimeImmutable|null $pivotDate Will be "now" if null is given + * @param string $roll * @param DateTimeImmutable|null $fixedDate Only to insert if $roll equals @see{self::T_FIXED_DATE} + * @param DateTimeImmutable $pivotDate Will be "now" if null is given */ - public function __construct(private string $roll, private ?\DateTimeImmutable $fixedDate = null, ?DateTimeImmutable $pivotDate = null) + public function __construct(private readonly string $roll, private readonly ?DateTimeImmutable $fixedDate = null, private readonly DateTimeImmutable $pivotDate = new DateTimeImmutable('now')) { - $this->pivotDate = $pivotDate ?? new DateTimeImmutable('now'); } public function getFixedDate(): ?DateTimeImmutable diff --git a/src/Bundle/ChillMainBundle/Service/ShortMessage/ShortMessage.php b/src/Bundle/ChillMainBundle/Service/ShortMessage/ShortMessage.php index 2a86ddab4..e028cf3c4 100644 --- a/src/Bundle/ChillMainBundle/Service/ShortMessage/ShortMessage.php +++ b/src/Bundle/ChillMainBundle/Service/ShortMessage/ShortMessage.php @@ -22,9 +22,9 @@ use libphonenumber\PhoneNumber; class ShortMessage { - public const PRIORITY_LOW = 'low'; + final public const PRIORITY_LOW = 'low'; - public const PRIORITY_MEDIUM = 'medium'; + final public const PRIORITY_MEDIUM = 'medium'; public function __construct(private string $content, private PhoneNumber $phoneNumber, private string $priority = 'low') { diff --git a/src/Bundle/ChillMainBundle/Service/ShortMessage/ShortMessageHandler.php b/src/Bundle/ChillMainBundle/Service/ShortMessage/ShortMessageHandler.php index 6f8b5427d..55490b2eb 100644 --- a/src/Bundle/ChillMainBundle/Service/ShortMessage/ShortMessageHandler.php +++ b/src/Bundle/ChillMainBundle/Service/ShortMessage/ShortMessageHandler.php @@ -25,7 +25,7 @@ use Symfony\Component\Messenger\Handler\MessageHandlerInterface; */ class ShortMessageHandler implements MessageHandlerInterface { - public function __construct(private ShortMessageTransporterInterface $messageTransporter) + public function __construct(private readonly ShortMessageTransporterInterface $messageTransporter) { } diff --git a/src/Bundle/ChillMainBundle/Service/ShortMessage/ShortMessageTransporter.php b/src/Bundle/ChillMainBundle/Service/ShortMessage/ShortMessageTransporter.php index 5dfbc9fc0..76e45acbd 100644 --- a/src/Bundle/ChillMainBundle/Service/ShortMessage/ShortMessageTransporter.php +++ b/src/Bundle/ChillMainBundle/Service/ShortMessage/ShortMessageTransporter.php @@ -20,7 +20,7 @@ namespace Chill\MainBundle\Service\ShortMessage; class ShortMessageTransporter implements ShortMessageTransporterInterface { - public function __construct(private ShortMessageSenderInterface $sender) + public function __construct(private readonly ShortMessageSenderInterface $sender) { } diff --git a/src/Bundle/ChillMainBundle/Service/ShortMessageOvh/OvhShortMessageSender.php b/src/Bundle/ChillMainBundle/Service/ShortMessageOvh/OvhShortMessageSender.php index 72ef53b85..bf43d76d4 100644 --- a/src/Bundle/ChillMainBundle/Service/ShortMessageOvh/OvhShortMessageSender.php +++ b/src/Bundle/ChillMainBundle/Service/ShortMessageOvh/OvhShortMessageSender.php @@ -28,14 +28,14 @@ use Psr\Log\LoggerInterface; class OvhShortMessageSender implements ShortMessageSenderInterface { public function __construct( - private Api $api, + private readonly Api $api, // for DI, must remains as first argument - private string $serviceName, + private readonly string $serviceName, // for di, must remains as second argument - private string $sender, + private readonly string $sender, // for DI, must remains as third argument - private LoggerInterface $logger, - private PhoneNumberUtil $phoneNumberUtil + private readonly LoggerInterface $logger, + private readonly PhoneNumberUtil $phoneNumberUtil ) { } diff --git a/src/Bundle/ChillMainBundle/Templating/CSVCellTwig.php b/src/Bundle/ChillMainBundle/Templating/CSVCellTwig.php index f5f91c361..7aaa33c7c 100644 --- a/src/Bundle/ChillMainBundle/Templating/CSVCellTwig.php +++ b/src/Bundle/ChillMainBundle/Templating/CSVCellTwig.php @@ -46,7 +46,7 @@ class CSVCellTwig extends AbstractExtension return [ new TwigFilter( 'csv_cell', - [$this, 'csvCellFilter'], + $this->csvCellFilter(...), ['is_safe' => ['html']] ), ]; diff --git a/src/Bundle/ChillMainBundle/Templating/ChillMarkdownRenderExtension.php b/src/Bundle/ChillMainBundle/Templating/ChillMarkdownRenderExtension.php index d277c0f41..690188704 100644 --- a/src/Bundle/ChillMainBundle/Templating/ChillMarkdownRenderExtension.php +++ b/src/Bundle/ChillMainBundle/Templating/ChillMarkdownRenderExtension.php @@ -34,7 +34,7 @@ final class ChillMarkdownRenderExtension extends AbstractExtension public function getFilters(): array { return [ - new TwigFilter('chill_markdown_to_html', [$this, 'renderMarkdownToHtml'], [ + new TwigFilter('chill_markdown_to_html', $this->renderMarkdownToHtml(...), [ 'is_safe' => ['html'], ]), ]; diff --git a/src/Bundle/ChillMainBundle/Templating/ChillTwigHelper.php b/src/Bundle/ChillMainBundle/Templating/ChillTwigHelper.php index 95b307ed7..56a729071 100644 --- a/src/Bundle/ChillMainBundle/Templating/ChillTwigHelper.php +++ b/src/Bundle/ChillMainBundle/Templating/ChillTwigHelper.php @@ -23,7 +23,7 @@ class ChillTwigHelper extends AbstractExtension public function getFilters() { return [ - new TwigFilter('chill_print_or_message', [$this, 'printOrMessage'], [ + new TwigFilter('chill_print_or_message', $this->printOrMessage(...), [ 'needs_environment' => true, 'is_safe' => ['html', 'html_attrs'], ]), diff --git a/src/Bundle/ChillMainBundle/Templating/ChillTwigRoutingHelper.php b/src/Bundle/ChillMainBundle/Templating/ChillTwigRoutingHelper.php index a01398210..1e55a8d74 100644 --- a/src/Bundle/ChillMainBundle/Templating/ChillTwigRoutingHelper.php +++ b/src/Bundle/ChillMainBundle/Templating/ChillTwigRoutingHelper.php @@ -46,16 +46,16 @@ class ChillTwigRoutingHelper extends AbstractExtension public function getFilters() { return [ - new TwigFilter('chill_return_path_label', [$this, 'getLabelReturnPath']), + new TwigFilter('chill_return_path_label', $this->getLabelReturnPath(...)), ]; } public function getFunctions() { return [ - new TwigFunction('chill_return_path_or', [$this, 'getReturnPathOr'], ['is_safe_callback' => [$this, 'isUrlGenerationSafe']]), - new TwigFunction('chill_path_add_return_path', [$this, 'getPathAddReturnPath'], ['is_safe_callback' => [$this, 'isUrlGenerationSafe']]), - new TwigFunction('chill_path_forward_return_path', [$this, 'getPathForwardReturnPath'], ['is_safe_callback' => [$this, 'isUrlGenerationSafe']]), + new TwigFunction('chill_return_path_or', $this->getReturnPathOr(...), ['is_safe_callback' => $this->isUrlGenerationSafe(...)]), + new TwigFunction('chill_path_add_return_path', $this->getPathAddReturnPath(...), ['is_safe_callback' => $this->isUrlGenerationSafe(...)]), + new TwigFunction('chill_path_forward_return_path', $this->getPathForwardReturnPath(...), ['is_safe_callback' => $this->isUrlGenerationSafe(...)]), ]; } diff --git a/src/Bundle/ChillMainBundle/Templating/Entity/AddressRender.php b/src/Bundle/ChillMainBundle/Templating/Entity/AddressRender.php index 668f7875a..c952bb5aa 100644 --- a/src/Bundle/ChillMainBundle/Templating/Entity/AddressRender.php +++ b/src/Bundle/ChillMainBundle/Templating/Entity/AddressRender.php @@ -25,7 +25,7 @@ use function strtr; */ class AddressRender implements ChillEntityRenderInterface { - public const DEFAULT_OPTIONS = [ + final public const DEFAULT_OPTIONS = [ 'with_valid_from' => false, 'with_valid_to' => false, 'with_picto' => false, @@ -36,7 +36,7 @@ class AddressRender implements ChillEntityRenderInterface 'extended_infos' => false, ]; - public function __construct(private EngineInterface $templating, private TranslatableStringHelperInterface $translatableStringHelper) + public function __construct(private readonly EngineInterface $templating, private readonly TranslatableStringHelperInterface $translatableStringHelper) { } diff --git a/src/Bundle/ChillMainBundle/Templating/Entity/ChillEntityRenderExtension.php b/src/Bundle/ChillMainBundle/Templating/Entity/ChillEntityRenderExtension.php index 967b3ca78..2a1c91fa2 100644 --- a/src/Bundle/ChillMainBundle/Templating/Entity/ChillEntityRenderExtension.php +++ b/src/Bundle/ChillMainBundle/Templating/Entity/ChillEntityRenderExtension.php @@ -44,10 +44,10 @@ class ChillEntityRenderExtension extends AbstractExtension public function getFilters() { return [ - new TwigFilter('chill_entity_render_string', [$this, 'renderString'], [ + new TwigFilter('chill_entity_render_string', $this->renderString(...), [ 'is_safe' => ['html'], ]), - new TwigFilter('chill_entity_render_box', [$this, 'renderBox'], [ + new TwigFilter('chill_entity_render_box', $this->renderBox(...), [ 'is_safe' => ['html'], ]), ]; diff --git a/src/Bundle/ChillMainBundle/Templating/Entity/CommentRender.php b/src/Bundle/ChillMainBundle/Templating/Entity/CommentRender.php index 464415848..ff8ea0dc3 100644 --- a/src/Bundle/ChillMainBundle/Templating/Entity/CommentRender.php +++ b/src/Bundle/ChillMainBundle/Templating/Entity/CommentRender.php @@ -25,7 +25,7 @@ class CommentRender implements ChillEntityRenderInterface { use BoxUtilsChillEntityRenderTrait; - public function __construct(private UserRepositoryInterface $userRepository, private EngineInterface $engine) + public function __construct(private readonly UserRepositoryInterface $userRepository, private readonly EngineInterface $engine) { } diff --git a/src/Bundle/ChillMainBundle/Templating/Entity/UserRender.php b/src/Bundle/ChillMainBundle/Templating/Entity/UserRender.php index e34440491..880ee8587 100644 --- a/src/Bundle/ChillMainBundle/Templating/Entity/UserRender.php +++ b/src/Bundle/ChillMainBundle/Templating/Entity/UserRender.php @@ -24,13 +24,13 @@ use function array_merge; */ class UserRender implements ChillEntityRenderInterface { - public const DEFAULT_OPTIONS = [ + final public const DEFAULT_OPTIONS = [ 'main_scope' => true, 'user_job' => true, 'absence' => true, ]; - public function __construct(private TranslatableStringHelper $translatableStringHelper, private EngineInterface $engine, private TranslatorInterface $translator) + public function __construct(private readonly TranslatableStringHelper $translatableStringHelper, private readonly EngineInterface $engine, private readonly TranslatorInterface $translator) { } diff --git a/src/Bundle/ChillMainBundle/Templating/Events/DelegatedBlockRenderingEvent.php b/src/Bundle/ChillMainBundle/Templating/Events/DelegatedBlockRenderingEvent.php index ce02789fd..c7a31b042 100644 --- a/src/Bundle/ChillMainBundle/Templating/Events/DelegatedBlockRenderingEvent.php +++ b/src/Bundle/ChillMainBundle/Templating/Events/DelegatedBlockRenderingEvent.php @@ -80,13 +80,13 @@ class DelegatedBlockRenderingEvent extends Event implements ArrayAccess return $this->context[$offset]; } - public function offsetSet($offset, $value): void + public function offsetSet($offset, $value): never { throw new RuntimeException('The event context is read-only, you are not ' . 'allowed to update it.'); } - public function offsetUnset($offset): void + public function offsetUnset($offset): never { throw new RuntimeException('The event context is read-only, you are not ' . 'allowed to update it.'); diff --git a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php index c8b3839c9..e9e5065b2 100644 --- a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php +++ b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php @@ -36,7 +36,7 @@ class FilterOrderHelper private ?array $submitted = null; - public function __construct(private FormFactoryInterface $formFactory, private RequestStack $requestStack) + public function __construct(private readonly FormFactoryInterface $formFactory, private readonly RequestStack $requestStack) { } diff --git a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperBuilder.php b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperBuilder.php index 770b42cae..206e57cea 100644 --- a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperBuilder.php +++ b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperBuilder.php @@ -23,7 +23,7 @@ class FilterOrderHelperBuilder private ?array $searchBoxFields = null; - public function __construct(private FormFactoryInterface $formFactory, private RequestStack $requestStack) + public function __construct(private readonly FormFactoryInterface $formFactory, private readonly RequestStack $requestStack) { } diff --git a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperFactory.php b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperFactory.php index 930da454c..c9c094a15 100644 --- a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperFactory.php +++ b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperFactory.php @@ -16,7 +16,7 @@ use Symfony\Component\HttpFoundation\RequestStack; class FilterOrderHelperFactory implements FilterOrderHelperFactoryInterface { - public function __construct(private FormFactoryInterface $formFactory, private RequestStack $requestStack) + public function __construct(private readonly FormFactoryInterface $formFactory, private readonly RequestStack $requestStack) { } diff --git a/src/Bundle/ChillMainBundle/Templating/Listing/Templating.php b/src/Bundle/ChillMainBundle/Templating/Listing/Templating.php index bc256e24f..4c3a1f3eb 100644 --- a/src/Bundle/ChillMainBundle/Templating/Listing/Templating.php +++ b/src/Bundle/ChillMainBundle/Templating/Listing/Templating.php @@ -20,7 +20,7 @@ class Templating extends AbstractExtension public function getFilters() { return [ - new TwigFilter('chill_render_filter_order_helper', [$this, 'renderFilterOrderHelper'], [ + new TwigFilter('chill_render_filter_order_helper', $this->renderFilterOrderHelper(...), [ 'needs_environment' => true, 'is_safe' => ['html'], ]), ]; diff --git a/src/Bundle/ChillMainBundle/Templating/TranslatableStringHelper.php b/src/Bundle/ChillMainBundle/Templating/TranslatableStringHelper.php index 6136ffc3e..924e1a2be 100644 --- a/src/Bundle/ChillMainBundle/Templating/TranslatableStringHelper.php +++ b/src/Bundle/ChillMainBundle/Templating/TranslatableStringHelper.php @@ -19,9 +19,9 @@ use function array_key_exists; final class TranslatableStringHelper implements TranslatableStringHelperInterface { - private string $defaultLocale; + private readonly string $defaultLocale; - public function __construct(private RequestStack $requestStack, private TranslatorInterface $translator, ParameterBagInterface $parameterBag) + public function __construct(private readonly RequestStack $requestStack, private readonly TranslatorInterface $translator, ParameterBagInterface $parameterBag) { $this->defaultLocale = $parameterBag->get('kernel.default_locale'); } diff --git a/src/Bundle/ChillMainBundle/Templating/TranslatableStringTwig.php b/src/Bundle/ChillMainBundle/Templating/TranslatableStringTwig.php index aaefdeeae..512d8bd2a 100644 --- a/src/Bundle/ChillMainBundle/Templating/TranslatableStringTwig.php +++ b/src/Bundle/ChillMainBundle/Templating/TranslatableStringTwig.php @@ -22,7 +22,7 @@ class TranslatableStringTwig extends AbstractExtension /** * TranslatableStringTwig constructor. */ - public function __construct(private TranslatableStringHelper $helper) + public function __construct(private readonly TranslatableStringHelper $helper) { } @@ -38,7 +38,7 @@ class TranslatableStringTwig extends AbstractExtension return [ new TwigFilter( 'localize_translatable_string', - [$this, 'localize'] + $this->localize(...) ), ]; } diff --git a/src/Bundle/ChillMainBundle/Templating/Widget/WidgetRenderingTwig.php b/src/Bundle/ChillMainBundle/Templating/Widget/WidgetRenderingTwig.php index 9b752c439..c38f410d4 100644 --- a/src/Bundle/ChillMainBundle/Templating/Widget/WidgetRenderingTwig.php +++ b/src/Bundle/ChillMainBundle/Templating/Widget/WidgetRenderingTwig.php @@ -92,7 +92,7 @@ class WidgetRenderingTwig extends AbstractExtension return [ new TwigFunction( 'chill_delegated_block', - [$this, 'renderingWidget'], + $this->renderingWidget(...), [ 'is_safe' => ['html'], 'needs_environment' => true, @@ -101,7 +101,7 @@ class WidgetRenderingTwig extends AbstractExtension ), new TwigFunction( 'chill_widget', - [$this, 'renderingWidget'], + $this->renderingWidget(...), ['is_safe' => ['html'], 'needs_environment' => true] ), ]; diff --git a/src/Bundle/ChillMainBundle/Tests/Controller/PermissionsGroupControllerTest.php b/src/Bundle/ChillMainBundle/Tests/Controller/PermissionsGroupControllerTest.php index cbb3e3601..1c2ffe4d3 100644 --- a/src/Bundle/ChillMainBundle/Tests/Controller/PermissionsGroupControllerTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Controller/PermissionsGroupControllerTest.php @@ -19,7 +19,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; */ final class PermissionsGroupControllerTest extends WebTestCase { - public function testEmpty() + public function testEmpty(): never { $this->markTestSkipped(); } diff --git a/src/Bundle/ChillMainBundle/Tests/Cron/CronManagerTest.php b/src/Bundle/ChillMainBundle/Tests/Cron/CronManagerTest.php index 98de6891f..20a3027b3 100644 --- a/src/Bundle/ChillMainBundle/Tests/Cron/CronManagerTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Cron/CronManagerTest.php @@ -161,7 +161,7 @@ final class CronManagerTest extends TestCase class JobCanRun implements CronJobInterface { - public function __construct(private string $key) + public function __construct(private readonly string $key) { } diff --git a/src/Bundle/ChillMainBundle/Tests/Form/Type/PickCenterTypeTest.php b/src/Bundle/ChillMainBundle/Tests/Form/Type/PickCenterTypeTest.php index ffb7c6bed..db1d701f6 100644 --- a/src/Bundle/ChillMainBundle/Tests/Form/Type/PickCenterTypeTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Form/Type/PickCenterTypeTest.php @@ -28,7 +28,7 @@ final class PickCenterTypeTest extends TypeTestCase * Test that a user which can reach multiple center * make CenterType render as "entity" type. */ - public function testUserCanReachMultipleCenters() + public function testUserCanReachMultipleCenters(): never { $this->markTestSkipped(); //prepare user @@ -51,7 +51,7 @@ final class PickCenterTypeTest extends TypeTestCase * Test that a user which can reach only one center * render as an hidden field. */ - public function testUserCanReachMultipleSameCenter() + public function testUserCanReachMultipleSameCenter(): never { $this->markTestSkipped(); //prepare user @@ -73,7 +73,7 @@ final class PickCenterTypeTest extends TypeTestCase * Test that a user which can reach only one center * render as an hidden field. */ - public function testUserCanReachSingleCenter() + public function testUserCanReachSingleCenter(): never { $this->markTestSkipped(); //prepare user diff --git a/src/Bundle/ChillMainBundle/Tests/Search/AbstractSearchTest.php b/src/Bundle/ChillMainBundle/Tests/Search/AbstractSearchTest.php index 9348c6fe2..afe10b4ec 100644 --- a/src/Bundle/ChillMainBundle/Tests/Search/AbstractSearchTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Search/AbstractSearchTest.php @@ -38,7 +38,7 @@ final class AbstractSearchTest extends \PHPUnit\Framework\TestCase $this->assertEquals('01', $date->format('d')); } - public function testRecompose() + public function testRecompose(): never { $this->markTestSkipped(); } diff --git a/src/Bundle/ChillMainBundle/Tests/Services/Import/GeographicalUnitBaseImporterTest.php b/src/Bundle/ChillMainBundle/Tests/Services/Import/GeographicalUnitBaseImporterTest.php index b3bd856ff..757e13c2f 100644 --- a/src/Bundle/ChillMainBundle/Tests/Services/Import/GeographicalUnitBaseImporterTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Services/Import/GeographicalUnitBaseImporterTest.php @@ -64,7 +64,7 @@ final class GeographicalUnitBaseImporterTest extends KernelTestCase $this->assertEquals($results['unitrefid'], 'layer_one'); $this->assertEquals($results['unitname'], 'Layer one'); - $this->assertEquals(json_decode($results['layername'], true, 512, JSON_THROW_ON_ERROR), ['fr' => 'Test Layer']); + $this->assertEquals(json_decode((string) $results['layername'], true, 512, JSON_THROW_ON_ERROR), ['fr' => 'Test Layer']); $this->assertEquals($results['layerrefid'], 'test'); $this->assertEquals($results['geom'], 'MULTIPOLYGON(((30 20,45 40,10 40,30 20)),((15 5,40 10,10 20,5 10,15 5)))'); @@ -93,7 +93,7 @@ final class GeographicalUnitBaseImporterTest extends KernelTestCase $this->assertEquals($results['unitrefid'], 'layer_one'); $this->assertEquals($results['unitname'], 'Layer one fixed'); - $this->assertEquals(json_decode($results['layername'], true, 512, JSON_THROW_ON_ERROR), ['fr' => 'Test Layer fixed']); + $this->assertEquals(json_decode((string) $results['layername'], true, 512, JSON_THROW_ON_ERROR), ['fr' => 'Test Layer fixed']); $this->assertEquals($results['layerrefid'], 'test'); $this->assertEquals($results['geom'], 'MULTIPOLYGON(((130 120,45 40,10 40,130 120)),((0 0,15 5,40 10,10 20,0 0)))'); } diff --git a/src/Bundle/ChillMainBundle/Timeline/TimelineBuilder.php b/src/Bundle/ChillMainBundle/Timeline/TimelineBuilder.php index c223bc375..df700324b 100644 --- a/src/Bundle/ChillMainBundle/Timeline/TimelineBuilder.php +++ b/src/Bundle/ChillMainBundle/Timeline/TimelineBuilder.php @@ -47,7 +47,7 @@ class TimelineBuilder implements ContainerAwareInterface */ private $providersByContext = []; - public function __construct(private EntityManagerInterface $em) + public function __construct(private readonly EntityManagerInterface $em) { } diff --git a/src/Bundle/ChillMainBundle/Util/DateRangeCovering.php b/src/Bundle/ChillMainBundle/Util/DateRangeCovering.php index 7ddecf70c..e5d3de41a 100644 --- a/src/Bundle/ChillMainBundle/Util/DateRangeCovering.php +++ b/src/Bundle/ChillMainBundle/Util/DateRangeCovering.php @@ -65,7 +65,7 @@ class DateRangeCovering private array $metadatas = []; - private int $minCover; + private readonly int $minCover; private array $sequence = []; @@ -74,7 +74,7 @@ class DateRangeCovering /** * @param int $minCover the minimum of covering required */ - public function __construct(int $minCover, private DateTimeZone $tz) + public function __construct(int $minCover, private readonly DateTimeZone $tz) { if (0 > $minCover) { throw new LogicException('argument minCover cannot be lower than 0'); diff --git a/src/Bundle/ChillMainBundle/Validation/Validator/RoleScopeScopePresence.php b/src/Bundle/ChillMainBundle/Validation/Validator/RoleScopeScopePresence.php index 1ffb767e3..cff4d34c7 100644 --- a/src/Bundle/ChillMainBundle/Validation/Validator/RoleScopeScopePresence.php +++ b/src/Bundle/ChillMainBundle/Validation/Validator/RoleScopeScopePresence.php @@ -24,7 +24,7 @@ use function in_array; class RoleScopeScopePresence extends ConstraintValidator { - public function __construct(private RoleProvider $roleProvider, private LoggerInterface $logger, private TranslatorInterface $translator) + public function __construct(private readonly RoleProvider $roleProvider, private readonly LoggerInterface $logger, private readonly TranslatorInterface $translator) { } diff --git a/src/Bundle/ChillMainBundle/Validation/Validator/ValidPhonenumber.php b/src/Bundle/ChillMainBundle/Validation/Validator/ValidPhonenumber.php index 0c9eae2c4..ab38e5081 100644 --- a/src/Bundle/ChillMainBundle/Validation/Validator/ValidPhonenumber.php +++ b/src/Bundle/ChillMainBundle/Validation/Validator/ValidPhonenumber.php @@ -19,7 +19,7 @@ use Symfony\Component\Validator\ConstraintValidator; final class ValidPhonenumber extends ConstraintValidator { - public function __construct(private LoggerInterface $logger, private PhoneNumberHelperInterface $phonenumberHelper) + public function __construct(private readonly LoggerInterface $logger, private readonly PhoneNumberHelperInterface $phonenumberHelper) { } diff --git a/src/Bundle/ChillMainBundle/Workflow/Counter/WorkflowByUserCounter.php b/src/Bundle/ChillMainBundle/Workflow/Counter/WorkflowByUserCounter.php index 3dc5928d6..2735a265f 100644 --- a/src/Bundle/ChillMainBundle/Workflow/Counter/WorkflowByUserCounter.php +++ b/src/Bundle/ChillMainBundle/Workflow/Counter/WorkflowByUserCounter.php @@ -20,7 +20,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Workflow\Event\Event; -final class WorkflowByUserCounter implements NotificationCounterInterface, EventSubscriberInterface +final readonly class WorkflowByUserCounter implements NotificationCounterInterface, EventSubscriberInterface { public function __construct(private EntityWorkflowStepRepository $workflowStepRepository, private CacheItemPoolInterface $cacheItemPool) { diff --git a/src/Bundle/ChillMainBundle/Workflow/EntityWorkflowManager.php b/src/Bundle/ChillMainBundle/Workflow/EntityWorkflowManager.php index 2f5356e6e..6c45cef3d 100644 --- a/src/Bundle/ChillMainBundle/Workflow/EntityWorkflowManager.php +++ b/src/Bundle/ChillMainBundle/Workflow/EntityWorkflowManager.php @@ -20,7 +20,7 @@ class EntityWorkflowManager /** * @param \Chill\MainBundle\Workflow\EntityWorkflowHandlerInterface[] $handlers */ - public function __construct(private iterable $handlers, private Registry $registry) + public function __construct(private readonly iterable $handlers, private readonly Registry $registry) { } diff --git a/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/EntityWorkflowTransitionEventSubscriber.php b/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/EntityWorkflowTransitionEventSubscriber.php index 3657e4f53..981c798dd 100644 --- a/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/EntityWorkflowTransitionEventSubscriber.php +++ b/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/EntityWorkflowTransitionEventSubscriber.php @@ -25,7 +25,7 @@ use function array_key_exists; class EntityWorkflowTransitionEventSubscriber implements EventSubscriberInterface { - public function __construct(private LoggerInterface $chillLogger, private Security $security, private UserRender $userRender) + public function __construct(private readonly LoggerInterface $chillLogger, private readonly Security $security, private readonly UserRender $userRender) { } diff --git a/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/NotificationOnTransition.php b/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/NotificationOnTransition.php index ceeb3023f..78b165a85 100644 --- a/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/NotificationOnTransition.php +++ b/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/NotificationOnTransition.php @@ -25,7 +25,7 @@ use function in_array; class NotificationOnTransition implements EventSubscriberInterface { - public function __construct(private EntityManagerInterface $entityManager, private EngineInterface $engine, private MetadataExtractor $metadataExtractor, private Security $security, private Registry $registry) + public function __construct(private readonly EntityManagerInterface $entityManager, private readonly EngineInterface $engine, private readonly MetadataExtractor $metadataExtractor, private readonly Security $security, private readonly Registry $registry) { } diff --git a/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/SendAccessKeyEventSubscriber.php b/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/SendAccessKeyEventSubscriber.php index b1ce5074c..adf19fb92 100644 --- a/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/SendAccessKeyEventSubscriber.php +++ b/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/SendAccessKeyEventSubscriber.php @@ -21,7 +21,7 @@ use Symfony\Component\Workflow\Registry; class SendAccessKeyEventSubscriber { - public function __construct(private EngineInterface $engine, private MetadataExtractor $metadataExtractor, private Registry $registry, private EntityWorkflowManager $entityWorkflowManager, private MailerInterface $mailer) + public function __construct(private readonly EngineInterface $engine, private readonly MetadataExtractor $metadataExtractor, private readonly Registry $registry, private readonly EntityWorkflowManager $entityWorkflowManager, private readonly MailerInterface $mailer) { } diff --git a/src/Bundle/ChillMainBundle/Workflow/Helper/MetadataExtractor.php b/src/Bundle/ChillMainBundle/Workflow/Helper/MetadataExtractor.php index 87026e920..9adffec8e 100644 --- a/src/Bundle/ChillMainBundle/Workflow/Helper/MetadataExtractor.php +++ b/src/Bundle/ChillMainBundle/Workflow/Helper/MetadataExtractor.php @@ -20,7 +20,7 @@ use function array_key_exists; class MetadataExtractor { - public function __construct(private Registry $registry, private TranslatableStringHelperInterface $translatableStringHelper) + public function __construct(private readonly Registry $registry, private readonly TranslatableStringHelperInterface $translatableStringHelper) { } diff --git a/src/Bundle/ChillMainBundle/Workflow/Notification/WorkflowNotificationHandler.php b/src/Bundle/ChillMainBundle/Workflow/Notification/WorkflowNotificationHandler.php index 9f286508c..bf55d8542 100644 --- a/src/Bundle/ChillMainBundle/Workflow/Notification/WorkflowNotificationHandler.php +++ b/src/Bundle/ChillMainBundle/Workflow/Notification/WorkflowNotificationHandler.php @@ -20,7 +20,7 @@ use Symfony\Component\Security\Core\Security; class WorkflowNotificationHandler implements NotificationHandlerInterface { - public function __construct(private EntityWorkflowRepository $entityWorkflowRepository, private EntityWorkflowManager $entityWorkflowManager, private Security $security) + public function __construct(private readonly EntityWorkflowRepository $entityWorkflowRepository, private readonly EntityWorkflowManager $entityWorkflowManager, private readonly Security $security) { } diff --git a/src/Bundle/ChillMainBundle/Workflow/Templating/WorkflowTwigExtensionRuntime.php b/src/Bundle/ChillMainBundle/Workflow/Templating/WorkflowTwigExtensionRuntime.php index d1381a397..e9edb11d9 100644 --- a/src/Bundle/ChillMainBundle/Workflow/Templating/WorkflowTwigExtensionRuntime.php +++ b/src/Bundle/ChillMainBundle/Workflow/Templating/WorkflowTwigExtensionRuntime.php @@ -23,7 +23,7 @@ use Twig\Extension\RuntimeExtensionInterface; class WorkflowTwigExtensionRuntime implements RuntimeExtensionInterface { - public function __construct(private EntityWorkflowManager $entityWorkflowManager, private Registry $registry, private EntityWorkflowRepository $repository, private MetadataExtractor $metadataExtractor, private NormalizerInterface $normalizer) + public function __construct(private readonly EntityWorkflowManager $entityWorkflowManager, private readonly Registry $registry, private readonly EntityWorkflowRepository $repository, private readonly MetadataExtractor $metadataExtractor, private readonly NormalizerInterface $normalizer) { } diff --git a/src/Bundle/ChillMainBundle/Workflow/Validator/EntityWorkflowCreationValidator.php b/src/Bundle/ChillMainBundle/Workflow/Validator/EntityWorkflowCreationValidator.php index eb035358d..e55eb6915 100644 --- a/src/Bundle/ChillMainBundle/Workflow/Validator/EntityWorkflowCreationValidator.php +++ b/src/Bundle/ChillMainBundle/Workflow/Validator/EntityWorkflowCreationValidator.php @@ -22,7 +22,7 @@ use function count; class EntityWorkflowCreationValidator extends \Symfony\Component\Validator\ConstraintValidator { - public function __construct(private EntityWorkflowManager $entityWorkflowManager) + public function __construct(private readonly EntityWorkflowManager $entityWorkflowManager) { } diff --git a/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Events/PersonAddressMoveEventSubscriber.php b/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Events/PersonAddressMoveEventSubscriber.php index a24d8adb4..ce26780a4 100644 --- a/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Events/PersonAddressMoveEventSubscriber.php +++ b/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Events/PersonAddressMoveEventSubscriber.php @@ -24,7 +24,7 @@ use Symfony\Contracts\Translation\TranslatorInterface; class PersonAddressMoveEventSubscriber implements EventSubscriberInterface { - public function __construct(private EngineInterface $engine, private NotificationPersisterInterface $notificationPersister, private Security $security, private TranslatorInterface $translator) + public function __construct(private readonly EngineInterface $engine, private readonly NotificationPersisterInterface $notificationPersister, private readonly Security $security, private readonly TranslatorInterface $translator) { } diff --git a/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Events/UserRefEventSubscriber.php b/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Events/UserRefEventSubscriber.php index cefc348c2..b8ca31835 100644 --- a/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Events/UserRefEventSubscriber.php +++ b/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Events/UserRefEventSubscriber.php @@ -24,7 +24,7 @@ use Symfony\Contracts\Translation\TranslatorInterface; class UserRefEventSubscriber implements EventSubscriberInterface { - public function __construct(private Security $security, private TranslatorInterface $translator, private EngineInterface $engine, private NotificationPersisterInterface $notificationPersister) + public function __construct(private readonly Security $security, private readonly TranslatorInterface $translator, private readonly EngineInterface $engine, private readonly NotificationPersisterInterface $notificationPersister) { } diff --git a/src/Bundle/ChillPersonBundle/Actions/ActionEvent.php b/src/Bundle/ChillPersonBundle/Actions/ActionEvent.php index b3a335ce7..c0935b995 100644 --- a/src/Bundle/ChillPersonBundle/Actions/ActionEvent.php +++ b/src/Bundle/ChillPersonBundle/Actions/ActionEvent.php @@ -18,9 +18,9 @@ use Symfony\Component\EventDispatcher\Event; */ class ActionEvent extends Event { - public const DELETE = 'CHILL_PERSON.DELETE_ASSOCIATED_ENTITY'; + final public const DELETE = 'CHILL_PERSON.DELETE_ASSOCIATED_ENTITY'; - public const MOVE = 'CHILL_PERSON.MOVE_ASSOCIATED_ENTITY'; + final public const MOVE = 'CHILL_PERSON.MOVE_ASSOCIATED_ENTITY'; /** * @var string[] diff --git a/src/Bundle/ChillPersonBundle/CRUD/Controller/OneToOneEntityPersonCRUDController.php b/src/Bundle/ChillPersonBundle/CRUD/Controller/OneToOneEntityPersonCRUDController.php index f9c53712a..52599e162 100644 --- a/src/Bundle/ChillPersonBundle/CRUD/Controller/OneToOneEntityPersonCRUDController.php +++ b/src/Bundle/ChillPersonBundle/CRUD/Controller/OneToOneEntityPersonCRUDController.php @@ -22,7 +22,7 @@ use Symfony\Component\HttpFoundation\Response; class OneToOneEntityPersonCRUDController extends CRUDController { - protected function generateRedirectOnCreateRoute($action, Request $request, $entity) + protected function generateRedirectOnCreateRoute($action, Request $request, $entity): never { throw new BadMethodCallException('Not implemented yet.'); } diff --git a/src/Bundle/ChillPersonBundle/Command/ChillPersonMoveCommand.php b/src/Bundle/ChillPersonBundle/Command/ChillPersonMoveCommand.php index 42b8f6cac..4817e3819 100644 --- a/src/Bundle/ChillPersonBundle/Command/ChillPersonMoveCommand.php +++ b/src/Bundle/ChillPersonBundle/Command/ChillPersonMoveCommand.php @@ -26,9 +26,9 @@ use function ctype_digit; final class ChillPersonMoveCommand extends Command { public function __construct( - private PersonMove $mover, - private EntityManagerInterface $em, - private LoggerInterface $chillLogger + private readonly PersonMove $mover, + private readonly EntityManagerInterface $em, + private readonly LoggerInterface $chillLogger ) { parent::__construct('chill:person:move'); } @@ -116,7 +116,7 @@ final class ChillPersonMoveCommand extends Command } $id = $input->getOption($name); - if (ctype_digit($id) === false) { + if (ctype_digit((string) $id) === false) { throw new RuntimeException("The id in \"{$name}\" field does not contains " . "only digits: {$id}"); } diff --git a/src/Bundle/ChillPersonBundle/Command/RemoveOldDraftAccompanyingPeriodCommand.php b/src/Bundle/ChillPersonBundle/Command/RemoveOldDraftAccompanyingPeriodCommand.php index ac6551bd2..b903b84b3 100644 --- a/src/Bundle/ChillPersonBundle/Command/RemoveOldDraftAccompanyingPeriodCommand.php +++ b/src/Bundle/ChillPersonBundle/Command/RemoveOldDraftAccompanyingPeriodCommand.php @@ -22,7 +22,7 @@ use Symfony\Component\Console\Output\OutputInterface; class RemoveOldDraftAccompanyingPeriodCommand extends Command { - public function __construct(private LoggerInterface $logger, private OldDraftAccompanyingPeriodRemoverInterface $remover) + public function __construct(private readonly LoggerInterface $logger, private readonly OldDraftAccompanyingPeriodRemoverInterface $remover) { parent::__construct('chill:person:remove-old-draft-period'); } diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php index 10329a87c..027279d04 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php @@ -51,7 +51,7 @@ use function count; final class AccompanyingCourseApiController extends ApiController { - public function __construct(private AccompanyingPeriodRepository $accompanyingPeriodRepository, private AccompanyingPeriodACLAwareRepository $accompanyingPeriodACLAwareRepository, private EventDispatcherInterface $eventDispatcher, private ReferralsSuggestionInterface $referralAvailable, private Registry $registry, private ValidatorInterface $validator) + public function __construct(private readonly AccompanyingPeriodRepository $accompanyingPeriodRepository, private readonly AccompanyingPeriodACLAwareRepository $accompanyingPeriodACLAwareRepository, private readonly EventDispatcherInterface $eventDispatcher, private readonly ReferralsSuggestionInterface $referralAvailable, private readonly Registry $registry, private readonly ValidatorInterface $validator) { } diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseCommentController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseCommentController.php index 99608d640..73c018052 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseCommentController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseCommentController.php @@ -32,7 +32,7 @@ use Symfony\Contracts\Translation\TranslatorInterface; class AccompanyingCourseCommentController extends AbstractController { - public function __construct(private EntityManagerInterface $entityManager, private FormFactoryInterface $formFactory, private TranslatorInterface $translator) + public function __construct(private readonly EntityManagerInterface $entityManager, private readonly FormFactoryInterface $formFactory, private readonly TranslatorInterface $translator) { } diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php index 41e4a9b90..344b52642 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php @@ -41,7 +41,7 @@ use function is_array; */ class AccompanyingCourseController extends Controller { - public function __construct(protected SerializerInterface $serializer, protected EventDispatcherInterface $dispatcher, protected ValidatorInterface $validator, private AccompanyingPeriodWorkRepository $workRepository, private Registry $registry, private TranslatorInterface $translator) + public function __construct(protected SerializerInterface $serializer, protected EventDispatcherInterface $dispatcher, protected ValidatorInterface $validator, private readonly AccompanyingPeriodWorkRepository $workRepository, private readonly Registry $registry, private readonly TranslatorInterface $translator) { } diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkApiController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkApiController.php index f57ad0c56..8573f547b 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkApiController.php @@ -23,7 +23,7 @@ use Symfony\Component\Routing\Annotation\Route; class AccompanyingCourseWorkApiController extends ApiController { - public function __construct(private AccompanyingPeriodWorkRepository $accompanyingPeriodWorkRepository) + public function __construct(private readonly AccompanyingPeriodWorkRepository $accompanyingPeriodWorkRepository) { } diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php index a36ad67b0..d4f316068 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php @@ -28,7 +28,7 @@ use Symfony\Contracts\Translation\TranslatorInterface; class AccompanyingCourseWorkController extends AbstractController { - public function __construct(private TranslatorInterface $trans, private SerializerInterface $serializer, private AccompanyingPeriodWorkRepository $workRepository, private PaginatorFactory $paginator, private LoggerInterface $chillLogger) + public function __construct(private readonly TranslatorInterface $trans, private readonly SerializerInterface $serializer, private readonly AccompanyingPeriodWorkRepository $workRepository, private readonly PaginatorFactory $paginator, private readonly LoggerInterface $chillLogger) { } diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodRegulationListController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodRegulationListController.php index 34aeb835a..5ce844a90 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodRegulationListController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodRegulationListController.php @@ -32,7 +32,7 @@ use Symfony\Component\Templating\EngineInterface; class AccompanyingPeriodRegulationListController { - public function __construct(private AccompanyingPeriodACLAwareRepositoryInterface $accompanyingPeriodACLAwareRepository, private EngineInterface $engine, private FormFactoryInterface $formFactory, private PaginatorFactory $paginatorFactory, private Security $security, private TranslatableStringHelperInterface $translatableStringHelper) + public function __construct(private readonly AccompanyingPeriodACLAwareRepositoryInterface $accompanyingPeriodACLAwareRepository, private readonly EngineInterface $engine, private readonly FormFactoryInterface $formFactory, private readonly PaginatorFactory $paginatorFactory, private readonly Security $security, private readonly TranslatableStringHelperInterface $translatableStringHelper) { } diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodWorkEvaluationApiController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodWorkEvaluationApiController.php index 9a4b5e15a..914c8afde 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodWorkEvaluationApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodWorkEvaluationApiController.php @@ -32,7 +32,7 @@ use function in_array; class AccompanyingPeriodWorkEvaluationApiController { - public function __construct(private AccompanyingPeriodWorkEvaluationRepository $accompanyingPeriodWorkEvaluationRepository, private DocGeneratorTemplateRepository $docGeneratorTemplateRepository, private SerializerInterface $serializer, private PaginatorFactory $paginatorFactory, private Security $security) + public function __construct(private readonly AccompanyingPeriodWorkEvaluationRepository $accompanyingPeriodWorkEvaluationRepository, private readonly DocGeneratorTemplateRepository $docGeneratorTemplateRepository, private readonly SerializerInterface $serializer, private readonly PaginatorFactory $paginatorFactory, private readonly Security $security) { } diff --git a/src/Bundle/ChillPersonBundle/Controller/HouseholdApiController.php b/src/Bundle/ChillPersonBundle/Controller/HouseholdApiController.php index 695caa976..8d6072132 100644 --- a/src/Bundle/ChillPersonBundle/Controller/HouseholdApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/HouseholdApiController.php @@ -35,7 +35,7 @@ use function array_values; class HouseholdApiController extends ApiController { - public function __construct(private EventDispatcherInterface $eventDispatcher, private HouseholdRepository $householdRepository, private HouseholdACLAwareRepositoryInterface $householdACLAwareRepository) + public function __construct(private readonly EventDispatcherInterface $eventDispatcher, private readonly HouseholdRepository $householdRepository, private readonly HouseholdACLAwareRepositoryInterface $householdACLAwareRepository) { } diff --git a/src/Bundle/ChillPersonBundle/Controller/HouseholdCompositionController.php b/src/Bundle/ChillPersonBundle/Controller/HouseholdCompositionController.php index 1abb6290f..01810feeb 100644 --- a/src/Bundle/ChillPersonBundle/Controller/HouseholdCompositionController.php +++ b/src/Bundle/ChillPersonBundle/Controller/HouseholdCompositionController.php @@ -36,7 +36,7 @@ use Symfony\Contracts\Translation\TranslatorInterface; class HouseholdCompositionController extends AbstractController { - public function __construct(private Security $security, private HouseholdCompositionRepository $householdCompositionRepository, private HouseholdRepository $householdRepository, private PaginatorFactory $paginatorFactory, private FormFactoryInterface $formFactory, private EntityManagerInterface $entityManager, private TranslatorInterface $translator, private EngineInterface $engine, private UrlGeneratorInterface $urlGenerator) + public function __construct(private readonly Security $security, private readonly HouseholdCompositionRepository $householdCompositionRepository, private readonly HouseholdRepository $householdRepository, private readonly PaginatorFactory $paginatorFactory, private readonly FormFactoryInterface $formFactory, private readonly EntityManagerInterface $entityManager, private readonly TranslatorInterface $translator, private readonly EngineInterface $engine, private readonly UrlGeneratorInterface $urlGenerator) { } diff --git a/src/Bundle/ChillPersonBundle/Controller/HouseholdController.php b/src/Bundle/ChillPersonBundle/Controller/HouseholdController.php index 9c4ae1441..ea120920c 100644 --- a/src/Bundle/ChillPersonBundle/Controller/HouseholdController.php +++ b/src/Bundle/ChillPersonBundle/Controller/HouseholdController.php @@ -37,7 +37,7 @@ use function count; */ class HouseholdController extends AbstractController { - public function __construct(private TranslatorInterface $translator, private PositionRepository $positionRepository, private SerializerInterface $serializer, private Security $security) + public function __construct(private readonly TranslatorInterface $translator, private readonly PositionRepository $positionRepository, private readonly SerializerInterface $serializer, private readonly Security $security) { } diff --git a/src/Bundle/ChillPersonBundle/Controller/HouseholdMemberController.php b/src/Bundle/ChillPersonBundle/Controller/HouseholdMemberController.php index 24cda5fc1..0506feda1 100644 --- a/src/Bundle/ChillPersonBundle/Controller/HouseholdMemberController.php +++ b/src/Bundle/ChillPersonBundle/Controller/HouseholdMemberController.php @@ -32,7 +32,7 @@ use function count; class HouseholdMemberController extends ApiController { - public function __construct(private UrlGeneratorInterface $generator, private TranslatorInterface $translator, private AccompanyingPeriodRepository $periodRepository) + public function __construct(private readonly UrlGeneratorInterface $generator, private readonly TranslatorInterface $translator, private readonly AccompanyingPeriodRepository $periodRepository) { } diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php b/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php index a3513fc1a..f7265537d 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php @@ -27,11 +27,11 @@ use function in_array; class PersonApiController extends ApiController { - private bool $showCenters; + private readonly bool $showCenters; public function __construct( - private AuthorizedCenterOnPersonCreationInterface $authorizedCenterOnPersonCreation, - private ConfigPersonAltNamesHelper $configPersonAltNameHelper, + private readonly AuthorizedCenterOnPersonCreationInterface $authorizedCenterOnPersonCreation, + private readonly ConfigPersonAltNamesHelper $configPersonAltNameHelper, ParameterBagInterface $parameterBag ) { $this->showCenters = $parameterBag->get('chill_main')['acl']['form_show_centers']; diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonController.php b/src/Bundle/ChillPersonBundle/Controller/PersonController.php index 016577130..448eb4f01 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonController.php @@ -48,7 +48,7 @@ use function is_array; final class PersonController extends AbstractController { public function __construct( - private AuthorizationHelperInterface $authorizationHelper, + private readonly AuthorizationHelperInterface $authorizationHelper, protected SimilarPersonMatcher $similarPersonMatcher, protected TranslatorInterface $translator, protected EventDispatcherInterface $eventDispatcher, @@ -57,9 +57,9 @@ final class PersonController extends AbstractController */ protected PersonRepository $personRepository, protected ConfigPersonAltNamesHelper $configPersonAltNameHelper, - private LoggerInterface $logger, - private ValidatorInterface $validator, - private EntityManagerInterface $em + private readonly LoggerInterface $logger, + private readonly ValidatorInterface $validator, + private readonly EntityManagerInterface $em ) { } diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php b/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php index d699937f4..aa7171639 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php @@ -34,7 +34,7 @@ use function count; class PersonDuplicateController extends Controller { - public function __construct(private SimilarPersonMatcher $similarPersonMatcher, private TranslatorInterface $translator, private PersonRepository $personRepository, private PersonMove $personMove, private EventDispatcherInterface $eventDispatcher) + public function __construct(private readonly SimilarPersonMatcher $similarPersonMatcher, private readonly TranslatorInterface $translator, private readonly PersonRepository $personRepository, private readonly PersonMove $personMove, private readonly EventDispatcherInterface $eventDispatcher) { } diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonResourceController.php b/src/Bundle/ChillPersonBundle/Controller/PersonResourceController.php index a1b852ba0..432852331 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonResourceController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonResourceController.php @@ -25,7 +25,7 @@ use Symfony\Contracts\Translation\TranslatorInterface; final class PersonResourceController extends AbstractController { - public function __construct(private PersonResourceRepository $personResourceRepository, private PersonRepository $personRepository, private EntityManagerInterface $em, private TranslatorInterface $translator) + public function __construct(private readonly PersonResourceRepository $personResourceRepository, private readonly PersonRepository $personRepository, private readonly EntityManagerInterface $em, private readonly TranslatorInterface $translator) { } diff --git a/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php b/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php index 2a90c57a8..6bfd7ac86 100644 --- a/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php +++ b/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php @@ -40,7 +40,7 @@ use function is_int; class ReassignAccompanyingPeriodController extends AbstractController { - public function __construct(private AccompanyingPeriodACLAwareRepositoryInterface $accompanyingPeriodACLAwareRepository, private UserRepository $userRepository, private AccompanyingPeriodRepository $courseRepository, private EngineInterface $engine, private FormFactoryInterface $formFactory, private PaginatorFactory $paginatorFactory, private Security $security, private UserRender $userRender, private EntityManagerInterface $em) + public function __construct(private readonly AccompanyingPeriodACLAwareRepositoryInterface $accompanyingPeriodACLAwareRepository, private readonly UserRepository $userRepository, private readonly AccompanyingPeriodRepository $courseRepository, private readonly EngineInterface $engine, private readonly FormFactoryInterface $formFactory, private readonly PaginatorFactory $paginatorFactory, private readonly Security $security, private readonly UserRender $userRender, private readonly EntityManagerInterface $em) { } @@ -84,7 +84,7 @@ class ReassignAccompanyingPeriodController extends AbstractController $assignForm->handleRequest($request); if ($assignForm->isSubmitted() && $assignForm->isValid()) { - $assignPeriodIds = json_decode($assignForm->get('periods')->getData(), true, 512, JSON_THROW_ON_ERROR); + $assignPeriodIds = json_decode((string) $assignForm->get('periods')->getData(), true, 512, JSON_THROW_ON_ERROR); $userTo = $assignForm->get('userTo')->getData(); $userFrom = $assignForm->get('userFrom')->getData(); diff --git a/src/Bundle/ChillPersonBundle/Controller/RelationshipApiController.php b/src/Bundle/ChillPersonBundle/Controller/RelationshipApiController.php index 4d11e2620..eac149245 100644 --- a/src/Bundle/ChillPersonBundle/Controller/RelationshipApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/RelationshipApiController.php @@ -21,7 +21,7 @@ use Symfony\Component\Validator\Validator\ValidatorInterface; class RelationshipApiController extends ApiController { - public function __construct(private ValidatorInterface $validator, private RelationshipRepository $repository) + public function __construct(private readonly ValidatorInterface $validator, private readonly RelationshipRepository $repository) { } diff --git a/src/Bundle/ChillPersonBundle/Controller/ResidentialAddressController.php b/src/Bundle/ChillPersonBundle/Controller/ResidentialAddressController.php index 7daf926fc..6d2b92438 100644 --- a/src/Bundle/ChillPersonBundle/Controller/ResidentialAddressController.php +++ b/src/Bundle/ChillPersonBundle/Controller/ResidentialAddressController.php @@ -27,7 +27,7 @@ use Symfony\Contracts\Translation\TranslatorInterface; final class ResidentialAddressController extends AbstractController { - public function __construct(private UrlGeneratorInterface $generator, private TranslatorInterface $translator, private ResidentialAddressRepository $residentialAddressRepository) + public function __construct(private readonly UrlGeneratorInterface $generator, private readonly TranslatorInterface $translator, private readonly ResidentialAddressRepository $residentialAddressRepository) { } diff --git a/src/Bundle/ChillPersonBundle/Controller/SocialWorkEvaluationApiController.php b/src/Bundle/ChillPersonBundle/Controller/SocialWorkEvaluationApiController.php index 8bfc90c0b..56ca54564 100644 --- a/src/Bundle/ChillPersonBundle/Controller/SocialWorkEvaluationApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/SocialWorkEvaluationApiController.php @@ -22,7 +22,7 @@ use Symfony\Component\Routing\Annotation\Route; class SocialWorkEvaluationApiController extends AbstractController { - public function __construct(private PaginatorFactory $paginatorFactory) + public function __construct(private readonly PaginatorFactory $paginatorFactory) { } diff --git a/src/Bundle/ChillPersonBundle/Controller/SocialWorkGoalApiController.php b/src/Bundle/ChillPersonBundle/Controller/SocialWorkGoalApiController.php index 45165eec4..cbbd9a748 100644 --- a/src/Bundle/ChillPersonBundle/Controller/SocialWorkGoalApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/SocialWorkGoalApiController.php @@ -21,7 +21,7 @@ use Symfony\Component\HttpFoundation\Response; class SocialWorkGoalApiController extends ApiController { - public function __construct(private GoalRepository $goalRepository, private PaginatorFactory $paginator) + public function __construct(private readonly GoalRepository $goalRepository, private readonly PaginatorFactory $paginator) { } diff --git a/src/Bundle/ChillPersonBundle/Controller/SocialWorkResultApiController.php b/src/Bundle/ChillPersonBundle/Controller/SocialWorkResultApiController.php index 397164707..aaedfd330 100644 --- a/src/Bundle/ChillPersonBundle/Controller/SocialWorkResultApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/SocialWorkResultApiController.php @@ -21,7 +21,7 @@ use Symfony\Component\HttpFoundation\Response; class SocialWorkResultApiController extends ApiController { - public function __construct(private ResultRepository $resultRepository) + public function __construct(private readonly ResultRepository $resultRepository) { } diff --git a/src/Bundle/ChillPersonBundle/Controller/SocialWorkSocialActionApiController.php b/src/Bundle/ChillPersonBundle/Controller/SocialWorkSocialActionApiController.php index 09f34dce9..dc28d0f1b 100644 --- a/src/Bundle/ChillPersonBundle/Controller/SocialWorkSocialActionApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/SocialWorkSocialActionApiController.php @@ -23,7 +23,7 @@ use function count; class SocialWorkSocialActionApiController extends ApiController { - public function __construct(private SocialIssueRepository $socialIssueRepository, private PaginatorFactory $paginator) + public function __construct(private readonly SocialIssueRepository $socialIssueRepository, private readonly PaginatorFactory $paginator) { } diff --git a/src/Bundle/ChillPersonBundle/Controller/UserAccompanyingPeriodController.php b/src/Bundle/ChillPersonBundle/Controller/UserAccompanyingPeriodController.php index 4a8580d30..bee1c6262 100644 --- a/src/Bundle/ChillPersonBundle/Controller/UserAccompanyingPeriodController.php +++ b/src/Bundle/ChillPersonBundle/Controller/UserAccompanyingPeriodController.php @@ -19,7 +19,7 @@ use Symfony\Component\Routing\Annotation\Route; class UserAccompanyingPeriodController extends AbstractController { - public function __construct(private AccompanyingPeriodRepository $accompanyingPeriodRepository, private PaginatorFactory $paginatorFactory) + public function __construct(private readonly AccompanyingPeriodRepository $accompanyingPeriodRepository, private readonly PaginatorFactory $paginatorFactory) { } diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadAccompanyingPeriodOrigin.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadAccompanyingPeriodOrigin.php index e55acc13b..84a2d835c 100644 --- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadAccompanyingPeriodOrigin.php +++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadAccompanyingPeriodOrigin.php @@ -21,7 +21,7 @@ use Doctrine\Persistence\ObjectManager; */ class LoadAccompanyingPeriodOrigin extends AbstractFixture implements OrderedFixtureInterface { - public const ACCOMPANYING_PERIOD_ORIGIN = 'accompanying_period_origin'; + final public const ACCOMPANYING_PERIOD_ORIGIN = 'accompanying_period_origin'; public static $references = []; diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadAccompanyingPeriodWork.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadAccompanyingPeriodWork.php index 06e1aab71..64fc73d3e 100644 --- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadAccompanyingPeriodWork.php +++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadAccompanyingPeriodWork.php @@ -31,7 +31,7 @@ class LoadAccompanyingPeriodWork extends \Doctrine\Bundle\FixturesBundle\Fixture */ private array $cacheEvaluations = []; - public function __construct(private AccompanyingPeriodRepository $periodRepository, private EvaluationRepository $evaluationRepository) + public function __construct(private readonly AccompanyingPeriodRepository $periodRepository, private readonly EvaluationRepository $evaluationRepository) { } diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadCustomFields.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadCustomFields.php index e229fb877..e200bc1f8 100644 --- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadCustomFields.php +++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadCustomFields.php @@ -49,7 +49,7 @@ class LoadCustomFields extends AbstractFixture implements /** * LoadCustomFields constructor. */ - public function __construct(private TranslatableStringHelper $translatableStringHelper, private TranslatorInterface $translator) + public function __construct(private readonly TranslatableStringHelper $translatableStringHelper, private readonly TranslatorInterface $translator) { } diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadHousehold.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadHousehold.php index b619de76d..274aa7638 100644 --- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadHousehold.php +++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadHousehold.php @@ -37,11 +37,11 @@ class LoadHousehold extends Fixture implements DependentFixtureInterface { private const NUMBER_OF_HOUSEHOLD = 10; - private NativeLoader $loader; + private readonly NativeLoader $loader; private array $personIds; - public function __construct(private MembersEditorFactory $editorFactory, private EntityManagerInterface $em) + public function __construct(private readonly MembersEditorFactory $editorFactory, private readonly EntityManagerInterface $em) { $this->loader = new NativeLoader(); } diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadHouseholdCompositionType.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadHouseholdCompositionType.php index 720e7ca38..c985f26d3 100644 --- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadHouseholdCompositionType.php +++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadHouseholdCompositionType.php @@ -18,7 +18,7 @@ use Doctrine\Persistence\ObjectManager; class LoadHouseholdCompositionType extends AbstractFixture implements FixtureGroupInterface { - public const TYPES = [ + final public const TYPES = [ ['fr' => 'Couple avec enfant(s)'], ['fr' => 'Couple sans enfant'], ['fr' => 'Mère seule'], diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadHouseholdPosition.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadHouseholdPosition.php index cb1affa85..f5c28c8c2 100644 --- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadHouseholdPosition.php +++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadHouseholdPosition.php @@ -17,13 +17,13 @@ use Doctrine\Persistence\ObjectManager; class LoadHouseholdPosition extends Fixture { - public const ADULT = 'position_adulte'; + final public const ADULT = 'position_adulte'; - public const CHILD = 'position_enfant'; + final public const CHILD = 'position_enfant'; - public const CHILD_OUT = 'position_enfant_hors'; + final public const CHILD_OUT = 'position_enfant_hors'; - public const POSITIONS_DATA = [ + final public const POSITIONS_DATA = [ ['Adulte', true, true, 1.0, self::ADULT], ['Enfant', true, false, 2.0, self::CHILD], ['Enfant hors ménage', false, false, 3.0, self::CHILD_OUT], diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadPeople.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadPeople.php index c658a6510..4ef2fde7f 100644 --- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadPeople.php +++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadPeople.php @@ -54,7 +54,7 @@ class LoadPeople extends AbstractFixture implements ContainerAwareInterface, Ord { use \Symfony\Component\DependencyInjection\ContainerAwareTrait; - public const PERSON = 'person'; + final public const PERSON = 'person'; /** * @var array|Center[] diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelations.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelations.php index 480238639..7a05f7f6a 100644 --- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelations.php +++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelations.php @@ -18,9 +18,9 @@ use Doctrine\Persistence\ObjectManager; class LoadRelations extends Fixture implements FixtureGroupInterface { - public const RELATION_KEY = 'relations'; + final public const RELATION_KEY = 'relations'; - public const RELATIONS = [ + final public const RELATIONS = [ ['title' => ['fr' => 'Parent'], 'reverseTitle' => ['fr' => 'Enfant']], ['title' => ['fr' => 'En couple'], 'reverseTitle' => ['fr' => 'En couple']], ['title' => ['fr' => 'Beau parent'], 'reverseTitle' => ['fr' => 'Belle-fille·beau-fils']], diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelationships.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelationships.php index 65d79b243..151ecf0c2 100644 --- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelationships.php +++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelationships.php @@ -28,7 +28,7 @@ class LoadRelationships extends Fixture implements DependentFixtureInterface { use PersonRandomHelper; - public function __construct(private EntityManagerInterface $em) + public function __construct(private readonly EntityManagerInterface $em) { } diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadSocialWorkMetadata.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadSocialWorkMetadata.php index 9605ce6f6..2ad47fc20 100644 --- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadSocialWorkMetadata.php +++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadSocialWorkMetadata.php @@ -21,7 +21,7 @@ use Throwable; class LoadSocialWorkMetadata extends Fixture implements OrderedFixtureInterface { - public function __construct(private SocialWorkMetadata $importer) + public function __construct(private readonly SocialWorkMetadata $importer) { } diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php index f4c36e7b7..6b3d9c078 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php @@ -77,21 +77,21 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface { - public const INTENSITIES = [self::INTENSITY_OCCASIONAL, self::INTENSITY_REGULAR]; + final public const INTENSITIES = [self::INTENSITY_OCCASIONAL, self::INTENSITY_REGULAR]; /** * Mark an accompanying period as "occasional". * * used in INTENSITY */ - public const INTENSITY_OCCASIONAL = 'occasional'; + final public const INTENSITY_OCCASIONAL = 'occasional'; /** * Mark an accompanying period as "regular". * * used in INTENSITY */ - public const INTENSITY_REGULAR = 'regular'; + final public const INTENSITY_REGULAR = 'regular'; /** * Mark an accompanying period as "closed". @@ -99,7 +99,7 @@ class AccompanyingPeriod implements * This means that the accompanying period **is** * closed by the creator */ - public const STEP_CLOSED = 'CLOSED'; + final public const STEP_CLOSED = 'CLOSED'; /** * Mark an accompanying period as "confirmed". @@ -107,7 +107,7 @@ class AccompanyingPeriod implements * This means that the accompanying period **is** * confirmed by the creator */ - public const STEP_CONFIRMED = 'CONFIRMED'; + final public const STEP_CONFIRMED = 'CONFIRMED'; /** * Mark an accompanying period as "draft". @@ -115,7 +115,7 @@ class AccompanyingPeriod implements * This means that the accompanying period is not yet * confirmed by the creator */ - public const STEP_DRAFT = 'DRAFT'; + final public const STEP_DRAFT = 'DRAFT'; /** * @ORM\ManyToOne( diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/UserHistory.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/UserHistory.php index e2325aaa0..5224722e7 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/UserHistory.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/UserHistory.php @@ -38,23 +38,19 @@ class UserHistory implements TrackCreationInterface */ private ?int $id = null; - /** - * @ORM\Column(type="datetime_immutable", nullable=false) - */ - private DateTimeImmutable $startDate; - - public function __construct(/** - * @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class, inversedBy="userHistories") - * @ORM\JoinColumn(nullable=false) - */ - private ?\Chill\PersonBundle\Entity\AccompanyingPeriod $accompanyingPeriod, /** - * @ORM\ManyToOne(targetEntity=User::class) - * @ORM\JoinColumn(nullable=false) - */ + public function __construct( + /** + * @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class, inversedBy="userHistories") + * @ORM\JoinColumn(nullable=false) + */ + private ?\Chill\PersonBundle\Entity\AccompanyingPeriod $accompanyingPeriod, + /** + * @ORM\ManyToOne(targetEntity=User::class) + * @ORM\JoinColumn(nullable=false) + */ private User $user, - ?DateTimeImmutable $startDate = null + private DateTimeImmutable $startDate = new DateTimeImmutable('now') ) { - $this->startDate = $startDate ?? new DateTimeImmutable('now'); } public function getAccompanyingPeriod(): AccompanyingPeriod diff --git a/src/Bundle/ChillPersonBundle/Entity/Person.php b/src/Bundle/ChillPersonBundle/Entity/Person.php index ac8988c26..89996a18e 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person.php @@ -76,18 +76,18 @@ use function in_array; */ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateInterface, \Stringable { - public const BOTH_GENDER = 'both'; + final public const BOTH_GENDER = 'both'; // have days in commun - public const ERROR_ADDIND_PERIOD_AFTER_AN_OPEN_PERIOD = 2; // where there exist + final public const ERROR_ADDIND_PERIOD_AFTER_AN_OPEN_PERIOD = 2; // where there exist - public const ERROR_PERIODS_ARE_COLLAPSING = 1; // when two different periods + final public const ERROR_PERIODS_ARE_COLLAPSING = 1; // when two different periods - public const FEMALE_GENDER = 'woman'; + final public const FEMALE_GENDER = 'woman'; - public const MALE_GENDER = 'man'; + final public const MALE_GENDER = 'man'; - public const NO_INFORMATION = 'unknown'; + final public const NO_INFORMATION = 'unknown'; /** * Accept receiving email. diff --git a/src/Bundle/ChillPersonBundle/Event/Person/PersonAddressMoveEvent.php b/src/Bundle/ChillPersonBundle/Event/Person/PersonAddressMoveEvent.php index 1242e61ef..5968832c2 100644 --- a/src/Bundle/ChillPersonBundle/Event/Person/PersonAddressMoveEvent.php +++ b/src/Bundle/ChillPersonBundle/Event/Person/PersonAddressMoveEvent.php @@ -21,7 +21,7 @@ use Symfony\Contracts\EventDispatcher\Event; class PersonAddressMoveEvent extends Event { - public const PERSON_MOVE_POST = 'chill_person.person_move_post'; + final public const PERSON_MOVE_POST = 'chill_person.person_move_post'; private ?Address $nextAddress = null; @@ -31,7 +31,7 @@ class PersonAddressMoveEvent extends Event private ?HouseholdMember $previousMembership = null; - public function __construct(private Person $person) + public function __construct(private readonly Person $person) { } diff --git a/src/Bundle/ChillPersonBundle/EventListener/AccompanyingPeriodWorkEventListener.php b/src/Bundle/ChillPersonBundle/EventListener/AccompanyingPeriodWorkEventListener.php index 2776faf43..60d521424 100644 --- a/src/Bundle/ChillPersonBundle/EventListener/AccompanyingPeriodWorkEventListener.php +++ b/src/Bundle/ChillPersonBundle/EventListener/AccompanyingPeriodWorkEventListener.php @@ -17,7 +17,7 @@ use Symfony\Component\Security\Core\Security; class AccompanyingPeriodWorkEventListener { - public function __construct(private Security $security) + public function __construct(private readonly Security $security) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/AdministrativeLocationAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/AdministrativeLocationAggregator.php index d01190ba4..27b0c9b93 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/AdministrativeLocationAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/AdministrativeLocationAggregator.php @@ -21,7 +21,7 @@ use function in_array; class AdministrativeLocationAggregator implements AggregatorInterface { - public function __construct(private LocationRepository $locationRepository, private TranslatableStringHelper $translatableStringHelper) + public function __construct(private readonly LocationRepository $locationRepository, private readonly TranslatableStringHelper $translatableStringHelper) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregator.php index b2703836e..758e93a9d 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregator.php @@ -20,7 +20,7 @@ use Symfony\Component\Form\FormBuilderInterface; class ClosingMotiveAggregator implements AggregatorInterface { - public function __construct(private ClosingMotiveRepositoryInterface $motiveRepository, private TranslatableStringHelper $translatableStringHelper) + public function __construct(private readonly ClosingMotiveRepositoryInterface $motiveRepository, private readonly TranslatableStringHelper $translatableStringHelper) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ConfidentialAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ConfidentialAggregator.php index a4279fc05..ed1f2727c 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ConfidentialAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ConfidentialAggregator.php @@ -20,7 +20,7 @@ use Symfony\Contracts\Translation\TranslatorInterface; class ConfidentialAggregator implements AggregatorInterface { - public function __construct(private TranslatorInterface $translator) + public function __construct(private readonly TranslatorInterface $translator) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/CreatorJobAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/CreatorJobAggregator.php index 87e119419..edd6239f5 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/CreatorJobAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/CreatorJobAggregator.php @@ -21,7 +21,7 @@ use function in_array; class CreatorJobAggregator implements AggregatorInterface { - public function __construct(private UserJobRepository $jobRepository, private TranslatableStringHelper $translatableStringHelper) + public function __construct(private readonly UserJobRepository $jobRepository, private readonly TranslatableStringHelper $translatableStringHelper) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/DurationAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/DurationAggregator.php index ce61739f0..a5eba39fa 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/DurationAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/DurationAggregator.php @@ -20,7 +20,7 @@ use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Contracts\Translation\TranslatorInterface; -final class DurationAggregator implements AggregatorInterface +final readonly class DurationAggregator implements AggregatorInterface { private const CHOICES = [ 'month', diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EmergencyAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EmergencyAggregator.php index aeb369b5a..6a791b8ab 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EmergencyAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EmergencyAggregator.php @@ -20,7 +20,7 @@ use Symfony\Contracts\Translation\TranslatorInterface; class EmergencyAggregator implements AggregatorInterface { - public function __construct(private TranslatorInterface $translator) + public function __construct(private readonly TranslatorInterface $translator) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EvaluationAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EvaluationAggregator.php index 47656c1d0..d9f873225 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EvaluationAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EvaluationAggregator.php @@ -19,7 +19,7 @@ use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; use function in_array; -final class EvaluationAggregator implements AggregatorInterface +final readonly class EvaluationAggregator implements AggregatorInterface { public function __construct(private EvaluationRepository $evaluationRepository, private TranslatableStringHelper $translatableStringHelper) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php index 3395247de..b05e9557c 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php @@ -27,7 +27,7 @@ use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\FormBuilderInterface; use UnexpectedValueException; -final class GeographicalUnitStatAggregator implements AggregatorInterface +final readonly class GeographicalUnitStatAggregator implements AggregatorInterface { public function __construct(private GeographicalUnitLayerRepositoryInterface $geographicalUnitLayerRepository, private TranslatableStringHelperInterface $translatableStringHelper, private RollingDateConverterInterface $rollingDateConverter) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/IntensityAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/IntensityAggregator.php index 2d9adc801..88ad95fb2 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/IntensityAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/IntensityAggregator.php @@ -20,7 +20,7 @@ use Symfony\Contracts\Translation\TranslatorInterface; class IntensityAggregator implements AggregatorInterface { - public function __construct(private TranslatorInterface $translator) + public function __construct(private readonly TranslatorInterface $translator) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/OriginAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/OriginAggregator.php index e6cb9cac6..c0e92eca9 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/OriginAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/OriginAggregator.php @@ -23,11 +23,11 @@ use function in_array; final class OriginAggregator implements AggregatorInterface { - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct( EntityManagerInterface $em, - private TranslatableStringHelper $translatableStringHelper + private readonly TranslatableStringHelper $translatableStringHelper ) { $this->repository = $em->getRepository(Origin::class); } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerAggregator.php index db12bbb0c..1e1b24aae 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerAggregator.php @@ -21,7 +21,7 @@ use Chill\PersonBundle\Export\Declarations; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; -final class ReferrerAggregator implements AggregatorInterface +final readonly class ReferrerAggregator implements AggregatorInterface { private const A = 'acp_ref_agg_uhistory'; diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerScopeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerScopeAggregator.php index 6e788d714..84670ee01 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerScopeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerScopeAggregator.php @@ -26,7 +26,7 @@ class ReferrerScopeAggregator implements AggregatorInterface { private const SCOPE_KEY = 'acp_agg_refscope_user_history_ref_scope_name'; - public function __construct(private ScopeRepositoryInterface $scopeRepository, private TranslatableStringHelperInterface $translatableStringHelper, private RollingDateConverterInterface $rollingDateConverter) + public function __construct(private readonly ScopeRepositoryInterface $scopeRepository, private readonly TranslatableStringHelperInterface $translatableStringHelper, private readonly RollingDateConverterInterface $rollingDateConverter) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/RequestorAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/RequestorAggregator.php index 5555671d3..0c3292d68 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/RequestorAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/RequestorAggregator.php @@ -18,7 +18,7 @@ use Symfony\Component\Form\FormBuilderInterface; use Symfony\Contracts\Translation\TranslatorInterface; use function in_array; -final class RequestorAggregator implements AggregatorInterface +final readonly class RequestorAggregator implements AggregatorInterface { public function __construct(private TranslatorInterface $translator) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ScopeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ScopeAggregator.php index d3f7783f3..3ee220255 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ScopeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ScopeAggregator.php @@ -19,7 +19,7 @@ use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; use function in_array; -final class ScopeAggregator implements AggregatorInterface +final readonly class ScopeAggregator implements AggregatorInterface { public function __construct(private ScopeRepository $scopeRepository, private TranslatableStringHelper $translatableStringHelper) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialActionAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialActionAggregator.php index e088be7ce..771e29396 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialActionAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialActionAggregator.php @@ -19,7 +19,7 @@ use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; use function in_array; -final class SocialActionAggregator implements AggregatorInterface +final readonly class SocialActionAggregator implements AggregatorInterface { public function __construct(private SocialActionRender $actionRender, private SocialActionRepository $actionRepository) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialIssueAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialIssueAggregator.php index 4ce7dfcd0..ad3197d38 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialIssueAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialIssueAggregator.php @@ -19,7 +19,7 @@ use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; use function in_array; -final class SocialIssueAggregator implements AggregatorInterface +final readonly class SocialIssueAggregator implements AggregatorInterface { public function __construct(private SocialIssueRepository $issueRepository, private SocialIssueRender $issueRender) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/StepAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/StepAggregator.php index 4fb7a38b8..5a49df05c 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/StepAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/StepAggregator.php @@ -22,7 +22,7 @@ use Symfony\Component\Form\FormBuilderInterface; use Symfony\Contracts\Translation\TranslatorInterface; use function in_array; -final class StepAggregator implements AggregatorInterface +final readonly class StepAggregator implements AggregatorInterface { private const A = 'acpstephistories'; diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/UserJobAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/UserJobAggregator.php index 97a8b228e..e75482bff 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/UserJobAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/UserJobAggregator.php @@ -19,7 +19,7 @@ use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; use function in_array; -final class UserJobAggregator implements AggregatorInterface +final readonly class UserJobAggregator implements AggregatorInterface { public function __construct(private UserJobRepository $jobRepository, private TranslatableStringHelper $translatableStringHelper) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByEndDateAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByEndDateAggregator.php index c8dd3b611..0113de714 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByEndDateAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByEndDateAggregator.php @@ -29,8 +29,6 @@ class ByEndDateAggregator implements AggregatorInterface private const DEFAULT_CHOICE = 'year'; - private TranslatorInterface $translator; - public function addRole(): ?string { return null; diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByMaxDateAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByMaxDateAggregator.php index 07498f026..56f71c297 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByMaxDateAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByMaxDateAggregator.php @@ -29,8 +29,6 @@ class ByMaxDateAggregator implements AggregatorInterface private const DEFAULT_CHOICE = 'year'; - private TranslatorInterface $translator; - public function addRole(): ?string { return null; diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByStartDateAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByStartDateAggregator.php index d5317feb6..d2ea6a559 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByStartDateAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByStartDateAggregator.php @@ -29,8 +29,6 @@ class ByStartDateAggregator implements AggregatorInterface private const DEFAULT_CHOICE = 'year'; - private TranslatorInterface $translator; - public function addRole(): ?string { return null; diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/EvaluationTypeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/EvaluationTypeAggregator.php index 2201cd747..2980e3d90 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/EvaluationTypeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/EvaluationTypeAggregator.php @@ -20,7 +20,7 @@ use Symfony\Component\Form\FormBuilderInterface; class EvaluationTypeAggregator implements AggregatorInterface { - public function __construct(private EvaluationRepository $evaluationRepository, private TranslatableStringHelper $translatableStringHelper) + public function __construct(private readonly EvaluationRepository $evaluationRepository, private readonly TranslatableStringHelper $translatableStringHelper) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/HavingEndDateAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/HavingEndDateAggregator.php index 9bc91f099..c0c31a5fd 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/HavingEndDateAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/HavingEndDateAggregator.php @@ -20,7 +20,7 @@ use Symfony\Contracts\Translation\TranslatorInterface; class HavingEndDateAggregator implements AggregatorInterface { - public function __construct(private TranslatorInterface $translator) + public function __construct(private readonly TranslatorInterface $translator) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/ChildrenNumberAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/ChildrenNumberAggregator.php index 7b4b3c646..2037716aa 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/ChildrenNumberAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/ChildrenNumberAggregator.php @@ -24,7 +24,7 @@ use function in_array; class ChildrenNumberAggregator implements AggregatorInterface { - public function __construct(private TranslatorInterface $translator, private RollingDateConverterInterface $rollingDateConverter) + public function __construct(private readonly TranslatorInterface $translator, private readonly RollingDateConverterInterface $rollingDateConverter) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/CompositionAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/CompositionAggregator.php index 1d38dddd4..946844f4b 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/CompositionAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/CompositionAggregator.php @@ -25,7 +25,7 @@ use function in_array; class CompositionAggregator implements AggregatorInterface { - public function __construct(private HouseholdCompositionTypeRepository $typeRepository, private TranslatableStringHelper $translatableStringHelper, private RollingDateConverterInterface $rollingDateConverter) + public function __construct(private readonly HouseholdCompositionTypeRepository $typeRepository, private readonly TranslatableStringHelper $translatableStringHelper, private readonly RollingDateConverterInterface $rollingDateConverter) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/AgeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/AgeAggregator.php index 88cf2363a..5d361fc8f 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/AgeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/AgeAggregator.php @@ -20,7 +20,7 @@ use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Validator\Context\ExecutionContextInterface; use Symfony\Contracts\Translation\TranslatorInterface; -final class AgeAggregator implements AggregatorInterface, ExportElementValidatedInterface +final readonly class AgeAggregator implements AggregatorInterface, ExportElementValidatedInterface { public function __construct(private TranslatorInterface $translator) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/ByHouseholdCompositionAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/ByHouseholdCompositionAggregator.php index ccb4710e0..8f4191352 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/ByHouseholdCompositionAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/ByHouseholdCompositionAggregator.php @@ -27,7 +27,7 @@ class ByHouseholdCompositionAggregator implements AggregatorInterface { private const PREFIX = 'acp_by_household_compo_agg'; - public function __construct(private RollingDateConverterInterface $rollingDateConverter, private HouseholdCompositionTypeRepositoryInterface $householdCompositionTypeRepository, private TranslatableStringHelperInterface $translatableStringHelper) + public function __construct(private readonly RollingDateConverterInterface $rollingDateConverter, private readonly HouseholdCompositionTypeRepositoryInterface $householdCompositionTypeRepository, private readonly TranslatableStringHelperInterface $translatableStringHelper) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/CountryOfBirthAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/CountryOfBirthAggregator.php index 25b01b3f7..de3747582 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/CountryOfBirthAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/CountryOfBirthAggregator.php @@ -25,7 +25,7 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface; use Symfony\Contracts\Translation\TranslatorInterface; use function in_array; -final class CountryOfBirthAggregator implements AggregatorInterface, ExportElementValidatedInterface +final readonly class CountryOfBirthAggregator implements AggregatorInterface, ExportElementValidatedInterface { public function __construct(private CountryRepository $countriesRepository, private TranslatableStringHelper $translatableStringHelper, private TranslatorInterface $translator) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GenderAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GenderAggregator.php index 60ab87fed..988639571 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GenderAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GenderAggregator.php @@ -19,7 +19,7 @@ use LogicException; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Contracts\Translation\TranslatorInterface; -final class GenderAggregator implements AggregatorInterface +final readonly class GenderAggregator implements AggregatorInterface { public function __construct(private TranslatorInterface $translator) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GeographicalUnitAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GeographicalUnitAggregator.php index e86524670..2911fc868 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GeographicalUnitAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GeographicalUnitAggregator.php @@ -26,7 +26,7 @@ use Symfony\Component\Form\FormBuilderInterface; class GeographicalUnitAggregator implements AggregatorInterface { - public function __construct(private GeographicalUnitLayerRepositoryInterface $geographicalUnitLayerRepository, private TranslatableStringHelperInterface $translatableStringHelper, private RollingDateConverterInterface $rollingDateConverter) + public function __construct(private readonly GeographicalUnitLayerRepositoryInterface $geographicalUnitLayerRepository, private readonly TranslatableStringHelperInterface $translatableStringHelper, private readonly RollingDateConverterInterface $rollingDateConverter) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/HouseholdPositionAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/HouseholdPositionAggregator.php index 48a08b190..120f50722 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/HouseholdPositionAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/HouseholdPositionAggregator.php @@ -27,7 +27,7 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface; use Symfony\Contracts\Translation\TranslatorInterface; use function in_array; -final class HouseholdPositionAggregator implements AggregatorInterface, ExportElementValidatedInterface +final readonly class HouseholdPositionAggregator implements AggregatorInterface, ExportElementValidatedInterface { public function __construct(private TranslatorInterface $translator, private TranslatableStringHelper $translatableStringHelper, private PositionRepository $positionRepository, private RollingDateConverterInterface $rollingDateConverter) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/MaritalStatusAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/MaritalStatusAggregator.php index 98049357a..96615a29d 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/MaritalStatusAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/MaritalStatusAggregator.php @@ -19,7 +19,7 @@ use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; use function in_array; -final class MaritalStatusAggregator implements AggregatorInterface +final readonly class MaritalStatusAggregator implements AggregatorInterface { public function __construct(private MaritalStatusRepository $maritalStatusRepository, private TranslatableStringHelper $translatableStringHelper) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/NationalityAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/NationalityAggregator.php index 14f5a5dd5..22c3e9ce7 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/NationalityAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/NationalityAggregator.php @@ -23,7 +23,7 @@ use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Validator\Context\ExecutionContextInterface; use Symfony\Contracts\Translation\TranslatorInterface; -final class NationalityAggregator implements AggregatorInterface, ExportElementValidatedInterface +final readonly class NationalityAggregator implements AggregatorInterface, ExportElementValidatedInterface { public function __construct(private CountryRepository $countriesRepository, private TranslatableStringHelper $translatableStringHelper, private TranslatorInterface $translator) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregator.php index a1b384ffa..a5be01391 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregator.php @@ -22,7 +22,7 @@ use LogicException; use Symfony\Component\Form\FormBuilderInterface; use function in_array; -final class ActionTypeAggregator implements AggregatorInterface +final readonly class ActionTypeAggregator implements AggregatorInterface { public function __construct(private SocialActionRepository $socialActionRepository, private SocialActionRender $actionRender, private SocialIssueRender $socialIssueRender, private SocialIssueRepository $socialIssueRepository) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CurrentActionAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CurrentActionAggregator.php index 30d272c15..9bb252f07 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CurrentActionAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CurrentActionAggregator.php @@ -20,7 +20,7 @@ use Symfony\Contracts\Translation\TranslatorInterface; class CurrentActionAggregator implements AggregatorInterface { - public function __construct(private TranslatorInterface $translator) + public function __construct(private readonly TranslatorInterface $translator) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalAggregator.php index a63580cf7..9ac183b0d 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalAggregator.php @@ -19,7 +19,7 @@ use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; use function in_array; -final class GoalAggregator implements AggregatorInterface +final readonly class GoalAggregator implements AggregatorInterface { public function __construct(private GoalRepository $goalRepository, private TranslatableStringHelper $translatableStringHelper) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalResultAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalResultAggregator.php index 7d3610c71..c6894ab8b 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalResultAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalResultAggregator.php @@ -23,7 +23,7 @@ use function in_array; class GoalResultAggregator implements AggregatorInterface { - public function __construct(private ResultRepository $resultRepository, private GoalRepository $goalRepository, private TranslatableStringHelper $translatableStringHelper) + public function __construct(private readonly ResultRepository $resultRepository, private readonly GoalRepository $goalRepository, private readonly TranslatableStringHelper $translatableStringHelper) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/JobAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/JobAggregator.php index 314149829..eae7e8789 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/JobAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/JobAggregator.php @@ -19,7 +19,7 @@ use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; use function in_array; -final class JobAggregator implements AggregatorInterface +final readonly class JobAggregator implements AggregatorInterface { public function __construct(private UserJobRepository $jobRepository, private TranslatableStringHelper $translatableStringHelper) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ReferrerAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ReferrerAggregator.php index a7adf6802..5d301c5be 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ReferrerAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ReferrerAggregator.php @@ -19,7 +19,7 @@ use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; use function in_array; -final class ReferrerAggregator implements AggregatorInterface +final readonly class ReferrerAggregator implements AggregatorInterface { public function __construct(private UserRepository $userRepository, private UserRender $userRender) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ResultAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ResultAggregator.php index c621b0899..3a8b10581 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ResultAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ResultAggregator.php @@ -19,7 +19,7 @@ use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; use function in_array; -final class ResultAggregator implements AggregatorInterface +final readonly class ResultAggregator implements AggregatorInterface { public function __construct(private ResultRepository $resultRepository, private TranslatableStringHelper $translatableStringHelper) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ScopeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ScopeAggregator.php index 1a085828f..9ec248caa 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ScopeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ScopeAggregator.php @@ -19,7 +19,7 @@ use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; use function in_array; -final class ScopeAggregator implements AggregatorInterface +final readonly class ScopeAggregator implements AggregatorInterface { public function __construct(private ScopeRepository $scopeRepository, private TranslatableStringHelper $translatableStringHelper) { diff --git a/src/Bundle/ChillPersonBundle/Export/Declarations.php b/src/Bundle/ChillPersonBundle/Export/Declarations.php index 507f02041..a512700ee 100644 --- a/src/Bundle/ChillPersonBundle/Export/Declarations.php +++ b/src/Bundle/ChillPersonBundle/Export/Declarations.php @@ -16,15 +16,15 @@ namespace Chill\PersonBundle\Export; */ abstract class Declarations { - public const ACP_TYPE = 'accompanying_period'; + final public const ACP_TYPE = 'accompanying_period'; - public const EVAL_TYPE = 'evaluation'; + final public const EVAL_TYPE = 'evaluation'; - public const HOUSEHOLD_TYPE = 'household'; + final public const HOUSEHOLD_TYPE = 'household'; - public const PERSON_IMPLIED_IN = 'person_implied_in'; + final public const PERSON_IMPLIED_IN = 'person_implied_in'; - public const PERSON_TYPE = 'person'; + final public const PERSON_TYPE = 'person'; - public const SOCIAL_WORK_ACTION_TYPE = 'social_actions'; + final public const SOCIAL_WORK_ACTION_TYPE = 'social_actions'; } diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php b/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php index 74d4bb4ff..b25f24c8c 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php @@ -25,7 +25,7 @@ use Symfony\Component\Form\FormBuilderInterface; class CountEvaluation implements ExportInterface, GroupedExportInterface { - public function __construct(private EntityManagerInterface $entityManager) + public function __construct(private readonly EntityManagerInterface $entityManager) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php b/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php index 778f19812..823ea703e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php @@ -30,7 +30,7 @@ class CountHousehold implements ExportInterface, GroupedExportInterface { private const TR_PREFIX = 'export.export.nb_household_with_course.'; - public function __construct(private EntityManagerInterface $entityManager, private RollingDateConverterInterface $rollingDateConverter) + public function __construct(private readonly EntityManagerInterface $entityManager, private readonly RollingDateConverterInterface $rollingDateConverter) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountPersonWithAccompanyingCourse.php b/src/Bundle/ChillPersonBundle/Export/Export/CountPersonWithAccompanyingCourse.php index e52cc83b1..c887a9468 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountPersonWithAccompanyingCourse.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountPersonWithAccompanyingCourse.php @@ -27,7 +27,7 @@ use function in_array; class CountPersonWithAccompanyingCourse implements ExportInterface, GroupedExportInterface { - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct( EntityManagerInterface $em diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php index 57e92f818..6c78f1494 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php @@ -78,7 +78,7 @@ class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface 'updatedBy', ]; - public function __construct(private ExportAddressHelper $addressHelper, private DateTimeHelper $dateTimeHelper, private EntityManagerInterface $entityManager, private PersonRenderInterface $personRender, private PersonRepository $personRepository, private ThirdPartyRepository $thirdPartyRepository, private ThirdPartyRender $thirdPartyRender, private SocialIssueRepository $socialIssueRepository, private SocialIssueRender $socialIssueRender, private TranslatableStringHelperInterface $translatableStringHelper, private RollingDateConverterInterface $rollingDateConverter, private UserHelper $userHelper) + public function __construct(private readonly ExportAddressHelper $addressHelper, private readonly DateTimeHelper $dateTimeHelper, private readonly EntityManagerInterface $entityManager, private readonly PersonRenderInterface $personRender, private readonly PersonRepository $personRepository, private readonly ThirdPartyRepository $thirdPartyRepository, private readonly ThirdPartyRender $thirdPartyRender, private readonly SocialIssueRepository $socialIssueRepository, private readonly SocialIssueRender $socialIssueRender, private readonly TranslatableStringHelperInterface $translatableStringHelper, private readonly RollingDateConverterInterface $rollingDateConverter, private readonly UserHelper $userHelper) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriodWork.php b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriodWork.php index 0625d1552..33761de88 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriodWork.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriodWork.php @@ -76,7 +76,7 @@ class ListAccompanyingPeriodWork implements ListInterface, GroupedExportInterfac 'updatedBy', ]; - public function __construct(private EntityManagerInterface $entityManager, private DateTimeHelper $dateTimeHelper, private UserHelper $userHelper, private LabelPersonHelper $personHelper, private LabelThirdPartyHelper $thirdPartyHelper, private TranslatableStringExportLabelHelper $translatableStringExportLabelHelper, private SocialIssueRender $socialIssueRender, private SocialIssueRepository $socialIssueRepository, private SocialActionRender $socialActionRender, private RollingDateConverterInterface $rollingDateConverter, private AggregateStringHelper $aggregateStringHelper, private SocialActionRepository $socialActionRepository) + public function __construct(private readonly EntityManagerInterface $entityManager, private readonly DateTimeHelper $dateTimeHelper, private readonly UserHelper $userHelper, private readonly LabelPersonHelper $personHelper, private readonly LabelThirdPartyHelper $thirdPartyHelper, private readonly TranslatableStringExportLabelHelper $translatableStringExportLabelHelper, private readonly SocialIssueRender $socialIssueRender, private readonly SocialIssueRepository $socialIssueRepository, private readonly SocialActionRender $socialActionRender, private readonly RollingDateConverterInterface $rollingDateConverter, private readonly AggregateStringHelper $aggregateStringHelper, private readonly SocialActionRepository $socialActionRepository) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListEvaluation.php b/src/Bundle/ChillPersonBundle/Export/Export/ListEvaluation.php index ebe3911a9..548054c58 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListEvaluation.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListEvaluation.php @@ -68,7 +68,7 @@ class ListEvaluation implements ListInterface, GroupedExportInterface 'updatedBy', ]; - public function __construct(private EntityManagerInterface $entityManager, private SocialIssueRender $socialIssueRender, private SocialIssueRepository $socialIssueRepository, private SocialActionRender $socialActionRender, private SocialActionRepository $socialActionRepository, private UserHelper $userHelper, private LabelPersonHelper $personHelper, private DateTimeHelper $dateTimeHelper, private TranslatableStringExportLabelHelper $translatableStringExportLabelHelper, private AggregateStringHelper $aggregateStringHelper, private RollingDateConverterInterface $rollingDateConverter) + public function __construct(private readonly EntityManagerInterface $entityManager, private readonly SocialIssueRender $socialIssueRender, private readonly SocialIssueRepository $socialIssueRepository, private readonly SocialActionRender $socialActionRender, private readonly SocialActionRepository $socialActionRepository, private readonly UserHelper $userHelper, private readonly LabelPersonHelper $personHelper, private readonly DateTimeHelper $dateTimeHelper, private readonly TranslatableStringExportLabelHelper $translatableStringExportLabelHelper, private readonly AggregateStringHelper $aggregateStringHelper, private readonly RollingDateConverterInterface $rollingDateConverter) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListHouseholdInPeriod.php b/src/Bundle/ChillPersonBundle/Export/Export/ListHouseholdInPeriod.php index 06d79d6fc..a140d166e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListHouseholdInPeriod.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListHouseholdInPeriod.php @@ -45,7 +45,7 @@ class ListHouseholdInPeriod implements ListInterface, GroupedExportInterface 'compositionType', ]; - public function __construct(private ExportAddressHelper $addressHelper, private AggregateStringHelper $aggregateStringHelper, private EntityManagerInterface $entityManager, private RollingDateConverterInterface $rollingDateConverter, private TranslatableStringExportLabelHelper $translatableStringHelper) + public function __construct(private readonly ExportAddressHelper $addressHelper, private readonly AggregateStringHelper $aggregateStringHelper, private readonly EntityManagerInterface $entityManager, private readonly RollingDateConverterInterface $rollingDateConverter, private readonly TranslatableStringExportLabelHelper $translatableStringHelper) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php b/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php index 02c0722d4..919e83049 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php @@ -50,7 +50,7 @@ class ListPerson implements ExportElementValidatedInterface, ListInterface, Grou { private $slugs = []; - public function __construct(private ExportAddressHelper $addressHelper, private CustomFieldProvider $customFieldProvider, private ListPersonHelper $listPersonHelper, private EntityManagerInterface $entityManager, private TranslatableStringHelper $translatableStringHelper) + public function __construct(private readonly ExportAddressHelper $addressHelper, private readonly CustomFieldProvider $customFieldProvider, private readonly ListPersonHelper $listPersonHelper, private readonly EntityManagerInterface $entityManager, private readonly TranslatableStringHelper $translatableStringHelper) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListPersonDuplicate.php b/src/Bundle/ChillPersonBundle/Export/Export/ListPersonDuplicate.php index 4181098b2..e986ef43c 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListPersonDuplicate.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListPersonDuplicate.php @@ -49,8 +49,8 @@ class ListPersonDuplicate implements DirectExportInterface, ExportElementValidat public function __construct( EntityManagerInterface $em, - private TranslatorInterface $translator, - private UrlGeneratorInterface $router, + private readonly TranslatorInterface $translator, + private readonly UrlGeneratorInterface $router, $routeParameters ) { $this->entityManager = $em; diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriod.php index 9676a9437..57e943bc0 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriod.php @@ -37,7 +37,7 @@ use function strlen; class ListPersonWithAccompanyingPeriod implements ExportElementValidatedInterface, ListInterface, GroupedExportInterface { - public function __construct(private ExportAddressHelper $addressHelper, private ListPersonHelper $listPersonHelper, private EntityManagerInterface $entityManager) + public function __construct(private readonly ExportAddressHelper $addressHelper, private readonly ListPersonHelper $listPersonHelper, private readonly EntityManagerInterface $entityManager) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php b/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php index 1d0161b24..5b6bea62a 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php @@ -29,7 +29,7 @@ use Symfony\Component\Form\FormBuilderInterface; class StatAccompanyingCourseDuration implements ExportInterface, GroupedExportInterface { - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct( EntityManagerInterface $em diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOnDateFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOnDateFilter.php index 3f5a25053..3ca897e61 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOnDateFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOnDateFilter.php @@ -22,7 +22,7 @@ use Symfony\Component\Form\FormBuilderInterface; class ActiveOnDateFilter implements FilterInterface { - public function __construct(private RollingDateConverterInterface $rollingDateConverter) + public function __construct(private readonly RollingDateConverterInterface $rollingDateConverter) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOneDayBetweenDatesFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOneDayBetweenDatesFilter.php index ff1ac7653..cf1703254 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOneDayBetweenDatesFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOneDayBetweenDatesFilter.php @@ -21,7 +21,7 @@ use Symfony\Component\Form\FormBuilderInterface; class ActiveOneDayBetweenDatesFilter implements FilterInterface { - public function __construct(private RollingDateConverterInterface $rollingDateConverter) + public function __construct(private readonly RollingDateConverterInterface $rollingDateConverter) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/AdministrativeLocationFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/AdministrativeLocationFilter.php index d4e74d165..871d56ce7 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/AdministrativeLocationFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/AdministrativeLocationFilter.php @@ -20,7 +20,7 @@ use Symfony\Component\Form\FormBuilderInterface; class AdministrativeLocationFilter implements FilterInterface { - public function __construct(private TranslatableStringHelper $translatableStringHelper) + public function __construct(private readonly TranslatableStringHelper $translatableStringHelper) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ClosingMotiveFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ClosingMotiveFilter.php index a8fb0b48e..59d7a7f38 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ClosingMotiveFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ClosingMotiveFilter.php @@ -22,7 +22,7 @@ use Symfony\Component\Form\FormBuilderInterface; class ClosingMotiveFilter implements FilterInterface { - public function __construct(private TranslatableStringHelper $translatableStringHelper) + public function __construct(private readonly TranslatableStringHelper $translatableStringHelper) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ConfidentialFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ConfidentialFilter.php index 1803e8067..e8f5c76da 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ConfidentialFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ConfidentialFilter.php @@ -28,7 +28,7 @@ class ConfidentialFilter implements FilterInterface private const DEFAULT_CHOICE = false; - public function __construct(private TranslatorInterface $translator) + public function __construct(private readonly TranslatorInterface $translator) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorJobFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorJobFilter.php index 79412bb61..9f77729d2 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorJobFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorJobFilter.php @@ -23,7 +23,7 @@ use function in_array; class CreatorJobFilter implements FilterInterface { - public function __construct(private TranslatableStringHelper $translatableStringHelper, private UserJobRepositoryInterface $userJobRepository) + public function __construct(private readonly TranslatableStringHelper $translatableStringHelper, private readonly UserJobRepositoryInterface $userJobRepository) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EmergencyFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EmergencyFilter.php index b680299a1..04a9d5e0e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EmergencyFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EmergencyFilter.php @@ -28,7 +28,7 @@ class EmergencyFilter implements FilterInterface private const DEFAULT_CHOICE = false; - public function __construct(private TranslatorInterface $translator) + public function __construct(private readonly TranslatorInterface $translator) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EvaluationFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EvaluationFilter.php index e4e895555..c762db932 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EvaluationFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EvaluationFilter.php @@ -23,7 +23,7 @@ use function in_array; class EvaluationFilter implements FilterInterface { - public function __construct(private EvaluationRepositoryInterface $evaluationRepository, private TranslatableStringHelper $translatableStringHelper) + public function __construct(private readonly EvaluationRepositoryInterface $evaluationRepository, private readonly TranslatableStringHelper $translatableStringHelper) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php index 31a449a35..83ba64949 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php @@ -32,7 +32,7 @@ use Symfony\Component\Form\FormBuilderInterface; */ class GeographicalUnitStatFilter implements FilterInterface { - public function __construct(private GeographicalUnitRepositoryInterface $geographicalUnitRepository, private GeographicalUnitLayerRepositoryInterface $geographicalUnitLayerRepository, private TranslatableStringHelperInterface $translatableStringHelper, private RollingDateConverterInterface $rollingDateConverter) + public function __construct(private readonly GeographicalUnitRepositoryInterface $geographicalUnitRepository, private readonly GeographicalUnitLayerRepositoryInterface $geographicalUnitLayerRepository, private readonly TranslatableStringHelperInterface $translatableStringHelper, private readonly RollingDateConverterInterface $rollingDateConverter) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasNoReferrerFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasNoReferrerFilter.php index 43503a6b9..b20ef28e7 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasNoReferrerFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasNoReferrerFilter.php @@ -22,7 +22,7 @@ use Symfony\Component\Form\FormBuilderInterface; class HasNoReferrerFilter implements FilterInterface { - public function __construct(private RollingDateConverterInterface $rollingDateConverter) + public function __construct(private readonly RollingDateConverterInterface $rollingDateConverter) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasTemporaryLocationFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasTemporaryLocationFilter.php index 9ef7f012f..36aa711bd 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasTemporaryLocationFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasTemporaryLocationFilter.php @@ -23,7 +23,7 @@ use Symfony\Component\Form\FormBuilderInterface; class HasTemporaryLocationFilter implements FilterInterface { - public function __construct(private RollingDateConverterInterface $rollingDateConverter) + public function __construct(private readonly RollingDateConverterInterface $rollingDateConverter) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/IntensityFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/IntensityFilter.php index 1f215bce9..3bdadb75d 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/IntensityFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/IntensityFilter.php @@ -28,7 +28,7 @@ class IntensityFilter implements FilterInterface private const DEFAULT_CHOICE = 'occasional'; - public function __construct(private TranslatorInterface $translator) + public function __construct(private readonly TranslatorInterface $translator) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OpenBetweenDatesFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OpenBetweenDatesFilter.php index 23823467f..d74b7d433 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OpenBetweenDatesFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OpenBetweenDatesFilter.php @@ -22,7 +22,7 @@ use Symfony\Component\Form\FormBuilderInterface; class OpenBetweenDatesFilter implements FilterInterface { - public function __construct(private RollingDateConverterInterface $rollingDateConverter) + public function __construct(private readonly RollingDateConverterInterface $rollingDateConverter) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OriginFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OriginFilter.php index f3b927f68..97390621b 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OriginFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OriginFilter.php @@ -22,7 +22,7 @@ use Symfony\Component\Form\FormBuilderInterface; class OriginFilter implements FilterInterface { - public function __construct(private TranslatableStringHelper $translatableStringHelper) + public function __construct(private readonly TranslatableStringHelper $translatableStringHelper) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ReferrerFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ReferrerFilter.php index ee79ca8f8..9bb0e8f45 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ReferrerFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ReferrerFilter.php @@ -29,7 +29,7 @@ class ReferrerFilter implements FilterInterface private const PU = 'acp_referrer_filter_users'; - public function __construct(private RollingDateConverterInterface $rollingDateConverter) + public function __construct(private readonly RollingDateConverterInterface $rollingDateConverter) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/RequestorFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/RequestorFilter.php index 60fc9e5ec..7e8aa2de4 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/RequestorFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/RequestorFilter.php @@ -22,7 +22,7 @@ use Symfony\Component\Form\FormBuilderInterface; use Symfony\Contracts\Translation\TranslatorInterface; use function in_array; -final class RequestorFilter implements FilterInterface +final readonly class RequestorFilter implements FilterInterface { private const DEFAULT_CHOICE = 'participation'; diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php index fd4d4ac64..64d7c4848 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php @@ -23,7 +23,7 @@ use function in_array; class SocialActionFilter implements FilterInterface { - public function __construct(private TranslatableStringHelper $translatableStringHelper, private SocialActionRender $actionRender) + public function __construct(private readonly TranslatableStringHelper $translatableStringHelper, private readonly SocialActionRender $actionRender) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php index ee9ebfc79..88b45e7be 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php @@ -30,7 +30,7 @@ class SocialIssueFilter implements FilterInterface public function __construct( TranslatorInterface $translator, - private SocialIssueRender $socialIssueRender + private readonly SocialIssueRender $socialIssueRender ) { $this->translator = $translator; } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/StepFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/StepFilter.php index e217cdab0..0549bc7a1 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/StepFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/StepFilter.php @@ -37,7 +37,7 @@ class StepFilter implements FilterInterface 'Closed' => AccompanyingPeriod::STEP_CLOSED, ]; - public function __construct(private RollingDateConverterInterface $rollingDateConverter, private TranslatorInterface $translator) + public function __construct(private readonly RollingDateConverterInterface $rollingDateConverter, private readonly TranslatorInterface $translator) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserJobFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserJobFilter.php index 7e8a3ecc3..b63c5c8f0 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserJobFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserJobFilter.php @@ -34,7 +34,7 @@ class UserJobFilter implements FilterInterface private const PJ = 'acp_ujob_filter_job'; - public function __construct(private TranslatableStringHelper $translatableStringHelper, private UserJobRepositoryInterface $userJobRepository, private RollingDateConverterInterface $rollingDateConverter) + public function __construct(private readonly TranslatableStringHelper $translatableStringHelper, private readonly UserJobRepositoryInterface $userJobRepository, private readonly RollingDateConverterInterface $rollingDateConverter) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserScopeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserScopeFilter.php index 58a935a0e..5abbdeec4 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserScopeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserScopeFilter.php @@ -35,7 +35,7 @@ class UserScopeFilter implements FilterInterface private const PS = 'acp_uscope_filter_scopes'; - public function __construct(private ScopeRepositoryInterface $scopeRepository, private Security $security, private TranslatableStringHelper $translatableStringHelper, private RollingDateConverterInterface $rollingDateConverter) + public function __construct(private readonly ScopeRepositoryInterface $scopeRepository, private readonly Security $security, private readonly TranslatableStringHelper $translatableStringHelper, private readonly RollingDateConverterInterface $rollingDateConverter) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/ByEndDateFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/ByEndDateFilter.php index 553e58a39..41e2ffc0a 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/ByEndDateFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/ByEndDateFilter.php @@ -21,7 +21,7 @@ use Symfony\Component\Form\FormBuilderInterface; class ByEndDateFilter implements FilterInterface { - public function __construct(private RollingDateConverterInterface $rollingDateConverter) + public function __construct(private readonly RollingDateConverterInterface $rollingDateConverter) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/ByStartDateFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/ByStartDateFilter.php index 7485020ce..f44acf6cc 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/ByStartDateFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/ByStartDateFilter.php @@ -21,7 +21,7 @@ use Symfony\Component\Form\FormBuilderInterface; class ByStartDateFilter implements FilterInterface { - public function __construct(private RollingDateConverterInterface $rollingDateConverter) + public function __construct(private readonly RollingDateConverterInterface $rollingDateConverter) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/EvaluationTypeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/EvaluationTypeFilter.php index 1062b8a12..5a4f3a2e0 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/EvaluationTypeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/EvaluationTypeFilter.php @@ -20,7 +20,7 @@ use Doctrine\ORM\QueryBuilder; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\FormBuilderInterface; -final class EvaluationTypeFilter implements FilterInterface +final readonly class EvaluationTypeFilter implements FilterInterface { public function __construct(private TranslatableStringHelper $translatableStringHelper) { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/MaxDateFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/MaxDateFilter.php index 1ca3f3f99..f020e24f0 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/MaxDateFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/MaxDateFilter.php @@ -25,7 +25,7 @@ class MaxDateFilter implements FilterInterface 'maxdate is not specified' => false, ]; - public function __construct(private TranslatorInterface $translator) + public function __construct(private readonly TranslatorInterface $translator) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/HouseholdFilters/CompositionFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/HouseholdFilters/CompositionFilter.php index dcf98f307..4e18e0adc 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/HouseholdFilters/CompositionFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/HouseholdFilters/CompositionFilter.php @@ -26,7 +26,7 @@ use function in_array; class CompositionFilter implements FilterInterface { - public function __construct(private TranslatableStringHelper $translatableStringHelper, private RollingDateConverterInterface $rollingDateConverter) + public function __construct(private readonly TranslatableStringHelper $translatableStringHelper, private readonly RollingDateConverterInterface $rollingDateConverter) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AddressRefStatusFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AddressRefStatusFilter.php index b4001b3c4..9d0568f02 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AddressRefStatusFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AddressRefStatusFilter.php @@ -24,7 +24,7 @@ use Symfony\Component\Form\FormBuilderInterface; class AddressRefStatusFilter implements \Chill\MainBundle\Export\FilterInterface { - public function __construct(private RollingDateConverterInterface $rollingDateConverter) + public function __construct(private readonly RollingDateConverterInterface $rollingDateConverter) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AgeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AgeFilter.php index da3c4a7f2..89a4dac56 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AgeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AgeFilter.php @@ -26,7 +26,7 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface; class AgeFilter implements ExportElementValidatedInterface, FilterInterface { - public function __construct(private RollingDateConverterInterface $rollingDateConverter) + public function __construct(private readonly RollingDateConverterInterface $rollingDateConverter) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/BirthdateFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/BirthdateFilter.php index 46946e41e..4724b2987 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/BirthdateFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/BirthdateFilter.php @@ -24,7 +24,7 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface; class BirthdateFilter implements ExportElementValidatedInterface, FilterInterface { - public function __construct(private RollingDateConverterInterface $rollingDateConverter) + public function __construct(private readonly RollingDateConverterInterface $rollingDateConverter) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ByHouseholdCompositionFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ByHouseholdCompositionFilter.php index 63ee441af..8307d7d70 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ByHouseholdCompositionFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ByHouseholdCompositionFilter.php @@ -28,7 +28,7 @@ use Symfony\Component\Form\FormBuilderInterface; class ByHouseholdCompositionFilter implements FilterInterface { - public function __construct(private HouseholdCompositionTypeRepositoryInterface $householdCompositionTypeRepository, private RollingDateConverterInterface $rollingDateConverter, private TranslatableStringHelperInterface $translatableStringHelper) + public function __construct(private readonly HouseholdCompositionTypeRepositoryInterface $householdCompositionTypeRepository, private readonly RollingDateConverterInterface $rollingDateConverter, private readonly TranslatableStringHelperInterface $translatableStringHelper) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/DeadOrAliveFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/DeadOrAliveFilter.php index 7daf1c9e1..c37d06da9 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/DeadOrAliveFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/DeadOrAliveFilter.php @@ -23,7 +23,7 @@ use Symfony\Component\Form\FormBuilderInterface; class DeadOrAliveFilter implements FilterInterface { - public function __construct(private RollingDateConverterInterface $rollingDateConverter) + public function __construct(private readonly RollingDateConverterInterface $rollingDateConverter) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/DeathdateFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/DeathdateFilter.php index 04675054f..a47893316 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/DeathdateFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/DeathdateFilter.php @@ -24,7 +24,7 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface; class DeathdateFilter implements ExportElementValidatedInterface, FilterInterface { - public function __construct(private RollingDateConverterInterface $rollingDateConverter) + public function __construct(private readonly RollingDateConverterInterface $rollingDateConverter) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GeographicalUnitFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GeographicalUnitFilter.php index 509bb3ab0..5776d0588 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GeographicalUnitFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GeographicalUnitFilter.php @@ -26,7 +26,7 @@ use Symfony\Component\Form\FormBuilderInterface; class GeographicalUnitFilter implements \Chill\MainBundle\Export\FilterInterface { - public function __construct(private GeographicalUnitRepositoryInterface $geographicalUnitRepository, private GeographicalUnitLayerRepositoryInterface $geographicalUnitLayerRepository, private TranslatableStringHelperInterface $translatableStringHelper, private RollingDateConverterInterface $rollingDateConverter) + public function __construct(private readonly GeographicalUnitRepositoryInterface $geographicalUnitRepository, private readonly GeographicalUnitLayerRepositoryInterface $geographicalUnitLayerRepository, private readonly TranslatableStringHelperInterface $translatableStringHelper, private readonly RollingDateConverterInterface $rollingDateConverter) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/MaritalStatusFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/MaritalStatusFilter.php index 279b693f6..6fa4987bb 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/MaritalStatusFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/MaritalStatusFilter.php @@ -19,7 +19,7 @@ use Symfony\Bridge\Doctrine\Form\Type\EntityType; class MaritalStatusFilter implements FilterInterface { - public function __construct(private TranslatableStringHelper $translatableStringHelper) + public function __construct(private readonly TranslatableStringHelper $translatableStringHelper) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/NationalityFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/NationalityFilter.php index 4463f433f..75fe4e2d4 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/NationalityFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/NationalityFilter.php @@ -26,7 +26,7 @@ class NationalityFilter implements ExportElementValidatedInterface, FilterInterface { - public function __construct(private TranslatableStringHelper $translatableStringHelper) + public function __construct(private readonly TranslatableStringHelper $translatableStringHelper) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php index 4afc3fd71..2418671cd 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php @@ -27,7 +27,7 @@ use function in_array; class ResidentialAddressAtThirdpartyFilter implements FilterInterface { - public function __construct(private RollingDateConverterInterface $rollingDateConverter, private TranslatableStringHelper $translatableStringHelper) + public function __construct(private readonly RollingDateConverterInterface $rollingDateConverter, private readonly TranslatableStringHelper $translatableStringHelper) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtUserFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtUserFilter.php index e6b55904e..05e7cc630 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtUserFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtUserFilter.php @@ -24,7 +24,7 @@ use function in_array; class ResidentialAddressAtUserFilter implements FilterInterface { - public function __construct(private RollingDateConverterInterface $rollingDateConverter) + public function __construct(private readonly RollingDateConverterInterface $rollingDateConverter) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/WithoutHouseholdComposition.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/WithoutHouseholdComposition.php index 702b8a7b0..d1ed0bbf2 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/WithoutHouseholdComposition.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/WithoutHouseholdComposition.php @@ -24,7 +24,7 @@ use Symfony\Component\Form\FormBuilderInterface; class WithoutHouseholdComposition implements FilterInterface { - public function __construct(private RollingDateConverterInterface $rollingDateConverter) + public function __construct(private readonly RollingDateConverterInterface $rollingDateConverter) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/JobFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/JobFilter.php index 36b671d54..cd65f16a5 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/JobFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/JobFilter.php @@ -24,7 +24,7 @@ use function in_array; class JobFilter implements FilterInterface { - public function __construct(protected TranslatorInterface $translator, private TranslatableStringHelper $translatableStringHelper) + public function __construct(protected TranslatorInterface $translator, private readonly TranslatableStringHelper $translatableStringHelper) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ScopeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ScopeFilter.php index f393354b1..2d75c1ae2 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ScopeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ScopeFilter.php @@ -24,7 +24,7 @@ use function in_array; class ScopeFilter implements FilterInterface { - public function __construct(protected TranslatorInterface $translator, private TranslatableStringHelper $translatableStringHelper) + public function __construct(protected TranslatorInterface $translator, private readonly TranslatableStringHelper $translatableStringHelper) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/SocialWorkTypeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/SocialWorkTypeFilter.php index 83fea8223..c717372d8 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/SocialWorkTypeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/SocialWorkTypeFilter.php @@ -28,7 +28,7 @@ use function in_array; class SocialWorkTypeFilter implements FilterInterface { - public function __construct(private SocialActionRender $socialActionRender, private TranslatableStringHelper $translatableStringHelper, private EntityManagerInterface $em) + public function __construct(private readonly SocialActionRender $socialActionRender, private readonly TranslatableStringHelper $translatableStringHelper, private readonly EntityManagerInterface $em) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Helper/LabelPersonHelper.php b/src/Bundle/ChillPersonBundle/Export/Helper/LabelPersonHelper.php index 5afde9986..20029b296 100644 --- a/src/Bundle/ChillPersonBundle/Export/Helper/LabelPersonHelper.php +++ b/src/Bundle/ChillPersonBundle/Export/Helper/LabelPersonHelper.php @@ -18,7 +18,7 @@ use const SORT_NUMERIC; class LabelPersonHelper { - public function __construct(private PersonRepository $personRepository, private PersonRenderInterface $personRender) + public function __construct(private readonly PersonRepository $personRepository, private readonly PersonRenderInterface $personRender) { } diff --git a/src/Bundle/ChillPersonBundle/Export/Helper/ListPersonHelper.php b/src/Bundle/ChillPersonBundle/Export/Helper/ListPersonHelper.php index 600aaa60b..0f8d6d4ae 100644 --- a/src/Bundle/ChillPersonBundle/Export/Helper/ListPersonHelper.php +++ b/src/Bundle/ChillPersonBundle/Export/Helper/ListPersonHelper.php @@ -41,7 +41,7 @@ use function strlen; */ class ListPersonHelper { - public const FIELDS = [ + final public const FIELDS = [ 'id', 'civility', 'firstName', @@ -73,7 +73,7 @@ class ListPersonHelper 'lifecycleUpdate', ]; - public function __construct(private ExportAddressHelper $addressHelper, private CenterRepositoryInterface $centerRepository, private CivilityRepositoryInterface $civilityRepository, private CountryRepository $countryRepository, private LanguageRepositoryInterface $languageRepository, private MaritalStatusRepositoryInterface $maritalStatusRepository, private TranslatableStringHelper $translatableStringHelper, private TranslatorInterface $translator, private UserRepositoryInterface $userRepository) + public function __construct(private readonly ExportAddressHelper $addressHelper, private readonly CenterRepositoryInterface $centerRepository, private readonly CivilityRepositoryInterface $civilityRepository, private readonly CountryRepository $countryRepository, private readonly LanguageRepositoryInterface $languageRepository, private readonly MaritalStatusRepositoryInterface $maritalStatusRepository, private readonly TranslatableStringHelper $translatableStringHelper, private readonly TranslatorInterface $translator, private readonly UserRepositoryInterface $userRepository) { } @@ -201,7 +201,7 @@ class ListPersonHelper public function getLabels($key, array $values, $data): callable { - if (str_starts_with($key, 'address_fields')) { + if (str_starts_with((string) $key, 'address_fields')) { return $this->addressHelper->getLabel($key, $values, $data, 'address_fields'); } diff --git a/src/Bundle/ChillPersonBundle/Form/CreationPersonType.php b/src/Bundle/ChillPersonBundle/Form/CreationPersonType.php index 8f1f0ba43..01814af38 100644 --- a/src/Bundle/ChillPersonBundle/Form/CreationPersonType.php +++ b/src/Bundle/ChillPersonBundle/Form/CreationPersonType.php @@ -40,11 +40,11 @@ final class CreationPersonType extends AbstractType // TODO: See if this is still valid and update accordingly. public const NAME = 'chill_personbundle_person_creation'; - private bool $askCenters; + private readonly bool $askCenters; public function __construct( - private ConfigPersonAltNamesHelper $configPersonAltNamesHelper, - private EventDispatcherInterface $dispatcher, + private readonly ConfigPersonAltNamesHelper $configPersonAltNamesHelper, + private readonly EventDispatcherInterface $dispatcher, ParameterBagInterface $parameterBag ) { $this->askCenters = $parameterBag->get('chill_main')['acl']['form_show_centers']; @@ -114,7 +114,7 @@ final class CreationPersonType extends AbstractType $resolver->setDefaults([ 'data_class' => Person::class, 'constraints' => [ - new Callback([$this, 'validateCheckedAddress']), + new Callback($this->validateCheckedAddress(...)), ], ]); } diff --git a/src/Bundle/ChillPersonBundle/Form/HouseholdCompositionType.php b/src/Bundle/ChillPersonBundle/Form/HouseholdCompositionType.php index 4dc2e1a73..0fe60cbe9 100644 --- a/src/Bundle/ChillPersonBundle/Form/HouseholdCompositionType.php +++ b/src/Bundle/ChillPersonBundle/Form/HouseholdCompositionType.php @@ -22,7 +22,7 @@ use Symfony\Component\Form\FormBuilderInterface; class HouseholdCompositionType extends AbstractType { - public function __construct(private HouseholdCompositionTypeRepository $householdCompositionTypeRepository, private TranslatableStringHelperInterface $translatableStringHelper) + public function __construct(private readonly HouseholdCompositionTypeRepository $householdCompositionTypeRepository, private readonly TranslatableStringHelperInterface $translatableStringHelper) { } diff --git a/src/Bundle/ChillPersonBundle/Form/PersonResourceType.php b/src/Bundle/ChillPersonBundle/Form/PersonResourceType.php index 3790cb03a..a4946b52d 100644 --- a/src/Bundle/ChillPersonBundle/Form/PersonResourceType.php +++ b/src/Bundle/ChillPersonBundle/Form/PersonResourceType.php @@ -29,7 +29,7 @@ use Symfony\Contracts\Translation\TranslatorInterface; final class PersonResourceType extends AbstractType { - public function __construct(private ResourceKindRender $resourceKindRender, private PersonRenderInterface $personRender, private ThirdPartyRender $thirdPartyRender, private TranslatorInterface $translator) + public function __construct(private readonly ResourceKindRender $resourceKindRender, private readonly PersonRenderInterface $personRender, private readonly ThirdPartyRender $thirdPartyRender, private readonly TranslatorInterface $translator) { } diff --git a/src/Bundle/ChillPersonBundle/Form/PersonType.php b/src/Bundle/ChillPersonBundle/Form/PersonType.php index db5635f97..6ba4cafaf 100644 --- a/src/Bundle/ChillPersonBundle/Form/PersonType.php +++ b/src/Bundle/ChillPersonBundle/Form/PersonType.php @@ -64,7 +64,7 @@ class PersonType extends AbstractType array $personFieldsConfiguration, ConfigPersonAltNamesHelper $configAltNamesHelper, protected TranslatableStringHelperInterface $translatableStringHelper, - private ParameterBagInterface $parameterBag + private readonly ParameterBagInterface $parameterBag ) { $this->config = $personFieldsConfiguration; $this->configAltNamesHelper = $configAltNamesHelper; diff --git a/src/Bundle/ChillPersonBundle/Form/Type/PersonAltNameType.php b/src/Bundle/ChillPersonBundle/Form/Type/PersonAltNameType.php index 0c7efe647..17aad8bd0 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/PersonAltNameType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/PersonAltNameType.php @@ -21,7 +21,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver; class PersonAltNameType extends AbstractType { - public function __construct(private ConfigPersonAltNamesHelper $configHelper, private TranslatableStringHelper $translatableStringHelper) + public function __construct(private readonly ConfigPersonAltNamesHelper $configHelper, private readonly TranslatableStringHelper $translatableStringHelper) { } diff --git a/src/Bundle/ChillPersonBundle/Form/Type/PersonPhoneType.php b/src/Bundle/ChillPersonBundle/Form/Type/PersonPhoneType.php index db51d507a..a55721011 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/PersonPhoneType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/PersonPhoneType.php @@ -24,7 +24,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver; class PersonPhoneType extends AbstractType { - public function __construct(private PhonenumberHelper $phonenumberHelper, private EntityManagerInterface $em) + public function __construct(private readonly PhonenumberHelper $phonenumberHelper, private readonly EntityManagerInterface $em) { } diff --git a/src/Bundle/ChillPersonBundle/Form/Type/PickPersonDynamicType.php b/src/Bundle/ChillPersonBundle/Form/Type/PickPersonDynamicType.php index 4c3139c8e..440b6568c 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/PickPersonDynamicType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/PickPersonDynamicType.php @@ -26,7 +26,7 @@ use Symfony\Component\Serializer\SerializerInterface; */ class PickPersonDynamicType extends AbstractType { - public function __construct(private DenormalizerInterface $denormalizer, private SerializerInterface $serializer, private NormalizerInterface $normalizer) + public function __construct(private readonly DenormalizerInterface $denormalizer, private readonly SerializerInterface $serializer, private readonly NormalizerInterface $normalizer) { } diff --git a/src/Bundle/ChillPersonBundle/Form/Type/PickSocialActionType.php b/src/Bundle/ChillPersonBundle/Form/Type/PickSocialActionType.php index b2e3c6d9b..0fe09e56a 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/PickSocialActionType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/PickSocialActionType.php @@ -20,7 +20,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver; class PickSocialActionType extends AbstractType { - public function __construct(private SocialActionRender $actionRender, private SocialActionRepository $actionRepository) + public function __construct(private readonly SocialActionRender $actionRender, private readonly SocialActionRepository $actionRepository) { } diff --git a/src/Bundle/ChillPersonBundle/Form/Type/PickSocialIssueType.php b/src/Bundle/ChillPersonBundle/Form/Type/PickSocialIssueType.php index 31cd44ab1..3e6ae1e97 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/PickSocialIssueType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/PickSocialIssueType.php @@ -20,7 +20,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver; class PickSocialIssueType extends AbstractType { - public function __construct(private SocialIssueRender $issueRender, private SocialIssueRepository $issueRepository) + public function __construct(private readonly SocialIssueRender $issueRender, private readonly SocialIssueRepository $issueRepository) { } diff --git a/src/Bundle/ChillPersonBundle/Form/Type/Select2MaritalStatusType.php b/src/Bundle/ChillPersonBundle/Form/Type/Select2MaritalStatusType.php index a4e6c46c9..69823c07c 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/Select2MaritalStatusType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/Select2MaritalStatusType.php @@ -28,7 +28,7 @@ use const SORT_STRING; */ class Select2MaritalStatusType extends AbstractType { - public function __construct(private TranslatableStringHelper $translatableStringHelper, private EntityManagerInterface $em) + public function __construct(private readonly TranslatableStringHelper $translatableStringHelper, private readonly EntityManagerInterface $em) { } diff --git a/src/Bundle/ChillPersonBundle/Household/MembersEditor.php b/src/Bundle/ChillPersonBundle/Household/MembersEditor.php index 92f1bba5c..50807bcff 100644 --- a/src/Bundle/ChillPersonBundle/Household/MembersEditor.php +++ b/src/Bundle/ChillPersonBundle/Household/MembersEditor.php @@ -28,11 +28,11 @@ use function spl_object_hash; class MembersEditor { - public const VALIDATION_GROUP_AFFECTED = 'household_memberships'; + final public const VALIDATION_GROUP_AFFECTED = 'household_memberships'; - public const VALIDATION_GROUP_COMPOSITION = 'household_composition'; + final public const VALIDATION_GROUP_COMPOSITION = 'household_composition'; - public const VALIDATION_GROUP_CREATED = 'household_memberships_created'; + final public const VALIDATION_GROUP_CREATED = 'household_memberships_created'; private array $events = []; @@ -42,7 +42,7 @@ class MembersEditor private array $persistables = []; - public function __construct(private ValidatorInterface $validator, private ?\Chill\PersonBundle\Entity\Household\Household $household, private EventDispatcherInterface $eventDispatcher) + public function __construct(private readonly ValidatorInterface $validator, private readonly ?\Chill\PersonBundle\Entity\Household\Household $household, private readonly EventDispatcherInterface $eventDispatcher) { } diff --git a/src/Bundle/ChillPersonBundle/Household/MembersEditorFactory.php b/src/Bundle/ChillPersonBundle/Household/MembersEditorFactory.php index 9fae0dc82..cb6f7d4ea 100644 --- a/src/Bundle/ChillPersonBundle/Household/MembersEditorFactory.php +++ b/src/Bundle/ChillPersonBundle/Household/MembersEditorFactory.php @@ -17,7 +17,7 @@ use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; class MembersEditorFactory { - public function __construct(private EventDispatcherInterface $eventDispatcher, private ValidatorInterface $validator) + public function __construct(private readonly EventDispatcherInterface $eventDispatcher, private readonly ValidatorInterface $validator) { } diff --git a/src/Bundle/ChillPersonBundle/Menu/PersonMenuBuilder.php b/src/Bundle/ChillPersonBundle/Menu/PersonMenuBuilder.php index dde404de0..2bbd47527 100644 --- a/src/Bundle/ChillPersonBundle/Menu/PersonMenuBuilder.php +++ b/src/Bundle/ChillPersonBundle/Menu/PersonMenuBuilder.php @@ -40,9 +40,9 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface public function __construct( ParameterBagInterface $parameterBag, - private Security $security, + private readonly Security $security, protected TranslatorInterface $translator, - private ResidentialAddressRepository $residentialAddressRepo + private readonly ResidentialAddressRepository $residentialAddressRepo ) { $this->showAccompanyingPeriod = $parameterBag->get('chill_person.accompanying_period'); } diff --git a/src/Bundle/ChillPersonBundle/Menu/SectionMenuBuilder.php b/src/Bundle/ChillPersonBundle/Menu/SectionMenuBuilder.php index acbdd6d3c..c562545bb 100644 --- a/src/Bundle/ChillPersonBundle/Menu/SectionMenuBuilder.php +++ b/src/Bundle/ChillPersonBundle/Menu/SectionMenuBuilder.php @@ -28,7 +28,7 @@ class SectionMenuBuilder implements LocalMenuBuilderInterface /** * SectionMenuBuilder constructor. */ - public function __construct(protected ParameterBagInterface $parameterBag, private Security $security, protected TranslatorInterface $translator) + public function __construct(protected ParameterBagInterface $parameterBag, private readonly Security $security, protected TranslatorInterface $translator) { } diff --git a/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodNotificationHandler.php b/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodNotificationHandler.php index 85e18633d..ddcae7d97 100644 --- a/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodNotificationHandler.php +++ b/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodNotificationHandler.php @@ -16,7 +16,7 @@ use Chill\MainBundle\Notification\NotificationHandlerInterface; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Repository\AccompanyingPeriodRepository; -final class AccompanyingPeriodNotificationHandler implements NotificationHandlerInterface +final readonly class AccompanyingPeriodNotificationHandler implements NotificationHandlerInterface { public function __construct(private AccompanyingPeriodRepository $accompanyingPeriodRepository) { diff --git a/src/Bundle/ChillPersonBundle/Privacy/AccompanyingPeriodPrivacyEvent.php b/src/Bundle/ChillPersonBundle/Privacy/AccompanyingPeriodPrivacyEvent.php index 957461b55..1475c35ec 100644 --- a/src/Bundle/ChillPersonBundle/Privacy/AccompanyingPeriodPrivacyEvent.php +++ b/src/Bundle/ChillPersonBundle/Privacy/AccompanyingPeriodPrivacyEvent.php @@ -36,7 +36,7 @@ use Symfony\Component\EventDispatcher\Event; class AccompanyingPeriodPrivacyEvent extends Event { - public const ACCOMPANYING_PERIOD_PRIVACY_EVENT = 'chill_person.accompanying_period_privacy_event'; + final public const ACCOMPANYING_PERIOD_PRIVACY_EVENT = 'chill_person.accompanying_period_privacy_event'; public function __construct(protected $period, protected $args = []) { diff --git a/src/Bundle/ChillPersonBundle/Privacy/PrivacyEvent.php b/src/Bundle/ChillPersonBundle/Privacy/PrivacyEvent.php index 27861944c..c021a0b8f 100644 --- a/src/Bundle/ChillPersonBundle/Privacy/PrivacyEvent.php +++ b/src/Bundle/ChillPersonBundle/Privacy/PrivacyEvent.php @@ -44,7 +44,7 @@ use function count; */ class PrivacyEvent extends Event { - public const PERSON_PRIVACY_EVENT = 'chill_person.privacy_event'; + final public const PERSON_PRIVACY_EVENT = 'chill_person.privacy_event'; /** * @var array @@ -54,7 +54,7 @@ class PrivacyEvent extends Event /** * PrivacyEvent constructor. */ - public function __construct(private Person $person, private array $args = ['action' => 'show']) + public function __construct(private readonly Person $person, private readonly array $args = ['action' => 'show']) { } diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationDocumentRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationDocumentRepository.php index 7aa8fde00..193509890 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationDocumentRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationDocumentRepository.php @@ -18,7 +18,7 @@ use Doctrine\Persistence\ObjectRepository; class AccompanyingPeriodWorkEvaluationDocumentRepository implements ObjectRepository { - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct(EntityManagerInterface $em) { diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationRepository.php index 3cd9284df..28cbca270 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationRepository.php @@ -21,7 +21,7 @@ use Doctrine\Persistence\ObjectRepository; class AccompanyingPeriodWorkEvaluationRepository implements ObjectRepository { - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct(EntityManagerInterface $entityManager) { diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkGoalRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkGoalRepository.php index a80964325..4e092beb0 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkGoalRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkGoalRepository.php @@ -23,7 +23,7 @@ use Doctrine\ORM\EntityRepository; */ final class AccompanyingPeriodWorkGoalRepository { - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct(EntityManagerInterface $entityManager) { diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php index 85c382a49..eaacaf333 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php @@ -23,7 +23,7 @@ use Doctrine\ORM\Query\ResultSetMappingBuilder; use Doctrine\ORM\QueryBuilder; use Doctrine\Persistence\ObjectRepository; -final class AccompanyingPeriodWorkRepository implements ObjectRepository +final readonly class AccompanyingPeriodWorkRepository implements ObjectRepository { private EntityRepository $repository; diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/ClosingMotiveRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/ClosingMotiveRepository.php index 7983596c7..4a50de12b 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/ClosingMotiveRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/ClosingMotiveRepository.php @@ -16,7 +16,7 @@ use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; use Doctrine\ORM\Query\ResultSetMappingBuilder; -final class ClosingMotiveRepository implements ClosingMotiveRepositoryInterface +final readonly class ClosingMotiveRepository implements ClosingMotiveRepositoryInterface { private EntityRepository $repository; diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/CommentRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/CommentRepository.php index 207864ae2..3759cf2cd 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/CommentRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/CommentRepository.php @@ -17,7 +17,7 @@ use Doctrine\ORM\EntityRepository; final class CommentRepository { - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct(EntityManagerInterface $entityManager) { diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/OriginRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/OriginRepository.php index 3b3b6283d..1668b456e 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/OriginRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/OriginRepository.php @@ -17,7 +17,7 @@ use Doctrine\ORM\EntityRepository; final class OriginRepository { - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct(EntityManagerInterface $entityManager) { diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/ResourceRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/ResourceRepository.php index d8bc4e306..a5dbf4b69 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/ResourceRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/ResourceRepository.php @@ -17,7 +17,7 @@ use Doctrine\ORM\EntityRepository; final class ResourceRepository { - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct(EntityManagerInterface $entityManager) { diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php index 2b70da0a1..0c65a4e5a 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php @@ -33,7 +33,7 @@ use Doctrine\ORM\QueryBuilder; use Symfony\Component\Security\Core\Security; use function count; -final class AccompanyingPeriodACLAwareRepository implements AccompanyingPeriodACLAwareRepositoryInterface +final readonly class AccompanyingPeriodACLAwareRepository implements AccompanyingPeriodACLAwareRepositoryInterface { public function __construct(private AccompanyingPeriodRepository $accompanyingPeriodRepository, private Security $security, private AuthorizationHelper $authorizationHelper, private CenterResolverDispatcherInterface $centerResolverDispatcher) { diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodParticipationRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodParticipationRepository.php index 5384a1cdd..616c56eb0 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodParticipationRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodParticipationRepository.php @@ -17,7 +17,7 @@ use Doctrine\ORM\EntityRepository; final class AccompanyingPeriodParticipationRepository { - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct(EntityManagerInterface $entityManager) { diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodRepository.php index 6b7311207..36af2c763 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodRepository.php @@ -21,7 +21,7 @@ use Doctrine\Persistence\ObjectRepository; final class AccompanyingPeriodRepository implements ObjectRepository { - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct(EntityManagerInterface $entityManager) { diff --git a/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdACLAwareRepository.php b/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdACLAwareRepository.php index 33a17dfa1..7cc9e7dbe 100644 --- a/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdACLAwareRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdACLAwareRepository.php @@ -20,7 +20,7 @@ use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Security\Core\Security; -final class HouseholdACLAwareRepository implements HouseholdACLAwareRepositoryInterface +final readonly class HouseholdACLAwareRepository implements HouseholdACLAwareRepositoryInterface { public function __construct(private EntityManagerInterface $em, private AuthorizationHelper $authorizationHelper, private Security $security) { diff --git a/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdCompositionRepository.php b/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdCompositionRepository.php index e25d0c867..5a0dee15d 100644 --- a/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdCompositionRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdCompositionRepository.php @@ -18,7 +18,7 @@ use Doctrine\ORM\EntityRepository; final class HouseholdCompositionRepository implements HouseholdCompositionRepositoryInterface { - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct(EntityManagerInterface $entityManager) { diff --git a/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdCompositionTypeRepository.php b/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdCompositionTypeRepository.php index 04110942b..1e2c4a67f 100644 --- a/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdCompositionTypeRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdCompositionTypeRepository.php @@ -17,7 +17,7 @@ use Doctrine\ORM\EntityRepository; final class HouseholdCompositionTypeRepository implements HouseholdCompositionTypeRepositoryInterface { - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct(EntityManagerInterface $entityManager) { diff --git a/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdMembersRepository.php b/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdMembersRepository.php index 564c17732..e76e88fc3 100644 --- a/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdMembersRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdMembersRepository.php @@ -17,7 +17,7 @@ use Doctrine\ORM\EntityRepository; final class HouseholdMembersRepository { - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct(EntityManagerInterface $entityManager) { diff --git a/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdRepository.php b/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdRepository.php index 5123e8eb1..95fbda3ee 100644 --- a/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdRepository.php @@ -42,9 +42,9 @@ final class HouseholdRepository implements ObjectRepository SELECT {select} FROM households {limits} SQL; - private EntityManagerInterface $em; + private readonly EntityManagerInterface $em; - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct(EntityManagerInterface $entityManager) { diff --git a/src/Bundle/ChillPersonBundle/Repository/Household/PersonHouseholdAddressRepository.php b/src/Bundle/ChillPersonBundle/Repository/Household/PersonHouseholdAddressRepository.php index bc8fddf4e..ebcfabe4f 100644 --- a/src/Bundle/ChillPersonBundle/Repository/Household/PersonHouseholdAddressRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/Household/PersonHouseholdAddressRepository.php @@ -18,7 +18,7 @@ use Doctrine\Persistence\ObjectRepository; final class PersonHouseholdAddressRepository implements ObjectRepository { - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct(EntityManagerInterface $em) { diff --git a/src/Bundle/ChillPersonBundle/Repository/Household/PositionRepository.php b/src/Bundle/ChillPersonBundle/Repository/Household/PositionRepository.php index 734d83156..99e7338f9 100644 --- a/src/Bundle/ChillPersonBundle/Repository/Household/PositionRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/Household/PositionRepository.php @@ -20,7 +20,7 @@ use Doctrine\Persistence\ObjectRepository; final class PositionRepository implements ObjectRepository { - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct(EntityManagerInterface $entityManager) { diff --git a/src/Bundle/ChillPersonBundle/Repository/MaritalStatusRepository.php b/src/Bundle/ChillPersonBundle/Repository/MaritalStatusRepository.php index 8697f9346..3324ee444 100644 --- a/src/Bundle/ChillPersonBundle/Repository/MaritalStatusRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/MaritalStatusRepository.php @@ -17,7 +17,7 @@ use Doctrine\ORM\EntityRepository; class MaritalStatusRepository implements MaritalStatusRepositoryInterface { - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct(EntityManagerInterface $entityManager) { diff --git a/src/Bundle/ChillPersonBundle/Repository/Person/PersonCenterHistoryRepository.php b/src/Bundle/ChillPersonBundle/Repository/Person/PersonCenterHistoryRepository.php index a29c4f93a..b6d80a721 100644 --- a/src/Bundle/ChillPersonBundle/Repository/Person/PersonCenterHistoryRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/Person/PersonCenterHistoryRepository.php @@ -17,7 +17,7 @@ use Doctrine\ORM\EntityRepository; class PersonCenterHistoryRepository implements PersonCenterHistoryInterface { - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct(EntityManagerInterface $em) { diff --git a/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepository.php b/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepository.php index dd82b6b96..cd68796f0 100644 --- a/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepository.php @@ -32,7 +32,7 @@ use function count; use function explode; use function implode; -final class PersonACLAwareRepository implements PersonACLAwareRepositoryInterface +final readonly class PersonACLAwareRepository implements PersonACLAwareRepositoryInterface { public function __construct(private Security $security, private EntityManagerInterface $em, private CountryRepository $countryRepository, private AuthorizationHelperInterface $authorizationHelper) { diff --git a/src/Bundle/ChillPersonBundle/Repository/PersonAltNameRepository.php b/src/Bundle/ChillPersonBundle/Repository/PersonAltNameRepository.php index 41a9efe63..4a1ee1dd6 100644 --- a/src/Bundle/ChillPersonBundle/Repository/PersonAltNameRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/PersonAltNameRepository.php @@ -17,7 +17,7 @@ use Doctrine\ORM\EntityRepository; final class PersonAltNameRepository { - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct(EntityManagerInterface $entityManager) { diff --git a/src/Bundle/ChillPersonBundle/Repository/PersonNotDuplicateRepository.php b/src/Bundle/ChillPersonBundle/Repository/PersonNotDuplicateRepository.php index 146357715..6694f0e32 100644 --- a/src/Bundle/ChillPersonBundle/Repository/PersonNotDuplicateRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/PersonNotDuplicateRepository.php @@ -18,7 +18,7 @@ use Doctrine\ORM\EntityRepository; final class PersonNotDuplicateRepository { - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct(EntityManagerInterface $entityManager) { diff --git a/src/Bundle/ChillPersonBundle/Repository/PersonRepository.php b/src/Bundle/ChillPersonBundle/Repository/PersonRepository.php index a38df8787..39b4dc306 100644 --- a/src/Bundle/ChillPersonBundle/Repository/PersonRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/PersonRepository.php @@ -24,7 +24,7 @@ use function str_replace; final class PersonRepository implements ObjectRepository { - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct(EntityManagerInterface $entityManager) { diff --git a/src/Bundle/ChillPersonBundle/Repository/PersonResourceRepository.php b/src/Bundle/ChillPersonBundle/Repository/PersonResourceRepository.php index 75f205cbc..9280ade69 100644 --- a/src/Bundle/ChillPersonBundle/Repository/PersonResourceRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/PersonResourceRepository.php @@ -18,7 +18,7 @@ use Doctrine\Persistence\ObjectRepository; final class PersonResourceRepository implements ObjectRepository { - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct(EntityManagerInterface $entityManager) { diff --git a/src/Bundle/ChillPersonBundle/Repository/Relationships/RelationRepository.php b/src/Bundle/ChillPersonBundle/Repository/Relationships/RelationRepository.php index 111f122a7..d3fe813dc 100644 --- a/src/Bundle/ChillPersonBundle/Repository/Relationships/RelationRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/Relationships/RelationRepository.php @@ -18,7 +18,7 @@ use Doctrine\Persistence\ObjectRepository; class RelationRepository implements ObjectRepository { - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct(EntityManagerInterface $entityManager) { diff --git a/src/Bundle/ChillPersonBundle/Repository/Relationships/RelationshipRepository.php b/src/Bundle/ChillPersonBundle/Repository/Relationships/RelationshipRepository.php index 442ce1c55..932b872c5 100644 --- a/src/Bundle/ChillPersonBundle/Repository/Relationships/RelationshipRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/Relationships/RelationshipRepository.php @@ -20,9 +20,9 @@ use Doctrine\Persistence\ObjectRepository; class RelationshipRepository implements ObjectRepository { - private EntityManagerInterface $em; + private readonly EntityManagerInterface $em; - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct(EntityManagerInterface $em) { diff --git a/src/Bundle/ChillPersonBundle/Repository/SocialWork/EvaluationRepository.php b/src/Bundle/ChillPersonBundle/Repository/SocialWork/EvaluationRepository.php index e8de5a278..a7b739f7d 100644 --- a/src/Bundle/ChillPersonBundle/Repository/SocialWork/EvaluationRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/SocialWork/EvaluationRepository.php @@ -17,7 +17,7 @@ use Doctrine\ORM\EntityRepository; final class EvaluationRepository implements EvaluationRepositoryInterface { - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct(EntityManagerInterface $entityManager) { diff --git a/src/Bundle/ChillPersonBundle/Repository/SocialWork/GoalRepository.php b/src/Bundle/ChillPersonBundle/Repository/SocialWork/GoalRepository.php index c667eafbf..a798c8388 100644 --- a/src/Bundle/ChillPersonBundle/Repository/SocialWork/GoalRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/SocialWork/GoalRepository.php @@ -21,7 +21,7 @@ use Doctrine\Persistence\ObjectRepository; final class GoalRepository implements ObjectRepository { - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct(EntityManagerInterface $entityManager) { diff --git a/src/Bundle/ChillPersonBundle/Repository/SocialWork/ResultRepository.php b/src/Bundle/ChillPersonBundle/Repository/SocialWork/ResultRepository.php index 747611500..407626afe 100644 --- a/src/Bundle/ChillPersonBundle/Repository/SocialWork/ResultRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/SocialWork/ResultRepository.php @@ -21,7 +21,7 @@ use Doctrine\Persistence\ObjectRepository; final class ResultRepository implements ObjectRepository { - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct(EntityManagerInterface $entityManager) { diff --git a/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialActionRepository.php b/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialActionRepository.php index 62ca3d853..b4df922a1 100644 --- a/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialActionRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialActionRepository.php @@ -20,7 +20,7 @@ use Doctrine\Persistence\ObjectRepository; final class SocialActionRepository implements ObjectRepository { - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct(EntityManagerInterface $entityManager) { diff --git a/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialIssueRepository.php b/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialIssueRepository.php index 63dfcc510..f645a4ac4 100644 --- a/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialIssueRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialIssueRepository.php @@ -20,7 +20,7 @@ use Doctrine\Persistence\ObjectRepository; final class SocialIssueRepository implements ObjectRepository { - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct(EntityManagerInterface $entityManager) { diff --git a/src/Bundle/ChillPersonBundle/Search/PersonSearch.php b/src/Bundle/ChillPersonBundle/Search/PersonSearch.php index 05b55dd23..205023f19 100644 --- a/src/Bundle/ChillPersonBundle/Search/PersonSearch.php +++ b/src/Bundle/ChillPersonBundle/Search/PersonSearch.php @@ -38,14 +38,14 @@ use function array_merge; class PersonSearch extends AbstractSearch implements HasAdvancedSearchFormInterface { - public const NAME = 'person_regular'; + final public const NAME = 'person_regular'; private const POSSIBLE_KEYS = [ '_default', 'firstname', 'lastname', 'birthdate', 'birthdate-before', 'birthdate-after', 'gender', 'nationality', 'phonenumber', 'city', ]; - public function __construct(private EngineInterface $templating, private ExtractDateFromPattern $extractDateFromPattern, private ExtractPhonenumberFromPattern $extractPhonenumberFromPattern, private PaginatorFactory $paginatorFactory, private PersonACLAwareRepositoryInterface $personACLAwareRepository) + public function __construct(private readonly EngineInterface $templating, private readonly ExtractDateFromPattern $extractDateFromPattern, private readonly ExtractPhonenumberFromPattern $extractPhonenumberFromPattern, private readonly PaginatorFactory $paginatorFactory, private readonly PersonACLAwareRepositoryInterface $personACLAwareRepository) { } @@ -101,7 +101,7 @@ class PersonSearch extends AbstractSearch implements HasAdvancedSearchFormInterf foreach (['firstname', 'lastname', 'gender', 'city'] as $key) { $string .= !isset($data[$key]) ? '' : $key . ':' . // add quote if contains spaces - (str_contains($data[$key], ' ') ? '"' . $data[$key] . '"' : $data[$key]) + (str_contains((string) $data[$key], ' ') ? '"' . $data[$key] . '"' : $data[$key]) . ' '; } diff --git a/src/Bundle/ChillPersonBundle/Search/SearchHouseholdApiProvider.php b/src/Bundle/ChillPersonBundle/Search/SearchHouseholdApiProvider.php index 5dcb3e7b3..fd8bc9557 100644 --- a/src/Bundle/ChillPersonBundle/Search/SearchHouseholdApiProvider.php +++ b/src/Bundle/ChillPersonBundle/Search/SearchHouseholdApiProvider.php @@ -26,7 +26,7 @@ use function in_array; class SearchHouseholdApiProvider implements SearchApiInterface { - public function __construct(private HouseholdRepository $householdRepository, private PersonACLAwareRepositoryInterface $personACLAwareRepository, private Security $security, private AuthorizationHelperInterface $authorizationHelper, private ExtractDateFromPattern $extractDateFromPattern, private ExtractPhonenumberFromPattern $extractPhonenumberFromPattern) + public function __construct(private readonly HouseholdRepository $householdRepository, private readonly PersonACLAwareRepositoryInterface $personACLAwareRepository, private readonly Security $security, private readonly AuthorizationHelperInterface $authorizationHelper, private readonly ExtractDateFromPattern $extractDateFromPattern, private readonly ExtractPhonenumberFromPattern $extractPhonenumberFromPattern) { } diff --git a/src/Bundle/ChillPersonBundle/Search/SearchPersonApiProvider.php b/src/Bundle/ChillPersonBundle/Search/SearchPersonApiProvider.php index 9e2e9d6f5..5ad51f842 100644 --- a/src/Bundle/ChillPersonBundle/Search/SearchPersonApiProvider.php +++ b/src/Bundle/ChillPersonBundle/Search/SearchPersonApiProvider.php @@ -26,7 +26,7 @@ use function in_array; class SearchPersonApiProvider implements SearchApiInterface { - public function __construct(private PersonRepository $personRepository, private PersonACLAwareRepositoryInterface $personACLAwareRepository, private Security $security, private AuthorizationHelperInterface $authorizationHelper, private ExtractDateFromPattern $extractDateFromPattern, private ExtractPhonenumberFromPattern $extractPhonenumberFromPattern) + public function __construct(private readonly PersonRepository $personRepository, private readonly PersonACLAwareRepositoryInterface $personACLAwareRepository, private readonly Security $security, private readonly AuthorizationHelperInterface $authorizationHelper, private readonly ExtractDateFromPattern $extractDateFromPattern, private readonly ExtractPhonenumberFromPattern $extractPhonenumberFromPattern) { } diff --git a/src/Bundle/ChillPersonBundle/Search/SimilarPersonMatcher.php b/src/Bundle/ChillPersonBundle/Search/SimilarPersonMatcher.php index 4da00c5fa..03b46957c 100644 --- a/src/Bundle/ChillPersonBundle/Search/SimilarPersonMatcher.php +++ b/src/Bundle/ChillPersonBundle/Search/SimilarPersonMatcher.php @@ -23,9 +23,9 @@ use function count; class SimilarPersonMatcher { - public const SIMILAR_SEARCH_ORDER_BY_ALPHABETICAL = 'alphabetical'; + final public const SIMILAR_SEARCH_ORDER_BY_ALPHABETICAL = 'alphabetical'; - public const SIMILAR_SEARCH_ORDER_BY_SIMILARITY = 'similarity'; + final public const SIMILAR_SEARCH_ORDER_BY_SIMILARITY = 'similarity'; /** * @var AuthorizationHelper diff --git a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodCommentVoter.php b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodCommentVoter.php index e8a06a8b3..613a3a514 100644 --- a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodCommentVoter.php +++ b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodCommentVoter.php @@ -19,11 +19,11 @@ use UnexpectedValueException; class AccompanyingPeriodCommentVoter extends Voter { - public const DELETE = 'CHILL_PERSON_ACCOMPANYING_PERIOD_COMMENT_DELETE'; + final public const DELETE = 'CHILL_PERSON_ACCOMPANYING_PERIOD_COMMENT_DELETE'; - public const EDIT = 'CHILL_PERSON_ACCOMPANYING_PERIOD_COMMENT_EDIT'; + final public const EDIT = 'CHILL_PERSON_ACCOMPANYING_PERIOD_COMMENT_EDIT'; - public function __construct(private Security $security) + public function __construct(private readonly Security $security) { } diff --git a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodResourceVoter.php b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodResourceVoter.php index 432c142fe..38c3c8633 100644 --- a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodResourceVoter.php +++ b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodResourceVoter.php @@ -19,9 +19,9 @@ use UnexpectedValueException; class AccompanyingPeriodResourceVoter extends Voter { - public const EDIT = 'CHILL_PERSON_ACCOMPANYING_PERIOD_RESOURCE_EDIT'; + final public const EDIT = 'CHILL_PERSON_ACCOMPANYING_PERIOD_RESOURCE_EDIT'; - public function __construct(private AccessDecisionManagerInterface $accessDecisionManager) + public function __construct(private readonly AccessDecisionManagerInterface $accessDecisionManager) { } diff --git a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php index 817873738..c99ee0da4 100644 --- a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php +++ b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php @@ -29,7 +29,7 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH /** * all the roles that are linked to an accompanying period. */ - public const ALL = [ + final public const ALL = [ self::SEE, self::SEE_DETAILS, self::CREATE, @@ -44,28 +44,28 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH /** * Give the ability to see all confidential courses. */ - public const CONFIDENTIAL_CRUD = 'CHILL_PERSON_ACCOMPANYING_PERIOD_CRUD_CONFIDENTIAL'; + final public const CONFIDENTIAL_CRUD = 'CHILL_PERSON_ACCOMPANYING_PERIOD_CRUD_CONFIDENTIAL'; - public const CREATE = 'CHILL_PERSON_ACCOMPANYING_PERIOD_CREATE'; + final public const CREATE = 'CHILL_PERSON_ACCOMPANYING_PERIOD_CREATE'; /** * role to DELETE the course. * * Will be true only for the creator, and if the course is still at DRAFT step. */ - public const DELETE = 'CHILL_PERSON_ACCOMPANYING_PERIOD_DELETE'; + final public const DELETE = 'CHILL_PERSON_ACCOMPANYING_PERIOD_DELETE'; /** * role to EDIT the course. * * If the course is closed, it will be always false. */ - public const EDIT = 'CHILL_PERSON_ACCOMPANYING_PERIOD_UPDATE'; + final public const EDIT = 'CHILL_PERSON_ACCOMPANYING_PERIOD_UPDATE'; /** * Give all the right above. */ - public const FULL = 'CHILL_PERSON_ACCOMPANYING_PERIOD_FULL'; + final public const FULL = 'CHILL_PERSON_ACCOMPANYING_PERIOD_FULL'; /** * Reopen a closed course. @@ -73,43 +73,43 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH * This forward to the EDIT role, without taking into account that the course * is closed */ - public const RE_OPEN_COURSE = 'CHILL_PERSON_ACCOMPANYING_PERIOD_REOPEN'; + final public const RE_OPEN_COURSE = 'CHILL_PERSON_ACCOMPANYING_PERIOD_REOPEN'; /** * Allow user to bulk reassign the courses. */ - public const REASSIGN_BULK = 'CHILL_PERSON_ACCOMPANYING_COURSE_REASSIGN_BULK'; + final public const REASSIGN_BULK = 'CHILL_PERSON_ACCOMPANYING_COURSE_REASSIGN_BULK'; - public const SEE = 'CHILL_PERSON_ACCOMPANYING_PERIOD_SEE'; + final public const SEE = 'CHILL_PERSON_ACCOMPANYING_PERIOD_SEE'; /** * details are for seeing:. * * * SocialIssues */ - public const SEE_DETAILS = 'CHILL_PERSON_ACCOMPANYING_PERIOD_SEE_DETAILS'; + final public const SEE_DETAILS = 'CHILL_PERSON_ACCOMPANYING_PERIOD_SEE_DETAILS'; /** * Give the ability to see statistics. */ - public const STATS = 'CHILL_PERSON_ACCOMPANYING_PERIOD_STATS'; + final public const STATS = 'CHILL_PERSON_ACCOMPANYING_PERIOD_STATS'; /** * Right to toggle confidentiality. */ - public const TOGGLE_CONFIDENTIAL = 'CHILL_PERSON_ACCOMPANYING_PERIOD_TOGGLE_CONFIDENTIAL'; + final public const TOGGLE_CONFIDENTIAL = 'CHILL_PERSON_ACCOMPANYING_PERIOD_TOGGLE_CONFIDENTIAL'; - public const TOGGLE_CONFIDENTIAL_ALL = 'CHILL_PERSON_ACCOMPANYING_PERIOD_TOGGLE_CONFIDENTIAL_ALL'; + final public const TOGGLE_CONFIDENTIAL_ALL = 'CHILL_PERSON_ACCOMPANYING_PERIOD_TOGGLE_CONFIDENTIAL_ALL'; /** * Right to toggle urgency of parcours. */ - public const TOGGLE_INTENSITY = 'CHILL_PERSON_ACCOMPANYING_PERIOD_TOGGLE_INTENSITY'; + final public const TOGGLE_INTENSITY = 'CHILL_PERSON_ACCOMPANYING_PERIOD_TOGGLE_INTENSITY'; - private VoterHelperInterface $voterHelper; + private readonly VoterHelperInterface $voterHelper; public function __construct( - private Security $security, + private readonly Security $security, VoterHelperFactoryInterface $voterHelperFactory ) { $this->voterHelper = $voterHelperFactory diff --git a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodWorkEvaluationDocumentVoter.php b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodWorkEvaluationDocumentVoter.php index 8591a044f..dffe3a89c 100644 --- a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodWorkEvaluationDocumentVoter.php +++ b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodWorkEvaluationDocumentVoter.php @@ -24,9 +24,9 @@ use UnexpectedValueException; */ class AccompanyingPeriodWorkEvaluationDocumentVoter extends Voter { - public const SEE = 'CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_EVALUATION_DOCUMENT_SHOW'; + final public const SEE = 'CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_EVALUATION_DOCUMENT_SHOW'; - public function __construct(private AccessDecisionManagerInterface $accessDecisionManager) + public function __construct(private readonly AccessDecisionManagerInterface $accessDecisionManager) { } diff --git a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodWorkEvaluationVoter.php b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodWorkEvaluationVoter.php index 955d199ff..2588443cb 100644 --- a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodWorkEvaluationVoter.php +++ b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodWorkEvaluationVoter.php @@ -21,16 +21,16 @@ use function in_array; class AccompanyingPeriodWorkEvaluationVoter extends Voter implements ChillVoterInterface { - public const ALL = [ + final public const ALL = [ self::SEE, self::STATS, ]; - public const SEE = 'CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_EVALUATION_SHOW'; + final public const SEE = 'CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_EVALUATION_SHOW'; - public const STATS = 'CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_EVALUATION_STATS'; + final public const STATS = 'CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_EVALUATION_STATS'; - public function __construct(private Security $security) + public function __construct(private readonly Security $security) { } diff --git a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodWorkVoter.php b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodWorkVoter.php index 43a99e7e1..69f90fa12 100644 --- a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodWorkVoter.php +++ b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodWorkVoter.php @@ -27,25 +27,25 @@ use function in_array; class AccompanyingPeriodWorkVoter extends Voter implements ProvideRoleHierarchyInterface, ChillVoterInterface { - public const ALL = [ + final public const ALL = [ self::SEE, self::CREATE, self::UPDATE, self::DELETE, ]; - public const CREATE = 'CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_CREATE'; + final public const CREATE = 'CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_CREATE'; - public const DELETE = 'CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_DELETE'; + final public const DELETE = 'CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_DELETE'; - public const SEE = 'CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_SEE'; + final public const SEE = 'CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_SEE'; - public const UPDATE = 'CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_UPDATE'; + final public const UPDATE = 'CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_UPDATE'; - private VoterHelperInterface $voterHelper; + private readonly VoterHelperInterface $voterHelper; public function __construct( - private Security $security, + private readonly Security $security, VoterHelperFactoryInterface $voterHelperFactory ) { $this->voterHelper = $voterHelperFactory diff --git a/src/Bundle/ChillPersonBundle/Security/Authorization/HouseholdVoter.php b/src/Bundle/ChillPersonBundle/Security/Authorization/HouseholdVoter.php index 74eee07f6..7000730a7 100644 --- a/src/Bundle/ChillPersonBundle/Security/Authorization/HouseholdVoter.php +++ b/src/Bundle/ChillPersonBundle/Security/Authorization/HouseholdVoter.php @@ -26,16 +26,16 @@ use function in_array; class HouseholdVoter extends Voter implements ProvideRoleHierarchyInterface, ChillVoterInterface { - public const EDIT = 'CHILL_PERSON_HOUSEHOLD_EDIT'; + final public const EDIT = 'CHILL_PERSON_HOUSEHOLD_EDIT'; - public const SEE = 'CHILL_PERSON_HOUSEHOLD_SEE'; + final public const SEE = 'CHILL_PERSON_HOUSEHOLD_SEE'; /** * @deprecated use @see{self::SEE} instead */ - public const SHOW = self::SEE; + final public const SHOW = self::SEE; - public const STATS = 'CHILL_PERSON_HOUSEHOLD_STATS'; + final public const STATS = 'CHILL_PERSON_HOUSEHOLD_STATS'; private const ALL = [ self::SEE, @@ -43,9 +43,9 @@ class HouseholdVoter extends Voter implements ProvideRoleHierarchyInterface, Chi self::STATS, ]; - private VoterHelperInterface $helper; + private readonly VoterHelperInterface $helper; - public function __construct(private Security $security, VoterHelperFactoryInterface $voterHelperFactory) + public function __construct(private readonly Security $security, VoterHelperFactoryInterface $voterHelperFactory) { $this->helper = $voterHelperFactory ->generate(self::class) diff --git a/src/Bundle/ChillPersonBundle/Security/Authorization/PersonVoter.php b/src/Bundle/ChillPersonBundle/Security/Authorization/PersonVoter.php index 95f10458b..2de8a1554 100644 --- a/src/Bundle/ChillPersonBundle/Security/Authorization/PersonVoter.php +++ b/src/Bundle/ChillPersonBundle/Security/Authorization/PersonVoter.php @@ -21,17 +21,17 @@ use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; class PersonVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface { - public const CREATE = 'CHILL_PERSON_CREATE'; + final public const CREATE = 'CHILL_PERSON_CREATE'; - public const DUPLICATE = 'CHILL_PERSON_DUPLICATE'; + final public const DUPLICATE = 'CHILL_PERSON_DUPLICATE'; - public const LISTS = 'CHILL_PERSON_LISTS'; + final public const LISTS = 'CHILL_PERSON_LISTS'; - public const SEE = 'CHILL_PERSON_SEE'; + final public const SEE = 'CHILL_PERSON_SEE'; - public const STATS = 'CHILL_PERSON_STATS'; + final public const STATS = 'CHILL_PERSON_STATS'; - public const UPDATE = 'CHILL_PERSON_UPDATE'; + final public const UPDATE = 'CHILL_PERSON_UPDATE'; protected VoterHelperInterface $voter; diff --git a/src/Bundle/ChillPersonBundle/Security/AuthorizedCenterOnPersonCreation.php b/src/Bundle/ChillPersonBundle/Security/AuthorizedCenterOnPersonCreation.php index 8b649f8f0..ae5f5281b 100644 --- a/src/Bundle/ChillPersonBundle/Security/AuthorizedCenterOnPersonCreation.php +++ b/src/Bundle/ChillPersonBundle/Security/AuthorizedCenterOnPersonCreation.php @@ -17,9 +17,9 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; class AuthorizedCenterOnPersonCreation implements AuthorizedCenterOnPersonCreationInterface { - private bool $showCenters; + private readonly bool $showCenters; - public function __construct(private AuthorizationHelperForCurrentUserInterface $authorizationHelperForCurrentUser, ParameterBagInterface $parameterBag) + public function __construct(private readonly AuthorizationHelperForCurrentUserInterface $authorizationHelperForCurrentUser, ParameterBagInterface $parameterBag) { $this->showCenters = $parameterBag->get('chill_main')['acl']['form_show_centers']; } diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodDocGenNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodDocGenNormalizer.php index 0bb3d68b6..c4257e04d 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodDocGenNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodDocGenNormalizer.php @@ -74,7 +74,7 @@ class AccompanyingPeriodDocGenNormalizer implements ContextAwareNormalizerInterf 'pinnedComment' => AccompanyingPeriod\Comment::class, ]; - public function __construct(private TranslatorInterface $translator, private TranslatableStringHelper $translatableStringHelper, private SocialIssueRender $socialIssueRender, private ClosingMotiveRender $closingMotiveRender, private ScopeResolverDispatcher $scopeResolverDispatcher) + public function __construct(private readonly TranslatorInterface $translator, private readonly TranslatableStringHelper $translatableStringHelper, private readonly SocialIssueRender $socialIssueRender, private readonly ClosingMotiveRender $closingMotiveRender, private readonly ScopeResolverDispatcher $scopeResolverDispatcher) { } diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodResourceNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodResourceNormalizer.php index c2a723274..29912618f 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodResourceNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodResourceNormalizer.php @@ -32,7 +32,7 @@ class AccompanyingPeriodResourceNormalizer implements DenormalizerAwareInterface use ObjectToPopulateTrait; - public function __construct(private ResourceRepository $repository) + public function __construct(private readonly ResourceRepository $repository) { } diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkDenormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkDenormalizer.php index e0697a6fd..1dfed604f 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkDenormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkDenormalizer.php @@ -36,11 +36,11 @@ class AccompanyingPeriodWorkDenormalizer implements ContextAwareDenormalizerInte use ObjectToPopulateTrait; - public const GROUP_CREATE = 'accompanying_period_work:create'; + final public const GROUP_CREATE = 'accompanying_period_work:create'; - public const GROUP_EDIT = 'accompanying_period_work:edit'; + final public const GROUP_EDIT = 'accompanying_period_work:edit'; - public function __construct(private AccompanyingPeriodWorkRepository $workRepository, private EntityManagerInterface $em) + public function __construct(private readonly AccompanyingPeriodWorkRepository $workRepository, private readonly EntityManagerInterface $em) { } diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationDocumentNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationDocumentNormalizer.php index 7850cc1c8..768e8e45f 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationDocumentNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationDocumentNormalizer.php @@ -26,7 +26,7 @@ class AccompanyingPeriodWorkEvaluationDocumentNormalizer implements ContextAware private const SKIP = 'accompanying_period_work_evaluation_document_skip'; - public function __construct(private EntityWorkflowRepository $entityWorkflowRepository, private MetadataExtractor $metadataExtractor, private Registry $registry) + public function __construct(private readonly EntityWorkflowRepository $entityWorkflowRepository, private readonly MetadataExtractor $metadataExtractor, private readonly Registry $registry) { } diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationNormalizer.php index 512dc6370..1c1076620 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationNormalizer.php @@ -27,7 +27,7 @@ class AccompanyingPeriodWorkEvaluationNormalizer implements ContextAwareNormaliz private const IGNORE_EVALUATION = 'evaluation:ignore'; - public function __construct(private Registry $registry, private EntityWorkflowRepository $entityWorkflowRepository, private MetadataExtractor $metadataExtractor) + public function __construct(private readonly Registry $registry, private readonly EntityWorkflowRepository $entityWorkflowRepository, private readonly MetadataExtractor $metadataExtractor) { } diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkNormalizer.php index 12652ce2a..8dc4fc726 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkNormalizer.php @@ -30,7 +30,7 @@ class AccompanyingPeriodWorkNormalizer implements ContextAwareNormalizerInterfac private const IGNORE_WORK = 'ignore:work'; - public function __construct(private Registry $registry, private EntityWorkflowRepository $entityWorkflowRepository, private MetadataExtractor $metadataExtractor) + public function __construct(private readonly Registry $registry, private readonly EntityWorkflowRepository $entityWorkflowRepository, private readonly MetadataExtractor $metadataExtractor) { } diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/MembersEditorNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/MembersEditorNormalizer.php index 6185c018d..ad5ef161a 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/MembersEditorNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/MembersEditorNormalizer.php @@ -31,7 +31,7 @@ class MembersEditorNormalizer implements DenormalizerAwareInterface, Denormalize { use DenormalizerAwareTrait; - public function __construct(private MembersEditorFactory $factory) + public function __construct(private readonly MembersEditorFactory $factory) { } diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonDocGenNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonDocGenNormalizer.php index 390d938d9..121c7fedf 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonDocGenNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonDocGenNormalizer.php @@ -47,7 +47,7 @@ class PersonDocGenNormalizer implements private const CIRCULAR_KEY = 'person:circular'; - public function __construct(private PersonRenderInterface $personRender, private RelationshipRepository $relationshipRepository, private TranslatorInterface $translator, private TranslatableStringHelper $translatableStringHelper, private SummaryBudgetInterface $summaryBudget) + public function __construct(private readonly PersonRenderInterface $personRender, private readonly RelationshipRepository $relationshipRepository, private readonly TranslatorInterface $translator, private readonly TranslatableStringHelper $translatableStringHelper, private readonly SummaryBudgetInterface $summaryBudget) { } diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php index 57f666f05..1420a5bf9 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php @@ -48,12 +48,12 @@ class PersonJsonNormalizer implements DenormalizerAwareInterface, NormalizerAwar use ObjectToPopulateTrait; public function __construct( - private ChillEntityRenderExtension $render, + private readonly ChillEntityRenderExtension $render, /* TODO: replace by PersonRenderInterface, as sthis is the only one required */ - private PersonRepository $repository, - private CenterResolverManagerInterface $centerResolverManager, - private ResidentialAddressRepository $residentialAddressRepository, - private PhoneNumberHelperInterface $phoneNumberHelper + private readonly PersonRepository $repository, + private readonly CenterResolverManagerInterface $centerResolverManager, + private readonly ResidentialAddressRepository $residentialAddressRepository, + private readonly PhoneNumberHelperInterface $phoneNumberHelper ) { } @@ -214,14 +214,9 @@ class PersonJsonNormalizer implements DenormalizerAwareInterface, NormalizerAwar return $data; } - return array_merge($data, [ - 'centers' => $this->normalizer->normalize($this->centerResolverManager->resolveCenters($person), $format, $context), - 'altNames' => $this->normalizeAltNames($person->getAltNames()), - 'current_household_id' => $household ? $this->normalizer->normalize($household->getId(), $format, $context) : null, - 'current_residential_addresses' => $currentResidentialAddresses ? - $this->normalizer->normalize($currentResidentialAddresses, $format, $context) : - null, - ]); + return [...$data, 'centers' => $this->normalizer->normalize($this->centerResolverManager->resolveCenters($person), $format, $context), 'altNames' => $this->normalizeAltNames($person->getAltNames()), 'current_household_id' => $household ? $this->normalizer->normalize($household->getId(), $format, $context) : null, 'current_residential_addresses' => $currentResidentialAddresses ? + $this->normalizer->normalize($currentResidentialAddresses, $format, $context) : + null]; } public function supportsDenormalization($data, $type, $format = null) diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/RelationshipDocGenNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/RelationshipDocGenNormalizer.php index 42bccba06..23ee8aeb0 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/RelationshipDocGenNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/RelationshipDocGenNormalizer.php @@ -22,7 +22,7 @@ class RelationshipDocGenNormalizer implements ContextAwareNormalizerInterface, N { use NormalizerAwareTrait; - public function __construct(private TranslatableStringHelperInterface $translatableStringHelper) + public function __construct(private readonly TranslatableStringHelperInterface $translatableStringHelper) { } diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialActionNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialActionNormalizer.php index 494c82735..12c36b286 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialActionNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialActionNormalizer.php @@ -21,7 +21,7 @@ class SocialActionNormalizer implements NormalizerAwareInterface, NormalizerInte { use NormalizerAwareTrait; - public function __construct(private SocialActionRender $render) + public function __construct(private readonly SocialActionRender $render) { } diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialIssueNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialIssueNormalizer.php index 7c8c8b226..1882ef7d6 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialIssueNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialIssueNormalizer.php @@ -21,7 +21,7 @@ class SocialIssueNormalizer implements ContextAwareNormalizerInterface, Normaliz { use NormalizerAwareTrait; - public function __construct(private SocialIssueRender $render) + public function __construct(private readonly SocialIssueRender $render) { } diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/WorkflowNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/WorkflowNormalizer.php index b5cbeda07..bce0e3423 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/WorkflowNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/WorkflowNormalizer.php @@ -27,7 +27,7 @@ class WorkflowNormalizer implements ContextAwareNormalizerInterface, NormalizerA private const IGNORE_ENTITY_WORKFLOW = 'ignore:entity_workflow'; - public function __construct(private Registry $registry, private MetadataExtractor $metadataExtractor) + public function __construct(private readonly Registry $registry, private readonly MetadataExtractor $metadataExtractor) { } diff --git a/src/Bundle/ChillPersonBundle/Service/AccompanyingPeriod/OldDraftAccompanyingPeriodRemover.php b/src/Bundle/ChillPersonBundle/Service/AccompanyingPeriod/OldDraftAccompanyingPeriodRemover.php index 745568ed7..cfc765548 100644 --- a/src/Bundle/ChillPersonBundle/Service/AccompanyingPeriod/OldDraftAccompanyingPeriodRemover.php +++ b/src/Bundle/ChillPersonBundle/Service/AccompanyingPeriod/OldDraftAccompanyingPeriodRemover.php @@ -22,7 +22,7 @@ use Psr\Log\LoggerInterface; class OldDraftAccompanyingPeriodRemover implements OldDraftAccompanyingPeriodRemoverInterface { - public function __construct(private EntityManagerInterface $em, private LoggerInterface $logger) + public function __construct(private readonly EntityManagerInterface $em, private readonly LoggerInterface $logger) { } diff --git a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php index f4c161a98..eff9c2636 100644 --- a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php +++ b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php @@ -46,7 +46,7 @@ class AccompanyingPeriodContext implements DocGeneratorContextWithAdminFormInterface, DocGeneratorContextWithPublicFormInterface { - public function __construct(private DocumentCategoryRepository $documentCategoryRepository, private NormalizerInterface $normalizer, private TranslatableStringHelperInterface $translatableStringHelper, private EntityManagerInterface $em, private PersonRenderInterface $personRender, private PersonRepository $personRepository, private TranslatorInterface $translator, private BaseContextData $baseContextData) + public function __construct(private readonly DocumentCategoryRepository $documentCategoryRepository, private readonly NormalizerInterface $normalizer, private readonly TranslatableStringHelperInterface $translatableStringHelper, private readonly EntityManagerInterface $em, private readonly PersonRenderInterface $personRender, private readonly PersonRepository $personRepository, private readonly TranslatorInterface $translator, private readonly BaseContextData $baseContextData) { } diff --git a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkContext.php b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkContext.php index 0bc61d19f..e8a81012e 100644 --- a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkContext.php +++ b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkContext.php @@ -29,7 +29,7 @@ use Symfony\Component\Serializer\Normalizer\NormalizerInterface; */ class AccompanyingPeriodWorkContext implements DocGeneratorContextWithPublicFormInterface { - public function __construct(private AccompanyingPeriodContext $periodContext, private NormalizerInterface $normalizer) + public function __construct(private readonly AccompanyingPeriodContext $periodContext, private readonly NormalizerInterface $normalizer) { } diff --git a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php index 209251cd0..5a06acdbf 100644 --- a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php +++ b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php @@ -33,7 +33,7 @@ class AccompanyingPeriodWorkEvaluationContext implements DocGeneratorContextWithAdminFormInterface, DocGeneratorContextWithPublicFormInterface { - public function __construct(private AccompanyingPeriodWorkContext $accompanyingPeriodWorkContext, private EntityManagerInterface $em, private EvaluationRepository $evaluationRepository, private NormalizerInterface $normalizer, private TranslatableStringHelperInterface $translatableStringHelper) + public function __construct(private readonly AccompanyingPeriodWorkContext $accompanyingPeriodWorkContext, private readonly EntityManagerInterface $em, private readonly EvaluationRepository $evaluationRepository, private readonly NormalizerInterface $normalizer, private readonly TranslatableStringHelperInterface $translatableStringHelper) { } diff --git a/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php b/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php index ecbbe28db..b894f7e55 100644 --- a/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php +++ b/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php @@ -45,20 +45,20 @@ use function count; final class PersonContext implements PersonContextInterface { - private bool $showScopes; + private readonly bool $showScopes; public function __construct( - private AuthorizationHelperInterface $authorizationHelper, - private BaseContextData $baseContextData, - private CenterResolverManagerInterface $centerResolverManager, - private DocumentCategoryRepository $documentCategoryRepository, - private EntityManagerInterface $em, - private NormalizerInterface $normalizer, + private readonly AuthorizationHelperInterface $authorizationHelper, + private readonly BaseContextData $baseContextData, + private readonly CenterResolverManagerInterface $centerResolverManager, + private readonly DocumentCategoryRepository $documentCategoryRepository, + private readonly EntityManagerInterface $em, + private readonly NormalizerInterface $normalizer, ParameterBagInterface $parameterBag, - private ScopeRepositoryInterface $scopeRepository, - private Security $security, - private TranslatorInterface $translator, - private TranslatableStringHelperInterface $translatableStringHelper + private readonly ScopeRepositoryInterface $scopeRepository, + private readonly Security $security, + private readonly TranslatorInterface $translator, + private readonly TranslatableStringHelperInterface $translatableStringHelper ) { $this->showScopes = $parameterBag->get('chill_main')['acl']['form_show_scopes']; } diff --git a/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContextWithThirdParty.php b/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContextWithThirdParty.php index c8e15be12..662984011 100644 --- a/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContextWithThirdParty.php +++ b/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContextWithThirdParty.php @@ -27,7 +27,7 @@ use Symfony\Component\Serializer\Normalizer\NormalizerInterface; */ class PersonContextWithThirdParty implements DocGeneratorContextWithAdminFormInterface, DocGeneratorContextWithPublicFormInterface { - public function __construct(private PersonContextInterface $personContext, private NormalizerInterface $normalizer, private ThirdPartyRepository $thirdPartyRepository) + public function __construct(private readonly PersonContextInterface $personContext, private readonly NormalizerInterface $normalizer, private readonly ThirdPartyRepository $thirdPartyRepository) { } diff --git a/src/Bundle/ChillPersonBundle/Service/Import/SocialWorkMetadata.php b/src/Bundle/ChillPersonBundle/Service/Import/SocialWorkMetadata.php index 017c90b73..80197f769 100644 --- a/src/Bundle/ChillPersonBundle/Service/Import/SocialWorkMetadata.php +++ b/src/Bundle/ChillPersonBundle/Service/Import/SocialWorkMetadata.php @@ -28,7 +28,7 @@ use Exception; use function count; -final class SocialWorkMetadata implements SocialWorkMetadataInterface +final readonly class SocialWorkMetadata implements SocialWorkMetadataInterface { public function __construct(private SocialIssueRepository $socialIssueRepository, private SocialActionRepository $socialActionRepository, private GoalRepository $goalRepository, private ResultRepository $resultRepository, private EvaluationRepository $evaluationRepository, private EntityManagerInterface $entityManager) { diff --git a/src/Bundle/ChillPersonBundle/Templating/Entity/ClosingMotiveRender.php b/src/Bundle/ChillPersonBundle/Templating/Entity/ClosingMotiveRender.php index 8ebc89c04..67171aaba 100644 --- a/src/Bundle/ChillPersonBundle/Templating/Entity/ClosingMotiveRender.php +++ b/src/Bundle/ChillPersonBundle/Templating/Entity/ClosingMotiveRender.php @@ -27,7 +27,7 @@ class ClosingMotiveRender implements ChillEntityRenderInterface use BoxUtilsChillEntityRenderTrait; private const SEPARATOR = ' > '; - public function __construct(private TranslatableStringHelper $translatableStringHelper) + public function __construct(private readonly TranslatableStringHelper $translatableStringHelper) { } diff --git a/src/Bundle/ChillPersonBundle/Templating/Entity/PersonRender.php b/src/Bundle/ChillPersonBundle/Templating/Entity/PersonRender.php index 8d50f03ac..c41a94779 100644 --- a/src/Bundle/ChillPersonBundle/Templating/Entity/PersonRender.php +++ b/src/Bundle/ChillPersonBundle/Templating/Entity/PersonRender.php @@ -28,7 +28,7 @@ class PersonRender implements PersonRenderInterface { use BoxUtilsChillEntityRenderTrait; - public function __construct(private ConfigPersonAltNamesHelper $configAltNamesHelper, private EngineInterface $engine, private TranslatorInterface $translator) + public function __construct(private readonly ConfigPersonAltNamesHelper $configAltNamesHelper, private readonly EngineInterface $engine, private readonly TranslatorInterface $translator) { } diff --git a/src/Bundle/ChillPersonBundle/Templating/Entity/ResourceKindRender.php b/src/Bundle/ChillPersonBundle/Templating/Entity/ResourceKindRender.php index 925c174cc..802ff6d8e 100644 --- a/src/Bundle/ChillPersonBundle/Templating/Entity/ResourceKindRender.php +++ b/src/Bundle/ChillPersonBundle/Templating/Entity/ResourceKindRender.php @@ -18,7 +18,7 @@ use Chill\PersonBundle\Entity\Person\PersonResourceKind; /** * @implements ChillEntityRenderInterface */ -final class ResourceKindRender implements ChillEntityRenderInterface +final readonly class ResourceKindRender implements ChillEntityRenderInterface { public function __construct(private TranslatableStringHelper $translatableStringHelper) { diff --git a/src/Bundle/ChillPersonBundle/Templating/Entity/SocialActionRender.php b/src/Bundle/ChillPersonBundle/Templating/Entity/SocialActionRender.php index 2d8b1ea92..e4253f52e 100644 --- a/src/Bundle/ChillPersonBundle/Templating/Entity/SocialActionRender.php +++ b/src/Bundle/ChillPersonBundle/Templating/Entity/SocialActionRender.php @@ -25,9 +25,9 @@ use function implode; */ class SocialActionRender implements ChillEntityRenderInterface { - public const AND_CHILDREN_MENTION = 'show_and_children_mention'; + final public const AND_CHILDREN_MENTION = 'show_and_children_mention'; - public const DEFAULT_ARGS = [ + final public const DEFAULT_ARGS = [ self::SEPARATOR_KEY => ' > ', self::NO_BADGE => false, self::SHOW_AND_CHILDREN => false, @@ -37,17 +37,17 @@ class SocialActionRender implements ChillEntityRenderInterface /** * if true, the action will not be encapsulated into a "badge". */ - public const NO_BADGE = 'no-badge'; + final public const NO_BADGE = 'no-badge'; - public const SEPARATOR_KEY = 'default.separator'; + final public const SEPARATOR_KEY = 'default.separator'; /** * Show a mention "and children" on each SocialAction, if the social action * has at least one child. */ - public const SHOW_AND_CHILDREN = 'show_and_children'; + final public const SHOW_AND_CHILDREN = 'show_and_children'; - public function __construct(private TranslatableStringHelper $translatableStringHelper, private EngineInterface $engine, private TranslatorInterface $translator) + public function __construct(private readonly TranslatableStringHelper $translatableStringHelper, private readonly EngineInterface $engine, private readonly TranslatorInterface $translator) { } diff --git a/src/Bundle/ChillPersonBundle/Templating/Entity/SocialIssueRender.php b/src/Bundle/ChillPersonBundle/Templating/Entity/SocialIssueRender.php index 381f80ef9..f815afc43 100644 --- a/src/Bundle/ChillPersonBundle/Templating/Entity/SocialIssueRender.php +++ b/src/Bundle/ChillPersonBundle/Templating/Entity/SocialIssueRender.php @@ -22,7 +22,7 @@ use function implode; /** * @implements ChillEntityRenderInterface */ -final class SocialIssueRender implements ChillEntityRenderInterface +final readonly class SocialIssueRender implements ChillEntityRenderInterface { public const AND_CHILDREN_MENTION = 'show_and_children_mention'; diff --git a/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/AccompanyingPeriodConfidentialTest.php b/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/AccompanyingPeriodConfidentialTest.php index dc5c5c2ce..93f773113 100644 --- a/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/AccompanyingPeriodConfidentialTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/AccompanyingPeriodConfidentialTest.php @@ -86,7 +86,7 @@ final class AccompanyingPeriodConfidentialTest extends WebTestCase } } - public function testConfidentialValid() + public function testConfidentialValid(): never { $this->markTestIncomplete( 'Marked as incomplete because of a problem in the dataprovider, at line 81.' diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseApiControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseApiControllerTest.php index 560928bff..60d29d8b0 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseApiControllerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseApiControllerTest.php @@ -316,7 +316,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase json_encode(['type' => 'person', 'id' => $personId], JSON_THROW_ON_ERROR) ); $response = $this->client->getResponse(); - $data = json_decode($response->getContent(), true, 512, JSON_THROW_ON_ERROR); + $data = json_decode((string) $response->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertTrue(in_array($response->getStatusCode(), [200, 422], true)); @@ -338,7 +338,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase } $response = $this->client->getResponse(); - $data = json_decode($response->getContent(), null, 512, JSON_THROW_ON_ERROR); + $data = json_decode((string) $response->getContent(), null, 512, JSON_THROW_ON_ERROR); // check that the person id is contained $participationsPersonsIds = array_map( @@ -358,7 +358,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase json_encode(['type' => 'person', 'id' => $personId], JSON_THROW_ON_ERROR) ); $response = $this->client->getResponse(); - $data = json_decode($response->getContent(), true, 512, JSON_THROW_ON_ERROR); + $data = json_decode((string) $response->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertTrue(in_array($response->getStatusCode(), [200, 422], true)); @@ -394,7 +394,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase $this->markTestSkipped('the next tests should appears only on valid accompanying period'); } - $data = json_decode($this->client->getResponse()->getContent(), true, 512, JSON_THROW_ON_ERROR); + $data = json_decode((string) $this->client->getResponse()->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertArrayHasKey('id', $data); $this->assertArrayHasKey('type', $data); $this->assertEquals('social_issue', $data['type']); @@ -425,7 +425,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase $this->markTestSkipped('the next tests should appears only on valid accompanying period'); } - $data = json_decode($response->getContent(), null, 512, JSON_THROW_ON_ERROR); + $data = json_decode((string) $response->getContent(), null, 512, JSON_THROW_ON_ERROR); $this->assertEquals( $data->id, $periodId, @@ -487,7 +487,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase json_encode(['type' => 'accompanying_period_comment', 'content' => 'this is a text']) ); $response = $this->client->getResponse(); - $data = json_decode($response->getContent(), true, 512, JSON_THROW_ON_ERROR); + $data = json_decode((string) $response->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertTrue(in_array($response->getStatusCode(), [200, 422], true)); @@ -506,7 +506,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase json_encode(['type' => 'accompanying_period_comment', 'id' => $data['id']], JSON_THROW_ON_ERROR) ); $response = $this->client->getResponse(); - $data = json_decode($response->getContent(), true, 512, JSON_THROW_ON_ERROR); + $data = json_decode((string) $response->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertTrue(in_array($response->getStatusCode(), [200, 422], true)); } @@ -563,7 +563,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase json_encode(['type' => 'person', 'id' => $personId], JSON_THROW_ON_ERROR) ); $response = $this->client->getResponse(); - $data = json_decode($response->getContent(), true, 512, JSON_THROW_ON_ERROR); + $data = json_decode((string) $response->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertTrue(in_array($response->getStatusCode(), [200, 422], true)); @@ -590,7 +590,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase json_encode(['type' => 'thirdparty', 'id' => $thirdPartyId], JSON_THROW_ON_ERROR) ); $response = $this->client->getResponse(); - $data = json_decode($response->getContent(), true, 512, JSON_THROW_ON_ERROR); + $data = json_decode((string) $response->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertTrue(in_array($response->getStatusCode(), [200, 422], true)); @@ -644,7 +644,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase json_encode(['type' => 'accompanying_period_resource', 'resource' => ['type' => 'person', 'id' => $personId]]) ); $response = $this->client->getResponse(); - $data = json_decode($response->getContent(), true, 512, JSON_THROW_ON_ERROR); + $data = json_decode((string) $response->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertTrue(in_array($response->getStatusCode(), [200, 422], true)); @@ -688,7 +688,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase json_encode(['type' => 'accompanying_period_resource', 'resource' => ['type' => 'thirdparty', 'id' => $thirdPartyId]]) ); $response = $this->client->getResponse(); - $data = json_decode($response->getContent(), true, 512, JSON_THROW_ON_ERROR); + $data = json_decode((string) $response->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertTrue(in_array($response->getStatusCode(), [200, 422], true)); diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseControllerTest.php index a7d98bd97..a4b11fdb6 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseControllerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseControllerTest.php @@ -70,7 +70,7 @@ final class AccompanyingCourseControllerTest extends WebTestCase $this->assertResponseRedirects(); $location = $this->client->getResponse()->headers->get('Location'); - $this->assertEquals(1, preg_match('|^\\/[^\\/]+\\/parcours/([\\d]+)/edit$|', $location)); + $this->assertEquals(1, preg_match('|^\\/[^\\/]+\\/parcours/([\\d]+)/edit$|', (string) $location)); } /** @@ -89,7 +89,7 @@ final class AccompanyingCourseControllerTest extends WebTestCase $location = $this->client->getResponse()->headers->get('Location'); $matches = []; - $this->assertEquals(1, preg_match('|^\\/[^\\/]+\\/parcours/([\\d]+)/edit$|', $location, $matches)); + $this->assertEquals(1, preg_match('|^\\/[^\\/]+\\/parcours/([\\d]+)/edit$|', (string) $location, $matches)); $id = $matches[1]; $period = self::$container->get(EntityManagerInterface::class) diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingPeriodControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingPeriodControllerTest.php index 0fbdad9d8..79e803a13 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingPeriodControllerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingPeriodControllerTest.php @@ -270,7 +270,7 @@ final class AccompanyingPeriodControllerTest extends WebTestCase * Then the response should not redirect to any page * and an error element is shown */ - public function testCreatePeriodWithClosingAfterCurrentFails() + public function testCreatePeriodWithClosingAfterCurrentFails(): never { $this->markTestSkipped('Multiple period may now cover. This test is kept ' . 'in case of a configuration may add this feature again'); @@ -438,7 +438,7 @@ final class AccompanyingPeriodControllerTest extends WebTestCase * Then the response should not redirect to any page * and an error element is shown */ - public function testCreatePeriodWithOpeningAndClosingAfterCurrentFails() + public function testCreatePeriodWithOpeningAndClosingAfterCurrentFails(): never { $this->markTestSkipped('Multiple period may now cover. This test is kept ' . 'in case of a configuration may add this feature again'); @@ -470,7 +470,7 @@ final class AccompanyingPeriodControllerTest extends WebTestCase /** * @group reopening */ - public function testReOpeningPeriod() + public function testReOpeningPeriod(): never { // test that re-opening a period which is opened does not work $this->client->request( diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerViewWithHiddenFieldsTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerViewWithHiddenFieldsTest.php index f4722d685..d6bbb461f 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerViewWithHiddenFieldsTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerViewWithHiddenFieldsTest.php @@ -69,7 +69,7 @@ final class PersonControllerViewWithHiddenFieldsTest extends WebTestCase * * @group configurable_fields */ - public function testViewPerson() + public function testViewPerson(): never { $this->markTestSkipped('This configuration does not allow multiple environnements'); $client = self::createClient( diff --git a/src/Bundle/ChillPersonBundle/Tests/Form/Type/PickPersonTypeTest.php b/src/Bundle/ChillPersonBundle/Tests/Form/Type/PickPersonTypeTest.php index 83071bcbd..f5e4639c2 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Form/Type/PickPersonTypeTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Form/Type/PickPersonTypeTest.php @@ -51,7 +51,7 @@ final class PickPersonTypeTest extends KernelTestCase /** * test with an invalid center type in the option 'centers' (in an array). */ - public function testWithInvalidOptionCenters() + public function testWithInvalidOptionCenters(): never { $this->expectException(RuntimeException::class); @@ -128,7 +128,7 @@ final class PickPersonTypeTest extends KernelTestCase ); } - public function testWithOptionRoleInvalid() + public function testWithOptionRoleInvalid(): never { $this->markTestSkipped('need to inject locale into url generator without request'); $form = $this->formFactory diff --git a/src/Bundle/ChillPersonBundle/Tests/Search/PersonSearchTest.php b/src/Bundle/ChillPersonBundle/Tests/Search/PersonSearchTest.php index 64143e7db..05ca5918d 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Search/PersonSearchTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Search/PersonSearchTest.php @@ -21,7 +21,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; */ final class PersonSearchTest extends WebTestCase { - public function testDefaultAccented() + public function testDefaultAccented(): never { $this->markTestSkipped('skipped until adapted to new fixtures'); $crawlerSpecial = $this->generateCrawlerForSearch('@person manço'); @@ -135,7 +135,7 @@ final class PersonSearchTest extends WebTestCase $this->assertMatchesRegularExpression('/DEPARDIEU/', $crawler->filter('.list-with-period')->text()); } - public function testSearchCombineBirthdateAndLastName() + public function testSearchCombineBirthdateAndLastName(): never { $this->markTestSkipped('skipped until adapted to new fixtures'); $crawler = $this->generateCrawlerForSearch('@person birthdate:1948-12-27 lastname:(Van Snick)'); @@ -144,7 +144,7 @@ final class PersonSearchTest extends WebTestCase $this->assertDoesNotMatchRegularExpression('/DEPARDIEU/', $crawler->filter('.list-with-period')->text()); } - public function testSearchCombineGenderAndLastName() + public function testSearchCombineGenderAndLastName(): never { $this->markTestSkipped('skipped until adapted to new fixtures'); $crawler = $this->generateCrawlerForSearch('@person gender:woman lastname:(Depardieu)'); @@ -153,7 +153,7 @@ final class PersonSearchTest extends WebTestCase $this->assertDoesNotMatchRegularExpression('/Gérard/', $crawler->filter('.list-with-period')->text()); } - public function testSearchCombineLastnameAndFirstName() + public function testSearchCombineLastnameAndFirstName(): never { $this->markTestSkipped('skipped until adapted to new fixtures'); $crawler = $this->generateCrawlerForSearch('@person lastname:Depardieu firstname:Jean'); @@ -167,7 +167,7 @@ final class PersonSearchTest extends WebTestCase ); } - public function testSearchCombineLastnameAndNationality() + public function testSearchCombineLastnameAndNationality(): never { $this->markTestSkipped('skipped until adapted to new fixtures'); $crawler = $this->generateCrawlerForSearch('@person lastname:Depardieu nationality:RU'); @@ -181,7 +181,7 @@ final class PersonSearchTest extends WebTestCase ); } - public function testSearchMultipleTrigramUseAndClauseInDefault() + public function testSearchMultipleTrigramUseAndClauseInDefault(): never { $this->markTestSkipped('skipped until adapted to new fixtures'); $crawler = $this->generateCrawlerForSearch('@person cha dep'); diff --git a/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationDenormalizerTest.php b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationDenormalizerTest.php index 8b2cf2ffb..b56cb1fd9 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationDenormalizerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/AccompanyingPeriodWorkEvaluationDenormalizerTest.php @@ -96,7 +96,7 @@ final class AccompanyingPeriodWorkEvaluationDenormalizerTest extends TestCase "id": 382 }'; - public function testAssociatedDocumentIsTheSame() + public function testAssociatedDocumentIsTheSame(): never { $this->markTestIncomplete('not yet finished'); $evaluation = new AccompanyingPeriodWorkEvaluation(); diff --git a/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/HouseholdNormalizerTest.php b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/HouseholdNormalizerTest.php index acd4119a1..5f29588c2 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/HouseholdNormalizerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/HouseholdNormalizerTest.php @@ -30,7 +30,7 @@ final class HouseholdNormalizerTest extends KernelTestCase private ?NormalizerInterface $normalizer; - private array $toDelete; + private readonly array $toDelete; protected function setUp(): void { diff --git a/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/PersonDocGenNormalizerTest.php b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/PersonDocGenNormalizerTest.php index 90ceddb04..bf4031970 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/PersonDocGenNormalizerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/PersonDocGenNormalizerTest.php @@ -95,11 +95,7 @@ final class PersonDocGenNormalizerTest extends KernelTestCase ->setFirstName('Renaud') ->setLastName('Mégane'); - $expected = array_merge( - self::BLANK, - ['firstName' => 'Renaud', 'lastName' => 'Mégane', - 'text' => 'Renaud Mégane', ] - ); + $expected = [...self::BLANK, 'firstName' => 'Renaud', 'lastName' => 'Mégane', 'text' => 'Renaud Mégane']; yield [$person, $expected, 'partial normalization for a person']; diff --git a/src/Bundle/ChillPersonBundle/Tests/Timeline/TimelineAccompanyingPeriodTest.php b/src/Bundle/ChillPersonBundle/Tests/Timeline/TimelineAccompanyingPeriodTest.php index be368e28c..7560b8fb1 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Timeline/TimelineAccompanyingPeriodTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Timeline/TimelineAccompanyingPeriodTest.php @@ -59,7 +59,7 @@ final class TimelineAccompanyingPeriodTest extends WebTestCase /** * @dataProvider provideDataPersonWithAccompanyingPeriod */ - public function testEntriesAreShown(mixed $personId) + public function testEntriesAreShown(mixed $personId): never { $this->markTestSkipped('page does not work'); diff --git a/src/Bundle/ChillPersonBundle/Timeline/AbstractTimelineAccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Timeline/AbstractTimelineAccompanyingPeriod.php index 2e11a4f4f..03ebbb7a2 100644 --- a/src/Bundle/ChillPersonBundle/Timeline/AbstractTimelineAccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Timeline/AbstractTimelineAccompanyingPeriod.php @@ -35,7 +35,7 @@ abstract class AbstractTimelineAccompanyingPeriod implements TimelineProviderInt { private const SUPPORTED_CONTEXTS = ['person', 'center']; - public function __construct(protected EntityManager $em, private Security $security, private AuthorizationHelper $authorizationHelper) + public function __construct(protected EntityManager $em, private readonly Security $security, private readonly AuthorizationHelper $authorizationHelper) { } diff --git a/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/AccompanyingPeriodValidityValidator.php b/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/AccompanyingPeriodValidityValidator.php index f7d533d0e..5e20a10f3 100644 --- a/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/AccompanyingPeriodValidityValidator.php +++ b/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/AccompanyingPeriodValidityValidator.php @@ -25,7 +25,7 @@ use function in_array; class AccompanyingPeriodValidityValidator extends ConstraintValidator { - public function __construct(private ActivityRepository $activityRepository, private SocialIssueRender $socialIssueRender, private TokenStorageInterface $token) + public function __construct(private readonly ActivityRepository $activityRepository, private readonly SocialIssueRender $socialIssueRender, private readonly TokenStorageInterface $token) { } diff --git a/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/LocationValidityValidator.php b/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/LocationValidityValidator.php index 50ef5059c..c01c02cc6 100644 --- a/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/LocationValidityValidator.php +++ b/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/LocationValidityValidator.php @@ -20,7 +20,7 @@ use Symfony\Component\Validator\Exception\UnexpectedValueException; class LocationValidityValidator extends ConstraintValidator { - public function __construct(private PersonRenderInterface $render) + public function __construct(private readonly PersonRenderInterface $render) { } diff --git a/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/ParticipationOverlapValidator.php b/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/ParticipationOverlapValidator.php index 2589a1751..5e3d5ba7c 100644 --- a/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/ParticipationOverlapValidator.php +++ b/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/ParticipationOverlapValidator.php @@ -26,7 +26,7 @@ class ParticipationOverlapValidator extends ConstraintValidator { private const MAX_PARTICIPATION = 1; - public function __construct(private PersonRenderInterface $personRender, private ThirdPartyRender $thirdpartyRender) + public function __construct(private readonly PersonRenderInterface $personRender, private readonly ThirdPartyRender $thirdpartyRender) { } diff --git a/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/ResourceDuplicateCheckValidator.php b/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/ResourceDuplicateCheckValidator.php index a9d339286..7333abf2c 100644 --- a/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/ResourceDuplicateCheckValidator.php +++ b/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/ResourceDuplicateCheckValidator.php @@ -24,7 +24,7 @@ use function in_array; class ResourceDuplicateCheckValidator extends ConstraintValidator { - public function __construct(private PersonRenderInterface $personRender, private ThirdPartyRender $thirdpartyRender) + public function __construct(private readonly PersonRenderInterface $personRender, private readonly ThirdPartyRender $thirdpartyRender) { } diff --git a/src/Bundle/ChillPersonBundle/Validator/Constraints/Household/HouseholdMembershipSequentialValidator.php b/src/Bundle/ChillPersonBundle/Validator/Constraints/Household/HouseholdMembershipSequentialValidator.php index edabface7..ebf87b12c 100644 --- a/src/Bundle/ChillPersonBundle/Validator/Constraints/Household/HouseholdMembershipSequentialValidator.php +++ b/src/Bundle/ChillPersonBundle/Validator/Constraints/Household/HouseholdMembershipSequentialValidator.php @@ -26,7 +26,7 @@ use function count; */ class HouseholdMembershipSequentialValidator extends ConstraintValidator { - public function __construct(private PersonRenderInterface $render) + public function __construct(private readonly PersonRenderInterface $render) { } diff --git a/src/Bundle/ChillPersonBundle/Validator/Constraints/Person/Birthdate.php b/src/Bundle/ChillPersonBundle/Validator/Constraints/Person/Birthdate.php index 15fb22728..c1c805adf 100644 --- a/src/Bundle/ChillPersonBundle/Validator/Constraints/Person/Birthdate.php +++ b/src/Bundle/ChillPersonBundle/Validator/Constraints/Person/Birthdate.php @@ -25,7 +25,7 @@ use Symfony\Component\Validator\Constraint; */ class Birthdate extends Constraint { - public const BIRTHDATE_INVALID_CODE = '3f42fd96-0b2d-11ec-8cf3-0f3b1b1ca1c4'; + final public const BIRTHDATE_INVALID_CODE = '3f42fd96-0b2d-11ec-8cf3-0f3b1b1ca1c4'; public $message = 'The birthdate must be before %date%'; } diff --git a/src/Bundle/ChillPersonBundle/Validator/Constraints/Person/PersonHasCenterValidator.php b/src/Bundle/ChillPersonBundle/Validator/Constraints/Person/PersonHasCenterValidator.php index 48fab3787..0d7ba3b17 100644 --- a/src/Bundle/ChillPersonBundle/Validator/Constraints/Person/PersonHasCenterValidator.php +++ b/src/Bundle/ChillPersonBundle/Validator/Constraints/Person/PersonHasCenterValidator.php @@ -20,9 +20,9 @@ use Symfony\Component\Validator\Exception\UnexpectedTypeException; class PersonHasCenterValidator extends ConstraintValidator { - private bool $centerRequired; + private readonly bool $centerRequired; - public function __construct(ParameterBagInterface $parameterBag, private CenterResolverManagerInterface $centerResolverManager) + public function __construct(ParameterBagInterface $parameterBag, private readonly CenterResolverManagerInterface $centerResolverManager) { $this->centerRequired = $parameterBag->get('chill_person')['validation']['center_required']; } diff --git a/src/Bundle/ChillPersonBundle/Validator/Constraints/Relationship/RelationshipNoDuplicateValidator.php b/src/Bundle/ChillPersonBundle/Validator/Constraints/Relationship/RelationshipNoDuplicateValidator.php index bec92b9c0..0a64aa891 100644 --- a/src/Bundle/ChillPersonBundle/Validator/Constraints/Relationship/RelationshipNoDuplicateValidator.php +++ b/src/Bundle/ChillPersonBundle/Validator/Constraints/Relationship/RelationshipNoDuplicateValidator.php @@ -20,7 +20,7 @@ use Symfony\Component\Validator\Exception\UnexpectedValueException; class RelationshipNoDuplicateValidator extends ConstraintValidator { - public function __construct(private RelationshipRepository $relationshipRepository) + public function __construct(private readonly RelationshipRepository $relationshipRepository) { } diff --git a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler.php b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler.php index c224cb166..1b85c3cb5 100644 --- a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler.php +++ b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler.php @@ -21,7 +21,7 @@ use Symfony\Contracts\Translation\TranslatorInterface; class AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler implements EntityWorkflowHandlerInterface { - public function __construct(private AccompanyingPeriodWorkEvaluationDocumentRepository $repository, private TranslatableStringHelperInterface $translatableStringHelper, private TranslatorInterface $translator) + public function __construct(private readonly AccompanyingPeriodWorkEvaluationDocumentRepository $repository, private readonly TranslatableStringHelperInterface $translatableStringHelper, private readonly TranslatorInterface $translator) { } diff --git a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationWorkflowHandler.php b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationWorkflowHandler.php index b5869c35f..70b23f9f7 100644 --- a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationWorkflowHandler.php +++ b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationWorkflowHandler.php @@ -22,7 +22,7 @@ use Symfony\Contracts\Translation\TranslatorInterface; class AccompanyingPeriodWorkEvaluationWorkflowHandler implements EntityWorkflowHandlerInterface { - public function __construct(private AccompanyingPeriodWorkEvaluationRepository $repository, private TranslatableStringHelperInterface $translatableStringHelper, private TranslatorInterface $translator) + public function __construct(private readonly AccompanyingPeriodWorkEvaluationRepository $repository, private readonly TranslatableStringHelperInterface $translatableStringHelper, private readonly TranslatorInterface $translator) { } diff --git a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkWorkflowHandler.php b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkWorkflowHandler.php index 203fd60d2..0f9b05ac9 100644 --- a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkWorkflowHandler.php +++ b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkWorkflowHandler.php @@ -23,7 +23,7 @@ use Symfony\Contracts\Translation\TranslatorInterface; class AccompanyingPeriodWorkWorkflowHandler implements EntityWorkflowHandlerInterface { - public function __construct(private AccompanyingPeriodWorkRepository $repository, private TranslatableStringHelperInterface $translatableStringHelper, private TranslatorInterface $translator) + public function __construct(private readonly AccompanyingPeriodWorkRepository $repository, private readonly TranslatableStringHelperInterface $translatableStringHelper, private readonly TranslatorInterface $translator) { } diff --git a/src/Bundle/ChillReportBundle/Export/Export/ReportList.php b/src/Bundle/ChillReportBundle/Export/Export/ReportList.php index dbaa1abea..c893d084a 100644 --- a/src/Bundle/ChillReportBundle/Export/Export/ReportList.php +++ b/src/Bundle/ChillReportBundle/Export/Export/ReportList.php @@ -325,7 +325,7 @@ class ReportList implements ExportElementValidatedInterface, ListInterface switch ($f) { case 'person_countryOfBirth': case 'person_nationality': - $suffix = substr($f, 7); + $suffix = substr((string) $f, 7); $qb->addSelect(sprintf('IDENTITY(person.%s) as %s', $suffix, $f)); break; @@ -338,7 +338,7 @@ class ReportList implements ExportElementValidatedInterface, ListInterface case 'person_address_country_name': case 'person_address_country_code': // remove 'person_' - $suffix = substr($f, 7); + $suffix = substr((string) $f, 7); $qb->addSelect(sprintf( 'GET_PERSON_ADDRESS_%s(person.id, :address_date) AS %s', @@ -361,8 +361,8 @@ class ReportList implements ExportElementValidatedInterface, ListInterface break; default: - $prefix = substr($f, 0, 7); - $suffix = substr($f, 7); + $prefix = substr((string) $f, 0, 7); + $suffix = substr((string) $f, 7); match ($prefix) { 'person_' => $qb->addSelect(sprintf('person.%s as %s', $suffix, $f)), diff --git a/src/Bundle/ChillReportBundle/Export/Filter/ReportDateFilter.php b/src/Bundle/ChillReportBundle/Export/Filter/ReportDateFilter.php index 6117d2f48..d11c5cc70 100644 --- a/src/Bundle/ChillReportBundle/Export/Filter/ReportDateFilter.php +++ b/src/Bundle/ChillReportBundle/Export/Filter/ReportDateFilter.php @@ -19,7 +19,7 @@ use Doctrine\ORM\Query\Expr; class ReportDateFilter implements FilterInterface { - public function __construct(private RollingDateConverterInterface $rollingDateConverter) + public function __construct(private readonly RollingDateConverterInterface $rollingDateConverter) { } diff --git a/src/Bundle/ChillReportBundle/Search/ReportSearch.php b/src/Bundle/ChillReportBundle/Search/ReportSearch.php index 8fbc24e16..3c5e7f4ad 100644 --- a/src/Bundle/ChillReportBundle/Search/ReportSearch.php +++ b/src/Bundle/ChillReportBundle/Search/ReportSearch.php @@ -37,8 +37,8 @@ class ReportSearch extends AbstractSearch implements ContainerAwareInterface private $user; public function __construct( - private EntityManagerInterface $em, - private AuthorizationHelper $helper, + private readonly EntityManagerInterface $em, + private readonly AuthorizationHelper $helper, TokenStorageInterface $tokenStorage ) { if (!$tokenStorage->getToken()->getUser() instanceof \Chill\MainBundle\Entity\User) { diff --git a/src/Bundle/ChillReportBundle/Security/Authorization/ReportVoter.php b/src/Bundle/ChillReportBundle/Security/Authorization/ReportVoter.php index ae4d1be55..2caf57305 100644 --- a/src/Bundle/ChillReportBundle/Security/Authorization/ReportVoter.php +++ b/src/Bundle/ChillReportBundle/Security/Authorization/ReportVoter.php @@ -23,13 +23,13 @@ use function in_array; class ReportVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface { - public const CREATE = 'CHILL_REPORT_CREATE'; + final public const CREATE = 'CHILL_REPORT_CREATE'; - public const LISTS = 'CHILL_REPORT_LISTS'; + final public const LISTS = 'CHILL_REPORT_LISTS'; - public const SEE = 'CHILL_REPORT_SEE'; + final public const SEE = 'CHILL_REPORT_SEE'; - public const UPDATE = 'CHILL_REPORT_UPDATE'; + final public const UPDATE = 'CHILL_REPORT_UPDATE'; /** * @var AuthorizationHelper diff --git a/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerTest.php b/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerTest.php index 69ccd3d54..10f4f14c0 100644 --- a/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerTest.php +++ b/src/Bundle/ChillReportBundle/Tests/Controller/ReportControllerTest.php @@ -160,7 +160,7 @@ final class ReportControllerTest extends WebTestCase * * @depends testNewReportPage */ - public function testInvalidDate(Form $form) + public function testInvalidDate(Form $form): never { $client = $this->getAuthenticatedClient(); $this->markTestSkipped('This test raise an error since symfony 2.7. ' @@ -379,7 +379,7 @@ final class ReportControllerTest extends WebTestCase $matches = []; preg_match( '|/report/([0-9]*)/view$|', - $client->getHistory()->current()->getUri(), + (string) $client->getHistory()->current()->getUri(), $matches ); diff --git a/src/Bundle/ChillReportBundle/Timeline/TimelineReportProvider.php b/src/Bundle/ChillReportBundle/Timeline/TimelineReportProvider.php index d2e856131..a5f62debc 100644 --- a/src/Bundle/ChillReportBundle/Timeline/TimelineReportProvider.php +++ b/src/Bundle/ChillReportBundle/Timeline/TimelineReportProvider.php @@ -35,7 +35,7 @@ use function strtr; */ class TimelineReportProvider implements TimelineProviderInterface { - public function __construct(protected EntityManager $em, protected AuthorizationHelper $helper, private Security $security, protected CustomFieldsHelper $customFieldsHelper, protected $showEmptyValues) + public function __construct(protected EntityManager $em, protected AuthorizationHelper $helper, private readonly Security $security, protected CustomFieldsHelper $customFieldsHelper, protected $showEmptyValues) { } diff --git a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php index a1085657a..d8afbc65d 100644 --- a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php +++ b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php @@ -47,7 +47,7 @@ use function array_merge; final class SingleTaskController extends AbstractController { - public function __construct(private CenterResolverDispatcherInterface $centerResolverDispatcher, private PaginatorFactory $paginatorFactory, private SingleTaskAclAwareRepositoryInterface $singleTaskAclAwareRepository, private TranslatorInterface $translator, private EventDispatcherInterface $eventDispatcher, private TimelineBuilder $timelineBuilder, private LoggerInterface $logger, private FilterOrderHelperFactoryInterface $filterOrderHelperFactory) + public function __construct(private readonly CenterResolverDispatcherInterface $centerResolverDispatcher, private readonly PaginatorFactory $paginatorFactory, private readonly SingleTaskAclAwareRepositoryInterface $singleTaskAclAwareRepository, private readonly TranslatorInterface $translator, private readonly EventDispatcherInterface $eventDispatcher, private readonly TimelineBuilder $timelineBuilder, private readonly LoggerInterface $logger, private readonly FilterOrderHelperFactoryInterface $filterOrderHelperFactory) { } diff --git a/src/Bundle/ChillTaskBundle/Event/TaskEvent.php b/src/Bundle/ChillTaskBundle/Event/TaskEvent.php index 57e8329c9..01cae799c 100644 --- a/src/Bundle/ChillTaskBundle/Event/TaskEvent.php +++ b/src/Bundle/ChillTaskBundle/Event/TaskEvent.php @@ -16,7 +16,7 @@ use Symfony\Component\EventDispatcher\Event; class TaskEvent extends Event { - public const PERSIST = 'chill_task.task_persist'; + final public const PERSIST = 'chill_task.task_persist'; /** * @var AbstractTask diff --git a/src/Bundle/ChillTaskBundle/Event/UI/UIEvent.php b/src/Bundle/ChillTaskBundle/Event/UI/UIEvent.php index ac88a1d3a..e0414948b 100644 --- a/src/Bundle/ChillTaskBundle/Event/UI/UIEvent.php +++ b/src/Bundle/ChillTaskBundle/Event/UI/UIEvent.php @@ -19,11 +19,11 @@ use Symfony\Component\Workflow\Transition; class UIEvent extends Event { - public const EDIT_FORM = 'chill_task.edit_form'; + final public const EDIT_FORM = 'chill_task.edit_form'; - public const EDIT_PAGE = 'chill_task.edit_page'; + final public const EDIT_PAGE = 'chill_task.edit_page'; - public const SHOW_TRANSITION_PAGE = 'chill_task.show_transition_page'; + final public const SHOW_TRANSITION_PAGE = 'chill_task.show_transition_page'; /** * @var FormInterface|null diff --git a/src/Bundle/ChillTaskBundle/Form/SingleTaskType.php b/src/Bundle/ChillTaskBundle/Form/SingleTaskType.php index 4378696d0..65417f21e 100644 --- a/src/Bundle/ChillTaskBundle/Form/SingleTaskType.php +++ b/src/Bundle/ChillTaskBundle/Form/SingleTaskType.php @@ -28,7 +28,7 @@ use Symfony\Component\Security\Core\Role\Role; class SingleTaskType extends AbstractType { - public function __construct(private ParameterBagInterface $parameterBag, private CenterResolverDispatcherInterface $centerResolverDispatcher, private ScopeResolverDispatcher $scopeResolverDispatcher) + public function __construct(private readonly ParameterBagInterface $parameterBag, private readonly CenterResolverDispatcherInterface $centerResolverDispatcher, private readonly ScopeResolverDispatcher $scopeResolverDispatcher) { } diff --git a/src/Bundle/ChillTaskBundle/Repository/SingleTaskAclAwareRepository.php b/src/Bundle/ChillTaskBundle/Repository/SingleTaskAclAwareRepository.php index 8c95aa9ee..5ae44c499 100644 --- a/src/Bundle/ChillTaskBundle/Repository/SingleTaskAclAwareRepository.php +++ b/src/Bundle/ChillTaskBundle/Repository/SingleTaskAclAwareRepository.php @@ -27,7 +27,7 @@ use Symfony\Component\Security\Core\Security; use function count; use function substr; -final class SingleTaskAclAwareRepository implements SingleTaskAclAwareRepositoryInterface +final readonly class SingleTaskAclAwareRepository implements SingleTaskAclAwareRepositoryInterface { public function __construct(private CenterResolverManagerInterface $centerResolverDispatcher, private EntityManagerInterface $em, private Security $security, private AuthorizationHelperInterface $authorizationHelper) { @@ -103,8 +103,8 @@ final class SingleTaskAclAwareRepository implements SingleTaskAclAwareRepository break; - case str_starts_with($flag, 'state_'): - $state = substr($flag, 6); + case str_starts_with((string) $flag, 'state_'): + $state = substr((string) $flag, 6); $orXState ->add( "JSONB_EXISTS_IN_ARRAY(t.currentStates, :state_{$key}) = 'TRUE'" diff --git a/src/Bundle/ChillTaskBundle/Repository/SingleTaskRepository.php b/src/Bundle/ChillTaskBundle/Repository/SingleTaskRepository.php index e3eb634cd..0a95e3b25 100644 --- a/src/Bundle/ChillTaskBundle/Repository/SingleTaskRepository.php +++ b/src/Bundle/ChillTaskBundle/Repository/SingleTaskRepository.php @@ -31,15 +31,15 @@ use function count; */ class SingleTaskRepository extends EntityRepository { - public const DATE_STATUS_CURRENT = 'current'; + final public const DATE_STATUS_CURRENT = 'current'; - public const DATE_STATUS_ENDED = 'ended'; + final public const DATE_STATUS_ENDED = 'ended'; - public const DATE_STATUS_NOT_STARTED = 'not_started'; + final public const DATE_STATUS_NOT_STARTED = 'not_started'; - public const DATE_STATUS_WARNING = 'warning'; + final public const DATE_STATUS_WARNING = 'warning'; - public const DATE_STATUSES = [ + final public const DATE_STATUSES = [ self::DATE_STATUS_ENDED, self::DATE_STATUS_WARNING, self::DATE_STATUS_CURRENT, diff --git a/src/Bundle/ChillTaskBundle/Security/Authorization/AuthorizationEvent.php b/src/Bundle/ChillTaskBundle/Security/Authorization/AuthorizationEvent.php index d7ccc0db9..60c7f3d5a 100644 --- a/src/Bundle/ChillTaskBundle/Security/Authorization/AuthorizationEvent.php +++ b/src/Bundle/ChillTaskBundle/Security/Authorization/AuthorizationEvent.php @@ -19,7 +19,7 @@ use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; class AuthorizationEvent extends Event { - public const VOTE = 'chill_task.vote'; + final public const VOTE = 'chill_task.vote'; /** * @var bool @@ -27,9 +27,9 @@ class AuthorizationEvent extends Event protected $vote; public function __construct( - private Person|AbstractTask|AccompanyingPeriod|null $subject, - private string $attribute, - private TokenInterface $token + private readonly Person|AbstractTask|AccompanyingPeriod|null $subject, + private readonly string $attribute, + private readonly TokenInterface $token ) { } diff --git a/src/Bundle/ChillTaskBundle/Security/Authorization/TaskVoter.php b/src/Bundle/ChillTaskBundle/Security/Authorization/TaskVoter.php index 6031f64d1..9575bfcfa 100644 --- a/src/Bundle/ChillTaskBundle/Security/Authorization/TaskVoter.php +++ b/src/Bundle/ChillTaskBundle/Security/Authorization/TaskVoter.php @@ -48,12 +48,12 @@ final class TaskVoter extends AbstractChillVoter implements ProvideRoleHierarchy public const UPDATE = 'CHILL_TASK_TASK_UPDATE'; - private VoterHelperInterface $voter; + private readonly VoterHelperInterface $voter; public function __construct( - private AccessDecisionManagerInterface $accessDecisionManager, - private EventDispatcherInterface $eventDispatcher, - private LoggerInterface $logger, + private readonly AccessDecisionManagerInterface $accessDecisionManager, + private readonly EventDispatcherInterface $eventDispatcher, + private readonly LoggerInterface $logger, VoterHelperFactoryInterface $voterFactory ) { $this->voter = $voterFactory diff --git a/src/Bundle/ChillTaskBundle/Templating/TaskTwigExtension.php b/src/Bundle/ChillTaskBundle/Templating/TaskTwigExtension.php index 8b1646435..affaab8c7 100644 --- a/src/Bundle/ChillTaskBundle/Templating/TaskTwigExtension.php +++ b/src/Bundle/ChillTaskBundle/Templating/TaskTwigExtension.php @@ -31,7 +31,7 @@ class TaskTwigExtension extends AbstractExtension public function getFunctions() { return [ - new TwigFunction('task_workflow_metadata', [$this, 'getWorkflowMetadata']), + new TwigFunction('task_workflow_metadata', $this->getWorkflowMetadata(...)), ]; } diff --git a/src/Bundle/ChillTaskBundle/Templating/UI/CountNotificationTask.php b/src/Bundle/ChillTaskBundle/Templating/UI/CountNotificationTask.php index 08a4177e1..783f41529 100644 --- a/src/Bundle/ChillTaskBundle/Templating/UI/CountNotificationTask.php +++ b/src/Bundle/ChillTaskBundle/Templating/UI/CountNotificationTask.php @@ -22,7 +22,7 @@ use function array_merge; class CountNotificationTask implements NotificationCounterInterface { - public const CACHE_KEY = 'chill_task.count_notifications.user.%d.%s'; + final public const CACHE_KEY = 'chill_task.count_notifications.user.%d.%s'; /** * @var CacheItempPoolInterface @@ -104,7 +104,7 @@ class CountNotificationTask implements NotificationCounterInterface ]; $sum = $this->singleTaskRepository->countByParameters( - array_merge($params, ['date_status' => $status]) + [...$params, 'date_status' => $status] ); $sumCache->set($sum); diff --git a/src/Bundle/ChillTaskBundle/Tests/Repository/SingleTaskACLAwareRepositoryTest.php b/src/Bundle/ChillTaskBundle/Tests/Repository/SingleTaskACLAwareRepositoryTest.php index 0bab53764..4d5520ca5 100644 --- a/src/Bundle/ChillTaskBundle/Tests/Repository/SingleTaskACLAwareRepositoryTest.php +++ b/src/Bundle/ChillTaskBundle/Tests/Repository/SingleTaskACLAwareRepositoryTest.php @@ -40,7 +40,7 @@ final class SingleTaskACLAwareRepositoryTest extends KernelTestCase use ProphecyTrait; - private AuthorizationHelperInterface $authorizationHelper; + private readonly AuthorizationHelperInterface $authorizationHelper; private CenterRepositoryInterface $centerRepository; diff --git a/src/Bundle/ChillTaskBundle/Timeline/SingleTaskTaskLifeCycleEventTimelineProvider.php b/src/Bundle/ChillTaskBundle/Timeline/SingleTaskTaskLifeCycleEventTimelineProvider.php index 9a8fcf6bd..8b2e5c707 100644 --- a/src/Bundle/ChillTaskBundle/Timeline/SingleTaskTaskLifeCycleEventTimelineProvider.php +++ b/src/Bundle/ChillTaskBundle/Timeline/SingleTaskTaskLifeCycleEventTimelineProvider.php @@ -28,7 +28,7 @@ use function array_map; */ class SingleTaskTaskLifeCycleEventTimelineProvider implements TimelineProviderInterface { - public const TYPE = 'chill_task.transition'; + final public const TYPE = 'chill_task.transition'; /** * @var EntityManagerInterface diff --git a/src/Bundle/ChillTaskBundle/Timeline/TaskLifeCycleEventTimelineProvider.php b/src/Bundle/ChillTaskBundle/Timeline/TaskLifeCycleEventTimelineProvider.php index 4efe57c7c..1fa818f41 100644 --- a/src/Bundle/ChillTaskBundle/Timeline/TaskLifeCycleEventTimelineProvider.php +++ b/src/Bundle/ChillTaskBundle/Timeline/TaskLifeCycleEventTimelineProvider.php @@ -38,7 +38,7 @@ use function strtr; */ class TaskLifeCycleEventTimelineProvider implements TimelineProviderInterface { - public const TYPE = 'chill_task.transition'; + final public const TYPE = 'chill_task.transition'; public function __construct(protected EntityManagerInterface $em, protected Registry $registry, protected AuthorizationHelper $authorizationHelper, protected Security $security) { diff --git a/src/Bundle/ChillTaskBundle/Workflow/Definition/DefaultTaskDefinition.php b/src/Bundle/ChillTaskBundle/Workflow/Definition/DefaultTaskDefinition.php index a68e8c9b9..02d3facda 100644 --- a/src/Bundle/ChillTaskBundle/Workflow/Definition/DefaultTaskDefinition.php +++ b/src/Bundle/ChillTaskBundle/Workflow/Definition/DefaultTaskDefinition.php @@ -23,11 +23,11 @@ use function implode; class DefaultTaskDefinition implements \Chill\TaskBundle\Workflow\TaskWorkflowDefinition { - public const DEFINITION_METADATA = [ + final public const DEFINITION_METADATA = [ 'name' => 'Default task', ]; - public const TRANSITION_METADATA = [ + final public const TRANSITION_METADATA = [ 'close' => [ 'verb' => 'close', 'class' => 'btn btn-task-label btn-task-close', diff --git a/src/Bundle/ChillThirdPartyBundle/Controller/ThirdPartyController.php b/src/Bundle/ChillThirdPartyBundle/Controller/ThirdPartyController.php index da806a750..821f6c7ef 100644 --- a/src/Bundle/ChillThirdPartyBundle/Controller/ThirdPartyController.php +++ b/src/Bundle/ChillThirdPartyBundle/Controller/ThirdPartyController.php @@ -32,7 +32,7 @@ use function array_merge; final class ThirdPartyController extends CRUDController { - private bool $askCenter; + private readonly bool $askCenter; public function __construct( protected AuthorizationHelper $authorizationHelper, diff --git a/src/Bundle/ChillThirdPartyBundle/DataFixtures/ORM/LoadThirdParty.php b/src/Bundle/ChillThirdPartyBundle/DataFixtures/ORM/LoadThirdParty.php index e813cbd7f..119446f13 100644 --- a/src/Bundle/ChillThirdPartyBundle/DataFixtures/ORM/LoadThirdParty.php +++ b/src/Bundle/ChillThirdPartyBundle/DataFixtures/ORM/LoadThirdParty.php @@ -30,7 +30,7 @@ use function count; class LoadThirdParty extends Fixture implements DependentFixtureInterface { - private PhoneNumberUtil $phoneNumberUtil; + private readonly PhoneNumberUtil $phoneNumberUtil; public function __construct() { diff --git a/src/Bundle/ChillThirdPartyBundle/DependencyInjection/CompilerPass/ThirdPartyTypeCompilerPass.php b/src/Bundle/ChillThirdPartyBundle/DependencyInjection/CompilerPass/ThirdPartyTypeCompilerPass.php index f5fa9d05a..11095df7f 100644 --- a/src/Bundle/ChillThirdPartyBundle/DependencyInjection/CompilerPass/ThirdPartyTypeCompilerPass.php +++ b/src/Bundle/ChillThirdPartyBundle/DependencyInjection/CompilerPass/ThirdPartyTypeCompilerPass.php @@ -25,7 +25,7 @@ use function in_array; */ class ThirdPartyTypeCompilerPass implements CompilerPassInterface { - public const TAG = 'chill_3party.provider'; + final public const TAG = 'chill_3party.provider'; public function process(ContainerBuilder $container) { diff --git a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php index b8ea8126c..2d4818ea6 100644 --- a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php +++ b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php @@ -90,11 +90,11 @@ use function spl_object_hash; */ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface, \Stringable { - public const KIND_CHILD = 'child'; + final public const KIND_CHILD = 'child'; - public const KIND_COMPANY = 'company'; + final public const KIND_COMPANY = 'company'; - public const KIND_CONTACT = 'contact'; + final public const KIND_CONTACT = 'contact'; /** * [fr] Sigle. diff --git a/src/Bundle/ChillThirdPartyBundle/Export/Helper/LabelThirdPartyHelper.php b/src/Bundle/ChillThirdPartyBundle/Export/Helper/LabelThirdPartyHelper.php index 61fb03226..be275b22a 100644 --- a/src/Bundle/ChillThirdPartyBundle/Export/Helper/LabelThirdPartyHelper.php +++ b/src/Bundle/ChillThirdPartyBundle/Export/Helper/LabelThirdPartyHelper.php @@ -18,7 +18,7 @@ use const SORT_NUMERIC; class LabelThirdPartyHelper { - public function __construct(private ThirdPartyRender $thirdPartyRender, private ThirdPartyRepository $thirdPartyRepository) + public function __construct(private readonly ThirdPartyRender $thirdPartyRender, private readonly ThirdPartyRepository $thirdPartyRepository) { } diff --git a/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php b/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php index 91e915e09..e8a26d3fd 100644 --- a/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php +++ b/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php @@ -38,7 +38,7 @@ use function array_key_exists; class ThirdPartyType extends AbstractType { - private bool $askCenter; + private readonly bool $askCenter; public function __construct( protected AuthorizationHelper $authorizationHelper, diff --git a/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdPartyTypeCategoryType.php b/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdPartyTypeCategoryType.php index a02785545..4e0477bcc 100644 --- a/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdPartyTypeCategoryType.php +++ b/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdPartyTypeCategoryType.php @@ -30,7 +30,7 @@ class PickThirdPartyTypeCategoryType extends \Symfony\Component\Form\AbstractTyp { private const PREFIX_TYPE = 'chill_3party.key_label.'; - public function __construct(private ThirdPartyCategoryRepository $thirdPartyCategoryRepository, private ThirdPartyTypeManager $thirdPartyTypeManager, private TranslatableStringHelper $translatableStringHelper, private TranslatorInterface $translator) + public function __construct(private readonly ThirdPartyCategoryRepository $thirdPartyCategoryRepository, private readonly ThirdPartyTypeManager $thirdPartyTypeManager, private readonly TranslatableStringHelper $translatableStringHelper, private readonly TranslatorInterface $translator) { } diff --git a/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdpartyDynamicType.php b/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdpartyDynamicType.php index 8ae1702ce..9022fb6dc 100644 --- a/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdpartyDynamicType.php +++ b/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdpartyDynamicType.php @@ -26,7 +26,7 @@ use Symfony\Component\Serializer\SerializerInterface; */ class PickThirdpartyDynamicType extends AbstractType { - public function __construct(private DenormalizerInterface $denormalizer, private SerializerInterface $serializer, private NormalizerInterface $normalizer) + public function __construct(private readonly DenormalizerInterface $denormalizer, private readonly SerializerInterface $serializer, private readonly NormalizerInterface $normalizer) { } diff --git a/src/Bundle/ChillThirdPartyBundle/Repository/ThirdPartyACLAwareRepository.php b/src/Bundle/ChillThirdPartyBundle/Repository/ThirdPartyACLAwareRepository.php index 283622e56..30f9be556 100644 --- a/src/Bundle/ChillThirdPartyBundle/Repository/ThirdPartyACLAwareRepository.php +++ b/src/Bundle/ChillThirdPartyBundle/Repository/ThirdPartyACLAwareRepository.php @@ -15,7 +15,7 @@ use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Security\Core\Security; -final class ThirdPartyACLAwareRepository implements ThirdPartyACLAwareRepositoryInterface +final readonly class ThirdPartyACLAwareRepository implements ThirdPartyACLAwareRepositoryInterface { public function __construct(private Security $security, private AuthorizationHelper $authorizationHelper, private ThirdPartyRepository $thirdPartyRepository) { diff --git a/src/Bundle/ChillThirdPartyBundle/Repository/ThirdPartyRepository.php b/src/Bundle/ChillThirdPartyBundle/Repository/ThirdPartyRepository.php index 76e15ef17..c9d1d856f 100644 --- a/src/Bundle/ChillThirdPartyBundle/Repository/ThirdPartyRepository.php +++ b/src/Bundle/ChillThirdPartyBundle/Repository/ThirdPartyRepository.php @@ -23,7 +23,7 @@ use function array_key_exists; final class ThirdPartyRepository implements ObjectRepository { - private EntityRepository $repository; + private readonly EntityRepository $repository; public function __construct(EntityManagerInterface $em) { diff --git a/src/Bundle/ChillThirdPartyBundle/Search/ThirdPartyApiSearch.php b/src/Bundle/ChillThirdPartyBundle/Search/ThirdPartyApiSearch.php index 8b0a26849..12d5ba95c 100644 --- a/src/Bundle/ChillThirdPartyBundle/Search/ThirdPartyApiSearch.php +++ b/src/Bundle/ChillThirdPartyBundle/Search/ThirdPartyApiSearch.php @@ -49,7 +49,7 @@ FROM rows, searches */ class ThirdPartyApiSearch implements SearchApiInterface { - public function __construct(private ThirdPartyRepository $thirdPartyRepository) + public function __construct(private readonly ThirdPartyRepository $thirdPartyRepository) { } diff --git a/src/Bundle/ChillThirdPartyBundle/Search/ThirdPartySearch.php b/src/Bundle/ChillThirdPartyBundle/Search/ThirdPartySearch.php index 0421d0f34..c60f97413 100644 --- a/src/Bundle/ChillThirdPartyBundle/Search/ThirdPartySearch.php +++ b/src/Bundle/ChillThirdPartyBundle/Search/ThirdPartySearch.php @@ -26,7 +26,7 @@ use Symfony\Component\Security\Core\Role\Role; */ class ThirdPartySearch implements SearchInterface { - public const NAME = '3party'; + final public const NAME = '3party'; /** * @var AuthorizationHelper @@ -53,7 +53,7 @@ class ThirdPartySearch implements SearchInterface TokenStorageInterface $tokenStorage, AuthorizationHelper $authorizationHelper, PaginatorFactory $paginatorFactory, - private ThirdPartyRepository $thirdPartyRepository + private readonly ThirdPartyRepository $thirdPartyRepository ) { $this->em = $em; $this->tokenStorage = $tokenStorage; diff --git a/src/Bundle/ChillThirdPartyBundle/Security/Voter/ThirdPartyVoter.php b/src/Bundle/ChillThirdPartyBundle/Security/Voter/ThirdPartyVoter.php index e1dae28b9..9e346ebf5 100644 --- a/src/Bundle/ChillThirdPartyBundle/Security/Voter/ThirdPartyVoter.php +++ b/src/Bundle/ChillThirdPartyBundle/Security/Voter/ThirdPartyVoter.php @@ -28,11 +28,11 @@ use function in_array; */ class ThirdPartyVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface { - public const CREATE = 'CHILL_3PARTY_3PARTY_CREATE'; + final public const CREATE = 'CHILL_3PARTY_3PARTY_CREATE'; - public const SHOW = 'CHILL_3PARTY_3PARTY_SHOW'; + final public const SHOW = 'CHILL_3PARTY_3PARTY_SHOW'; - public const UPDATE = 'CHILL_3PARTY_3PARTY_UPDATE'; + final public const UPDATE = 'CHILL_3PARTY_3PARTY_UPDATE'; /** * @var AuthorizationHelper diff --git a/src/Bundle/ChillThirdPartyBundle/Serializer/Normalizer/ThirdPartyNormalizer.php b/src/Bundle/ChillThirdPartyBundle/Serializer/Normalizer/ThirdPartyNormalizer.php index b3f898a76..b2271e8df 100644 --- a/src/Bundle/ChillThirdPartyBundle/Serializer/Normalizer/ThirdPartyNormalizer.php +++ b/src/Bundle/ChillThirdPartyBundle/Serializer/Normalizer/ThirdPartyNormalizer.php @@ -24,7 +24,7 @@ class ThirdPartyNormalizer implements NormalizerAwareInterface, NormalizerInterf { use NormalizerAwareTrait; - public function __construct(private ThirdPartyRender $thirdPartyRender, private TranslatableStringHelperInterface $translatableStringHelper) + public function __construct(private readonly ThirdPartyRender $thirdPartyRender, private readonly TranslatableStringHelperInterface $translatableStringHelper) { } diff --git a/src/Bundle/ChillThirdPartyBundle/ThirdPartyType/ThirdPartyTypeManager.php b/src/Bundle/ChillThirdPartyBundle/ThirdPartyType/ThirdPartyTypeManager.php index cc8081aaa..714cb6455 100644 --- a/src/Bundle/ChillThirdPartyBundle/ThirdPartyType/ThirdPartyTypeManager.php +++ b/src/Bundle/ChillThirdPartyBundle/ThirdPartyType/ThirdPartyTypeManager.php @@ -21,7 +21,7 @@ class ThirdPartyTypeManager /** * The prefix used to translate the key of provider. */ - public const THIRD_PARTY_TRANSLATOR_KEY = 'chill_3party.key_label.'; + final public const THIRD_PARTY_TRANSLATOR_KEY = 'chill_3party.key_label.'; /** * @var ThirdPartyTypeProviderInterface[] diff --git a/src/Bundle/ChillWopiBundle/src/Controller/Convert.php b/src/Bundle/ChillWopiBundle/src/Controller/Convert.php index d7e90e46a..665386ffe 100644 --- a/src/Bundle/ChillWopiBundle/src/Controller/Convert.php +++ b/src/Bundle/ChillWopiBundle/src/Controller/Convert.php @@ -35,17 +35,17 @@ class Convert { private const LOG_PREFIX = '[convert] '; - private string $collaboraDomain; + private readonly string $collaboraDomain; /** * @param StoredObjectManager $storedObjectManager */ public function __construct( - private HttpClientInterface $httpClient, - private RequestStack $requestStack, - private Security $security, - private StoredObjectManagerInterface $storedObjectManager, - private LoggerInterface $logger, + private readonly HttpClientInterface $httpClient, + private readonly RequestStack $requestStack, + private readonly Security $security, + private readonly StoredObjectManagerInterface $storedObjectManager, + private readonly LoggerInterface $logger, ParameterBagInterface $parameters ) { $this->collaboraDomain = $parameters->get('wopi')['server']; diff --git a/src/Bundle/ChillWopiBundle/src/Controller/Editor.php b/src/Bundle/ChillWopiBundle/src/Controller/Editor.php index ec10cc973..7280e7fca 100644 --- a/src/Bundle/ChillWopiBundle/src/Controller/Editor.php +++ b/src/Bundle/ChillWopiBundle/src/Controller/Editor.php @@ -36,7 +36,7 @@ use Twig\Environment; * @internal * @coversNothing */ -final class Editor +final readonly class Editor { public function __construct(private ConfigurationInterface $wopiConfiguration, private DiscoveryInterface $wopiDiscovery, private DocumentManagerInterface $documentManager, private EngineInterface $engine, private JWTTokenManagerInterface $JWTTokenManager, private NormalizerInterface $normalizer, private ResponderInterface $responder, private Security $security, private Psr17Interface $psr17, private RouterInterface $router) { diff --git a/src/Bundle/ChillWopiBundle/src/Service/Controller/Responder.php b/src/Bundle/ChillWopiBundle/src/Service/Controller/Responder.php index af22cf952..b85d1b8b3 100644 --- a/src/Bundle/ChillWopiBundle/src/Service/Controller/Responder.php +++ b/src/Bundle/ChillWopiBundle/src/Service/Controller/Responder.php @@ -20,7 +20,7 @@ use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Serializer\SerializerInterface; use Twig\Environment; -final class Responder implements ResponderInterface +final readonly class Responder implements ResponderInterface { public function __construct(private Environment $twig, private UrlGeneratorInterface $urlGenerator, private SerializerInterface $serializer) { @@ -51,12 +51,7 @@ final class Responder implements ResponderInterface ->serialize( $data, 'json', - array_merge( - [ - 'json_encode_options' => JsonResponse::DEFAULT_ENCODING_OPTIONS, - ], - $context - ) + ['json_encode_options' => JsonResponse::DEFAULT_ENCODING_OPTIONS, ...$context] ), $status, $headers, diff --git a/src/Bundle/ChillWopiBundle/src/Service/Wopi/AuthorizationManager.php b/src/Bundle/ChillWopiBundle/src/Service/Wopi/AuthorizationManager.php index 08cdec97e..53e9ad819 100644 --- a/src/Bundle/ChillWopiBundle/src/Service/Wopi/AuthorizationManager.php +++ b/src/Bundle/ChillWopiBundle/src/Service/Wopi/AuthorizationManager.php @@ -19,7 +19,7 @@ use Symfony\Component\Security\Core\Security; class AuthorizationManager implements \ChampsLibres\WopiBundle\Contracts\AuthorizationManagerInterface { - public function __construct(private JWTTokenManagerInterface $tokenManager, private Security $security) + public function __construct(private readonly JWTTokenManagerInterface $tokenManager, private readonly Security $security) { } diff --git a/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillDocumentLockManager.php b/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillDocumentLockManager.php index 358831f87..148b1fc8e 100644 --- a/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillDocumentLockManager.php +++ b/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillDocumentLockManager.php @@ -26,7 +26,7 @@ class ChillDocumentLockManager implements DocumentLockManagerInterface */ private const LOCK_GRACEFUL_DURATION_TIME = 3; - public function __construct(private ChillRedis $redis) + public function __construct(private readonly ChillRedis $redis) { } diff --git a/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillDocumentManager.php b/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillDocumentManager.php index 6084d4785..0963cf903 100644 --- a/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillDocumentManager.php +++ b/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillDocumentManager.php @@ -34,16 +34,16 @@ use function strlen; final class ChillDocumentManager implements DocumentManagerInterface { - private RequestInterface $request; + private readonly RequestInterface $request; public function __construct( - private DocumentLockManagerInterface $documentLockManager, - private EntityManagerInterface $entityManager, + private readonly DocumentLockManagerInterface $documentLockManager, + private readonly EntityManagerInterface $entityManager, HttpMessageFactoryInterface $httpMessageFactory, - private Psr17Interface $psr17, + private readonly Psr17Interface $psr17, RequestStack $requestStack, - private StoredObjectManagerInterface $storedObjectManager, - private StoredObjectRepository $storedObjectRepository + private readonly StoredObjectManagerInterface $storedObjectManager, + private readonly StoredObjectRepository $storedObjectRepository ) { $this->request = $httpMessageFactory->createRequest($requestStack->getCurrentRequest()); } diff --git a/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillWopi.php b/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillWopi.php index 88f863cd1..189b780b2 100644 --- a/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillWopi.php +++ b/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillWopi.php @@ -15,7 +15,7 @@ use ChampsLibres\WopiLib\Contract\Service\WopiInterface; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; -final class ChillWopi implements WopiInterface +final readonly class ChillWopi implements WopiInterface { public function __construct(private WopiInterface $wopi) { diff --git a/src/Bundle/ChillWopiBundle/src/Service/Wopi/UserManager.php b/src/Bundle/ChillWopiBundle/src/Service/Wopi/UserManager.php index 96ed5c651..4a0857521 100644 --- a/src/Bundle/ChillWopiBundle/src/Service/Wopi/UserManager.php +++ b/src/Bundle/ChillWopiBundle/src/Service/Wopi/UserManager.php @@ -17,7 +17,7 @@ use Symfony\Component\Security\Core\Security; class UserManager implements \ChampsLibres\WopiBundle\Contracts\UserManagerInterface { - public function __construct(private Security $security) + public function __construct(private readonly Security $security) { } From a0ae1f0d0f96e9036db1e24514f922f157fe9173 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 3 May 2023 12:11:00 +0200 Subject: [PATCH 060/724] FIX [budget] display budget element comment if it is of kind 'autre' --- .../Resources/views/Budget/_macros.html.twig | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_macros.html.twig b/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_macros.html.twig index 70e96d96c..dfa286af4 100644 --- a/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_macros.html.twig +++ b/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_macros.html.twig @@ -16,8 +16,14 @@
    {% if f.isResource %} {{ f.resource.name|localize_translatable_string }} + {% if f.resource.getKind is same as 'other' %} + : {{ f.getComment }} + {% endif %} {% else %} {{ f.charge.name|localize_translatable_string }} + {% if f.charge.getKind is same as 'other' %} + : {{ f.getComment }} + {% endif %} {% endif %} {{ f.amount|format_currency('EUR') }}{{ mm.mimeIcon(d.storedObject.type) }} - + {% if accompanyingCourse.hasUser and accompanyingCourse.user is not same as(app.user) %} + + + {% else %} + + {% endif %} + {{ d.storedObject|chill_document_button_group(d.title, is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_UPDATE', w), {'small': true}) }}
    - - - - - -
    {{ document.title }}{{ mm.mimeIcon(document.storedObject.type) }} - -
    -
    -{% endmacro %} {% if document is not null %} - + {% import "@ChillDocStore/Macro/macro_mimeicon.html.twig" as mm %}
    {% if is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_EVALUATION_DOCUMENT_SHOW', document) %} -
    - {% include '@ChillPerson/AccompanyingCourseWork/_objectifs_results_evaluations.html.twig' with { - 'w': document.accompanyingPeriodWorkEvaluation.accompanyingPeriodWork, - 'd': document.storedObject, - 'displayContent': 'short', - 'recordAction': _self.recordAction(document), - 'onlyone' : true, - 'evalId': document.accompanyingPeriodWorkEvaluation.id - } %} + {% set doc = document %} +
    +
    +

    {{ "Document"|trans }}: {{ doc.title }}

    +
    +
    +

    + + + {{ evaluation.accompanyingPeriodWork.socialAction|chill_entity_render_string }} +
      +
    • + {{ 'accompanying_course_work.start_date'|trans ~ ' : ' }} + {{ evaluation.accompanyingPeriodWork.startDate|format_date('short') }} +
    • + {% if evaluation.accompanyingPeriodWork.endDate %} +
    • + {{ 'accompanying_course_work.end_date'|trans ~ ' : ' }} + {{ evaluation.accompanyingPeriodWork.endDate|format_date('short') }} +
    • + {% endif %} +
    +
    +

    +
    +
    +
    +

    + {{ 'Participants'|trans }} +

    +
    +
    + {% for p in evaluation.accompanyingPeriodWork.persons %} + {% include '@ChillMain/OnTheFly/_insert_vue_onthefly.html.twig' with { + targetEntity: { name: 'person', id: p.id }, + action: 'show', + displayBadge: true, + buttonText: p|chill_entity_render_string, + isDead: p.deathdate is not null + } %} + {% endfor %} +
    +
    +
    + + + + + + + + + + + +
    +

    + {{ 'Évaluation'|trans }} +

    +
    +
      +
    • + {{ evaluation.evaluation.title|localize_translatable_string }} +
        +
      • + {{ 'accompanying_course_work.start_date'|trans ~ ' : ' }} + {{ evaluation.startDate|format_date('short') }} +
      • + {% if evaluation.endDate %} +
      • + {{ 'accompanying_course_work.end_date'|trans ~ ' : ' }} + {{ evaluation.endDate|format_date('short') }} +
      • + {% endif %} + {% if evaluation.maxDate %} +
      • + {{ 'accompanying_course_work.max_date'|trans ~ ' : ' }} + {{ evaluation.maxDate|format_date('short') }} +
      • + {% endif %} + {% if evaluation.warningInterval and evaluation.warningInterval.d > 0 %} +
      • + {% set days = (evaluation.warningInterval.d + evaluation.warningInterval.m * 30) %} + {{ 'accompanying_course_work.warning_interval'|trans ~ ' : ' }} + {{ 'accompanying_course_work.%days% days before max_date'|trans({'%days%': days }) }} +
      • + {% endif %} +
      • + {% if evaluation.createdBy is not null %} + créé par + {{ evaluation.createdBy.username }} + {% endif %} + {% if evaluation.createdAt is not null %} + {{ 'le'|trans }} + {{ evaluation.createdAt|format_date('short') }} + {% endif %} +
      • +
      + {% if evaluation.comment %} +
      + {{ evaluation.comment }} +
      + {% endif %} +
    • +
    +
    +
    +
    +
      +
    • + +
    • +
    +
    {% else %} From d815b4428011049720d34422e9ebfd663dfd9099 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 13 Jun 2023 23:05:34 +0200 Subject: [PATCH 204/724] DX: more type-hinting on AccompanyingPeriodWork --- .../Entity/AccompanyingPeriod/AccompanyingPeriodWork.php | 4 ++++ .../AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php index 5361012b3..e3b2883be 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php @@ -59,6 +59,7 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues * ) * @Serializer\Groups({"read", "docgen:read"}) * @ORM\OrderBy({"startDate": "DESC", "id": "DESC"}) + * @var Collection * * @internal /!\ the serialization for write evaluations is handled in `AccompanyingPeriodWorkDenormalizer` */ @@ -278,6 +279,9 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues return $this->accompanyingPeriod; } + /** + * @return Collection + */ public function getAccompanyingPeriodWorkEvaluations(): Collection { return $this->accompanyingPeriodWorkEvaluations; diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php index 8780f7d17..d35ffc900 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php @@ -79,6 +79,7 @@ class AccompanyingPeriodWorkEvaluation implements TrackCreationInterface, TrackU * ) * @ORM\OrderBy({"createdAt": "DESC", "id": "DESC"}) * @Serializer\Groups({"read"}) + * @var Collection */ private Collection $documents; @@ -204,7 +205,7 @@ class AccompanyingPeriodWorkEvaluation implements TrackCreationInterface, TrackU } /** - * @return Collection + * @return Collection */ public function getDocuments() { From 3b9fae3b49220c7f32c98837cfaa4aab6b31d945 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 13 Jun 2023 23:06:50 +0200 Subject: [PATCH 205/724] add changelog --- .changes/unreleased/Feature-20230613-230640.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changes/unreleased/Feature-20230613-230640.yaml diff --git a/.changes/unreleased/Feature-20230613-230640.yaml b/.changes/unreleased/Feature-20230613-230640.yaml new file mode 100644 index 000000000..18694c724 --- /dev/null +++ b/.changes/unreleased/Feature-20230613-230640.yaml @@ -0,0 +1,5 @@ +kind: Feature +body: Add notification to accompanying period work and work's evaluation's documents +time: 2023-06-13T23:06:40.090777525+02:00 +custom: + Issue: "" From 8a91be4ef39ae9ab8199664ee6d0a3fa77ef1abb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 13 Jun 2023 23:09:08 +0200 Subject: [PATCH 206/724] add changelog [ci-skip] --- .changes/unreleased/Fixed-20230613-230838.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changes/unreleased/Fixed-20230613-230838.yaml diff --git a/.changes/unreleased/Fixed-20230613-230838.yaml b/.changes/unreleased/Fixed-20230613-230838.yaml new file mode 100644 index 000000000..816f4f8d4 --- /dev/null +++ b/.changes/unreleased/Fixed-20230613-230838.yaml @@ -0,0 +1,5 @@ +kind: Fixed +body: Fix the notification counter +time: 2023-06-13T23:08:38.67342897+02:00 +custom: + Issue: "55" From 8fabfdd5c023571429ba5b2efa13d20b27c9fd96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 14 Jun 2023 22:54:18 +0200 Subject: [PATCH 207/724] Feature: [export] filter on accompanying period step: allow to check multiple steps --- .../unreleased/Feature-20230614-224720.yaml | 6 +++++ .../AccompanyingCourseFilters/StepFilter.php | 27 ++++++++++++------- 2 files changed, 24 insertions(+), 9 deletions(-) create mode 100644 .changes/unreleased/Feature-20230614-224720.yaml diff --git a/.changes/unreleased/Feature-20230614-224720.yaml b/.changes/unreleased/Feature-20230614-224720.yaml new file mode 100644 index 000000000..3f86b022f --- /dev/null +++ b/.changes/unreleased/Feature-20230614-224720.yaml @@ -0,0 +1,6 @@ +kind: Feature +body: '[Export] Filter accompanying period by step at date: allow to pick multiple + steps' +time: 2023-06-14T22:47:20.577100599+02:00 +custom: + Issue: "113" diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/StepFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/StepFilter.php index 8ee798c07..539aa9940 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/StepFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/StepFilter.php @@ -27,7 +27,11 @@ class StepFilter implements FilterInterface { private const A = 'acp_filter_bystep_stephistories'; - private const DEFAULT_CHOICE = AccompanyingPeriod::STEP_CONFIRMED; + private const DEFAULT_CHOICE = [ + AccompanyingPeriod::STEP_CONFIRMED, + AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_SHORT, + AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_LONG, + ]; private const P = 'acp_step_filter_date'; @@ -79,7 +83,7 @@ class StepFilter implements FilterInterface $qb->expr()->in(self::A . '.step', ':acp_filter_by_step_steps') ) ->setParameter(self::P, $this->rollingDateConverter->convert($data['calc_date'])) - ->setParameter('acp_filter_by_step_steps', $data['accepted_steps']); + ->setParameter('acp_filter_by_step_steps', $data['accepted_steps_multi']); } public function applyOn() @@ -90,25 +94,30 @@ class StepFilter implements FilterInterface public function buildForm(FormBuilderInterface $builder) { $builder - ->add('accepted_steps', ChoiceType::class, [ + ->add('accepted_steps_multi', ChoiceType::class, [ 'choices' => self::STEPS, - 'multiple' => false, + 'multiple' => true, 'expanded' => true, - 'empty_data' => self::DEFAULT_CHOICE, - 'data' => self::DEFAULT_CHOICE, ]) ->add('calc_date', PickRollingDateType::class, [ 'label' => 'export.filter.course.by_step.date_calc', - 'data' => new RollingDate(RollingDate::T_TODAY), ]); } + public function getFormDefaultData(): array + { + return [ + 'accepted_steps_multi' => self::DEFAULT_CHOICE, + 'calc_date' => new RollingDate(RollingDate::T_TODAY), + ]; + } + public function describeAction($data, $format = 'string') { - $step = array_flip(self::STEPS)[$data['accepted_steps']]; + $steps = array_map(fn (string $step) => $this->translator->trans(array_flip(self::STEPS)[$step]), $data['accepted_steps_multi']); return ['Filtered by steps: only %step%', [ - '%step%' => $this->translator->trans($step), + '%step%' => implode(', ', $steps), ]]; } From 398b63386393cd11a0a154e9a469ffc483d61aca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 14 Jun 2023 23:29:18 +0200 Subject: [PATCH 208/724] DX: simplify overlapsI expression in postgresql --- .changes/unreleased/DX-20230614-233000.yaml | 5 +++++ src/Bundle/ChillMainBundle/Doctrine/DQL/OverlapsI.php | 6 ++---- 2 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 .changes/unreleased/DX-20230614-233000.yaml diff --git a/.changes/unreleased/DX-20230614-233000.yaml b/.changes/unreleased/DX-20230614-233000.yaml new file mode 100644 index 000000000..ca4a3171b --- /dev/null +++ b/.changes/unreleased/DX-20230614-233000.yaml @@ -0,0 +1,5 @@ +kind: DX +body: 'DQL function OVERLAPSI: simplify expression in postgresql' +time: 2023-06-14T23:30:00.217427234+02:00 +custom: + Issue: "" diff --git a/src/Bundle/ChillMainBundle/Doctrine/DQL/OverlapsI.php b/src/Bundle/ChillMainBundle/Doctrine/DQL/OverlapsI.php index 29642dc15..d39c1451c 100644 --- a/src/Bundle/ChillMainBundle/Doctrine/DQL/OverlapsI.php +++ b/src/Bundle/ChillMainBundle/Doctrine/DQL/OverlapsI.php @@ -90,16 +90,14 @@ class OverlapsI extends FunctionNode if ($part instanceof PathExpression) { return sprintf( - "CASE WHEN %s IS NOT NULL THEN %s ELSE '%s'::date END", - $part->dispatch($sqlWalker), + "COALESCE(%s, '%s'::date)", $part->dispatch($sqlWalker), $p ); } return sprintf( - "CASE WHEN %s::date IS NOT NULL THEN %s::date ELSE '%s'::date END", - $part->dispatch($sqlWalker), + "COALESCE(%s::date, '%s'::date)", $part->dispatch($sqlWalker), $p ); From fe936ac0f2aab826149a226efb5d631efc0d76b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 14 Jun 2023 23:31:43 +0200 Subject: [PATCH 209/724] Feature: [export][course] filter course by step, between two dates --- .../unreleased/Feature-20230614-233107.yaml | 5 + .../StepFilterBetweenDates.php | 125 ++++++++++++++++++ .../{StepFilter.php => StepFilterOnDate.php} | 5 +- .../StepFilterTest.php | 4 +- .../services/exports_accompanying_course.yaml | 7 +- .../translations/messages.fr.yml | 7 +- 6 files changed, 146 insertions(+), 7 deletions(-) create mode 100644 .changes/unreleased/Feature-20230614-233107.yaml create mode 100644 src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/StepFilterBetweenDates.php rename src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/{StepFilter.php => StepFilterOnDate.php} (95%) diff --git a/.changes/unreleased/Feature-20230614-233107.yaml b/.changes/unreleased/Feature-20230614-233107.yaml new file mode 100644 index 000000000..2d0e502f2 --- /dev/null +++ b/.changes/unreleased/Feature-20230614-233107.yaml @@ -0,0 +1,5 @@ +kind: Feature +body: '[export] add a filter on accompanying period: filter by step between two dates' +time: 2023-06-14T23:31:07.979389911+02:00 +custom: + Issue: "113" diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/StepFilterBetweenDates.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/StepFilterBetweenDates.php new file mode 100644 index 000000000..9033c64b3 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/StepFilterBetweenDates.php @@ -0,0 +1,125 @@ + AccompanyingPeriod::STEP_DRAFT, + 'course.confirmed' => AccompanyingPeriod::STEP_CONFIRMED, + 'course.closed' => AccompanyingPeriod::STEP_CLOSED, + 'course.inactive_short' => AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_SHORT, + 'course.inactive_long' => AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_LONG, + ]; + + private RollingDateConverterInterface $rollingDateConverter; + + private TranslatorInterface $translator; + + public function __construct( + RollingDateConverterInterface $rollingDateConverter, + TranslatorInterface $translator + ) { + $this->rollingDateConverter = $rollingDateConverter; + $this->translator = $translator; + } + + public function addRole(): ?string + { + return null; + } + + public function alterQuery(QueryBuilder $qb, $data) + { + $alias = 'acp_filter_by_step_between_dat_alias'; + $steps = 'acp_filter_by_step_between_dat_steps'; + $from = 'acp_filter_by_step_between_dat_from'; + $to = 'acp_filter_by_step_between_dat_to'; + + $qb + ->andWhere( + $qb->expr()->exists( + "SELECT 1 FROM " . AccompanyingPeriod\AccompanyingPeriodStepHistory::class . " {$alias} " . + "WHERE {$alias}.step IN (:{$steps}) AND OVERLAPSI ({$alias}.startDate, {$alias}.endDate),(:{$from}, :{$to}) = TRUE " . + "AND {$alias}.period = acp" + ) + ) + ->setParameter($from, $this->rollingDateConverter->convert($data['date_from'])) + ->setParameter($to, $this->rollingDateConverter->convert($data['date_to'])) + ->setParameter($steps, $data['accepted_steps_multi']); + } + + public function applyOn() + { + return Declarations::ACP_TYPE; + } + + public function buildForm(FormBuilderInterface $builder) + { + $builder + ->add('accepted_steps_multi', ChoiceType::class, [ + 'label' => 'export.filter.course.by_step.steps', + 'choices' => self::STEPS, + 'multiple' => true, + 'expanded' => true, + ]) + ->add('date_from', PickRollingDateType::class, [ + 'label' => 'export.filter.course.by_step.date_from', + ]) + ->add('date_to', PickRollingDateType::class, [ + 'label' => 'export.filter.course.by_step.date_to', + ]); + } + + public function getFormDefaultData(): array + { + return [ + 'accepted_steps_multi' => self::DEFAULT_CHOICE, + 'date_from' => new RollingDate(RollingDate::T_YEAR_CURRENT_START), + 'date_to' => new RollingDate(RollingDate::T_TODAY), + ]; + } + + public function describeAction($data, $format = 'string') + { + $steps = array_map(fn (string $step) => $this->translator->trans(array_flip(self::STEPS)[$step]), $data['accepted_steps_multi']); + + return ['export.filter.course.by_step.Filtered by steps: only %step% and between %date_from% and %date_to%', [ + '%step%' => implode(', ', $steps), + '%date_from%' => $this->rollingDateConverter->convert($data['date_from'])->format('d-m-Y'), + '%date_to%' => $this->rollingDateConverter->convert($data['date_to'])->format('d-m-Y'), + ]]; + } + + public function getTitle() + { + return 'export.filter.course.by_step.Filter by step between dates'; + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/StepFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/StepFilterOnDate.php similarity index 95% rename from src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/StepFilter.php rename to src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/StepFilterOnDate.php index 539aa9940..357ed6f30 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/StepFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/StepFilterOnDate.php @@ -23,7 +23,7 @@ use Symfony\Component\Form\FormBuilderInterface; use Symfony\Contracts\Translation\TranslatorInterface; use function in_array; -class StepFilter implements FilterInterface +class StepFilterOnDate implements FilterInterface { private const A = 'acp_filter_bystep_stephistories'; @@ -95,6 +95,7 @@ class StepFilter implements FilterInterface { $builder ->add('accepted_steps_multi', ChoiceType::class, [ + 'label' => 'export.filter.course.by_step.steps', 'choices' => self::STEPS, 'multiple' => true, 'expanded' => true, @@ -123,6 +124,6 @@ class StepFilter implements FilterInterface public function getTitle() { - return 'Filter by step'; + return 'export.filter.course.by_step.Filter by step'; } } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/StepFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/StepFilterTest.php index 42eec5823..1b6224487 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/StepFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/StepFilterTest.php @@ -13,7 +13,7 @@ namespace Chill\PersonBundle\Tests\Export\Filter\AccompanyingCourseFilters; use Chill\MainBundle\Test\Export\AbstractFilterTest; use Chill\PersonBundle\Entity\AccompanyingPeriod; -use Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\StepFilter; +use Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\StepFilterOnDate; /** * @internal @@ -21,7 +21,7 @@ use Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\StepFilter; */ final class StepFilterTest extends AbstractFilterTest { - private StepFilter $filter; + private StepFilterOnDate $filter; protected function setUp(): void { diff --git a/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_course.yaml b/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_course.yaml index adde8d336..c299bbaaa 100644 --- a/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_course.yaml +++ b/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_course.yaml @@ -28,11 +28,14 @@ services: tags: - { name: chill.export_filter, alias: accompanyingcourse_socialissue_filter } - chill.person.export.filter_step: - class: Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\StepFilter + Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\StepFilterOnDate: tags: - { name: chill.export_filter, alias: accompanyingcourse_step_filter } + Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\StepFilterBetweenDates: + tags: + - { name: chill.export_filter, alias: accompanyingcourse_step_filter_between_dates } + chill.person.export.filter_geographicalunitstat: class: Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\GeographicalUnitStatFilter tags: diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 5cc9ee1f1..bdb93afc0 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -473,7 +473,6 @@ Accepted socialissues: Problématiques sociales "Filtered by socialissues: only %socialissues%": "Filtré par problématique sociale: uniquement %socialissues%" Group by social issue: Grouper les parcours par problématiques sociales -Filter by step: Filtrer les parcours par statut du parcours Accepted steps: Statuts Step: Statut "Filtered by steps: only %step%": "Filtré par statut du parcours: uniquement %step%" @@ -1085,7 +1084,13 @@ export: title: Filter les parcours par intervenant 'Filtered by user working on course: only %users%': 'Filtré par intervenants sur le parcours: seulement %users%' by_step: + Filter by step: Filtrer les parcours par statut du parcours + Filter by step between dates: Filtrer les parcours par statut du parcours entre deux dates + steps: Statuts retenus date_calc: Date de prise en compte du statut + date_from: Statuts acquis après cette date + date_to: Statuts acquis avant cette date + 'Filtered by steps: only %step% and between %date_from% and %date_to%': 'Filtré par statut: seulement %step%, entre %date_from% et %date_to%' by_user_scope: Computation date for referrer: Date à laquelle le référent était actif by_referrer: From 3fb97c3945f4e61ba118e7d9be16cc5d830338f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 16 Jun 2023 14:07:49 +0200 Subject: [PATCH 210/724] DX: comment the examples in rule definition As this is genearte error in both phpunits and php-cs-fixer --- ...BundleAddFormDefaultDataOnExportFilterAggregatorRector.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/rector/src/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector.php b/utils/rector/src/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector.php index e6bf4a75a..fe996c987 100644 --- a/utils/rector/src/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector.php +++ b/utils/rector/src/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector.php @@ -32,7 +32,7 @@ class ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector extends Abstra { return new RuleDefinition( 'Add a getFormDefault data method on exports, filters and aggregators, filled with default data', - [ + [/* << new RollingDate(RollingDate::T_TODAY), 'baz' => 'Castor']; } } -PHP +PHP */ ] ); } From c52ba06ea0a29e1149046ab24d21d53fb2f17453 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 16 Jun 2023 15:26:49 +0200 Subject: [PATCH 211/724] adapt rector rules for chained builder->add --- ...aultDataOnExportFilterAggregatorRector.php | 113 ++++++++++++------ ...-default-data-with-chained-builder.php.inc | 111 +++++++++++++++++ 2 files changed, 188 insertions(+), 36 deletions(-) create mode 100644 utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/Fixture/filter-multiple-reuse-data-on-form-default-data-with-chained-builder.php.inc diff --git a/utils/rector/src/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector.php b/utils/rector/src/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector.php index fe996c987..cc54a24f1 100644 --- a/utils/rector/src/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector.php +++ b/utils/rector/src/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector.php @@ -183,43 +183,11 @@ PHP */ if ($stmt instanceof Node\Stmt\Expression // it must be a method call && $stmt->expr instanceof Node\Expr\MethodCall - // the method call must be "add" - && $stmt->expr->name instanceof Node\Identifier - && $stmt->expr->name->name === 'add' - // and the method call must apply on the builder (compare with builderName) - && $stmt->expr->var instanceof Node\Expr\Variable - && $stmt->expr->var->name === $builderName - // it must have a first argument, a string - // TODO what happens if a value, or a const ? - && ($stmt->expr->args[0] ?? null) instanceof Node\Arg - && $stmt->expr->args[0]->value instanceof Node\Scalar\String_ - // and a third argument, an array - && ($stmt->expr->args[2] ?? null) instanceof Node\Arg - && $stmt->expr->args[2]->value instanceof Node\Expr\Array_ + && false !== ($results = $this->handleMethodCallBuilderAdd($stmt->expr, $builderName)) ) { - - // we parse on the 3rd argument, to find if there is an 'empty_data' key - $emptyDataIndex = null; - foreach ($stmt->expr->args[2]->value->items as $arrayItemIndex => $item) { - /* @phpstan-ignore-next-line */ - if ($item->key->value === 'data') { - $k = $stmt->expr->args[0]->value->value; - $emptyDataToReplace[$k] = $item->value; - $emptyDataIndex = $arrayItemIndex; - } - } - - if (null !== $emptyDataIndex) { - $stmt->expr->args[2]->value->items = array_values( - array_filter( - $stmt->expr->args[2]->value->items, - /* @phpstan-ignore-next-line */ - fn (Node\Expr\ArrayItem $item) => $item->key->value !== 'data' - ) - ); - } - - $newStmts[] = $stmt; + ['stmt' => $newMethodCAll, 'emptyDataToReplace' => $newEmptyDataToReplace] = $results; + $newStmts[] = new Node\Stmt\Expression($newMethodCAll); + $emptyDataToReplace = [...$emptyDataToReplace, ...$newEmptyDataToReplace]; } else { $newStmts[] = $stmt; } @@ -229,4 +197,77 @@ PHP */ return ['build_form_method' => $buildFormMethod, "empty_to_replace" => $emptyDataToReplace]; } + + private function handleMethodCallBuilderAdd(Node\Expr\MethodCall $methodCall, string $builderName): array|false + { + $emptyDataToReplace = []; + // check for chained method call + if ( + // this means that the MethodCall apply on another method call: a chained + $methodCall->var instanceof Node\Expr\MethodCall + ) { + // as this is chained, we make a recursion on this method + + $resultFormDeepMethodCall = $this->handleMethodCallBuilderAdd($methodCall->var, $builderName); + + if (false === $resultFormDeepMethodCall) { + return false; + } + + ['stmt' => $chainedMethodCall, 'emptyDataToReplace' => $newEmptyDataToReplace] = $resultFormDeepMethodCall; + $emptyDataToReplace = $newEmptyDataToReplace; + $methodCall->var = $chainedMethodCall; + } + + if ( + $methodCall->var instanceof Node\Expr\Variable + ) { + if ($methodCall->var->name !== $builderName) { + // ho, this does not apply on a builder, so we cancel all the method calls + return false; + } + } + + if ($methodCall->name instanceof Node\Identifier && $methodCall->name->name !== 'add') { + return ['stmt' => $methodCall, 'emptyDataToReplace' => $emptyDataToReplace]; + } + + if ( + // the method call must be "add" + $methodCall->name instanceof Node\Identifier + && $methodCall->name->name === 'add' + // it must have a first argument, a string + // TODO what happens if a value, or a const ? + && ($methodCall->args[0] ?? null) instanceof Node\Arg + && $methodCall->args[0]->value instanceof Node\Scalar\String_ + // and a third argument, an array + && ($methodCall->args[2] ?? null) instanceof Node\Arg + && $methodCall->args[2]->value instanceof Node\Expr\Array_ + ) { + // we parse on the 3rd argument, to find if there is an 'empty_data' key + $emptyDataIndex = null; + foreach ($methodCall->args[2]->value->items as $arrayItemIndex => $item) { + /* @phpstan-ignore-next-line */ + if ($item->key->value === 'data' or $item->key->value === 'empty_data') { + $k = $methodCall->args[0]->value->value; + $emptyDataToReplace[$k] = $item->value; + $emptyDataIndex = $arrayItemIndex; + } + } + + if (null !== $emptyDataIndex) { + $methodCall->args[2]->value->items = array_values( + array_filter( + $methodCall->args[2]->value->items, + /* @phpstan-ignore-next-line */ + fn (Node\Expr\ArrayItem $item) => $item->key->value !== 'data' + ) + ); + } + + return ['stmt' => $methodCall, 'emptyDataToReplace' => $emptyDataToReplace]; + } + + throw new \RuntimeException("Not supported situation"); + } } diff --git a/utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/Fixture/filter-multiple-reuse-data-on-form-default-data-with-chained-builder.php.inc b/utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/Fixture/filter-multiple-reuse-data-on-form-default-data-with-chained-builder.php.inc new file mode 100644 index 000000000..ed46f6381 --- /dev/null +++ b/utils/rector/tests/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector/Fixture/filter-multiple-reuse-data-on-form-default-data-with-chained-builder.php.inc @@ -0,0 +1,111 @@ +add('foo', PickRollingDateType::class, [ + 'label' => 'Test thing', + 'data' => new RollingDate(RollingDate::T_TODAY) + ]) + ->anotherCall('test') + ->add('baz', TextType::class, [ + 'label' => 'OrNiCar', + 'data' => 'Castor' + ]) + ->baz('foo'); + } + + public function getTitle() + { + // TODO: Implement getTitle() method. + } + + public function addRole(): ?string + { + // TODO: Implement addRole() method. + } + + public function alterQuery(QueryBuilder $qb, $data) + { + // TODO: Implement alterQuery() method. + } + + public function applyOn() + { + // TODO: Implement applyOn() method. + } +} +?> +----- +add('foo', PickRollingDateType::class, [ + 'label' => 'Test thing' + ]) + ->anotherCall('test') + ->add('baz', TextType::class, [ + 'label' => 'OrNiCar' + ]) + ->baz('foo'); + } + public function getFormDefaultData(): array + { + return ['foo' => new RollingDate(RollingDate::T_TODAY), 'baz' => 'Castor']; + } + + public function getTitle() + { + // TODO: Implement getTitle() method. + } + + public function addRole(): ?string + { + // TODO: Implement addRole() method. + } + + public function alterQuery(QueryBuilder $qb, $data) + { + // TODO: Implement alterQuery() method. + } + + public function applyOn() + { + // TODO: Implement applyOn() method. + } +} +?> From 960acb8c0ac32467743bab2f9b09c3f3580af353 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sun, 18 Jun 2023 11:57:26 +0200 Subject: [PATCH 212/724] Revert "apply rector rules for exports" This reverts commit 3adf3625 --- docs/source/_static/code/exports/BirthdateFilter.php | 6 ++---- docs/source/_static/code/exports/CountPerson.php | 4 ---- .../ACPAggregators/ByActivityNumberAggregator.php | 4 ---- .../Aggregator/ACPAggregators/ByCreatorAggregator.php | 4 ---- .../ACPAggregators/BySocialActionAggregator.php | 4 ---- .../Aggregator/ACPAggregators/BySocialIssueAggregator.php | 4 ---- .../Aggregator/ACPAggregators/ByThirdpartyAggregator.php | 4 ---- .../Aggregator/ACPAggregators/CreatorScopeAggregator.php | 4 ---- .../Export/Aggregator/ACPAggregators/DateAggregator.php | 6 ++---- .../Aggregator/ACPAggregators/LocationTypeAggregator.php | 4 ---- .../Export/Aggregator/ActivityTypeAggregator.php | 4 ---- .../Export/Aggregator/ActivityUserAggregator.php | 4 ---- .../Export/Aggregator/ActivityUsersAggregator.php | 4 ---- .../Export/Aggregator/ActivityUsersJobAggregator.php | 4 ---- .../Export/Aggregator/ActivityUsersScopeAggregator.php | 4 ---- .../PersonAggregators/ActivityReasonAggregator.php | 4 ---- .../Export/Aggregator/SentReceivedAggregator.php | 4 ---- .../Export/Export/LinkedToACP/AvgActivityDuration.php | 4 ---- .../Export/LinkedToACP/AvgActivityVisitDuration.php | 4 ---- .../Export/Export/LinkedToACP/CountActivity.php | 4 ---- .../Export/Export/LinkedToACP/SumActivityDuration.php | 4 ---- .../Export/LinkedToACP/SumActivityVisitDuration.php | 4 ---- .../Export/Export/LinkedToPerson/CountActivity.php | 4 ---- .../Export/Export/LinkedToPerson/StatActivityDuration.php | 4 ---- .../Export/Filter/ACPFilters/ActivityTypeFilter.php | 4 ---- .../Export/Filter/ACPFilters/ByCreatorFilter.php | 4 ---- .../Export/Filter/ACPFilters/BySocialActionFilter.php | 4 ---- .../Export/Filter/ACPFilters/BySocialIssueFilter.php | 4 ---- .../Export/Filter/ACPFilters/EmergencyFilter.php | 6 ++---- .../Export/Filter/ACPFilters/HasNoActivityFilter.php | 4 ---- .../Export/Filter/ACPFilters/LocationFilter.php | 4 ---- .../Export/Filter/ACPFilters/LocationTypeFilter.php | 4 ---- .../Export/Filter/ACPFilters/SentReceivedFilter.php | 5 +---- .../Export/Filter/ACPFilters/UserFilter.php | 4 ---- .../Export/Filter/ACPFilters/UserScopeFilter.php | 4 ---- .../Export/Filter/ActivityDateFilter.php | 4 ---- .../Export/Filter/ActivityTypeFilter.php | 4 ---- .../Export/Filter/ActivityUsersFilter.php | 4 ---- .../Export/Filter/PersonFilters/ActivityReasonFilter.php | 4 ---- .../PersonHavingActivityBetweenDateFilter.php | 7 +++---- .../ChillActivityBundle/Export/Filter/UsersJobFilter.php | 4 ---- .../Export/Filter/UsersScopeFilter.php | 4 ---- .../src/Export/Aggregator/ByActivityTypeAggregator.php | 4 ---- .../src/Export/Aggregator/ByUserJobAggregator.php | 4 ---- .../src/Export/Aggregator/ByUserScopeAggregator.php | 4 ---- .../src/Export/Export/AvgAsideActivityDuration.php | 4 ---- .../src/Export/Export/CountAsideActivity.php | 4 ---- .../src/Export/Export/SumAsideActivityDuration.php | 4 ---- .../src/Export/Filter/ByActivityTypeFilter.php | 4 ---- .../src/Export/Filter/ByDateFilter.php | 4 ---- .../src/Export/Filter/ByUserFilter.php | 4 ---- .../src/Export/Filter/ByUserJobFilter.php | 4 ---- .../src/Export/Filter/ByUserScopeFilter.php | 4 ---- .../Export/Aggregator/AgentAggregator.php | 4 ---- .../Export/Aggregator/CancelReasonAggregator.php | 4 ---- .../Export/Aggregator/JobAggregator.php | 4 ---- .../Export/Aggregator/LocationAggregator.php | 4 ---- .../Export/Aggregator/LocationTypeAggregator.php | 4 ---- .../Export/Aggregator/MonthYearAggregator.php | 4 ---- .../Export/Aggregator/ScopeAggregator.php | 4 ---- .../Export/Aggregator/UrgencyAggregator.php | 4 ---- .../ChillCalendarBundle/Export/Export/CountCalendars.php | 4 ---- .../Export/Export/StatCalendarAvgDuration.php | 4 ---- .../Export/Export/StatCalendarSumDuration.php | 4 ---- .../ChillCalendarBundle/Export/Filter/AgentFilter.php | 4 ---- .../Export/Filter/BetweenDatesFilter.php | 4 ---- .../Export/Filter/CalendarRangeFilter.php | 5 +---- .../ChillCalendarBundle/Export/Filter/JobFilter.php | 4 ---- .../ChillCalendarBundle/Export/Filter/ScopeFilter.php | 4 ---- .../AdministrativeLocationAggregator.php | 4 ---- .../ByActionNumberAggregator.php | 4 ---- .../ClosingMotiveAggregator.php | 4 ---- .../ConfidentialAggregator.php | 4 ---- .../CreatorJobAggregator.php | 4 ---- .../AccompanyingCourseAggregators/DurationAggregator.php | 4 ---- .../AccompanyingCourseAggregators/EmergencyAggregator.php | 4 ---- .../EvaluationAggregator.php | 4 ---- .../GeographicalUnitStatAggregator.php | 4 ---- .../AccompanyingCourseAggregators/IntensityAggregator.php | 4 ---- .../AccompanyingCourseAggregators/OriginAggregator.php | 4 ---- .../AccompanyingCourseAggregators/ReferrerAggregator.php | 5 +---- .../ReferrerScopeAggregator.php | 5 +---- .../AccompanyingCourseAggregators/RequestorAggregator.php | 4 ---- .../AccompanyingCourseAggregators/ScopeAggregator.php | 4 ---- .../SocialActionAggregator.php | 4 ---- .../SocialIssueAggregator.php | 4 ---- .../AccompanyingCourseAggregators/StepAggregator.php | 8 +++----- .../AccompanyingCourseAggregators/UserJobAggregator.php | 4 ---- .../EvaluationAggregators/ByEndDateAggregator.php | 5 +---- .../EvaluationAggregators/ByMaxDateAggregator.php | 5 +---- .../EvaluationAggregators/ByStartDateAggregator.php | 5 +---- .../EvaluationAggregators/EvaluationTypeAggregator.php | 4 ---- .../EvaluationAggregators/HavingEndDateAggregator.php | 4 ---- .../HouseholdAggregators/ChildrenNumberAggregator.php | 8 +++----- .../HouseholdAggregators/CompositionAggregator.php | 8 +++----- .../Export/Aggregator/PersonAggregators/AgeAggregator.php | 5 +---- .../ByHouseholdCompositionAggregator.php | 5 +---- .../PersonAggregators/CountryOfBirthAggregator.php | 4 ---- .../Aggregator/PersonAggregators/GenderAggregator.php | 4 ---- .../PersonAggregators/GeographicalUnitAggregator.php | 4 ---- .../PersonAggregators/HouseholdPositionAggregator.php | 5 +---- .../SocialWorkAggregators/ActionTypeAggregator.php | 4 ---- .../SocialWorkAggregators/CurrentActionAggregator.php | 4 ---- .../Aggregator/SocialWorkAggregators/GoalAggregator.php | 4 ---- .../SocialWorkAggregators/GoalResultAggregator.php | 4 ---- .../Aggregator/SocialWorkAggregators/JobAggregator.php | 4 ---- .../SocialWorkAggregators/ReferrerAggregator.php | 4 ---- .../Aggregator/SocialWorkAggregators/ResultAggregator.php | 4 ---- .../Aggregator/SocialWorkAggregators/ScopeAggregator.php | 4 ---- .../Export/Export/CountAccompanyingCourse.php | 4 ---- .../Export/Export/CountAccompanyingPeriodWork.php | 4 ---- .../ChillPersonBundle/Export/Export/CountEvaluation.php | 4 ---- .../ChillPersonBundle/Export/Export/CountHousehold.php | 5 +---- .../Export/Export/CountPersonWithAccompanyingCourse.php | 4 ---- .../Export/Export/ListPersonDuplicate.php | 5 +---- .../Export/Export/StatAccompanyingCourseDuration.php | 5 +---- .../AccompanyingCourseFilters/ActiveOnDateFilter.php | 8 +++----- .../ActiveOneDayBetweenDatesFilter.php | 4 ---- .../AdministrativeLocationFilter.php | 4 ---- .../AccompanyingCourseFilters/ClosingMotiveFilter.php | 4 ---- .../AccompanyingCourseFilters/ConfidentialFilter.php | 6 ++---- .../Filter/AccompanyingCourseFilters/CreatorFilter.php | 4 ---- .../Filter/AccompanyingCourseFilters/CreatorJobFilter.php | 4 ---- .../Filter/AccompanyingCourseFilters/EmergencyFilter.php | 6 ++---- .../Filter/AccompanyingCourseFilters/EvaluationFilter.php | 4 ---- .../GeographicalUnitStatFilter.php | 4 ---- .../AccompanyingCourseFilters/HasNoActionFilter.php | 4 ---- .../AccompanyingCourseFilters/HasNoReferrerFilter.php | 5 +---- .../HasTemporaryLocationFilter.php | 4 ---- .../HavingAnAccompanyingPeriodInfoWithinDatesFilter.php | 4 ---- .../Filter/AccompanyingCourseFilters/IntensityFilter.php | 5 +---- .../AccompanyingCourseFilters/OpenBetweenDatesFilter.php | 4 ---- .../Filter/AccompanyingCourseFilters/OriginFilter.php | 4 ---- .../Filter/AccompanyingCourseFilters/ReferrerFilter.php | 4 ---- .../Filter/AccompanyingCourseFilters/RequestorFilter.php | 5 +---- .../AccompanyingCourseFilters/SocialActionFilter.php | 4 ---- .../AccompanyingCourseFilters/SocialIssueFilter.php | 4 ---- .../Filter/AccompanyingCourseFilters/StepFilter.php | 4 ---- .../Filter/AccompanyingCourseFilters/UserJobFilter.php | 4 ---- .../Filter/AccompanyingCourseFilters/UserScopeFilter.php | 4 ---- .../UserWorkingOnCourseFilter.php | 4 ---- .../Export/Filter/EvaluationFilters/ByEndDateFilter.php | 4 ---- .../Export/Filter/EvaluationFilters/ByStartDateFilter.php | 4 ---- .../Filter/EvaluationFilters/CurrentEvaluationsFilter.php | 4 ---- .../Filter/EvaluationFilters/EvaluationTypeFilter.php | 4 ---- .../Export/Filter/EvaluationFilters/MaxDateFilter.php | 4 ---- .../Export/Filter/HouseholdFilters/CompositionFilter.php | 4 ---- .../Filter/PersonFilters/AddressRefStatusFilter.php | 4 ---- .../Export/Filter/PersonFilters/BirthdateFilter.php | 6 ++---- .../Filter/PersonFilters/ByHouseholdCompositionFilter.php | 4 ---- .../Export/Filter/PersonFilters/DeadOrAliveFilter.php | 5 +---- .../Export/Filter/PersonFilters/DeathdateFilter.php | 6 ++---- .../Export/Filter/PersonFilters/GenderFilter.php | 4 ---- .../Filter/PersonFilters/GeographicalUnitFilter.php | 4 ---- .../Export/Filter/PersonFilters/MaritalStatusFilter.php | 4 ---- .../Export/Filter/PersonFilters/NationalityFilter.php | 4 ---- .../ResidentialAddressAtThirdpartyFilter.php | 5 +---- .../PersonFilters/ResidentialAddressAtUserFilter.php | 5 +---- .../Filter/PersonFilters/WithoutHouseholdComposition.php | 5 +---- .../AccompanyingPeriodWorkEndDateBetweenDateFilter.php | 4 ---- .../AccompanyingPeriodWorkStartDateBetweenDateFilter.php | 4 ---- .../Filter/SocialWorkFilters/CurrentActionFilter.php | 4 ---- .../Export/Filter/SocialWorkFilters/JobFilter.php | 4 ---- .../Export/Filter/SocialWorkFilters/ReferrerFilter.php | 4 ---- .../Export/Filter/SocialWorkFilters/ScopeFilter.php | 4 ---- .../Filter/SocialWorkFilters/SocialWorkTypeFilter.php | 4 ---- .../ChillReportBundle/Export/Filter/ReportDateFilter.php | 6 ++---- 167 files changed, 51 insertions(+), 672 deletions(-) diff --git a/docs/source/_static/code/exports/BirthdateFilter.php b/docs/source/_static/code/exports/BirthdateFilter.php index e25d8b42f..64c1d53a9 100644 --- a/docs/source/_static/code/exports/BirthdateFilter.php +++ b/docs/source/_static/code/exports/BirthdateFilter.php @@ -62,6 +62,7 @@ class BirthdateFilter implements ExportElementValidatedInterface, FilterInterfac { $builder->add('date_from', DateType::class, [ 'label' => 'Born after this date', + 'data' => new DateTime(), 'attr' => ['class' => 'datepicker'], 'widget' => 'single_text', 'format' => 'dd-MM-yyyy', @@ -69,15 +70,12 @@ class BirthdateFilter implements ExportElementValidatedInterface, FilterInterfac $builder->add('date_to', DateType::class, [ 'label' => 'Born before this date', + 'data' => new DateTime(), 'attr' => ['class' => 'datepicker'], 'widget' => 'single_text', 'format' => 'dd-MM-yyyy', ]); } - public function getFormDefaultData(): array - { - return ['date_from' => new DateTime(), 'date_to' => new DateTime()]; - } // here, we create a simple string which will describe the action of // the filter in the Response diff --git a/docs/source/_static/code/exports/CountPerson.php b/docs/source/_static/code/exports/CountPerson.php index be800e52c..afe19c73b 100644 --- a/docs/source/_static/code/exports/CountPerson.php +++ b/docs/source/_static/code/exports/CountPerson.php @@ -36,10 +36,6 @@ class CountPerson implements ExportInterface { // this export does not add any form } - public function getFormDefaultData(): array - { - return []; - } public function getAllowedFormattersTypes() { diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByActivityNumberAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByActivityNumberAggregator.php index c23db738e..5c6656009 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByActivityNumberAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByActivityNumberAggregator.php @@ -40,10 +40,6 @@ class ByActivityNumberAggregator implements AggregatorInterface { // No form needed } - public function getFormDefaultData(): array - { - return []; - } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByCreatorAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByCreatorAggregator.php index 917459de3..69149737b 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByCreatorAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByCreatorAggregator.php @@ -52,10 +52,6 @@ class ByCreatorAggregator implements AggregatorInterface { // no form } - public function getFormDefaultData(): array - { - return []; - } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialActionAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialActionAggregator.php index 1a75357ae..89732412d 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialActionAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialActionAggregator.php @@ -57,10 +57,6 @@ class BySocialActionAggregator implements AggregatorInterface { // no form } - public function getFormDefaultData(): array - { - return []; - } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialIssueAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialIssueAggregator.php index 9100a8c8f..158e87664 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialIssueAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialIssueAggregator.php @@ -57,10 +57,6 @@ class BySocialIssueAggregator implements AggregatorInterface { // no form } - public function getFormDefaultData(): array - { - return []; - } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByThirdpartyAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByThirdpartyAggregator.php index ac05b153c..c3ca6d59c 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByThirdpartyAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByThirdpartyAggregator.php @@ -57,10 +57,6 @@ class ByThirdpartyAggregator implements AggregatorInterface { // no form } - public function getFormDefaultData(): array - { - return []; - } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/CreatorScopeAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/CreatorScopeAggregator.php index a4b5258e2..2c7ec1483 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/CreatorScopeAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/CreatorScopeAggregator.php @@ -57,10 +57,6 @@ class CreatorScopeAggregator implements AggregatorInterface { // no form } - public function getFormDefaultData(): array - { - return []; - } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/DateAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/DateAggregator.php index e0fa215f3..a2f465a38 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/DateAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/DateAggregator.php @@ -75,12 +75,10 @@ class DateAggregator implements AggregatorInterface 'choices' => self::CHOICES, 'multiple' => false, 'expanded' => true, + 'empty_data' => self::DEFAULT_CHOICE, + 'data' => self::DEFAULT_CHOICE, ]); } - public function getFormDefaultData(): array - { - return ['frequency' => self::DEFAULT_CHOICE]; - } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/LocationTypeAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/LocationTypeAggregator.php index c72609e2c..ec4ce6315 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/LocationTypeAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/LocationTypeAggregator.php @@ -57,10 +57,6 @@ class LocationTypeAggregator implements AggregatorInterface { // no form } - public function getFormDefaultData(): array - { - return []; - } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php index a74428b4a..7cd16718e 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php @@ -60,10 +60,6 @@ class ActivityTypeAggregator implements AggregatorInterface { // no form required for this aggregator } - public function getFormDefaultData(): array - { - return []; - } public function getLabels($key, array $values, $data): Closure { diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUserAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUserAggregator.php index 2fab2af83..9bde692c6 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUserAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUserAggregator.php @@ -58,10 +58,6 @@ class ActivityUserAggregator implements AggregatorInterface { // nothing to add } - public function getFormDefaultData(): array - { - return []; - } public function getLabels($key, $values, $data): Closure { diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersAggregator.php index e1e9f161d..139f2743e 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersAggregator.php @@ -56,10 +56,6 @@ class ActivityUsersAggregator implements AggregatorInterface { // nothing to add on the form } - public function getFormDefaultData(): array - { - return []; - } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersJobAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersJobAggregator.php index 721078989..5741a0e58 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersJobAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersJobAggregator.php @@ -55,10 +55,6 @@ class ActivityUsersJobAggregator implements \Chill\MainBundle\Export\AggregatorI { // nothing to add in the form } - public function getFormDefaultData(): array - { - return []; - } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersScopeAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersScopeAggregator.php index d7932e9e8..15da300be 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersScopeAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersScopeAggregator.php @@ -55,10 +55,6 @@ class ActivityUsersScopeAggregator implements \Chill\MainBundle\Export\Aggregato { // nothing to add in the form } - public function getFormDefaultData(): array - { - return []; - } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/PersonAggregators/ActivityReasonAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/PersonAggregators/ActivityReasonAggregator.php index 2537f2cf6..eaccf95cb 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/PersonAggregators/ActivityReasonAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/PersonAggregators/ActivityReasonAggregator.php @@ -110,10 +110,6 @@ class ActivityReasonAggregator implements AggregatorInterface, ExportElementVali ] ); } - public function getFormDefaultData(): array - { - return []; - } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/SentReceivedAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/SentReceivedAggregator.php index ae1dae375..5f772e156 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/SentReceivedAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/SentReceivedAggregator.php @@ -47,10 +47,6 @@ class SentReceivedAggregator implements AggregatorInterface { // No form needed } - public function getFormDefaultData(): array - { - return []; - } public function getLabels($key, array $values, $data): callable { diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php index 6930784d3..34771d077 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php @@ -39,10 +39,6 @@ class AvgActivityDuration implements ExportInterface, GroupedExportInterface public function buildForm(FormBuilderInterface $builder) { } - public function getFormDefaultData(): array - { - return []; - } public function getAllowedFormattersTypes(): array { diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php index f1e926c64..df21362cd 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php @@ -40,10 +40,6 @@ class AvgActivityVisitDuration implements ExportInterface, GroupedExportInterfac { // TODO: Implement buildForm() method. } - public function getFormDefaultData(): array - { - return []; - } public function getAllowedFormattersTypes(): array { diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php index d473a925a..6b7b1562d 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php @@ -39,10 +39,6 @@ class CountActivity implements ExportInterface, GroupedExportInterface public function buildForm(FormBuilderInterface $builder) { } - public function getFormDefaultData(): array - { - return []; - } public function getAllowedFormattersTypes(): array { diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php index 8adb3b77f..e916cab54 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php @@ -40,10 +40,6 @@ class SumActivityDuration implements ExportInterface, GroupedExportInterface { // TODO: Implement buildForm() method. } - public function getFormDefaultData(): array - { - return []; - } public function getAllowedFormattersTypes(): array { diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php index cc424e68b..18a47289c 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php @@ -40,10 +40,6 @@ class SumActivityVisitDuration implements ExportInterface, GroupedExportInterfac { // TODO: Implement buildForm() method. } - public function getFormDefaultData(): array - { - return []; - } public function getAllowedFormattersTypes(): array { diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/CountActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/CountActivity.php index 6360251b3..4246df173 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/CountActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/CountActivity.php @@ -35,10 +35,6 @@ class CountActivity implements ExportInterface, GroupedExportInterface public function buildForm(FormBuilderInterface $builder) { } - public function getFormDefaultData(): array - { - return []; - } public function getAllowedFormattersTypes() { diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/StatActivityDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/StatActivityDuration.php index e68d47cd3..050034954 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/StatActivityDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/StatActivityDuration.php @@ -53,10 +53,6 @@ class StatActivityDuration implements ExportInterface, GroupedExportInterface public function buildForm(FormBuilderInterface $builder) { } - public function getFormDefaultData(): array - { - return []; - } public function getAllowedFormattersTypes() { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php index 4ffc3b38c..c6616a4c6 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php @@ -68,10 +68,6 @@ class ActivityTypeFilter implements FilterInterface 'expanded' => true, ]); } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ByCreatorFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ByCreatorFilter.php index add9c7c3d..322393f32 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ByCreatorFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ByCreatorFilter.php @@ -52,10 +52,6 @@ class ByCreatorFilter implements FilterInterface 'multiple' => true, ]); } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialActionFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialActionFilter.php index 08f6bbbc3..d0c1b0fc7 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialActionFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialActionFilter.php @@ -60,10 +60,6 @@ class BySocialActionFilter implements FilterInterface 'multiple' => true, ]); } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialIssueFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialIssueFilter.php index bd6e2ef4a..bbb882a65 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialIssueFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialIssueFilter.php @@ -60,10 +60,6 @@ class BySocialIssueFilter implements FilterInterface 'multiple' => true, ]); } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/EmergencyFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/EmergencyFilter.php index d5792d6d5..b79c2ca10 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/EmergencyFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/EmergencyFilter.php @@ -67,12 +67,10 @@ class EmergencyFilter implements FilterInterface 'choices' => self::CHOICES, 'multiple' => false, 'expanded' => true, + 'empty_data' => self::DEFAULT_CHOICE, + 'data' => self::DEFAULT_CHOICE, ]); } - public function getFormDefaultData(): array - { - return ['accepted_emergency' => self::DEFAULT_CHOICE]; - } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/HasNoActivityFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/HasNoActivityFilter.php index b5dab4009..570f42ae0 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/HasNoActivityFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/HasNoActivityFilter.php @@ -44,10 +44,6 @@ class HasNoActivityFilter implements FilterInterface { //no form needed } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationFilter.php index 312f3a6a0..3d69d1633 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationFilter.php @@ -46,10 +46,6 @@ class LocationFilter implements FilterInterface 'label' => 'pick location', ]); } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationTypeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationTypeFilter.php index 1c3415460..5fe928b6c 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationTypeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationTypeFilter.php @@ -65,10 +65,6 @@ class LocationTypeFilter implements FilterInterface //'label' => false, ]); } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/SentReceivedFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/SentReceivedFilter.php index 0f2a1c7e4..8daa7a781 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/SentReceivedFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/SentReceivedFilter.php @@ -69,12 +69,9 @@ class SentReceivedFilter implements FilterInterface 'multiple' => false, 'expanded' => true, 'empty_data' => self::DEFAULT_CHOICE, + 'data' => self::DEFAULT_CHOICE, ]); } - public function getFormDefaultData(): array - { - return ['accepted_sentreceived' => self::DEFAULT_CHOICE]; - } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserFilter.php index 9ae988579..6350f3ace 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserFilter.php @@ -61,10 +61,6 @@ class UserFilter implements FilterInterface 'label' => 'Creators', ]); } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserScopeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserScopeFilter.php index adb1e94f1..4319c100a 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserScopeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserScopeFilter.php @@ -71,10 +71,6 @@ class UserScopeFilter implements FilterInterface 'expanded' => true, ]); } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityDateFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityDateFilter.php index d1e69fe28..f2216c929 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityDateFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityDateFilter.php @@ -127,10 +127,6 @@ class ActivityDateFilter implements FilterInterface } }); } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php index 8dfcb543c..b9d39c3ce 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php @@ -78,10 +78,6 @@ class ActivityTypeFilter implements ExportElementValidatedInterface, FilterInter ], ]); } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityUsersFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityUsersFilter.php index a63ca2629..2f6cd8462 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityUsersFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityUsersFilter.php @@ -56,10 +56,6 @@ class ActivityUsersFilter implements FilterInterface 'label' => 'Users', ]); } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/ActivityReasonFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/ActivityReasonFilter.php index 31cfde6b6..c55d579e4 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/ActivityReasonFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/ActivityReasonFilter.php @@ -82,10 +82,6 @@ class ActivityReasonFilter implements ExportElementValidatedInterface, FilterInt 'expanded' => false, ]); } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/PersonHavingActivityBetweenDateFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/PersonHavingActivityBetweenDateFilter.php index 490b5fd0c..e3c85fe9c 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/PersonHavingActivityBetweenDateFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/PersonHavingActivityBetweenDateFilter.php @@ -112,6 +112,7 @@ class PersonHavingActivityBetweenDateFilter implements ExportElementValidatedInt { $builder->add('date_from', DateType::class, [ 'label' => 'Implied in an activity after this date', + 'data' => new DateTime(), 'attr' => ['class' => 'datepicker'], 'widget' => 'single_text', 'format' => 'dd-MM-yyyy', @@ -119,6 +120,7 @@ class PersonHavingActivityBetweenDateFilter implements ExportElementValidatedInt $builder->add('date_to', DateType::class, [ 'label' => 'Implied in an activity before this date', + 'data' => new DateTime(), 'attr' => ['class' => 'datepicker'], 'widget' => 'single_text', 'format' => 'dd-MM-yyyy', @@ -128,6 +130,7 @@ class PersonHavingActivityBetweenDateFilter implements ExportElementValidatedInt 'class' => ActivityReason::class, 'choice_label' => fn (ActivityReason $reason): ?string => $this->translatableStringHelper->localize($reason->getName()), 'group_by' => fn (ActivityReason $reason): ?string => $this->translatableStringHelper->localize($reason->getCategory()->getName()), + 'data' => $this->activityReasonRepository->findAll(), 'multiple' => true, 'expanded' => false, 'label' => 'Activity reasons for those activities', @@ -173,10 +176,6 @@ class PersonHavingActivityBetweenDateFilter implements ExportElementValidatedInt } }); } - public function getFormDefaultData(): array - { - return ['date_from' => new DateTime(), 'date_to' => new DateTime(), 'reasons' => $this->activityReasonRepository->findAll()]; - } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/UsersJobFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/UsersJobFilter.php index e85b2d247..b52ef441c 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/UsersJobFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/UsersJobFilter.php @@ -60,10 +60,6 @@ class UsersJobFilter implements FilterInterface 'expanded' => true, ]); } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/UsersScopeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/UsersScopeFilter.php index 07ff509ce..61b12264e 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/UsersScopeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/UsersScopeFilter.php @@ -67,10 +67,6 @@ class UsersScopeFilter implements FilterInterface 'expanded' => true, ]); } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByActivityTypeAggregator.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByActivityTypeAggregator.php index 8ae43534d..32418e3c3 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByActivityTypeAggregator.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByActivityTypeAggregator.php @@ -50,10 +50,6 @@ class ByActivityTypeAggregator implements AggregatorInterface { // No form needed } - public function getFormDefaultData(): array - { - return []; - } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserJobAggregator.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserJobAggregator.php index f09a704e2..d2fe7c2f2 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserJobAggregator.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserJobAggregator.php @@ -57,10 +57,6 @@ class ByUserJobAggregator implements AggregatorInterface { // nothing to add in the form } - public function getFormDefaultData(): array - { - return []; - } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserScopeAggregator.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserScopeAggregator.php index 3dd465db2..6c06ee756 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserScopeAggregator.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserScopeAggregator.php @@ -57,10 +57,6 @@ class ByUserScopeAggregator implements AggregatorInterface { // nothing to add in the form } - public function getFormDefaultData(): array - { - return []; - } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/AvgAsideActivityDuration.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/AvgAsideActivityDuration.php index 2b28062f6..f3db629cb 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/AvgAsideActivityDuration.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/AvgAsideActivityDuration.php @@ -34,10 +34,6 @@ class AvgAsideActivityDuration implements ExportInterface, GroupedExportInterfac public function buildForm(FormBuilderInterface $builder) { } - public function getFormDefaultData(): array - { - return []; - } public function getAllowedFormattersTypes(): array { diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/CountAsideActivity.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/CountAsideActivity.php index 91210f764..9204fad4b 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/CountAsideActivity.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/CountAsideActivity.php @@ -34,10 +34,6 @@ class CountAsideActivity implements ExportInterface, GroupedExportInterface public function buildForm(FormBuilderInterface $builder) { } - public function getFormDefaultData(): array - { - return []; - } public function getAllowedFormattersTypes(): array { diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/SumAsideActivityDuration.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/SumAsideActivityDuration.php index 741f129f1..af17a2591 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/SumAsideActivityDuration.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/SumAsideActivityDuration.php @@ -34,10 +34,6 @@ class SumAsideActivityDuration implements ExportInterface, GroupedExportInterfac public function buildForm(FormBuilderInterface $builder) { } - public function getFormDefaultData(): array - { - return []; - } public function getAllowedFormattersTypes(): array { diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByActivityTypeFilter.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByActivityTypeFilter.php index 3d389f5b3..3ad8e0e93 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByActivityTypeFilter.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByActivityTypeFilter.php @@ -76,10 +76,6 @@ class ByActivityTypeFilter implements FilterInterface }, ]); } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByDateFilter.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByDateFilter.php index 5019c3597..7a1b6f4dc 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByDateFilter.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByDateFilter.php @@ -119,10 +119,6 @@ class ByDateFilter implements FilterInterface } }); } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserFilter.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserFilter.php index 2858d3417..795c813cd 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserFilter.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserFilter.php @@ -53,10 +53,6 @@ class ByUserFilter implements FilterInterface 'label' => 'Creators', ]); } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserJobFilter.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserJobFilter.php index 55f477768..86194b123 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserJobFilter.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserJobFilter.php @@ -60,10 +60,6 @@ class ByUserJobFilter implements FilterInterface 'expanded' => true, ]); } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserScopeFilter.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserScopeFilter.php index 8fa51866d..4342e11eb 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserScopeFilter.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserScopeFilter.php @@ -67,10 +67,6 @@ class ByUserScopeFilter implements FilterInterface 'expanded' => true, ]); } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/AgentAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/AgentAggregator.php index 1b1b170b8..e1de9f399 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/AgentAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/AgentAggregator.php @@ -58,10 +58,6 @@ final class AgentAggregator implements AggregatorInterface { // no form } - public function getFormDefaultData(): array - { - return []; - } public function getLabels($key, array $values, $data): Closure { diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/CancelReasonAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/CancelReasonAggregator.php index a9967c470..611cb6d79 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/CancelReasonAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/CancelReasonAggregator.php @@ -59,10 +59,6 @@ class CancelReasonAggregator implements AggregatorInterface { // no form } - public function getFormDefaultData(): array - { - return []; - } public function getLabels($key, array $values, $data): Closure { diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/JobAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/JobAggregator.php index 51291b49e..23292a5b0 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/JobAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/JobAggregator.php @@ -58,10 +58,6 @@ final class JobAggregator implements AggregatorInterface { // no form } - public function getFormDefaultData(): array - { - return []; - } public function getLabels($key, array $values, $data): Closure { diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationAggregator.php index 952d0c5d5..940000f47 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationAggregator.php @@ -52,10 +52,6 @@ final class LocationAggregator implements AggregatorInterface { // no form } - public function getFormDefaultData(): array - { - return []; - } public function getLabels($key, array $values, $data): Closure { diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationTypeAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationTypeAggregator.php index a9b369af0..6574e3934 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationTypeAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationTypeAggregator.php @@ -58,10 +58,6 @@ final class LocationTypeAggregator implements AggregatorInterface { // no form } - public function getFormDefaultData(): array - { - return []; - } public function getLabels($key, array $values, $data): Closure { diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/MonthYearAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/MonthYearAggregator.php index b3c2aaf19..7b2a5e898 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/MonthYearAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/MonthYearAggregator.php @@ -40,10 +40,6 @@ class MonthYearAggregator implements AggregatorInterface { // No form needed } - public function getFormDefaultData(): array - { - return []; - } public function getLabels($key, array $values, $data): Closure { diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/ScopeAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/ScopeAggregator.php index 01874b0e2..3aff3e0d8 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/ScopeAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/ScopeAggregator.php @@ -58,10 +58,6 @@ final class ScopeAggregator implements AggregatorInterface { // no form } - public function getFormDefaultData(): array - { - return []; - } public function getLabels($key, array $values, $data): Closure { diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/UrgencyAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/UrgencyAggregator.php index 66ab8b42e..ad5910461 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/UrgencyAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/UrgencyAggregator.php @@ -56,10 +56,6 @@ class UrgencyAggregator implements AggregatorInterface { // no form } - public function getFormDefaultData(): array - { - return []; - } public function getLabels($key, array $values, $data): Closure { diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php b/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php index e0391948e..9d3f00f99 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php @@ -36,10 +36,6 @@ class CountCalendars implements ExportInterface, GroupedExportInterface { // No form necessary } - public function getFormDefaultData(): array - { - return []; - } public function getAllowedFormattersTypes(): array { diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php index dcbfb695b..14dd42d6b 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php @@ -36,10 +36,6 @@ class StatCalendarAvgDuration implements ExportInterface, GroupedExportInterface { // no form needed } - public function getFormDefaultData(): array - { - return []; - } public function getAllowedFormattersTypes(): array { diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php index 7f509a896..1d31bfa26 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php @@ -36,10 +36,6 @@ class StatCalendarSumDuration implements ExportInterface, GroupedExportInterface { // no form needed } - public function getFormDefaultData(): array - { - return []; - } public function getAllowedFormattersTypes(): array { diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php index 0cef89c20..b58cee594 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php @@ -63,10 +63,6 @@ class AgentFilter implements FilterInterface 'expanded' => true, ]); } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/BetweenDatesFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/BetweenDatesFilter.php index 71dc95e60..59019ac03 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/BetweenDatesFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/BetweenDatesFilter.php @@ -67,10 +67,6 @@ class BetweenDatesFilter implements FilterInterface 'data' => new RollingDate(RollingDate::T_TODAY), ]); } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/CalendarRangeFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/CalendarRangeFilter.php index 5ffb7c01f..d6c38e163 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/CalendarRangeFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/CalendarRangeFilter.php @@ -69,12 +69,9 @@ class CalendarRangeFilter implements FilterInterface 'multiple' => false, 'expanded' => true, 'empty_data' => self::DEFAULT_CHOICE, + 'data' => self::DEFAULT_CHOICE, ]); } - public function getFormDefaultData(): array - { - return ['hasCalendarRange' => self::DEFAULT_CHOICE]; - } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php index d02bb8e9d..69fb24447 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php @@ -76,10 +76,6 @@ class JobFilter implements FilterInterface 'expanded' => true, ]); } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php index d8a40da72..08d9ae023 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php @@ -76,10 +76,6 @@ class ScopeFilter implements FilterInterface 'expanded' => true, ]); } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/AdministrativeLocationAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/AdministrativeLocationAggregator.php index 56fdc07d7..96deac574 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/AdministrativeLocationAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/AdministrativeLocationAggregator.php @@ -57,10 +57,6 @@ class AdministrativeLocationAggregator implements AggregatorInterface { // no form } - public function getFormDefaultData(): array - { - return []; - } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ByActionNumberAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ByActionNumberAggregator.php index 104b934ca..2dffccbbb 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ByActionNumberAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ByActionNumberAggregator.php @@ -39,10 +39,6 @@ class ByActionNumberAggregator implements AggregatorInterface { // No form needed } - public function getFormDefaultData(): array - { - return []; - } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregator.php index 73cfdc7b9..342958361 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregator.php @@ -52,10 +52,6 @@ class ClosingMotiveAggregator implements AggregatorInterface { // no form } - public function getFormDefaultData(): array - { - return []; - } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ConfidentialAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ConfidentialAggregator.php index 4ad18030e..e9b9e28fa 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ConfidentialAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ConfidentialAggregator.php @@ -48,10 +48,6 @@ class ConfidentialAggregator implements AggregatorInterface { // no form } - public function getFormDefaultData(): array - { - return []; - } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/CreatorJobAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/CreatorJobAggregator.php index 5a060bcd7..c336a8887 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/CreatorJobAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/CreatorJobAggregator.php @@ -57,10 +57,6 @@ class CreatorJobAggregator implements AggregatorInterface { // No form needed } - public function getFormDefaultData(): array - { - return []; - } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/DurationAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/DurationAggregator.php index 581c7d6e5..0dc66e81e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/DurationAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/DurationAggregator.php @@ -84,10 +84,6 @@ final class DurationAggregator implements AggregatorInterface 'expanded' => true, ]); } - public function getFormDefaultData(): array - { - return []; - } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EmergencyAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EmergencyAggregator.php index 4429c7b62..02f9f5cd9 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EmergencyAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EmergencyAggregator.php @@ -48,10 +48,6 @@ class EmergencyAggregator implements AggregatorInterface { // no form } - public function getFormDefaultData(): array - { - return []; - } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EvaluationAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EvaluationAggregator.php index 119fa50b7..b6436efc0 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EvaluationAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EvaluationAggregator.php @@ -61,10 +61,6 @@ final class EvaluationAggregator implements AggregatorInterface { // no form } - public function getFormDefaultData(): array - { - return []; - } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php index 22b21d352..d001cbef7 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php @@ -133,10 +133,6 @@ final class GeographicalUnitStatAggregator implements AggregatorInterface 'expanded' => true, ]); } - public function getFormDefaultData(): array - { - return []; - } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/IntensityAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/IntensityAggregator.php index ac55d7734..a3618f40f 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/IntensityAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/IntensityAggregator.php @@ -48,10 +48,6 @@ class IntensityAggregator implements AggregatorInterface { // no form } - public function getFormDefaultData(): array - { - return []; - } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/OriginAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/OriginAggregator.php index 1d01920d5..37d0c7b20 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/OriginAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/OriginAggregator.php @@ -59,10 +59,6 @@ final class OriginAggregator implements AggregatorInterface { // no form } - public function getFormDefaultData(): array - { - return []; - } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerAggregator.php index 7b826600a..a09097fd2 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerAggregator.php @@ -81,14 +81,11 @@ final class ReferrerAggregator implements AggregatorInterface { $builder ->add('date_calc', PickRollingDateType::class, [ + 'data' => new RollingDate(RollingDate::T_TODAY), 'label' => 'export.aggregator.course.by_referrer.Computation date for referrer', 'required' => true, ]); } - public function getFormDefaultData(): array - { - return ['date_calc' => new RollingDate(RollingDate::T_TODAY)]; - } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerScopeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerScopeAggregator.php index adfd9b489..ccbd21da1 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerScopeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerScopeAggregator.php @@ -88,14 +88,11 @@ class ReferrerScopeAggregator implements AggregatorInterface public function buildForm(FormBuilderInterface $builder) { $builder->add('date_calc', PickRollingDateType::class, [ + 'data' => new RollingDate(RollingDate::T_TODAY), 'label' => 'export.aggregator.course.by_user_scope.Computation date for referrer', 'required' => true, ]); } - public function getFormDefaultData(): array - { - return ['date_calc' => new RollingDate(RollingDate::T_TODAY)]; - } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/RequestorAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/RequestorAggregator.php index 3baf9bd33..7b5cf0edd 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/RequestorAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/RequestorAggregator.php @@ -69,10 +69,6 @@ final class RequestorAggregator implements AggregatorInterface { // no form } - public function getFormDefaultData(): array - { - return []; - } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ScopeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ScopeAggregator.php index 253727c89..8f34661bb 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ScopeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ScopeAggregator.php @@ -57,10 +57,6 @@ final class ScopeAggregator implements AggregatorInterface { // no form } - public function getFormDefaultData(): array - { - return []; - } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialActionAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialActionAggregator.php index b82b47ad0..3bdd6549e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialActionAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialActionAggregator.php @@ -58,10 +58,6 @@ final class SocialActionAggregator implements AggregatorInterface { // no form } - public function getFormDefaultData(): array - { - return []; - } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialIssueAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialIssueAggregator.php index 29fcba4a2..12fa5a454 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialIssueAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialIssueAggregator.php @@ -58,10 +58,6 @@ final class SocialIssueAggregator implements AggregatorInterface { // no form } - public function getFormDefaultData(): array - { - return []; - } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/StepAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/StepAggregator.php index 7632f72f0..85cfc3190 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/StepAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/StepAggregator.php @@ -76,11 +76,9 @@ final class StepAggregator implements AggregatorInterface public function buildForm(FormBuilderInterface $builder) { - $builder->add('on_date', PickRollingDateType::class, []); - } - public function getFormDefaultData(): array - { - return ['on_date' => new RollingDate(RollingDate::T_TODAY)]; + $builder->add('on_date', PickRollingDateType::class, [ + 'data' => new RollingDate(RollingDate::T_TODAY), + ]); } public function getLabels($key, array $values, $data) diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/UserJobAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/UserJobAggregator.php index 13d1e3f83..a8acdcf12 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/UserJobAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/UserJobAggregator.php @@ -57,10 +57,6 @@ final class UserJobAggregator implements AggregatorInterface { // no form } - public function getFormDefaultData(): array - { - return []; - } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByEndDateAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByEndDateAggregator.php index cb66fa600..2f4275c49 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByEndDateAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByEndDateAggregator.php @@ -75,12 +75,9 @@ class ByEndDateAggregator implements AggregatorInterface 'multiple' => false, 'expanded' => true, 'empty_data' => self::DEFAULT_CHOICE, + 'data' => self::DEFAULT_CHOICE, ]); } - public function getFormDefaultData(): array - { - return ['frequency' => self::DEFAULT_CHOICE]; - } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByMaxDateAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByMaxDateAggregator.php index af6dfc465..9283fd9dc 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByMaxDateAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByMaxDateAggregator.php @@ -75,12 +75,9 @@ class ByMaxDateAggregator implements AggregatorInterface 'multiple' => false, 'expanded' => true, 'empty_data' => self::DEFAULT_CHOICE, + 'data' => self::DEFAULT_CHOICE, ]); } - public function getFormDefaultData(): array - { - return ['frequency' => self::DEFAULT_CHOICE]; - } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByStartDateAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByStartDateAggregator.php index 87a6a672b..cd183b25e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByStartDateAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByStartDateAggregator.php @@ -75,12 +75,9 @@ class ByStartDateAggregator implements AggregatorInterface 'multiple' => false, 'expanded' => true, 'empty_data' => self::DEFAULT_CHOICE, + 'data' => self::DEFAULT_CHOICE, ]); } - public function getFormDefaultData(): array - { - return ['frequency' => self::DEFAULT_CHOICE]; - } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/EvaluationTypeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/EvaluationTypeAggregator.php index a48ed763d..0c13611cb 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/EvaluationTypeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/EvaluationTypeAggregator.php @@ -52,10 +52,6 @@ class EvaluationTypeAggregator implements AggregatorInterface { // no form } - public function getFormDefaultData(): array - { - return []; - } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/HavingEndDateAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/HavingEndDateAggregator.php index e710949fd..e33bb326f 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/HavingEndDateAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/HavingEndDateAggregator.php @@ -48,10 +48,6 @@ class HavingEndDateAggregator implements AggregatorInterface { // No form needed } - public function getFormDefaultData(): array - { - return []; - } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/ChildrenNumberAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/ChildrenNumberAggregator.php index 1c5b3dc2c..0c9bc623f 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/ChildrenNumberAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/ChildrenNumberAggregator.php @@ -72,11 +72,9 @@ class ChildrenNumberAggregator implements AggregatorInterface public function buildForm(FormBuilderInterface $builder) { - $builder->add('on_date', PickRollingDateType::class, []); - } - public function getFormDefaultData(): array - { - return ['on_date' => new RollingDate(RollingDate::T_TODAY)]; + $builder->add('on_date', PickRollingDateType::class, [ + 'data' => new RollingDate(RollingDate::T_TODAY), + ]); } public function getLabels($key, array $values, $data) diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/CompositionAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/CompositionAggregator.php index 62fc20173..52bcd88e5 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/CompositionAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/CompositionAggregator.php @@ -77,11 +77,9 @@ class CompositionAggregator implements AggregatorInterface public function buildForm(FormBuilderInterface $builder) { - $builder->add('on_date', PickRollingDateType::class, []); - } - public function getFormDefaultData(): array - { - return ['on_date' => new RollingDate(RollingDate::T_TODAY)]; + $builder->add('on_date', PickRollingDateType::class, [ + 'data' => new RollingDate(RollingDate::T_TODAY), + ]); } public function getLabels($key, array $values, $data) diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/AgeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/AgeAggregator.php index 2a63e475a..365a73704 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/AgeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/AgeAggregator.php @@ -50,15 +50,12 @@ final class AgeAggregator implements AggregatorInterface, ExportElementValidated { $builder->add('date_age_calculation', DateType::class, [ 'label' => 'Calculate age in relation to this date', + 'data' => new DateTime(), 'attr' => ['class' => 'datepicker'], 'widget' => 'single_text', 'format' => 'dd-MM-yyyy', ]); } - public function getFormDefaultData(): array - { - return ['date_age_calculation' => new DateTime()]; - } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/ByHouseholdCompositionAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/ByHouseholdCompositionAggregator.php index 16b62c2b5..80f0faa17 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/ByHouseholdCompositionAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/ByHouseholdCompositionAggregator.php @@ -94,12 +94,9 @@ class ByHouseholdCompositionAggregator implements AggregatorInterface { $builder->add('date_calc', PickRollingDateType::class, [ 'label' => 'export.aggregator.person.by_household_composition.Calc date', + 'data' => new RollingDate(RollingDate::T_TODAY), ]); } - public function getFormDefaultData(): array - { - return ['date_calc' => new RollingDate(RollingDate::T_TODAY)]; - } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/CountryOfBirthAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/CountryOfBirthAggregator.php index 90882245e..3d785b586 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/CountryOfBirthAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/CountryOfBirthAggregator.php @@ -108,10 +108,6 @@ final class CountryOfBirthAggregator implements AggregatorInterface, ExportEleme 'multiple' => false, ]); } - public function getFormDefaultData(): array - { - return []; - } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GenderAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GenderAggregator.php index dbe3d19d3..f76420047 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GenderAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GenderAggregator.php @@ -48,10 +48,6 @@ final class GenderAggregator implements AggregatorInterface public function buildForm(FormBuilderInterface $builder) { } - public function getFormDefaultData(): array - { - return []; - } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GeographicalUnitAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GeographicalUnitAggregator.php index 6c6ed340f..5d73c1fdd 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GeographicalUnitAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GeographicalUnitAggregator.php @@ -105,10 +105,6 @@ class GeographicalUnitAggregator implements AggregatorInterface 'expanded' => true, ]); } - public function getFormDefaultData(): array - { - return []; - } public static function getDefaultAlias(): string { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/HouseholdPositionAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/HouseholdPositionAggregator.php index 63d84d4da..107634803 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/HouseholdPositionAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/HouseholdPositionAggregator.php @@ -90,12 +90,9 @@ final class HouseholdPositionAggregator implements AggregatorInterface, ExportEl { $builder->add('date_position', PickRollingDateType::class, [ 'label' => 'Household position in relation to this date', + 'data' => new RollingDate(RollingDate::T_TODAY), ]); } - public function getFormDefaultData(): array - { - return ['date_position' => new RollingDate(RollingDate::T_TODAY)]; - } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregator.php index 66c87d94f..c1fccb968 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregator.php @@ -75,10 +75,6 @@ final class ActionTypeAggregator implements AggregatorInterface { // no form } - public function getFormDefaultData(): array - { - return []; - } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CurrentActionAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CurrentActionAggregator.php index 539c9f286..58fcb2874 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CurrentActionAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CurrentActionAggregator.php @@ -51,10 +51,6 @@ class CurrentActionAggregator implements AggregatorInterface { // No form needed } - public function getFormDefaultData(): array - { - return []; - } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalAggregator.php index 4c0e8b393..8cc6a25da 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalAggregator.php @@ -55,10 +55,6 @@ final class GoalAggregator implements AggregatorInterface { // no form } - public function getFormDefaultData(): array - { - return []; - } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalResultAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalResultAggregator.php index c99ee85ea..17b263d7e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalResultAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalResultAggregator.php @@ -68,10 +68,6 @@ class GoalResultAggregator implements AggregatorInterface { // no form } - public function getFormDefaultData(): array - { - return []; - } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/JobAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/JobAggregator.php index 8271c90e3..cbf07091f 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/JobAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/JobAggregator.php @@ -57,10 +57,6 @@ final class JobAggregator implements AggregatorInterface { // no form } - public function getFormDefaultData(): array - { - return []; - } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ReferrerAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ReferrerAggregator.php index 047504224..0fe53b707 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ReferrerAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ReferrerAggregator.php @@ -57,10 +57,6 @@ final class ReferrerAggregator implements AggregatorInterface { // no form } - public function getFormDefaultData(): array - { - return []; - } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ResultAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ResultAggregator.php index 3cce7b283..2e46673da 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ResultAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ResultAggregator.php @@ -55,10 +55,6 @@ final class ResultAggregator implements AggregatorInterface { // no form } - public function getFormDefaultData(): array - { - return []; - } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ScopeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ScopeAggregator.php index 0828b5d0d..243263b83 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ScopeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ScopeAggregator.php @@ -57,10 +57,6 @@ final class ScopeAggregator implements AggregatorInterface { // no form } - public function getFormDefaultData(): array - { - return []; - } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php b/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php index 75583dfa0..978f88a10 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php @@ -39,10 +39,6 @@ class CountAccompanyingCourse implements ExportInterface, GroupedExportInterface { // Nothing to add here } - public function getFormDefaultData(): array - { - return []; - } public function getAllowedFormattersTypes(): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingPeriodWork.php b/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingPeriodWork.php index 8a035bdcd..122ee14d9 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingPeriodWork.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingPeriodWork.php @@ -38,10 +38,6 @@ class CountAccompanyingPeriodWork implements ExportInterface, GroupedExportInter { // No form necessary? } - public function getFormDefaultData(): array - { - return []; - } public function getAllowedFormattersTypes(): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php b/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php index 3de433e2e..1613b63d3 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php @@ -37,10 +37,6 @@ class CountEvaluation implements ExportInterface, GroupedExportInterface { // TODO: Implement buildForm() method. } - public function getFormDefaultData(): array - { - return []; - } public function getAllowedFormattersTypes(): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php b/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php index 05e32fde6..0b693b9d8 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php @@ -46,14 +46,11 @@ class CountHousehold implements ExportInterface, GroupedExportInterface { $builder ->add('calc_date', PickRollingDateType::class, [ + 'data' => new RollingDate(RollingDate::T_TODAY), 'label' => self::TR_PREFIX . 'Date of calculation of household members', 'required' => false, ]); } - public function getFormDefaultData(): array - { - return ['calc_date' => new RollingDate(RollingDate::T_TODAY)]; - } public function getAllowedFormattersTypes(): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountPersonWithAccompanyingCourse.php b/src/Bundle/ChillPersonBundle/Export/Export/CountPersonWithAccompanyingCourse.php index ae7238d4e..e52cc83b1 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountPersonWithAccompanyingCourse.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountPersonWithAccompanyingCourse.php @@ -39,10 +39,6 @@ class CountPersonWithAccompanyingCourse implements ExportInterface, GroupedExpor { // TODO: Implement buildForm() method. } - public function getFormDefaultData(): array - { - return []; - } public function getAllowedFormattersTypes(): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListPersonDuplicate.php b/src/Bundle/ChillPersonBundle/Export/Export/ListPersonDuplicate.php index e7c105604..e40ffccce 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListPersonDuplicate.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListPersonDuplicate.php @@ -74,12 +74,9 @@ class ListPersonDuplicate implements DirectExportInterface, ExportElementValidat { $builder->add('precision', NumberType::class, [ 'label' => 'Precision', + 'data' => self::PRECISION_DEFAULT_VALUE, ]); } - public function getFormDefaultData(): array - { - return ['precision' => self::PRECISION_DEFAULT_VALUE]; - } public function generate(array $acl, array $data = []): Response { diff --git a/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php b/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php index 66b47131d..31ca41cbb 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php @@ -41,12 +41,9 @@ class StatAccompanyingCourseDuration implements ExportInterface, GroupedExportIn { $builder->add('closingdate', ChillDateType::class, [ 'label' => 'Closingdate to apply', + 'data' => new DateTime('now'), ]); } - public function getFormDefaultData(): array - { - return ['closingdate' => new DateTime('now')]; - } public function getAllowedFormattersTypes(): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOnDateFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOnDateFilter.php index fcb4d67fb..3fa8d711f 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOnDateFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOnDateFilter.php @@ -67,11 +67,9 @@ class ActiveOnDateFilter implements FilterInterface public function buildForm(FormBuilderInterface $builder) { $builder - ->add('on_date', PickRollingDateType::class, []); - } - public function getFormDefaultData(): array - { - return ['on_date' => new RollingDate(RollingDate::T_TODAY)]; + ->add('on_date', PickRollingDateType::class, [ + 'data' => new RollingDate(RollingDate::T_TODAY), + ]); } public function describeAction($data, $format = 'string'): array diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOneDayBetweenDatesFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOneDayBetweenDatesFilter.php index f693a6d04..f713e8a97 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOneDayBetweenDatesFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOneDayBetweenDatesFilter.php @@ -63,10 +63,6 @@ class ActiveOneDayBetweenDatesFilter implements FilterInterface 'data' => new RollingDate(RollingDate::T_TODAY), ]); } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/AdministrativeLocationFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/AdministrativeLocationFilter.php index aa1abb36e..c74e309b2 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/AdministrativeLocationFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/AdministrativeLocationFilter.php @@ -53,10 +53,6 @@ class AdministrativeLocationFilter implements FilterInterface 'multiple' => true, ]); } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ClosingMotiveFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ClosingMotiveFilter.php index 153b2ecbd..e57370f30 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ClosingMotiveFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ClosingMotiveFilter.php @@ -64,10 +64,6 @@ class ClosingMotiveFilter implements FilterInterface 'expanded' => true, ]); } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ConfidentialFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ConfidentialFilter.php index 58085f762..4be284b2d 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ConfidentialFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ConfidentialFilter.php @@ -66,12 +66,10 @@ class ConfidentialFilter implements FilterInterface 'choices' => self::CHOICES, 'multiple' => false, 'expanded' => true, + 'empty_data' => self::DEFAULT_CHOICE, + 'data' => self::DEFAULT_CHOICE, ]); } - public function getFormDefaultData(): array - { - return ['accepted_confidentials' => self::DEFAULT_CHOICE]; - } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorFilter.php index 8a8a24013..b13947e60 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorFilter.php @@ -50,10 +50,6 @@ class CreatorFilter implements FilterInterface 'label' => false, ]); } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorJobFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorJobFilter.php index 5faeb850f..f585cfafb 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorJobFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorJobFilter.php @@ -69,10 +69,6 @@ class CreatorJobFilter implements FilterInterface 'label' => 'Job', ]); } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EmergencyFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EmergencyFilter.php index 897a4db2d..d31b93bd4 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EmergencyFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EmergencyFilter.php @@ -66,12 +66,10 @@ class EmergencyFilter implements FilterInterface 'choices' => self::CHOICES, 'multiple' => false, 'expanded' => true, + 'empty_data' => self::DEFAULT_CHOICE, + 'data' => self::DEFAULT_CHOICE, ]); } - public function getFormDefaultData(): array - { - return ['accepted_emergency' => self::DEFAULT_CHOICE]; - } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EvaluationFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EvaluationFilter.php index a6fb3583d..ab7f4257e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EvaluationFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EvaluationFilter.php @@ -75,10 +75,6 @@ class EvaluationFilter implements FilterInterface 'attr' => ['class' => 'select2'], ]); } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php index b4ffed280..d35565c80 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php @@ -114,10 +114,6 @@ class GeographicalUnitStatFilter implements FilterInterface 'multiple' => true, ]); } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasNoActionFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasNoActionFilter.php index 4820116c0..54c28d027 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasNoActionFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasNoActionFilter.php @@ -38,10 +38,6 @@ class HasNoActionFilter implements FilterInterface { // no form } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasNoReferrerFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasNoReferrerFilter.php index 6d01ea7c2..4c682a56a 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasNoReferrerFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasNoReferrerFilter.php @@ -65,12 +65,9 @@ class HasNoReferrerFilter implements FilterInterface $builder ->add('calc_date', PickRollingDateType::class, [ 'label' => 'Has no referrer on this date', + 'data' => new RollingDate(RollingDate::T_TODAY), ]); } - public function getFormDefaultData(): array - { - return ['calc_date' => new RollingDate(RollingDate::T_TODAY)]; - } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasTemporaryLocationFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasTemporaryLocationFilter.php index f9b2f2bd6..615ace4c6 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasTemporaryLocationFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasTemporaryLocationFilter.php @@ -95,10 +95,6 @@ class HasTemporaryLocationFilter implements FilterInterface 'data' => new RollingDate(RollingDate::T_TODAY), ]); } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HavingAnAccompanyingPeriodInfoWithinDatesFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HavingAnAccompanyingPeriodInfoWithinDatesFilter.php index cdc771b19..7069a1d80 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HavingAnAccompanyingPeriodInfoWithinDatesFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HavingAnAccompanyingPeriodInfoWithinDatesFilter.php @@ -46,10 +46,6 @@ final readonly class HavingAnAccompanyingPeriodInfoWithinDatesFilter implements ]) ; } - public function getFormDefaultData(): array - { - return []; - } public function getTitle(): string { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/IntensityFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/IntensityFilter.php index 1fd05d2b4..b0c2205a0 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/IntensityFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/IntensityFilter.php @@ -67,12 +67,9 @@ class IntensityFilter implements FilterInterface 'multiple' => false, 'expanded' => true, 'empty_data' => self::DEFAULT_CHOICE, + 'data' => self::DEFAULT_CHOICE, ]); } - public function getFormDefaultData(): array - { - return ['accepted_intensities' => self::DEFAULT_CHOICE]; - } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OpenBetweenDatesFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OpenBetweenDatesFilter.php index ebbec06a4..07ca1de75 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OpenBetweenDatesFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OpenBetweenDatesFilter.php @@ -61,10 +61,6 @@ class OpenBetweenDatesFilter implements FilterInterface 'data' => new RollingDate(RollingDate::T_TODAY), ]); } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OriginFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OriginFilter.php index 8395c79f8..00febc640 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OriginFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OriginFilter.php @@ -64,10 +64,6 @@ class OriginFilter implements FilterInterface 'expanded' => true, ]); } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ReferrerFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ReferrerFilter.php index daf0d83a4..2a3e5d17e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ReferrerFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ReferrerFilter.php @@ -82,10 +82,6 @@ class ReferrerFilter implements FilterInterface 'required' => true, ]); } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/RequestorFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/RequestorFilter.php index 614889c27..3295a5b57 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/RequestorFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/RequestorFilter.php @@ -126,12 +126,9 @@ final class RequestorFilter implements FilterInterface 'multiple' => false, 'expanded' => true, 'empty_data' => self::DEFAULT_CHOICE, + 'data' => self::DEFAULT_CHOICE, ]); } - public function getFormDefaultData(): array - { - return ['accepted_choices' => self::DEFAULT_CHOICE]; - } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php index 0c14ba73a..bc1f368da 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php @@ -70,10 +70,6 @@ class SocialActionFilter implements FilterInterface 'multiple' => true, ]); } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php index a793bc548..917e129bf 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php @@ -69,10 +69,6 @@ class SocialIssueFilter implements FilterInterface 'multiple' => true, ]); } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/StepFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/StepFilter.php index 993ebe301..8ee798c07 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/StepFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/StepFilter.php @@ -102,10 +102,6 @@ class StepFilter implements FilterInterface 'data' => new RollingDate(RollingDate::T_TODAY), ]); } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserJobFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserJobFilter.php index cb70fb78b..05d84d7b2 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserJobFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserJobFilter.php @@ -101,10 +101,6 @@ class UserJobFilter implements FilterInterface 'required' => true, ]); } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserScopeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserScopeFilter.php index 580c8e334..bbffa4bca 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserScopeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserScopeFilter.php @@ -105,10 +105,6 @@ class UserScopeFilter implements FilterInterface 'required' => true, ]); } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserWorkingOnCourseFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserWorkingOnCourseFilter.php index d078443af..586bb645d 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserWorkingOnCourseFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserWorkingOnCourseFilter.php @@ -42,10 +42,6 @@ readonly class UserWorkingOnCourseFilter implements FilterInterface 'multiple' => true, ]); } - public function getFormDefaultData(): array - { - return []; - } public function getTitle(): string { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/ByEndDateFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/ByEndDateFilter.php index c0e9c4a99..de86604e6 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/ByEndDateFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/ByEndDateFilter.php @@ -64,10 +64,6 @@ class ByEndDateFilter implements FilterInterface 'data' => new RollingDate(RollingDate::T_TODAY), ]); } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/ByStartDateFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/ByStartDateFilter.php index a40becbad..27518599c 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/ByStartDateFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/ByStartDateFilter.php @@ -64,10 +64,6 @@ class ByStartDateFilter implements FilterInterface 'data' => new RollingDate(RollingDate::T_TODAY), ]); } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/CurrentEvaluationsFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/CurrentEvaluationsFilter.php index 8841c7b9e..140f6c3cb 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/CurrentEvaluationsFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/CurrentEvaluationsFilter.php @@ -37,10 +37,6 @@ class CurrentEvaluationsFilter implements FilterInterface { //no form needed } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/EvaluationTypeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/EvaluationTypeFilter.php index 77bae1b56..6a0c71d55 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/EvaluationTypeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/EvaluationTypeFilter.php @@ -64,10 +64,6 @@ final class EvaluationTypeFilter implements FilterInterface 'expanded' => true, ]); } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/MaxDateFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/MaxDateFilter.php index daa7d1954..4a65452a1 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/MaxDateFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/MaxDateFilter.php @@ -61,10 +61,6 @@ class MaxDateFilter implements FilterInterface 'expanded' => true, ]); } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/HouseholdFilters/CompositionFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/HouseholdFilters/CompositionFilter.php index a89236159..22761c158 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/HouseholdFilters/CompositionFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/HouseholdFilters/CompositionFilter.php @@ -88,10 +88,6 @@ class CompositionFilter implements FilterInterface 'data' => new RollingDate(RollingDate::T_TODAY), ]); } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AddressRefStatusFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AddressRefStatusFilter.php index cf777e08d..7580a37a3 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AddressRefStatusFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AddressRefStatusFilter.php @@ -87,10 +87,6 @@ class AddressRefStatusFilter implements \Chill\MainBundle\Export\FilterInterface 'data' => [Address::ADDR_REFERENCE_STATUS_TO_REVIEW] ]); } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/BirthdateFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/BirthdateFilter.php index 9a0478b6c..7ae22ddd8 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/BirthdateFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/BirthdateFilter.php @@ -71,16 +71,14 @@ class BirthdateFilter implements ExportElementValidatedInterface, FilterInterfac { $builder->add('date_from', PickRollingDateType::class, [ 'label' => 'Born after this date', + 'data' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START), ]); $builder->add('date_to', PickRollingDateType::class, [ 'label' => 'Born before this date', + 'data' => new RollingDate(RollingDate::T_TODAY), ]); } - public function getFormDefaultData(): array - { - return ['date_from' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START), 'date_to' => new RollingDate(RollingDate::T_TODAY)]; - } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ByHouseholdCompositionFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ByHouseholdCompositionFilter.php index d7adb5cd9..9b59549f1 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ByHouseholdCompositionFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ByHouseholdCompositionFilter.php @@ -89,10 +89,6 @@ class ByHouseholdCompositionFilter implements FilterInterface 'data' => new RollingDate(RollingDate::T_TODAY), ]); } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/DeadOrAliveFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/DeadOrAliveFilter.php index 8b2444ca2..384d6698a 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/DeadOrAliveFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/DeadOrAliveFilter.php @@ -102,12 +102,9 @@ class DeadOrAliveFilter implements FilterInterface $builder->add('date_calc', PickRollingDateType::class, [ 'label' => 'Filter in relation to this date', + 'data' => new RollingDate(RollingDate::T_TODAY), ]); } - public function getFormDefaultData(): array - { - return ['date_calc' => new RollingDate(RollingDate::T_TODAY)]; - } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/DeathdateFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/DeathdateFilter.php index 7805331a5..0ac4b3173 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/DeathdateFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/DeathdateFilter.php @@ -72,16 +72,14 @@ class DeathdateFilter implements ExportElementValidatedInterface, FilterInterfac { $builder->add('date_from', PickRollingDateType::class, [ 'label' => 'Death after this date', + 'data' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START), ]); $builder->add('date_to', PickRollingDateType::class, [ 'label' => 'Deathdate before', + 'data' => new RollingDate(RollingDate::T_TODAY), ]); } - public function getFormDefaultData(): array - { - return ['date_from' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START), 'date_to' => new RollingDate(RollingDate::T_TODAY)]; - } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GenderFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GenderFilter.php index 182006bbc..739945b98 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GenderFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GenderFilter.php @@ -89,10 +89,6 @@ class GenderFilter implements 'expanded' => true, ]); } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GeographicalUnitFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GeographicalUnitFilter.php index 7efeca49e..79f5cb2d4 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GeographicalUnitFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GeographicalUnitFilter.php @@ -105,10 +105,6 @@ class GeographicalUnitFilter implements \Chill\MainBundle\Export\FilterInterface 'multiple' => true, ]); } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/MaritalStatusFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/MaritalStatusFilter.php index 021c22fc6..47a75871c 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/MaritalStatusFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/MaritalStatusFilter.php @@ -56,10 +56,6 @@ class MaritalStatusFilter implements FilterInterface 'expanded' => true, ]); } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/NationalityFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/NationalityFilter.php index e5102128b..b1d77d60e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/NationalityFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/NationalityFilter.php @@ -67,10 +67,6 @@ class NationalityFilter implements 'placeholder' => 'Choose countries', ]); } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php index 8f22750a5..21bb40947 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php @@ -107,12 +107,9 @@ class ResidentialAddressAtThirdpartyFilter implements FilterInterface $builder->add('date_calc', PickRollingDateType::class, [ 'label' => 'Date during which residential address was valid', + 'data' => new RollingDate(RollingDate::T_TODAY), ]); } - public function getFormDefaultData(): array - { - return ['date_calc' => new RollingDate(RollingDate::T_TODAY)]; - } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtUserFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtUserFilter.php index 62b142420..bd55c5b80 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtUserFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtUserFilter.php @@ -82,12 +82,9 @@ class ResidentialAddressAtUserFilter implements FilterInterface { $builder->add('date_calc', PickRollingDateType::class, [ 'label' => 'Date during which residential address was valid', + 'data' => new RollingDate(RollingDate::T_TODAY), ]); } - public function getFormDefaultData(): array - { - return ['date_calc' => new RollingDate(RollingDate::T_TODAY)]; - } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/WithoutHouseholdComposition.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/WithoutHouseholdComposition.php index 9f5ed90b5..c4644fc11 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/WithoutHouseholdComposition.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/WithoutHouseholdComposition.php @@ -66,12 +66,9 @@ class WithoutHouseholdComposition implements FilterInterface $builder ->add('calc_date', PickRollingDateType::class, [ 'label' => 'export.filter.person.by_no_composition.Date calc', + 'data' => new RollingDate(RollingDate::T_TODAY), ]); } - public function getFormDefaultData(): array - { - return ['calc_date' => new RollingDate(RollingDate::T_TODAY)]; - } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/AccompanyingPeriodWorkEndDateBetweenDateFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/AccompanyingPeriodWorkEndDateBetweenDateFilter.php index 45d86bc97..b13c49e9a 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/AccompanyingPeriodWorkEndDateBetweenDateFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/AccompanyingPeriodWorkEndDateBetweenDateFilter.php @@ -44,10 +44,6 @@ final readonly class AccompanyingPeriodWorkEndDateBetweenDateFilter implements F ]) ; } - public function getFormDefaultData(): array - { - return []; - } public function getTitle(): string { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/AccompanyingPeriodWorkStartDateBetweenDateFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/AccompanyingPeriodWorkStartDateBetweenDateFilter.php index f4a914203..e9526a9a5 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/AccompanyingPeriodWorkStartDateBetweenDateFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/AccompanyingPeriodWorkStartDateBetweenDateFilter.php @@ -44,10 +44,6 @@ final readonly class AccompanyingPeriodWorkStartDateBetweenDateFilter implements ]) ; } - public function getFormDefaultData(): array - { - return []; - } public function getTitle(): string { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CurrentActionFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CurrentActionFilter.php index e99590025..cbdb64d8d 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CurrentActionFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CurrentActionFilter.php @@ -37,10 +37,6 @@ class CurrentActionFilter implements FilterInterface { //no form } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/JobFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/JobFilter.php index 265c8e24d..144bf3260 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/JobFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/JobFilter.php @@ -76,10 +76,6 @@ class JobFilter implements FilterInterface 'expanded' => true, ]); } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ReferrerFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ReferrerFilter.php index bddcfbf9b..8d0da32fb 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ReferrerFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ReferrerFilter.php @@ -57,10 +57,6 @@ class ReferrerFilter implements FilterInterface 'multiple' => true, ]); } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ScopeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ScopeFilter.php index 737759c3e..315025722 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ScopeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ScopeFilter.php @@ -76,10 +76,6 @@ class ScopeFilter implements FilterInterface 'expanded' => true, ]); } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/SocialWorkTypeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/SocialWorkTypeFilter.php index 25bfc17a0..11fd0ed9d 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/SocialWorkTypeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/SocialWorkTypeFilter.php @@ -110,10 +110,6 @@ class SocialWorkTypeFilter implements FilterInterface $this->iterableToIdTransformer(Result::class) ); } - public function getFormDefaultData(): array - { - return []; - } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillReportBundle/Export/Filter/ReportDateFilter.php b/src/Bundle/ChillReportBundle/Export/Filter/ReportDateFilter.php index cb8e7d1d0..79bad4f52 100644 --- a/src/Bundle/ChillReportBundle/Export/Filter/ReportDateFilter.php +++ b/src/Bundle/ChillReportBundle/Export/Filter/ReportDateFilter.php @@ -67,16 +67,14 @@ class ReportDateFilter implements FilterInterface { $builder->add('date_from', PickRollingDateType::class, [ 'label' => 'Report is after this date', + 'data' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START), ]); $builder->add('date_to', PickRollingDateType::class, [ 'label' => 'Report is before this date', + 'data' => new RollingDate(RollingDate::T_TODAY), ]); } - public function getFormDefaultData(): array - { - return ['date_from' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START), 'date_to' => new RollingDate(RollingDate::T_TODAY)]; - } public function describeAction($data, $format = 'string') { From 50de389bc7a6b6c75b4033b33de93dad7f3b5750 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sun, 18 Jun 2023 11:58:42 +0200 Subject: [PATCH 213/724] Revert "apply fixes for list" This reverts commit 938027cc --- .../Export/Export/LinkedToACP/ListActivity.php | 4 ---- .../Export/Export/LinkedToPerson/ListActivity.php | 4 ---- .../src/Export/Export/ListAsideActivity.php | 4 ---- .../ChillMainBundle/Export/Formatter/CSVListFormatter.php | 8 +------- .../Export/Formatter/CSVPivotedListFormatter.php | 6 +----- .../Export/Formatter/SpreadsheetListFormatter.php | 6 +----- .../Export/Export/ListAccompanyingPeriod.php | 4 ---- .../Export/Export/ListAccompanyingPeriodWork.php | 5 +---- .../ChillPersonBundle/Export/Export/ListEvaluation.php | 5 +---- .../Export/Export/ListHouseholdInPeriod.php | 5 +---- .../Export/Export/ListPersonWithAccompanyingPeriod.php | 8 ++------ src/Bundle/ChillReportBundle/Export/Export/ReportList.php | 5 +---- 12 files changed, 9 insertions(+), 55 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php index 9ed6bcda2..026e16f90 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php @@ -44,10 +44,6 @@ class ListActivity implements ListInterface, GroupedExportInterface { $this->helper->buildForm($builder); } - public function getFormDefaultData(): array - { - return []; - } public function getAllowedFormattersTypes() { diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php index d14111ba7..60110c9a8 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php @@ -88,10 +88,6 @@ class ListActivity implements ListInterface, GroupedExportInterface ])], ]); } - public function getFormDefaultData(): array - { - return []; - } public function getAllowedFormattersTypes() { diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/ListAsideActivity.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/ListAsideActivity.php index b46e120b5..aee168174 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/ListAsideActivity.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/ListAsideActivity.php @@ -73,10 +73,6 @@ final class ListAsideActivity implements ListInterface, GroupedExportInterface public function buildForm(FormBuilderInterface $builder) { } - public function getFormDefaultData(): array - { - return []; - } public function getAllowedFormattersTypes() { diff --git a/src/Bundle/ChillMainBundle/Export/Formatter/CSVListFormatter.php b/src/Bundle/ChillMainBundle/Export/Formatter/CSVListFormatter.php index 70d80b74b..b84c80118 100644 --- a/src/Bundle/ChillMainBundle/Export/Formatter/CSVListFormatter.php +++ b/src/Bundle/ChillMainBundle/Export/Formatter/CSVListFormatter.php @@ -85,16 +85,10 @@ class CSVListFormatter implements FormatterInterface 'expanded' => true, 'multiple' => false, 'label' => 'Add a number on first column', + 'data' => true, ]); } - public function getFormDefaultData(array $aggregatorAliases): array - { - return ['numerotation' => true]; - } - - - public function getName() { return 'CSV vertical list'; diff --git a/src/Bundle/ChillMainBundle/Export/Formatter/CSVPivotedListFormatter.php b/src/Bundle/ChillMainBundle/Export/Formatter/CSVPivotedListFormatter.php index cce0fa1e4..63d691443 100644 --- a/src/Bundle/ChillMainBundle/Export/Formatter/CSVPivotedListFormatter.php +++ b/src/Bundle/ChillMainBundle/Export/Formatter/CSVPivotedListFormatter.php @@ -80,14 +80,10 @@ class CSVPivotedListFormatter implements FormatterInterface 'expanded' => true, 'multiple' => false, 'label' => 'Add a number on first column', + 'data' => true, ]); } - public function getFormDefaultData(array $aggregatorAliases): array - { - return ['numerotation' => true]; - } - public function getName() { return 'CSV horizontal list'; diff --git a/src/Bundle/ChillMainBundle/Export/Formatter/SpreadsheetListFormatter.php b/src/Bundle/ChillMainBundle/Export/Formatter/SpreadsheetListFormatter.php index 34960d8d2..0e5e339ea 100644 --- a/src/Bundle/ChillMainBundle/Export/Formatter/SpreadsheetListFormatter.php +++ b/src/Bundle/ChillMainBundle/Export/Formatter/SpreadsheetListFormatter.php @@ -104,14 +104,10 @@ class SpreadsheetListFormatter implements FormatterInterface 'expanded' => true, 'multiple' => false, 'label' => 'Add a number on first column', + 'data' => true, ]); } - public function getFormDefaultData(array $aggregatorAliases): array - { - return ['format' => 'xlsx', 'numerotation' => true]; - } - public function getName() { return 'Spreadsheet list formatter (.xlsx, .ods)'; diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php index e5e724b6c..0647460dd 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php @@ -144,10 +144,6 @@ class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface 'required' => true, ]); } - public function getFormDefaultData(): array - { - return []; - } public function getAllowedFormattersTypes() { diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriodWork.php b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriodWork.php index c437454c2..00fa8adb1 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriodWork.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriodWork.php @@ -135,12 +135,9 @@ class ListAccompanyingPeriodWork implements ListInterface, GroupedExportInterfac 'label' => 'export.list.acpw.Date of calculation for associated elements', 'help' => 'export.list.acpw.help_description', 'required' => true, + 'data' => new RollingDate(RollingDate::T_TODAY), ]); } - public function getFormDefaultData(): array - { - return ['calc_date' => new RollingDate(RollingDate::T_TODAY)]; - } public function getAllowedFormattersTypes() { diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListEvaluation.php b/src/Bundle/ChillPersonBundle/Export/Export/ListEvaluation.php index c3e273733..f0985436b 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListEvaluation.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListEvaluation.php @@ -123,12 +123,9 @@ class ListEvaluation implements ListInterface, GroupedExportInterface 'label' => 'export.list.eval.Date of calculation for associated elements', 'help' => 'export.list.eval.help_description', 'required' => true, + 'data' => new RollingDate(RollingDate::T_TODAY), ]); } - public function getFormDefaultData(): array - { - return ['calc_date' => new RollingDate(RollingDate::T_TODAY)]; - } public function getAllowedFormattersTypes() { diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListHouseholdInPeriod.php b/src/Bundle/ChillPersonBundle/Export/Export/ListHouseholdInPeriod.php index 4dcc89495..8894d145d 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListHouseholdInPeriod.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListHouseholdInPeriod.php @@ -75,13 +75,10 @@ class ListHouseholdInPeriod implements ListInterface, GroupedExportInterface ->add('calc_date', PickRollingDateType::class, [ 'label' => 'export.list.household.Date of calculation for associated elements', 'help' => 'export.list.household.help_description', + 'data' => new RollingDate(RollingDate::T_TODAY), 'required' => true, ]); } - public function getFormDefaultData(): array - { - return ['calc_date' => new RollingDate(RollingDate::T_TODAY)]; - } public function getAllowedFormattersTypes() { diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriod.php index e8e495cc7..7cb066e87 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriod.php @@ -80,21 +80,17 @@ class ListPersonWithAccompanyingPeriod implements ExportElementValidatedInterfac } }, ])], + 'data' => array_values($choices), ]); // add a date field for addresses $builder->add('address_date', ChillDateType::class, [ 'label' => 'Data valid at this date', 'help' => 'Data regarding center, addresses, and so on will be computed at this date', + 'data' => new DateTimeImmutable(), 'input' => 'datetime_immutable', ]); } - public function getFormDefaultData(): array - { - $choices = array_combine(ListPersonHelper::FIELDS, ListPersonHelper::FIELDS); - - return ['fields' => array_values($choices), 'address_date' => new DateTimeImmutable()]; - } public function getAllowedFormattersTypes() { diff --git a/src/Bundle/ChillReportBundle/Export/Export/ReportList.php b/src/Bundle/ChillReportBundle/Export/Export/ReportList.php index c551bfb11..9adae0097 100644 --- a/src/Bundle/ChillReportBundle/Export/Export/ReportList.php +++ b/src/Bundle/ChillReportBundle/Export/Export/ReportList.php @@ -137,14 +137,11 @@ class ReportList implements ExportElementValidatedInterface, ListInterface // add a date field for addresses $builder->add('address_date', ChillDateType::class, [ 'label' => 'Address valid at this date', + 'data' => new DateTime(), 'required' => false, 'block_name' => 'list_export_form_address_date', ]); } - public function getFormDefaultData(): array - { - return ['address_date' => new DateTime()]; - } public function getAllowedFormattersTypes() { From 21f11fb034db2cb8d7411480265fff7be29ae145 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sun, 18 Jun 2023 21:36:40 +0200 Subject: [PATCH 214/724] execute rector run on filters and aggregators --- docs/source/_static/code/exports/BirthdateFilter.php | 6 ++++-- docs/source/_static/code/exports/CountPerson.php | 4 ++++ .../ACPAggregators/ByActivityNumberAggregator.php | 4 ++++ .../ACPAggregators/ByCreatorAggregator.php | 4 ++++ .../ACPAggregators/BySocialActionAggregator.php | 4 ++++ .../ACPAggregators/BySocialIssueAggregator.php | 4 ++++ .../ACPAggregators/ByThirdpartyAggregator.php | 4 ++++ .../ACPAggregators/CreatorScopeAggregator.php | 4 ++++ .../Aggregator/ACPAggregators/DateAggregator.php | 5 ++++- .../ACPAggregators/LocationTypeAggregator.php | 4 ++++ .../Export/Aggregator/ActivityTypeAggregator.php | 4 ++++ .../Export/Aggregator/ActivityUserAggregator.php | 4 ++++ .../Export/Aggregator/ActivityUsersAggregator.php | 4 ++++ .../Export/Aggregator/ActivityUsersJobAggregator.php | 4 ++++ .../Aggregator/ActivityUsersScopeAggregator.php | 4 ++++ .../PersonAggregators/ActivityReasonAggregator.php | 4 ++++ .../Export/Aggregator/SentReceivedAggregator.php | 4 ++++ .../Export/LinkedToACP/AvgActivityDuration.php | 4 ++++ .../Export/LinkedToACP/AvgActivityVisitDuration.php | 4 ++++ .../Export/Export/LinkedToACP/CountActivity.php | 4 ++++ .../Export/Export/LinkedToACP/ListActivity.php | 4 ++++ .../Export/LinkedToACP/SumActivityDuration.php | 4 ++++ .../Export/LinkedToACP/SumActivityVisitDuration.php | 4 ++++ .../Export/Export/LinkedToPerson/CountActivity.php | 4 ++++ .../Export/Export/LinkedToPerson/ListActivity.php | 4 ++++ .../Export/LinkedToPerson/StatActivityDuration.php | 4 ++++ .../Export/Filter/ACPFilters/ActivityTypeFilter.php | 4 ++++ .../Export/Filter/ACPFilters/ByCreatorFilter.php | 4 ++++ .../Filter/ACPFilters/BySocialActionFilter.php | 4 ++++ .../Export/Filter/ACPFilters/BySocialIssueFilter.php | 4 ++++ .../Export/Filter/ACPFilters/EmergencyFilter.php | 5 ++++- .../Export/Filter/ACPFilters/HasNoActivityFilter.php | 4 ++++ .../Export/Filter/ACPFilters/LocationFilter.php | 4 ++++ .../Export/Filter/ACPFilters/LocationTypeFilter.php | 4 ++++ .../Export/Filter/ACPFilters/SentReceivedFilter.php | 5 ++++- .../Export/Filter/ACPFilters/UserFilter.php | 4 ++++ .../Export/Filter/ACPFilters/UserScopeFilter.php | 4 ++++ .../Export/Filter/ActivityDateFilter.php | 6 ++++-- .../Export/Filter/ActivityTypeFilter.php | 4 ++++ .../Export/Filter/ActivityUsersFilter.php | 4 ++++ .../Filter/PersonFilters/ActivityReasonFilter.php | 4 ++++ .../PersonHavingActivityBetweenDateFilter.php | 7 ++++--- .../Export/Filter/UsersJobFilter.php | 4 ++++ .../Export/Filter/UsersScopeFilter.php | 4 ++++ .../Export/Aggregator/ByActivityTypeAggregator.php | 4 ++++ .../src/Export/Aggregator/ByUserJobAggregator.php | 4 ++++ .../src/Export/Aggregator/ByUserScopeAggregator.php | 4 ++++ .../src/Export/Export/AvgAsideActivityDuration.php | 4 ++++ .../src/Export/Export/CountAsideActivity.php | 4 ++++ .../src/Export/Export/ListAsideActivity.php | 4 ++++ .../src/Export/Export/SumAsideActivityDuration.php | 4 ++++ .../src/Export/Filter/ByActivityTypeFilter.php | 4 ++++ .../src/Export/Filter/ByDateFilter.php | 6 ++++-- .../src/Export/Filter/ByUserFilter.php | 4 ++++ .../src/Export/Filter/ByUserJobFilter.php | 4 ++++ .../src/Export/Filter/ByUserScopeFilter.php | 4 ++++ .../Export/Aggregator/AgentAggregator.php | 4 ++++ .../Export/Aggregator/CancelReasonAggregator.php | 4 ++++ .../Export/Aggregator/JobAggregator.php | 4 ++++ .../Export/Aggregator/LocationAggregator.php | 4 ++++ .../Export/Aggregator/LocationTypeAggregator.php | 4 ++++ .../Export/Aggregator/MonthYearAggregator.php | 4 ++++ .../Export/Aggregator/ScopeAggregator.php | 4 ++++ .../Export/Aggregator/UrgencyAggregator.php | 4 ++++ .../Export/Export/CountCalendars.php | 4 ++++ .../Export/Export/StatCalendarAvgDuration.php | 4 ++++ .../Export/Export/StatCalendarSumDuration.php | 4 ++++ .../Export/Filter/AgentFilter.php | 4 ++++ .../Export/Filter/BetweenDatesFilter.php | 12 ++++++------ .../Export/Filter/CalendarRangeFilter.php | 5 ++++- .../ChillCalendarBundle/Export/Filter/JobFilter.php | 4 ++++ .../Export/Filter/ScopeFilter.php | 4 ++++ .../Export/Formatter/CSVListFormatter.php | 6 +++++- .../Export/Formatter/CSVPivotedListFormatter.php | 5 +++++ .../Export/Formatter/SpreadsheetListFormatter.php | 6 +++++- .../AdministrativeLocationAggregator.php | 4 ++++ .../ByActionNumberAggregator.php | 4 ++++ .../ClosingMotiveAggregator.php | 4 ++++ .../ConfidentialAggregator.php | 4 ++++ .../CreatorJobAggregator.php | 4 ++++ .../DurationAggregator.php | 4 ++++ .../EmergencyAggregator.php | 4 ++++ .../EvaluationAggregator.php | 4 ++++ .../GeographicalUnitStatAggregator.php | 5 ++++- .../IntensityAggregator.php | 4 ++++ .../OriginAggregator.php | 4 ++++ .../ReferrerAggregator.php | 5 ++++- .../ReferrerScopeAggregator.php | 5 ++++- .../RequestorAggregator.php | 4 ++++ .../ScopeAggregator.php | 4 ++++ .../SocialActionAggregator.php | 4 ++++ .../SocialIssueAggregator.php | 4 ++++ .../AccompanyingCourseAggregators/StepAggregator.php | 8 +++++--- .../UserJobAggregator.php | 4 ++++ .../EvaluationAggregators/ByEndDateAggregator.php | 5 ++++- .../EvaluationAggregators/ByMaxDateAggregator.php | 5 ++++- .../EvaluationAggregators/ByStartDateAggregator.php | 5 ++++- .../EvaluationTypeAggregator.php | 4 ++++ .../HavingEndDateAggregator.php | 4 ++++ .../ChildrenNumberAggregator.php | 8 +++++--- .../HouseholdAggregators/CompositionAggregator.php | 8 +++++--- .../Aggregator/PersonAggregators/AgeAggregator.php | 5 ++++- .../ByHouseholdCompositionAggregator.php | 5 ++++- .../PersonAggregators/CountryOfBirthAggregator.php | 4 ++++ .../PersonAggregators/GenderAggregator.php | 4 ++++ .../PersonAggregators/GeographicalUnitAggregator.php | 5 ++++- .../HouseholdPositionAggregator.php | 5 ++++- .../SocialWorkAggregators/ActionTypeAggregator.php | 4 ++++ .../CurrentActionAggregator.php | 4 ++++ .../SocialWorkAggregators/GoalAggregator.php | 4 ++++ .../SocialWorkAggregators/GoalResultAggregator.php | 4 ++++ .../SocialWorkAggregators/JobAggregator.php | 4 ++++ .../SocialWorkAggregators/ReferrerAggregator.php | 4 ++++ .../SocialWorkAggregators/ResultAggregator.php | 4 ++++ .../SocialWorkAggregators/ScopeAggregator.php | 4 ++++ .../Export/Export/CountAccompanyingCourse.php | 4 ++++ .../Export/Export/CountAccompanyingPeriodWork.php | 4 ++++ .../Export/Export/CountEvaluation.php | 4 ++++ .../Export/Export/CountHousehold.php | 5 ++++- .../Export/CountPersonWithAccompanyingCourse.php | 4 ++++ .../Export/Export/ListAccompanyingPeriod.php | 4 ++++ .../Export/Export/ListAccompanyingPeriodWork.php | 5 ++++- .../Export/Export/ListEvaluation.php | 5 ++++- .../Export/Export/ListHouseholdInPeriod.php | 5 ++++- .../Export/Export/ListPersonDuplicate.php | 5 ++++- .../Export/ListPersonWithAccompanyingPeriod.php | 10 ++++++---- .../Export/Export/StatAccompanyingCourseDuration.php | 5 ++++- .../AccompanyingCourseFilters/ActiveOnDateFilter.php | 8 +++++--- .../ActiveOneDayBetweenDatesFilter.php | 12 ++++++------ .../AdministrativeLocationFilter.php | 4 ++++ .../ClosingMotiveFilter.php | 4 ++++ .../AccompanyingCourseFilters/ConfidentialFilter.php | 9 ++++++--- .../AccompanyingCourseFilters/CreatorFilter.php | 4 ++++ .../AccompanyingCourseFilters/CreatorJobFilter.php | 4 ++++ .../AccompanyingCourseFilters/EmergencyFilter.php | 9 ++++++--- .../AccompanyingCourseFilters/EvaluationFilter.php | 4 ++++ .../GeographicalUnitStatFilter.php | 5 ++++- .../AccompanyingCourseFilters/HasNoActionFilter.php | 4 ++++ .../HasNoReferrerFilter.php | 5 ++++- .../HasTemporaryLocationFilter.php | 5 ++++- ...vingAnAccompanyingPeriodInfoWithinDatesFilter.php | 9 +++++---- .../AccompanyingCourseFilters/IntensityFilter.php | 5 ++++- .../OpenBetweenDatesFilter.php | 12 ++++++------ .../AccompanyingCourseFilters/OriginFilter.php | 4 ++++ .../AccompanyingCourseFilters/ReferrerFilter.php | 5 ++++- .../AccompanyingCourseFilters/RequestorFilter.php | 5 ++++- .../AccompanyingCourseFilters/SocialActionFilter.php | 4 ++++ .../AccompanyingCourseFilters/SocialIssueFilter.php | 4 ++++ .../Filter/AccompanyingCourseFilters/StepFilter.php | 6 ++++-- .../AccompanyingCourseFilters/UserJobFilter.php | 5 ++++- .../AccompanyingCourseFilters/UserScopeFilter.php | 5 ++++- .../UserWorkingOnCourseFilter.php | 4 ++++ .../Filter/EvaluationFilters/ByEndDateFilter.php | 6 ++++-- .../Filter/EvaluationFilters/ByStartDateFilter.php | 6 ++++-- .../EvaluationFilters/CurrentEvaluationsFilter.php | 4 ++++ .../EvaluationFilters/EvaluationTypeFilter.php | 4 ++++ .../Filter/EvaluationFilters/MaxDateFilter.php | 4 ++++ .../Filter/HouseholdFilters/CompositionFilter.php | 8 +++++--- .../Filter/PersonFilters/AddressRefStatusFilter.php | 8 +++++--- .../Export/Filter/PersonFilters/BirthdateFilter.php | 6 ++++-- .../PersonFilters/ByHouseholdCompositionFilter.php | 5 ++++- .../Filter/PersonFilters/DeadOrAliveFilter.php | 5 ++++- .../Export/Filter/PersonFilters/DeathdateFilter.php | 6 ++++-- .../Export/Filter/PersonFilters/GenderFilter.php | 4 ++++ .../Filter/PersonFilters/GeographicalUnitFilter.php | 5 ++++- .../Filter/PersonFilters/MaritalStatusFilter.php | 4 ++++ .../Filter/PersonFilters/NationalityFilter.php | 4 ++++ .../ResidentialAddressAtThirdpartyFilter.php | 5 ++++- .../PersonFilters/ResidentialAddressAtUserFilter.php | 5 ++++- .../PersonFilters/WithoutHouseholdComposition.php | 5 ++++- ...ccompanyingPeriodWorkEndDateBetweenDateFilter.php | 9 +++++---- ...ompanyingPeriodWorkStartDateBetweenDateFilter.php | 9 +++++---- .../Filter/SocialWorkFilters/CurrentActionFilter.php | 4 ++++ .../Export/Filter/SocialWorkFilters/JobFilter.php | 4 ++++ .../Filter/SocialWorkFilters/ReferrerFilter.php | 4 ++++ .../Export/Filter/SocialWorkFilters/ScopeFilter.php | 4 ++++ .../SocialWorkFilters/SocialWorkTypeFilter.php | 5 +++++ .../ChillReportBundle/Export/Export/ReportList.php | 7 ++++--- .../Export/Filter/ReportDateFilter.php | 6 ++++-- 179 files changed, 741 insertions(+), 118 deletions(-) diff --git a/docs/source/_static/code/exports/BirthdateFilter.php b/docs/source/_static/code/exports/BirthdateFilter.php index 64c1d53a9..e25d8b42f 100644 --- a/docs/source/_static/code/exports/BirthdateFilter.php +++ b/docs/source/_static/code/exports/BirthdateFilter.php @@ -62,7 +62,6 @@ class BirthdateFilter implements ExportElementValidatedInterface, FilterInterfac { $builder->add('date_from', DateType::class, [ 'label' => 'Born after this date', - 'data' => new DateTime(), 'attr' => ['class' => 'datepicker'], 'widget' => 'single_text', 'format' => 'dd-MM-yyyy', @@ -70,12 +69,15 @@ class BirthdateFilter implements ExportElementValidatedInterface, FilterInterfac $builder->add('date_to', DateType::class, [ 'label' => 'Born before this date', - 'data' => new DateTime(), 'attr' => ['class' => 'datepicker'], 'widget' => 'single_text', 'format' => 'dd-MM-yyyy', ]); } + public function getFormDefaultData(): array + { + return ['date_from' => new DateTime(), 'date_to' => new DateTime()]; + } // here, we create a simple string which will describe the action of // the filter in the Response diff --git a/docs/source/_static/code/exports/CountPerson.php b/docs/source/_static/code/exports/CountPerson.php index afe19c73b..be800e52c 100644 --- a/docs/source/_static/code/exports/CountPerson.php +++ b/docs/source/_static/code/exports/CountPerson.php @@ -36,6 +36,10 @@ class CountPerson implements ExportInterface { // this export does not add any form } + public function getFormDefaultData(): array + { + return []; + } public function getAllowedFormattersTypes() { diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByActivityNumberAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByActivityNumberAggregator.php index 5c6656009..c23db738e 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByActivityNumberAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByActivityNumberAggregator.php @@ -40,6 +40,10 @@ class ByActivityNumberAggregator implements AggregatorInterface { // No form needed } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByCreatorAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByCreatorAggregator.php index 69149737b..917459de3 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByCreatorAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByCreatorAggregator.php @@ -52,6 +52,10 @@ class ByCreatorAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialActionAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialActionAggregator.php index 89732412d..1a75357ae 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialActionAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialActionAggregator.php @@ -57,6 +57,10 @@ class BySocialActionAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialIssueAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialIssueAggregator.php index 158e87664..9100a8c8f 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialIssueAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialIssueAggregator.php @@ -57,6 +57,10 @@ class BySocialIssueAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByThirdpartyAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByThirdpartyAggregator.php index c3ca6d59c..ac05b153c 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByThirdpartyAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByThirdpartyAggregator.php @@ -57,6 +57,10 @@ class ByThirdpartyAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/CreatorScopeAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/CreatorScopeAggregator.php index 2c7ec1483..a4b5258e2 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/CreatorScopeAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/CreatorScopeAggregator.php @@ -57,6 +57,10 @@ class CreatorScopeAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/DateAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/DateAggregator.php index a2f465a38..4ede5b4c4 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/DateAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/DateAggregator.php @@ -76,9 +76,12 @@ class DateAggregator implements AggregatorInterface 'multiple' => false, 'expanded' => true, 'empty_data' => self::DEFAULT_CHOICE, - 'data' => self::DEFAULT_CHOICE, ]); } + public function getFormDefaultData(): array + { + return ['frequency' => self::DEFAULT_CHOICE]; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/LocationTypeAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/LocationTypeAggregator.php index ec4ce6315..c72609e2c 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/LocationTypeAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/LocationTypeAggregator.php @@ -57,6 +57,10 @@ class LocationTypeAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php index 7cd16718e..a74428b4a 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php @@ -60,6 +60,10 @@ class ActivityTypeAggregator implements AggregatorInterface { // no form required for this aggregator } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data): Closure { diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUserAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUserAggregator.php index 9bde692c6..2fab2af83 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUserAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUserAggregator.php @@ -58,6 +58,10 @@ class ActivityUserAggregator implements AggregatorInterface { // nothing to add } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, $values, $data): Closure { diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersAggregator.php index 139f2743e..e1e9f161d 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersAggregator.php @@ -56,6 +56,10 @@ class ActivityUsersAggregator implements AggregatorInterface { // nothing to add on the form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersJobAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersJobAggregator.php index 5741a0e58..721078989 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersJobAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersJobAggregator.php @@ -55,6 +55,10 @@ class ActivityUsersJobAggregator implements \Chill\MainBundle\Export\AggregatorI { // nothing to add in the form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersScopeAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersScopeAggregator.php index 15da300be..d7932e9e8 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersScopeAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersScopeAggregator.php @@ -55,6 +55,10 @@ class ActivityUsersScopeAggregator implements \Chill\MainBundle\Export\Aggregato { // nothing to add in the form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/PersonAggregators/ActivityReasonAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/PersonAggregators/ActivityReasonAggregator.php index eaccf95cb..2537f2cf6 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/PersonAggregators/ActivityReasonAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/PersonAggregators/ActivityReasonAggregator.php @@ -110,6 +110,10 @@ class ActivityReasonAggregator implements AggregatorInterface, ExportElementVali ] ); } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/SentReceivedAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/SentReceivedAggregator.php index 5f772e156..ae1dae375 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/SentReceivedAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/SentReceivedAggregator.php @@ -47,6 +47,10 @@ class SentReceivedAggregator implements AggregatorInterface { // No form needed } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data): callable { diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php index 34771d077..6930784d3 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php @@ -39,6 +39,10 @@ class AvgActivityDuration implements ExportInterface, GroupedExportInterface public function buildForm(FormBuilderInterface $builder) { } + public function getFormDefaultData(): array + { + return []; + } public function getAllowedFormattersTypes(): array { diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php index df21362cd..f1e926c64 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php @@ -40,6 +40,10 @@ class AvgActivityVisitDuration implements ExportInterface, GroupedExportInterfac { // TODO: Implement buildForm() method. } + public function getFormDefaultData(): array + { + return []; + } public function getAllowedFormattersTypes(): array { diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php index 6b7b1562d..d473a925a 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php @@ -39,6 +39,10 @@ class CountActivity implements ExportInterface, GroupedExportInterface public function buildForm(FormBuilderInterface $builder) { } + public function getFormDefaultData(): array + { + return []; + } public function getAllowedFormattersTypes(): array { diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php index 026e16f90..9ed6bcda2 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php @@ -44,6 +44,10 @@ class ListActivity implements ListInterface, GroupedExportInterface { $this->helper->buildForm($builder); } + public function getFormDefaultData(): array + { + return []; + } public function getAllowedFormattersTypes() { diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php index e916cab54..8adb3b77f 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php @@ -40,6 +40,10 @@ class SumActivityDuration implements ExportInterface, GroupedExportInterface { // TODO: Implement buildForm() method. } + public function getFormDefaultData(): array + { + return []; + } public function getAllowedFormattersTypes(): array { diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php index 18a47289c..cc424e68b 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php @@ -40,6 +40,10 @@ class SumActivityVisitDuration implements ExportInterface, GroupedExportInterfac { // TODO: Implement buildForm() method. } + public function getFormDefaultData(): array + { + return []; + } public function getAllowedFormattersTypes(): array { diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/CountActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/CountActivity.php index 4246df173..6360251b3 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/CountActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/CountActivity.php @@ -35,6 +35,10 @@ class CountActivity implements ExportInterface, GroupedExportInterface public function buildForm(FormBuilderInterface $builder) { } + public function getFormDefaultData(): array + { + return []; + } public function getAllowedFormattersTypes() { diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php index 60110c9a8..d14111ba7 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php @@ -88,6 +88,10 @@ class ListActivity implements ListInterface, GroupedExportInterface ])], ]); } + public function getFormDefaultData(): array + { + return []; + } public function getAllowedFormattersTypes() { diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/StatActivityDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/StatActivityDuration.php index 050034954..e68d47cd3 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/StatActivityDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/StatActivityDuration.php @@ -53,6 +53,10 @@ class StatActivityDuration implements ExportInterface, GroupedExportInterface public function buildForm(FormBuilderInterface $builder) { } + public function getFormDefaultData(): array + { + return []; + } public function getAllowedFormattersTypes() { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php index c6616a4c6..4ffc3b38c 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php @@ -68,6 +68,10 @@ class ActivityTypeFilter implements FilterInterface 'expanded' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ByCreatorFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ByCreatorFilter.php index 322393f32..add9c7c3d 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ByCreatorFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ByCreatorFilter.php @@ -52,6 +52,10 @@ class ByCreatorFilter implements FilterInterface 'multiple' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialActionFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialActionFilter.php index d0c1b0fc7..08f6bbbc3 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialActionFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialActionFilter.php @@ -60,6 +60,10 @@ class BySocialActionFilter implements FilterInterface 'multiple' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialIssueFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialIssueFilter.php index bbb882a65..bd6e2ef4a 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialIssueFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialIssueFilter.php @@ -60,6 +60,10 @@ class BySocialIssueFilter implements FilterInterface 'multiple' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/EmergencyFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/EmergencyFilter.php index b79c2ca10..807ba3903 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/EmergencyFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/EmergencyFilter.php @@ -68,9 +68,12 @@ class EmergencyFilter implements FilterInterface 'multiple' => false, 'expanded' => true, 'empty_data' => self::DEFAULT_CHOICE, - 'data' => self::DEFAULT_CHOICE, ]); } + public function getFormDefaultData(): array + { + return ['accepted_emergency' => self::DEFAULT_CHOICE]; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/HasNoActivityFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/HasNoActivityFilter.php index 570f42ae0..b5dab4009 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/HasNoActivityFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/HasNoActivityFilter.php @@ -44,6 +44,10 @@ class HasNoActivityFilter implements FilterInterface { //no form needed } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationFilter.php index 3d69d1633..312f3a6a0 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationFilter.php @@ -46,6 +46,10 @@ class LocationFilter implements FilterInterface 'label' => 'pick location', ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationTypeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationTypeFilter.php index 5fe928b6c..1c3415460 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationTypeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationTypeFilter.php @@ -65,6 +65,10 @@ class LocationTypeFilter implements FilterInterface //'label' => false, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/SentReceivedFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/SentReceivedFilter.php index 8daa7a781..0f2a1c7e4 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/SentReceivedFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/SentReceivedFilter.php @@ -69,9 +69,12 @@ class SentReceivedFilter implements FilterInterface 'multiple' => false, 'expanded' => true, 'empty_data' => self::DEFAULT_CHOICE, - 'data' => self::DEFAULT_CHOICE, ]); } + public function getFormDefaultData(): array + { + return ['accepted_sentreceived' => self::DEFAULT_CHOICE]; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserFilter.php index 6350f3ace..9ae988579 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserFilter.php @@ -61,6 +61,10 @@ class UserFilter implements FilterInterface 'label' => 'Creators', ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserScopeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserScopeFilter.php index 4319c100a..adb1e94f1 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserScopeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserScopeFilter.php @@ -71,6 +71,10 @@ class UserScopeFilter implements FilterInterface 'expanded' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityDateFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityDateFilter.php index f2216c929..e582acc12 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityDateFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityDateFilter.php @@ -80,11 +80,9 @@ class ActivityDateFilter implements FilterInterface $builder ->add('date_from', PickRollingDateType::class, [ 'label' => 'Activities after this date', - 'data' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START), ]) ->add('date_to', PickRollingDateType::class, [ 'label' => 'Activities before this date', - 'data' => new RollingDate(RollingDate::T_TODAY), ]); $builder->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) { @@ -127,6 +125,10 @@ class ActivityDateFilter implements FilterInterface } }); } + public function getFormDefaultData(): array + { + return ['date_from' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START), 'date_to' => new RollingDate(RollingDate::T_TODAY)]; + } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php index b9d39c3ce..8dfcb543c 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php @@ -78,6 +78,10 @@ class ActivityTypeFilter implements ExportElementValidatedInterface, FilterInter ], ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityUsersFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityUsersFilter.php index 2f6cd8462..a63ca2629 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityUsersFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityUsersFilter.php @@ -56,6 +56,10 @@ class ActivityUsersFilter implements FilterInterface 'label' => 'Users', ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/ActivityReasonFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/ActivityReasonFilter.php index c55d579e4..31cfde6b6 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/ActivityReasonFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/ActivityReasonFilter.php @@ -82,6 +82,10 @@ class ActivityReasonFilter implements ExportElementValidatedInterface, FilterInt 'expanded' => false, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/PersonHavingActivityBetweenDateFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/PersonHavingActivityBetweenDateFilter.php index e3c85fe9c..490b5fd0c 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/PersonHavingActivityBetweenDateFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/PersonHavingActivityBetweenDateFilter.php @@ -112,7 +112,6 @@ class PersonHavingActivityBetweenDateFilter implements ExportElementValidatedInt { $builder->add('date_from', DateType::class, [ 'label' => 'Implied in an activity after this date', - 'data' => new DateTime(), 'attr' => ['class' => 'datepicker'], 'widget' => 'single_text', 'format' => 'dd-MM-yyyy', @@ -120,7 +119,6 @@ class PersonHavingActivityBetweenDateFilter implements ExportElementValidatedInt $builder->add('date_to', DateType::class, [ 'label' => 'Implied in an activity before this date', - 'data' => new DateTime(), 'attr' => ['class' => 'datepicker'], 'widget' => 'single_text', 'format' => 'dd-MM-yyyy', @@ -130,7 +128,6 @@ class PersonHavingActivityBetweenDateFilter implements ExportElementValidatedInt 'class' => ActivityReason::class, 'choice_label' => fn (ActivityReason $reason): ?string => $this->translatableStringHelper->localize($reason->getName()), 'group_by' => fn (ActivityReason $reason): ?string => $this->translatableStringHelper->localize($reason->getCategory()->getName()), - 'data' => $this->activityReasonRepository->findAll(), 'multiple' => true, 'expanded' => false, 'label' => 'Activity reasons for those activities', @@ -176,6 +173,10 @@ class PersonHavingActivityBetweenDateFilter implements ExportElementValidatedInt } }); } + public function getFormDefaultData(): array + { + return ['date_from' => new DateTime(), 'date_to' => new DateTime(), 'reasons' => $this->activityReasonRepository->findAll()]; + } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/UsersJobFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/UsersJobFilter.php index b52ef441c..e85b2d247 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/UsersJobFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/UsersJobFilter.php @@ -60,6 +60,10 @@ class UsersJobFilter implements FilterInterface 'expanded' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/UsersScopeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/UsersScopeFilter.php index 61b12264e..07ff509ce 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/UsersScopeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/UsersScopeFilter.php @@ -67,6 +67,10 @@ class UsersScopeFilter implements FilterInterface 'expanded' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByActivityTypeAggregator.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByActivityTypeAggregator.php index 32418e3c3..8ae43534d 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByActivityTypeAggregator.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByActivityTypeAggregator.php @@ -50,6 +50,10 @@ class ByActivityTypeAggregator implements AggregatorInterface { // No form needed } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserJobAggregator.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserJobAggregator.php index d2fe7c2f2..f09a704e2 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserJobAggregator.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserJobAggregator.php @@ -57,6 +57,10 @@ class ByUserJobAggregator implements AggregatorInterface { // nothing to add in the form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserScopeAggregator.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserScopeAggregator.php index 6c06ee756..3dd465db2 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserScopeAggregator.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserScopeAggregator.php @@ -57,6 +57,10 @@ class ByUserScopeAggregator implements AggregatorInterface { // nothing to add in the form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/AvgAsideActivityDuration.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/AvgAsideActivityDuration.php index f3db629cb..2b28062f6 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/AvgAsideActivityDuration.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/AvgAsideActivityDuration.php @@ -34,6 +34,10 @@ class AvgAsideActivityDuration implements ExportInterface, GroupedExportInterfac public function buildForm(FormBuilderInterface $builder) { } + public function getFormDefaultData(): array + { + return []; + } public function getAllowedFormattersTypes(): array { diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/CountAsideActivity.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/CountAsideActivity.php index 9204fad4b..91210f764 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/CountAsideActivity.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/CountAsideActivity.php @@ -34,6 +34,10 @@ class CountAsideActivity implements ExportInterface, GroupedExportInterface public function buildForm(FormBuilderInterface $builder) { } + public function getFormDefaultData(): array + { + return []; + } public function getAllowedFormattersTypes(): array { diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/ListAsideActivity.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/ListAsideActivity.php index aee168174..b46e120b5 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/ListAsideActivity.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/ListAsideActivity.php @@ -73,6 +73,10 @@ final class ListAsideActivity implements ListInterface, GroupedExportInterface public function buildForm(FormBuilderInterface $builder) { } + public function getFormDefaultData(): array + { + return []; + } public function getAllowedFormattersTypes() { diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/SumAsideActivityDuration.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/SumAsideActivityDuration.php index af17a2591..741f129f1 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/SumAsideActivityDuration.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/SumAsideActivityDuration.php @@ -34,6 +34,10 @@ class SumAsideActivityDuration implements ExportInterface, GroupedExportInterfac public function buildForm(FormBuilderInterface $builder) { } + public function getFormDefaultData(): array + { + return []; + } public function getAllowedFormattersTypes(): array { diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByActivityTypeFilter.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByActivityTypeFilter.php index 3ad8e0e93..3d389f5b3 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByActivityTypeFilter.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByActivityTypeFilter.php @@ -76,6 +76,10 @@ class ByActivityTypeFilter implements FilterInterface }, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByDateFilter.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByDateFilter.php index 7a1b6f4dc..98a254bc4 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByDateFilter.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByDateFilter.php @@ -72,11 +72,9 @@ class ByDateFilter implements FilterInterface $builder ->add('date_from', PickRollingDateType::class, [ 'label' => 'export.filter.Aside activities after this date', - 'data' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START), ]) ->add('date_to', PickRollingDateType::class, [ 'label' => 'export.filter.Aside activities before this date', - 'data' => new RollingDate(RollingDate::T_TODAY), ]); $builder->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) { @@ -119,6 +117,10 @@ class ByDateFilter implements FilterInterface } }); } + public function getFormDefaultData(): array + { + return ['date_from' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START), 'date_to' => new RollingDate(RollingDate::T_TODAY)]; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserFilter.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserFilter.php index 795c813cd..2858d3417 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserFilter.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserFilter.php @@ -53,6 +53,10 @@ class ByUserFilter implements FilterInterface 'label' => 'Creators', ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserJobFilter.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserJobFilter.php index 86194b123..55f477768 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserJobFilter.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserJobFilter.php @@ -60,6 +60,10 @@ class ByUserJobFilter implements FilterInterface 'expanded' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserScopeFilter.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserScopeFilter.php index 4342e11eb..8fa51866d 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserScopeFilter.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserScopeFilter.php @@ -67,6 +67,10 @@ class ByUserScopeFilter implements FilterInterface 'expanded' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/AgentAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/AgentAggregator.php index e1de9f399..1b1b170b8 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/AgentAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/AgentAggregator.php @@ -58,6 +58,10 @@ final class AgentAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data): Closure { diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/CancelReasonAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/CancelReasonAggregator.php index 611cb6d79..a9967c470 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/CancelReasonAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/CancelReasonAggregator.php @@ -59,6 +59,10 @@ class CancelReasonAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data): Closure { diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/JobAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/JobAggregator.php index 23292a5b0..51291b49e 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/JobAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/JobAggregator.php @@ -58,6 +58,10 @@ final class JobAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data): Closure { diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationAggregator.php index 940000f47..952d0c5d5 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationAggregator.php @@ -52,6 +52,10 @@ final class LocationAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data): Closure { diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationTypeAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationTypeAggregator.php index 6574e3934..a9b369af0 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationTypeAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationTypeAggregator.php @@ -58,6 +58,10 @@ final class LocationTypeAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data): Closure { diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/MonthYearAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/MonthYearAggregator.php index 7b2a5e898..b3c2aaf19 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/MonthYearAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/MonthYearAggregator.php @@ -40,6 +40,10 @@ class MonthYearAggregator implements AggregatorInterface { // No form needed } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data): Closure { diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/ScopeAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/ScopeAggregator.php index 3aff3e0d8..01874b0e2 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/ScopeAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/ScopeAggregator.php @@ -58,6 +58,10 @@ final class ScopeAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data): Closure { diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/UrgencyAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/UrgencyAggregator.php index ad5910461..66ab8b42e 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/UrgencyAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/UrgencyAggregator.php @@ -56,6 +56,10 @@ class UrgencyAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data): Closure { diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php b/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php index 9d3f00f99..e0391948e 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php @@ -36,6 +36,10 @@ class CountCalendars implements ExportInterface, GroupedExportInterface { // No form necessary } + public function getFormDefaultData(): array + { + return []; + } public function getAllowedFormattersTypes(): array { diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php index 14dd42d6b..dcbfb695b 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php @@ -36,6 +36,10 @@ class StatCalendarAvgDuration implements ExportInterface, GroupedExportInterface { // no form needed } + public function getFormDefaultData(): array + { + return []; + } public function getAllowedFormattersTypes(): array { diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php index 1d31bfa26..7f509a896 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php @@ -36,6 +36,10 @@ class StatCalendarSumDuration implements ExportInterface, GroupedExportInterface { // no form needed } + public function getFormDefaultData(): array + { + return []; + } public function getAllowedFormattersTypes(): array { diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php index b58cee594..0cef89c20 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php @@ -63,6 +63,10 @@ class AgentFilter implements FilterInterface 'expanded' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/BetweenDatesFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/BetweenDatesFilter.php index 59019ac03..4260ecd99 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/BetweenDatesFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/BetweenDatesFilter.php @@ -60,12 +60,12 @@ class BetweenDatesFilter implements FilterInterface public function buildForm(FormBuilderInterface $builder) { $builder - ->add('date_from', PickRollingDateType::class, [ - 'data' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START), - ]) - ->add('date_to', PickRollingDateType::class, [ - 'data' => new RollingDate(RollingDate::T_TODAY), - ]); + ->add('date_from', PickRollingDateType::class, []) + ->add('date_to', PickRollingDateType::class, []); + } + public function getFormDefaultData(): array + { + return ['date_from' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START), 'date_to' => new RollingDate(RollingDate::T_TODAY)]; } public function describeAction($data, $format = 'string'): array diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/CalendarRangeFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/CalendarRangeFilter.php index d6c38e163..5ffb7c01f 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/CalendarRangeFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/CalendarRangeFilter.php @@ -69,9 +69,12 @@ class CalendarRangeFilter implements FilterInterface 'multiple' => false, 'expanded' => true, 'empty_data' => self::DEFAULT_CHOICE, - 'data' => self::DEFAULT_CHOICE, ]); } + public function getFormDefaultData(): array + { + return ['hasCalendarRange' => self::DEFAULT_CHOICE]; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php index 69fb24447..d02bb8e9d 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php @@ -76,6 +76,10 @@ class JobFilter implements FilterInterface 'expanded' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php index 08d9ae023..d8a40da72 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php @@ -76,6 +76,10 @@ class ScopeFilter implements FilterInterface 'expanded' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillMainBundle/Export/Formatter/CSVListFormatter.php b/src/Bundle/ChillMainBundle/Export/Formatter/CSVListFormatter.php index b84c80118..d11aea068 100644 --- a/src/Bundle/ChillMainBundle/Export/Formatter/CSVListFormatter.php +++ b/src/Bundle/ChillMainBundle/Export/Formatter/CSVListFormatter.php @@ -85,10 +85,14 @@ class CSVListFormatter implements FormatterInterface 'expanded' => true, 'multiple' => false, 'label' => 'Add a number on first column', - 'data' => true, ]); } + public function getFormDefaultData(array $aggregatorAliases): array + { + return ['numerotation' => true]; + } + public function getName() { return 'CSV vertical list'; diff --git a/src/Bundle/ChillMainBundle/Export/Formatter/CSVPivotedListFormatter.php b/src/Bundle/ChillMainBundle/Export/Formatter/CSVPivotedListFormatter.php index 63d691443..ae4d3629f 100644 --- a/src/Bundle/ChillMainBundle/Export/Formatter/CSVPivotedListFormatter.php +++ b/src/Bundle/ChillMainBundle/Export/Formatter/CSVPivotedListFormatter.php @@ -84,6 +84,11 @@ class CSVPivotedListFormatter implements FormatterInterface ]); } + public function getFormDefaultData(array $aggregatorAliases): array + { + return ['numerotation' => true]; + } + public function getName() { return 'CSV horizontal list'; diff --git a/src/Bundle/ChillMainBundle/Export/Formatter/SpreadsheetListFormatter.php b/src/Bundle/ChillMainBundle/Export/Formatter/SpreadsheetListFormatter.php index 0e5e339ea..b82ab8f61 100644 --- a/src/Bundle/ChillMainBundle/Export/Formatter/SpreadsheetListFormatter.php +++ b/src/Bundle/ChillMainBundle/Export/Formatter/SpreadsheetListFormatter.php @@ -104,10 +104,14 @@ class SpreadsheetListFormatter implements FormatterInterface 'expanded' => true, 'multiple' => false, 'label' => 'Add a number on first column', - 'data' => true, ]); } + public function getFormDefaultData(array $aggregatorAliases): array + { + return ['numerotation' => true, 'format' => 'xlsx']; + } + public function getName() { return 'Spreadsheet list formatter (.xlsx, .ods)'; diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/AdministrativeLocationAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/AdministrativeLocationAggregator.php index 96deac574..56fdc07d7 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/AdministrativeLocationAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/AdministrativeLocationAggregator.php @@ -57,6 +57,10 @@ class AdministrativeLocationAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ByActionNumberAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ByActionNumberAggregator.php index 2dffccbbb..104b934ca 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ByActionNumberAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ByActionNumberAggregator.php @@ -39,6 +39,10 @@ class ByActionNumberAggregator implements AggregatorInterface { // No form needed } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregator.php index 342958361..73cfdc7b9 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregator.php @@ -52,6 +52,10 @@ class ClosingMotiveAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ConfidentialAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ConfidentialAggregator.php index e9b9e28fa..4ad18030e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ConfidentialAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ConfidentialAggregator.php @@ -48,6 +48,10 @@ class ConfidentialAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/CreatorJobAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/CreatorJobAggregator.php index c336a8887..5a060bcd7 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/CreatorJobAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/CreatorJobAggregator.php @@ -57,6 +57,10 @@ class CreatorJobAggregator implements AggregatorInterface { // No form needed } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/DurationAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/DurationAggregator.php index 0dc66e81e..581c7d6e5 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/DurationAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/DurationAggregator.php @@ -84,6 +84,10 @@ final class DurationAggregator implements AggregatorInterface 'expanded' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EmergencyAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EmergencyAggregator.php index 02f9f5cd9..4429c7b62 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EmergencyAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EmergencyAggregator.php @@ -48,6 +48,10 @@ class EmergencyAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EvaluationAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EvaluationAggregator.php index b6436efc0..119fa50b7 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EvaluationAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EvaluationAggregator.php @@ -61,6 +61,10 @@ final class EvaluationAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php index d001cbef7..a83634830 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php @@ -121,7 +121,6 @@ final class GeographicalUnitStatAggregator implements AggregatorInterface ->add('date_calc', PickRollingDateType::class, [ 'label' => 'Compute geographical location at date', 'required' => true, - 'data' => new RollingDate(RollingDate::T_TODAY), ]) ->add('level', EntityType::class, [ 'label' => 'Geographical layer', @@ -133,6 +132,10 @@ final class GeographicalUnitStatAggregator implements AggregatorInterface 'expanded' => true, ]); } + public function getFormDefaultData(): array + { + return ['date_calc' => new RollingDate(RollingDate::T_TODAY)]; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/IntensityAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/IntensityAggregator.php index a3618f40f..ac55d7734 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/IntensityAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/IntensityAggregator.php @@ -48,6 +48,10 @@ class IntensityAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/OriginAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/OriginAggregator.php index 37d0c7b20..1d01920d5 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/OriginAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/OriginAggregator.php @@ -59,6 +59,10 @@ final class OriginAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerAggregator.php index a09097fd2..7b826600a 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerAggregator.php @@ -81,11 +81,14 @@ final class ReferrerAggregator implements AggregatorInterface { $builder ->add('date_calc', PickRollingDateType::class, [ - 'data' => new RollingDate(RollingDate::T_TODAY), 'label' => 'export.aggregator.course.by_referrer.Computation date for referrer', 'required' => true, ]); } + public function getFormDefaultData(): array + { + return ['date_calc' => new RollingDate(RollingDate::T_TODAY)]; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerScopeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerScopeAggregator.php index ccbd21da1..adfd9b489 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerScopeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerScopeAggregator.php @@ -88,11 +88,14 @@ class ReferrerScopeAggregator implements AggregatorInterface public function buildForm(FormBuilderInterface $builder) { $builder->add('date_calc', PickRollingDateType::class, [ - 'data' => new RollingDate(RollingDate::T_TODAY), 'label' => 'export.aggregator.course.by_user_scope.Computation date for referrer', 'required' => true, ]); } + public function getFormDefaultData(): array + { + return ['date_calc' => new RollingDate(RollingDate::T_TODAY)]; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/RequestorAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/RequestorAggregator.php index 7b5cf0edd..3baf9bd33 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/RequestorAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/RequestorAggregator.php @@ -69,6 +69,10 @@ final class RequestorAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ScopeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ScopeAggregator.php index 8f34661bb..253727c89 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ScopeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ScopeAggregator.php @@ -57,6 +57,10 @@ final class ScopeAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialActionAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialActionAggregator.php index 3bdd6549e..b82b47ad0 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialActionAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialActionAggregator.php @@ -58,6 +58,10 @@ final class SocialActionAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialIssueAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialIssueAggregator.php index 12fa5a454..29fcba4a2 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialIssueAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialIssueAggregator.php @@ -58,6 +58,10 @@ final class SocialIssueAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/StepAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/StepAggregator.php index 85cfc3190..7632f72f0 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/StepAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/StepAggregator.php @@ -76,9 +76,11 @@ final class StepAggregator implements AggregatorInterface public function buildForm(FormBuilderInterface $builder) { - $builder->add('on_date', PickRollingDateType::class, [ - 'data' => new RollingDate(RollingDate::T_TODAY), - ]); + $builder->add('on_date', PickRollingDateType::class, []); + } + public function getFormDefaultData(): array + { + return ['on_date' => new RollingDate(RollingDate::T_TODAY)]; } public function getLabels($key, array $values, $data) diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/UserJobAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/UserJobAggregator.php index a8acdcf12..13d1e3f83 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/UserJobAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/UserJobAggregator.php @@ -57,6 +57,10 @@ final class UserJobAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByEndDateAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByEndDateAggregator.php index 2f4275c49..cb66fa600 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByEndDateAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByEndDateAggregator.php @@ -75,9 +75,12 @@ class ByEndDateAggregator implements AggregatorInterface 'multiple' => false, 'expanded' => true, 'empty_data' => self::DEFAULT_CHOICE, - 'data' => self::DEFAULT_CHOICE, ]); } + public function getFormDefaultData(): array + { + return ['frequency' => self::DEFAULT_CHOICE]; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByMaxDateAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByMaxDateAggregator.php index 9283fd9dc..af6dfc465 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByMaxDateAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByMaxDateAggregator.php @@ -75,9 +75,12 @@ class ByMaxDateAggregator implements AggregatorInterface 'multiple' => false, 'expanded' => true, 'empty_data' => self::DEFAULT_CHOICE, - 'data' => self::DEFAULT_CHOICE, ]); } + public function getFormDefaultData(): array + { + return ['frequency' => self::DEFAULT_CHOICE]; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByStartDateAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByStartDateAggregator.php index cd183b25e..87a6a672b 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByStartDateAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByStartDateAggregator.php @@ -75,9 +75,12 @@ class ByStartDateAggregator implements AggregatorInterface 'multiple' => false, 'expanded' => true, 'empty_data' => self::DEFAULT_CHOICE, - 'data' => self::DEFAULT_CHOICE, ]); } + public function getFormDefaultData(): array + { + return ['frequency' => self::DEFAULT_CHOICE]; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/EvaluationTypeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/EvaluationTypeAggregator.php index 0c13611cb..a48ed763d 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/EvaluationTypeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/EvaluationTypeAggregator.php @@ -52,6 +52,10 @@ class EvaluationTypeAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/HavingEndDateAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/HavingEndDateAggregator.php index e33bb326f..e710949fd 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/HavingEndDateAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/HavingEndDateAggregator.php @@ -48,6 +48,10 @@ class HavingEndDateAggregator implements AggregatorInterface { // No form needed } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/ChildrenNumberAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/ChildrenNumberAggregator.php index 0c9bc623f..1c5b3dc2c 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/ChildrenNumberAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/ChildrenNumberAggregator.php @@ -72,9 +72,11 @@ class ChildrenNumberAggregator implements AggregatorInterface public function buildForm(FormBuilderInterface $builder) { - $builder->add('on_date', PickRollingDateType::class, [ - 'data' => new RollingDate(RollingDate::T_TODAY), - ]); + $builder->add('on_date', PickRollingDateType::class, []); + } + public function getFormDefaultData(): array + { + return ['on_date' => new RollingDate(RollingDate::T_TODAY)]; } public function getLabels($key, array $values, $data) diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/CompositionAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/CompositionAggregator.php index 52bcd88e5..62fc20173 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/CompositionAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/CompositionAggregator.php @@ -77,9 +77,11 @@ class CompositionAggregator implements AggregatorInterface public function buildForm(FormBuilderInterface $builder) { - $builder->add('on_date', PickRollingDateType::class, [ - 'data' => new RollingDate(RollingDate::T_TODAY), - ]); + $builder->add('on_date', PickRollingDateType::class, []); + } + public function getFormDefaultData(): array + { + return ['on_date' => new RollingDate(RollingDate::T_TODAY)]; } public function getLabels($key, array $values, $data) diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/AgeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/AgeAggregator.php index 365a73704..2a63e475a 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/AgeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/AgeAggregator.php @@ -50,12 +50,15 @@ final class AgeAggregator implements AggregatorInterface, ExportElementValidated { $builder->add('date_age_calculation', DateType::class, [ 'label' => 'Calculate age in relation to this date', - 'data' => new DateTime(), 'attr' => ['class' => 'datepicker'], 'widget' => 'single_text', 'format' => 'dd-MM-yyyy', ]); } + public function getFormDefaultData(): array + { + return ['date_age_calculation' => new DateTime()]; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/ByHouseholdCompositionAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/ByHouseholdCompositionAggregator.php index 80f0faa17..16b62c2b5 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/ByHouseholdCompositionAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/ByHouseholdCompositionAggregator.php @@ -94,9 +94,12 @@ class ByHouseholdCompositionAggregator implements AggregatorInterface { $builder->add('date_calc', PickRollingDateType::class, [ 'label' => 'export.aggregator.person.by_household_composition.Calc date', - 'data' => new RollingDate(RollingDate::T_TODAY), ]); } + public function getFormDefaultData(): array + { + return ['date_calc' => new RollingDate(RollingDate::T_TODAY)]; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/CountryOfBirthAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/CountryOfBirthAggregator.php index 3d785b586..90882245e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/CountryOfBirthAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/CountryOfBirthAggregator.php @@ -108,6 +108,10 @@ final class CountryOfBirthAggregator implements AggregatorInterface, ExportEleme 'multiple' => false, ]); } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GenderAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GenderAggregator.php index f76420047..dbe3d19d3 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GenderAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GenderAggregator.php @@ -48,6 +48,10 @@ final class GenderAggregator implements AggregatorInterface public function buildForm(FormBuilderInterface $builder) { } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GeographicalUnitAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GeographicalUnitAggregator.php index 5d73c1fdd..a72d91db2 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GeographicalUnitAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GeographicalUnitAggregator.php @@ -93,7 +93,6 @@ class GeographicalUnitAggregator implements AggregatorInterface ->add('date_calc', PickRollingDateType::class, [ 'label' => 'Address valid at this date', 'required' => true, - 'data' => new RollingDate(RollingDate::T_TODAY), ]) ->add('level', EntityType::class, [ 'label' => 'Geographical layer', @@ -105,6 +104,10 @@ class GeographicalUnitAggregator implements AggregatorInterface 'expanded' => true, ]); } + public function getFormDefaultData(): array + { + return ['date_calc' => new RollingDate(RollingDate::T_TODAY)]; + } public static function getDefaultAlias(): string { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/HouseholdPositionAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/HouseholdPositionAggregator.php index 107634803..63d84d4da 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/HouseholdPositionAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/HouseholdPositionAggregator.php @@ -90,9 +90,12 @@ final class HouseholdPositionAggregator implements AggregatorInterface, ExportEl { $builder->add('date_position', PickRollingDateType::class, [ 'label' => 'Household position in relation to this date', - 'data' => new RollingDate(RollingDate::T_TODAY), ]); } + public function getFormDefaultData(): array + { + return ['date_position' => new RollingDate(RollingDate::T_TODAY)]; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregator.php index c1fccb968..66c87d94f 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregator.php @@ -75,6 +75,10 @@ final class ActionTypeAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CurrentActionAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CurrentActionAggregator.php index 58fcb2874..539c9f286 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CurrentActionAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CurrentActionAggregator.php @@ -51,6 +51,10 @@ class CurrentActionAggregator implements AggregatorInterface { // No form needed } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalAggregator.php index 8cc6a25da..4c0e8b393 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalAggregator.php @@ -55,6 +55,10 @@ final class GoalAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalResultAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalResultAggregator.php index 17b263d7e..c99ee85ea 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalResultAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalResultAggregator.php @@ -68,6 +68,10 @@ class GoalResultAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/JobAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/JobAggregator.php index cbf07091f..8271c90e3 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/JobAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/JobAggregator.php @@ -57,6 +57,10 @@ final class JobAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ReferrerAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ReferrerAggregator.php index 0fe53b707..047504224 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ReferrerAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ReferrerAggregator.php @@ -57,6 +57,10 @@ final class ReferrerAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ResultAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ResultAggregator.php index 2e46673da..3cce7b283 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ResultAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ResultAggregator.php @@ -55,6 +55,10 @@ final class ResultAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ScopeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ScopeAggregator.php index 243263b83..0828b5d0d 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ScopeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ScopeAggregator.php @@ -57,6 +57,10 @@ final class ScopeAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function getLabels($key, array $values, $data) { diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php b/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php index 978f88a10..75583dfa0 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php @@ -39,6 +39,10 @@ class CountAccompanyingCourse implements ExportInterface, GroupedExportInterface { // Nothing to add here } + public function getFormDefaultData(): array + { + return []; + } public function getAllowedFormattersTypes(): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingPeriodWork.php b/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingPeriodWork.php index 122ee14d9..8a035bdcd 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingPeriodWork.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingPeriodWork.php @@ -38,6 +38,10 @@ class CountAccompanyingPeriodWork implements ExportInterface, GroupedExportInter { // No form necessary? } + public function getFormDefaultData(): array + { + return []; + } public function getAllowedFormattersTypes(): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php b/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php index 1613b63d3..3de433e2e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php @@ -37,6 +37,10 @@ class CountEvaluation implements ExportInterface, GroupedExportInterface { // TODO: Implement buildForm() method. } + public function getFormDefaultData(): array + { + return []; + } public function getAllowedFormattersTypes(): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php b/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php index 0b693b9d8..05e32fde6 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php @@ -46,11 +46,14 @@ class CountHousehold implements ExportInterface, GroupedExportInterface { $builder ->add('calc_date', PickRollingDateType::class, [ - 'data' => new RollingDate(RollingDate::T_TODAY), 'label' => self::TR_PREFIX . 'Date of calculation of household members', 'required' => false, ]); } + public function getFormDefaultData(): array + { + return ['calc_date' => new RollingDate(RollingDate::T_TODAY)]; + } public function getAllowedFormattersTypes(): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountPersonWithAccompanyingCourse.php b/src/Bundle/ChillPersonBundle/Export/Export/CountPersonWithAccompanyingCourse.php index e52cc83b1..ae7238d4e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountPersonWithAccompanyingCourse.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountPersonWithAccompanyingCourse.php @@ -39,6 +39,10 @@ class CountPersonWithAccompanyingCourse implements ExportInterface, GroupedExpor { // TODO: Implement buildForm() method. } + public function getFormDefaultData(): array + { + return []; + } public function getAllowedFormattersTypes(): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php index 0647460dd..e5e724b6c 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php @@ -144,6 +144,10 @@ class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface 'required' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function getAllowedFormattersTypes() { diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriodWork.php b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriodWork.php index 00fa8adb1..c437454c2 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriodWork.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriodWork.php @@ -135,9 +135,12 @@ class ListAccompanyingPeriodWork implements ListInterface, GroupedExportInterfac 'label' => 'export.list.acpw.Date of calculation for associated elements', 'help' => 'export.list.acpw.help_description', 'required' => true, - 'data' => new RollingDate(RollingDate::T_TODAY), ]); } + public function getFormDefaultData(): array + { + return ['calc_date' => new RollingDate(RollingDate::T_TODAY)]; + } public function getAllowedFormattersTypes() { diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListEvaluation.php b/src/Bundle/ChillPersonBundle/Export/Export/ListEvaluation.php index f0985436b..c3e273733 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListEvaluation.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListEvaluation.php @@ -123,9 +123,12 @@ class ListEvaluation implements ListInterface, GroupedExportInterface 'label' => 'export.list.eval.Date of calculation for associated elements', 'help' => 'export.list.eval.help_description', 'required' => true, - 'data' => new RollingDate(RollingDate::T_TODAY), ]); } + public function getFormDefaultData(): array + { + return ['calc_date' => new RollingDate(RollingDate::T_TODAY)]; + } public function getAllowedFormattersTypes() { diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListHouseholdInPeriod.php b/src/Bundle/ChillPersonBundle/Export/Export/ListHouseholdInPeriod.php index 8894d145d..4dcc89495 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListHouseholdInPeriod.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListHouseholdInPeriod.php @@ -75,10 +75,13 @@ class ListHouseholdInPeriod implements ListInterface, GroupedExportInterface ->add('calc_date', PickRollingDateType::class, [ 'label' => 'export.list.household.Date of calculation for associated elements', 'help' => 'export.list.household.help_description', - 'data' => new RollingDate(RollingDate::T_TODAY), 'required' => true, ]); } + public function getFormDefaultData(): array + { + return ['calc_date' => new RollingDate(RollingDate::T_TODAY)]; + } public function getAllowedFormattersTypes() { diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListPersonDuplicate.php b/src/Bundle/ChillPersonBundle/Export/Export/ListPersonDuplicate.php index e40ffccce..e7c105604 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListPersonDuplicate.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListPersonDuplicate.php @@ -74,9 +74,12 @@ class ListPersonDuplicate implements DirectExportInterface, ExportElementValidat { $builder->add('precision', NumberType::class, [ 'label' => 'Precision', - 'data' => self::PRECISION_DEFAULT_VALUE, ]); } + public function getFormDefaultData(): array + { + return ['precision' => self::PRECISION_DEFAULT_VALUE]; + } public function generate(array $acl, array $data = []): Response { diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriod.php index 7cb066e87..370046232 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriod.php @@ -57,7 +57,6 @@ class ListPersonWithAccompanyingPeriod implements ExportElementValidatedInterfac { $choices = array_combine(ListPersonHelper::FIELDS, ListPersonHelper::FIELDS); - // Add a checkbox to select fields $builder->add('fields', ChoiceType::class, [ 'multiple' => true, 'expanded' => true, @@ -80,17 +79,20 @@ class ListPersonWithAccompanyingPeriod implements ExportElementValidatedInterfac } }, ])], - 'data' => array_values($choices), ]); - // add a date field for addresses $builder->add('address_date', ChillDateType::class, [ 'label' => 'Data valid at this date', 'help' => 'Data regarding center, addresses, and so on will be computed at this date', - 'data' => new DateTimeImmutable(), 'input' => 'datetime_immutable', ]); } + public function getFormDefaultData(): array + { + $choices = array_combine(ListPersonHelper::FIELDS, ListPersonHelper::FIELDS); + + return ['fields' => array_values($choices), 'address_date' => new DateTimeImmutable()]; + } public function getAllowedFormattersTypes() { diff --git a/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php b/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php index 31ca41cbb..66b47131d 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php @@ -41,9 +41,12 @@ class StatAccompanyingCourseDuration implements ExportInterface, GroupedExportIn { $builder->add('closingdate', ChillDateType::class, [ 'label' => 'Closingdate to apply', - 'data' => new DateTime('now'), ]); } + public function getFormDefaultData(): array + { + return ['closingdate' => new DateTime('now')]; + } public function getAllowedFormattersTypes(): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOnDateFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOnDateFilter.php index 3fa8d711f..fcb4d67fb 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOnDateFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOnDateFilter.php @@ -67,9 +67,11 @@ class ActiveOnDateFilter implements FilterInterface public function buildForm(FormBuilderInterface $builder) { $builder - ->add('on_date', PickRollingDateType::class, [ - 'data' => new RollingDate(RollingDate::T_TODAY), - ]); + ->add('on_date', PickRollingDateType::class, []); + } + public function getFormDefaultData(): array + { + return ['on_date' => new RollingDate(RollingDate::T_TODAY)]; } public function describeAction($data, $format = 'string'): array diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOneDayBetweenDatesFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOneDayBetweenDatesFilter.php index f713e8a97..ae21dc724 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOneDayBetweenDatesFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOneDayBetweenDatesFilter.php @@ -56,12 +56,12 @@ class ActiveOneDayBetweenDatesFilter implements FilterInterface public function buildForm(FormBuilderInterface $builder) { $builder - ->add('date_from', PickRollingDateType::class, [ - 'data' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START), - ]) - ->add('date_to', PickRollingDateType::class, [ - 'data' => new RollingDate(RollingDate::T_TODAY), - ]); + ->add('date_from', PickRollingDateType::class, []) + ->add('date_to', PickRollingDateType::class, []); + } + public function getFormDefaultData(): array + { + return ['date_from' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START), 'date_to' => new RollingDate(RollingDate::T_TODAY)]; } public function describeAction($data, $format = 'string'): array diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/AdministrativeLocationFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/AdministrativeLocationFilter.php index c74e309b2..aa1abb36e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/AdministrativeLocationFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/AdministrativeLocationFilter.php @@ -53,6 +53,10 @@ class AdministrativeLocationFilter implements FilterInterface 'multiple' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ClosingMotiveFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ClosingMotiveFilter.php index e57370f30..153b2ecbd 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ClosingMotiveFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ClosingMotiveFilter.php @@ -64,6 +64,10 @@ class ClosingMotiveFilter implements FilterInterface 'expanded' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ConfidentialFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ConfidentialFilter.php index 4be284b2d..8811b9930 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ConfidentialFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ConfidentialFilter.php @@ -22,8 +22,8 @@ use Symfony\Contracts\Translation\TranslatorInterface; class ConfidentialFilter implements FilterInterface { private const CHOICES = [ - 'is not confidential' => false, - 'is confidential' => true, + 'is not confidential' => 'false', + 'is confidential' => 'true', ]; private const DEFAULT_CHOICE = 'false'; @@ -67,9 +67,12 @@ class ConfidentialFilter implements FilterInterface 'multiple' => false, 'expanded' => true, 'empty_data' => self::DEFAULT_CHOICE, - 'data' => self::DEFAULT_CHOICE, ]); } + public function getFormDefaultData(): array + { + return ['accepted_confidentials' => self::DEFAULT_CHOICE]; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorFilter.php index b13947e60..8a8a24013 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorFilter.php @@ -50,6 +50,10 @@ class CreatorFilter implements FilterInterface 'label' => false, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorJobFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorJobFilter.php index f585cfafb..5faeb850f 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorJobFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorJobFilter.php @@ -69,6 +69,10 @@ class CreatorJobFilter implements FilterInterface 'label' => 'Job', ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EmergencyFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EmergencyFilter.php index d31b93bd4..f9d45c9d7 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EmergencyFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EmergencyFilter.php @@ -22,8 +22,8 @@ use Symfony\Contracts\Translation\TranslatorInterface; class EmergencyFilter implements FilterInterface { private const CHOICES = [ - 'is emergency' => true, - 'is not emergency' => false, + 'is emergency' => 'true', + 'is not emergency' => 'false', ]; private const DEFAULT_CHOICE = 'false'; @@ -67,9 +67,12 @@ class EmergencyFilter implements FilterInterface 'multiple' => false, 'expanded' => true, 'empty_data' => self::DEFAULT_CHOICE, - 'data' => self::DEFAULT_CHOICE, ]); } + public function getFormDefaultData(): array + { + return ['accepted_emergency' => self::DEFAULT_CHOICE]; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EvaluationFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EvaluationFilter.php index ab7f4257e..a6fb3583d 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EvaluationFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EvaluationFilter.php @@ -75,6 +75,10 @@ class EvaluationFilter implements FilterInterface 'attr' => ['class' => 'select2'], ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php index d35565c80..a20cfc08f 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php @@ -100,7 +100,6 @@ class GeographicalUnitStatFilter implements FilterInterface ->add('date_calc', PickRollingDateType::class, [ 'label' => 'Compute geographical location at date', 'required' => true, - 'data' => new RollingDate(RollingDate::T_TODAY), ]) ->add('units', ChoiceType::class, [ 'label' => 'Geographical unit', @@ -114,6 +113,10 @@ class GeographicalUnitStatFilter implements FilterInterface 'multiple' => true, ]); } + public function getFormDefaultData(): array + { + return ['date_calc' => new RollingDate(RollingDate::T_TODAY)]; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasNoActionFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasNoActionFilter.php index 54c28d027..4820116c0 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasNoActionFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasNoActionFilter.php @@ -38,6 +38,10 @@ class HasNoActionFilter implements FilterInterface { // no form } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasNoReferrerFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasNoReferrerFilter.php index 4c682a56a..6d01ea7c2 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasNoReferrerFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasNoReferrerFilter.php @@ -65,9 +65,12 @@ class HasNoReferrerFilter implements FilterInterface $builder ->add('calc_date', PickRollingDateType::class, [ 'label' => 'Has no referrer on this date', - 'data' => new RollingDate(RollingDate::T_TODAY), ]); } + public function getFormDefaultData(): array + { + return ['calc_date' => new RollingDate(RollingDate::T_TODAY)]; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasTemporaryLocationFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasTemporaryLocationFilter.php index 615ace4c6..ec3b4e417 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasTemporaryLocationFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasTemporaryLocationFilter.php @@ -92,9 +92,12 @@ class HasTemporaryLocationFilter implements FilterInterface ]) ->add('calc_date', PickRollingDateType::class, [ 'label' => 'export.filter.course.having_temporarily.Calculation date', - 'data' => new RollingDate(RollingDate::T_TODAY), ]); } + public function getFormDefaultData(): array + { + return ['calc_date' => new RollingDate(RollingDate::T_TODAY)]; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HavingAnAccompanyingPeriodInfoWithinDatesFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HavingAnAccompanyingPeriodInfoWithinDatesFilter.php index 7069a1d80..d50622502 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HavingAnAccompanyingPeriodInfoWithinDatesFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HavingAnAccompanyingPeriodInfoWithinDatesFilter.php @@ -38,13 +38,14 @@ final readonly class HavingAnAccompanyingPeriodInfoWithinDatesFilter implements $builder ->add('start_date', PickRollingDateType::class, [ 'label' => 'export.filter.course.having_info_within_interval.start_date', - 'data' => new RollingDate(RollingDate::T_TODAY), ]) ->add('end_date', PickRollingDateType::class, [ 'label' => 'export.filter.course.having_info_within_interval.end_date', - 'data' => new RollingDate(RollingDate::T_TODAY), - ]) - ; + ]); + } + public function getFormDefaultData(): array + { + return ['start_date' => new RollingDate(RollingDate::T_TODAY), 'end_date' => new RollingDate(RollingDate::T_TODAY)]; } public function getTitle(): string diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/IntensityFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/IntensityFilter.php index b0c2205a0..1fd05d2b4 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/IntensityFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/IntensityFilter.php @@ -67,9 +67,12 @@ class IntensityFilter implements FilterInterface 'multiple' => false, 'expanded' => true, 'empty_data' => self::DEFAULT_CHOICE, - 'data' => self::DEFAULT_CHOICE, ]); } + public function getFormDefaultData(): array + { + return ['accepted_intensities' => self::DEFAULT_CHOICE]; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OpenBetweenDatesFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OpenBetweenDatesFilter.php index 07ca1de75..e9413083f 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OpenBetweenDatesFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OpenBetweenDatesFilter.php @@ -54,12 +54,12 @@ class OpenBetweenDatesFilter implements FilterInterface public function buildForm(FormBuilderInterface $builder) { $builder - ->add('date_from', PickRollingDateType::class, [ - 'data' => new RollingDate(RollingDate::T_MONTH_PREVIOUS_START), - ]) - ->add('date_to', PickRollingDateType::class, [ - 'data' => new RollingDate(RollingDate::T_TODAY), - ]); + ->add('date_from', PickRollingDateType::class, []) + ->add('date_to', PickRollingDateType::class, []); + } + public function getFormDefaultData(): array + { + return ['date_from' => new RollingDate(RollingDate::T_MONTH_PREVIOUS_START), 'date_to' => new RollingDate(RollingDate::T_TODAY)]; } public function describeAction($data, $format = 'string'): array diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OriginFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OriginFilter.php index 00febc640..8395c79f8 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OriginFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OriginFilter.php @@ -64,6 +64,10 @@ class OriginFilter implements FilterInterface 'expanded' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ReferrerFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ReferrerFilter.php index 2a3e5d17e..f0bf65d49 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ReferrerFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ReferrerFilter.php @@ -77,11 +77,14 @@ class ReferrerFilter implements FilterInterface 'multiple' => true, ]) ->add('date_calc', PickRollingDateType::class, [ - 'data' => new RollingDate(RollingDate::T_TODAY), 'label' => 'export.filter.course.by_referrer.Computation date for referrer', 'required' => true, ]); } + public function getFormDefaultData(): array + { + return ['date_calc' => new RollingDate(RollingDate::T_TODAY)]; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/RequestorFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/RequestorFilter.php index 3295a5b57..614889c27 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/RequestorFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/RequestorFilter.php @@ -126,9 +126,12 @@ final class RequestorFilter implements FilterInterface 'multiple' => false, 'expanded' => true, 'empty_data' => self::DEFAULT_CHOICE, - 'data' => self::DEFAULT_CHOICE, ]); } + public function getFormDefaultData(): array + { + return ['accepted_choices' => self::DEFAULT_CHOICE]; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php index bc1f368da..0c14ba73a 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php @@ -70,6 +70,10 @@ class SocialActionFilter implements FilterInterface 'multiple' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php index 917e129bf..a793bc548 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php @@ -69,6 +69,10 @@ class SocialIssueFilter implements FilterInterface 'multiple' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/StepFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/StepFilter.php index 8ee798c07..0a816c0b6 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/StepFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/StepFilter.php @@ -95,13 +95,15 @@ class StepFilter implements FilterInterface 'multiple' => false, 'expanded' => true, 'empty_data' => self::DEFAULT_CHOICE, - 'data' => self::DEFAULT_CHOICE, ]) ->add('calc_date', PickRollingDateType::class, [ 'label' => 'export.filter.course.by_step.date_calc', - 'data' => new RollingDate(RollingDate::T_TODAY), ]); } + public function getFormDefaultData(): array + { + return ['accepted_steps' => self::DEFAULT_CHOICE, 'calc_date' => new RollingDate(RollingDate::T_TODAY)]; + } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserJobFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserJobFilter.php index 05d84d7b2..e7685fe4d 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserJobFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserJobFilter.php @@ -96,11 +96,14 @@ class UserJobFilter implements FilterInterface 'label' => 'Job', ]) ->add('date_calc', PickRollingDateType::class, [ - 'data' => new RollingDate(RollingDate::T_TODAY), 'label' => 'export.filter.course.by_user_scope.Computation date for referrer', 'required' => true, ]); } + public function getFormDefaultData(): array + { + return ['date_calc' => new RollingDate(RollingDate::T_TODAY)]; + } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserScopeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserScopeFilter.php index bbffa4bca..7c8d84499 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserScopeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserScopeFilter.php @@ -100,11 +100,14 @@ class UserScopeFilter implements FilterInterface 'expanded' => true, ]) ->add('date_calc', PickRollingDateType::class, [ - 'data' => new RollingDate(RollingDate::T_TODAY), 'label' => 'export.filter.course.by_user_scope.Computation date for referrer', 'required' => true, ]); } + public function getFormDefaultData(): array + { + return ['date_calc' => new RollingDate(RollingDate::T_TODAY)]; + } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserWorkingOnCourseFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserWorkingOnCourseFilter.php index 586bb645d..d078443af 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserWorkingOnCourseFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserWorkingOnCourseFilter.php @@ -42,6 +42,10 @@ readonly class UserWorkingOnCourseFilter implements FilterInterface 'multiple' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function getTitle(): string { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/ByEndDateFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/ByEndDateFilter.php index de86604e6..4c019cc73 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/ByEndDateFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/ByEndDateFilter.php @@ -57,13 +57,15 @@ class ByEndDateFilter implements FilterInterface $builder ->add('start_date', PickRollingDateType::class, [ 'label' => 'start period date', - 'data' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START), ]) ->add('end_date', PickRollingDateType::class, [ 'label' => 'end period date', - 'data' => new RollingDate(RollingDate::T_TODAY), ]); } + public function getFormDefaultData(): array + { + return ['start_date' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START), 'end_date' => new RollingDate(RollingDate::T_TODAY)]; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/ByStartDateFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/ByStartDateFilter.php index 27518599c..ea221e87b 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/ByStartDateFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/ByStartDateFilter.php @@ -57,13 +57,15 @@ class ByStartDateFilter implements FilterInterface $builder ->add('start_date', PickRollingDateType::class, [ 'label' => 'start period date', - 'data' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START), ]) ->add('end_date', PickRollingDateType::class, [ 'label' => 'end period date', - 'data' => new RollingDate(RollingDate::T_TODAY), ]); } + public function getFormDefaultData(): array + { + return ['start_date' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START), 'end_date' => new RollingDate(RollingDate::T_TODAY)]; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/CurrentEvaluationsFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/CurrentEvaluationsFilter.php index 140f6c3cb..8841c7b9e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/CurrentEvaluationsFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/CurrentEvaluationsFilter.php @@ -37,6 +37,10 @@ class CurrentEvaluationsFilter implements FilterInterface { //no form needed } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/EvaluationTypeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/EvaluationTypeFilter.php index 6a0c71d55..77bae1b56 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/EvaluationTypeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/EvaluationTypeFilter.php @@ -64,6 +64,10 @@ final class EvaluationTypeFilter implements FilterInterface 'expanded' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/MaxDateFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/MaxDateFilter.php index 4a65452a1..daa7d1954 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/MaxDateFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/MaxDateFilter.php @@ -61,6 +61,10 @@ class MaxDateFilter implements FilterInterface 'expanded' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/HouseholdFilters/CompositionFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/HouseholdFilters/CompositionFilter.php index 22761c158..3a2cb5337 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/HouseholdFilters/CompositionFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/HouseholdFilters/CompositionFilter.php @@ -84,9 +84,11 @@ class CompositionFilter implements FilterInterface 'multiple' => true, 'expanded' => true, ]) - ->add('on_date', PickRollingDateType::class, [ - 'data' => new RollingDate(RollingDate::T_TODAY), - ]); + ->add('on_date', PickRollingDateType::class, []); + } + public function getFormDefaultData(): array + { + return ['on_date' => new RollingDate(RollingDate::T_TODAY)]; } public function describeAction($data, $format = 'string'): array diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AddressRefStatusFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AddressRefStatusFilter.php index 7580a37a3..5588d8c15 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AddressRefStatusFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AddressRefStatusFilter.php @@ -76,17 +76,19 @@ class AddressRefStatusFilter implements \Chill\MainBundle\Export\FilterInterface ->add('date_calc', PickRollingDateType::class, [ 'label' => 'Compute address at date', 'required' => true, - 'data' => new RollingDate(RollingDate::T_TODAY), ]) ->add('ref_statuses', ChoiceType::class, [ 'label' => 'export.filter.person.by_address_ref_status.Status', 'choices' => [Address::ADDR_REFERENCE_STATUS_TO_REVIEW, Address::ADDR_REFERENCE_STATUS_REVIEWED, Address::ADDR_REFERENCE_STATUS_MATCH], 'choice_label' => fn (string $item) => 'export.filter.person.by_address_ref_status.'.$item, 'multiple' => true, - 'expanded' => true, - 'data' => [Address::ADDR_REFERENCE_STATUS_TO_REVIEW] + 'expanded' => true ]); } + public function getFormDefaultData(): array + { + return ['date_calc' => new RollingDate(RollingDate::T_TODAY), 'ref_statuses' => [Address::ADDR_REFERENCE_STATUS_TO_REVIEW]]; + } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/BirthdateFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/BirthdateFilter.php index 7ae22ddd8..9a0478b6c 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/BirthdateFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/BirthdateFilter.php @@ -71,14 +71,16 @@ class BirthdateFilter implements ExportElementValidatedInterface, FilterInterfac { $builder->add('date_from', PickRollingDateType::class, [ 'label' => 'Born after this date', - 'data' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START), ]); $builder->add('date_to', PickRollingDateType::class, [ 'label' => 'Born before this date', - 'data' => new RollingDate(RollingDate::T_TODAY), ]); } + public function getFormDefaultData(): array + { + return ['date_from' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START), 'date_to' => new RollingDate(RollingDate::T_TODAY)]; + } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ByHouseholdCompositionFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ByHouseholdCompositionFilter.php index 9b59549f1..749897a53 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ByHouseholdCompositionFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ByHouseholdCompositionFilter.php @@ -86,9 +86,12 @@ class ByHouseholdCompositionFilter implements FilterInterface ]) ->add('calc_date', PickRollingDateType::class, [ 'label' => 'export.filter.person.by_composition.Date calc', - 'data' => new RollingDate(RollingDate::T_TODAY), ]); } + public function getFormDefaultData(): array + { + return ['calc_date' => new RollingDate(RollingDate::T_TODAY)]; + } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/DeadOrAliveFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/DeadOrAliveFilter.php index 384d6698a..8b2444ca2 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/DeadOrAliveFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/DeadOrAliveFilter.php @@ -102,9 +102,12 @@ class DeadOrAliveFilter implements FilterInterface $builder->add('date_calc', PickRollingDateType::class, [ 'label' => 'Filter in relation to this date', - 'data' => new RollingDate(RollingDate::T_TODAY), ]); } + public function getFormDefaultData(): array + { + return ['date_calc' => new RollingDate(RollingDate::T_TODAY)]; + } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/DeathdateFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/DeathdateFilter.php index 0ac4b3173..7805331a5 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/DeathdateFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/DeathdateFilter.php @@ -72,14 +72,16 @@ class DeathdateFilter implements ExportElementValidatedInterface, FilterInterfac { $builder->add('date_from', PickRollingDateType::class, [ 'label' => 'Death after this date', - 'data' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START), ]); $builder->add('date_to', PickRollingDateType::class, [ 'label' => 'Deathdate before', - 'data' => new RollingDate(RollingDate::T_TODAY), ]); } + public function getFormDefaultData(): array + { + return ['date_from' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START), 'date_to' => new RollingDate(RollingDate::T_TODAY)]; + } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GenderFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GenderFilter.php index 739945b98..182006bbc 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GenderFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GenderFilter.php @@ -89,6 +89,10 @@ class GenderFilter implements 'expanded' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GeographicalUnitFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GeographicalUnitFilter.php index 79f5cb2d4..ab9bb08ab 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GeographicalUnitFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GeographicalUnitFilter.php @@ -91,7 +91,6 @@ class GeographicalUnitFilter implements \Chill\MainBundle\Export\FilterInterface ->add('date_calc', PickRollingDateType::class, [ 'label' => 'Compute geographical location at date', 'required' => true, - 'data' => new RollingDate(RollingDate::T_TODAY), ]) ->add('units', ChoiceType::class, [ 'label' => 'Geographical unit', @@ -105,6 +104,10 @@ class GeographicalUnitFilter implements \Chill\MainBundle\Export\FilterInterface 'multiple' => true, ]); } + public function getFormDefaultData(): array + { + return ['date_calc' => new RollingDate(RollingDate::T_TODAY)]; + } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/MaritalStatusFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/MaritalStatusFilter.php index 47a75871c..021c22fc6 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/MaritalStatusFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/MaritalStatusFilter.php @@ -56,6 +56,10 @@ class MaritalStatusFilter implements FilterInterface 'expanded' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/NationalityFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/NationalityFilter.php index b1d77d60e..e5102128b 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/NationalityFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/NationalityFilter.php @@ -67,6 +67,10 @@ class NationalityFilter implements 'placeholder' => 'Choose countries', ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php index 21bb40947..8f22750a5 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php @@ -107,9 +107,12 @@ class ResidentialAddressAtThirdpartyFilter implements FilterInterface $builder->add('date_calc', PickRollingDateType::class, [ 'label' => 'Date during which residential address was valid', - 'data' => new RollingDate(RollingDate::T_TODAY), ]); } + public function getFormDefaultData(): array + { + return ['date_calc' => new RollingDate(RollingDate::T_TODAY)]; + } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtUserFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtUserFilter.php index bd55c5b80..62b142420 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtUserFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtUserFilter.php @@ -82,9 +82,12 @@ class ResidentialAddressAtUserFilter implements FilterInterface { $builder->add('date_calc', PickRollingDateType::class, [ 'label' => 'Date during which residential address was valid', - 'data' => new RollingDate(RollingDate::T_TODAY), ]); } + public function getFormDefaultData(): array + { + return ['date_calc' => new RollingDate(RollingDate::T_TODAY)]; + } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/WithoutHouseholdComposition.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/WithoutHouseholdComposition.php index c4644fc11..9f5ed90b5 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/WithoutHouseholdComposition.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/WithoutHouseholdComposition.php @@ -66,9 +66,12 @@ class WithoutHouseholdComposition implements FilterInterface $builder ->add('calc_date', PickRollingDateType::class, [ 'label' => 'export.filter.person.by_no_composition.Date calc', - 'data' => new RollingDate(RollingDate::T_TODAY), ]); } + public function getFormDefaultData(): array + { + return ['calc_date' => new RollingDate(RollingDate::T_TODAY)]; + } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/AccompanyingPeriodWorkEndDateBetweenDateFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/AccompanyingPeriodWorkEndDateBetweenDateFilter.php index b13c49e9a..e78b1d021 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/AccompanyingPeriodWorkEndDateBetweenDateFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/AccompanyingPeriodWorkEndDateBetweenDateFilter.php @@ -32,17 +32,18 @@ final readonly class AccompanyingPeriodWorkEndDateBetweenDateFilter implements F $builder ->add('start_date', PickRollingDateType::class, [ 'label' => 'export.filter.work.end_between_dates.start_date', - 'data' => new RollingDate(RollingDate::T_TODAY), ]) ->add('end_date', PickRollingDateType::class, [ 'label' => 'export.filter.work.end_between_dates.end_date', - 'data' => new RollingDate(RollingDate::T_TODAY), ]) ->add('keep_null', CheckboxType::class, [ 'label' => 'export.filter.work.end_between_dates.keep_null', 'help' => 'export.filter.work.end_between_dates.keep_null_help', - ]) - ; + ]); + } + public function getFormDefaultData(): array + { + return ['start_date' => new RollingDate(RollingDate::T_TODAY), 'end_date' => new RollingDate(RollingDate::T_TODAY)]; } public function getTitle(): string diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/AccompanyingPeriodWorkStartDateBetweenDateFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/AccompanyingPeriodWorkStartDateBetweenDateFilter.php index e9526a9a5..947e6c57c 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/AccompanyingPeriodWorkStartDateBetweenDateFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/AccompanyingPeriodWorkStartDateBetweenDateFilter.php @@ -32,17 +32,18 @@ final readonly class AccompanyingPeriodWorkStartDateBetweenDateFilter implements $builder ->add('start_date', PickRollingDateType::class, [ 'label' => 'export.filter.work.start_between_dates.start_date', - 'data' => new RollingDate(RollingDate::T_TODAY), ]) ->add('end_date', PickRollingDateType::class, [ 'label' => 'export.filter.work.start_between_dates.end_date', - 'data' => new RollingDate(RollingDate::T_TODAY), ]) ->add('keep_null', CheckboxType::class, [ 'label' => 'export.filter.work.start_between_dates.keep_null', 'help' => 'export.filter.work.start_between_dates.keep_null_help', - ]) - ; + ]); + } + public function getFormDefaultData(): array + { + return ['start_date' => new RollingDate(RollingDate::T_TODAY), 'end_date' => new RollingDate(RollingDate::T_TODAY)]; } public function getTitle(): string diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CurrentActionFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CurrentActionFilter.php index cbdb64d8d..e99590025 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CurrentActionFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CurrentActionFilter.php @@ -37,6 +37,10 @@ class CurrentActionFilter implements FilterInterface { //no form } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/JobFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/JobFilter.php index 144bf3260..265c8e24d 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/JobFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/JobFilter.php @@ -76,6 +76,10 @@ class JobFilter implements FilterInterface 'expanded' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ReferrerFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ReferrerFilter.php index 8d0da32fb..bddcfbf9b 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ReferrerFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ReferrerFilter.php @@ -57,6 +57,10 @@ class ReferrerFilter implements FilterInterface 'multiple' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string'): array { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ScopeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ScopeFilter.php index 315025722..737759c3e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ScopeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ScopeFilter.php @@ -76,6 +76,10 @@ class ScopeFilter implements FilterInterface 'expanded' => true, ]); } + public function getFormDefaultData(): array + { + return []; + } public function describeAction($data, $format = 'string') { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/SocialWorkTypeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/SocialWorkTypeFilter.php index 11fd0ed9d..9a687b1e6 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/SocialWorkTypeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/SocialWorkTypeFilter.php @@ -111,6 +111,11 @@ class SocialWorkTypeFilter implements FilterInterface ); } + public function getFormDefaultData(): array + { + return ['action_type' => '', 'goal' => '', 'result' => '']; + } + public function describeAction($data, $format = 'string'): array { $actionTypes = []; diff --git a/src/Bundle/ChillReportBundle/Export/Export/ReportList.php b/src/Bundle/ChillReportBundle/Export/Export/ReportList.php index 9adae0097..9d99b7e62 100644 --- a/src/Bundle/ChillReportBundle/Export/Export/ReportList.php +++ b/src/Bundle/ChillReportBundle/Export/Export/ReportList.php @@ -94,7 +94,6 @@ class ReportList implements ExportElementValidatedInterface, ListInterface $cf->getSlug(); } - // Add a checkbox to select fields $builder->add('fields', ChoiceType::class, [ 'multiple' => true, 'expanded' => true, @@ -134,14 +133,16 @@ class ReportList implements ExportElementValidatedInterface, ListInterface ])], ]); - // add a date field for addresses $builder->add('address_date', ChillDateType::class, [ 'label' => 'Address valid at this date', - 'data' => new DateTime(), 'required' => false, 'block_name' => 'list_export_form_address_date', ]); } + public function getFormDefaultData(): array + { + return ['address_date' => new DateTime()]; + } public function getAllowedFormattersTypes() { diff --git a/src/Bundle/ChillReportBundle/Export/Filter/ReportDateFilter.php b/src/Bundle/ChillReportBundle/Export/Filter/ReportDateFilter.php index 79bad4f52..cb8e7d1d0 100644 --- a/src/Bundle/ChillReportBundle/Export/Filter/ReportDateFilter.php +++ b/src/Bundle/ChillReportBundle/Export/Filter/ReportDateFilter.php @@ -67,14 +67,16 @@ class ReportDateFilter implements FilterInterface { $builder->add('date_from', PickRollingDateType::class, [ 'label' => 'Report is after this date', - 'data' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START), ]); $builder->add('date_to', PickRollingDateType::class, [ 'label' => 'Report is before this date', - 'data' => new RollingDate(RollingDate::T_TODAY), ]); } + public function getFormDefaultData(): array + { + return ['date_from' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START), 'date_to' => new RollingDate(RollingDate::T_TODAY)]; + } public function describeAction($data, $format = 'string') { From 9073f118dbf9e8f0455f2d149514efaa944302d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sun, 18 Jun 2023 21:37:52 +0200 Subject: [PATCH 215/724] [rector] add form default data rule: handle case when there are method call on builder without add --- ...FormDefaultDataOnExportFilterAggregatorRector.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/utils/rector/src/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector.php b/utils/rector/src/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector.php index cc54a24f1..4718aedac 100644 --- a/utils/rector/src/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector.php +++ b/utils/rector/src/Rector/ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector.php @@ -138,7 +138,7 @@ PHP */ } ['build_form_method' => $buildFormMethod, 'empty_to_replace' => $emptyToReplace] - = $this->filterBuildFormMethod($node->stmts[$buildFormStmtIndex]); + = $this->filterBuildFormMethod($node->stmts[$buildFormStmtIndex], $node); $node->stmts = [ ...$stmtBefore, @@ -172,7 +172,7 @@ PHP */ * @param Node\Stmt\ClassMethod $buildFormMethod * @return array{"build_form_method": Node\Stmt\ClassMethod, "empty_to_replace": array} */ - private function filterBuildFormMethod(Node\Stmt\ClassMethod $buildFormMethod): array + private function filterBuildFormMethod(Node\Stmt\ClassMethod $buildFormMethod, Node\Stmt\Class_ $node): array { $builderName = $buildFormMethod->params[0]->var->name; @@ -183,7 +183,7 @@ PHP */ if ($stmt instanceof Node\Stmt\Expression // it must be a method call && $stmt->expr instanceof Node\Expr\MethodCall - && false !== ($results = $this->handleMethodCallBuilderAdd($stmt->expr, $builderName)) + && false !== ($results = $this->handleMethodCallBuilderAdd($stmt->expr, $builderName, $node)) ) { ['stmt' => $newMethodCAll, 'emptyDataToReplace' => $newEmptyDataToReplace] = $results; $newStmts[] = new Node\Stmt\Expression($newMethodCAll); @@ -198,7 +198,7 @@ PHP */ return ['build_form_method' => $buildFormMethod, "empty_to_replace" => $emptyDataToReplace]; } - private function handleMethodCallBuilderAdd(Node\Expr\MethodCall $methodCall, string $builderName): array|false + private function handleMethodCallBuilderAdd(Node\Expr\MethodCall $methodCall, string $builderName, Node\Stmt\Class_ $node): array|false { $emptyDataToReplace = []; // check for chained method call @@ -208,7 +208,7 @@ PHP */ ) { // as this is chained, we make a recursion on this method - $resultFormDeepMethodCall = $this->handleMethodCallBuilderAdd($methodCall->var, $builderName); + $resultFormDeepMethodCall = $this->handleMethodCallBuilderAdd($methodCall->var, $builderName, $node); if (false === $resultFormDeepMethodCall) { return false; @@ -268,6 +268,6 @@ PHP */ return ['stmt' => $methodCall, 'emptyDataToReplace' => $emptyDataToReplace]; } - throw new \RuntimeException("Not supported situation"); + return ['stmt' => $methodCall, 'emptyDataToReplace' => $emptyDataToReplace]; } } From 5a102d4989233c2023c9de703f0a5e240c32be4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sun, 18 Jun 2023 21:44:10 +0200 Subject: [PATCH 216/724] publish new 2.2.0 version --- .changes/unreleased/DX-20230614-233000.yaml | 5 ----- .changes/unreleased/Feature-20230613-154903.yaml | 7 ------- .changes/unreleased/Feature-20230613-230640.yaml | 5 ----- .changes/unreleased/Feature-20230614-224720.yaml | 6 ------ .changes/unreleased/Feature-20230614-233107.yaml | 5 ----- .changes/unreleased/Fixed-20230606-170742.yaml | 6 ------ .changes/unreleased/Fixed-20230613-155453.yaml | 5 ----- .changes/unreleased/Fixed-20230613-230838.yaml | 5 ----- .changes/v2.2.0.md | 12 ++++++++++++ CHANGELOG.md | 13 +++++++++++++ 10 files changed, 25 insertions(+), 44 deletions(-) delete mode 100644 .changes/unreleased/DX-20230614-233000.yaml delete mode 100644 .changes/unreleased/Feature-20230613-154903.yaml delete mode 100644 .changes/unreleased/Feature-20230613-230640.yaml delete mode 100644 .changes/unreleased/Feature-20230614-224720.yaml delete mode 100644 .changes/unreleased/Feature-20230614-233107.yaml delete mode 100644 .changes/unreleased/Fixed-20230606-170742.yaml delete mode 100644 .changes/unreleased/Fixed-20230613-155453.yaml delete mode 100644 .changes/unreleased/Fixed-20230613-230838.yaml create mode 100644 .changes/v2.2.0.md diff --git a/.changes/unreleased/DX-20230614-233000.yaml b/.changes/unreleased/DX-20230614-233000.yaml deleted file mode 100644 index ca4a3171b..000000000 --- a/.changes/unreleased/DX-20230614-233000.yaml +++ /dev/null @@ -1,5 +0,0 @@ -kind: DX -body: 'DQL function OVERLAPSI: simplify expression in postgresql' -time: 2023-06-14T23:30:00.217427234+02:00 -custom: - Issue: "" diff --git a/.changes/unreleased/Feature-20230613-154903.yaml b/.changes/unreleased/Feature-20230613-154903.yaml deleted file mode 100644 index 7506bf473..000000000 --- a/.changes/unreleased/Feature-20230613-154903.yaml +++ /dev/null @@ -1,7 +0,0 @@ -kind: Feature -body: When navigating from a workflow regarding to an evaluation's document to an - accompanying course, scroll directly to the document, and blink to highlight this - document -time: 2023-06-13T15:49:03.663438985+02:00 -custom: - Issue: "" diff --git a/.changes/unreleased/Feature-20230613-230640.yaml b/.changes/unreleased/Feature-20230613-230640.yaml deleted file mode 100644 index 18694c724..000000000 --- a/.changes/unreleased/Feature-20230613-230640.yaml +++ /dev/null @@ -1,5 +0,0 @@ -kind: Feature -body: Add notification to accompanying period work and work's evaluation's documents -time: 2023-06-13T23:06:40.090777525+02:00 -custom: - Issue: "" diff --git a/.changes/unreleased/Feature-20230614-224720.yaml b/.changes/unreleased/Feature-20230614-224720.yaml deleted file mode 100644 index 3f86b022f..000000000 --- a/.changes/unreleased/Feature-20230614-224720.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: Feature -body: '[Export] Filter accompanying period by step at date: allow to pick multiple - steps' -time: 2023-06-14T22:47:20.577100599+02:00 -custom: - Issue: "113" diff --git a/.changes/unreleased/Feature-20230614-233107.yaml b/.changes/unreleased/Feature-20230614-233107.yaml deleted file mode 100644 index 2d0e502f2..000000000 --- a/.changes/unreleased/Feature-20230614-233107.yaml +++ /dev/null @@ -1,5 +0,0 @@ -kind: Feature -body: '[export] add a filter on accompanying period: filter by step between two dates' -time: 2023-06-14T23:31:07.979389911+02:00 -custom: - Issue: "113" diff --git a/.changes/unreleased/Fixed-20230606-170742.yaml b/.changes/unreleased/Fixed-20230606-170742.yaml deleted file mode 100644 index 0bd65b6cf..000000000 --- a/.changes/unreleased/Fixed-20230606-170742.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: Fixed -body: use the correct annotation for the association between PersonCurrentCenter and - Person -time: 2023-06-06T17:07:42.060486553+02:00 -custom: - Issue: "" diff --git a/.changes/unreleased/Fixed-20230613-155453.yaml b/.changes/unreleased/Fixed-20230613-155453.yaml deleted file mode 100644 index f183c3a17..000000000 --- a/.changes/unreleased/Fixed-20230613-155453.yaml +++ /dev/null @@ -1,5 +0,0 @@ -kind: Fixed -body: Fix birthdate timezone in PersonRenderBox -time: 2023-06-13T15:54:53.125120559+02:00 -custom: - Issue: "58" diff --git a/.changes/unreleased/Fixed-20230613-230838.yaml b/.changes/unreleased/Fixed-20230613-230838.yaml deleted file mode 100644 index 816f4f8d4..000000000 --- a/.changes/unreleased/Fixed-20230613-230838.yaml +++ /dev/null @@ -1,5 +0,0 @@ -kind: Fixed -body: Fix the notification counter -time: 2023-06-13T23:08:38.67342897+02:00 -custom: - Issue: "55" diff --git a/.changes/v2.2.0.md b/.changes/v2.2.0.md new file mode 100644 index 000000000..5371cad35 --- /dev/null +++ b/.changes/v2.2.0.md @@ -0,0 +1,12 @@ +## v2.2.0 - 2023-06-18 +### Feature +* When navigating from a workflow regarding to an evaluation's document to an accompanying course, scroll directly to the document, and blink to highlight this document +* Add notification to accompanying period work and work's evaluation's documents +* ([#113](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/113))[Export] Filter accompanying period by step at date: allow to pick multiple steps +* ([#113](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/113))[export] add a filter on accompanying period: filter by step between two dates +### Fixed +* use the correct annotation for the association between PersonCurrentCenter and Person +* ([#58](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/58))Fix birthdate timezone in PersonRenderBox +* ([#55](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/55))Fix the notification counter +### DX +* DQL function OVERLAPSI: simplify expression in postgresql diff --git a/CHANGELOG.md b/CHANGELOG.md index f10f12f9b..2c5ed9b3a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,19 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html), and is generated by [Changie](https://github.com/miniscruff/changie). +## v2.2.0 - 2023-06-18 +### Feature +* When navigating from a workflow regarding to an evaluation's document to an accompanying course, scroll directly to the document, and blink to highlight this document +* Add notification to accompanying period work and work's evaluation's documents +* ([#113](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/113))[Export] Filter accompanying period by step at date: allow to pick multiple steps +* ([#113](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/113))[export] add a filter on accompanying period: filter by step between two dates +### Fixed +* use the correct annotation for the association between PersonCurrentCenter and Person +* ([#58](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/58))Fix birthdate timezone in PersonRenderBox +* ([#55](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/55))Fix the notification counter +### DX +* DQL function OVERLAPSI: simplify expression in postgresql + ## v2.1.0 - 2023-06-12 ### Feature From 4359c2dddc8d8db8ae46e4429286a081f8a6a341 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 19 Jun 2023 20:21:50 +0200 Subject: [PATCH 217/724] DX: add a space between issue number and description in changie --- .changie.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changie.yaml b/.changie.yaml index 83fd9770a..ba5454ce7 100644 --- a/.changie.yaml +++ b/.changie.yaml @@ -6,7 +6,7 @@ versionExt: md versionFormat: '## {{.Version}} - {{.Time.Format "2006-01-02"}}' kindFormat: '### {{.Kind}}' changeFormat: >- - * {{ if not (eq .Custom.Issue "") }}([#{{ .Custom.Issue }}](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/{{ .Custom.Issue }})) {{- end }}{{.Body}} + * {{ if not (eq .Custom.Issue "") }}([#{{ .Custom.Issue }}](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/{{ .Custom.Issue }})) {{ end }}{{.Body}} custom: - key: Issue label: Issue number (on chill-bundles repository) (optional) From 6c16967cdc982f17fea3d2056b08e45190484b35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 19 Jun 2023 21:00:19 +0200 Subject: [PATCH 218/724] Fix: Fix entityId and return path when add a notification on a document's evaluation --- .../unreleased/Fixed-20230619-205836.yaml | 6 ++++++ .../public/lib/entity-notification/api.ts | 20 +++++++++++++++++++ .../components/FormEvaluation.vue | 15 ++++++++------ 3 files changed, 35 insertions(+), 6 deletions(-) create mode 100644 .changes/unreleased/Fixed-20230619-205836.yaml create mode 100644 src/Bundle/ChillMainBundle/Resources/public/lib/entity-notification/api.ts diff --git a/.changes/unreleased/Fixed-20230619-205836.yaml b/.changes/unreleased/Fixed-20230619-205836.yaml new file mode 100644 index 000000000..54b292394 --- /dev/null +++ b/.changes/unreleased/Fixed-20230619-205836.yaml @@ -0,0 +1,6 @@ +kind: Fixed +body: '[notification on document evaluation] fix entityId and return path when + adding a notification on a document in an evaluation' +time: 2023-06-19T20:58:36.941795323+02:00 +custom: + Issue: "114" diff --git a/src/Bundle/ChillMainBundle/Resources/public/lib/entity-notification/api.ts b/src/Bundle/ChillMainBundle/Resources/public/lib/entity-notification/api.ts new file mode 100644 index 000000000..ce0671d82 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/public/lib/entity-notification/api.ts @@ -0,0 +1,20 @@ +const buildLinkCreate = function (relatedEntityClass: string, relatedEntityId: number, to: number | null, returnPath: string | null): string +{ + const params = new URLSearchParams(); + params.append('entityClass', relatedEntityClass); + params.append('entityId', relatedEntityId.toString()); + + if (null !== to) { + params.append('tos[0]', to.toString()); + } + + if (null !== returnPath) { + params.append('returnPath', returnPath); + } + + return `/fr/notification/create?${params.toString()}`; +} + +export { + buildLinkCreate, +} diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue index a4e03bd31..4ea00f73a 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue @@ -201,6 +201,7 @@ import AddAsyncUpload from 'ChillDocStoreAssets/vuejs/_components/AddAsyncUpload import AddAsyncUploadDownloader from 'ChillDocStoreAssets/vuejs/_components/AddAsyncUploadDownloader.vue'; import ListWorkflowModal from 'ChillMainAssets/vuejs/_components/EntityWorkflow/ListWorkflowModal.vue'; import {buildLinkCreate} from 'ChillMainAssets/lib/entity-workflow/api.js'; +import {buildLinkCreate as buildLinkCreateNotification} from 'ChillMainAssets/lib/entity-notification/api'; import DocumentActionButtonsGroup from "ChillDocStoreAssets/vuejs/DocumentActionButtonsGroup.vue"; const i18n = { @@ -413,14 +414,16 @@ export default { return this.$store.dispatch('submit', callback) .catch(e => { console.log(e); throw e; }); }, - goToGenerateDocumentNotification(document, tos){ + goToGenerateDocumentNotification(document, tos) { const callback = (data) => { let evaluation = data.accompanyingPeriodWorkEvaluations.find(e => e.key === this.evaluation.key); - if (tos === true) { - window.location.assign(`/fr/notification/create?entityClass=Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluationDocument&entityId=${document.id}&tos[0]=${this.$store.state.work.accompanyingPeriod.user.id}&returnPath=/fr/person/accompanying-period/work/${evaluation.id}/edit`) - } else { - window.location.assign(`/fr/notification/create?entityClass=Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluationDocument&entityId=${document.id}&returnPath=/fr/person/accompanying-period/work/${evaluation.id}/edit`) - } + let updatedDocument = evaluation.documents.find(d => d.key === document.key); + window.location.assign(buildLinkCreateNotification( + 'Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluationDocument', + updatedDocument.id, + tos === true ? this.$store.state.work.accompanyingPeriod.user.id : null, + window.location.pathname + window.location.search + window.location.hash + )); }; return this.$store.dispatch('submit', callback) .catch(e => {console.log(e); throw e}); From 9d2dfbe610feeebfd5fd253ede70d59ffac162ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 19 Jun 2023 21:02:19 +0200 Subject: [PATCH 219/724] DX: publish release 2.2.1 --- .changes/unreleased/Fixed-20230619-205836.yaml | 6 ------ .changes/v2.2.1.md | 3 +++ CHANGELOG.md | 4 ++++ 3 files changed, 7 insertions(+), 6 deletions(-) delete mode 100644 .changes/unreleased/Fixed-20230619-205836.yaml create mode 100644 .changes/v2.2.1.md diff --git a/.changes/unreleased/Fixed-20230619-205836.yaml b/.changes/unreleased/Fixed-20230619-205836.yaml deleted file mode 100644 index 54b292394..000000000 --- a/.changes/unreleased/Fixed-20230619-205836.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: Fixed -body: '[notification on document evaluation] fix entityId and return path when - adding a notification on a document in an evaluation' -time: 2023-06-19T20:58:36.941795323+02:00 -custom: - Issue: "114" diff --git a/.changes/v2.2.1.md b/.changes/v2.2.1.md new file mode 100644 index 000000000..c96b18585 --- /dev/null +++ b/.changes/v2.2.1.md @@ -0,0 +1,3 @@ +## v2.2.1 - 2023-06-19 +### Fixed +* ([#114](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/114)) [notification on document evaluation] fix entityId and return path when adding a notification on a document in an evaluation diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c5ed9b3a..e223fa116 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html), and is generated by [Changie](https://github.com/miniscruff/changie). +## v2.2.1 - 2023-06-19 +### Fixed +* ([#114](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/114)) [notification on document evaluation] fix entityId and return path when adding a notification on a document in an evaluation + ## v2.2.0 - 2023-06-18 ### Feature * When navigating from a workflow regarding to an evaluation's document to an accompanying course, scroll directly to the document, and blink to highlight this document From 146103e87c0cf8fef61b4b6bff1d72b84f710c99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 21 Jun 2023 13:33:29 +0200 Subject: [PATCH 220/724] Fixed: Accompanyingperiod / comment: order by newest to oldest --- .changes/unreleased/Fixed-20230621-132851.yaml | 6 ++++++ src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php | 7 +++++-- 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 .changes/unreleased/Fixed-20230621-132851.yaml diff --git a/.changes/unreleased/Fixed-20230621-132851.yaml b/.changes/unreleased/Fixed-20230621-132851.yaml new file mode 100644 index 000000000..89fb7cdd9 --- /dev/null +++ b/.changes/unreleased/Fixed-20230621-132851.yaml @@ -0,0 +1,6 @@ +kind: Fixed +body: '[Accompanying period comments]: order comments from the most recent to the + oldest, in the list' +time: 2023-06-21T13:28:51.282714011+02:00 +custom: + Issue: "" diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php index a8e191df3..accf39db5 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php @@ -185,7 +185,9 @@ class AccompanyingPeriod implements * cascade={"persist", "remove"}, * orphanRemoval=true * ) + * @ORM\OrderBy({"createdAt": "DESC", "id": "DESC"}) * @Assert\NotBlank(groups={AccompanyingPeriod::STEP_DRAFT}) + * @var Collection */ private Collection $comments; @@ -705,10 +707,11 @@ class AccompanyingPeriod implements ->comments ->filter( static fn (Comment $c): bool => $c !== $pinnedComment - ); + ) + ; } - public function getCreatedAt(): ?DateTime + public function getCreatedAt(): DateTimeInterface { return $this->createdAt; } From 471898e6d831d708bd3e90766aee9f816a781faf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 21 Jun 2023 13:59:42 +0200 Subject: [PATCH 221/724] Fixed: filter social action to keep only currently activated --- .../unreleased/Fixed-20230621-135912.yaml | 5 ++++ .../SocialWorkSocialActionApiController.php | 21 ++++++++-------- .../Entity/SocialWork/SocialAction.php | 24 +++++++++++++++++++ .../Entity/SocialWork/SocialIssue.php | 4 ++-- .../SocialWork/SocialAction/index.html.twig | 2 +- 5 files changed, 43 insertions(+), 13 deletions(-) create mode 100644 .changes/unreleased/Fixed-20230621-135912.yaml diff --git a/.changes/unreleased/Fixed-20230621-135912.yaml b/.changes/unreleased/Fixed-20230621-135912.yaml new file mode 100644 index 000000000..676d1c21b --- /dev/null +++ b/.changes/unreleased/Fixed-20230621-135912.yaml @@ -0,0 +1,5 @@ +kind: Fixed +body: 'Api: filter social action to keep only the currently activated' +time: 2023-06-21T13:59:12.57760217+02:00 +custom: + Issue: "" diff --git a/src/Bundle/ChillPersonBundle/Controller/SocialWorkSocialActionApiController.php b/src/Bundle/ChillPersonBundle/Controller/SocialWorkSocialActionApiController.php index 4fe877a72..ae70d55f9 100644 --- a/src/Bundle/ChillPersonBundle/Controller/SocialWorkSocialActionApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/SocialWorkSocialActionApiController.php @@ -16,21 +16,19 @@ use Chill\MainBundle\Pagination\PaginatorFactory; use Chill\MainBundle\Serializer\Model\Collection; use Chill\PersonBundle\Entity\SocialWork\SocialAction; use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository; +use Symfony\Component\Clock\ClockInterface; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use function count; -class SocialWorkSocialActionApiController extends ApiController +final class SocialWorkSocialActionApiController extends ApiController { - private PaginatorFactory $paginator; - - private SocialIssueRepository $socialIssueRepository; - - public function __construct(SocialIssueRepository $socialIssueRepository, PaginatorFactory $paginator) - { - $this->socialIssueRepository = $socialIssueRepository; - $this->paginator = $paginator; + public function __construct( + private readonly SocialIssueRepository $socialIssueRepository, + private readonly PaginatorFactory $paginator, + private readonly ClockInterface $clock, + ) { } public function listBySocialIssueApi($id, Request $request) @@ -42,7 +40,10 @@ class SocialWorkSocialActionApiController extends ApiController throw $this->createNotFoundException('socialIssue not found'); } - $socialActions = $socialIssue->getRecursiveSocialActions()->toArray(); + $socialActions = SocialAction::filterRemoveDeactivatedActions( + $socialIssue->getRecursiveSocialActions()->toArray(), + \DateTime::createFromImmutable($this->clock->now()) + ); usort($socialActions, static fn (SocialAction $sa, SocialAction $sb) => $sa->getOrdering() <=> $sb->getOrdering()); diff --git a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php index a8c68c8ce..b5b0f9101 100644 --- a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php +++ b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php @@ -15,6 +15,7 @@ use DateInterval; use DateTimeInterface; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; +use Doctrine\Common\Collections\ReadableCollection; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Serializer\Annotation as Serializer; @@ -295,6 +296,19 @@ class SocialAction return 0 < $this->getChildren()->count(); } + public function isDesactivated(\DateTime $atDate): bool + { + if (null !== $this->desactivationDate && $this->desactivationDate < $atDate) { + return true; + } + + if ($this->hasParent()) { + return $this->parent->isDesactivated($atDate); + } + + return false; + } + public function hasParent(): bool { return $this->getParent() instanceof self; @@ -401,4 +415,14 @@ class SocialAction return $this; } + + public static function filterRemoveDeactivatedActions(ReadableCollection|array $actions, \DateTime $comparisonDate): ReadableCollection|array + { + $filterFn = fn (SocialAction $socialAction) => !$socialAction->isDesactivated($comparisonDate); + + return match ($actions instanceof ReadableCollection) { + true => $actions->filter($filterFn), + false => array_filter($actions, $filterFn) + }; + } } diff --git a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php index 675a1a923..f12627ae3 100644 --- a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php +++ b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php @@ -253,7 +253,7 @@ class SocialIssue } /** - * @return Collection|SocialAction[] All the descendant social actions of all + * @return Collection All the descendant social actions of all * the descendants of the entity */ public function getRecursiveSocialActions(): Collection @@ -272,7 +272,7 @@ class SocialIssue } /** - * @return Collection|SocialAction[] + * @return Collection */ public function getSocialActions(): Collection { diff --git a/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/SocialAction/index.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/SocialAction/index.html.twig index e78216f04..9e6c6e5aa 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/SocialAction/index.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/SocialAction/index.html.twig @@ -20,7 +20,7 @@ {{ entity.ordering }} {% if entity.desactivationDate is not null %} - {{ entity.desactivationDate|date('Y-m-d') }} + {{ entity.desactivationDate|format_date('medium') }} {% endif %} From 27f797d7361ac4b8234a8cb435cf7d17671ab147 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 21 Jun 2023 14:30:22 +0200 Subject: [PATCH 222/724] add changie entry for fixing filiation bug --- .changes/unreleased/Fixed-20230621-141828.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changes/unreleased/Fixed-20230621-141828.yaml diff --git a/.changes/unreleased/Fixed-20230621-141828.yaml b/.changes/unreleased/Fixed-20230621-141828.yaml new file mode 100644 index 000000000..2c7f94488 --- /dev/null +++ b/.changes/unreleased/Fixed-20230621-141828.yaml @@ -0,0 +1,5 @@ +kind: Fixed +body: Fix deletion and re-creation of filiation relationship +time: 2023-06-21T14:18:28.437876316+02:00 +custom: + Issue: "82" From 659dff3d2c310951bf3a0dce6474ed375e4d5b55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 23 Jun 2023 12:19:40 +0200 Subject: [PATCH 223/724] DX: Add features to filterOrder Allow to add single checkboxes and entitychoices to filter order --- .changes/unreleased/DX-20230623-122408.yaml | 5 ++ .../Form/Type/Listing/FilterOrderType.php | 54 ++++++------- .../views/FilterOrder/base.html.twig | 50 ++++++++++-- .../Templating/Listing/FilterOrderHelper.php | 76 +++++++++++++++++-- .../Listing/FilterOrderHelperBuilder.php | 39 ++++++++++ .../Templating/Listing/Templating.php | 39 +++++++++- 6 files changed, 224 insertions(+), 39 deletions(-) create mode 100644 .changes/unreleased/DX-20230623-122408.yaml diff --git a/.changes/unreleased/DX-20230623-122408.yaml b/.changes/unreleased/DX-20230623-122408.yaml new file mode 100644 index 000000000..58dd96180 --- /dev/null +++ b/.changes/unreleased/DX-20230623-122408.yaml @@ -0,0 +1,5 @@ +kind: DX +body: '[FilterOrderHelper] add entity choice and singleCheckbox' +time: 2023-06-23T12:24:08.133491895+02:00 +custom: + Issue: "" diff --git a/src/Bundle/ChillMainBundle/Form/Type/Listing/FilterOrderType.php b/src/Bundle/ChillMainBundle/Form/Type/Listing/FilterOrderType.php index aaa6afa24..16038515d 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/Listing/FilterOrderType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/Listing/FilterOrderType.php @@ -13,6 +13,8 @@ namespace Chill\MainBundle\Form\Type\Listing; use Chill\MainBundle\Form\Type\ChillDateType; use Chill\MainBundle\Templating\Listing\FilterOrderHelper; +use Symfony\Bridge\Doctrine\Form\Type\EntityType; +use Symfony\Component\Form\Extension\Core\Type\CheckboxType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\HiddenType; use Symfony\Component\Form\Extension\Core\Type\SearchType; @@ -27,13 +29,6 @@ use function count; final class FilterOrderType extends \Symfony\Component\Form\AbstractType { - private RequestStack $requestStack; - - public function __construct(RequestStack $requestStack) - { - $this->requestStack = $requestStack; - } - public function buildForm(FormBuilderInterface $builder, array $options) { /** @var FilterOrderHelper $helper */ @@ -71,6 +66,25 @@ final class FilterOrderType extends \Symfony\Component\Form\AbstractType $builder->add($checkboxesBuilder); } + if ([] !== $helper->getEntityChoices()) { + $entityChoicesBuilder = $builder->create('entity_choices', null, ['compound' => true]); + + foreach ($helper->getEntityChoices() as $key => [ + 'label' => $label, 'choices' => $choices, 'options' => $opts, 'class' => $class + ]) { + $entityChoicesBuilder->add($key, EntityType::class, [ + 'label' => $label, + 'choices' => $choices, + 'class' => $class, + 'multiple' => true, + 'expanded' => true, + ...$opts, + ]); + } + + $builder->add($entityChoicesBuilder); + } + if (0 < count($helper->getDateRanges())) { $dateRangesBuilder = $builder->create('dateRanges', null, ['compound' => true]); @@ -97,28 +111,14 @@ final class FilterOrderType extends \Symfony\Component\Form\AbstractType $builder->add($dateRangesBuilder); } - foreach ($this->requestStack->getCurrentRequest()->query->getIterator() as $key => $value) { - switch ($key) { - case 'q': - case 'checkboxes' . $key: - case $key . '_from': - case $key . '_to': - break; + if ([] !== $helper->getSingleCheckbox()) { + $singleCheckBoxBuilder = $builder->create('single_checkboxes', null, ['compound' => true]); - case 'page': - $builder->add($key, HiddenType::class, [ - 'data' => 1, - ]); - - break; - - default: - $builder->add($key, HiddenType::class, [ - 'data' => $value, - ]); - - break; + foreach ($helper->getSingleCheckbox() as $name => ['label' => $label]) { + $singleCheckBoxBuilder->add($name, CheckboxType::class, ['label' => $label, 'required' => false]); } + + $builder->add($singleCheckBoxBuilder); } } diff --git a/src/Bundle/ChillMainBundle/Resources/views/FilterOrder/base.html.twig b/src/Bundle/ChillMainBundle/Resources/views/FilterOrder/base.html.twig index 1f1e54c72..d4a6bbdd4 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/FilterOrder/base.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/FilterOrder/base.html.twig @@ -13,13 +13,13 @@ {% if form.dateRanges is defined %} {% if form.dateRanges|length > 0 %} {% for dateRangeName, _o in form.dateRanges %} -
    +
    {% if form.dateRanges[dateRangeName].vars.label is not same as(false) %} -
    +
    {{ form_label(form.dateRanges[dateRangeName])}}
    {% endif %} -
    +
    {{ 'chill_calendar.From'|trans }} {{ form_widget(form.dateRanges[dateRangeName]['from']) }} @@ -27,7 +27,7 @@ {{ form_widget(form.dateRanges[dateRangeName]['to']) }}
    -
    +
    @@ -37,7 +37,7 @@ {% if form.checkboxes is defined %} {% if form.checkboxes|length > 0 %} {% for checkbox_name, options in form.checkboxes %} -
    +
    {% for c in form['checkboxes'][checkbox_name].children %}
    @@ -61,5 +61,45 @@ {% endfor %} {% endif %} {% endif %} + {% if form.entity_choices is defined %} + {% if form.entity_choices |length > 0 %} + {% for checkbox_name, options in form.entity_choices %} +
    + {% if form.entity_choices[checkbox_name].vars.label is not same as(false) %} +
    + {{ form_label(form.entity_choices[checkbox_name])}} +
    + {% endif %} +
    + {% for c in form['entity_choices'][checkbox_name].children %} +
    + {{ form_widget(c) }} + {{ form_label(c) }} +
    + {% endfor %} +
    +
    + +
    +
    + {% endfor %} + {% endif %} + {% endif %} + {% if form.single_checkboxes is defined %} + {% for name, _o in form.single_checkboxes %} +
    +
    + {{ form_widget(form.single_checkboxes[name]) }} +
    +
    + +
    +
    + {% endfor %} + {% endif %}
    + + {% for k,v in otherParameters %} + + {% endfor %} {{ form_end(form) }} diff --git a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php index 367cc0861..28cc8e331 100644 --- a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php +++ b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php @@ -13,6 +13,8 @@ namespace Chill\MainBundle\Templating\Listing; use Chill\MainBundle\Form\Type\Listing\FilterOrderType; use DateTimeImmutable; +use Symfony\Component\Form\Extension\Core\Type\FormType; +use Symfony\Component\Form\Extension\Core\Type\HiddenType; use Symfony\Component\Form\FormFactoryInterface; use Symfony\Component\Form\FormInterface; use Symfony\Component\HttpFoundation\RequestStack; @@ -24,11 +26,16 @@ class FilterOrderHelper { private array $checkboxes = []; + /** + * @var array + */ + private array $singleCheckbox = []; + private array $dateRanges = []; private FormFactoryInterface $formFactory; - private ?string $formName = 'f'; + public const FORM_NAME = 'f'; private array $formOptions = []; @@ -40,6 +47,11 @@ class FilterOrderHelper private ?array $submitted = null; + /** + * @var array + */ + private array $entityChoices = []; + public function __construct( FormFactoryInterface $formFactory, RequestStack $requestStack @@ -48,7 +60,29 @@ class FilterOrderHelper $this->requestStack = $requestStack; } - public function addCheckbox(string $name, array $choices, ?array $default = [], ?array $trans = []): self + public function addSingleCheckbox(string $name, string $label): self + { + $this->singleCheckbox[$name] = ['label' => $label]; + + return $this; + } + + /** + * @param class-string $class + */ + public function addEntityChoice(string $name, string $class, string $label, array $choices, array $options = []): self + { + $this->entityChoices[$name] = ['label' => $label, 'class' => $class, 'choices' => $choices, 'options' => $options]; + + return $this; + } + + public function getEntityChoices(): array + { + return $this->entityChoices; + } + + public function addCheckbox(string $name, array $choices, ?array $default = [], ?array $trans = [], array $options = []): self { $missing = count($choices) - count($trans) - 1; $this->checkboxes[$name] = [ @@ -58,6 +92,7 @@ class FilterOrderHelper 0 < $missing ? array_fill(0, $missing, null) : [] ), + ...$options, ]; return $this; @@ -73,7 +108,7 @@ class FilterOrderHelper public function buildForm(): FormInterface { return $this->formFactory - ->createNamed($this->formName, $this->formType, $this->getDefaultData(), array_merge([ + ->createNamed(self::FORM_NAME, $this->formType, $this->getDefaultData(), array_merge([ 'helper' => $this, 'method' => 'GET', 'csrf_protection' => false, @@ -86,13 +121,31 @@ class FilterOrderHelper return $this->getFormData()['checkboxes'][$name]; } + public function getSingleCheckboxData(string $name): ?bool + { + return $this->getFormData()['single_checkboxes'][$name]; + } + + public function getEntityChoiceData($name): mixed + { + return $this->getFormData()['entity_choices'][$name]; + } + public function getCheckboxes(): array { return $this->checkboxes; } /** - * @return array<'to': DateTimeImmutable, 'from': DateTimeImmutable> + * @return array + */ + public function getSingleCheckbox(): array + { + return $this->singleCheckbox; + } + + /** + * @return array{to: ?DateTimeImmutable, from: ?DateTimeImmutable} */ public function getDateRangeData(string $name): array { @@ -123,7 +176,12 @@ class FilterOrderHelper private function getDefaultData(): array { - $r = []; + $r = [ + 'checkboxes' => [], + 'dateRanges' => [], + 'single_checkboxes' => [], + 'entity_choices' => [] + ]; if ($this->hasSearchBox()) { $r['q'] = ''; @@ -138,6 +196,14 @@ class FilterOrderHelper $r['dateRanges'][$name]['to'] = $defaults['to']; } + foreach ($this->singleCheckbox as $name => $c) { + $r['single_checkboxes'][$name] = false; + } + + foreach ($this->entityChoices as $name => $c) { + $r['entity_choices'][$name] = ($c['options']['multiple'] ?? true) ? [] : null; + } + return $r; } diff --git a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperBuilder.php b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperBuilder.php index d68c8c37a..e176e27c6 100644 --- a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperBuilder.php +++ b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperBuilder.php @@ -27,6 +27,16 @@ class FilterOrderHelperBuilder private ?array $searchBoxFields = null; + /** + * @var array + */ + private array $singleCheckboxes = []; + + /** + * @var array + */ + private array $entityChoices = []; + public function __construct( FormFactoryInterface $formFactory, RequestStack $requestStack @@ -35,6 +45,13 @@ class FilterOrderHelperBuilder $this->requestStack = $requestStack; } + public function addSingleCheckbox(string $name, string $label): self + { + $this->singleCheckboxes[$name] = ['label' => $label]; + + return $this; + } + public function addCheckbox(string $name, array $choices, ?array $default = [], ?array $trans = []): self { $this->checkboxes[$name] = ['choices' => $choices, 'default' => $default, 'trans' => $trans]; @@ -42,6 +59,16 @@ class FilterOrderHelperBuilder return $this; } + /** + * @param class-string $class + */ + public function addEntityChoice(string $name, string $label, string $class, array $choices, ?array $options = []): self + { + $this->entityChoices[$name] = ['label' => $label, 'class' => $class, 'choices' => $choices, 'options' => $options]; + + return $this; + } + public function addDateRange(string $name, ?string $label = null, ?DateTimeImmutable $from = null, ?DateTimeImmutable $to = null): self { $this->dateRanges[$name] = ['from' => $from, 'to' => $to, 'label' => $label]; @@ -75,6 +102,18 @@ class FilterOrderHelperBuilder $helper->addCheckbox($name, $choices, $default, $trans); } + foreach ( + $this->singleCheckboxes as $name => ['label' => $label] + ) { + $helper->addSingleCheckbox($name, $label); + } + + foreach ( + $this->entityChoices as $name => ['label' => $label, 'class' => $class, 'choices' => $choices, 'options' => $options] + ) { + $helper->addEntityChoice($name, $class, $label, $choices, $options); + } + foreach ( $this->dateRanges as $name => [ 'from' => $from, diff --git a/src/Bundle/ChillMainBundle/Templating/Listing/Templating.php b/src/Bundle/ChillMainBundle/Templating/Listing/Templating.php index bc256e24f..b91cd86e8 100644 --- a/src/Bundle/ChillMainBundle/Templating/Listing/Templating.php +++ b/src/Bundle/ChillMainBundle/Templating/Listing/Templating.php @@ -11,13 +11,23 @@ declare(strict_types=1); namespace Chill\MainBundle\Templating\Listing; +use Chill\MainBundle\Pagination\PaginatorFactory; +use Symfony\Component\HttpFoundation\RequestStack; use Twig\Environment; +use Twig\Error\LoaderError; +use Twig\Error\RuntimeError; +use Twig\Error\SyntaxError; use Twig\Extension\AbstractExtension; use Twig\TwigFilter; class Templating extends AbstractExtension { - public function getFilters() + public function __construct( + private readonly RequestStack $requestStack, + ) { + } + + public function getFilters(): array { return [ new TwigFilter('chill_render_filter_order_helper', [$this, 'renderFilterOrderHelper'], [ @@ -26,16 +36,41 @@ class Templating extends AbstractExtension ]; } + /** + * @throws SyntaxError + * @throws RuntimeError + * @throws LoaderError + */ public function renderFilterOrderHelper( Environment $environment, FilterOrderHelper $helper, ?string $template = '@ChillMain/FilterOrder/base.html.twig', ?array $options = [] - ) { + ): string { + $otherParameters = []; + + foreach ($this->requestStack->getCurrentRequest()->query->getIterator() as $key => $value) { + switch ($key) { + case FilterOrderHelper::FORM_NAME: + break; + + case PaginatorFactory::DEFAULT_CURRENT_PAGE_KEY: + // when filtering, go back to page 1 + $otherParameters[PaginatorFactory::DEFAULT_CURRENT_PAGE_KEY] = 1; + + break; + default: + $otherParameters[$key] = $value; + + break; + } + } + return $environment->render($template, [ 'helper' => $helper, 'form' => $helper->buildForm()->createView(), 'options' => $options, + 'otherParameters' => $otherParameters, ]); } } From 51544cfc48418e3492d43b232081efabf5d1772e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 23 Jun 2023 12:21:13 +0200 Subject: [PATCH 224/724] DX: improve typing of a property in UserJob --- src/Bundle/ChillMainBundle/Entity/UserJob.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bundle/ChillMainBundle/Entity/UserJob.php b/src/Bundle/ChillMainBundle/Entity/UserJob.php index ed8bc43f3..c6bfe1aa3 100644 --- a/src/Bundle/ChillMainBundle/Entity/UserJob.php +++ b/src/Bundle/ChillMainBundle/Entity/UserJob.php @@ -37,7 +37,7 @@ class UserJob protected ?int $id = null; /** - * @var array|string[]A + * @var array * @ORM\Column(name="label", type="json") * @Serializer\Groups({"read", "docgen:read"}) * @Serializer\Context({"is-translatable": true}, groups={"docgen:read"}) From f7c11d356737351d7fda548b3bb5d0acc7b0fac4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 23 Jun 2023 12:22:24 +0200 Subject: [PATCH 225/724] Feature: Add filters on activity list --- .../unreleased/Feature-20230623-122530.yaml | 5 + .../unreleased/Feature-20230623-122702.yaml | 6 + .../Controller/ActivityController.php | 138 ++++---- .../Repository/ActivityACLAwareRepository.php | 240 ++++++++++--- .../ActivityACLAwareRepositoryInterface.php | 36 +- .../Repository/ActivityTypeRepository.php | 4 + .../ActivityTypeRepositoryInterface.php | 4 +- .../Resources/views/Activity/list.html.twig | 3 + .../ActivityACLAwareRepositoryTest.php | 325 ++++++++++++++++++ .../translations/messages.fr.yml | 8 + 10 files changed, 648 insertions(+), 121 deletions(-) create mode 100644 .changes/unreleased/Feature-20230623-122530.yaml create mode 100644 .changes/unreleased/Feature-20230623-122702.yaml create mode 100644 src/Bundle/ChillActivityBundle/Tests/Repository/ActivityACLAwareRepositoryTest.php diff --git a/.changes/unreleased/Feature-20230623-122530.yaml b/.changes/unreleased/Feature-20230623-122530.yaml new file mode 100644 index 000000000..922750ea8 --- /dev/null +++ b/.changes/unreleased/Feature-20230623-122530.yaml @@ -0,0 +1,5 @@ +kind: Feature +body: '[activity list] add filtering for activities list' +time: 2023-06-23T12:25:30.49643551+02:00 +custom: + Issue: "" diff --git a/.changes/unreleased/Feature-20230623-122702.yaml b/.changes/unreleased/Feature-20230623-122702.yaml new file mode 100644 index 000000000..e1d1b0e1f --- /dev/null +++ b/.changes/unreleased/Feature-20230623-122702.yaml @@ -0,0 +1,6 @@ +kind: Feature +body: '[activity list] in person context, show also the activities from the accompanying + periods where the person participates' +time: 2023-06-23T12:27:02.159041095+02:00 +custom: + Issue: "" diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php index 444c663fc..07e4fcf62 100644 --- a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php +++ b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php @@ -18,11 +18,16 @@ use Chill\ActivityBundle\Repository\ActivityACLAwareRepositoryInterface; use Chill\ActivityBundle\Repository\ActivityRepository; use Chill\ActivityBundle\Repository\ActivityTypeCategoryRepository; use Chill\ActivityBundle\Repository\ActivityTypeRepositoryInterface; +use Chill\ActivityBundle\Repository\ActivityUserJobRepository; use Chill\ActivityBundle\Security\Authorization\ActivityVoter; use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable; +use Chill\MainBundle\Entity\UserJob; use Chill\MainBundle\Repository\LocationRepository; use Chill\MainBundle\Repository\UserRepositoryInterface; use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface; +use Chill\MainBundle\Templating\Listing\FilterOrderHelper; +use Chill\MainBundle\Templating\Listing\FilterOrderHelperFactoryInterface; +use Chill\MainBundle\Templating\TranslatableStringHelperInterface; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Privacy\PrivacyEvent; @@ -47,68 +52,25 @@ use function array_key_exists; final class ActivityController extends AbstractController { - private AccompanyingPeriodRepository $accompanyingPeriodRepository; - - private ActivityACLAwareRepositoryInterface $activityACLAwareRepository; - - private ActivityRepository $activityRepository; - - private ActivityTypeCategoryRepository $activityTypeCategoryRepository; - - private ActivityTypeRepositoryInterface $activityTypeRepository; - - private CenterResolverManagerInterface $centerResolver; - - private EntityManagerInterface $entityManager; - - private EventDispatcherInterface $eventDispatcher; - - private LocationRepository $locationRepository; - - private LoggerInterface $logger; - - private PersonRepository $personRepository; - - private SerializerInterface $serializer; - - private ThirdPartyRepository $thirdPartyRepository; - - private TranslatorInterface $translator; - - private UserRepositoryInterface $userRepository; - public function __construct( - ActivityACLAwareRepositoryInterface $activityACLAwareRepository, - ActivityTypeRepositoryInterface $activityTypeRepository, - ActivityTypeCategoryRepository $activityTypeCategoryRepository, - PersonRepository $personRepository, - ThirdPartyRepository $thirdPartyRepository, - LocationRepository $locationRepository, - ActivityRepository $activityRepository, - AccompanyingPeriodRepository $accompanyingPeriodRepository, - EntityManagerInterface $entityManager, - EventDispatcherInterface $eventDispatcher, - LoggerInterface $logger, - SerializerInterface $serializer, - UserRepositoryInterface $userRepository, - CenterResolverManagerInterface $centerResolver, - TranslatorInterface $translator + private readonly ActivityACLAwareRepositoryInterface $activityACLAwareRepository, + private readonly ActivityTypeRepositoryInterface $activityTypeRepository, + private readonly ActivityTypeCategoryRepository $activityTypeCategoryRepository, + private readonly PersonRepository $personRepository, + private readonly ThirdPartyRepository $thirdPartyRepository, + private readonly LocationRepository $locationRepository, + private readonly ActivityRepository $activityRepository, + private readonly AccompanyingPeriodRepository $accompanyingPeriodRepository, + private readonly EntityManagerInterface $entityManager, + private readonly EventDispatcherInterface $eventDispatcher, + private readonly LoggerInterface $logger, + private readonly SerializerInterface $serializer, + private readonly UserRepositoryInterface $userRepository, + private readonly CenterResolverManagerInterface $centerResolver, + private readonly TranslatorInterface $translator, + private readonly FilterOrderHelperFactoryInterface $filterOrderHelperFactory, + private readonly TranslatableStringHelperInterface $translatableStringHelper, ) { - $this->activityACLAwareRepository = $activityACLAwareRepository; - $this->activityTypeRepository = $activityTypeRepository; - $this->activityTypeCategoryRepository = $activityTypeCategoryRepository; - $this->personRepository = $personRepository; - $this->thirdPartyRepository = $thirdPartyRepository; - $this->locationRepository = $locationRepository; - $this->activityRepository = $activityRepository; - $this->accompanyingPeriodRepository = $accompanyingPeriodRepository; - $this->entityManager = $entityManager; - $this->eventDispatcher = $eventDispatcher; - $this->logger = $logger; - $this->serializer = $serializer; - $this->userRepository = $userRepository; - $this->centerResolver = $centerResolver; - $this->translator = $translator; } /** @@ -292,11 +254,27 @@ final class ActivityController extends AbstractController // TODO: add pagination [$person, $accompanyingPeriod] = $this->getEntity($request); + $filter = $this->buildFilterOrder($person ?? $accompanyingPeriod); + + $filterArgs = [ + 'my_activities' => $filter->getSingleCheckboxData('my_activities'), + 'types' => $filter->getEntityChoiceData('activity_types'), + 'jobs' => $filter->getEntityChoiceData('jobs'), + 'before' => $filter->getDateRangeData('activity_date')['to'], + 'after' => $filter->getDateRangeData('activity_date')['from'], + ]; if ($person instanceof Person) { $this->denyAccessUnlessGranted(ActivityVoter::SEE, $person); $activities = $this->activityACLAwareRepository - ->findByPerson($person, ActivityVoter::SEE, 0, null, ['date' => 'DESC', 'id' => 'DESC']); + ->findByPerson( + $person, + ActivityVoter::SEE, + 0, + null, + ['date' => 'DESC', 'id' => 'DESC'], + $filterArgs + ); $event = new PrivacyEvent($person, [ 'element_class' => Activity::class, @@ -309,7 +287,14 @@ final class ActivityController extends AbstractController $this->denyAccessUnlessGranted(ActivityVoter::SEE, $accompanyingPeriod); $activities = $this->activityACLAwareRepository - ->findByAccompanyingPeriod($accompanyingPeriod, ActivityVoter::SEE, 0, null, ['date' => 'DESC', 'id' => 'DESC']); + ->findByAccompanyingPeriod( + $accompanyingPeriod, + ActivityVoter::SEE, + 0, + null, + ['date' => 'DESC', 'id' => 'DESC'], + $filterArgs + ); $view = 'ChillActivityBundle:Activity:listAccompanyingCourse.html.twig'; } @@ -320,10 +305,39 @@ final class ActivityController extends AbstractController 'activities' => $activities, 'person' => $person, 'accompanyingCourse' => $accompanyingPeriod, + 'filter' => $filter, ] ); } + private function buildFilterOrder(AccompanyingPeriod|Person $associated): FilterOrderHelper + { + + $filterBuilder = $this->filterOrderHelperFactory->create(self::class); + $types = $this->activityACLAwareRepository->findActivityTypeByAssociated($associated); + $jobs = $this->activityACLAwareRepository->findUserJobByAssociated($associated); + + $filterBuilder + ->addDateRange('activity_date', 'activity.date') + ->addSingleCheckbox('my_activities', 'activity_filter.My activities') + ->addEntityChoice('activity_types', 'activity_filter.Types', \Chill\ActivityBundle\Entity\ActivityType::class, $types, [ + 'choice_label' => function (\Chill\ActivityBundle\Entity\ActivityType $activityType) { + $text = match ($activityType->hasCategory()) { + true => $this->translatableStringHelper->localize($activityType->getCategory()->getName()) . ' > ', + false => '', + }; + + return $text . $this->translatableStringHelper->localize($activityType->getName()); + } + ]) + ->addEntityChoice('jobs', 'activity_filter.Jobs', UserJob::class, $jobs, [ + 'choice_label' => fn (UserJob $u) => $this->translatableStringHelper->localize($u->getLabel()) + ]) + ; + + return $filterBuilder->build(); + } + public function newAction(Request $request): Response { $view = null; diff --git a/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php b/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php index 1f2039a2c..1fd0a57d6 100644 --- a/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php +++ b/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php @@ -18,67 +18,159 @@ use Chill\ActivityBundle\Security\Authorization\ActivityVoter; use Chill\MainBundle\Entity\Location; use Chill\MainBundle\Entity\LocationType; use Chill\MainBundle\Entity\Scope; -use Chill\MainBundle\Security\Authorization\AuthorizationHelper; -use Chill\MainBundle\Security\Resolver\CenterResolverDispatcherInterface; +use Chill\MainBundle\Entity\User; +use Chill\MainBundle\Entity\UserJob; +use Chill\MainBundle\Security\Authorization\AuthorizationHelperForCurrentUserInterface; +use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\Person; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\AbstractQuery; use Doctrine\ORM\EntityManagerInterface; +use Doctrine\ORM\Query\Expr\Join; use Doctrine\ORM\Query\ResultSetMappingBuilder; -use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; -use Symfony\Component\Security\Core\Role\Role; +use Doctrine\ORM\QueryBuilder; +use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\Security\Core\Security; use function count; use function in_array; -final class ActivityACLAwareRepository implements ActivityACLAwareRepositoryInterface +final readonly class ActivityACLAwareRepository implements ActivityACLAwareRepositoryInterface { - private AuthorizationHelper $authorizationHelper; - - private CenterResolverDispatcherInterface $centerResolverDispatcher; - - private EntityManagerInterface $em; - - private ActivityRepository $repository; - - private Security $security; - - private TokenStorageInterface $tokenStorage; - public function __construct( - AuthorizationHelper $authorizationHelper, - CenterResolverDispatcherInterface $centerResolverDispatcher, - TokenStorageInterface $tokenStorage, - ActivityRepository $repository, - EntityManagerInterface $em, - Security $security + private AuthorizationHelperForCurrentUserInterface $authorizationHelper, + private CenterResolverManagerInterface $centerResolverManager, + private ActivityRepository $repository, + private EntityManagerInterface $em, + private Security $security, + private RequestStack $requestStack, ) { - $this->authorizationHelper = $authorizationHelper; - $this->centerResolverDispatcher = $centerResolverDispatcher; - $this->tokenStorage = $tokenStorage; - $this->repository = $repository; - $this->em = $em; - $this->security = $security; } - public function findByAccompanyingPeriod(AccompanyingPeriod $period, string $role, ?int $start = 0, ?int $limit = 1000, ?array $orderBy = []): array + public function findByAccompanyingPeriod(AccompanyingPeriod $period, string $role, ?int $start = 0, ?int $limit = 1000, array $orderBy = ['date' => 'DESC'], array $filters = []): array { - $user = $this->security->getUser(); - $center = $this->centerResolverDispatcher->resolveCenter($period); + $qb = $this->buildBaseQuery($filters); - if (0 === count($orderBy)) { - $orderBy = ['date' => 'DESC']; + $qb->andWhere('a.accompanyingPeriod = :period')->setParameter('period', $period); + + foreach ($orderBy as $field => $order) { + $qb->addOrderBy('a.' . $field, $order); } - $scopes = $this->authorizationHelper - ->getReachableCircles($user, $role, $center); + $qb->setFirstResult(0)->setMaxResults(1000); - return $this->em->getRepository(Activity::class) - ->findByAccompanyingPeriod($period, $scopes, true, $limit, $start, $orderBy); + return $qb->getQuery()->getResult(); } + public function buildBaseQuery(array $filters): QueryBuilder + { + $qb = $this->repository + ->createQueryBuilder('a') + ; + + if (($filters['my_activities'] ?? false) and ($user = $this->security->getUser()) instanceof User) { + $qb->andWhere( + $qb->expr()->orX( + 'a.createdBy = :user', + 'a.user = :user', + ':user MEMBER OF a.users' + ) + )->setParameter('user', $user); + } + + if ([] !== ($types = $filters['types'] ?? [])) { + $qb->andWhere('a.activityType IN (:types)')->setParameter('types', $types); + } + + if ([] !== ($jobs = $filters['jobs'] ?? [])) { + $qb + ->leftJoin('a.createdBy', 'creator') + ->leftJoin('a.user', 'activity_u') + ->andWhere( + $qb->expr()->orX( + 'creator.userJob IN (:jobs)', + 'activity_u.userJob IN (:jobs)', + 'EXISTS (SELECT 1 FROM ' . User::class . ' activity_user WHERE activity_user MEMBER OF a.users AND activity_user.userJob IN (:jobs))' + ) + ) + ->setParameter('jobs', $jobs); + } + + if (null !== ($after = $filters['after'] ?? null)) { + $qb->andWhere('a.date >= :after')->setParameter('after', $after); + } + + if (null !== ($before = $filters['before'] ?? null)) { + $qb->andWhere('a.date <= :before')->setParameter('before', $before); + } + + return $qb; + } + + /** + * @param AccompanyingPeriod|Person $associated + * @return array + */ + public function findActivityTypeByAssociated(AccompanyingPeriod|Person $associated): array + { + $in = $this->em->createQueryBuilder(); + $in + ->select('1') + ->from(Activity::class, 'a'); + + if ($associated instanceof Person) { + $in = $this->filterBaseQueryByPerson($in, $associated, ActivityVoter::SEE); + } else { + $in->andWhere('a.accompanyingPeriod = :period')->setParameter('period', $associated); + } + + // join between the embedded exist query and the main query + $in->andWhere('a.activityType = t'); + + $qb = $this->em->createQueryBuilder()->setParameters($in->getParameters()); + $qb + ->select('t') + ->from(ActivityType::class, 't') + ->where( + $qb->expr()->exists($in->getDQL()) + ); + + return $qb->getQuery()->getResult(); + } + + public function findUserJobByAssociated(Person|AccompanyingPeriod $associated): array + { + $in = $this->em->createQueryBuilder(); + $in->select('IDENTITY(u.userJob)') + ->from(User::class, 'u') + ->join( + Activity::class, + 'a', + Join::WITH, + 'a.createdBy = u OR a.user = u OR u MEMBER OF a.users' + ); + + if ($associated instanceof Person) { + $in = $this->filterBaseQueryByPerson($in, $associated, ActivityVoter::SEE); + } else { + $in->andWhere('a.accompanyingPeriod = :associated'); + $in->setParameter('associated', $associated); + } + + $qb = $this->em->createQueryBuilder()->setParameters($in->getParameters()); + + $qb->select('ub', 'JSON_EXTRACT(ub.label, :lang) AS HIDDEN lang') + ->from(UserJob::class, 'ub') + ->where($qb->expr()->in('ub.id', $in->getDQL())) + ->setParameter('lang', $this->requestStack->getCurrentRequest()->getLocale()) + ->orderBy('lang') + ; + + return $qb->getQuery()->getResult(); + } + + public function findByAccompanyingPeriodSimplified(AccompanyingPeriod $period, ?int $limit = 1000): array { $rsm = new ResultSetMappingBuilder($this->em); @@ -159,25 +251,66 @@ final class ActivityACLAwareRepository implements ActivityACLAwareRepositoryInte return $nq->getResult(AbstractQuery::HYDRATE_ARRAY); } - /** - * @param array $orderBy - * - * @return Activity[]|array - */ - public function findByPerson(Person $person, string $role, ?int $start = 0, ?int $limit = 1000, ?array $orderBy = []): array + public function findByPerson(Person $person, string $role, ?int $start = 0, ?int $limit = 1000, ?array $orderBy = [], array $filters = []): array { - $user = $this->security->getUser(); - $center = $this->centerResolverDispatcher->resolveCenter($person); + $qb = $this->buildBaseQuery($filters); - if (0 === count($orderBy)) { - $orderBy = ['date' => 'DESC']; + $qb = $this->filterBaseQueryByPerson($qb, $person, $role); + + foreach ($orderBy as $field => $direction) { + $qb->addOrderBy('a.' . $field, $direction); } - $reachableScopes = $this->authorizationHelper - ->getReachableCircles($user, $role, $center); + return $qb->getQuery()->getResult(); + } - return $this->em->getRepository(Activity::class) - ->findByPersonImplied($person, $reachableScopes, $orderBy, $limit, $start); + private function filterBaseQueryByPerson(QueryBuilder $qb, Person $person, string $role): QueryBuilder + { + $orX = $qb->expr()->orX(); + $counter = 0; + foreach ($this->centerResolverManager->resolveCenters($person) as $center) { + $scopes = $this->authorizationHelper->getReachableScopes($role, $center); + + if ([] === $scopes) { + continue; + } + + $orX->add(sprintf('a.person = :person AND a.scope IN (:scopes_%d)', $counter)); + $qb->setParameter(sprintf('scopes_%d', $counter), $scopes); + $qb->setParameter('person', $person); + $counter++; + } + + foreach ($person->getAccompanyingPeriodParticipations() as $participation) { + if (!$this->security->isGranted(ActivityVoter::SEE, $participation->getAccompanyingPeriod())) { + continue; + } + + $and = $qb->expr()->andX( + sprintf('a.accompanyingPeriod = :period_%d', $counter), + sprintf('a.date >= :participation_start_%d', $counter) + ); + + $qb + ->setParameter(sprintf('period_%d', $counter), $participation->getAccompanyingPeriod()) + ->setParameter(sprintf('participation_start_%d', $counter), $participation->getStartDate()); + + if (null !== $participation->getEndDate()) { + $and->add(sprintf('a.date < :participation_end_%d', $counter)); + $qb + ->setParameter(sprintf('participation_end_%d', $counter), $participation->getEndDate()); + } + $orX->add($and); + $counter++; + } + + if (0 === $orX->count()) { + $qb->andWhere('FALSE = TRUE'); + } else { + $qb->andWhere($orX); + } + + return $qb; } public function queryTimelineIndexer(string $context, array $args = []): array @@ -226,7 +359,6 @@ final class ActivityACLAwareRepository implements ActivityACLAwareRepositoryInte // acls: $reachableCenters = $this->authorizationHelper->getReachableCenters( - $this->tokenStorage->getToken()->getUser(), ActivityVoter::SEE ); @@ -251,7 +383,7 @@ final class ActivityACLAwareRepository implements ActivityACLAwareRepositoryInte continue; } // we get all the reachable scopes for this center - $reachableScopes = $this->authorizationHelper->getReachableScopes($this->tokenStorage->getToken()->getUser(), ActivityVoter::SEE, $center); + $reachableScopes = $this->authorizationHelper->getReachableScopes(ActivityVoter::SEE, $center); // we get the ids for those scopes $reachablesScopesId = array_map( static fn (Scope $scope) => $scope->getId(), diff --git a/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepositoryInterface.php b/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepositoryInterface.php index 8cdb83524..a046ad218 100644 --- a/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepositoryInterface.php +++ b/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepositoryInterface.php @@ -11,15 +11,22 @@ declare(strict_types=1); namespace Chill\ActivityBundle\Repository; +use Chill\ActivityBundle\Entity\Activity; +use Chill\ActivityBundle\Entity\ActivityType; +use Chill\MainBundle\Entity\UserJob; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\Person; interface ActivityACLAwareRepositoryInterface { /** - * @return Activity[]|array + * Return all the activities associated to an accompanying period and that the user is allowed to apply the given role. + * + * + * @param array{my_activities?: bool, types?: array, jobs?: array, after?: \DateTimeImmutable|null, before?: \DateTimeImmutable|null} $filters + * @return array */ - public function findByAccompanyingPeriod(AccompanyingPeriod $period, string $role, ?int $start = 0, ?int $limit = 1000, ?array $orderBy = []): array; + public function findByAccompanyingPeriod(AccompanyingPeriod $period, string $role, ?int $start = 0, ?int $limit = 1000, array $orderBy = ['date' => 'DESC'], array $filters = []): array; /** * Return a list of activities, simplified as array (not object). @@ -31,7 +38,28 @@ interface ActivityACLAwareRepositoryInterface public function findByAccompanyingPeriodSimplified(AccompanyingPeriod $period, ?int $limit = 1000): array; /** - * @return Activity[]|array + * @param array{my_activities?: bool, types?: array, jobs?: array, after?: \DateTimeImmutable|null, before?: \DateTimeImmutable|null} $filters + * @return array */ - public function findByPerson(Person $person, string $role, ?int $start = 0, ?int $limit = 1000, ?array $orderBy = []): array; + public function findByPerson(Person $person, string $role, ?int $start = 0, ?int $limit = 1000, array $orderBy = ['date' => 'DESC'], array $filters = []): array; + + + /** + * Return a list of the type for the activities associated to person or accompanying period + * + * @return array + */ + public function findActivityTypeByAssociated(AccompanyingPeriod|Person $associated): array; + + /** + * Return a list of the user job for the activities associated to person or accompanying period + * + * Associated mean the job: + * - of the creator; + * - of the user (activity.user) + * - of all the users + * + * @return array + */ + public function findUserJobByAssociated(AccompanyingPeriod|Person $associated): array; } diff --git a/src/Bundle/ChillActivityBundle/Repository/ActivityTypeRepository.php b/src/Bundle/ChillActivityBundle/Repository/ActivityTypeRepository.php index fd5d52fce..10bd1e651 100644 --- a/src/Bundle/ChillActivityBundle/Repository/ActivityTypeRepository.php +++ b/src/Bundle/ChillActivityBundle/Repository/ActivityTypeRepository.php @@ -11,9 +11,13 @@ declare(strict_types=1); namespace Chill\ActivityBundle\Repository; +use Chill\ActivityBundle\Entity\Activity; use Chill\ActivityBundle\Entity\ActivityType; +use Chill\PersonBundle\Entity\AccompanyingPeriod; +use Chill\PersonBundle\Entity\Person; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; +use Doctrine\ORM\Query\Expr\Join; final class ActivityTypeRepository implements ActivityTypeRepositoryInterface { diff --git a/src/Bundle/ChillActivityBundle/Repository/ActivityTypeRepositoryInterface.php b/src/Bundle/ChillActivityBundle/Repository/ActivityTypeRepositoryInterface.php index 2148a02f5..574faea22 100644 --- a/src/Bundle/ChillActivityBundle/Repository/ActivityTypeRepositoryInterface.php +++ b/src/Bundle/ChillActivityBundle/Repository/ActivityTypeRepositoryInterface.php @@ -12,12 +12,14 @@ declare(strict_types=1); namespace Chill\ActivityBundle\Repository; use Chill\ActivityBundle\Entity\ActivityType; +use Chill\PersonBundle\Entity\AccompanyingPeriod; +use Chill\PersonBundle\Entity\Person; use Doctrine\Persistence\ObjectRepository; interface ActivityTypeRepositoryInterface extends ObjectRepository { /** - * @return array|ActivityType[] + * @return array */ public function findAllActive(): array; } diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/list.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/list.html.twig index 79c946f17..17ae0598b 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/list.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/list.html.twig @@ -86,6 +86,9 @@

    {% else %} + + {{ filter|chill_render_filter_order_helper }} +
    {% for activity in activities %} {% include 'ChillActivityBundle:Activity:_list_item.html.twig' with { diff --git a/src/Bundle/ChillActivityBundle/Tests/Repository/ActivityACLAwareRepositoryTest.php b/src/Bundle/ChillActivityBundle/Tests/Repository/ActivityACLAwareRepositoryTest.php new file mode 100644 index 000000000..e7b2117d4 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Tests/Repository/ActivityACLAwareRepositoryTest.php @@ -0,0 +1,325 @@ +authorizationHelperForCurrentUser = self::$container->get(AuthorizationHelperForCurrentUserInterface::class); + $this->centerResolverManager = self::$container->get(CenterResolverManagerInterface::class); + $this->activityRepository = self::$container->get(ActivityRepository::class); + $this->entityManager = self::$container->get(EntityManagerInterface::class); + $this->security = self::$container->get(Security::class); + + $this->requestStack = $requestStack = new RequestStack(); + $request = $this->prophesize(Request::class); + $request->getLocale()->willReturn('fr'); + $request->getDefaultLocale()->willReturn('fr'); + $requestStack->push($request->reveal()); + } + + /** + * @dataProvider provideDataFindByAccompanyingPeriod + */ + public function testFindByAccompanyingPeriod(AccompanyingPeriod $period, User $user, string $role, ?int $start = 0, ?int $limit = 1000, array $orderBy = ['date' => 'DESC'], array $filters = []): void + { + $security = $this->prophesize(Security::class); + $security->isGranted($role, $period)->willReturn(true); + $security->getUser()->willReturn($user); + + $repository = new ActivityACLAwareRepository( + $this->authorizationHelperForCurrentUser, + $this->centerResolverManager, + $this->activityRepository, + $this->entityManager, + $security->reveal(), + $this->requestStack + ); + + $actual = $repository->findByAccompanyingPeriod($period, $role, $start, $limit, $orderBy, $filters); + + self::assertIsArray($actual); + } + + /** + * @dataProvider provideDataFindByAccompanyingPeriod + */ + public function testFindActivityTypeByAccompanyingPeriod(AccompanyingPeriod $period, User $user, string $role, ?int $start = 0, ?int $limit = 1000, array $orderBy = ['date' => 'DESC'], array $filters = []): void + { + $security = $this->prophesize(Security::class); + $security->isGranted($role, $period)->willReturn(true); + $security->getUser()->willReturn($user); + + $repository = new ActivityACLAwareRepository( + $this->authorizationHelperForCurrentUser, + $this->centerResolverManager, + $this->activityRepository, + $this->entityManager, + $security->reveal(), + $this->requestStack + ); + + $actual = $repository->findActivityTypeByAssociated($period); + + self::assertIsArray($actual); + } + + /** + * @dataProvider provideDataFindByPerson + */ + public function testFindActivityTypeByPerson(Person $person, User $user, array $centers, array $scopes, string $role, ?int $start = 0, ?int $limit = 1000, ?array $orderBy = [], array $filters = []): void + { + $role = ActivityVoter::SEE; + $centerResolver = $this->prophesize(CenterResolverManagerInterface::class); + $centerResolver->resolveCenters($person)->willReturn($centers); + + $authorizationHelper = $this->prophesize(AuthorizationHelperForCurrentUserInterface::class); + $authorizationHelper->getReachableScopes($role, Argument::type(Center::class)) + ->willReturn($scopes); + + $security = $this->prophesize(Security::class); + $security->isGranted($role, Argument::type(AccompanyingPeriod::class))->willReturn(true); + $security->getUser()->willReturn($user); + + $repository = new ActivityACLAwareRepository( + $authorizationHelper->reveal(), + $centerResolver->reveal(), + $this->activityRepository, + $this->entityManager, + $security->reveal(), + $this->requestStack + ); + + $actual = $repository->findByPerson($person, $role, $start, $limit, $orderBy, $filters); + + self::assertIsArray($actual); + } + + /** + * @dataProvider provideDataFindByPerson + */ + public function testFindByPerson(Person $person, User $user, array $centers, array $scopes, string $role, ?int $start = 0, ?int $limit = 1000, ?array $orderBy = [], array $filters = []): void + { + $centerResolver = $this->prophesize(CenterResolverManagerInterface::class); + $centerResolver->resolveCenters($person)->willReturn($centers); + + $authorizationHelper = $this->prophesize(AuthorizationHelperForCurrentUserInterface::class); + $authorizationHelper->getReachableScopes($role, Argument::type(Center::class)) + ->willReturn($scopes); + + $security = $this->prophesize(Security::class); + $security->isGranted($role, Argument::type(AccompanyingPeriod::class))->willReturn(true); + $security->getUser()->willReturn($user); + + $repository = new ActivityACLAwareRepository( + $authorizationHelper->reveal(), + $centerResolver->reveal(), + $this->activityRepository, + $this->entityManager, + $security->reveal(), + $this->requestStack + ); + + $actual = $repository->findByPerson($person, $role, $start, $limit, $orderBy, $filters); + + self::assertIsArray($actual); + } + + public function provideDataFindByPerson(): iterable + { + $this->setUp(); + + /** @var Person $person */ + if (null === $person = $this->entityManager->createQueryBuilder() + ->select('p')->from(Person::class, 'p')->setMaxResults(1) + ->getQuery()->getSingleResult()) { + throw new \RuntimeException("person not found"); + } + + /** @var AccompanyingPeriod $period1 */ + if (null === $period1 = $this->entityManager + ->createQueryBuilder() + ->select('a') + ->from(AccompanyingPeriod::class, 'a') + ->setMaxResults(1) + ->getQuery() + ->getSingleResult()) { + throw new \RuntimeException("no period found"); + } + + /** @var AccompanyingPeriod $period2 */ + if (null === $period2 = $this->entityManager + ->createQueryBuilder() + ->select('a') + ->from(AccompanyingPeriod::class, 'a') + ->where('a.id > :pid') + ->setParameter('pid', $period1->getId()) + ->setMaxResults(1) + ->getQuery() + ->getSingleResult()) { + throw new \RuntimeException("no second period found"); + } + // add a period + $period1->addPerson($person); + $period2->addPerson($person); + $period1->getParticipationsContainsPerson($person)->first()->setEndDate( + (new \DateTime('now'))->add(new \DateInterval('P1M')) + ); + + if ([] === $types = $this->entityManager + ->createQueryBuilder() + ->select('t') + ->from(ActivityType::class, 't') + ->setMaxResults(2) + ->getQuery() + ->getResult()) { + throw new \RuntimeException("no types"); + } + + if ([] === $jobs = $this->entityManager + ->createQueryBuilder() + ->select('j') + ->from(UserJob::class, 'j') + ->setMaxResults(2) + ->getQuery() + ->getResult() + ) { + throw new \RuntimeException("no jobs found"); + } + + if (null === $user = $this->entityManager + ->createQueryBuilder() + ->select('u') + ->from(User::class, 'u') + ->setMaxResults(1) + ->getQuery() + ->getSingleResult() + ) { + throw new \RuntimeException("no user found"); + } + + if ([] === $centers = $this->entityManager->createQueryBuilder() + ->select('c')->from(Center::class, 'c')->setMaxResults(2)->getQuery() + ->getResult()) { + throw new \RuntimeException("no centers found"); + } + + if ([] === $scopes = $this->entityManager->createQueryBuilder() + ->select('s')->from(Scope::class, 's')->setMaxResults(2)->getQuery() + ->getResult()) { + throw new \RuntimeException("no scopes found"); + } + + yield [$person, $user, $centers, $scopes, ActivityVoter::SEE, 0, 5, ['date' => 'DESC'], []]; + yield [$person, $user, $centers, $scopes, ActivityVoter::SEE, 0, 5, ['date' => 'DESC'], ['my_activities' => true]]; + yield [$person, $user, $centers, $scopes, ActivityVoter::SEE, 0, 5, ['date' => 'DESC'], ['types' => $types]]; + yield [$person, $user, $centers, $scopes, ActivityVoter::SEE, 0, 5, ['date' => 'DESC'], ['jobs' => $jobs]]; + yield [$person, $user, $centers, $scopes, ActivityVoter::SEE, 0, 5, ['date' => 'DESC'], ['after' => new \DateTimeImmutable('1 year ago')]]; + yield [$person, $user, $centers, $scopes, ActivityVoter::SEE, 0, 5, ['date' => 'DESC'], ['before' => new \DateTimeImmutable('1 year ago')]]; + yield [$person, $user, $centers, $scopes, ActivityVoter::SEE, 0, 5, ['date' => 'DESC'], ['after' => new \DateTimeImmutable('1 year ago'), 'before' => new \DateTimeImmutable('1 month ago')]]; + } + + public function provideDataFindByAccompanyingPeriod(): iterable + { + $this->setUp(); + + if (null === $period = $this->entityManager + ->createQueryBuilder() + ->select('a') + ->from(AccompanyingPeriod::class, 'a') + ->setMaxResults(1) + ->getQuery() + ->getSingleResult()) { + throw new \RuntimeException("no period found"); + } + + if ([] === $types = $this->entityManager + ->createQueryBuilder() + ->select('t') + ->from(ActivityType::class, 't') + ->setMaxResults(2) + ->getQuery() + ->getResult()) { + throw new \RuntimeException("no types"); + } + + if ([] === $jobs = $this->entityManager + ->createQueryBuilder() + ->select('j') + ->from(UserJob::class, 'j') + ->setMaxResults(2) + ->getQuery() + ->getResult() + ) { + throw new \RuntimeException("no jobs found"); + } + + if (null === $user = $this->entityManager + ->createQueryBuilder() + ->select('u') + ->from(User::class, 'u') + ->setMaxResults(1) + ->getQuery() + ->getSingleResult() + ) { + throw new \RuntimeException("no user found"); + } + + yield [$period, $user, ActivityVoter::SEE, 0, 10, ['date' => 'DESC'], []]; + yield [$period, $user, ActivityVoter::SEE, 0, 10, ['date' => 'DESC'], ['my_activities' => true]]; + yield [$period, $user, ActivityVoter::SEE, 0, 10, ['date' => 'DESC'], ['types' => $types]]; + yield [$period, $user, ActivityVoter::SEE, 0, 10, ['date' => 'DESC'], ['jobs' => $jobs]]; + yield [$period, $user, ActivityVoter::SEE, 0, 10, ['date' => 'DESC'], ['after' => new \DateTimeImmutable('1 year ago')]]; + yield [$period, $user, ActivityVoter::SEE, 0, 10, ['date' => 'DESC'], ['before' => new \DateTimeImmutable('1 year ago')]]; + yield [$period, $user, ActivityVoter::SEE, 0, 10, ['date' => 'DESC'], ['after' => new \DateTimeImmutable('1 year ago'), 'before' => new \DateTimeImmutable('1 month ago')]]; + } +} diff --git a/src/Bundle/ChillActivityBundle/translations/messages.fr.yml b/src/Bundle/ChillActivityBundle/translations/messages.fr.yml index 042fccc69..1229494bb 100644 --- a/src/Bundle/ChillActivityBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillActivityBundle/translations/messages.fr.yml @@ -83,12 +83,20 @@ Third persons: Tiers non-pro. Others persons: Usagers Third parties: Tiers professionnels Users concerned: T(M)S + activity: + date: Date de l'échange Insert a document: Insérer un document Remove a document: Supprimer le document comment: Commentaire No documents: Aucun document +# activity filter in list page +activity_filter: + My activities: Mes échanges (où j'interviens) + Types: Par type d'échange + Jobs: Par métier impliqué + #timeline '%user% has done an %activity_type%': '%user% a effectué un échange de type "%activity_type%"' From 0e5f1b4ab9c7d8e693332d42709841249e68a0eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 23 Jun 2023 12:44:54 +0200 Subject: [PATCH 226/724] Feature: [activity list] add pagination --- .../unreleased/Feature-20230623-124438.yaml | 5 +++ .../Controller/ActivityController.php | 18 +++++--- .../Repository/ActivityACLAwareRepository.php | 43 ++++++++++++++++++- .../ActivityACLAwareRepositoryInterface.php | 10 +++++ .../Resources/views/Activity/list.html.twig | 6 ++- 5 files changed, 74 insertions(+), 8 deletions(-) create mode 100644 .changes/unreleased/Feature-20230623-124438.yaml diff --git a/.changes/unreleased/Feature-20230623-124438.yaml b/.changes/unreleased/Feature-20230623-124438.yaml new file mode 100644 index 000000000..bc199d3bb --- /dev/null +++ b/.changes/unreleased/Feature-20230623-124438.yaml @@ -0,0 +1,5 @@ +kind: Feature +body: '[activity list] add pagination to the list of activities' +time: 2023-06-23T12:44:38.879098862+02:00 +custom: + Issue: "" diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php index 07e4fcf62..63639c149 100644 --- a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php +++ b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php @@ -22,6 +22,7 @@ use Chill\ActivityBundle\Repository\ActivityUserJobRepository; use Chill\ActivityBundle\Security\Authorization\ActivityVoter; use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable; use Chill\MainBundle\Entity\UserJob; +use Chill\MainBundle\Pagination\PaginatorFactory; use Chill\MainBundle\Repository\LocationRepository; use Chill\MainBundle\Repository\UserRepositoryInterface; use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface; @@ -70,6 +71,7 @@ final class ActivityController extends AbstractController private readonly TranslatorInterface $translator, private readonly FilterOrderHelperFactoryInterface $filterOrderHelperFactory, private readonly TranslatableStringHelperInterface $translatableStringHelper, + private readonly PaginatorFactory $paginatorFactory, ) { } @@ -251,7 +253,6 @@ final class ActivityController extends AbstractController { $view = null; $activities = []; - // TODO: add pagination [$person, $accompanyingPeriod] = $this->getEntity($request); $filter = $this->buildFilterOrder($person ?? $accompanyingPeriod); @@ -266,12 +267,14 @@ final class ActivityController extends AbstractController if ($person instanceof Person) { $this->denyAccessUnlessGranted(ActivityVoter::SEE, $person); + $count = $this->activityACLAwareRepository->countByPerson($person, ActivityVoter::SEE, $filterArgs); + $paginator = $this->paginatorFactory->create($count); $activities = $this->activityACLAwareRepository ->findByPerson( $person, ActivityVoter::SEE, - 0, - null, + $paginator->getCurrentPageFirstItemNumber(), + $paginator->getItemsPerPage(), ['date' => 'DESC', 'id' => 'DESC'], $filterArgs ); @@ -286,17 +289,21 @@ final class ActivityController extends AbstractController } elseif ($accompanyingPeriod instanceof AccompanyingPeriod) { $this->denyAccessUnlessGranted(ActivityVoter::SEE, $accompanyingPeriod); + $count = $this->activityACLAwareRepository->countByAccompanyingPeriod($accompanyingPeriod, ActivityVoter::SEE, $filterArgs); + $paginator = $this->paginatorFactory->create($count); $activities = $this->activityACLAwareRepository ->findByAccompanyingPeriod( $accompanyingPeriod, ActivityVoter::SEE, - 0, - null, + $paginator->getCurrentPageFirstItemNumber(), + $paginator->getItemsPerPage(), ['date' => 'DESC', 'id' => 'DESC'], $filterArgs ); $view = 'ChillActivityBundle:Activity:listAccompanyingCourse.html.twig'; + } else { + throw new \LogicException("Unsupported"); } return $this->render( @@ -306,6 +313,7 @@ final class ActivityController extends AbstractController 'person' => $person, 'accompanyingCourse' => $accompanyingPeriod, 'filter' => $filter, + 'paginator' => $paginator, ] ); } diff --git a/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php b/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php index 1fd0a57d6..1544dd764 100644 --- a/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php +++ b/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php @@ -27,6 +27,8 @@ use Chill\PersonBundle\Entity\Person; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\AbstractQuery; use Doctrine\ORM\EntityManagerInterface; +use Doctrine\ORM\NonUniqueResultException; +use Doctrine\ORM\NoResultException; use Doctrine\ORM\Query\Expr\Join; use Doctrine\ORM\Query\ResultSetMappingBuilder; use Doctrine\ORM\QueryBuilder; @@ -48,6 +50,33 @@ final readonly class ActivityACLAwareRepository implements ActivityACLAwareRepos ) { } + /** + * @throws NonUniqueResultException + * @throws NoResultException + */ + public function countByAccompanyingPeriod(AccompanyingPeriod $period, string $role, array $filters = []): int + { + $qb = $this->buildBaseQuery($filters); + + $qb + ->select('COUNT(a)') + ->andWhere('a.accompanyingPeriod = :period')->setParameter('period', $period); + + return $qb->getQuery()->getSingleScalarResult(); + } + + public function countByPerson(Person $person, string $role, array $filters = []): int + { + $qb = $this->buildBaseQuery($filters); + + $qb = $this->filterBaseQueryByPerson($qb, $person, $role); + + $qb->select('COUNT(a)'); + + return $qb->getQuery()->getSingleScalarResult(); + } + + public function findByAccompanyingPeriod(AccompanyingPeriod $period, string $role, ?int $start = 0, ?int $limit = 1000, array $orderBy = ['date' => 'DESC'], array $filters = []): array { $qb = $this->buildBaseQuery($filters); @@ -58,7 +87,12 @@ final readonly class ActivityACLAwareRepository implements ActivityACLAwareRepos $qb->addOrderBy('a.' . $field, $order); } - $qb->setFirstResult(0)->setMaxResults(1000); + if (null !== $start) { + $qb->setFirstResult($start); + } + if (null !== $limit) { + $qb->setMaxResults($limit); + } return $qb->getQuery()->getResult(); } @@ -261,6 +295,13 @@ final readonly class ActivityACLAwareRepository implements ActivityACLAwareRepos $qb->addOrderBy('a.' . $field, $direction); } + if (null !== $start) { + $qb->setFirstResult($start); + } + if (null !== $limit) { + $qb->setMaxResults($limit); + } + return $qb->getQuery()->getResult(); } diff --git a/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepositoryInterface.php b/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepositoryInterface.php index a046ad218..474d8ad16 100644 --- a/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepositoryInterface.php +++ b/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepositoryInterface.php @@ -28,6 +28,16 @@ interface ActivityACLAwareRepositoryInterface */ public function findByAccompanyingPeriod(AccompanyingPeriod $period, string $role, ?int $start = 0, ?int $limit = 1000, array $orderBy = ['date' => 'DESC'], array $filters = []): array; + /** + * @param array{my_activities?: bool, types?: array, jobs?: array, after?: \DateTimeImmutable|null, before?: \DateTimeImmutable|null} $filters + */ + public function countByAccompanyingPeriod(AccompanyingPeriod $period, string $role, array $filters = []): int; + + /** + * @param array{my_activities?: bool, types?: array, jobs?: array, after?: \DateTimeImmutable|null, before?: \DateTimeImmutable|null} $filters + */ + public function countByPerson(Person $person, string $role, array $filters = []): int; + /** * Return a list of activities, simplified as array (not object). * diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/list.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/list.html.twig index 17ae0598b..dd78c9396 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/list.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/list.html.twig @@ -80,6 +80,8 @@
    + {{ filter|chill_render_filter_order_helper }} + {% if activities|length == 0 %}

    {{ "There isn't any activities."|trans }} @@ -87,8 +89,6 @@ {% else %} - {{ filter|chill_render_filter_order_helper }} -

    {% for activity in activities %} {% include 'ChillActivityBundle:Activity:_list_item.html.twig' with { @@ -99,4 +99,6 @@
    {% endif %} + {{ chill_pagination(paginator) }} +
    From 9978b6a6e410028907579e41856145bbe95ba733 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 23 Jun 2023 13:04:13 +0200 Subject: [PATCH 227/724] Fix: fix the loading of pickCenterType when no regroupments exists and defaults of SocialWorkTypeFilter --- .../DataMapper/ExportPickCenterDataMapper.php | 29 +++++-------------- .../Form/Type/Export/PickCenterType.php | 2 +- .../SocialWorkTypeFilter.php | 2 +- 3 files changed, 9 insertions(+), 24 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Form/DataMapper/ExportPickCenterDataMapper.php b/src/Bundle/ChillMainBundle/Form/DataMapper/ExportPickCenterDataMapper.php index c88f1dfe3..d4dc4719d 100644 --- a/src/Bundle/ChillMainBundle/Form/DataMapper/ExportPickCenterDataMapper.php +++ b/src/Bundle/ChillMainBundle/Form/DataMapper/ExportPickCenterDataMapper.php @@ -20,38 +20,23 @@ use Symfony\Component\Form\FormInterface; use function array_key_exists; use function count; -class ExportPickCenterDataMapper implements DataMapperInterface +final readonly class ExportPickCenterDataMapper implements DataMapperInterface { - public function __construct( - private RegroupmentRepository $regroupmentRepository, - ) { - } - - public function mapDataToForms($data, $forms): void + public function mapDataToForms($viewData, $forms): void { - if (null === $data) { + if (null === $viewData) { return; } /** @var array $form */ $form = iterator_to_array($forms); - $pickedRegroupment = []; + $form['center']->setData($viewData); - foreach ($this->regroupmentRepository->findAll() as $regroupment) { - /** @phpstan-ignore-next-line */ - [$contained, $notContained] = $regroupment->getCenters()->partition(static fn (int $id, Center $center): bool => false); - - if (0 === count($notContained)) { - $pickedRegroupment[] = $regroupment; - } - } - - $form['regroupment']->setData([]); - $form['center']->setData($data); + // NOTE: we do not map back the regroupments } - public function mapFormsToData($forms, &$data): void + public function mapFormsToData($forms, &$viewData): void { /** @var array $forms */ $forms = iterator_to_array($forms); @@ -71,6 +56,6 @@ class ExportPickCenterDataMapper implements DataMapperInterface } } - $data = array_values($centers); + $viewData = array_values($centers); } } diff --git a/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php b/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php index b2d903909..d33ab2ade 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php @@ -77,7 +77,7 @@ final class PickCenterType extends AbstractType ]); } - $builder->setDataMapper(new ExportPickCenterDataMapper($this->regroupmentRepository)); + $builder->setDataMapper(new ExportPickCenterDataMapper()); } public function configureOptions(OptionsResolver $resolver) diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/SocialWorkTypeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/SocialWorkTypeFilter.php index 9a687b1e6..e97834319 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/SocialWorkTypeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/SocialWorkTypeFilter.php @@ -113,7 +113,7 @@ class SocialWorkTypeFilter implements FilterInterface public function getFormDefaultData(): array { - return ['action_type' => '', 'goal' => '', 'result' => '']; + return ['action_type' => [], 'goal' => [], 'result' => []]; } public function describeAction($data, $format = 'string'): array From 0e9597bf777ec47b12e524e5b9d4093e5a563a0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sun, 25 Jun 2023 15:47:30 +0200 Subject: [PATCH 228/724] fix handling of DirectExportInterface --- .../Export/ExportFormHelper.php | 24 +++++++++++-------- .../ChillMainBundle/Export/ExportManager.php | 10 +++++--- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Export/ExportFormHelper.php b/src/Bundle/ChillMainBundle/Export/ExportFormHelper.php index c2127fb36..5271fb223 100644 --- a/src/Bundle/ChillMainBundle/Export/ExportFormHelper.php +++ b/src/Bundle/ChillMainBundle/Export/ExportFormHelper.php @@ -72,17 +72,21 @@ final readonly class ExportFormHelper ]; } - $allowedFormatters = $this->exportManager - ->getFormattersByTypes($export->getAllowedFormattersTypes()); - $choices = []; - foreach (array_keys(iterator_to_array($allowedFormatters)) as $alias) { - $choices[] = $alias; - } + if ($export instanceof ExportInterface) { + $allowedFormatters = $this->exportManager + ->getFormattersByTypes($export->getAllowedFormattersTypes()); + $choices = []; + foreach (array_keys(iterator_to_array($allowedFormatters)) as $alias) { + $choices[] = $alias; + } - $data[ExportType::PICK_FORMATTER_KEY]['alias'] = match (count($choices)) { - 1 => $choices[0], - default => null, - }; + $data[ExportType::PICK_FORMATTER_KEY]['alias'] = match (count($choices)) { + 1 => $choices[0], + default => null, + }; + } else { + unset($data[ExportType::PICK_FORMATTER_KEY]); + } return $data; } diff --git a/src/Bundle/ChillMainBundle/Export/ExportManager.php b/src/Bundle/ChillMainBundle/Export/ExportManager.php index 7ad880642..3f9c839a5 100644 --- a/src/Bundle/ChillMainBundle/Export/ExportManager.php +++ b/src/Bundle/ChillMainBundle/Export/ExportManager.php @@ -113,8 +113,12 @@ class ExportManager * * @return FilterInterface[] a \Generator that contains filters. The key is the filter's alias */ - public function &getFiltersApplyingOn(ExportInterface $export, ?array $centers = null) + public function &getFiltersApplyingOn(ExportInterface|DirectExportInterface $export, ?array $centers = null): iterable { + if ($export instanceof DirectExportInterface) { + return; + } + foreach ($this->filters as $alias => $filter) { if ( in_array($filter->applyOn(), $export->supportsModifiers(), true) @@ -132,9 +136,9 @@ class ExportManager * * @return null|iterable a \Generator that contains aggretagors. The key is the filter's alias */ - public function &getAggregatorsApplyingOn(ExportInterface $export, ?array $centers = null): ?iterable + public function &getAggregatorsApplyingOn(ExportInterface|DirectExportInterface $export, ?array $centers = null): ?iterable { - if ($export instanceof ListInterface) { + if ($export instanceof ListInterface || $export instanceof DirectExportInterface) { return; } From cd7a80b680fb5f6e95a88d4666c8c12ee12afdd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 26 Jun 2023 11:05:20 +0000 Subject: [PATCH 229/724] Do a release automatically using ci/cd when tag is created --- .gitlab-ci.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3f1d75ed5..aa1eff8b1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -34,6 +34,7 @@ variables: stages: - Composer install - Tests + - Deploy build: stage: Composer install @@ -121,3 +122,14 @@ unit_tests: paths: - bin - tests/app/vendor/ + +release: + stage: Deploy + image: registry.gitlab.com/gitlab-org/release-cli:latest + rules: + - if: $CI_COMMIT_TAG + script: + - echo "running release_job" + release: + tag_name: '$CI_COMMIT_TAG' + description: "./.changes/v$CI_COMMIT_TAG.md" From c0ae2f8ed9aceb6c6c4d4d6a2823604667145357 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 26 Jun 2023 14:27:07 +0200 Subject: [PATCH 230/724] publish on version 2.2.2 --- .changes/unreleased/Fixed-20230621-132851.yaml | 6 ------ .changes/unreleased/Fixed-20230621-135912.yaml | 5 ----- .changes/unreleased/Fixed-20230621-141828.yaml | 5 ----- .changes/v2.2.2.md | 5 +++++ CHANGELOG.md | 6 ++++++ 5 files changed, 11 insertions(+), 16 deletions(-) delete mode 100644 .changes/unreleased/Fixed-20230621-132851.yaml delete mode 100644 .changes/unreleased/Fixed-20230621-135912.yaml delete mode 100644 .changes/unreleased/Fixed-20230621-141828.yaml create mode 100644 .changes/v2.2.2.md diff --git a/.changes/unreleased/Fixed-20230621-132851.yaml b/.changes/unreleased/Fixed-20230621-132851.yaml deleted file mode 100644 index 89fb7cdd9..000000000 --- a/.changes/unreleased/Fixed-20230621-132851.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: Fixed -body: '[Accompanying period comments]: order comments from the most recent to the - oldest, in the list' -time: 2023-06-21T13:28:51.282714011+02:00 -custom: - Issue: "" diff --git a/.changes/unreleased/Fixed-20230621-135912.yaml b/.changes/unreleased/Fixed-20230621-135912.yaml deleted file mode 100644 index 676d1c21b..000000000 --- a/.changes/unreleased/Fixed-20230621-135912.yaml +++ /dev/null @@ -1,5 +0,0 @@ -kind: Fixed -body: 'Api: filter social action to keep only the currently activated' -time: 2023-06-21T13:59:12.57760217+02:00 -custom: - Issue: "" diff --git a/.changes/unreleased/Fixed-20230621-141828.yaml b/.changes/unreleased/Fixed-20230621-141828.yaml deleted file mode 100644 index 2c7f94488..000000000 --- a/.changes/unreleased/Fixed-20230621-141828.yaml +++ /dev/null @@ -1,5 +0,0 @@ -kind: Fixed -body: Fix deletion and re-creation of filiation relationship -time: 2023-06-21T14:18:28.437876316+02:00 -custom: - Issue: "82" diff --git a/.changes/v2.2.2.md b/.changes/v2.2.2.md new file mode 100644 index 000000000..61d194b6d --- /dev/null +++ b/.changes/v2.2.2.md @@ -0,0 +1,5 @@ +## v2.2.2 - 2023-06-26 +### Fixed +* [Accompanying period comments]: order comments from the most recent to the oldest, in the list +* Api: filter social action to keep only the currently activated +* ([#82](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/82)) Fix deletion and re-creation of filiation relationship diff --git a/CHANGELOG.md b/CHANGELOG.md index e223fa116..ab33c7fc4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html), and is generated by [Changie](https://github.com/miniscruff/changie). +## v2.2.2 - 2023-06-26 +### Fixed +* [Accompanying period comments]: order comments from the most recent to the oldest, in the list +* Api: filter social action to keep only the currently activated +* ([#82](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/82)) Fix deletion and re-creation of filiation relationship + ## v2.2.1 - 2023-06-19 ### Fixed * ([#114](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/114)) [notification on document evaluation] fix entityId and return path when adding a notification on a document in an evaluation From f19b939bd429dde6f7f502cee896324f71f97ae9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 27 Jun 2023 11:04:22 +0200 Subject: [PATCH 231/724] Fixed: rights on the action list in accompanying period main's page Add is_granted check on the action: - if update action is allowed, open in update mode; - if see action is allowed, open in see mode; - fallback to an inactive link (should not happens) --- .../unreleased/Fixed-20230627-110233.yaml | 6 +++++ ...st_recent_by_accompanying_period.html.twig | 26 ++++++++++--------- 2 files changed, 20 insertions(+), 12 deletions(-) create mode 100644 .changes/unreleased/Fixed-20230627-110233.yaml diff --git a/.changes/unreleased/Fixed-20230627-110233.yaml b/.changes/unreleased/Fixed-20230627-110233.yaml new file mode 100644 index 000000000..58bb23933 --- /dev/null +++ b/.changes/unreleased/Fixed-20230627-110233.yaml @@ -0,0 +1,6 @@ +kind: Fixed +body: On the accompanying course page, open the action on view mode if the user does + not have right to update them (i.e. if the accompanying period is closed) +time: 2023-06-27T11:02:33.027807027+02:00 +custom: + Issue: "116" diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/list_recent_by_accompanying_period.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/list_recent_by_accompanying_period.html.twig index 92b2e3920..897f19b46 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/list_recent_by_accompanying_period.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/list_recent_by_accompanying_period.html.twig @@ -1,9 +1,11 @@ - From a93051d157cb4b0f59ee550bd7ff86b8c1b5eac2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 27 Jun 2023 11:13:07 +0200 Subject: [PATCH 232/724] [export] set the default date for accompanying period list --- .changes/unreleased/Feature-20230627-111222.yaml | 6 ++++++ .../Export/Export/ListAccompanyingPeriod.php | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 .changes/unreleased/Feature-20230627-111222.yaml diff --git a/.changes/unreleased/Feature-20230627-111222.yaml b/.changes/unreleased/Feature-20230627-111222.yaml new file mode 100644 index 000000000..1946b9332 --- /dev/null +++ b/.changes/unreleased/Feature-20230627-111222.yaml @@ -0,0 +1,6 @@ +kind: Feature +body: '[export] Set the default date of calculation of the accompanying period''s + list as "today"' +time: 2023-06-27T11:12:22.296330037+02:00 +custom: + Issue: "" diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php index e5e724b6c..294b9ce9a 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php @@ -20,6 +20,7 @@ use Chill\MainBundle\Export\Helper\ExportAddressHelper; use Chill\MainBundle\Export\Helper\UserHelper; use Chill\MainBundle\Export\ListInterface; use Chill\MainBundle\Form\Type\PickRollingDateType; +use Chill\MainBundle\Service\RollingDate\RollingDate; use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface; use Chill\MainBundle\Templating\TranslatableStringHelperInterface; use Chill\PersonBundle\Entity\AccompanyingPeriod; @@ -146,7 +147,9 @@ class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface } public function getFormDefaultData(): array { - return []; + return [ + 'calc_date' => new RollingDate(RollingDate::T_TODAY) + ]; } public function getAllowedFormattersTypes() From 90be68002a4765520faae3e15f2caff62727c66c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 27 Jun 2023 15:30:16 +0200 Subject: [PATCH 233/724] add possibility to add long text in changelog --- .changie.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.changie.yaml b/.changie.yaml index ba5454ce7..8a25ed695 100644 --- a/.changie.yaml +++ b/.changie.yaml @@ -5,8 +5,11 @@ changelogPath: CHANGELOG.md versionExt: md versionFormat: '## {{.Version}} - {{.Time.Format "2006-01-02"}}' kindFormat: '### {{.Kind}}' +# Note: it is possible to add a `.custom.Long` text manually into the yaml file produced by `changie new`. This will add a long description. changeFormat: >- - * {{ if not (eq .Custom.Issue "") }}([#{{ .Custom.Issue }}](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/{{ .Custom.Issue }})) {{ end }}{{.Body}} + * {{ if not (eq .Custom.Issue "") }}([#{{ .Custom.Issue }}](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/{{ .Custom.Issue }})) {{ end }}{{.Body}} {{ if not (eq .Custom.Long "") }} + + {{ .Custom.Long }}{{ end }} custom: - key: Issue label: Issue number (on chill-bundles repository) (optional) From a7c3089736020e20192e71d34189ca638c5972e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 27 Jun 2023 15:30:44 +0200 Subject: [PATCH 234/724] Feature: avoid duplicates for the same period in acc period user history --- .../unreleased/Feature-20230627-151615.yaml | 28 +++++++++++++++ .../migrations/Version20230627130331.php | 36 +++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 .changes/unreleased/Feature-20230627-151615.yaml create mode 100644 src/Bundle/ChillPersonBundle/migrations/Version20230627130331.php diff --git a/.changes/unreleased/Feature-20230627-151615.yaml b/.changes/unreleased/Feature-20230627-151615.yaml new file mode 100644 index 000000000..499e874dc --- /dev/null +++ b/.changes/unreleased/Feature-20230627-151615.yaml @@ -0,0 +1,28 @@ +kind: Feature +body: "Force accompanying period user history to be unique for the same period and + stardate/enddate [:warning: may encounter migration issue]" +time: 2023-06-27T15:16:15.775571488+02:00 +custom: + Issue: "" + Long: "If some issue is encountered during migration, use this SQL to find the line which are in conflict, examine the problem and delete some of the concerning line + + ```sql + + -- to see the line which are in conflict with another one + + SELECT o.* + + FROM chill_person_accompanying_period_user_history o + + JOIN chill_person_accompanying_period_user_history c ON o.id < c.id AND o.accompanyingperiod_id = c.accompanyingperiod_id + + WHERE tsrange(o.startdate, o.enddate, '[)') && tsrange(c.startdate, c.enddate, '[)') + + ORDER BY accompanyingperiod_id; + + -- to examine line in conflict for a given accompanyingperiod_id (given by the previous query) + + SELECT * FROM chill_person_accompanying_period_user_history WHERE accompanyingperiod_id = IIIIDDDD order by startdate, enddate; + + ``` + " diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20230627130331.php b/src/Bundle/ChillPersonBundle/migrations/Version20230627130331.php new file mode 100644 index 000000000..63f160997 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/migrations/Version20230627130331.php @@ -0,0 +1,36 @@ +addSql('ALTER TABLE chill_person_accompanying_period_user_history + ADD CONSTRAINT acc_period_user_history_not_overlaps + EXCLUDE USING GIST (accompanyingperiod_id with =, tsrange(startdate, enddate) with &&) + DEFERRABLE INITIALLY DEFERRED'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_person_accompanying_period_user_history DROP CONSTRAINT acc_period_user_history_not_overlaps'); + } +} From 687ff63ce7218da27b1b11fa033c1d9398ffeabc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 27 Jun 2023 16:00:05 +0200 Subject: [PATCH 235/724] Rename label of filter in French: "parcours actif" => "parcours ouvert", and "filtrer les parcours ouverts" => "Filtrer les parcours dont la date d''ouverture" --- .changes/unreleased/Feature-20230627-155925.yaml | 6 ++++++ .../ChillPersonBundle/translations/messages.fr.yml | 14 +++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) create mode 100644 .changes/unreleased/Feature-20230627-155925.yaml diff --git a/.changes/unreleased/Feature-20230627-155925.yaml b/.changes/unreleased/Feature-20230627-155925.yaml new file mode 100644 index 000000000..b134adab5 --- /dev/null +++ b/.changes/unreleased/Feature-20230627-155925.yaml @@ -0,0 +1,6 @@ +kind: Feature +body: 'Rename label of filter in French: "parcours actif" => "parcours ouvert", and + "filtrer les parcours ouverts" => "Filtrer les parcours dont la date d''ouverture"' +time: 2023-06-27T15:59:25.442854464+02:00 +custom: + Issue: "" diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index bdb93afc0..188c31f1a 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -555,22 +555,22 @@ is regular: le parcours est régulier Intensity: Intensité Group by intensity: Grouper les parcours par intensité -Filter by active on date: Filtrer les parcours actifs à une date -On date: Actifs à cette date -"Filtered by actives courses: active on %ondate%": "Filtrer les parcours actifs: actifs le %ondate%" +Filter by active on date: Filtrer les parcours ouverts à une date +On date: A l'état ouvert à cette date +"Filtered by actives courses: active on %ondate%": "Filtrer les parcours ouverts: actifs le %ondate%" -Filter by active at least one day between dates: Filtrer les parcours actifs au moins un jour dans la période -"Filtered by actives courses: at least one day between %datefrom% and %dateto%": "Filtrer les parcours actifs: au moins un jour entre le %datefrom% et le %dateto%" +Filter by active at least one day between dates: Filtrer les parcours ouverts au moins un jour dans la période +"Filtered by actives courses: at least one day between %datefrom% and %dateto%": "Filtrer les parcours ouverts: au moins un jour entre le %datefrom% et le %dateto%" Filter by referrers: Filtrer les parcours par référent Accepted referrers: Référents "Filtered by referrer: only %referrers%": "Filtré par référent: uniquement %referrers%" Group by referrers: Grouper les parcours par référent -Filter by opened between dates: Filtrer les parcours ouverts entre deux dates +Filter by opened between dates: Filtrer les parcours dont la date d'ouverture est comprise entre deux dates Date from: Date de début Date to: Date de fin -"Filtered by opening dates: between %datefrom% and %dateto%": "Filtrer les parcours ouverts entre deux dates: entre le %datefrom% et le %dateto%" +"Filtered by opening dates: between %datefrom% and %dateto%": "Filtrer les parcours dont la date d'ouverture est comprise entre le %datefrom% et le %dateto%" Filter by temporary location: Filtrer les parcours avec une localisation temporaire Filter by which has no referrer: Filtrer les parcours sans référent From 7a1feaa8cb2e09560953eb087e05e285be5c2405 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 27 Jun 2023 18:20:41 +0200 Subject: [PATCH 236/724] show documents from person in list of document from course --- .../PersonDocumentGenericDocProvider.php | 16 +++- .../PersonDocumentACLAwareRepository.php | 89 ++++++++++++++++--- ...sonDocumentACLAwareRepositoryInterface.php | 8 ++ .../Resources/views/List/list_item.html.twig | 9 +- .../PersonDocumentACLAwareRepositoryTest.php | 61 ++++++++++++- .../translations/messages.fr.yml | 2 + .../Entity/AccompanyingPeriod.php | 2 + .../translations/messages.fr.yml | 1 - 8 files changed, 171 insertions(+), 17 deletions(-) diff --git a/src/Bundle/ChillDocStoreBundle/GenericDoc/Providers/PersonDocumentGenericDocProvider.php b/src/Bundle/ChillDocStoreBundle/GenericDoc/Providers/PersonDocumentGenericDocProvider.php index 08a0df960..613f8d758 100644 --- a/src/Bundle/ChillDocStoreBundle/GenericDoc/Providers/PersonDocumentGenericDocProvider.php +++ b/src/Bundle/ChillDocStoreBundle/GenericDoc/Providers/PersonDocumentGenericDocProvider.php @@ -12,14 +12,16 @@ declare(strict_types=1); namespace Chill\DocStoreBundle\GenericDoc\Providers; use Chill\DocStoreBundle\GenericDoc\FetchQueryInterface; +use Chill\DocStoreBundle\GenericDoc\GenericDocForAccompanyingPeriodProviderInterface; use Chill\DocStoreBundle\GenericDoc\GenericDocForPersonProviderInterface; use Chill\DocStoreBundle\Repository\PersonDocumentACLAwareRepositoryInterface; use Chill\DocStoreBundle\Security\Authorization\PersonDocumentVoter; +use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\Person; use DateTimeImmutable; use Symfony\Component\Security\Core\Security; -final readonly class PersonDocumentGenericDocProvider implements GenericDocForPersonProviderInterface +final readonly class PersonDocumentGenericDocProvider implements GenericDocForPersonProviderInterface, GenericDocForAccompanyingPeriodProviderInterface { public const KEY = 'person_document'; @@ -48,4 +50,16 @@ final readonly class PersonDocumentGenericDocProvider implements GenericDocForPe { return $this->security->isGranted(PersonDocumentVoter::SEE, $person); } + + public function buildFetchQueryForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod, ?\DateTimeImmutable $startDate = null, ?\DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface + { + return $this->personDocumentACLAwareRepository->buildFetchQueryForAccompanyingPeriod($accompanyingPeriod, $startDate, $endDate, $content); + } + + public function isAllowedForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod): bool + { + // we assume that the user is allowed to see at least one person of the course + // this will be double checked when running the query + return true; + } } diff --git a/src/Bundle/ChillDocStoreBundle/Repository/PersonDocumentACLAwareRepository.php b/src/Bundle/ChillDocStoreBundle/Repository/PersonDocumentACLAwareRepository.php index 5d85541aa..26a42b894 100644 --- a/src/Bundle/ChillDocStoreBundle/Repository/PersonDocumentACLAwareRepository.php +++ b/src/Bundle/ChillDocStoreBundle/Repository/PersonDocumentACLAwareRepository.php @@ -22,6 +22,8 @@ use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface; use Chill\MainBundle\Security\Resolver\CenterResolverDispatcher; use Chill\MainBundle\Security\Resolver\CenterResolverDispatcherInterface; use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface; +use Chill\PersonBundle\Entity\AccompanyingPeriod; +use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation; use Chill\PersonBundle\Entity\Person; use DateTimeImmutable; use Doctrine\DBAL\Types\Types; @@ -29,19 +31,14 @@ use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Security\Core\Security; -class PersonDocumentACLAwareRepository implements PersonDocumentACLAwareRepositoryInterface +final readonly class PersonDocumentACLAwareRepository implements PersonDocumentACLAwareRepositoryInterface { - private AuthorizationHelperForCurrentUserInterface $authorizationHelperForCurrentUser; - - private CenterResolverManagerInterface $centerResolverManager; - - private EntityManagerInterface $em; - - public function __construct(EntityManagerInterface $em, CenterResolverManagerInterface $centerResolverManager, AuthorizationHelperForCurrentUserInterface $authorizationHelperForCurrentUser) - { - $this->em = $em; - $this->centerResolverManager = $centerResolverManager; - $this->authorizationHelperForCurrentUser = $authorizationHelperForCurrentUser; + public function __construct( + private EntityManagerInterface $em, + private CenterResolverManagerInterface $centerResolverManager, + private AuthorizationHelperForCurrentUserInterface $authorizationHelperForCurrentUser, + private Security $security, + ) { } public function buildQueryByPerson(Person $person): QueryBuilder @@ -63,6 +60,66 @@ class PersonDocumentACLAwareRepository implements PersonDocumentACLAwareReposito return $this->addFetchQueryByPersonACL($query, $person); } + public function buildFetchQueryForAccompanyingPeriod(AccompanyingPeriod $period, ?\DateTimeImmutable $startDate = null, ?\DateTimeImmutable $endDate = null, ?string $content = null): FetchQueryInterface + { + $personDocMetadata = $this->em->getClassMetadata(PersonDocument::class); + $participationMetadata = $this->em->getClassMetadata(AccompanyingPeriodParticipation::class); + + $query = new FetchQuery( + PersonDocumentGenericDocProvider::KEY, + sprintf('jsonb_build_object(\'id\', person_document.%s)', $personDocMetadata->getSingleIdentifierColumnName()), + sprintf('person_document.%s', $personDocMetadata->getColumnName('date')), + sprintf('%s AS person_document', $personDocMetadata->getSchemaName().'.'.$personDocMetadata->getTableName()) + ); + + $query->addJoinClause( + sprintf( + 'JOIN %s AS participation ON participation.%s = person_document.%s '. + 'AND person_document.%s BETWEEN participation.%s AND COALESCE(participation.%s, \'infinity\'::date)', + $participationMetadata->getTableName(), + $participationMetadata->getSingleAssociationJoinColumnName('person'), + $personDocMetadata->getSingleAssociationJoinColumnName('person'), + $personDocMetadata->getColumnName('date'), + $participationMetadata->getColumnName('startDate'), + $participationMetadata->getColumnName('endDate') + ) + ); + + $query->addWhereClause( + sprintf('participation.%s = ?', $participationMetadata->getSingleAssociationJoinColumnName('accompanyingPeriod')), + [$period->getId()], + [Types::INTEGER] + ); + + // can we see the document for this person ? + $orPersonId = []; + foreach ($period->getParticipations() as $participation) { + if (!$this->security->isGranted(PersonDocumentVoter::SEE, $participation->getPerson())) { + continue; + } + $orPersonId[] = $participation->getPerson()->getId(); + + } + + if ([] === $orPersonId) { + $query->addWhereClause('FALSE = TRUE'); + + return $query; + } + + $query->addWhereClause( + sprintf( + 'participation.%s IN (%s)', + $participationMetadata->getSingleAssociationJoinColumnName('person'), + implode(', ', array_fill(0, count($orPersonId), '?')) + ), + $orPersonId, + array_fill(0, count($orPersonId), Types::INTEGER) + ); + + return $this->addFilterClauses($query, $startDate, $endDate, $content); + } + public function buildBaseFetchQueryForPerson(Person $person, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null): FetchQuery { $personDocMetadata = $this->em->getClassMetadata(PersonDocument::class); @@ -80,6 +137,13 @@ class PersonDocumentACLAwareRepository implements PersonDocumentACLAwareReposito [Types::INTEGER] ); + return $this->addFilterClauses($query, $startDate, $endDate, $content); + } + + private function addFilterClauses(FetchQuery $query, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null): FetchQuery + { + $personDocMetadata = $this->em->getClassMetadata(PersonDocument::class); + if (null !== $startDate) { $query->addWhereClause( sprintf('? <= %s', $personDocMetadata->getColumnName('date')), @@ -107,7 +171,6 @@ class PersonDocumentACLAwareRepository implements PersonDocumentACLAwareReposito [Types::STRING, Types::STRING] ); } - return $query; } diff --git a/src/Bundle/ChillDocStoreBundle/Repository/PersonDocumentACLAwareRepositoryInterface.php b/src/Bundle/ChillDocStoreBundle/Repository/PersonDocumentACLAwareRepositoryInterface.php index 0b5e26792..f1bc70812 100644 --- a/src/Bundle/ChillDocStoreBundle/Repository/PersonDocumentACLAwareRepositoryInterface.php +++ b/src/Bundle/ChillDocStoreBundle/Repository/PersonDocumentACLAwareRepositoryInterface.php @@ -12,6 +12,7 @@ declare(strict_types=1); namespace Chill\DocStoreBundle\Repository; use Chill\DocStoreBundle\GenericDoc\FetchQueryInterface; +use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\Person; interface PersonDocumentACLAwareRepositoryInterface @@ -32,4 +33,11 @@ interface PersonDocumentACLAwareRepositoryInterface ?\DateTimeImmutable $endDate = null, ?string $content = null ): FetchQueryInterface; + + public function buildFetchQueryForAccompanyingPeriod( + AccompanyingPeriod $period, + ?\DateTimeImmutable $startDate = null, + ?\DateTimeImmutable $endDate = null, + ?string $content = null + ): FetchQueryInterface; } diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/List/list_item.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/List/list_item.html.twig index 9be38074d..58504b095 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/views/List/list_item.html.twig +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/List/list_item.html.twig @@ -17,7 +17,14 @@ {{ accompanyingCourse.id }}  
    - {% endif %} + {% elseif context == 'accompanying-period' and person is defined %} +
    + + {{ 'Document from person %name%'|trans({ '%name%': document.person|chill_entity_render_string }) }} +   +
    + + {% endif %}
    {{ document.title|chill_print_or_message("No title") }}
    diff --git a/src/Bundle/ChillDocStoreBundle/Tests/Repository/PersonDocumentACLAwareRepositoryTest.php b/src/Bundle/ChillDocStoreBundle/Tests/Repository/PersonDocumentACLAwareRepositoryTest.php index 98fca5622..fd611042c 100644 --- a/src/Bundle/ChillDocStoreBundle/Tests/Repository/PersonDocumentACLAwareRepositoryTest.php +++ b/src/Bundle/ChillDocStoreBundle/Tests/Repository/PersonDocumentACLAwareRepositoryTest.php @@ -21,12 +21,14 @@ use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface; use Chill\MainBundle\Security\Resolver\CenterResolverDispatcher; use Chill\MainBundle\Security\Resolver\CenterResolverDispatcherInterface; use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface; +use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\Person; use DateTimeImmutable; use Doctrine\ORM\EntityManagerInterface; use Prophecy\Argument; use Prophecy\PhpUnit\ProphecyTrait; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; +use Symfony\Component\Security\Core\Security; /** * @internal @@ -66,7 +68,8 @@ class PersonDocumentACLAwareRepositoryTest extends KernelTestCase $repository = new PersonDocumentACLAwareRepository( $this->entityManager, $centerManager->reveal(), - $authorizationHelper->reveal() + $authorizationHelper->reveal(), + $this->prophesize(Security::class)->reveal() ); $person = $this->entityManager->createQuery("SELECT p FROM " . Person::class . " p") @@ -86,6 +89,62 @@ class PersonDocumentACLAwareRepositoryTest extends KernelTestCase self::assertIsInt($nb, "test that the query could be executed"); } + /** + * @dataProvider provideDateForFetchQueryForAccompanyingPeriod + */ + public function testBuildFetchQueryForAccompanyingPeriod( + AccompanyingPeriod $period, + ?\DateTimeImmutable $startDate = null, + ?\DateTimeImmutable $endDate = null, + ?string $content = null + ): void { + $centerManager = $this->prophesize(CenterResolverManagerInterface::class); + $centerManager->resolveCenters(Argument::type(Person::class)) + ->willReturn([new Center()]); + + $scopes = $this->scopeRepository->findAll(); + $authorizationHelper = $this->prophesize(AuthorizationHelperForCurrentUserInterface::class); + $authorizationHelper->getReachableScopes(PersonDocumentVoter::SEE, Argument::any())->willReturn($scopes); + + $security = $this->prophesize(Security::class); + $security->isGranted(PersonDocumentVoter::SEE, Argument::type(Person::class))->willReturn(true); + + $repository = new PersonDocumentACLAwareRepository( + $this->entityManager, + $centerManager->reveal(), + $authorizationHelper->reveal(), + $security->reveal() + ); + + $query = $repository->buildFetchQueryForAccompanyingPeriod($period, $startDate, $endDate, $content); + ['sql' => $sql, 'params' => $params, 'types' => $types] = (new FetchQueryToSqlBuilder())->toSql($query); + + $nb = $this->entityManager->getConnection() + ->fetchOne("SELECT COUNT(*) FROM ({$sql}) AS sq", $params, $types); + + self::assertIsInt($nb, "test that the query could be executed"); + } + + public function provideDateForFetchQueryForAccompanyingPeriod(): iterable + { + $this->setUp(); + + if (null === $period = $this->entityManager->createQuery( + "SELECT p FROM " . AccompanyingPeriod::class . " p WHERE SIZE(p.participations) > 0" + ) + ->setMaxResults(1)->getSingleResult()) { + throw new \RuntimeException("no course found"); + } + + yield [$period, null, null, null]; + yield [$period, new DateTimeImmutable('1 year ago'), null, null]; + yield [$period, null, new DateTimeImmutable('1 year ago'), null]; + yield [$period, new DateTimeImmutable('2 years ago'), new DateTimeImmutable('1 year ago'), null]; + yield [$period, null, null, 'test']; + yield [$period, new DateTimeImmutable('2 years ago'), new DateTimeImmutable('1 year ago'), 'test']; + + } + public function provideDataBuildFetchQueryForPerson(): iterable { yield [null, null, null]; diff --git a/src/Bundle/ChillDocStoreBundle/translations/messages.fr.yml b/src/Bundle/ChillDocStoreBundle/translations/messages.fr.yml index 1dde57eee..d4531fa2b 100644 --- a/src/Bundle/ChillDocStoreBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillDocStoreBundle/translations/messages.fr.yml @@ -18,6 +18,7 @@ No document found: Aucun document trouvé The document is successfully registered: Le document est enregistré The document is successfully updated: Le document est mis à jour Any description: Aucune description +Document from person %name%: Document de l'usager %name% document: Any title: Aucun titre @@ -26,6 +27,7 @@ generic_doc: filter: keys: accompanying_course_document: Document du parcours + person_document: Documents de l'usager date-range: Date du document # delete diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php index a8e191df3..18ad2da7d 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php @@ -269,6 +269,7 @@ class AccompanyingPeriod implements * cascade={"persist", "refresh", "remove", "merge", "detach"}) * @Groups({"read", "docgen:read"}) * @ParticipationOverlap(groups={AccompanyingPeriod::STEP_DRAFT, AccompanyingPeriod::STEP_CONFIRMED}) + * @var Collection */ private Collection $participations; @@ -870,6 +871,7 @@ class AccompanyingPeriod implements /** * Get Participations Collection. + * @return Collection */ public function getParticipations(): Collection { diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 6205fabae..aeaa2bb3f 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -1236,4 +1236,3 @@ generic_doc: filter: keys: accompanying_period_work_evaluation_document: Document des actions d'accompagnement - person_document: Documents de la personne From 4632c18d930dcdd794ad849e9f98ccc243e44509 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 27 Jun 2023 18:26:41 +0200 Subject: [PATCH 237/724] restore feature: generate a document from period --- .../views/GenericDoc/accompanying_period_list.html.twig | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/GenericDoc/accompanying_period_list.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/GenericDoc/accompanying_period_list.html.twig index f76e4b984..b22c7d00f 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/views/GenericDoc/accompanying_period_list.html.twig +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/GenericDoc/accompanying_period_list.html.twig @@ -8,12 +8,14 @@ {% block js %} {{ parent() }} + {{ encore_entry_script_tags('mod_docgen_picktemplate') }} {{ encore_entry_script_tags('mod_entity_workflow_pick') }} {{ encore_entry_script_tags('mod_document_action_buttons_group') }} {% endblock %} {% block css %} {{ parent() }} + {{ encore_entry_script_tags('mod_docgen_picktemplate') }} {{ encore_entry_link_tags('mod_entity_workflow_pick') }} {{ encore_entry_link_tags('mod_document_action_buttons_group') }} {% endblock %} @@ -36,6 +38,8 @@ {{ chill_pagination(pagination) }} +
    + {% if is_granted('CHILL_ACCOMPANYING_COURSE_DOCUMENT_CREATE', accompanyingCourse) %}
    • From da50fbc1fb7bdea6b6b62bd9f79c5202c8982fe1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 27 Jun 2023 18:46:04 +0200 Subject: [PATCH 238/724] update for release v2.3.0 --- .../unreleased/Feature-20230606-105153.yaml | 6 --- .../unreleased/Feature-20230613-151546.yaml | 5 --- .../unreleased/Feature-20230627-111222.yaml | 6 --- .../unreleased/Feature-20230627-151615.yaml | 28 ------------ .../unreleased/Feature-20230627-155925.yaml | 6 --- .changes/v2.3.0.md | 42 ++++++++++++++++++ CHANGELOG.md | 43 +++++++++++++++++++ 7 files changed, 85 insertions(+), 51 deletions(-) delete mode 100644 .changes/unreleased/Feature-20230606-105153.yaml delete mode 100644 .changes/unreleased/Feature-20230613-151546.yaml delete mode 100644 .changes/unreleased/Feature-20230627-111222.yaml delete mode 100644 .changes/unreleased/Feature-20230627-151615.yaml delete mode 100644 .changes/unreleased/Feature-20230627-155925.yaml create mode 100644 .changes/v2.3.0.md diff --git a/.changes/unreleased/Feature-20230606-105153.yaml b/.changes/unreleased/Feature-20230606-105153.yaml deleted file mode 100644 index 00c3ab1da..000000000 --- a/.changes/unreleased/Feature-20230606-105153.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: Feature -body: 'Edit saved exports options: the saved exports options (forms, filters, aggregators) - are now editable.' -time: 2023-06-06T10:51:53.331701352+02:00 -custom: - Issue: "110" diff --git a/.changes/unreleased/Feature-20230613-151546.yaml b/.changes/unreleased/Feature-20230613-151546.yaml deleted file mode 100644 index e66076aa5..000000000 --- a/.changes/unreleased/Feature-20230613-151546.yaml +++ /dev/null @@ -1,5 +0,0 @@ -kind: Feature -body: Get an unified list of document in person and accompanying period context -time: 2023-06-13T15:15:46.146899906+02:00 -custom: - Issue: "103" diff --git a/.changes/unreleased/Feature-20230627-111222.yaml b/.changes/unreleased/Feature-20230627-111222.yaml deleted file mode 100644 index 1946b9332..000000000 --- a/.changes/unreleased/Feature-20230627-111222.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: Feature -body: '[export] Set the default date of calculation of the accompanying period''s - list as "today"' -time: 2023-06-27T11:12:22.296330037+02:00 -custom: - Issue: "" diff --git a/.changes/unreleased/Feature-20230627-151615.yaml b/.changes/unreleased/Feature-20230627-151615.yaml deleted file mode 100644 index 499e874dc..000000000 --- a/.changes/unreleased/Feature-20230627-151615.yaml +++ /dev/null @@ -1,28 +0,0 @@ -kind: Feature -body: "Force accompanying period user history to be unique for the same period and - stardate/enddate [:warning: may encounter migration issue]" -time: 2023-06-27T15:16:15.775571488+02:00 -custom: - Issue: "" - Long: "If some issue is encountered during migration, use this SQL to find the line which are in conflict, examine the problem and delete some of the concerning line - - ```sql - - -- to see the line which are in conflict with another one - - SELECT o.* - - FROM chill_person_accompanying_period_user_history o - - JOIN chill_person_accompanying_period_user_history c ON o.id < c.id AND o.accompanyingperiod_id = c.accompanyingperiod_id - - WHERE tsrange(o.startdate, o.enddate, '[)') && tsrange(c.startdate, c.enddate, '[)') - - ORDER BY accompanyingperiod_id; - - -- to examine line in conflict for a given accompanyingperiod_id (given by the previous query) - - SELECT * FROM chill_person_accompanying_period_user_history WHERE accompanyingperiod_id = IIIIDDDD order by startdate, enddate; - - ``` - " diff --git a/.changes/unreleased/Feature-20230627-155925.yaml b/.changes/unreleased/Feature-20230627-155925.yaml deleted file mode 100644 index b134adab5..000000000 --- a/.changes/unreleased/Feature-20230627-155925.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: Feature -body: 'Rename label of filter in French: "parcours actif" => "parcours ouvert", and - "filtrer les parcours ouverts" => "Filtrer les parcours dont la date d''ouverture"' -time: 2023-06-27T15:59:25.442854464+02:00 -custom: - Issue: "" diff --git a/.changes/v2.3.0.md b/.changes/v2.3.0.md new file mode 100644 index 000000000..827a338de --- /dev/null +++ b/.changes/v2.3.0.md @@ -0,0 +1,42 @@ +## v2.3.0 - 2023-06-27 +### Feature +* ([#110](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/110)) Edit saved exports options: the saved exports options (forms, filters, aggregators) are now editable. +* ([#103](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/103)) Get an unified list of document in person and accompanying period context +* [export] Set the default date of calculation of the accompanying period's list as "today" +* Force accompanying period user history to be unique for the same period and stardate/enddate [:warning: may encounter migration issue] + + If some issue is encountered during migration, use this SQL to find the line which are in conflict, examine the problem and delete some of the concerning line +* + ```sql + -- to see the line which are in conflict with another one + SELECT o.* + FROM chill_person_accompanying_period_user_history o + JOIN chill_person_accompanying_period_user_history c ON o.id < c.id AND o.accompanyingperiod_id = c.accompanyingperiod_id + WHERE tsrange(o.startdate, o.enddate, '[)') && tsrange(c.startdate, c.enddate, '[)') + ORDER BY accompanyingperiod_id; + -- to examine line in conflict for a given accompanyingperiod_id (given by the previous query) + SELECT * FROM chill_person_accompanying_period_user_history WHERE accompanyingperiod_id = IIIIDDDD order by startdate, enddate; + ``` +* Rename label of filter in French: "parcours actif" => "parcours ouvert", and "filtrer les parcours ouverts" => "Filtrer les parcours dont la date d'ouverture" + +### Traduction francophone des principaux changements + +* Les exports enregistrés sont éditables par l'utilisateur; +* L'onglet "Document" dans les parcours et les dossiers d'usager affiche désormais les documents ajoutés à différents endroits. + + Pour les parcours, il s'agit de: + + - documents ajoutés directement dans le parcours; + - documents des échanges; + - documents des rendez-vous; + - documents des évaluations; + - documents directement ajoutés dans le dossier des usagers concernés par le parcours; + + Pour les usagers, il s'agit de: + + - documents des échanges; + - documents des parcours; + - documents des rendez-vous; + - documents des actions, des échanges, des rendez-vous, des évaluations ajoutés dans les parcours. +* Dans la liste des parcours, la date de calcul des éléments associés est "aujourd'hui" par défaut. +* Dans les exports, renommage des libellés des filtres: "parcours actif" => "parcours ouvert", et "filtrer les parcours ouverts" => "Filtrer les parcours dont la date d'ouverture" diff --git a/CHANGELOG.md b/CHANGELOG.md index ab33c7fc4..93ff93556 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,49 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html), and is generated by [Changie](https://github.com/miniscruff/changie). +## v2.3.0 - 2023-06-27 +### Feature +* ([#110](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/110)) Edit saved exports options: the saved exports options (forms, filters, aggregators) are now editable. +* ([#103](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/103)) Get an unified list of document in person and accompanying period context +* [export] Set the default date of calculation of the accompanying period's list as "today" +* Force accompanying period user history to be unique for the same period and stardate/enddate [:warning: may encounter migration issue] + + If some issue is encountered during migration, use this SQL to find the line which are in conflict, examine the problem and delete some of the concerning line +* + ```sql + -- to see the line which are in conflict with another one + SELECT o.* + FROM chill_person_accompanying_period_user_history o + JOIN chill_person_accompanying_period_user_history c ON o.id < c.id AND o.accompanyingperiod_id = c.accompanyingperiod_id + WHERE tsrange(o.startdate, o.enddate, '[)') && tsrange(c.startdate, c.enddate, '[)') + ORDER BY accompanyingperiod_id; + -- to examine line in conflict for a given accompanyingperiod_id (given by the previous query) + SELECT * FROM chill_person_accompanying_period_user_history WHERE accompanyingperiod_id = IIIIDDDD order by startdate, enddate; + ``` +* Rename label of filter in French: "parcours actif" => "parcours ouvert", and "filtrer les parcours ouverts" => "Filtrer les parcours dont la date d'ouverture" + +### Traduction francophone des principaux changements + +* Les exports enregistrés sont éditables par l'utilisateur; +* L'onglet "Document" dans les parcours et les dossiers d'usager affiche désormais les documents ajoutés à différents endroits. + + Pour les parcours, il s'agit de: + + - documents ajoutés directement dans le parcours; + - documents des échanges; + - documents des rendez-vous; + - documents des évaluations; + - documents directement ajoutés dans le dossier des usagers concernés par le parcours; + + Pour les usagers, il s'agit de: + + - documents des échanges; + - documents des parcours; + - documents des rendez-vous; + - documents des actions, des échanges, des rendez-vous, des évaluations ajoutés dans les parcours. +* Dans la liste des parcours, la date de calcul des éléments associés est "aujourd'hui" par défaut. +* Dans les exports, renommage des libellés des filtres: "parcours actif" => "parcours ouvert", et "filtrer les parcours ouverts" => "Filtrer les parcours dont la date d'ouverture" + ## v2.2.2 - 2023-06-26 ### Fixed * [Accompanying period comments]: order comments from the most recent to the oldest, in the list From 90e868779976c529c792cca5e0f0ecc6c389ea7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 28 Jun 2023 17:01:42 +0200 Subject: [PATCH 239/724] Fixed: [export] rename label on CurrentActionFilter --- .changes/unreleased/Fixed-20230628-170055.yaml | 6 ++++++ .../Export/Filter/SocialWorkFilters/CurrentActionFilter.php | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 .changes/unreleased/Fixed-20230628-170055.yaml diff --git a/.changes/unreleased/Fixed-20230628-170055.yaml b/.changes/unreleased/Fixed-20230628-170055.yaml new file mode 100644 index 000000000..7f9ec3028 --- /dev/null +++ b/.changes/unreleased/Fixed-20230628-170055.yaml @@ -0,0 +1,6 @@ +kind: Fixed +body: '[export] Rename label for CurrentActionFilter (on accompanying period work) + to make precision between "ouvert" and "sans date de fin"' +time: 2023-06-28T17:00:55.206937751+02:00 +custom: + Issue: "" diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CurrentActionFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CurrentActionFilter.php index e99590025..09551a3c5 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CurrentActionFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CurrentActionFilter.php @@ -44,11 +44,11 @@ class CurrentActionFilter implements FilterInterface public function describeAction($data, $format = 'string'): array { - return ['Filtered by current action']; + return ['Filtered actions without end date']; } public function getTitle(): string { - return 'Filter by current actions'; + return 'Filter actions without end date'; } } From 347eda05df8ec3a2b6f106c7a0470970270543cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 29 Jun 2023 12:44:28 +0200 Subject: [PATCH 240/724] Fix: force the consistency of location in accompanying period - internally, the entity remove the addressLocation when the personLocation is set, and vice-versa; - this commit add a migration which may solve the case when both case happens (priority to personLocation + keep the history) - add a constraint on the database to avoid such situation --- .../unreleased/Fixed-20230629-124412.yaml | 6 +++ .../Entity/AccompanyingPeriod.php | 5 ++- .../Tests/Entity/AccompanyingPeriodTest.php | 33 +++++++++++--- .../migrations/Version20230628152138.php | 45 +++++++++++++++++++ .../translations/messages.fr.yml | 4 +- 5 files changed, 85 insertions(+), 8 deletions(-) create mode 100644 .changes/unreleased/Fixed-20230629-124412.yaml create mode 100644 src/Bundle/ChillPersonBundle/migrations/Version20230628152138.php diff --git a/.changes/unreleased/Fixed-20230629-124412.yaml b/.changes/unreleased/Fixed-20230629-124412.yaml new file mode 100644 index 000000000..7fc3d3eb0 --- /dev/null +++ b/.changes/unreleased/Fixed-20230629-124412.yaml @@ -0,0 +1,6 @@ +kind: Fixed +body: Force the db to have either a person_location or a address_location, and avoid + to have both also internally in the entity +time: 2023-06-29T12:44:12.019663991+02:00 +custom: + Issue: "" diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php index ba2fca2af..07e1bafe4 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php @@ -786,7 +786,7 @@ class AccompanyingPeriod implements } /** - * @return Collection|AccompanyingPeriodLocationHistory[] + * @return Collection */ public function getLocationHistories(): Collection { @@ -797,6 +797,7 @@ class AccompanyingPeriod implements * Get where the location is. * * @Groups({"read"}) + * @return 'person'|'address'|'none' */ public function getLocationStatus(): string { @@ -1209,6 +1210,7 @@ class AccompanyingPeriod implements $this->addressLocation = $addressLocation; if (null !== $addressLocation) { + $this->setPersonLocation(null); $locationHistory = new AccompanyingPeriodLocationHistory(); $locationHistory ->setStartDate(new DateTimeImmutable('now')) @@ -1327,6 +1329,7 @@ class AccompanyingPeriod implements $this->personLocation = $person; if (null !== $person) { + $this->setAddressLocation(null); $locationHistory = new AccompanyingPeriodLocationHistory(); $locationHistory ->setStartDate(new DateTimeImmutable('now')) diff --git a/src/Bundle/ChillPersonBundle/Tests/Entity/AccompanyingPeriodTest.php b/src/Bundle/ChillPersonBundle/Tests/Entity/AccompanyingPeriodTest.php index 0a9c22df1..dad574000 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Entity/AccompanyingPeriodTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Entity/AccompanyingPeriodTest.php @@ -138,12 +138,14 @@ final class AccompanyingPeriodTest extends \PHPUnit\Framework\TestCase $this->assertCount(1, $period->getLocationHistories()); $this->assertSame($address, $period->getLocationHistories()->first()->getAddressLocation()); + $this->assertNull($period->getLocationHistories()->first()->getPersonLocation()); $period->setPersonLocation($person); $period->setAddressLocation(null); $this->assertCount(2, $period->getLocationHistories()); $this->assertSame($person, $period->getLocationHistories()->last()->getPersonLocation()); + $this->assertNull($period->getLocationHistories()->last()->getAddressLocation()); $period->setAddressLocation($address); $period->setPersonLocation(null); @@ -172,14 +174,35 @@ final class AccompanyingPeriodTest extends \PHPUnit\Framework\TestCase } while ($iterator->valid()); } - public function testIsClosed() - { - $period = new AccompanyingPeriod(new DateTime()); - $period->setClosingDate(new DateTime('tomorrow')); - $this->assertFalse($period->isOpen()); + public function testHistoryLocationNotHavingBothAtStart() + { + $period = new AccompanyingPeriod(); + $person = new Person(); + $address = new Address(); + + $period->setAddressLocation($address); + $period->setPersonLocation($person); + + $period->setStep(AccompanyingPeriod::STEP_CONFIRMED); + + $this->assertCount(1, $period->getLocationHistories()); + + self::assertNull($period->getAddressLocation()); + self::assertNull($period->getLocationHistories()->first()->getAddressLocation()); + self::assertSame($person, $period->getLocationHistories()->first()->getPersonLocation()); + self::assertSame($person, $period->getPersonLocation()); + self::assertEquals('person', $period->getLocationStatus()); } + public function testIsClosed() + { + $period = new AccompanyingPeriod(new DateTime()); + $period->setClosingDate(new DateTime('tomorrow')); + + $this->assertFalse($period->isOpen()); + } + public function testIsOpen() { $period = new AccompanyingPeriod(new DateTime()); diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20230628152138.php b/src/Bundle/ChillPersonBundle/migrations/Version20230628152138.php new file mode 100644 index 000000000..240b99dbf --- /dev/null +++ b/src/Bundle/ChillPersonBundle/migrations/Version20230628152138.php @@ -0,0 +1,45 @@ +addSql('UPDATE chill_person_accompanying_period SET addresslocation_id = NULL + where personlocation_id IS NOT NULL AND addresslocation_id IS NOT NULL'); + $this->addSql('INSERT INTO chill_person_accompanying_period_location_history + (id, period_id, startdate, enddate, createdat, personlocation_id, addresslocation_id, createdby_id) + SELECT nextval(\'chill_person_accompanying_period_location_history_id_seq\'), period_id, startdate, startdate, now(), null, addresslocation_id, null + FROM chill_person_accompanying_period_location_history + WHERE personlocation_id IS NOT NULL AND addresslocation_id IS NOT NULL + '); + $this->addSql('UPDATE chill_person_accompanying_period_location_history SET addresslocation_id = NULL WHERE addresslocation_id IS NOT NULL AND personlocation_id IS NOT NULL'); + + $this->addSql('ALTER TABLE chill_person_accompanying_period ADD CONSTRAINT location_check CHECK (personlocation_id IS NULL OR addresslocation_id IS NULL)'); + $this->addSql('ALTER TABLE chill_person_accompanying_period_location_history ADD CONSTRAINT location_check CHECK (personlocation_id IS NULL OR addresslocation_id IS NULL)'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_person_accompanying_period DROP CONSTRAINT location_check'); + $this->addSql('ALTER TABLE chill_person_accompanying_period_location_history DROP CONSTRAINT location_check'); + } +} diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 12647d04c..7387ccf1c 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -585,8 +585,8 @@ Filter by creator job: Filtrer les parcours par métier du créateur 'Filtered by creator job: only %jobs%': 'Filtré par métier du créateur: uniquement %jobs%' Group by creator job: Grouper les parcours par métier du créateur -Filter by current actions: Filtrer les actions en cours -Filtered by current action: 'Filtré: uniquement les actions en cours (sans date de fin)' +Filter actions without end date: Filtre les actions sans date de fin (ouvertes) +Filtered actions without end date: 'Filtré: uniquement les actions sans date de fin (ouvertes)' Filter by start date evaluations: Filtrer les évaluations par date de début Filter by end date evaluations: Filtrer les évaluations par date de fin start period date: Date de début de la période From 56940d830c46fa789cc12fd29a00cb0e8cda92b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 29 Jun 2023 17:45:39 +0200 Subject: [PATCH 241/724] fix typos --- .../ChillAsideActivityBundle/src/translations/messages.fr.yml | 3 ++- src/Bundle/ChillPersonBundle/translations/messages.fr.yml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillAsideActivityBundle/src/translations/messages.fr.yml b/src/Bundle/ChillAsideActivityBundle/src/translations/messages.fr.yml index cc428390c..25d07bd22 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/translations/messages.fr.yml +++ b/src/Bundle/ChillAsideActivityBundle/src/translations/messages.fr.yml @@ -176,11 +176,12 @@ export: agent_id: Utilisateur creator_id: Créateur main_scope: Service principal de l'utilisateur - main_center: Centre principal de l'utilisteur + main_center: Centre principal de l'utilisateur aside_activity_type: Catégorie d'activité annexe date: Date duration: Durée note: Note + id: Identifiant Exports of aside activities: Exports des activités annexes Count aside activities: Nombre d'activités annexes diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 7387ccf1c..01383c050 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -1137,7 +1137,7 @@ export: createdAt: Créé le updatedAt: Dernière mise à jour le acpOrigin: Origine du parcours - origin: Origine du parcourse + origin: Origine du parcours acpClosingMotive: Motif de fermeture acpJob: Métier du parcours createdBy: Créé par From 31745bc25213a834bc2e5a5ecf04307494694bb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 29 Jun 2023 17:52:26 +0200 Subject: [PATCH 242/724] [export] order center alphabetically when generating an export --- src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php b/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php index d33ab2ade..c51676b32 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php @@ -57,6 +57,9 @@ final class PickCenterType extends AbstractType $export->requiredRole() ); + // order alphabetically + usort($centers, fn (Center $a, Center $b) => $a->getCenter() <=> $b->getName()); + $builder->add('center', EntityType::class, [ 'class' => Center::class, 'choices' => $centers, From c019fffbe74838d04da2204754b94d8a4200f6ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 29 Jun 2023 17:53:01 +0200 Subject: [PATCH 243/724] fix cs --- .../Tests/Entity/AccompanyingPeriodTest.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Tests/Entity/AccompanyingPeriodTest.php b/src/Bundle/ChillPersonBundle/Tests/Entity/AccompanyingPeriodTest.php index dad574000..bb7e2e80a 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Entity/AccompanyingPeriodTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Entity/AccompanyingPeriodTest.php @@ -195,13 +195,13 @@ final class AccompanyingPeriodTest extends \PHPUnit\Framework\TestCase self::assertEquals('person', $period->getLocationStatus()); } - public function testIsClosed() - { - $period = new AccompanyingPeriod(new DateTime()); - $period->setClosingDate(new DateTime('tomorrow')); + public function testIsClosed() + { + $period = new AccompanyingPeriod(new DateTime()); + $period->setClosingDate(new DateTime('tomorrow')); - $this->assertFalse($period->isOpen()); - } + $this->assertFalse($period->isOpen()); + } public function testIsOpen() { From 4a5ac170ba30f548edaee801f08395ffa086cda0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 29 Jun 2023 13:16:40 +0200 Subject: [PATCH 244/724] [export] add dates for filter "user working on course" --- .../unreleased/Feature-20230629-131558.yaml | 6 +++ .../UserWorkingOnCourseFilter.php | 40 ++++++++++++++----- .../translations/messages.fr.yml | 4 +- 3 files changed, 40 insertions(+), 10 deletions(-) create mode 100644 .changes/unreleased/Feature-20230629-131558.yaml diff --git a/.changes/unreleased/Feature-20230629-131558.yaml b/.changes/unreleased/Feature-20230629-131558.yaml new file mode 100644 index 000000000..42d731c4f --- /dev/null +++ b/.changes/unreleased/Feature-20230629-131558.yaml @@ -0,0 +1,6 @@ +kind: Feature +body: '[export] on "filter by user working" on accompanying period, add two dates + to filters intervention within a period' +time: 2023-06-29T13:15:58.070316708+02:00 +custom: + Issue: "113" diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserWorkingOnCourseFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserWorkingOnCourseFilter.php index d078443af..1f9bfc61a 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserWorkingOnCourseFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserWorkingOnCourseFilter.php @@ -13,7 +13,10 @@ namespace Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters; use Chill\MainBundle\Entity\User; use Chill\MainBundle\Export\FilterInterface; +use Chill\MainBundle\Form\Type\PickRollingDateType; use Chill\MainBundle\Form\Type\PickUserDynamicType; +use Chill\MainBundle\Service\RollingDate\RollingDate; +use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface; use Chill\MainBundle\Templating\Entity\UserRender; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Export\Declarations; @@ -27,11 +30,9 @@ use Symfony\Component\Form\FormBuilderInterface; */ readonly class UserWorkingOnCourseFilter implements FilterInterface { - private const AI_ALIAS = 'user_working_on_course_filter_acc_info'; - private const AI_USERS = 'user_working_on_course_filter_users'; - public function __construct( private UserRender $userRender, + private RollingDateConverterInterface $rollingDateConverter, ) { } @@ -40,11 +41,23 @@ readonly class UserWorkingOnCourseFilter implements FilterInterface $builder ->add('users', PickUserDynamicType::class, [ 'multiple' => true, - ]); + ]) + ->add('start_date', PickRollingDateType::class, [ + 'label' => 'export.filter.course.by_user_working.User working after' + ]) + ->add('end_date', PickRollingDateType::class, [ + 'label' => 'export.filter.course.by_user_working.User working before' + ]) + ; } + public function getFormDefaultData(): array { - return []; + return [ + 'users' => [], + 'start_date' => new RollingDate(RollingDate::T_YEAR_CURRENT_START), + 'end_date' => new RollingDate(RollingDate::T_TODAY), + ]; } public function getTitle(): string @@ -55,7 +68,7 @@ readonly class UserWorkingOnCourseFilter implements FilterInterface public function describeAction($data, $format = 'string'): array { return [ - 'export.filter.course.by_user_working.Filtered by user working on course: only %users%', [ + 'export.filter.course.by_user_working.Filtered by user working on course: only %users%, between %start_date% and %end_date%', [ '%users%' => implode( ', ', array_map( @@ -63,6 +76,8 @@ readonly class UserWorkingOnCourseFilter implements FilterInterface $data['users'] ) ), + '%start_date%' => $this->rollingDateConverter->convert($data['start_date'])?->format('d-m-Y'), + '%end_date%' => $this->rollingDateConverter->convert($data['end_date'])?->format('d-m-Y'), ], ]; } @@ -74,14 +89,21 @@ readonly class UserWorkingOnCourseFilter implements FilterInterface public function alterQuery(QueryBuilder $qb, $data): void { + $ai_alias = 'user_working_on_course_filter_acc_info'; + $ai_users = 'user_working_on_course_filter_users'; + $start = 'acp_use_work_on_start'; + $end = 'acp_use_work_on_end'; + $qb ->andWhere( $qb->expr()->exists( - "SELECT 1 FROM " . AccompanyingPeriod\AccompanyingPeriodInfo::class . " " . self::AI_ALIAS . " " . - "WHERE " . self::AI_ALIAS . ".user IN (:" . self::AI_USERS .") AND IDENTITY(" . self::AI_ALIAS . ".accompanyingPeriod) = acp.id" + "SELECT 1 FROM " . AccompanyingPeriod\AccompanyingPeriodInfo::class . " {$ai_alias} " . + "WHERE {$ai_alias}.user IN (:{$ai_users}) AND IDENTITY({$ai_alias}.accompanyingPeriod) = acp.id AND {$ai_alias}.infoDate >= :{$start} and {$ai_alias}.infoDate < :{$end}" ) ) - ->setParameter(self::AI_USERS, $data['users']) + ->setParameter($ai_users, $data['users']) + ->setParameter($start, $this->rollingDateConverter->convert($data['start_date'])) + ->setParameter($end, $this->rollingDateConverter->convert($data['end_date'])) ; } diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 01383c050..464e8fa67 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -1082,7 +1082,9 @@ export: Only course with events between %startDate% and %endDate%: Seulement les parcours ayant reçu une intervention entre le %startDate% et le %endDate% by_user_working: title: Filter les parcours par intervenant - 'Filtered by user working on course: only %users%': 'Filtré par intervenants sur le parcours: seulement %users%' + 'Filtered by user working on course: only %users%, between %start_date% and %end_date%': 'Filtré par intervenants sur le parcours: seulement %users%, entre le %start_date% et le %end_date%' + User working after: Intervention après le + User working before: Intervention avant le by_step: Filter by step: Filtrer les parcours par statut du parcours Filter by step between dates: Filtrer les parcours par statut du parcours entre deux dates From 393e59e22bdab368ca6ca53fea6e079a8f1a19ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 29 Jun 2023 16:00:50 +0200 Subject: [PATCH 245/724] DX: Rolling date: allow to receive a null parameter (RollingDate) When receiving a null parameter (a null rolling date), it will return null --- .changes/unreleased/DX-20230629-160029.yaml | 5 +++++ .../Service/RollingDate/RollingDateConverter.php | 6 +++++- .../Service/RollingDate/RollingDateConverterInterface.php | 6 +++++- 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 .changes/unreleased/DX-20230629-160029.yaml diff --git a/.changes/unreleased/DX-20230629-160029.yaml b/.changes/unreleased/DX-20230629-160029.yaml new file mode 100644 index 000000000..b83befec6 --- /dev/null +++ b/.changes/unreleased/DX-20230629-160029.yaml @@ -0,0 +1,5 @@ +kind: DX +body: 'Rolling Date: can receive a null parameter' +time: 2023-06-29T16:00:29.664814895+02:00 +custom: + Issue: "" diff --git a/src/Bundle/ChillMainBundle/Service/RollingDate/RollingDateConverter.php b/src/Bundle/ChillMainBundle/Service/RollingDate/RollingDateConverter.php index 026ff7a8a..72ad89c58 100644 --- a/src/Bundle/ChillMainBundle/Service/RollingDate/RollingDateConverter.php +++ b/src/Bundle/ChillMainBundle/Service/RollingDate/RollingDateConverter.php @@ -18,8 +18,12 @@ use UnexpectedValueException; class RollingDateConverter implements RollingDateConverterInterface { - public function convert(RollingDate $rollingDate): DateTimeImmutable + public function convert(?RollingDate $rollingDate): ?DateTimeImmutable { + if (null === $rollingDate) { + return null; + } + switch ($rollingDate->getRoll()) { case RollingDate::T_MONTH_CURRENT_START: return $this->toBeginOfMonth($rollingDate->getPivotDate()); diff --git a/src/Bundle/ChillMainBundle/Service/RollingDate/RollingDateConverterInterface.php b/src/Bundle/ChillMainBundle/Service/RollingDate/RollingDateConverterInterface.php index b20a5ced2..6c7d9a5bd 100644 --- a/src/Bundle/ChillMainBundle/Service/RollingDate/RollingDateConverterInterface.php +++ b/src/Bundle/ChillMainBundle/Service/RollingDate/RollingDateConverterInterface.php @@ -15,5 +15,9 @@ use DateTimeImmutable; interface RollingDateConverterInterface { - public function convert(RollingDate $rollingDate): DateTimeImmutable; + /** + * @param RollingDate|null $rollingDate + * @return ($rollingDate is null ? null : DateTimeImmutable) + */ + public function convert(?RollingDate $rollingDate): ?DateTimeImmutable; } From 5a395b160fd990d423887a6451a15f1f52768f6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 29 Jun 2023 17:39:26 +0200 Subject: [PATCH 246/724] [export] add aggregator and filter related to AccompanyingPeriodInfo + Center aggregator for Person see #113 --- .../unreleased/Feature-20230629-173445.yaml | 5 + .../unreleased/Feature-20230629-173509.yaml | 5 + .../unreleased/Feature-20230629-173544.yaml | 5 + .../unreleased/Feature-20230629-173617.yaml | 5 + .../unreleased/Feature-20230629-173822.yaml | 5 + .../unreleased/Feature-20230629-173844.yaml | 5 + exports_alias_conventions.md | 3 + .../JobWorkingOnCourseAggregator.php | 100 +++++++++++++ .../ScopeWorkingOnCourseAggregator.php | 101 ++++++++++++++ .../UserWorkingOnCourseAggregator.php | 100 +++++++++++++ .../PersonAggregators/CenterAggregator.php | 103 ++++++++++++++ .../JobWorkingOnCourseFilter.php | 130 +++++++++++++++++ .../OpenBetweenDatesFilter.php | 2 +- .../ScopeWorkingOnCourseFilter.php | 132 ++++++++++++++++++ .../services/exports_accompanying_course.yaml | 20 +++ .../config/services/exports_person.yaml | 5 + .../translations/messages.fr.yml | 28 +++- 17 files changed, 751 insertions(+), 3 deletions(-) create mode 100644 .changes/unreleased/Feature-20230629-173445.yaml create mode 100644 .changes/unreleased/Feature-20230629-173509.yaml create mode 100644 .changes/unreleased/Feature-20230629-173544.yaml create mode 100644 .changes/unreleased/Feature-20230629-173617.yaml create mode 100644 .changes/unreleased/Feature-20230629-173822.yaml create mode 100644 .changes/unreleased/Feature-20230629-173844.yaml create mode 100644 src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/JobWorkingOnCourseAggregator.php create mode 100644 src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ScopeWorkingOnCourseAggregator.php create mode 100644 src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/UserWorkingOnCourseAggregator.php create mode 100644 src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/CenterAggregator.php create mode 100644 src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/JobWorkingOnCourseFilter.php create mode 100644 src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ScopeWorkingOnCourseFilter.php diff --git a/.changes/unreleased/Feature-20230629-173445.yaml b/.changes/unreleased/Feature-20230629-173445.yaml new file mode 100644 index 000000000..2d3642a85 --- /dev/null +++ b/.changes/unreleased/Feature-20230629-173445.yaml @@ -0,0 +1,5 @@ +kind: Feature +body: '[export] Add an aggregator by user''s job working on a course' +time: 2023-06-29T17:34:45.278993433+02:00 +custom: + Issue: "113" diff --git a/.changes/unreleased/Feature-20230629-173509.yaml b/.changes/unreleased/Feature-20230629-173509.yaml new file mode 100644 index 000000000..95fd23458 --- /dev/null +++ b/.changes/unreleased/Feature-20230629-173509.yaml @@ -0,0 +1,5 @@ +kind: Feature +body: '[export] add an aggregator by user''s scope working on a course' +time: 2023-06-29T17:35:09.548758741+02:00 +custom: + Issue: "113" diff --git a/.changes/unreleased/Feature-20230629-173544.yaml b/.changes/unreleased/Feature-20230629-173544.yaml new file mode 100644 index 000000000..94e79bc6d --- /dev/null +++ b/.changes/unreleased/Feature-20230629-173544.yaml @@ -0,0 +1,5 @@ +kind: Feature +body: '[export] on aggregator "user working on a course"' +time: 2023-06-29T17:35:44.998468724+02:00 +custom: + Issue: "" diff --git a/.changes/unreleased/Feature-20230629-173617.yaml b/.changes/unreleased/Feature-20230629-173617.yaml new file mode 100644 index 000000000..445b85cff --- /dev/null +++ b/.changes/unreleased/Feature-20230629-173617.yaml @@ -0,0 +1,5 @@ +kind: Feature +body: '[export] add a center aggregator for Person' +time: 2023-06-29T17:36:17.635876613+02:00 +custom: + Issue: "113" diff --git a/.changes/unreleased/Feature-20230629-173822.yaml b/.changes/unreleased/Feature-20230629-173822.yaml new file mode 100644 index 000000000..6a1569d00 --- /dev/null +++ b/.changes/unreleased/Feature-20230629-173822.yaml @@ -0,0 +1,5 @@ +kind: Feature +body: '[export] add a filter on "job working on a course"' +time: 2023-06-29T17:38:22.682951416+02:00 +custom: + Issue: "113" diff --git a/.changes/unreleased/Feature-20230629-173844.yaml b/.changes/unreleased/Feature-20230629-173844.yaml new file mode 100644 index 000000000..f307ebf57 --- /dev/null +++ b/.changes/unreleased/Feature-20230629-173844.yaml @@ -0,0 +1,5 @@ +kind: Feature +body: '[export] Add a filter on "scope working on a course"' +time: 2023-06-29T17:38:44.238287822+02:00 +custom: + Issue: "113" diff --git a/exports_alias_conventions.md b/exports_alias_conventions.md index fd7844691..64df91030 100644 --- a/exports_alias_conventions.md +++ b/exports_alias_conventions.md @@ -18,6 +18,7 @@ These are alias conventions : | | SocialIssue::class | acp.socialIssues | acpsocialissue | | | User::class | acp.user | acpuser | | | AccompanyingPeriopStepHistory::class | acp.stepHistories | acpstephistories | +| | AccompanyingPeriodInfo::class | not existing (using custom WITH clause) | acpinfo | | AccompanyingPeriodWork::class | | | acpw | | | AccompanyingPeriodWorkEvaluation::class | acpw.accompanyingPeriodWorkEvaluations | workeval | | | User::class | acpw.referrers | acpwuser | @@ -28,6 +29,8 @@ These are alias conventions : | | Person::class | acppart.person | partperson | | AccompanyingPeriodWorkEvaluation::class | | | workeval | | | Evaluation::class | workeval.evaluation | eval | +| AccompanyingPeriodInfo::class | | | acpinfo | +| | User::class | acpinfo.user | acpinfo_user | | Goal::class | | | goal | | | Result::class | goal.results | goalresult | | Person::class | | | person | diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/JobWorkingOnCourseAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/JobWorkingOnCourseAggregator.php new file mode 100644 index 000000000..e93300e85 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/JobWorkingOnCourseAggregator.php @@ -0,0 +1,100 @@ +userJobRepository->find((int) $jobId)) { + return ''; + } + + return $this->translatableStringHelper->localize($job->getLabel()); + }; + } + + public function getQueryKeys($data) + { + return [self::COLUMN_NAME]; + } + + public function getTitle() + { + return 'export.aggregator.course.by_job_working.title'; + } + + public function addRole(): ?string + { + return null; + } + + public function alterQuery(QueryBuilder $qb, $data) + { + if (!in_array('acpinfo', $qb->getAllAliases(), true)) { + $qb->leftJoin( + AccompanyingPeriodInfo::class, + 'acpinfo', + Join::WITH, + 'acp.id = IDENTITY(acpinfo.accompanyingPeriod)' + ); + } + + if (!in_array('acpinfo_user', $qb->getAllAliases(), true)) { + $qb->leftJoin('acpinfo.user', 'acpinfo_user'); + } + + $qb->addSelect('IDENTITY(acpinfo_user.userJob) AS ' . self::COLUMN_NAME); + $qb->addGroupBy(self::COLUMN_NAME); + } + + public function applyOn() + { + return Declarations::ACP_TYPE; + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ScopeWorkingOnCourseAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ScopeWorkingOnCourseAggregator.php new file mode 100644 index 000000000..b9f493af9 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ScopeWorkingOnCourseAggregator.php @@ -0,0 +1,101 @@ +scopeRepository->find((int) $scopeId)) { + return ''; + } + + return $this->translatableStringHelper->localize($scope->getName()); + }; + } + + public function getQueryKeys($data) + { + return [self::COLUMN_NAME]; + } + + public function getTitle() + { + return 'export.aggregator.course.by_scope_working.title'; + } + + public function addRole(): ?string + { + return null; + } + + public function alterQuery(QueryBuilder $qb, $data) + { + if (!in_array('acpinfo', $qb->getAllAliases(), true)) { + $qb->leftJoin( + AccompanyingPeriodInfo::class, + 'acpinfo', + Join::WITH, + 'acp.id = IDENTITY(acpinfo.accompanyingPeriod)' + ); + } + + if (!in_array('acpinfo_user', $qb->getAllAliases(), true)) { + $qb->leftJoin('acpinfo.user', 'acpinfo_user'); + } + + $qb->addSelect('IDENTITY(acpinfo_user.mainScope) AS ' . self::COLUMN_NAME); + $qb->addGroupBy(self::COLUMN_NAME); + } + + public function applyOn() + { + return Declarations::ACP_TYPE; + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/UserWorkingOnCourseAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/UserWorkingOnCourseAggregator.php new file mode 100644 index 000000000..b4941fa01 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/UserWorkingOnCourseAggregator.php @@ -0,0 +1,100 @@ +userRepository->find((int) $userId)) { + return ''; + } + + return $this->userRender->renderString($user, []); + }; + } + + public function getQueryKeys($data) + { + return [self::COLUMN_NAME]; + } + + public function getTitle() + { + return 'export.aggregator.course.by_user_working.title'; + } + + public function addRole(): ?string + { + return null; + } + + public function alterQuery(QueryBuilder $qb, $data) + { + if (!in_array('acpinfo', $qb->getAllAliases(), true)) { + $qb->leftJoin( + AccompanyingPeriodInfo::class, + 'acpinfo', + Join::WITH, + 'acp.id = IDENTITY(acpinfo.accompanyingPeriod)' + ); + } + + if (!in_array('acpinfo_user', $qb->getAllAliases(), true)) { + $qb->leftJoin('acpinfo.user', 'acpinfo_user'); + } + + $qb->addSelect('acpinfo_user.id AS ' . self::COLUMN_NAME); + $qb->addGroupBy('acpinfo_user.id'); + } + + public function applyOn() + { + return Declarations::ACP_TYPE; + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/CenterAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/CenterAggregator.php new file mode 100644 index 000000000..9be0b0c7e --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/CenterAggregator.php @@ -0,0 +1,103 @@ +add('at_date', PickRollingDateType::class, [ + 'label' => 'export.aggregator.person.by_center.at_date', + ]); + } + + public function getFormDefaultData(): array + { + return [ + 'at_date' => new RollingDate(RollingDate::T_TODAY) + ]; + } + + public function getLabels($key, array $values, $data): Closure + { + return function (int|string|null $value) { + if (null === $value || '' === $value) { + return ''; + } + + if ('_header' === $value) { + return 'export.aggregator.person.by_center.center'; + } + + return (string) $this->centerRepository->find((int) $value)?->getName(); + }; + } + + public function getQueryKeys($data) + { + return [self::COLUMN_NAME]; + } + + public function getTitle() + { + return 'export.aggregator.person.by_center.title'; + } + + public function addRole(): ?string + { + return null; + } + + public function alterQuery(QueryBuilder $qb, $data) + { + $alias = 'pers_center_agg'; + $atDate = 'pers_center_agg_at_date'; + + $qb->leftJoin('person.centerHistory', $alias); + $qb + ->andWhere( + $qb->expr()->lte($alias.'.startDate', ':'.$atDate), + )->andWhere( + $qb->expr()->orX( + $qb->expr()->isNull($alias.'.endDate'), + $qb->expr()->gt($alias.'.endDate', ':'.$atDate) + ) + ); + $qb->setParameter($atDate, $this->rollingDateConverter->convert($data['at_date'])); + + $qb->addSelect("IDENTITY({$alias}.center) AS " . self::COLUMN_NAME); + $qb->addGroupBy(self::COLUMN_NAME); + } + + public function applyOn() + { + return Declarations::PERSON_TYPE; + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/JobWorkingOnCourseFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/JobWorkingOnCourseFilter.php new file mode 100644 index 000000000..63a668b6d --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/JobWorkingOnCourseFilter.php @@ -0,0 +1,130 @@ +userJobRepository->findAllActive(); + usort($jobs, fn (UserJob $a, UserJob $b) => $this->translatableStringHelper->localize($a->getLabel()) <=> $this->translatableStringHelper->localize($b->getLabel())); + + $builder + ->add('jobs', EntityType::class, [ + 'class' => UserJob::class, + 'choices' => $jobs, + 'choice_label' => fn (UserJob $userJob) => $this->translatableStringHelper->localize($userJob->getLabel()), + 'multiple' => true, + 'expanded' => true, + ]) + ->add('start_date', PickRollingDateType::class, [ + 'label' => 'export.filter.course.by_job_working.Job working after' + ]) + ->add('end_date', PickRollingDateType::class, [ + 'label' => 'export.filter.course.by_job_working.Job working before' + ]) + ; + } + + public function getFormDefaultData(): array + { + return [ + 'jobs' => [], + 'start_date' => new RollingDate(RollingDate::T_YEAR_CURRENT_START), + 'end_date' => new RollingDate(RollingDate::T_TODAY), + ]; + } + + public function getTitle(): string + { + return 'export.filter.course.by_job_working.title'; + } + + public function describeAction($data, $format = 'string'): array + { + return [ + 'export.filter.course.by_job_working.Filtered by job working on course: only %jobs%, between %start_date% and %end_date%', [ + '%jobs%' => implode( + ', ', + array_map( + fn (UserJob $userJob) => $this->translatableStringHelper->localize($userJob->getLabel()), + $data['jobs'] + ) + ), + '%start_date%' => $this->rollingDateConverter->convert($data['start_date'])?->format('d-m-Y'), + '%end_date%' => $this->rollingDateConverter->convert($data['end_date'])?->format('d-m-Y'), + ], + ]; + } + + public function addRole(): ?string + { + return null; + } + + public function alterQuery(QueryBuilder $qb, $data): void + { + $ai_alias = 'jobs_working_on_course_filter_acc_info'; + $ai_user_alias = 'jobs_working_on_course_filter_user'; + $ai_jobs = 'jobs_working_on_course_filter_jobs'; + $start = 'acp_jobs_work_on_start'; + $end = 'acp_jobs_work_on_end'; + + $qb + ->andWhere( + $qb->expr()->exists( + "SELECT 1 FROM " . AccompanyingPeriod\AccompanyingPeriodInfo::class . " {$ai_alias} JOIN {$ai_alias}.user {$ai_user_alias} " . + "WHERE IDENTITY({$ai_alias}.accompanyingPeriod) = acp.id + AND {$ai_user_alias}.userJob IN (:{$ai_jobs}) + AND {$ai_alias}.infoDate >= :{$start} and {$ai_alias}.infoDate < :{$end} + " + ) + ) + ->setParameter($ai_jobs, $data['jobs']) + ->setParameter($start, $this->rollingDateConverter->convert($data['start_date'])) + ->setParameter($end, $this->rollingDateConverter->convert($data['end_date'])) + ; + } + + public function applyOn(): string + { + return Declarations::ACP_TYPE; + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OpenBetweenDatesFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OpenBetweenDatesFilter.php index e9413083f..69fdd7bc0 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OpenBetweenDatesFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OpenBetweenDatesFilter.php @@ -38,7 +38,7 @@ class OpenBetweenDatesFilter implements FilterInterface { $clause = $qb->expr()->andX( $qb->expr()->gte('acp.openingDate', ':datefrom'), - $qb->expr()->lte('acp.openingDate', ':dateto') + $qb->expr()->lt('acp.openingDate', ':dateto') ); $qb->andWhere($clause); diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ScopeWorkingOnCourseFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ScopeWorkingOnCourseFilter.php new file mode 100644 index 000000000..b9787bf52 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ScopeWorkingOnCourseFilter.php @@ -0,0 +1,132 @@ +scopeRepository->findAllActive(); + usort($scopes, fn (Scope $a, Scope $b) => $this->translatableStringHelper->localize($a->getName()) <=> $this->translatableStringHelper->localize($b->getName())); + + $builder + ->add('scopes', EntityType::class, [ + 'class' => Scope::class, + 'choices' => $scopes, + 'choice_label' => fn (Scope $scope) => $this->translatableStringHelper->localize($scope->getName()), + 'multiple' => true, + 'expanded' => true, + ]) + ->add('start_date', PickRollingDateType::class, [ + 'label' => 'export.filter.course.by_scope_working.Scope working after' + ]) + ->add('end_date', PickRollingDateType::class, [ + 'label' => 'export.filter.course.by_scope_working.Scope working before' + ]) + ; + } + + public function getFormDefaultData(): array + { + return [ + 'scopes' => [], + 'start_date' => new RollingDate(RollingDate::T_YEAR_CURRENT_START), + 'end_date' => new RollingDate(RollingDate::T_TODAY), + ]; + } + + public function getTitle(): string + { + return 'export.filter.course.by_scope_working.title'; + } + + public function describeAction($data, $format = 'string'): array + { + return [ + 'export.filter.course.by_scope_working.Filtered by scope working on course: only %scopes%, between %start_date% and %end_date%', [ + '%scopes%' => implode( + ', ', + array_map( + fn (Scope $scope) => $this->translatableStringHelper->localize($scope->getName()), + $data['scopes'] + ) + ), + '%start_date%' => $this->rollingDateConverter->convert($data['start_date'])?->format('d-m-Y'), + '%end_date%' => $this->rollingDateConverter->convert($data['end_date'])?->format('d-m-Y'), + ], + ]; + } + + public function addRole(): ?string + { + return null; + } + + public function alterQuery(QueryBuilder $qb, $data): void + { + $ai_alias = 'scopes_working_on_course_filter_acc_info'; + $ai_user_alias = 'scopes_working_on_course_filter_user'; + $ai_scopes = 'scopes_working_on_course_filter_scopes'; + $start = 'acp_scopes_work_on_start'; + $end = 'acp_scopes_work_on_end'; + + $qb + ->andWhere( + $qb->expr()->exists( + "SELECT 1 FROM " . AccompanyingPeriod\AccompanyingPeriodInfo::class . " {$ai_alias} JOIN {$ai_alias}.user {$ai_user_alias} " . + "WHERE IDENTITY({$ai_alias}.accompanyingPeriod) = acp.id + AND {$ai_user_alias}.mainScope IN (:{$ai_scopes}) + AND {$ai_alias}.infoDate >= :{$start} and {$ai_alias}.infoDate < :{$end} + " + ) + ) + ->setParameter($ai_scopes, $data['scopes']) + ->setParameter($start, $this->rollingDateConverter->convert($data['start_date'])) + ->setParameter($end, $this->rollingDateConverter->convert($data['end_date'])) + ; + } + + public function applyOn(): string + { + return Declarations::ACP_TYPE; + } +} diff --git a/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_course.yaml b/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_course.yaml index c299bbaaa..c5a2dba68 100644 --- a/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_course.yaml +++ b/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_course.yaml @@ -135,6 +135,14 @@ services: tags: - { name: chill.export_filter, alias: accompanyingcourse_user_working_on_filter } + Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\JobWorkingOnCourseFilter: + tags: + - { name: chill.export_filter, alias: accompanyingcourse_job_working_on_filter } + + Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\ScopeWorkingOnCourseFilter: + tags: + - { name: chill.export_filter, alias: accompanyingcourse_scope_working_on_filter } + Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\HavingAnAccompanyingPeriodInfoWithinDatesFilter: tags: - { name: chill.export_filter, alias: accompanyingcourse_info_within_filter } @@ -231,3 +239,15 @@ services: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\CreatorJobAggregator: tags: - { name: chill.export_aggregator, alias: accompanyingcourse_creator_job_aggregator } + + Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\UserWorkingOnCourseAggregator: + tags: + - { name: chill.export_aggregator, alias: accompanyingcourse_user_working_on_course_aggregator } + + Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\JobWorkingOnCourseAggregator: + tags: + - { name: chill.export_aggregator, alias: accompanyingcourse_job_working_on_course_aggregator } + + Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\ScopeWorkingOnCourseAggregator: + tags: + - { name: chill.export_aggregator, alias: accompanyingcourse_scope_working_on_course_aggregator } diff --git a/src/Bundle/ChillPersonBundle/config/services/exports_person.yaml b/src/Bundle/ChillPersonBundle/config/services/exports_person.yaml index bf372ea06..64360aee9 100644 --- a/src/Bundle/ChillPersonBundle/config/services/exports_person.yaml +++ b/src/Bundle/ChillPersonBundle/config/services/exports_person.yaml @@ -177,3 +177,8 @@ services: tags: - { name: chill.export_aggregator, alias: person_household_compo_aggregator } + Chill\PersonBundle\Export\Aggregator\PersonAggregators\CenterAggregator: + tags: + - { name: chill.export_aggregator, alias: person_center_aggregator } + + diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 464e8fa67..2f7800e2b 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -372,7 +372,7 @@ Count people participating in an accompanying course by various parameters.: Com Exports of accompanying courses: Exports des parcours d'accompagnement Count accompanying courses: Nombre de parcours Count accompanying courses by various parameters: Compte le nombre de parcours en fonction de différents filtres. -Accompanying courses participation duration and number of participations: Durée moyenne et nombre des participation des usagers aux parcours +Accompanying courses participation duration and number of participations: Durée moyenne et nombre des participations des usagers aux parcours Create an average of accompanying courses duration of each person participation to accompanying course, according to filters on persons, accompanying course: Crée un rapport qui comptabilise la moyenne de la durée de participation de chaque usager concerné aux parcours, avec différents filtres, notamment sur les usagers concernés. Closingdate to apply: Date de fin à prendre en compte lorsque le parcours n'est pas clotûré @@ -1016,6 +1016,11 @@ export: Household composition: Composition du ménage Group course by household composition: Grouper les usagers par composition familiale Calc date: Date de calcul de la composition du ménage + by_center: + title: Grouper les usagers par centre + at_date: Date de calcul du centre + center: Centre de l'usager + course: by_referrer: Computation date for referrer: Date à laquelle le référent était actif @@ -1032,6 +1037,15 @@ export: Number of actions: Nombre d'actions by_creator_job: Creator's job: Métier du créateur + by_user_working: + title: Grouper les parcours par intervenant + user: Intervenant + by_job_working: + title: Grouper les parcours par métier de l'intervenant + job: Métier de l'intervenant + by_scope_working: + title: Grouper les parcours par service de l'intervenant + scope: Service de l'intervenant course_work: by_current_action: Current action ?: Action en cours ? @@ -1081,10 +1095,20 @@ export: end_date: Fin de la période Only course with events between %startDate% and %endDate%: Seulement les parcours ayant reçu une intervention entre le %startDate% et le %endDate% by_user_working: - title: Filter les parcours par intervenant + title: Filter les parcours par intervenant, entre deux dates 'Filtered by user working on course: only %users%, between %start_date% and %end_date%': 'Filtré par intervenants sur le parcours: seulement %users%, entre le %start_date% et le %end_date%' User working after: Intervention après le User working before: Intervention avant le + by_job_working: + title: Filtrer les parcours par métier de l'intervenant, entre deux dates + 'Filtered by job working on course: only %jobs%, between %start_date% and %end_date%': 'Filtré par métier des intervenants sur le parcours: seulement %jobs%, entre le %start_date% et le %end_date%' + Job working after: Intervention après le + Job working before: Intervention avant le + by_scope_working: + title: Filtrer les parcours par service de l'intervenant, entre deux dates + 'Filtered by scope working on course: only %scopes%, between %start_date% and %end_date%': 'Filtré par service des intervenants sur le parcours: seulement %scopes%, entre le %start_date% et le %end_date%' + Scope working after: Intervention après le + Scope working before: Intervention avant le by_step: Filter by step: Filtrer les parcours par statut du parcours Filter by step between dates: Filtrer les parcours par statut du parcours entre deux dates From b7df62d4f55201ded3a689b5a358cd43d099c69a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 29 Jun 2023 23:15:15 +0200 Subject: [PATCH 247/724] [export] use a rolling date on age aggregator (Person) This query allow to detects the saved export which won't work any more: ```sql select s.id, user_id, description, title, u.label from chill_main_saved_export s join users u on u.id = s.user_id WHERE options->'export'->'export'->'aggregators'->'person_age_aggregator'->'enabled' is not null; ``` --- .../unreleased/Fixed-20230629-231503.yaml | 5 +++ .../PersonAggregators/AgeAggregator.php | 31 +++++++------------ 2 files changed, 16 insertions(+), 20 deletions(-) create mode 100644 .changes/unreleased/Fixed-20230629-231503.yaml diff --git a/.changes/unreleased/Fixed-20230629-231503.yaml b/.changes/unreleased/Fixed-20230629-231503.yaml new file mode 100644 index 000000000..e021d1fda --- /dev/null +++ b/.changes/unreleased/Fixed-20230629-231503.yaml @@ -0,0 +1,5 @@ +kind: Fixed +body: '[export] set rolling date on person age aggregator' +time: 2023-06-29T23:15:03.20841309+02:00 +custom: + Issue: "" diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/AgeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/AgeAggregator.php index 2a63e475a..e3d364fa2 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/AgeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/AgeAggregator.php @@ -13,20 +13,18 @@ namespace Chill\PersonBundle\Export\Aggregator\PersonAggregators; use Chill\MainBundle\Export\AggregatorInterface; use Chill\MainBundle\Export\ExportElementValidatedInterface; -use DateTime; +use Chill\MainBundle\Form\Type\PickRollingDateType; +use Chill\MainBundle\Service\RollingDate\RollingDate; +use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface; use Doctrine\ORM\QueryBuilder; -use Symfony\Component\Form\Extension\Core\Type\DateType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Validator\Context\ExecutionContextInterface; -use Symfony\Contracts\Translation\TranslatorInterface; -final class AgeAggregator implements AggregatorInterface, ExportElementValidatedInterface +final readonly class AgeAggregator implements AggregatorInterface, ExportElementValidatedInterface { - private TranslatorInterface $translator; - - public function __construct(TranslatorInterface $translator) - { - $this->translator = $translator; + public function __construct( + private RollingDateConverterInterface $rollingDateConverter, + ) { } public function addRole(): ?string @@ -37,7 +35,7 @@ final class AgeAggregator implements AggregatorInterface, ExportElementValidated public function alterQuery(QueryBuilder $qb, $data) { $qb->addSelect('DATE_DIFF(:date_age_calculation, person.birthdate)/365 as person_age'); - $qb->setParameter('date_age_calculation', $data['date_age_calculation']); + $qb->setParameter('date_age_calculation', $this->rollingDateConverter->convert($data['date_age_calculation'])); $qb->addGroupBy('person_age'); } @@ -48,16 +46,13 @@ final class AgeAggregator implements AggregatorInterface, ExportElementValidated public function buildForm(FormBuilderInterface $builder) { - $builder->add('date_age_calculation', DateType::class, [ + $builder->add('date_age_calculation', PickRollingDateType::class, [ 'label' => 'Calculate age in relation to this date', - 'attr' => ['class' => 'datepicker'], - 'widget' => 'single_text', - 'format' => 'dd-MM-yyyy', ]); } public function getFormDefaultData(): array { - return ['date_age_calculation' => new DateTime()]; + return ['date_age_calculation' => new RollingDate(RollingDate::T_TODAY)]; } public function getLabels($key, array $values, $data) @@ -67,11 +62,7 @@ final class AgeAggregator implements AggregatorInterface, ExportElementValidated return 'Age'; } - if (null === $value) { - return $this->translator->trans('without data'); - } - - return $value; + return $value ?? ''; }; } From c8b62d990a6572fa123b0b0b6b137910698f090f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 30 Jun 2023 17:12:09 +0200 Subject: [PATCH 248/724] fixes for exports and list --- .changes/unreleased/Fixed-20230630-171119.yaml | 5 +++++ .changes/unreleased/Fixed-20230630-171153.yaml | 5 +++++ .../Export/Export/CountAccompanyingCourse.php | 1 - .../Export/Export/CountAccompanyingPeriodWork.php | 1 - .../Export/Export/CountEvaluation.php | 1 - .../Export/Export/ListAccompanyingPeriod.php | 14 +++++--------- 6 files changed, 15 insertions(+), 12 deletions(-) create mode 100644 .changes/unreleased/Fixed-20230630-171119.yaml create mode 100644 .changes/unreleased/Fixed-20230630-171153.yaml diff --git a/.changes/unreleased/Fixed-20230630-171119.yaml b/.changes/unreleased/Fixed-20230630-171119.yaml new file mode 100644 index 000000000..f3185ace2 --- /dev/null +++ b/.changes/unreleased/Fixed-20230630-171119.yaml @@ -0,0 +1,5 @@ +kind: Fixed +body: '[export] fix list when a person locating a course is without address' +time: 2023-06-30T17:11:19.454081914+02:00 +custom: + Issue: "" diff --git a/.changes/unreleased/Fixed-20230630-171153.yaml b/.changes/unreleased/Fixed-20230630-171153.yaml new file mode 100644 index 000000000..c09bd93d0 --- /dev/null +++ b/.changes/unreleased/Fixed-20230630-171153.yaml @@ -0,0 +1,5 @@ +kind: Fixed +body: '[export] remove unused condition on course about duration participation' +time: 2023-06-30T17:11:53.076615549+02:00 +custom: + Issue: "" diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php b/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php index 75583dfa0..58ef24e42 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php @@ -101,7 +101,6 @@ class CountAccompanyingCourse implements ExportInterface, GroupedExportInterface ->andWhere('acp.step != :count_acp_step') ->leftJoin('acp.participations', 'acppart') ->leftJoin('acppart.person', 'person') - ->andWhere('acppart.startDate != acppart.endDate OR acppart.endDate IS NULL') ->andWhere( $qb->expr()->exists( 'SELECT 1 FROM ' . PersonCenterHistory::class . ' acl_count_person_history WHERE acl_count_person_history.person = person diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingPeriodWork.php b/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingPeriodWork.php index 8a035bdcd..cf9feb3af 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingPeriodWork.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingPeriodWork.php @@ -101,7 +101,6 @@ class CountAccompanyingPeriodWork implements ExportInterface, GroupedExportInter ->join('acpw.accompanyingPeriod', 'acp') ->join('acp.participations', 'acppart') ->join('acppart.person', 'person') - ->andWhere('acppart.startDate != acppart.endDate OR acppart.endDate IS NULL') ->andWhere( $qb->expr()->exists( 'SELECT 1 FROM ' . PersonCenterHistory::class . ' acl_count_person_history WHERE acl_count_person_history.person = person diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php b/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php index 3de433e2e..d9795e3ba 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php @@ -101,7 +101,6 @@ class CountEvaluation implements ExportInterface, GroupedExportInterface ->join('acpw.accompanyingPeriod', 'acp') ->join('acp.participations', 'acppart') ->join('acppart.person', 'person') - ->andWhere('acppart.startDate != acppart.endDate OR acppart.endDate IS NULL') ->andWhere( $qb->expr()->exists( 'SELECT 1 FROM ' . PersonCenterHistory::class . ' acl_count_person_history WHERE acl_count_person_history.person = person diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php index 294b9ce9a..af66ab312 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php @@ -416,15 +416,11 @@ class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface ) ) ) - ->leftJoin(PersonHouseholdAddress::class, 'personAddress', Join::WITH, 'locationHistory.personLocation = personAddress.person') - ->andWhere( - $qb->expr()->orX( - $qb->expr()->isNull('personAddress'), - $qb->expr()->andX( - $qb->expr()->lte('personAddress.validFrom', ':calcDate'), - $qb->expr()->orX($qb->expr()->isNull('personAddress.validTo'), $qb->expr()->gt('personAddress.validTo', ':calcDate')) - ) - ) + ->leftJoin( + PersonHouseholdAddress::class, + 'personAddress', + Join::WITH, + 'locationHistory.personLocation = personAddress.person AND (personAddress.validFrom <= :calcDate AND (personAddress.validTo IS NULL OR personAddress.validTo > :calcDate))' ) ->leftJoin(Address::class, 'acp_address', Join::WITH, 'COALESCE(IDENTITY(locationHistory.addressLocation), IDENTITY(personAddress.address)) = acp_address.id'); From cc0e832cc97167105ea096be185b8334806c2047 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 19 Jan 2023 12:47:04 +0100 Subject: [PATCH 249/724] FEATURE [voter][confidential] added right to see confidential periods --- .../Security/Authorization/AccompanyingPeriodVoter.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php index 709624b54..9b4976847 100644 --- a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php +++ b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php @@ -107,6 +107,11 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH */ public const TOGGLE_INTENSITY = 'CHILL_PERSON_ACCOMPANYING_PERIOD_TOGGLE_INTENSITY'; + /** + * Right to see confidential period even if not referrer + */ + public const SEE_CONFIDENTIAL = 'CHILL_PERSON_ACCOMPANYING_PERIOD_SEE_CONFIDENTIAL'; + private Security $security; private VoterHelperInterface $voterHelper; From 9ccc57bbcb394bed6b1fe1f13ff07fa9d9f27ba7 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 19 Jan 2023 12:48:00 +0100 Subject: [PATCH 250/724] FEATURE [config][voter] config set for relation between bulk_assign and see_confidential --- .../DependencyInjection/ChillPersonExtension.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php index 569dd1502..576e563bd 100644 --- a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php +++ b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php @@ -985,6 +985,7 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac ], AccompanyingPeriodVoter::REASSIGN_BULK => [ AccompanyingPeriodVoter::CONFIDENTIAL_CRUD, + AccompanyingPeriodVoter::SEE_CONFIDENTIAL, ], AccompanyingPeriodVoter::TOGGLE_CONFIDENTIAL => [ AccompanyingPeriodVoter::CONFIDENTIAL_CRUD, From b3d993165d27a3354adbe2c3a65b4e59ebd0ddfd Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 25 Jan 2023 15:10:33 +0100 Subject: [PATCH 251/724] FEATURE: [confidential][voter] bulk assign right should also give right to access confidential parcours --- .../Security/Authorization/AccompanyingPeriodVoter.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php index 9b4976847..436f51792 100644 --- a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php +++ b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php @@ -225,6 +225,10 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH return true; } +/* if ($this->voterHelper->voteOnAttribute(self::REASSIGN_BULK, null, $token)) { + return true; + }*/ + return $token->getUser() === $subject->getUser(); } } From a7dbdc2b9d9bb2a6d7dd8f12ddacb2fd145735aa Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 10 Feb 2023 19:15:09 +0100 Subject: [PATCH 252/724] FEATURE [voter][confidential] voter adapted. repository changes left to do --- .../ReassignAccompanyingPeriodController.php | 6 ++++-- .../DependencyInjection/ChillPersonExtension.php | 8 ++++---- .../Authorization/AccompanyingPeriodVoter.php | 16 +++------------- 3 files changed, 11 insertions(+), 19 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php b/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php index bafc4b1cb..fde9746d3 100644 --- a/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php +++ b/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php @@ -20,6 +20,7 @@ use Chill\MainBundle\Repository\UserRepository; use Chill\MainBundle\Templating\Entity\UserRender; use Chill\PersonBundle\Repository\AccompanyingPeriodACLAwareRepositoryInterface; use Chill\PersonBundle\Repository\AccompanyingPeriodRepository; +use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; use Doctrine\ORM\EntityManagerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Form\CallbackTransformer; @@ -30,6 +31,7 @@ use Symfony\Component\Form\FormFactoryInterface; use Symfony\Component\Form\FormInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Security\Core\Exception\AccessDeniedException; use Symfony\Component\Security\Core\Security; @@ -85,8 +87,8 @@ class ReassignAccompanyingPeriodController extends AbstractController */ public function listAction(Request $request): Response { - if (!$this->security->isGranted('ROLE_USER') || !$this->security->getUser() instanceof User) { - throw new AccessDeniedException(); + if (!$this->security->isGranted(AccompanyingPeriodVoter::REASSIGN_BULK)) { + throw new AccessDeniedHttpException('no right to reassign bulk'); } $form = $this->buildFilterForm(); diff --git a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php index 576e563bd..6fd434635 100644 --- a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php +++ b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php @@ -984,11 +984,11 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac AccompanyingPeriodVoter::DELETE, ], AccompanyingPeriodVoter::REASSIGN_BULK => [ - AccompanyingPeriodVoter::CONFIDENTIAL_CRUD, - AccompanyingPeriodVoter::SEE_CONFIDENTIAL, + AccompanyingPeriodVoter::SEE_CONFIDENTIAL_ALL, + AccompanyingPeriodVoter::TOGGLE_CONFIDENTIAL_ALL, ], - AccompanyingPeriodVoter::TOGGLE_CONFIDENTIAL => [ - AccompanyingPeriodVoter::CONFIDENTIAL_CRUD, + AccompanyingPeriodVoter::TOGGLE_CONFIDENTIAL_ALL => [ + AccompanyingPeriodVoter::SEE_CONFIDENTIAL_ALL, ], ], ]); diff --git a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php index 436f51792..3dd991501 100644 --- a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php +++ b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php @@ -42,11 +42,6 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH self::RE_OPEN_COURSE, ]; - /** - * Give the ability to see all confidential courses. - */ - public const CONFIDENTIAL_CRUD = 'CHILL_PERSON_ACCOMPANYING_PERIOD_CRUD_CONFIDENTIAL'; - public const CREATE = 'CHILL_PERSON_ACCOMPANYING_PERIOD_CREATE'; /** @@ -110,7 +105,7 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH /** * Right to see confidential period even if not referrer */ - public const SEE_CONFIDENTIAL = 'CHILL_PERSON_ACCOMPANYING_PERIOD_SEE_CONFIDENTIAL'; + public const SEE_CONFIDENTIAL_ALL = 'CHILL_PERSON_ACCOMPANYING_PERIOD_SEE_CONFIDENTIAL'; private Security $security; @@ -136,7 +131,6 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH return [ self::SEE, self::SEE_DETAILS, - self::CONFIDENTIAL_CRUD, self::CREATE, self::EDIT, self::DELETE, @@ -154,7 +148,7 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH public function getRolesWithoutScope(): array { - return [self::REASSIGN_BULK]; + return []; } protected function supports($attribute, $subject) @@ -221,14 +215,10 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH // if confidential, only the referent can see it if ($subject->isConfidential()) { - if ($this->voterHelper->voteOnAttribute(self::CONFIDENTIAL_CRUD, $subject, $token)) { + if ($this->voterHelper->voteOnAttribute(self::SEE_CONFIDENTIAL_ALL, $subject, $token)) { return true; } -/* if ($this->voterHelper->voteOnAttribute(self::REASSIGN_BULK, null, $token)) { - return true; - }*/ - return $token->getUser() === $subject->getUser(); } } From dd344aed527df6718ebed27fe089991b4862693e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 4 Jul 2023 15:59:39 +0200 Subject: [PATCH 253/724] Implements right "see confidential course" on method findByPerson Add unit tests for that --- .../Authorization/AuthorizationHelper.php | 4 - ...orizationHelperForCurrentUserInterface.php | 5 +- .../AuthorizationHelperInterface.php | 3 +- .../AccompanyingPeriodController.php | 8 +- .../AccompanyingPeriodACLAwareRepository.php | 119 ++++++---- ...nyingPeriodACLAwareRepositoryInterface.php | 10 +- ...companyingPeriodACLAwareRepositoryTest.php | 206 ++++++++++++++++++ 7 files changed, 306 insertions(+), 49 deletions(-) create mode 100644 src/Bundle/ChillPersonBundle/Tests/Repository/AccompanyingPeriodACLAwareRepositoryTest.php diff --git a/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php b/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php index 1105c9d8a..be884de94 100644 --- a/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php +++ b/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php @@ -195,10 +195,6 @@ class AuthorizationHelper implements AuthorizationHelperInterface /** * Return all reachable scope for a given user, center and role. - * - * @param Center|Center[] $center - * - * @return array|Scope[] */ public function getReachableScopes(UserInterface $user, string $role, Center|array $center): array { diff --git a/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelperForCurrentUserInterface.php b/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelperForCurrentUserInterface.php index f0d3f9fba..54e30c244 100644 --- a/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelperForCurrentUserInterface.php +++ b/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelperForCurrentUserInterface.php @@ -25,7 +25,8 @@ interface AuthorizationHelperForCurrentUserInterface public function getReachableCenters(string $role, ?Scope $scope = null): array; /** - * @param array|Center|Center[] $center + * @param list
      |Center $center + * @return list */ - public function getReachableScopes(string $role, $center): array; + public function getReachableScopes(string $role, array|Center $center): array; } diff --git a/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelperInterface.php b/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelperInterface.php index 1176cf1fa..1dc9668ec 100644 --- a/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelperInterface.php +++ b/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelperInterface.php @@ -26,7 +26,8 @@ interface AuthorizationHelperInterface public function getReachableCenters(UserInterface $user, string $role, ?Scope $scope = null): array; /** - * @param Center|list
      $center + * @param Center|array
      $center + * @return list */ public function getReachableScopes(UserInterface $user, string $role, Center|array $center): array; } diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodController.php index b32454387..8b4c0b27a 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodController.php @@ -219,13 +219,13 @@ class AccompanyingPeriodController extends AbstractController ]); $this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event); - $accompanyingPeriodsRaw = $this->accompanyingPeriodACLAwareRepository - ->findByPerson($person, AccompanyingPeriodVoter::SEE); + $accompanyingPeriods = $this->accompanyingPeriodACLAwareRepository + ->findByPerson($person, AccompanyingPeriodVoter::SEE, ["openingDate" => "DESC", "id" => "DESC"]); - usort($accompanyingPeriodsRaw, static fn ($a, $b) => $b->getOpeningDate() > $a->getOpeningDate()); + //usort($accompanyingPeriodsRaw, static fn ($a, $b) => $b->getOpeningDate() <=> $a->getOpeningDate()); // filter visible or not visible - $accompanyingPeriods = array_filter($accompanyingPeriodsRaw, fn (AccompanyingPeriod $ap) => $this->isGranted(AccompanyingPeriodVoter::SEE, $ap)); + //$accompanyingPeriods = array_filter($accompanyingPeriodsRaw, fn (AccompanyingPeriod $ap) => $this->isGranted(AccompanyingPeriodVoter::SEE, $ap)); return $this->render('@ChillPerson/AccompanyingPeriod/list.html.twig', [ 'accompanying_periods' => $accompanyingPeriods, diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php index 0aaabd05f..104f49ec7 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php @@ -13,54 +13,51 @@ namespace Chill\PersonBundle\Repository; use Chill\MainBundle\Entity\Address; use Chill\MainBundle\Entity\Location; -use Chill\MainBundle\Entity\PostalCode; use Chill\MainBundle\Entity\Scope; use Chill\MainBundle\Entity\User; use Chill\MainBundle\Entity\UserJob; -use Chill\MainBundle\Security\Authorization\AuthorizationHelper; -use Chill\MainBundle\Security\Resolver\CenterResolverDispatcherInterface; +use Chill\MainBundle\Security\Authorization\AuthorizationHelperForCurrentUserInterface; +use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation; use Chill\PersonBundle\Entity\Household\PersonHouseholdAddress; use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; use DateTime; - use DateTimeImmutable; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Query\Expr\Join; use Doctrine\ORM\QueryBuilder; +use Repository\AccompanyingPeriodACLAwareRepositoryTest; use Symfony\Component\Security\Core\Security; use function count; -final class AccompanyingPeriodACLAwareRepository implements AccompanyingPeriodACLAwareRepositoryInterface +/** + * @see AccompanyingPeriodACLAwareRepositoryTest + */ +final readonly class AccompanyingPeriodACLAwareRepository implements AccompanyingPeriodACLAwareRepositoryInterface { private AccompanyingPeriodRepository $accompanyingPeriodRepository; - private AuthorizationHelper $authorizationHelper; + private AuthorizationHelperForCurrentUserInterface $authorizationHelper; - private CenterResolverDispatcherInterface $centerResolverDispatcher; + private CenterResolverManagerInterface $centerResolver; private Security $security; public function __construct( AccompanyingPeriodRepository $accompanyingPeriodRepository, Security $security, - AuthorizationHelper $authorizationHelper, - CenterResolverDispatcherInterface $centerResolverDispatcher + AuthorizationHelperForCurrentUserInterface $authorizationHelper, + CenterResolverManagerInterface $centerResolverDispatcher ) { $this->accompanyingPeriodRepository = $accompanyingPeriodRepository; $this->security = $security; $this->authorizationHelper = $authorizationHelper; - $this->centerResolverDispatcher = $centerResolverDispatcher; + $this->centerResolver = $centerResolverDispatcher; } - /** - * @param array|PostalCode[] - * - * @return QueryBuilder - */ - public function buildQueryOpenedAccompanyingCourseByUser(?User $user, array $postalCodes = []) + public function buildQueryOpenedAccompanyingCourseByUser(?User $user, array $postalCodes = []): QueryBuilder { $qb = $this->accompanyingPeriodRepository->createQueryBuilder('ap'); @@ -152,10 +149,14 @@ final class AccompanyingPeriodACLAwareRepository implements AccompanyingPeriodAC ): array { $qb = $this->accompanyingPeriodRepository->createQueryBuilder('ap'); $scopes = $this->authorizationHelper - ->getReachableCircles( - $this->security->getUser(), + ->getReachableScopes( $role, - $this->centerResolverDispatcher->resolveCenter($person) + $this->centerResolver->resolveCenters($person) + ); + $scopesCanSeeConfidential = $this->authorizationHelper + ->getReachableScopes( + AccompanyingPeriodVoter::SEE_CONFIDENTIAL_ALL, + $this->centerResolver->resolveCenters($person) ); if (0 === count($scopes)) { @@ -165,12 +166,42 @@ final class AccompanyingPeriodACLAwareRepository implements AccompanyingPeriodAC $qb ->join('ap.participations', 'participation') ->where($qb->expr()->eq('participation.person', ':person')) - ->andWhere( - $qb->expr()->orX( - 'ap.confidential = FALSE', - $qb->expr()->eq('ap.user', ':user') - ) - ) + ->setParameter('person', $person); + + $qb = $this->addACLClauses($qb, $scopes, $scopesCanSeeConfidential); + $qb = $this->addOrderLimitClauses($qb, $orderBy, $limit, $offset); + + return $qb->getQuery()->getResult(); + } + + public function addOrderLimitClauses(QueryBuilder $qb, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): QueryBuilder + { + if (null !== $orderBy) { + foreach ($orderBy as $field => $order) { + $qb->addOrderBy('ap.' . $field, $order); + } + } + + if (null !== $limit) { + $qb->setMaxResults($limit); + } + + if (null !== $offset) { + $qb->setFirstResult($offset); + } + + return $qb; + } + + /** + * @param QueryBuilder $qb where the accompanying period have the `ap` alias + * @param array $scopesCanSee + * @param array $scopesCanSeeConfidential + * @return QueryBuilder + */ + public function addACLClauses(QueryBuilder $qb, array $scopesCanSee, array $scopesCanSeeConfidential): QueryBuilder + { + $qb ->andWhere( $qb->expr()->orX( $qb->expr()->neq('ap.step', ':draft'), @@ -181,25 +212,44 @@ final class AccompanyingPeriodACLAwareRepository implements AccompanyingPeriodAC ) ) ->setParameter('draft', AccompanyingPeriod::STEP_DRAFT) - ->setParameter('person', $person) ->setParameter('user', $this->security->getUser()) ->setParameter('creator', $this->security->getUser()); + // add join condition for scopes $orx = $qb->expr()->orX( + // even if the scope is not in one authorized, the user can see the course if it is in DRAFT state $qb->expr()->eq('ap.step', ':draft') ); - foreach ($scopes as $key => $scope) { - $orx->add($qb->expr()->orX( + foreach ($scopesCanSee as $key => $scope) { + // for each scope: + // - either the user is the referrer of the course + // - or the accompanying course is one of the reachable scopes + // - and the parcours is not confidential OR the user is the referrer OR the user can see the confidential course + + $orOnScope = $qb->expr()->orX( $qb->expr()->isMemberOf(':scope_' . $key, 'ap.scopes'), $qb->expr()->eq('ap.user', ':user') - )); + ); + + if (in_array($scope, $scopesCanSeeConfidential, true)) { + $orx->add($orOnScope); + } else { + // we must add a condition: the course is not confidential or the user is the referrer + $andXOnScope = $qb->expr()->andX( + $orOnScope, + $qb->expr()->orX( + 'ap.confidential = FALSE', + $qb->expr()->eq('ap.user', ':user') + ) + ); + $orx->add($andXOnScope); + } $qb->setParameter('scope_' . $key, $scope); - $qb->setParameter('user', $this->security->getUser()); } $qb->andWhere($orx); - return $qb->getQuery()->getResult(); + return $qb; } public function findByUnDispatched(array $jobs, array $services, array $administrativeLocations, ?int $limit = null, ?int $offset = null): array @@ -237,9 +287,6 @@ final class AccompanyingPeriodACLAwareRepository implements AccompanyingPeriodAC return $qb->getQuery()->getResult(); } - /** - * @return array|AccompanyingPeriod[] - */ public function findByUserOpenedAccompanyingPeriod(?User $user, array $orderBy = [], int $limit = 0, int $offset = 50): array { if (null === $user) { @@ -261,7 +308,6 @@ final class AccompanyingPeriodACLAwareRepository implements AccompanyingPeriodAC private function addACLByUnDispatched(QueryBuilder $qb): QueryBuilder { $centers = $this->authorizationHelper->getReachableCenters( - $this->security->getUser(), AccompanyingPeriodVoter::SEE ); @@ -273,8 +319,7 @@ final class AccompanyingPeriodACLAwareRepository implements AccompanyingPeriodAC foreach ($centers as $key => $center) { $scopes = $this->authorizationHelper - ->getReachableCircles( - $this->security->getUser(), + ->getReachableScopes( AccompanyingPeriodVoter::SEE, $center ); diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepositoryInterface.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepositoryInterface.php index 0cca1a5f4..ff3d89783 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepositoryInterface.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepositoryInterface.php @@ -33,6 +33,9 @@ interface AccompanyingPeriodACLAwareRepositoryInterface public function countByUserOpenedAccompanyingPeriod(?User $user): int; + /** + * @return array + */ public function findByPerson( Person $person, string $role, @@ -45,14 +48,19 @@ interface AccompanyingPeriodACLAwareRepositoryInterface * @param array|UserJob[] $jobs if empty, does not take this argument into account * @param array|Scope[] $services if empty, does not take this argument into account * - * @return array|AccompanyingPeriod[] + * @return list */ public function findByUnDispatched(array $jobs, array $services, array $administrativeLocations, ?int $limit = null, ?int $offset = null): array; /** * @param array|PostalCode[] $postalCodes + * @return list */ public function findByUserAndPostalCodesOpenedAccompanyingPeriod(?User $user, array $postalCodes, array $orderBy = [], int $limit = 0, int $offset = 50): array; + /** + * @deprecated + * @return list + */ public function findByUserOpenedAccompanyingPeriod(?User $user, array $orderBy = [], int $limit = 0, int $offset = 50): array; } diff --git a/src/Bundle/ChillPersonBundle/Tests/Repository/AccompanyingPeriodACLAwareRepositoryTest.php b/src/Bundle/ChillPersonBundle/Tests/Repository/AccompanyingPeriodACLAwareRepositoryTest.php new file mode 100644 index 000000000..17c12fea5 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Repository/AccompanyingPeriodACLAwareRepositoryTest.php @@ -0,0 +1,206 @@ +accompanyingPeriodRepository = self::$container->get(AccompanyingPeriodRepository::class); + $this->centerResolverManager = self::$container->get(CenterResolverManagerInterface::class); + $this->entityManager = self::$container->get(EntityManagerInterface::class); + $this->scopeRepository = self::$container->get(ScopeRepositoryInterface::class); + $this->registry = self::$container->get(Registry::class); + + } + + public static function tearDownAfterClass(): void + { + self::bootKernel(); + $em = self::$container->get(EntityManagerInterface::class); + $repository = self::$container->get(AccompanyingPeriodRepository::class); + + foreach (self::$periodsIdsToDelete as $id) { + if (null === $period = $repository->find($id)) { + throw new \RuntimeException("period not found while trying to delete it"); + } + + foreach ($period->getParticipations() as $participation) { + $em->remove($participation); + } + $em->remove($period); + } + + $em->flush(); + } + + + /** + * For testing this method, we mock the authorization helper to return different Scope that a user + * can see, or that a user can see confidential periods. + * + * @param array $scopeUserCanSee + * @param array $scopeUserCanSeeConfidential + * @param array $expectedPeriod + * @dataProvider provideDataForFindByPerson + */ + public function testFindByPersonTestUser(User $user, Person $person, array $scopeUserCanSee, array $scopeUserCanSeeConfidential, array $expectedPeriod, string $message): void + { + $security = $this->prophesize(Security::class); + $security->getUser()->willReturn($user); + + $authorizationHelper = $this->prophesize(AuthorizationHelperForCurrentUserInterface::class); + $authorizationHelper->getReachableScopes(AccompanyingPeriodVoter::SEE, Argument::any()) + ->willReturn($scopeUserCanSee); + $authorizationHelper->getReachableScopes(AccompanyingPeriodVoter::SEE_CONFIDENTIAL_ALL, Argument::any()) + ->willReturn($scopeUserCanSeeConfidential); + + $repository = new AccompanyingPeriodACLAwareRepository( + $this->accompanyingPeriodRepository, + $security->reveal(), + $authorizationHelper->reveal(), + $this->centerResolverManager + ); + + $actuals = $repository->findByPerson($person, AccompanyingPeriodVoter::SEE); + $expectedIds = array_map(fn (AccompanyingPeriod $period) => $period->getId(), $expectedPeriod); + + self::assertCount(count($expectedPeriod), $actuals, $message); + foreach ($actuals as $actual) { + self::assertContains($actual->getId(), $expectedIds); + } + } + + public function provideDataForFindByPerson(): iterable + { + $this->setUp(); + + if (null === $user = $this->entityManager->createQuery("SELECT u FROM " . User::class . " u")->setMaxResults(1)->getSingleResult()) { + throw new \RuntimeException("no user found"); + } + + if (null === $anotherUser = $this->entityManager->createQuery("SELECT u FROM " . User::class . " u WHERE u.id != :uid")->setParameter('uid', $user->getId()) + ->setMaxResults(1)->getSingleResult()) { + throw new \RuntimeException("no user found"); + } + + [$person, $anotherPerson, $person2, $person3] = $this->entityManager + ->createQuery("SELECT p FROM " . Person::class . " p WHERE SIZE(p.accompanyingPeriodParticipations) = 0") + ->setMaxResults(4) + ->getResult(); + + if (null === $person || null === $anotherPerson || null === $person2 || null === $person3) { + throw new \RuntimeException("no person found"); + } + + $scopes = $this->scopeRepository->findAll(); + + if (3 > count($scopes)) { + throw new \RuntimeException("not enough scopes for this test"); + } + $scopesCanSee = [ $scopes[0] ]; + $scopesGroup2 = [ $scopes[1] ]; + + // case: a period is in draft state + $period = $this->buildPeriod($person, $scopesCanSee, $user, false); + + yield [$user, $person, $scopesCanSee, [], [$period], "a user can see his period during draft state"]; + + // another user is not allowed to see this period, because it is in DRAFT state + yield [$anotherUser, $person, $scopesCanSee, [], [], "another user is not allowed to see the period of someone else in draft state"]; + + // the period is confirmed + $period = $this->buildPeriod($anotherPerson, $scopesCanSee, $user, true); + + // the other user can now see it + yield [$user, $anotherPerson, $scopesCanSee, [], [$period], "a user see his period when confirmed"]; + yield [$anotherUser, $anotherPerson, $scopesCanSee, [], [$period], "another user with required scopes is allowed to see the period when not draft"]; + yield [$anotherUser, $anotherPerson, $scopesGroup2, [], [], "another user without the required scopes is not allowed to see the period when not draft"]; + + // this period will be confidential + $period = $this->buildPeriod($person2, $scopesCanSee, $user, true); + $period->setConfidential(true)->setUser($user, true); + + yield [$user, $person2, $scopesCanSee, [], [$period], "a user see his period when confirmed and confidential with required scopes"]; + yield [$user, $person2, $scopesGroup2, [], [$period], "a user see his period when confirmed and confidential without required scopes"]; + yield [$anotherUser, $person2, $scopesCanSee, [], [], "a user don't see a confidential period, even if he has required scopes"]; + yield [$anotherUser, $person2, $scopesCanSee, $scopesCanSee, [$period], "a user see the period when confirmed and confidential if he has required scope to see the period"]; + + // period draft with creator = null + $period = $this->buildPeriod($person3, $scopesCanSee, null, false); + yield [$user, $person3, $scopesCanSee, [], [$period], "a user see a period when draft if no creator on the period"]; + $this->entityManager->flush(); + } + + /** + * @param Person $person + * @param array $scopes + * @return AccompanyingPeriod + */ + private function buildPeriod(Person $person, array $scopes, User|null $creator, bool $confirm): AccompanyingPeriod + { + $period = new AccompanyingPeriod(); + $period->addPerson($person); + if (null !== $creator) { + $period->setCreatedBy($creator); + } + + foreach ($scopes as $scope) { + $period->addScope($scope); + } + + $this->entityManager->persist($period); + self::$periodsIdsToDelete[] = $period->getId(); + + if ($confirm) { + $workflow = $this->registry->get($period, 'accompanying_period_lifecycle'); + $workflow->apply($period, 'confirm'); + } + + return $period; + } +} From 3e63b4abf30736c41afccb7af97fd259f3bfb6cb Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Tue, 4 Jul 2023 16:42:56 +0200 Subject: [PATCH 254/724] UX: improve FilterOrder box design --- .../translations/messages.fr.yml | 2 + .../Form/Type/Listing/FilterOrderType.php | 3 + .../Resources/public/chill/scss/forms.scss | 12 +++ .../views/FilterOrder/base.html.twig | 81 ++++++++----------- 4 files changed, 50 insertions(+), 48 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/translations/messages.fr.yml b/src/Bundle/ChillActivityBundle/translations/messages.fr.yml index c53a04f31..d37b3488f 100644 --- a/src/Bundle/ChillActivityBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillActivityBundle/translations/messages.fr.yml @@ -96,6 +96,8 @@ activity_filter: My activities: Mes échanges (où j'interviens) Types: Par type d'échange Jobs: Par métier impliqué + By: Filtrer par + Search: Chercher dans la liste #timeline '%user% has done an %activity_type%': '%user% a effectué un échange de type "%activity_type%"' diff --git a/src/Bundle/ChillMainBundle/Form/Type/Listing/FilterOrderType.php b/src/Bundle/ChillMainBundle/Form/Type/Listing/FilterOrderType.php index 16038515d..1f373400c 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/Listing/FilterOrderType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/Listing/FilterOrderType.php @@ -38,6 +38,9 @@ final class FilterOrderType extends \Symfony\Component\Form\AbstractType $builder->add('q', SearchType::class, [ 'label' => false, 'required' => false, + 'attr' => [ + 'placeholder' => 'activity_filter.Search', + ] ]); } diff --git a/src/Bundle/ChillMainBundle/Resources/public/chill/scss/forms.scss b/src/Bundle/ChillMainBundle/Resources/public/chill/scss/forms.scss index 0ae568244..cd81f36dc 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/chill/scss/forms.scss +++ b/src/Bundle/ChillMainBundle/Resources/public/chill/scss/forms.scss @@ -42,3 +42,15 @@ form { font-weight: 700; margin-bottom: .375em; } + +.chill_filter_order { + background: $gray-100; /* + border: 3px dashed $white; + background: repeating-linear-gradient( + -45deg, + $gray-100, + $gray-100 2px, + $white 2px, + $white 6px + ); */ +} \ No newline at end of file diff --git a/src/Bundle/ChillMainBundle/Resources/views/FilterOrder/base.html.twig b/src/Bundle/ChillMainBundle/Resources/views/FilterOrder/base.html.twig index d4a6bbdd4..8faef5d14 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/FilterOrder/base.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/FilterOrder/base.html.twig @@ -1,102 +1,87 @@ {{ form_start(form) }} -
      -
      + {% set btnSubmit = 0 %} +
      +
      {% if form.vars.has_search_box %} -
      -
      - {{ form_widget(form.q)}} - +
      +
      + {{ form_widget(form.q) }} +
      {% endif %}
      {% if form.dateRanges is defined %} + {% set btnSubmit = 1 %} {% if form.dateRanges|length > 0 %} {% for dateRangeName, _o in form.dateRanges %} -
      +
      {% if form.dateRanges[dateRangeName].vars.label is not same as(false) %} -
      {{ form_label(form.dateRanges[dateRangeName])}} -
      {% endif %} -
      -
      +
      +
      {{ 'chill_calendar.From'|trans }} {{ form_widget(form.dateRanges[dateRangeName]['from']) }} {{ 'chill_calendar.To'|trans }} {{ form_widget(form.dateRanges[dateRangeName]['to']) }}
      -
      - -
      {% endfor %} {% endif %} {% endif %} {% if form.checkboxes is defined %} + {% set btnSubmit = 1 %} {% if form.checkboxes|length > 0 %} {% for checkbox_name, options in form.checkboxes %} -
      -
      +
      +
      {{ 'activity_filter.By'|trans }}
      +
      {% for c in form['checkboxes'][checkbox_name].children %} -
      - {{ form_widget(c) }} - {{ form_label(c) }} -
      + {{ form_widget(c) }} + {{ form_label(c) }} {% endfor %}
      - {% if loop.last %} -
      -
      -
        -
      • - -
      • -
      -
      -
      - {% endif %} {% endfor %} {% endif %} {% endif %} {% if form.entity_choices is defined %} + {% set btnSubmit = 1 %} {% if form.entity_choices |length > 0 %} {% for checkbox_name, options in form.entity_choices %} -
      +
      {% if form.entity_choices[checkbox_name].vars.label is not same as(false) %} -
      - {{ form_label(form.entity_choices[checkbox_name])}} -
      + {{ form_label(form.entity_choices[checkbox_name])}} {% endif %} -
      +
      {% for c in form['entity_choices'][checkbox_name].children %} -
      - {{ form_widget(c) }} - {{ form_label(c) }} -
      + {{ form_widget(c) }} + {{ form_label(c) }} {% endfor %}
      -
      - -
      {% endfor %} {% endif %} {% endif %} {% if form.single_checkboxes is defined %} + {% set btnSubmit = 1 %} {% for name, _o in form.single_checkboxes %} -
      -
      +
      +
      {{ 'activity_filter.By'|trans }}
      +
      {{ form_widget(form.single_checkboxes[name]) }}
      -
      - -
      {% endfor %} {% endif %} + + {% if btnSubmit == 1 %} +
      + +
      + {% endif %}
      {% for k,v in otherParameters %} From a56370d8519af48dc217ee48d789ceab136cacb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 4 Jul 2023 16:00:09 +0200 Subject: [PATCH 255/724] DX: fix phpstan issues with more strict type hinting in AuthorizationHelperInterface --- .../Timeline/TimelineActivityProvider.php | 1 + .../Service/DocGenerator/PersonContext.php | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Timeline/TimelineActivityProvider.php b/src/Bundle/ChillActivityBundle/Timeline/TimelineActivityProvider.php index dad597676..2c9272b08 100644 --- a/src/Bundle/ChillActivityBundle/Timeline/TimelineActivityProvider.php +++ b/src/Bundle/ChillActivityBundle/Timeline/TimelineActivityProvider.php @@ -161,6 +161,7 @@ class TimelineActivityProvider implements TimelineProviderInterface // loop on reachable scopes foreach ($reachableScopes as $scope) { + /** @phpstan-ignore-next-line */ if (in_array($scope->getId(), $scopes_ids, true)) { continue; } diff --git a/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php b/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php index 9d7f1cdd5..5b5773922 100644 --- a/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php +++ b/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php @@ -360,10 +360,12 @@ final class PersonContext implements PersonContextInterface private function isScopeNecessary(Person $person): bool { - if ($this->showScopes && 1 < $this->authorizationHelper->getReachableScopes( - $this->security->getUser(), - PersonDocumentVoter::CREATE, - $this->centerResolverManager->resolveCenters($person) + if ($this->showScopes && 1 < count( + $this->authorizationHelper->getReachableScopes( + $this->security->getUser(), + PersonDocumentVoter::CREATE, + $this->centerResolverManager->resolveCenters($person) + ) )) { return true; } From 7f9738975cd6690b20ea7c886562342994c9c5f3 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Tue, 4 Jul 2023 17:53:08 +0200 Subject: [PATCH 256/724] UX: improve FilterOrder box design --- src/Bundle/ChillActivityBundle/translations/messages.fr.yml | 1 + .../Resources/views/FilterOrder/base.html.twig | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillActivityBundle/translations/messages.fr.yml b/src/Bundle/ChillActivityBundle/translations/messages.fr.yml index d37b3488f..3099e99b0 100644 --- a/src/Bundle/ChillActivityBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillActivityBundle/translations/messages.fr.yml @@ -98,6 +98,7 @@ activity_filter: Jobs: Par métier impliqué By: Filtrer par Search: Chercher dans la liste + By date: Filtrer par date #timeline '%user% has done an %activity_type%': '%user% a effectué un échange de type "%activity_type%"' diff --git a/src/Bundle/ChillMainBundle/Resources/views/FilterOrder/base.html.twig b/src/Bundle/ChillMainBundle/Resources/views/FilterOrder/base.html.twig index 8faef5d14..b2673b60c 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/FilterOrder/base.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/FilterOrder/base.html.twig @@ -18,8 +18,10 @@
      {% if form.dateRanges[dateRangeName].vars.label is not same as(false) %} {{ form_label(form.dateRanges[dateRangeName])}} + {% else %} +
      {{ 'activity_filter.By date'|trans }}
      {% endif %} -
      +
      {{ 'chill_calendar.From'|trans }} {{ form_widget(form.dateRanges[dateRangeName]['from']) }} From 145c1df313e0328830fe406c12b1afcf03b070dd Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Wed, 5 Jul 2023 09:43:13 +0200 Subject: [PATCH 257/724] cleaning --- .../Resources/public/chill/scss/forms.scss | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Resources/public/chill/scss/forms.scss b/src/Bundle/ChillMainBundle/Resources/public/chill/scss/forms.scss index cd81f36dc..a517a5516 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/chill/scss/forms.scss +++ b/src/Bundle/ChillMainBundle/Resources/public/chill/scss/forms.scss @@ -44,13 +44,5 @@ form { } .chill_filter_order { - background: $gray-100; /* - border: 3px dashed $white; - background: repeating-linear-gradient( - -45deg, - $gray-100, - $gray-100 2px, - $white 2px, - $white 6px - ); */ + background: $gray-100; } \ No newline at end of file From 25d4b6acbb2b5d547abb38072f69da7f764e4141 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 5 Jul 2023 10:54:37 +0200 Subject: [PATCH 258/724] [FEATURE] allow adding of user filters in filter order - template still to be done --- .../Form/Type/Listing/FilterOrderType.php | 30 ++++++++++++++++++ .../Templating/Listing/FilterOrderHelper.php | 31 ++++++++++++++++++- .../Listing/FilterOrderHelperBuilder.php | 23 ++++++++++++++ 3 files changed, 83 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillMainBundle/Form/Type/Listing/FilterOrderType.php b/src/Bundle/ChillMainBundle/Form/Type/Listing/FilterOrderType.php index 16038515d..9aebab144 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/Listing/FilterOrderType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/Listing/FilterOrderType.php @@ -12,6 +12,7 @@ declare(strict_types=1); namespace Chill\MainBundle\Form\Type\Listing; use Chill\MainBundle\Form\Type\ChillDateType; +use Chill\MainBundle\Form\Type\PickUserDynamicType; use Chill\MainBundle\Templating\Listing\FilterOrderHelper; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\Extension\Core\Type\CheckboxType; @@ -120,6 +121,35 @@ final class FilterOrderType extends \Symfony\Component\Form\AbstractType $builder->add($singleCheckBoxBuilder); } + + if ([] !== $helper->getUserPickers()) { + $userPickersBuilder = $builder->create('userPicker', null, ['compound' => true]); + + foreach ($helper->getUserPickers() as $name => [ + 'label' => $label, 'options' => $options + ]) { + $userPicker = $userPickersBuilder->create($name, null, [ + 'compound' => true, + 'label' => $label, + ]); + + $userPicker->add( + $name, + PickUserDynamicType::class, + [ + 'multiple' => true, + 'label' => $label, + ...$options, + ] + ); + + + $userPickersBuilder->add($userPicker); + } + + $builder->add($userPickersBuilder); + } + } public function buildView(FormView $view, FormInterface $form, array $options) diff --git a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php index 28cc8e331..f12c23299 100644 --- a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php +++ b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php @@ -52,6 +52,11 @@ class FilterOrderHelper */ private array $entityChoices = []; + /** + * @var array + */ + private array $userPickers = []; + public function __construct( FormFactoryInterface $formFactory, RequestStack $requestStack @@ -82,6 +87,14 @@ class FilterOrderHelper return $this->entityChoices; } + public function addUserPickers(string $name, ?string $label = null, array $options = []): self + { + $this->userPickers[$name] = ['label' => $label, 'options' => $options]; + + return $this; + } + + public function addCheckbox(string $name, array $choices, ?array $default = [], ?array $trans = [], array $options = []): self { $missing = count($choices) - count($trans) - 1; @@ -116,6 +129,16 @@ class FilterOrderHelper ->handleRequest($this->requestStack->getCurrentRequest()); } + public function getUserPickers(): array + { + return $this->userPickers; + } + + public function getUserPickerData(string $name): array + { + return $this->getFormData()['userPickers'][$name]; + } + public function getCheckboxData(string $name): array { return $this->getFormData()['checkboxes'][$name]; @@ -180,7 +203,8 @@ class FilterOrderHelper 'checkboxes' => [], 'dateRanges' => [], 'single_checkboxes' => [], - 'entity_choices' => [] + 'entity_choices' => [], + 'user_pickers' => [] ]; if ($this->hasSearchBox()) { @@ -204,7 +228,12 @@ class FilterOrderHelper $r['entity_choices'][$name] = ($c['options']['multiple'] ?? true) ? [] : null; } + foreach ($this->userPickers as $name => $u) { + $r['user_pickers'][$name] = ($u['options']['multiple'] ?? true) ? [] : null; + } + return $r; + } private function getFormData(): array diff --git a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperBuilder.php b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperBuilder.php index e176e27c6..6fd0eeb42 100644 --- a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperBuilder.php +++ b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperBuilder.php @@ -37,6 +37,11 @@ class FilterOrderHelperBuilder */ private array $entityChoices = []; + /** + * @var array + */ + private array $userPickers = []; + public function __construct( FormFactoryInterface $formFactory, RequestStack $requestStack @@ -83,6 +88,13 @@ class FilterOrderHelperBuilder return $this; } + public function addUserPickers(string $name, ?string $label = null, ?array $options = []): self + { + $this->userPickers[$name] = ['label' => $label, 'options' => $options]; + + return $this; + } + public function build(): FilterOrderHelper { $helper = new FilterOrderHelper( @@ -124,6 +136,17 @@ class FilterOrderHelperBuilder $helper->addDateRange($name, $label, $from, $to); } + + foreach ( + $this->userPickers as $name => [ + 'label' => $label, + 'options' => $options + ] + ) { + $helper->addUserPickers($name, $label, $options); + } + + return $helper; } } From 0d626fb3459a0b30e847b315618851e203db68ef Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 5 Jul 2023 10:55:30 +0200 Subject: [PATCH 259/724] [FEATURE] implement user filter in orderFilterHelper for tasks --- src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php | 2 ++ .../Resources/views/SingleTask/List/index.html.twig | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php index 2ba9488b6..58d2a406e 100644 --- a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php +++ b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php @@ -299,6 +299,7 @@ final class SingleTaskController extends AbstractController $this->denyAccessUnlessGranted(TaskVoter::SHOW, null); $filterOrder = $this->buildFilterOrder(); + $flags = array_merge( $filterOrder->getCheckboxData('status'), array_map(static fn ($i) => 'state_' . $i, $filterOrder->getCheckboxData('states')) @@ -680,6 +681,7 @@ final class SingleTaskController extends AbstractController ->addSearchBox() ->addCheckbox('status', $statuses, $statuses, $statusTrans) ->addCheckbox('states', $states, ['new', 'in_progress']) + ->addUserPickers('userPicker', 'userPicker', ['multiple' => True]) ->build(); } diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/List/index.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/List/index.html.twig index 8fe45959e..b479eb948 100644 --- a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/List/index.html.twig +++ b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/List/index.html.twig @@ -27,8 +27,10 @@ {% block css %} {{ parent() }} {{ encore_entry_link_tags('page_task_list') }} + {{ encore_entry_link_tags('mod_pickentity_type') }} {% endblock %} {% block js %} {{ parent() }} {{ encore_entry_script_tags('page_task_list') }} + {{ encore_entry_script_tags('mod_pickentity_type') }} {% endblock %} From 4da7040a49b4a05af0e37434052cc1d457806629 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 5 Jul 2023 12:38:42 +0200 Subject: [PATCH 260/724] FEATURE [user filter] implement query. Selecting multiple users doesn't work --- .../Form/Type/Listing/FilterOrderType.php | 2 +- .../views/FilterOrder/base.html.twig | 18 +++++++++++- .../Templating/Listing/FilterOrderHelper.php | 5 ++-- .../Listing/FilterOrderHelperBuilder.php | 4 +-- .../Controller/SingleTaskController.php | 8 +++-- .../SingleTaskAclAwareRepository.php | 29 ++++++++++++++++--- .../SingleTaskAclAwareRepositoryInterface.php | 4 ++- .../translations/messages.fr.yml | 1 + 8 files changed, 58 insertions(+), 13 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Form/Type/Listing/FilterOrderType.php b/src/Bundle/ChillMainBundle/Form/Type/Listing/FilterOrderType.php index a5166e322..c6744f852 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/Listing/FilterOrderType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/Listing/FilterOrderType.php @@ -126,7 +126,7 @@ final class FilterOrderType extends \Symfony\Component\Form\AbstractType } if ([] !== $helper->getUserPickers()) { - $userPickersBuilder = $builder->create('userPicker', null, ['compound' => true]); + $userPickersBuilder = $builder->create('user_pickers', null, ['compound' => true]); foreach ($helper->getUserPickers() as $name => [ 'label' => $label, 'options' => $options diff --git a/src/Bundle/ChillMainBundle/Resources/views/FilterOrder/base.html.twig b/src/Bundle/ChillMainBundle/Resources/views/FilterOrder/base.html.twig index b2673b60c..fa35cdbf3 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/FilterOrder/base.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/FilterOrder/base.html.twig @@ -67,6 +67,22 @@ {% endfor %} {% endif %} {% endif %} + {% if form.user_pickers is defined %} + {% set btnSubmit = 1 %} + {% if form.user_pickers|length > 0 %} + {% for name, options in form.user_pickers %} +
      +
      + {% for p in form['user_pickers'][name].children %} + {{ form_widget(p) }} + {{ form_label(p) }} + {% endfor %} +
      +
      + {% endfor %} + {% endif %} + {% endif %} + {% if form.single_checkboxes is defined %} {% set btnSubmit = 1 %} {% for name, _o in form.single_checkboxes %} @@ -78,7 +94,7 @@
      {% endfor %} {% endif %} - + {% if btnSubmit == 1 %}
      diff --git a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php index bdec463bd..026c55ef6 100644 --- a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php +++ b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php @@ -87,7 +87,7 @@ class FilterOrderHelper return $this->entityChoices; } - public function addUserPickers(string $name, ?string $label = null, array $options = []): self + public function addUserPicker(string $name, ?string $label = null, array $options = []): self { $this->userPickers[$name] = ['label' => $label, 'options' => $options]; @@ -136,7 +136,8 @@ class FilterOrderHelper public function getUserPickerData(string $name): array { - return $this->getFormData()['userPickers'][$name]; + dump($this->getFormData()['user_pickers']); + return $this->getFormData()['user_pickers'][$name]; } public function getCheckboxData(string $name): array diff --git a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperBuilder.php b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperBuilder.php index 6fd0eeb42..86180d06e 100644 --- a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperBuilder.php +++ b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperBuilder.php @@ -88,7 +88,7 @@ class FilterOrderHelperBuilder return $this; } - public function addUserPickers(string $name, ?string $label = null, ?array $options = []): self + public function addUserPicker(string $name, ?string $label = null, ?array $options = []): self { $this->userPickers[$name] = ['label' => $label, 'options' => $options]; @@ -143,7 +143,7 @@ class FilterOrderHelperBuilder 'options' => $options ] ) { - $helper->addUserPickers($name, $label, $options); + $helper->addUserPicker($name, $label, $options); } diff --git a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php index 58d2a406e..e60a58145 100644 --- a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php +++ b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php @@ -300,13 +300,16 @@ final class SingleTaskController extends AbstractController $filterOrder = $this->buildFilterOrder(); + $filteredUsers = $filterOrder->getUserPickerData('userPicker'); + $flags = array_merge( $filterOrder->getCheckboxData('status'), array_map(static fn ($i) => 'state_' . $i, $filterOrder->getCheckboxData('states')) ); $nb = $this->singleTaskAclAwareRepository->countByAllViewable( $filterOrder->getQueryString(), - $flags + $flags, + $filteredUsers ); $paginator = $this->paginatorFactory->create($nb); @@ -314,6 +317,7 @@ final class SingleTaskController extends AbstractController $tasks = $this->singleTaskAclAwareRepository->findByAllViewable( $filterOrder->getQueryString(), $flags, + $filteredUsers, $paginator->getCurrentPageFirstItemNumber(), $paginator->getItemsPerPage(), [ @@ -681,7 +685,7 @@ final class SingleTaskController extends AbstractController ->addSearchBox() ->addCheckbox('status', $statuses, $statuses, $statusTrans) ->addCheckbox('states', $states, ['new', 'in_progress']) - ->addUserPickers('userPicker', 'userPicker', ['multiple' => True]) + ->addUserPicker('userPicker', 'Filter by user', ['multiple' => True, 'required' => False]) ->build(); } diff --git a/src/Bundle/ChillTaskBundle/Repository/SingleTaskAclAwareRepository.php b/src/Bundle/ChillTaskBundle/Repository/SingleTaskAclAwareRepository.php index 0efc16085..ef30a7783 100644 --- a/src/Bundle/ChillTaskBundle/Repository/SingleTaskAclAwareRepository.php +++ b/src/Bundle/ChillTaskBundle/Repository/SingleTaskAclAwareRepository.php @@ -51,7 +51,8 @@ final class SingleTaskAclAwareRepository implements SingleTaskAclAwareRepository public function buildBaseQuery( ?string $pattern = null, - ?array $flags = [] + ?array $flags = [], + ?array $users = [] ): QueryBuilder { $qb = $this->em->createQueryBuilder(); $qb @@ -62,6 +63,24 @@ final class SingleTaskAclAwareRepository implements SingleTaskAclAwareRepository ->setParameter('pattern', '%' . $pattern . '%'); } + if (count($users) > 0) { + $orXUser = $qb->expr()->orX(); + + foreach ($users as $key => $user) { + $orXUser->add( + $qb->expr()->eq('t.assignee', ':user') + ); + + $qb->setParameter('user', $user); + } + + if ($orXUser->count() > 0) { + $qb->andWhere($orXUser); + } + + return $qb; + } + if (count($flags) > 0) { $orXDate = $qb->expr()->orX(); $orXState = $qb->expr()->orX(); @@ -183,9 +202,10 @@ final class SingleTaskAclAwareRepository implements SingleTaskAclAwareRepository public function countByAllViewable( ?string $pattern = null, - ?array $flags = [] + ?array $flags = [], + ?array $users = [] ): int { - $qb = $this->buildBaseQuery($pattern, $flags); + $qb = $this->buildBaseQuery($pattern, $flags, $users); return $this ->addACLGlobal($qb) @@ -231,11 +251,12 @@ final class SingleTaskAclAwareRepository implements SingleTaskAclAwareRepository public function findByAllViewable( ?string $pattern = null, ?array $flags = [], + ?array $users = [], ?int $start = 0, ?int $limit = 50, ?array $orderBy = [] ): array { - $qb = $this->buildBaseQuery($pattern, $flags); + $qb = $this->buildBaseQuery($pattern, $flags, $users); $qb = $this->addACLGlobal($qb); return $this->getResult($qb, $start, $limit, $orderBy); diff --git a/src/Bundle/ChillTaskBundle/Repository/SingleTaskAclAwareRepositoryInterface.php b/src/Bundle/ChillTaskBundle/Repository/SingleTaskAclAwareRepositoryInterface.php index 57c57e592..7d2870c67 100644 --- a/src/Bundle/ChillTaskBundle/Repository/SingleTaskAclAwareRepositoryInterface.php +++ b/src/Bundle/ChillTaskBundle/Repository/SingleTaskAclAwareRepositoryInterface.php @@ -18,7 +18,8 @@ interface SingleTaskAclAwareRepositoryInterface { public function countByAllViewable( ?string $pattern = null, - ?array $flags = [] + ?array $flags = [], + ?array $users = [] ): int; public function countByCourse( @@ -38,6 +39,7 @@ interface SingleTaskAclAwareRepositoryInterface public function findByAllViewable( ?string $pattern = null, ?array $flags = [], + ?array $users = [], ?int $start = 0, ?int $limit = 50, ?array $orderBy = [] diff --git a/src/Bundle/ChillTaskBundle/translations/messages.fr.yml b/src/Bundle/ChillTaskBundle/translations/messages.fr.yml index d437baac2..599ca8640 100644 --- a/src/Bundle/ChillTaskBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillTaskBundle/translations/messages.fr.yml @@ -65,6 +65,7 @@ Not assigned: Aucun utilisateur assigné For person: Pour By: Par Any tasks: Aucune tâche +Filter by user: Filtrer par utilisateur(s) # transitions - default task definition "new": "nouvelle" From 1ee0e8e350381e039f04171019f2a9584394412e Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 5 Jul 2023 13:35:06 +0200 Subject: [PATCH 261/724] DX phpstan and csfixer --- .../Form/Type/Listing/FilterOrderType.php | 13 +++---------- .../Resources/views/FilterOrder/base.html.twig | 12 +++++++----- .../Templating/Listing/FilterOrderHelper.php | 1 - .../Templating/Listing/FilterOrderHelperBuilder.php | 6 +++--- .../Controller/SingleTaskController.php | 2 +- 5 files changed, 14 insertions(+), 20 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Form/Type/Listing/FilterOrderType.php b/src/Bundle/ChillMainBundle/Form/Type/Listing/FilterOrderType.php index c6744f852..4e41a1740 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/Listing/FilterOrderType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/Listing/FilterOrderType.php @@ -129,25 +129,18 @@ final class FilterOrderType extends \Symfony\Component\Form\AbstractType $userPickersBuilder = $builder->create('user_pickers', null, ['compound' => true]); foreach ($helper->getUserPickers() as $name => [ - 'label' => $label, 'options' => $options + 'label' => $label, 'options' => $opts ]) { - $userPicker = $userPickersBuilder->create($name, null, [ - 'compound' => true, - 'label' => $label, - ]); - $userPicker->add( + $userPickersBuilder->add( $name, PickUserDynamicType::class, [ 'multiple' => true, 'label' => $label, - ...$options, + ...$opts, ] ); - - - $userPickersBuilder->add($userPicker); } $builder->add($userPickersBuilder); diff --git a/src/Bundle/ChillMainBundle/Resources/views/FilterOrder/base.html.twig b/src/Bundle/ChillMainBundle/Resources/views/FilterOrder/base.html.twig index fa35cdbf3..9a9a11fbd 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/FilterOrder/base.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/FilterOrder/base.html.twig @@ -69,14 +69,16 @@ {% endif %} {% if form.user_pickers is defined %} {% set btnSubmit = 1 %} - {% if form.user_pickers|length > 0 %} + {% if form.user_pickers.children|length > 0 %} {% for name, options in form.user_pickers %}
      + {% if form.user_pickers[name].vars.label is not same as(false) %} + {{ form_label(form.user_pickers[name]) }} + {% else %} + {{ form_label(form.user_pickers[name].vars.label) }} + {% endif %}
      - {% for p in form['user_pickers'][name].children %} - {{ form_widget(p) }} - {{ form_label(p) }} - {% endfor %} + {{ form_widget(form.user_pickers[name]) }}
      {% endfor %} diff --git a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php index 026c55ef6..8554b4431 100644 --- a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php +++ b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php @@ -136,7 +136,6 @@ class FilterOrderHelper public function getUserPickerData(string $name): array { - dump($this->getFormData()['user_pickers']); return $this->getFormData()['user_pickers'][$name]; } diff --git a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperBuilder.php b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperBuilder.php index 86180d06e..d9a505dee 100644 --- a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperBuilder.php +++ b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperBuilder.php @@ -139,9 +139,9 @@ class FilterOrderHelperBuilder foreach ( $this->userPickers as $name => [ - 'label' => $label, - 'options' => $options - ] + 'label' => $label, + 'options' => $options + ] ) { $helper->addUserPicker($name, $label, $options); } diff --git a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php index e60a58145..22e49704f 100644 --- a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php +++ b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php @@ -685,7 +685,7 @@ final class SingleTaskController extends AbstractController ->addSearchBox() ->addCheckbox('status', $statuses, $statuses, $statusTrans) ->addCheckbox('states', $states, ['new', 'in_progress']) - ->addUserPicker('userPicker', 'Filter by user', ['multiple' => True, 'required' => False]) + ->addUserPicker('userPicker', 'Filter by user', ['multiple' => true, 'required' => false]) ->build(); } From 4e934653be7641605ac52070e3529663c78e00f7 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 5 Jul 2023 14:12:43 +0200 Subject: [PATCH 262/724] DX changie added --- .changes/unreleased/Feature-20230705-140336.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changes/unreleased/Feature-20230705-140336.yaml diff --git a/.changes/unreleased/Feature-20230705-140336.yaml b/.changes/unreleased/Feature-20230705-140336.yaml new file mode 100644 index 000000000..3ce7f3c0f --- /dev/null +++ b/.changes/unreleased/Feature-20230705-140336.yaml @@ -0,0 +1,5 @@ +kind: Feature +body: Allow filtering on the basis of a user within general tasks list +time: 2023-07-05T14:03:36.664880092+02:00 +custom: + Issue: "" From 52d51264bab3a096be592a8df31f83e3f0b4dca4 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 5 Jul 2023 14:57:28 +0200 Subject: [PATCH 263/724] FIX [query][user filter] avoid replacement of user parameter in query --- .../Repository/SingleTaskAclAwareRepository.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillTaskBundle/Repository/SingleTaskAclAwareRepository.php b/src/Bundle/ChillTaskBundle/Repository/SingleTaskAclAwareRepository.php index ef30a7783..d1652cc89 100644 --- a/src/Bundle/ChillTaskBundle/Repository/SingleTaskAclAwareRepository.php +++ b/src/Bundle/ChillTaskBundle/Repository/SingleTaskAclAwareRepository.php @@ -68,10 +68,10 @@ final class SingleTaskAclAwareRepository implements SingleTaskAclAwareRepository foreach ($users as $key => $user) { $orXUser->add( - $qb->expr()->eq('t.assignee', ':user') + $qb->expr()->eq('t.assignee', ':user_' . $key) ); - $qb->setParameter('user', $user); + $qb->setParameter('user_' . $key, $user); } if ($orXUser->count() > 0) { From 4b25970ce0a43e82531280940c6507da8f071b41 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 5 Jul 2023 15:35:13 +0200 Subject: [PATCH 264/724] FEATURE [filter] start implementation of social action filter --- .../AccompanyingCourseWorkController.php | 38 ++++++++++++++++++- .../AccompanyingPeriodWorkRepository.php | 2 +- .../translations/messages.fr.yml | 3 ++ 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php index 8d15ca30f..75d0bae7c 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php @@ -11,9 +11,14 @@ declare(strict_types=1); namespace Chill\PersonBundle\Controller; +use Chill\MainBundle\Entity\UserJob; use Chill\MainBundle\Pagination\PaginatorFactory; +use Chill\MainBundle\Templating\Listing\FilterOrderHelper; +use Chill\MainBundle\Templating\TranslatableStringHelperInterface; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork; +use Chill\PersonBundle\Entity\Person; +use Chill\PersonBundle\Entity\SocialWork\SocialAction; use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodWorkVoter; use Psr\Log\LoggerInterface; @@ -38,18 +43,22 @@ class AccompanyingCourseWorkController extends AbstractController private AccompanyingPeriodWorkRepository $workRepository; + private TranslatableStringHelperInterface $translatableStringHelper; + public function __construct( TranslatorInterface $trans, SerializerInterface $serializer, AccompanyingPeriodWorkRepository $workRepository, PaginatorFactory $paginator, - LoggerInterface $chillLogger + LoggerInterface $chillLogger, + TranslatableStringHelperInterface $translatableStringHelper ) { $this->trans = $trans; $this->serializer = $serializer; $this->workRepository = $workRepository; $this->paginator = $paginator; $this->chillLogger = $chillLogger; + $this->translatableStringHelper = $translatableStringHelper; } /** @@ -162,11 +171,21 @@ class AccompanyingCourseWorkController extends AbstractController { $this->denyAccessUnlessGranted(AccompanyingPeriodWorkVoter::SEE, $period); + $filter = $this->buildFilterOrder($period); + + $filterData = [ + 'types' => $filter->getEntityChoiceData('typesFilter'), + 'before' => $filter->getDateRangeData('dateFilter')['to'], + 'after' => $filter->getDateRangeData('dateFilter')['from'], + 'user' => $filter->getUserPickerData('userFilter') + ]; + $totalItems = $this->workRepository->countByAccompanyingPeriod($period); $paginator = $this->paginator->create($totalItems); $works = $this->workRepository->findByAccompanyingPeriodOpenFirst( $period, + $filterData, $paginator->getItemsPerPage(), $paginator->getCurrentPageFirstItemNumber() ); @@ -210,4 +229,21 @@ class AccompanyingCourseWorkController extends AbstractController ->add('submit', SubmitType::class, ['label' => 'Delete']) ->getForm(); } + + private function buildFilterOrder($associatedPeriod): FilterOrderHelper + { + + $filterBuilder = $this->filterOrderHelperFactory->create(self::class); + $types = $this->workRepository->findByAccompanyingPeriod($associatedPeriod); + + $filterBuilder + ->addDateRange('dateFilter', 'accompanying_course_work.date_filter') + ->addEntityChoice('typesFilter', 'accompanying_course_work.types_filter', \Chill\PersonBundle\Entity\SocialAction::class, $types, [ + 'choice_label' => fn (SocialAction $sa) => $this->translatableStringHelper->localize($sa->getTitle()) + ]) + ->addUserPicker('userFilter', 'accompanying_course_work.user_filter') + ; + + return $filterBuilder->build(); + } } diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php index bf2d34aae..1bd9b0f4e 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php @@ -96,7 +96,7 @@ final class AccompanyingPeriodWorkRepository implements ObjectRepository * * @return AccompanyingPeriodWork[] */ - public function findByAccompanyingPeriodOpenFirst(AccompanyingPeriod $period, int $limit = 10, int $offset = 0): array + public function findByAccompanyingPeriodOpenFirst(AccompanyingPeriod $period, $filters, int $limit = 10, int $offset = 0): array { $rsm = new ResultSetMappingBuilder($this->em); $rsm->addRootEntityFromClassMetadata(AccompanyingPeriodWork::class, 'w'); diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 01383c050..f783c403e 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -912,6 +912,9 @@ accompanying_course_work: social_evaluation: Évaluation private_comment: Commentaire privé timeSpent: Temps de rédaction + date_filter: Filtrer par date + types_filter: Filtrer par type d'action + user_filter: Filtrer par intervenant # From 6c58e7eb3e13a3421250263f69043740787e0c8d Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 5 Jul 2023 15:49:50 +0200 Subject: [PATCH 265/724] DX phpstan and cs-fixer --- .../AccompanyingCourseWorkController.php | 34 +++++-------------- .../AccompanyingPeriodWorkRepository.php | 1 + 2 files changed, 10 insertions(+), 25 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php index 75d0bae7c..9abf1677d 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php @@ -14,6 +14,7 @@ namespace Chill\PersonBundle\Controller; use Chill\MainBundle\Entity\UserJob; use Chill\MainBundle\Pagination\PaginatorFactory; use Chill\MainBundle\Templating\Listing\FilterOrderHelper; +use Chill\MainBundle\Templating\Listing\FilterOrderHelperFactoryInterface; use Chill\MainBundle\Templating\TranslatableStringHelperInterface; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork; @@ -33,32 +34,15 @@ use Symfony\Contracts\Translation\TranslatorInterface; class AccompanyingCourseWorkController extends AbstractController { - private LoggerInterface $chillLogger; - - private PaginatorFactory $paginator; - - private SerializerInterface $serializer; - - private TranslatorInterface $trans; - - private AccompanyingPeriodWorkRepository $workRepository; - - private TranslatableStringHelperInterface $translatableStringHelper; - public function __construct( - TranslatorInterface $trans, - SerializerInterface $serializer, - AccompanyingPeriodWorkRepository $workRepository, - PaginatorFactory $paginator, - LoggerInterface $chillLogger, - TranslatableStringHelperInterface $translatableStringHelper + private readonly TranslatorInterface $trans, + private readonly SerializerInterface $serializer, + private readonly AccompanyingPeriodWorkRepository $workRepository, + private readonly PaginatorFactory $paginator, + private readonly LoggerInterface $chillLogger, + private readonly TranslatableStringHelperInterface $translatableStringHelper, + private readonly FilterOrderHelperFactoryInterface $filterOrderHelperFactory ) { - $this->trans = $trans; - $this->serializer = $serializer; - $this->workRepository = $workRepository; - $this->paginator = $paginator; - $this->chillLogger = $chillLogger; - $this->translatableStringHelper = $translatableStringHelper; } /** @@ -238,7 +222,7 @@ class AccompanyingCourseWorkController extends AbstractController $filterBuilder ->addDateRange('dateFilter', 'accompanying_course_work.date_filter') - ->addEntityChoice('typesFilter', 'accompanying_course_work.types_filter', \Chill\PersonBundle\Entity\SocialAction::class, $types, [ + ->addEntityChoice('typesFilter', 'accompanying_course_work.types_filter', \Chill\PersonBundle\Entity\SocialWork\SocialAction::class, $types, [ 'choice_label' => fn (SocialAction $sa) => $this->translatableStringHelper->localize($sa->getTitle()) ]) ->addUserPicker('userFilter', 'accompanying_course_work.user_filter') diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php index 1bd9b0f4e..60a00e12a 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php @@ -95,6 +95,7 @@ final class AccompanyingPeriodWorkRepository implements ObjectRepository * * then, closed works * * @return AccompanyingPeriodWork[] + * @param mixed $filters */ public function findByAccompanyingPeriodOpenFirst(AccompanyingPeriod $period, $filters, int $limit = 10, int $offset = 0): array { From 61982634a6203875f6bcaf0fd30fd454db204729 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 5 Jul 2023 16:05:51 +0200 Subject: [PATCH 266/724] FEATURE add filter to the template --- .../Controller/AccompanyingCourseWorkController.php | 3 ++- .../Resources/views/AccompanyingCourseWork/index.html.twig | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php index 9abf1677d..1f2680f9e 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php @@ -178,6 +178,7 @@ class AccompanyingCourseWorkController extends AbstractController 'accompanyingCourse' => $period, 'works' => $works, 'paginator' => $paginator, + 'filter' => $filter ]); } @@ -225,7 +226,7 @@ class AccompanyingCourseWorkController extends AbstractController ->addEntityChoice('typesFilter', 'accompanying_course_work.types_filter', \Chill\PersonBundle\Entity\SocialWork\SocialAction::class, $types, [ 'choice_label' => fn (SocialAction $sa) => $this->translatableStringHelper->localize($sa->getTitle()) ]) - ->addUserPicker('userFilter', 'accompanying_course_work.user_filter') + ->addUserPicker('userFilter', 'accompanying_course_work.user_filter', ['required' => false]) ; return $filterBuilder->build(); diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/index.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/index.html.twig index ab1989f63..1cedfa694 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/index.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/index.html.twig @@ -5,18 +5,23 @@ {% block js %} {{ parent() }} {{ encore_entry_script_tags('mod_entity_workflow_pick') }} + {{ encore_entry_script_tags('mod_pickentity_type') }} {% endblock %} {% block css %} {{ parent() }} {{ encore_entry_link_tags('mod_entity_workflow_pick') }} + {{ encore_entry_link_tags('mod_pickentity_type') }} {% endblock %} + {% block content %}

      {{ block('title') }}

      + {{ filter|chill_render_filter_order_helper }} + {% if works|length == 0 %}

      {{ 'accompanying_course_work.Any work'|trans }}

      {% else %} From a990591e0cadcb5d2f70b61ab9c60df5c8a88036 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 5 Jul 2023 16:23:14 +0200 Subject: [PATCH 267/724] handle right to see confidential course on regulation list --- ...mpanyingPeriodRegulationListController.php | 1 + .../AccompanyingPeriodACLAwareRepository.php | 122 ++++++++++----- ...nyingPeriodACLAwareRepositoryInterface.php | 2 +- ...companyingPeriodACLAwareRepositoryTest.php | 141 +++++++++++++++++- 4 files changed, 229 insertions(+), 37 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodRegulationListController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodRegulationListController.php index 6bbb6c368..cd550ef59 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodRegulationListController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingPeriodRegulationListController.php @@ -78,6 +78,7 @@ class AccompanyingPeriodRegulationListController $form['jobs']->getData(), $form['services']->getData(), $form['locations']->getData(), + ['openingDate' => 'DESC', 'id' => 'DESC'], $paginator->getItemsPerPage(), $paginator->getCurrentPageFirstItemNumber() ); diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php index 104f49ec7..e62e2b3ac 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php @@ -12,6 +12,7 @@ declare(strict_types=1); namespace Chill\PersonBundle\Repository; use Chill\MainBundle\Entity\Address; +use Chill\MainBundle\Entity\Center; use Chill\MainBundle\Entity\Location; use Chill\MainBundle\Entity\Scope; use Chill\MainBundle\Entity\User; @@ -26,6 +27,8 @@ use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; use DateTime; use DateTimeImmutable; use Doctrine\DBAL\Types\Types; +use Doctrine\ORM\NonUniqueResultException; +use Doctrine\ORM\NoResultException; use Doctrine\ORM\Query\Expr\Join; use Doctrine\ORM\QueryBuilder; use Repository\AccompanyingPeriodACLAwareRepositoryTest; @@ -107,9 +110,16 @@ final readonly class AccompanyingPeriodACLAwareRepository implements Accompanyin return $qb; } + /** + * @throws NonUniqueResultException + * @throws NoResultException + */ public function countByUnDispatched(array $jobs, array $services, array $administrativeLocations): int { - $qb = $this->addACLByUnDispatched($this->buildQueryUnDispatched($jobs, $services, $administrativeLocations)); + $qb = $this->addACLByUnDispatched( + $this->buildQueryUnDispatched($jobs, $services, $administrativeLocations), + $this->buildCenterOnScope() + ); $qb->select('COUNT(ap)'); @@ -194,6 +204,8 @@ final readonly class AccompanyingPeriodACLAwareRepository implements Accompanyin } /** + * Add clause for scope on a query, based on no + * * @param QueryBuilder $qb where the accompanying period have the `ap` alias * @param array $scopesCanSee * @param array $scopesCanSeeConfidential @@ -252,19 +264,27 @@ final readonly class AccompanyingPeriodACLAwareRepository implements Accompanyin return $qb; } - public function findByUnDispatched(array $jobs, array $services, array $administrativeLocations, ?int $limit = null, ?int $offset = null): array + public function buildCenterOnScope(): array { - $qb = $this->addACLByUnDispatched($this->buildQueryUnDispatched($jobs, $services, $administrativeLocations)); + $centerOnScopes = []; + foreach ($this->authorizationHelper->getReachableCenters(AccompanyingPeriodVoter::SEE) as $center) { + $centerOnScopes[] = [ + 'center' => $center, + 'scopeOnRole' => $this->authorizationHelper->getReachableScopes(AccompanyingPeriodVoter::SEE, $center), + 'scopeCanSeeConfidential' => $this->authorizationHelper->getReachableScopes(AccompanyingPeriodVoter::SEE_CONFIDENTIAL_ALL, $center), + ]; + } + return $centerOnScopes; + } + + public function findByUnDispatched(array $jobs, array $services, array $administrativeAdministrativeLocations, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array + { + $qb = $this->buildQueryUnDispatched($jobs, $services, $administrativeAdministrativeLocations); $qb->select('ap'); - if (null !== $limit) { - $qb->setMaxResults($limit); - } - - if (null !== $offset) { - $qb->setFirstResult($offset); - } + $qb = $this->addACLByUnDispatched($qb, $this->buildCenterOnScope(), false); + $qb = $this->addOrderLimitClauses($qb, $orderBy, $limit, $offset); return $qb->getQuery()->getResult(); } @@ -305,41 +325,73 @@ final readonly class AccompanyingPeriodACLAwareRepository implements Accompanyin return $qb->getQuery()->getResult(); } - private function addACLByUnDispatched(QueryBuilder $qb): QueryBuilder + /** + * @param QueryBuilder $qb + * @param list, scopeCanSeeConfidential: list}> $centerScopes + * @param bool $allowNoCenter if true, will allow to see the periods linked to person which does not have any center. Very few edge case when some Person are not associated to a center. + * @return QueryBuilder + */ + public function addACLByUnDispatched(QueryBuilder $qb, array $centerScopes, bool $allowNoCenter = false): QueryBuilder { - $centers = $this->authorizationHelper->getReachableCenters( - AccompanyingPeriodVoter::SEE - ); + $user = $this->security->getUser(); - $orX = $qb->expr()->orX(); - - if (0 === count($centers)) { + if (0 === count($centerScopes) || !$user instanceof User) { return $qb->andWhere("'FALSE' = 'TRUE'"); } - foreach ($centers as $key => $center) { - $scopes = $this->authorizationHelper - ->getReachableScopes( - AccompanyingPeriodVoter::SEE, - $center - ); + $orX = $qb->expr()->orX(); + $idx = 0; + foreach ($centerScopes as ['center' => $center, 'scopeOnRole' => $scopes, 'scopeCanSeeConfidential' => $scopesCanSeeConfidential]) { $and = $qb->expr()->andX( - $qb->expr()->exists('SELECT part FROM ' . AccompanyingPeriodParticipation::class . ' part ' . - "JOIN part.person p WHERE part.accompanyingPeriod = ap.id AND p.center = :center_{$key}") + $qb->expr()->exists( + 'SELECT 1 FROM ' . AccompanyingPeriodParticipation::class . " part_{$idx} " . + "JOIN part_{$idx}.person p{$idx} LEFT JOIN p{$idx}.centerCurrent centerCurrent_{$idx} " . + "WHERE part_{$idx}.accompanyingPeriod = ap.id AND (centerCurrent_{$idx}.center = :center_{$idx}" + . ($allowNoCenter ? " OR centerCurrent_{$idx}.id IS NULL)" : ")") + ) ); - $qb->setParameter('center_' . $key, $center); - $orScope = $qb->expr()->orX(); + $qb->setParameter('center_' . $idx, $center); - foreach ($scopes as $skey => $scope) { - $orScope->add( - $qb->expr()->isMemberOf(':scope_' . $key . '_' . $skey, 'ap.scopes') + $orScopeInsideCenter = $qb->expr()->orX( + // even if the scope is not in one authorized, the user can see the course if it is in DRAFT state + $qb->expr()->eq('ap.step', ':draft') + ); + + $idx++; + foreach ($scopes as $scope) { + // for each scope: + // - either the user is the referrer of the course + // - or the accompanying course is one of the reachable scopes + // - and the parcours is not confidential OR the user is the referrer OR the user can see the confidential course + $orOnScope = $qb->expr()->orX( + $qb->expr()->isMemberOf(':scope_' . $idx, 'ap.scopes'), + $qb->expr()->eq('ap.user', ':user') ); - $qb->setParameter('scope_' . $key . '_' . $skey, $scope); + $qb->setParameter('user', $user); + + if (in_array($scope, $scopesCanSeeConfidential, true)) { + $orScopeInsideCenter->add($orOnScope); + } else { + // we must add a condition: the course is not confidential or the user is the referrer + $andXOnScope = $qb->expr()->andX( + $orOnScope, + $qb->expr()->orX( + 'ap.confidential = FALSE', + $qb->expr()->eq('ap.user', ':user') + ) + ); + $orScopeInsideCenter->add($andXOnScope); + } + $qb->setParameter('scope_' . $idx, $scope); + + $idx++; } - $and->add($orScope); + $and->add($orScopeInsideCenter); $orX->add($and); + + $idx++; } return $qb->andWhere($orX); @@ -350,7 +402,7 @@ final readonly class AccompanyingPeriodACLAwareRepository implements Accompanyin * @param array|Scope[] $services * @param array|Location[] $locations */ - private function buildQueryUnDispatched(array $jobs, array $services, array $locations): QueryBuilder + public function buildQueryUnDispatched(array $jobs, array $services, array $locations): QueryBuilder { $qb = $this->accompanyingPeriodRepository->createQueryBuilder('ap'); @@ -378,8 +430,8 @@ final readonly class AccompanyingPeriodACLAwareRepository implements Accompanyin $or = $qb->expr()->orX(); foreach ($services as $key => $service) { - $or->add($qb->expr()->isMemberOf(':scope_' . $key, 'ap.scopes')); - $qb->setParameter('scope_' . $key, $service); + $or->add($qb->expr()->isMemberOf(':scopef_' . $key, 'ap.scopes')); + $qb->setParameter('scopef_' . $key, $service); } $qb->andWhere($or); } diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepositoryInterface.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepositoryInterface.php index ff3d89783..61b631904 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepositoryInterface.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepositoryInterface.php @@ -50,7 +50,7 @@ interface AccompanyingPeriodACLAwareRepositoryInterface * * @return list */ - public function findByUnDispatched(array $jobs, array $services, array $administrativeLocations, ?int $limit = null, ?int $offset = null): array; + public function findByUnDispatched(array $jobs, array $services, array $administrativeAdministrativeLocations, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array; /** * @param array|PostalCode[] $postalCodes diff --git a/src/Bundle/ChillPersonBundle/Tests/Repository/AccompanyingPeriodACLAwareRepositoryTest.php b/src/Bundle/ChillPersonBundle/Tests/Repository/AccompanyingPeriodACLAwareRepositoryTest.php index 17c12fea5..90e0d2384 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Repository/AccompanyingPeriodACLAwareRepositoryTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Repository/AccompanyingPeriodACLAwareRepositoryTest.php @@ -11,8 +11,10 @@ declare(strict_types=1); namespace Repository; +use Chill\MainBundle\Entity\Center; use Chill\MainBundle\Entity\Scope; use Chill\MainBundle\Entity\User; +use Chill\MainBundle\Repository\CenterRepositoryInterface; use Chill\MainBundle\Repository\ScopeRepositoryInterface; use Chill\MainBundle\Security\Authorization\AuthorizationHelperForCurrentUserInterface; use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface; @@ -35,10 +37,13 @@ use Symfony\Component\Workflow\Registry; class AccompanyingPeriodACLAwareRepositoryTest extends KernelTestCase { use ProphecyTrait; + private AccompanyingPeriodRepository $accompanyingPeriodRepository; private CenterResolverManagerInterface $centerResolverManager; + private CenterRepositoryInterface $centerRepository; + private EntityManagerInterface $entityManager; private ScopeRepositoryInterface $scopeRepository; @@ -51,11 +56,11 @@ class AccompanyingPeriodACLAwareRepositoryTest extends KernelTestCase { self::bootKernel(); $this->accompanyingPeriodRepository = self::$container->get(AccompanyingPeriodRepository::class); + $this->centerRepository = self::$container->get(CenterRepositoryInterface::class); $this->centerResolverManager = self::$container->get(CenterResolverManagerInterface::class); $this->entityManager = self::$container->get(EntityManagerInterface::class); $this->scopeRepository = self::$container->get(ScopeRepositoryInterface::class); $this->registry = self::$container->get(Registry::class); - } public static function tearDownAfterClass(): void @@ -78,6 +83,140 @@ class AccompanyingPeriodACLAwareRepositoryTest extends KernelTestCase $em->flush(); } + /** + * @dataProvider provideDataFindByUndispatched + * @param list, scopeCanSeeConfidential: list}> $centerScopes + * @param list $expectedContains + * @param list $expectedNotContains + */ + public function testFindByUndispatched(User $user, array $centerScopes, array $expectedContains, array $expectedNotContains, string $message): void + { + $security = $this->prophesize(Security::class); + $security->getUser()->willReturn($user); + + $authorizationHelper = $this->prophesize(AuthorizationHelperForCurrentUserInterface::class); + $centers = []; + + foreach ($centerScopes as ['center' => $center, 'scopeOnRole' => $scopes, 'scopeCanSeeConfidential' => $scopesCanSeeConfidential]) { + $centers[spl_object_hash($center)] = $center; + $authorizationHelper->getReachableScopes(AccompanyingPeriodVoter::SEE, $center) + ->willReturn($scopes); + $authorizationHelper->getReachableScopes(AccompanyingPeriodVoter::SEE_CONFIDENTIAL_ALL, $center) + ->willReturn($scopesCanSeeConfidential); + } + $authorizationHelper->getReachableCenters(AccompanyingPeriodVoter::SEE)->willReturn(array_values($centers)); + + $repository = new AccompanyingPeriodACLAwareRepository( + $this->accompanyingPeriodRepository, + $security->reveal(), + $authorizationHelper->reveal(), + $this->centerResolverManager + ); + + $actual = array_map( + fn (AccompanyingPeriod $period) => $period->getId(), + $repository->findByUnDispatched([], [], [], ['id' => 'DESC'], 20, 0) + ); + + foreach ($expectedContains as $expected) { + self::assertContains($expected->getId(), $actual, $message); + } + foreach ($expectedNotContains as $expected) { + self::assertNotContains($expected->getId(), $actual, $message); + } + } + + public function provideDataFindByUndispatched(): iterable + { + $this->setUp(); + + if (null === $user = $this->entityManager->createQuery("SELECT u FROM " . User::class . " u")->setMaxResults(1)->getSingleResult()) { + throw new \RuntimeException("no user found"); + } + + if (null === $anotherUser = $this->entityManager->createQuery("SELECT u FROM " . User::class . " u WHERE u.id != :uid")->setParameter('uid', $user->getId()) + ->setMaxResults(1)->getSingleResult()) { + throw new \RuntimeException("no user found"); + } + + /** @var Person $person */ + [$person, $anotherPerson, $person2, $person3] = $this->entityManager + ->createQuery("SELECT p FROM " . Person::class . " p ") + ->setMaxResults(4) + ->getResult(); + + if (null === $person || null === $anotherPerson || null === $person2 || null === $person3) { + throw new \RuntimeException("no person found"); + } + + $scopes = $this->scopeRepository->findAll(); + + if (3 > count($scopes)) { + throw new \RuntimeException("not enough scopes for this test"); + } + $scopesCanSee = [ $scopes[0] ]; + $scopesGroup2 = [ $scopes[1] ]; + + $centers = $this->centerRepository->findActive(); + + if (2 > count($centers)) { + throw new \RuntimeException("not enough centers for this test"); + } + + $period = $this->buildPeriod($person, $scopesCanSee, $user, true); + + // expected scope: can see the period + yield [ + $anotherUser, + [ + [ + 'center' => $person->getCenter(), + 'scopeOnRole' => $scopesCanSee, + 'scopeCanSeeConfidential' => [], + ], + ], + [$period], + [], + "period should be visible with expected scopes", + ]; + + // no scope visible + yield [ + $anotherUser, + [ + [ + 'center' => $person->getCenter(), + 'scopeOnRole' => $scopesGroup2, + 'scopeCanSeeConfidential' => [], + ], + ], + [], + [$period], + "period should not be visible without expected scopes", + ]; + + // another center + yield [ + $anotherUser, + [ + [ + 'center' => $person->getCenter(), + 'scopeOnRole' => $scopesGroup2, + 'scopeCanSeeConfidential' => [], + ], + [ + 'center' => array_values(array_filter($centers, fn (Center $c) => $c !== $person->getCenter()))[0], + 'scopeOnRole' => $scopesCanSee, + 'scopeCanSeeConfidential' => [], + ], + ], + [], + [$period], + "period should not be visible for user having right in another scope (with multiple centers)" + ]; + + $this->entityManager->flush(); + } /** * For testing this method, we mock the authorization helper to return different Scope that a user From 779eb812b0f542a5c2ccb64dc92fc1aa18c6317c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 5 Jul 2023 21:56:50 +0200 Subject: [PATCH 268/724] Add new role to see confidential right on method AccompanyingPeriodACLAwareRepositoryInterface::findByUserAndPostalCodeOpenedAccompanyingPeriod --- .../ReassignAccompanyingPeriodController.php | 2 +- .../AccompanyingPeriodACLAwareRepository.php | 102 +++------- ...nyingPeriodACLAwareRepositoryInterface.php | 12 +- ...companyingPeriodACLAwareRepositoryTest.php | 174 +++++++++++++++++- 4 files changed, 200 insertions(+), 90 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php b/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php index fde9746d3..3e5b59c2a 100644 --- a/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php +++ b/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php @@ -98,7 +98,7 @@ class ReassignAccompanyingPeriodController extends AbstractController $userFrom = $form['user']->getData(); $postalCodes = $form['postal_code']->getData() instanceof PostalCode ? [$form['postal_code']->getData()] : []; - $total = $this->accompanyingPeriodACLAwareRepository->countByUserOpenedAccompanyingPeriod($userFrom); + $total = $this->accompanyingPeriodACLAwareRepository->countByUserAndPostalCodesOpenedAccompanyingPeriod($userFrom, $postalCodes); $paginator = $this->paginatorFactory->create($total); $paginator->setItemsPerPage(50); $periods = $this->accompanyingPeriodACLAwareRepository diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php index e62e2b3ac..79a7710ff 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php @@ -14,6 +14,7 @@ namespace Chill\PersonBundle\Repository; use Chill\MainBundle\Entity\Address; use Chill\MainBundle\Entity\Center; use Chill\MainBundle\Entity\Location; +use Chill\MainBundle\Entity\PostalCode; use Chill\MainBundle\Entity\Scope; use Chill\MainBundle\Entity\User; use Chill\MainBundle\Entity\UserJob; @@ -21,12 +22,8 @@ use Chill\MainBundle\Security\Authorization\AuthorizationHelperForCurrentUserInt use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation; -use Chill\PersonBundle\Entity\Household\PersonHouseholdAddress; use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; -use DateTime; -use DateTimeImmutable; -use Doctrine\DBAL\Types\Types; use Doctrine\ORM\NonUniqueResultException; use Doctrine\ORM\NoResultException; use Doctrine\ORM\Query\Expr\Join; @@ -60,51 +57,33 @@ final readonly class AccompanyingPeriodACLAwareRepository implements Accompanyin $this->centerResolver = $centerResolverDispatcher; } - public function buildQueryOpenedAccompanyingCourseByUser(?User $user, array $postalCodes = []): QueryBuilder + public function buildQueryOpenedAccompanyingCourseByUserAndPostalCodes(?User $user, array $postalCodes = []): QueryBuilder { $qb = $this->accompanyingPeriodRepository->createQueryBuilder('ap'); $qb->where($qb->expr()->eq('ap.user', ':user')) ->andWhere( $qb->expr()->neq('ap.step', ':draft'), - $qb->expr()->orX( - $qb->expr()->isNull('ap.closingDate'), - $qb->expr()->gt('ap.closingDate', ':now') - ) + $qb->expr()->neq('ap.step', ':closed'), ) ->setParameter('user', $user) - ->setParameter('now', new DateTime('now')) - ->setParameter('draft', AccompanyingPeriod::STEP_DRAFT); + ->setParameter('draft', AccompanyingPeriod::STEP_DRAFT) + ->setParameter('closed', AccompanyingPeriod::STEP_CLOSED); if ([] !== $postalCodes) { - $qb->join('ap.locationHistories', 'location_history') - ->leftJoin(PersonHouseholdAddress::class, 'person_address', Join::WITH, 'IDENTITY(location_history.personLocation) = IDENTITY(person_address.person)') + $qb->join('ap.locationHistories', 'location_history', Join::WITH, 'location_history.endDate IS NULL') + ->leftJoin(Person\PersonCurrentAddress::class, 'person_address', Join::WITH, 'IDENTITY(location_history.personLocation) = IDENTITY(person_address.person)') ->join( Address::class, 'address', Join::WITH, - 'COALESCE(IDENTITY(location_history.addressLocation), IDENTITY(person_address.address)) = address.id' + 'COALESCE(IDENTITY(person_address.address), IDENTITY(location_history.addressLocation)) = address.id' ) + ->join('address.postcode', 'postcode') ->andWhere( - $qb->expr()->orX( - $qb->expr()->isNull('person_address'), - $qb->expr()->andX( - $qb->expr()->lte('person_address.validFrom', ':now'), - $qb->expr()->orX( - $qb->expr()->isNull('person_address.validTo'), - $qb->expr()->lt('person_address.validTo', ':now') - ) - ) - ) + $qb->expr()->in('postcode.code', ':postal_codes') ) - ->andWhere( - $qb->expr()->isNull('location_history.endDate') - ) - ->andWhere( - $qb->expr()->in('address.postcode', ':postal_codes') - ) - ->setParameter('now', new DateTimeImmutable('now'), Types::DATE_IMMUTABLE) - ->setParameter('postal_codes', $postalCodes); + ->setParameter('postal_codes', array_map(fn (PostalCode $postalCode) => $postalCode->getCode(), $postalCodes)); } return $qb; @@ -116,7 +95,7 @@ final readonly class AccompanyingPeriodACLAwareRepository implements Accompanyin */ public function countByUnDispatched(array $jobs, array $services, array $administrativeLocations): int { - $qb = $this->addACLByUnDispatched( + $qb = $this->addACLMultiCenterOnQuery( $this->buildQueryUnDispatched($jobs, $services, $administrativeLocations), $this->buildCenterOnScope() ); @@ -132,22 +111,12 @@ final readonly class AccompanyingPeriodACLAwareRepository implements Accompanyin return 0; } - return $this->buildQueryOpenedAccompanyingCourseByUser($user, $postalCodes) - ->select('COUNT(ap)') - ->getQuery() - ->getSingleScalarResult(); - } + $qb = $this->buildQueryOpenedAccompanyingCourseByUserAndPostalCodes($user, $postalCodes); + $qb = $this->addACLMultiCenterOnQuery($qb, $this->buildCenterOnScope(), false); - public function countByUserOpenedAccompanyingPeriod(?User $user): int - { - if (null === $user) { - return 0; - } + $qb->select('COUNT(DISTINCT ap)'); - return $this->buildQueryOpenedAccompanyingCourseByUser($user) - ->select('COUNT(ap)') - ->getQuery() - ->getSingleScalarResult(); + return $qb->getQuery()->getSingleScalarResult(); } public function findByPerson( @@ -283,7 +252,7 @@ final readonly class AccompanyingPeriodACLAwareRepository implements Accompanyin $qb = $this->buildQueryUnDispatched($jobs, $services, $administrativeAdministrativeLocations); $qb->select('ap'); - $qb = $this->addACLByUnDispatched($qb, $this->buildCenterOnScope(), false); + $qb = $this->addACLMultiCenterOnQuery($qb, $this->buildCenterOnScope(), false); $qb = $this->addOrderLimitClauses($qb, $orderBy, $limit, $offset); return $qb->getQuery()->getResult(); @@ -295,32 +264,9 @@ final readonly class AccompanyingPeriodACLAwareRepository implements Accompanyin return []; } - $qb = $this->buildQueryOpenedAccompanyingCourseByUser($user); - - $qb->setFirstResult($offset) - ->setMaxResults($limit); - - foreach ($orderBy as $field => $direction) { - $qb->addOrderBy('ap.' . $field, $direction); - } - - return $qb->getQuery()->getResult(); - } - - public function findByUserOpenedAccompanyingPeriod(?User $user, array $orderBy = [], int $limit = 0, int $offset = 50): array - { - if (null === $user) { - return []; - } - - $qb = $this->buildQueryOpenedAccompanyingCourseByUser($user); - - $qb->setFirstResult($offset) - ->setMaxResults($limit); - - foreach ($orderBy as $field => $direction) { - $qb->addOrderBy('ap.' . $field, $direction); - } + $qb = $this->buildQueryOpenedAccompanyingCourseByUserAndPostalCodes($user, $postalCodes); + $qb = $this->addACLMultiCenterOnQuery($qb, $this->buildCenterOnScope(), false); + $qb = $this->addOrderLimitClauses($qb, $orderBy, $limit, $offset); return $qb->getQuery()->getResult(); } @@ -331,7 +277,7 @@ final readonly class AccompanyingPeriodACLAwareRepository implements Accompanyin * @param bool $allowNoCenter if true, will allow to see the periods linked to person which does not have any center. Very few edge case when some Person are not associated to a center. * @return QueryBuilder */ - public function addACLByUnDispatched(QueryBuilder $qb, array $centerScopes, bool $allowNoCenter = false): QueryBuilder + public function addACLMultiCenterOnQuery(QueryBuilder $qb, array $centerScopes, bool $allowNoCenter = false): QueryBuilder { $user = $this->security->getUser(); @@ -366,9 +312,9 @@ final readonly class AccompanyingPeriodACLAwareRepository implements Accompanyin // - and the parcours is not confidential OR the user is the referrer OR the user can see the confidential course $orOnScope = $qb->expr()->orX( $qb->expr()->isMemberOf(':scope_' . $idx, 'ap.scopes'), - $qb->expr()->eq('ap.user', ':user') + $qb->expr()->eq('ap.user', ':user_executing') ); - $qb->setParameter('user', $user); + $qb->setParameter('user_executing', $user); if (in_array($scope, $scopesCanSeeConfidential, true)) { $orScopeInsideCenter->add($orOnScope); @@ -378,7 +324,7 @@ final readonly class AccompanyingPeriodACLAwareRepository implements Accompanyin $orOnScope, $qb->expr()->orX( 'ap.confidential = FALSE', - $qb->expr()->eq('ap.user', ':user') + $qb->expr()->eq('ap.user', ':user_executing') ) ); $orScopeInsideCenter->add($andXOnScope); diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepositoryInterface.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepositoryInterface.php index 61b631904..7b31887b9 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepositoryInterface.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepositoryInterface.php @@ -31,8 +31,6 @@ interface AccompanyingPeriodACLAwareRepositoryInterface */ public function countByUserAndPostalCodesOpenedAccompanyingPeriod(?User $user, array $postalCodes): int; - public function countByUserOpenedAccompanyingPeriod(?User $user): int; - /** * @return array */ @@ -40,8 +38,8 @@ interface AccompanyingPeriodACLAwareRepositoryInterface Person $person, string $role, ?array $orderBy = [], - ?int $limit = null, - ?int $offset = null + ?int $limit = null, + ?int $offset = null ): array; /** @@ -57,10 +55,4 @@ interface AccompanyingPeriodACLAwareRepositoryInterface * @return list */ public function findByUserAndPostalCodesOpenedAccompanyingPeriod(?User $user, array $postalCodes, array $orderBy = [], int $limit = 0, int $offset = 50): array; - - /** - * @deprecated - * @return list - */ - public function findByUserOpenedAccompanyingPeriod(?User $user, array $orderBy = [], int $limit = 0, int $offset = 50): array; } diff --git a/src/Bundle/ChillPersonBundle/Tests/Repository/AccompanyingPeriodACLAwareRepositoryTest.php b/src/Bundle/ChillPersonBundle/Tests/Repository/AccompanyingPeriodACLAwareRepositoryTest.php index 90e0d2384..cb8d56ba3 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Repository/AccompanyingPeriodACLAwareRepositoryTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Repository/AccompanyingPeriodACLAwareRepositoryTest.php @@ -80,7 +80,178 @@ class AccompanyingPeriodACLAwareRepositoryTest extends KernelTestCase $em->remove($period); } - $em->flush(); + //$em->flush(); + } + + /** + * @dataProvider provideDataFindByUserAndPostalCodesOpenedAccompanyingPeriod + * @param list, scopeCanSeeConfidential: list}> $centerScopes + * @param list $expectedContains + * @param list $expectedNotContains + */ + public function testFindByUserAndPostalCodesOpenedAccompanyingPeriod(User $user, User $searched, array $centerScopes, array $expectedContains, array $expectedNotContains, string $message): void + { + $security = $this->prophesize(Security::class); + $security->getUser()->willReturn($user); + + $authorizationHelper = $this->prophesize(AuthorizationHelperForCurrentUserInterface::class); + $centers = []; + + foreach ($centerScopes as ['center' => $center, 'scopeOnRole' => $scopes, 'scopeCanSeeConfidential' => $scopesCanSeeConfidential]) { + $centers[spl_object_hash($center)] = $center; + $authorizationHelper->getReachableScopes(AccompanyingPeriodVoter::SEE, $center) + ->willReturn($scopes); + $authorizationHelper->getReachableScopes(AccompanyingPeriodVoter::SEE_CONFIDENTIAL_ALL, $center) + ->willReturn($scopesCanSeeConfidential); + } + $authorizationHelper->getReachableCenters(AccompanyingPeriodVoter::SEE)->willReturn(array_values($centers)); + + $repository = new AccompanyingPeriodACLAwareRepository( + $this->accompanyingPeriodRepository, + $security->reveal(), + $authorizationHelper->reveal(), + $this->centerResolverManager + ); + + $actual = array_map( + fn (AccompanyingPeriod $period) => $period->getId(), + $repository->findByUserAndPostalCodesOpenedAccompanyingPeriod($searched, [], ['id' => 'DESC'], 20, 0) + ); + + foreach ($expectedContains as $expected) { + self::assertContains($expected->getId(), $actual, $message); + } + foreach ($expectedNotContains as $expected) { + self::assertNotContains($expected->getId(), $actual, $message); + } + } + + public function provideDataFindByUserAndPostalCodesOpenedAccompanyingPeriod(): iterable + { + $this->setUp(); + + if (null === $user = $this->entityManager->createQuery("SELECT u FROM " . User::class . " u")->setMaxResults(1)->getSingleResult()) { + throw new \RuntimeException("no user found"); + } + + if (null === $anotherUser = $this->entityManager->createQuery("SELECT u FROM " . User::class . " u WHERE u.id != :uid")->setParameter('uid', $user->getId()) + ->setMaxResults(1)->getSingleResult()) { + throw new \RuntimeException("no user found"); + } + + /** @var Person $person */ + [$person, $anotherPerson, $person2, $person3] = $this->entityManager + ->createQuery("SELECT p FROM " . Person::class . " p JOIN p.centerCurrent current_center") + ->setMaxResults(4) + ->getResult(); + + if (null === $person || null === $anotherPerson || null === $person2 || null === $person3) { + throw new \RuntimeException("no person found"); + } + + $scopes = $this->scopeRepository->findAll(); + + if (3 > count($scopes)) { + throw new \RuntimeException("not enough scopes for this test"); + } + $scopesCanSee = [ $scopes[0] ]; + $scopesGroup2 = [ $scopes[1] ]; + + $centers = $this->centerRepository->findActive(); + $aCenterNotAssociatedToPerson = array_values(array_filter($centers, fn (Center $c) => $c !== $person->getCenter()))[0]; + + if (2 > count($centers)) { + throw new \RuntimeException("not enough centers for this test"); + } + + $period = $this->buildPeriod($person, $scopesCanSee, $user, true); + $period->setUser($user); + + yield [ + $anotherUser, + $user, + [ + [ + 'center' => $person->getCenter(), + 'scopeOnRole' => $scopesCanSee, + 'scopeCanSeeConfidential' => [], + ], + ], + [$period], + [], + "period should be visible with expected scopes", + ]; + + yield [ + $anotherUser, + $user, + [ + [ + 'center' => $person->getCenter(), + 'scopeOnRole' => $scopesGroup2, + 'scopeCanSeeConfidential' => [], + ], + ], + [], + [$period], + "period should not be visible without expected scopes", + ]; + + yield [ + $anotherUser, + $user, + [ + [ + 'center' => $person->getCenter(), + 'scopeOnRole' => $scopesGroup2, + 'scopeCanSeeConfidential' => [], + ], + [ + 'center' => $aCenterNotAssociatedToPerson, + 'scopeOnRole' => $scopesCanSee, + 'scopeCanSeeConfidential' => [], + ], + ], + [], + [$period], + "period should not be visible for user having right in another scope (with multiple centers)" + ]; + + $period = $this->buildPeriod($person, $scopesCanSee, $user, true); + $period->setUser($user); + $period->setConfidential(true); + + yield [ + $anotherUser, + $user, + [ + [ + 'center' => $person->getCenter(), + 'scopeOnRole' => $scopesCanSee, + 'scopeCanSeeConfidential' => [], + ], + ], + [], + [$period], + "period confidential should not be visible", + ]; + + yield [ + $anotherUser, + $user, + [ + [ + 'center' => $person->getCenter(), + 'scopeOnRole' => $scopesCanSee, + 'scopeCanSeeConfidential' => $scopesCanSee, + ], + ], + [$period], + [], + "period confidential be visible if user has required scopes", + ]; + + $this->entityManager->flush(); } /** @@ -165,6 +336,7 @@ class AccompanyingPeriodACLAwareRepositoryTest extends KernelTestCase $period = $this->buildPeriod($person, $scopesCanSee, $user, true); + // expected scope: can see the period yield [ $anotherUser, From ff1629cbb7d6719c381d86cea6bb54d658534202 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 5 Jul 2023 22:06:21 +0200 Subject: [PATCH 269/724] Separate role "see confidential course" from "reassign bulk" --- .../DependencyInjection/ChillPersonExtension.php | 4 ---- .../Security/Authorization/AccompanyingPeriodVoter.php | 1 + src/Bundle/ChillPersonBundle/translations/messages.fr.yml | 3 ++- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php index 6fd434635..121bbba14 100644 --- a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php +++ b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php @@ -983,10 +983,6 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac AccompanyingPeriodVoter::EDIT, AccompanyingPeriodVoter::DELETE, ], - AccompanyingPeriodVoter::REASSIGN_BULK => [ - AccompanyingPeriodVoter::SEE_CONFIDENTIAL_ALL, - AccompanyingPeriodVoter::TOGGLE_CONFIDENTIAL_ALL, - ], AccompanyingPeriodVoter::TOGGLE_CONFIDENTIAL_ALL => [ AccompanyingPeriodVoter::SEE_CONFIDENTIAL_ALL, ], diff --git a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php index 3dd991501..795a921e7 100644 --- a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php +++ b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php @@ -138,6 +138,7 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH self::TOGGLE_CONFIDENTIAL_ALL, self::REASSIGN_BULK, self::STATS, + self::SEE_CONFIDENTIAL_ALL, ]; } diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 01383c050..635f86c99 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -329,8 +329,9 @@ CHILL_PERSON_ACCOMPANYING_PERIOD_CREATE: Créer un parcours d'accompagnement CHILL_PERSON_ACCOMPANYING_PERIOD_UPDATE: Modifier un parcours d'accompagnement CHILL_PERSON_ACCOMPANYING_PERIOD_FULL: Voir les détails, créer, supprimer et mettre à jour un parcours d'accompagnement CHILL_PERSON_ACCOMPANYING_COURSE_REASSIGN_BULK: Réassigner les parcours en lot -CHILL_PERSON_ACCOMPANYING_PERIOD_SEE_DETAILS: Voir les détails d'un parcours d'accompagnement +CHILL_PERSON_ACCOMPANYING_PERIOD_SEE_DETAILS: Voir les détails d'un parcours d'accompagnement CHILL_PERSON_ACCOMPANYING_PERIOD_STATS: Statistiques sur les parcours d'accompagnement +CHILL_PERSON_ACCOMPANYING_PERIOD_SEE_CONFIDENTIAL: Voir les parcours confidentiels CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_CREATE: Créer une action d'accompagnement CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_DELETE: Supprimer une action d'accompagnement From af4e7f1226bad8fb4e5327ddf515f7dc11a0369f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 5 Jul 2023 22:06:36 +0200 Subject: [PATCH 270/724] Add changie entry --- .changes/unreleased/Feature-20230705-220544.yaml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changes/unreleased/Feature-20230705-220544.yaml diff --git a/.changes/unreleased/Feature-20230705-220544.yaml b/.changes/unreleased/Feature-20230705-220544.yaml new file mode 100644 index 000000000..4212f7646 --- /dev/null +++ b/.changes/unreleased/Feature-20230705-220544.yaml @@ -0,0 +1,6 @@ +kind: Feature +body: Create a role "See Confidential Periods", separated from the "Reassign courses" + role +time: 2023-07-05T22:05:44.435112463+02:00 +custom: + Issue: "121" From c04fd66163f2014ac54362f56bafebca9f38e1ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 5 Jul 2023 22:20:27 +0200 Subject: [PATCH 271/724] do not show filter on job or activity type if less than 2 possibilities --- .../Controller/ActivityController.php | 39 +++++++++++-------- .../Templating/Listing/FilterOrderHelper.php | 20 ++++++++++ 2 files changed, 43 insertions(+), 16 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php index 63639c149..9b6e69bf0 100644 --- a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php +++ b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php @@ -259,8 +259,8 @@ final class ActivityController extends AbstractController $filterArgs = [ 'my_activities' => $filter->getSingleCheckboxData('my_activities'), - 'types' => $filter->getEntityChoiceData('activity_types'), - 'jobs' => $filter->getEntityChoiceData('jobs'), + 'types' => $filter->hasEntityChoice('activity_type') ? $filter->getEntityChoiceData('activity_types') : [], + 'jobs' => $filter->hasEntityChoice('jobs') ? $filter->getEntityChoiceData('jobs') : [], 'before' => $filter->getDateRangeData('activity_date')['to'], 'after' => $filter->getDateRangeData('activity_date')['from'], ]; @@ -327,21 +327,28 @@ final class ActivityController extends AbstractController $filterBuilder ->addDateRange('activity_date', 'activity.date') - ->addSingleCheckbox('my_activities', 'activity_filter.My activities') - ->addEntityChoice('activity_types', 'activity_filter.Types', \Chill\ActivityBundle\Entity\ActivityType::class, $types, [ - 'choice_label' => function (\Chill\ActivityBundle\Entity\ActivityType $activityType) { - $text = match ($activityType->hasCategory()) { - true => $this->translatableStringHelper->localize($activityType->getCategory()->getName()) . ' > ', - false => '', - }; + ->addSingleCheckbox('my_activities', 'activity_filter.My activities'); - return $text . $this->translatableStringHelper->localize($activityType->getName()); - } - ]) - ->addEntityChoice('jobs', 'activity_filter.Jobs', UserJob::class, $jobs, [ - 'choice_label' => fn (UserJob $u) => $this->translatableStringHelper->localize($u->getLabel()) - ]) - ; + if (1 < count($types)) { + $filterBuilder + ->addEntityChoice('activity_types', 'activity_filter.Types', \Chill\ActivityBundle\Entity\ActivityType::class, $types, [ + 'choice_label' => function (\Chill\ActivityBundle\Entity\ActivityType $activityType) { + $text = match ($activityType->hasCategory()) { + true => $this->translatableStringHelper->localize($activityType->getCategory()->getName()) . ' > ', + false => '', + }; + + return $text . $this->translatableStringHelper->localize($activityType->getName()); + } + ]); + } + + if (1 < count($jobs)) { + $filterBuilder + ->addEntityChoice('jobs', 'activity_filter.Jobs', UserJob::class, $jobs, [ + 'choice_label' => fn (UserJob $u) => $this->translatableStringHelper->localize($u->getLabel()) + ]); + } return $filterBuilder->build(); } diff --git a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php index 28cc8e331..5c9971890 100644 --- a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php +++ b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php @@ -116,16 +116,31 @@ class FilterOrderHelper ->handleRequest($this->requestStack->getCurrentRequest()); } + public function hasCheckboxData(string $name): bool + { + return array_key_exists($name, $this->checkboxes); + } + public function getCheckboxData(string $name): array { return $this->getFormData()['checkboxes'][$name]; } + public function hasSingleCheckboxData(string $name): bool + { + return array_key_exists($name, $this->singleCheckbox); + } + public function getSingleCheckboxData(string $name): ?bool { return $this->getFormData()['single_checkboxes'][$name]; } + public function hasEntityChoice(string $name): bool + { + return array_key_exists($name, $this->entityChoices); + } + public function getEntityChoiceData($name): mixed { return $this->getFormData()['entity_choices'][$name]; @@ -144,6 +159,11 @@ class FilterOrderHelper return $this->singleCheckbox; } + public function hasDateRangeData(string $name): bool + { + return array_key_exists($name, $this->dateRanges); + } + /** * @return array{to: ?DateTimeImmutable, from: ?DateTimeImmutable} */ From c19232de35e72cadf0bc5978af2e8d6d79b50e8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 5 Jul 2023 22:37:51 +0200 Subject: [PATCH 272/724] DX: fix phpstan issues --- .../ChillEventBundle/Controller/ParticipationController.php | 5 ++++- src/Bundle/ChillEventBundle/Entity/Event.php | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Bundle/ChillEventBundle/Controller/ParticipationController.php b/src/Bundle/ChillEventBundle/Controller/ParticipationController.php index 1929beac1..a2a82c88f 100644 --- a/src/Bundle/ChillEventBundle/Controller/ParticipationController.php +++ b/src/Bundle/ChillEventBundle/Controller/ParticipationController.php @@ -16,6 +16,8 @@ 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; @@ -509,7 +511,7 @@ class ParticipationController extends AbstractController /** * @return \Symfony\Component\Form\FormInterface */ - protected function createEditFormMultiple(ArrayIterator $participations, Event $event) + protected function createEditFormMultiple(Collection $participations, Event $event) { $form = $this->createForm( \Symfony\Component\Form\Extension\Core\Type\FormType::class, @@ -638,6 +640,7 @@ class ParticipationController extends AbstractController $ignoredParticipations = $newParticipations = []; foreach ($participations as $participation) { + /** @var Participation $participation */ // check for authorization $this->denyAccessUnlessGranted( ParticipationVoter::CREATE, diff --git a/src/Bundle/ChillEventBundle/Entity/Event.php b/src/Bundle/ChillEventBundle/Entity/Event.php index d55a7b8a8..cc762e979 100644 --- a/src/Bundle/ChillEventBundle/Entity/Event.php +++ b/src/Bundle/ChillEventBundle/Entity/Event.php @@ -160,11 +160,11 @@ class Event implements HasCenterInterface, HasScopeInterface } /** - * @return ArrayIterator|Collection|Traversable + * @return Collection */ public function getParticipations() { - return $this->getParticipationsOrdered(); + return new ArrayCollection(iterator_to_array($this->getParticipationsOrdered())); } /** From 20d5fabc1876e65ca07ffb18b1cfa477ae1fc2c4 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 6 Jul 2023 13:39:08 +0200 Subject: [PATCH 273/724] [repository][action filter] integrating filters in repository --- .../AccompanyingCourseWorkController.php | 4 +- .../AccompanyingPeriodWorkRepository.php | 58 ++++++++++++++++++- 2 files changed, 58 insertions(+), 4 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php index 1f2680f9e..c56489afd 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php @@ -161,7 +161,7 @@ class AccompanyingCourseWorkController extends AbstractController 'types' => $filter->getEntityChoiceData('typesFilter'), 'before' => $filter->getDateRangeData('dateFilter')['to'], 'after' => $filter->getDateRangeData('dateFilter')['from'], - 'user' => $filter->getUserPickerData('userFilter') + 'users' => $filter->getUserPickerData('userFilter') ]; $totalItems = $this->workRepository->countByAccompanyingPeriod($period); @@ -219,7 +219,7 @@ class AccompanyingCourseWorkController extends AbstractController { $filterBuilder = $this->filterOrderHelperFactory->create(self::class); - $types = $this->workRepository->findByAccompanyingPeriod($associatedPeriod); + $types = $this->workRepository->findActionTypeByPeriod($associatedPeriod); $filterBuilder ->addDateRange('dateFilter', 'accompanying_course_work.date_filter') diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php index 60a00e12a..a5e27afd5 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php @@ -108,8 +108,32 @@ final class AccompanyingPeriodWorkRepository implements ObjectRepository CASE WHEN enddate IS NULL THEN '-infinity'::timestamp ELSE 'infinity'::timestamp END ASC, startdate DESC, enddate DESC, - id DESC - LIMIT :limit OFFSET :offset"; + id DESC"; + + // implement filters + + if([] !== ($filters['types'] ?? [])) + { + $sql .= "AND WHERE w.socialAction IN (:types)"; + } + + if([] !== ($filters['users'] ?? [])) + { + $sql .= "AND WHERE w.createdBy IN (:users)"; + + foreach ($filters['users'] as $key => $user) { + $sql .= "OR :user_" . $key . " IN w.referrers)"; + + $nq = $this->em->createNativeQuery($sql, $rsm) + ->setParameter(':user_' . $key); + } + + // ... to be continued + } + + // set limit and offset + + $sql .= " LIMIT :limit OFFSET :offset"; $nq = $this->em->createNativeQuery($sql, $rsm) ->setParameter('periodId', $period->getId(), Types::INTEGER) @@ -119,6 +143,36 @@ final class AccompanyingPeriodWorkRepository implements ObjectRepository return $nq->getResult(); } + /** + * Return a list of types of social actions associated to the accompanying period + * + * @return array + */ + public function findActionTypeByPeriod(AccompanyingPeriod $period): array + { + $in = $this->em->createQueryBuilder(); + $in + ->select('1') + ->from(AccompanyingPeriodWork::class, 'apw'); + + + $in->andWhere('apw.accompanyingPeriod = :period')->setParameter('period', $period); + + + // join between the embedded exist query and the main query + $in->andWhere('apw.socialAction = sa'); + + $qb = $this->em->createQueryBuilder()->setParameters($in->getParameters()); + $qb + ->select('sa') + ->from(SocialAction::class, 'sa') + ->where( + $qb->expr()->exists($in->getDQL()) + ); + + return $qb->getQuery()->getResult(); + } + public function findNearEndDateByUser(User $user, DateTimeImmutable $since, DateTimeImmutable $until, int $limit = 20, int $offset = 0): array { return $this->buildQueryNearEndDateByUser($user, $since, $until) From cc97199c5deceb7c98bca0af26c659a9b5ea149d Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 6 Jul 2023 13:40:25 +0200 Subject: [PATCH 274/724] DX added changie --- .changes/unreleased/Feature-20230706-134010.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changes/unreleased/Feature-20230706-134010.yaml diff --git a/.changes/unreleased/Feature-20230706-134010.yaml b/.changes/unreleased/Feature-20230706-134010.yaml new file mode 100644 index 000000000..73a0727fc --- /dev/null +++ b/.changes/unreleased/Feature-20230706-134010.yaml @@ -0,0 +1,5 @@ +kind: Feature +body: Adding OrderFilter to the list of social actions. +time: 2023-07-06T13:40:10.339001208+02:00 +custom: + Issue: "120" From 5b42b85b503c23eda24d5c774d05f4524fc70a72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 6 Jul 2023 16:58:24 +0200 Subject: [PATCH 275/724] Read absence from MS graph api --- .../Exception/UserAbsenceSyncException.php | 20 ++ .../Connector/MSGraph/MSUserAbsenceReader.php | 68 +++++++ .../MSGraph/MSUserAbsenceReaderTest.php | 176 ++++++++++++++++++ 3 files changed, 264 insertions(+) create mode 100644 src/Bundle/ChillCalendarBundle/Exception/UserAbsenceSyncException.php create mode 100644 src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MSUserAbsenceReader.php create mode 100644 src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/MSUserAbsenceReaderTest.php diff --git a/src/Bundle/ChillCalendarBundle/Exception/UserAbsenceSyncException.php b/src/Bundle/ChillCalendarBundle/Exception/UserAbsenceSyncException.php new file mode 100644 index 000000000..b46c93976 --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/Exception/UserAbsenceSyncException.php @@ -0,0 +1,20 @@ +mapCalendarToUser->getUserId($user); + + if (null === $id) { + return null; + } + + try { + $automaticRepliesSettings = $this->machineHttpClient + ->request('GET', '/users/' . $id . '/mailboxSettings/automaticRepliesSetting') + ->toArray(true); + } catch (ClientExceptionInterface|DecodingExceptionInterface|RedirectionExceptionInterface|TransportExceptionInterface $e) { + throw new UserAbsenceSyncException("Error receiving response for mailboxSettings", 0, $e); + } catch (ServerExceptionInterface $e) { + throw new UserAbsenceSyncException("Server error receiving response for mailboxSettings", 0, $e); + } + + if (!array_key_exists("status", $automaticRepliesSettings)) { + throw new \LogicException("no key \"status\" on automatic replies settings: " . json_encode($automaticRepliesSettings)); + } + + return match ($automaticRepliesSettings['status']) { + 'disabled' => false, + 'alwaysEnabled' => true, + 'scheduled' => + RemoteEventConverter::convertStringDateWithoutTimezone($automaticRepliesSettings['scheduledStartDateTime']['dateTime']) < $this->clock->now() + && RemoteEventConverter::convertStringDateWithoutTimezone($automaticRepliesSettings['scheduledEndDateTime']['dateTime']) > $this->clock->now(), + default => throw new UserAbsenceSyncException("this status is not documented by Microsoft") + }; + } + +} diff --git a/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/MSUserAbsenceReaderTest.php b/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/MSUserAbsenceReaderTest.php new file mode 100644 index 000000000..089477fda --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/MSUserAbsenceReaderTest.php @@ -0,0 +1,176 @@ +prophesize(MapCalendarToUser::class); + $mapUser->getUserId($user)->willReturn('1234'); + $clock = new MockClock(new \DateTimeImmutable('2023-07-07T12:00:00')); + + $absenceReader = new MSUserAbsenceReader($client, $mapUser->reveal(), $clock); + + self::assertEquals($expected, $absenceReader->isUserAbsent($user), $message); + } + + public function testIsUserAbsentWithoutRemoteId(): void + { + $user = new User(); + $client = new MockHttpClient(); + + $mapUser = $this->prophesize(MapCalendarToUser::class); + $mapUser->getUserId($user)->willReturn(null); + $clock = new MockClock(new \DateTimeImmutable('2023-07-07T12:00:00')); + + $absenceReader = new MSUserAbsenceReader($client, $mapUser->reveal(), $clock); + + self::assertNull($absenceReader->isUserAbsent($user), "when no user found, absence should be null"); + } + + public function provideDataTestUserAbsence(): iterable + { + // contains data that was retrieved from microsoft graph api on 2023-07-06 + + yield [ + <<<'JSON' + { + "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('4feb0ae3-7ffb-48dd-891e-c86b2cdeefd4')/mailboxSettings/automaticRepliesSetting", + "status": "disabled", + "externalAudience": "none", + "internalReplyMessage": "Je suis en congé.", + "externalReplyMessage": "", + "scheduledStartDateTime": { + "dateTime": "2023-07-06T12:00:00.0000000", + "timeZone": "UTC" + }, + "scheduledEndDateTime": { + "dateTime": "2023-07-07T12:00:00.0000000", + "timeZone": "UTC" + } + } + JSON, + false, + "User is present" + ]; + + yield [ + <<<'JSON' + { + "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('4feb0ae3-7ffb-48dd-891e-c86b2cdeefd4')/mailboxSettings/automaticRepliesSetting", + "status": "scheduled", + "externalAudience": "none", + "internalReplyMessage": "Je suis en congé.", + "externalReplyMessage": "", + "scheduledStartDateTime": { + "dateTime": "2023-07-06T11:00:00.0000000", + "timeZone": "UTC" + }, + "scheduledEndDateTime": { + "dateTime": "2023-07-21T11:00:00.0000000", + "timeZone": "UTC" + } + } + JSON, + true, + 'User is absent with absence scheduled, we are within this period' + ]; + + yield [ + <<<'JSON' + { + "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('4feb0ae3-7ffb-48dd-891e-c86b2cdeefd4')/mailboxSettings/automaticRepliesSetting", + "status": "scheduled", + "externalAudience": "none", + "internalReplyMessage": "Je suis en congé.", + "externalReplyMessage": "", + "scheduledStartDateTime": { + "dateTime": "2023-07-08T11:00:00.0000000", + "timeZone": "UTC" + }, + "scheduledEndDateTime": { + "dateTime": "2023-07-21T11:00:00.0000000", + "timeZone": "UTC" + } + } + JSON, + false, + 'User is present: absence is scheduled for later' + ]; + + yield [ + <<<'JSON' + { + "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('4feb0ae3-7ffb-48dd-891e-c86b2cdeefd4')/mailboxSettings/automaticRepliesSetting", + "status": "scheduled", + "externalAudience": "none", + "internalReplyMessage": "Je suis en congé.", + "externalReplyMessage": "", + "scheduledStartDateTime": { + "dateTime": "2023-07-05T11:00:00.0000000", + "timeZone": "UTC" + }, + "scheduledEndDateTime": { + "dateTime": "2023-07-06T11:00:00.0000000", + "timeZone": "UTC" + } + } + JSON, + false, + 'User is present: absence is past' + ]; + + yield [ + <<<'JSON' + { + "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('4feb0ae3-7ffb-48dd-891e-c86b2cdeefd4')/mailboxSettings/automaticRepliesSetting", + "status": "alwaysEnabled", + "externalAudience": "none", + "internalReplyMessage": "Je suis en congé.", + "externalReplyMessage": "", + "scheduledStartDateTime": { + "dateTime": "2023-07-06T12:00:00.0000000", + "timeZone": "UTC" + }, + "scheduledEndDateTime": { + "dateTime": "2023-07-07T12:00:00.0000000", + "timeZone": "UTC" + } + } + JSON, + true, + "User is absent: absence is always enabled" + ]; + } + +} From 2861945a5251ed77d50bfe5a8e1fc6083234ba6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 6 Jul 2023 17:29:10 +0200 Subject: [PATCH 276/724] Syncer for user absence, from the msgraph reader --- .../Exception/UserAbsenceSyncException.php | 4 +- .../Connector/MSGraph/MSUserAbsenceReader.php | 2 +- .../MSGraph/MSUserAbsenceReaderInterface.php | 22 ++++++ .../Connector/MSGraph/MSUserAbsenceSync.php | 44 ++++++++++++ .../MSGraph/MSUserAbsenceSyncTest.php | 67 +++++++++++++++++++ 5 files changed, 136 insertions(+), 3 deletions(-) create mode 100644 src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MSUserAbsenceReaderInterface.php create mode 100644 src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MSUserAbsenceSync.php create mode 100644 src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/MSUserAbsenceSyncTest.php diff --git a/src/Bundle/ChillCalendarBundle/Exception/UserAbsenceSyncException.php b/src/Bundle/ChillCalendarBundle/Exception/UserAbsenceSyncException.php index b46c93976..558774fc5 100644 --- a/src/Bundle/ChillCalendarBundle/Exception/UserAbsenceSyncException.php +++ b/src/Bundle/ChillCalendarBundle/Exception/UserAbsenceSyncException.php @@ -13,8 +13,8 @@ namespace Chill\CalendarBundle\Exception; class UserAbsenceSyncException extends \LogicException { - public function __construct(string $message = "", int $code = 20230706) + public function __construct(string $message = "", int $code = 20230706, ?\Throwable $previous = null) { - parent::__construct($message, $code); + parent::__construct($message, $code, $previous); } } diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MSUserAbsenceReader.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MSUserAbsenceReader.php index b79a55052..83376528f 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MSUserAbsenceReader.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MSUserAbsenceReader.php @@ -21,7 +21,7 @@ use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface; use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; -readonly class MSUserAbsenceReader +final readonly class MSUserAbsenceReader implements MSUserAbsenceReaderInterface { public function __construct( private HttpClientInterface $machineHttpClient, diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MSUserAbsenceReaderInterface.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MSUserAbsenceReaderInterface.php new file mode 100644 index 000000000..a918bb7ea --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MSUserAbsenceReaderInterface.php @@ -0,0 +1,22 @@ +absenceReader->isUserAbsent($user); + + if (null === $absence) { + return; + } + + if ($absence === $user->isAbsent()) { + // nothing to do + return; + } + + if ($absence) { + $user->setAbsenceStart($this->clock->now()); + } else { + $user->setAbsenceStart(null); + } + } +} diff --git a/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/MSUserAbsenceSyncTest.php b/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/MSUserAbsenceSyncTest.php new file mode 100644 index 000000000..ddd92086d --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/MSUserAbsenceSyncTest.php @@ -0,0 +1,67 @@ +prophesize(MSUserAbsenceReaderInterface::class); + $userAbsenceReader->isUserAbsent($user)->willReturn($absenceFromMicrosoft); + + $clock = new MockClock(new \DateTimeImmutable('2023-07-01T12:00:00')); + + $syncer = new MSUserAbsenceSync($userAbsenceReader->reveal(), $clock); + + $syncer->syncUserAbsence($user); + + self::assertEquals($expectedAbsence, $user->isAbsent(), $message); + self::assertEquals($expectedAbsenceStart, $user->getAbsenceStart(), $message); + } + + public function provideDataTestSyncUserAbsence(): iterable + { + yield [new User(), false, false, null, "user present remains present"]; + yield [new User(), true, true, new \DateTimeImmutable('2023-07-01T12:00:00'), "user present becomes absent"]; + + $user = new User(); + $user->setAbsenceStart($abs = new \DateTimeImmutable("2023-07-01T12:00:00")); + yield [$user, true, true, $abs, "user absent remains absent"]; + + $user = new User(); + $user->setAbsenceStart($abs = new \DateTimeImmutable("2023-07-01T12:00:00")); + yield [$user, false, false, null, "user absent becomes present"]; + + yield [new User(), null, false, null, "user not syncable: presence do not change"]; + + $user = new User(); + $user->setAbsenceStart($abs = new \DateTimeImmutable("2023-07-01T12:00:00")); + yield [$user, null, true, $abs, "user not syncable: absence do not change"]; + } +} From 77d4b13c1bab2624a9b28c016f522486f859abb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 6 Jul 2023 21:33:01 +0200 Subject: [PATCH 277/724] Sync user absence / presence within MapAndSubscribeUserCalendarCommand --- .../MapAndSubscribeUserCalendarCommand.php | 182 ++++++++++-------- .../MSGraph/MSGraphUserRepository.php | 2 +- .../Connector/MSGraph/MSUserAbsenceReader.php | 3 +- .../Connector/MSGraph/MSUserAbsenceSync.php | 6 + .../MSGraph/MSUserAbsenceSyncTest.php | 3 +- 5 files changed, 109 insertions(+), 87 deletions(-) diff --git a/src/Bundle/ChillCalendarBundle/Command/MapAndSubscribeUserCalendarCommand.php b/src/Bundle/ChillCalendarBundle/Command/MapAndSubscribeUserCalendarCommand.php index b90fb83d4..193b04934 100644 --- a/src/Bundle/ChillCalendarBundle/Command/MapAndSubscribeUserCalendarCommand.php +++ b/src/Bundle/ChillCalendarBundle/Command/MapAndSubscribeUserCalendarCommand.php @@ -18,9 +18,12 @@ declare(strict_types=1); namespace Chill\CalendarBundle\Command; +use Chill\CalendarBundle\Exception\UserAbsenceSyncException; use Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph\EventsOnUserSubscriptionCreator; use Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph\MapCalendarToUser; use Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph\MSGraphUserRepository; +use Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph\MSUserAbsenceSync; +use Chill\MainBundle\Repository\UserRepositoryInterface; use DateInterval; use DateTimeImmutable; use Doctrine\ORM\EntityManagerInterface; @@ -30,32 +33,17 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -class MapAndSubscribeUserCalendarCommand extends Command +final class MapAndSubscribeUserCalendarCommand extends Command { - private EntityManagerInterface $em; - - private EventsOnUserSubscriptionCreator $eventsOnUserSubscriptionCreator; - - private LoggerInterface $logger; - - private MapCalendarToUser $mapCalendarToUser; - - private MSGraphUserRepository $userRepository; - public function __construct( - EntityManagerInterface $em, - EventsOnUserSubscriptionCreator $eventsOnUserSubscriptionCreator, - LoggerInterface $logger, - MapCalendarToUser $mapCalendarToUser, - MSGraphUserRepository $userRepository + private readonly EntityManagerInterface $em, + private readonly EventsOnUserSubscriptionCreator $eventsOnUserSubscriptionCreator, + private readonly LoggerInterface $logger, + private readonly MapCalendarToUser $mapCalendarToUser, + private readonly UserRepositoryInterface $userRepository, + private readonly MSUserAbsenceSync $userAbsenceSync, ) { parent::__construct('chill:calendar:msgraph-user-map-subscribe'); - - $this->em = $em; - $this->eventsOnUserSubscriptionCreator = $eventsOnUserSubscriptionCreator; - $this->logger = $logger; - $this->mapCalendarToUser = $mapCalendarToUser; - $this->userRepository = $userRepository; } public function execute(InputInterface $input, OutputInterface $output): int @@ -67,83 +55,109 @@ class MapAndSubscribeUserCalendarCommand extends Command /** @var DateInterval $interval the interval before the end of the expiration */ $interval = new DateInterval('P1D'); $expiration = (new DateTimeImmutable('now'))->add(new DateInterval($input->getOption('subscription-duration'))); - $total = $this->userRepository->countByMostOldSubscriptionOrWithoutSubscriptionOrData($interval); + $users = $this->userRepository->findAllAsArray('fr'); $created = 0; $renewed = 0; - $this->logger->info(self::class . ' the number of user to get - renew', [ - 'total' => $total, + $this->logger->info(self::class . ' start user to get - renew', [ 'expiration' => $expiration->format(DateTimeImmutable::ATOM), ]); - while ($offset < $total) { - $users = $this->userRepository->findByMostOldSubscriptionOrWithoutSubscriptionOrData( - $interval, - $limit, - $offset - ); + foreach ($users as $u) { + ++$offset; - foreach ($users as $user) { - if (!$this->mapCalendarToUser->hasUserId($user)) { - $this->mapCalendarToUser->writeMetadata($user); - } - - if ($this->mapCalendarToUser->hasUserId($user)) { - // we first try to renew an existing subscription, if any. - // if not, or if it fails, we try to create a new one - if ($this->mapCalendarToUser->hasActiveSubscription($user)) { - $this->logger->debug(self::class . ' renew a subscription for', [ - 'userId' => $user->getId(), - 'username' => $user->getUsernameCanonical(), - ]); - - ['secret' => $secret, 'id' => $id, 'expiration' => $expirationTs] - = $this->eventsOnUserSubscriptionCreator->renewSubscriptionForUser($user, $expiration); - $this->mapCalendarToUser->writeSubscriptionMetadata($user, $expirationTs, $id, $secret); - - if (0 !== $expirationTs) { - ++$renewed; - } else { - $this->logger->warning(self::class . ' could not renew subscription for a user', [ - 'userId' => $user->getId(), - 'username' => $user->getUsernameCanonical(), - ]); - } - } - - if (!$this->mapCalendarToUser->hasActiveSubscription($user)) { - $this->logger->debug(self::class . ' create a subscription for', [ - 'userId' => $user->getId(), - 'username' => $user->getUsernameCanonical(), - ]); - - ['secret' => $secret, 'id' => $id, 'expiration' => $expirationTs] - = $this->eventsOnUserSubscriptionCreator->createSubscriptionForUser($user, $expiration); - $this->mapCalendarToUser->writeSubscriptionMetadata($user, $expirationTs, $id, $secret); - - if (0 !== $expirationTs) { - ++$created; - } else { - $this->logger->warning(self::class . ' could not create subscription for a user', [ - 'userId' => $user->getId(), - 'username' => $user->getUsernameCanonical(), - ]); - } - } - } - - ++$offset; + if (false === $u['enabled']) { + continue; } - $this->em->flush(); - $this->em->clear(); + $user = $this->userRepository->find($u['id']); + + if (null === $user) { + $this->logger->error("could not find user by id", ['uid' => $u['id']]); + $output->writeln("could not find user by id : " . $u['id']); + continue; + } + + if (!$this->mapCalendarToUser->hasUserId($user)) { + $user = $this->mapCalendarToUser->writeMetadata($user); + + // if user still does not have userid, continue + if (!$this->mapCalendarToUser->hasUserId($user)) { + $this->logger->warning("user does not have a counterpart on ms api", ['userId' => $user->getId(), 'email' => $user->getEmail()]); + $output->writeln(sprintf("giving up for user with email %s and id %s", $user->getEmail(), $user->getId())); + + continue; + } + } + + // sync user absence + try { + $this->userAbsenceSync->syncUserAbsence($user); + } catch (UserAbsenceSyncException $e) { + $this->logger->error("could not sync user absence", ['userId' => $user->getId(), 'email' => $user->getEmail(), 'exception' => $e->getTraceAsString(), "message" => $e->getMessage()]); + $output->writeln(sprintf("Could not sync user absence: id: %s and email: %s", $user->getId(), $user->getEmail())); + throw $e; + } + + // we first try to renew an existing subscription, if any. + // if not, or if it fails, we try to create a new one + if ($this->mapCalendarToUser->hasActiveSubscription($user)) { + $this->logger->debug(self::class . ' renew a subscription for', [ + 'userId' => $user->getId(), + 'username' => $user->getUsernameCanonical(), + ]); + + ['secret' => $secret, 'id' => $id, 'expiration' => $expirationTs] + = $this->eventsOnUserSubscriptionCreator->renewSubscriptionForUser($user, $expiration); + $this->mapCalendarToUser->writeSubscriptionMetadata($user, $expirationTs, $id, $secret); + + if (0 !== $expirationTs) { + ++$renewed; + } else { + $this->logger->warning(self::class . ' could not renew subscription for a user', [ + 'userId' => $user->getId(), + 'username' => $user->getUsernameCanonical(), + ]); + } + } + + if (!$this->mapCalendarToUser->hasActiveSubscription($user)) { + $this->logger->debug(self::class . ' create a subscription for', [ + 'userId' => $user->getId(), + 'username' => $user->getUsernameCanonical(), + ]); + + ['secret' => $secret, 'id' => $id, 'expiration' => $expirationTs] + = $this->eventsOnUserSubscriptionCreator->createSubscriptionForUser($user, $expiration); + $this->mapCalendarToUser->writeSubscriptionMetadata($user, $expirationTs, $id, $secret); + + if (0 !== $expirationTs) { + ++$created; + } else { + $this->logger->warning(self::class . ' could not create subscription for a user', [ + 'userId' => $user->getId(), + 'username' => $user->getUsernameCanonical(), + ]); + } + } + + + if (0 === $offset % $limit) { + $this->em->flush(); + $this->em->clear(); + } } + $this->em->flush(); + $this->em->clear(); + $this->logger->warning(self::class . ' process executed', [ 'created' => $created, 'renewed' => $renewed, ]); + $output->writeln("users synchronized"); + return 0; } @@ -152,7 +166,7 @@ class MapAndSubscribeUserCalendarCommand extends Command parent::configure(); $this - ->setDescription('MSGraph: collect user metadata and create subscription on events for users') + ->setDescription('MSGraph: collect user metadata and create subscription on events for users, and sync the user absence-presence') ->addOption( 'renew-before-end-interval', 'r', diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MSGraphUserRepository.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MSGraphUserRepository.php index c523a1e92..ae822669c 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MSGraphUserRepository.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MSGraphUserRepository.php @@ -65,7 +65,7 @@ class MSGraphUserRepository } /** - * @return array|User[] + * @return array */ public function findByMostOldSubscriptionOrWithoutSubscriptionOrData(DateInterval $interval, int $limit = 50, int $offset = 0): array { diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MSUserAbsenceReader.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MSUserAbsenceReader.php index 83376528f..0e756c194 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MSUserAbsenceReader.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MSUserAbsenceReader.php @@ -13,6 +13,7 @@ namespace Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph; use Chill\CalendarBundle\Exception\UserAbsenceSyncException; use Chill\MainBundle\Entity\User; +use Psr\Log\LoggerInterface; use Symfony\Component\Clock\ClockInterface; use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface; use Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface; @@ -43,7 +44,7 @@ final readonly class MSUserAbsenceReader implements MSUserAbsenceReaderInterface try { $automaticRepliesSettings = $this->machineHttpClient - ->request('GET', '/users/' . $id . '/mailboxSettings/automaticRepliesSetting') + ->request('GET', 'users/' . $id . '/mailboxSettings/automaticRepliesSetting') ->toArray(true); } catch (ClientExceptionInterface|DecodingExceptionInterface|RedirectionExceptionInterface|TransportExceptionInterface $e) { throw new UserAbsenceSyncException("Error receiving response for mailboxSettings", 0, $e); diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MSUserAbsenceSync.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MSUserAbsenceSync.php index aaa06a64b..10bf21b9b 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MSUserAbsenceSync.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MSUserAbsenceSync.php @@ -12,6 +12,7 @@ declare(strict_types=1); namespace Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph; use Chill\MainBundle\Entity\User; +use Psr\Log\LoggerInterface; use Symfony\Component\Clock\ClockInterface; readonly class MSUserAbsenceSync @@ -19,6 +20,7 @@ readonly class MSUserAbsenceSync public function __construct( private MSUserAbsenceReaderInterface $absenceReader, private ClockInterface $clock, + private LoggerInterface $logger, ) { } @@ -35,9 +37,13 @@ readonly class MSUserAbsenceSync return; } + $this->logger->info("will change user absence", ['userId' => $user->getId()]); + if ($absence) { + $this->logger->debug("make user absent", ['userId' => $user->getId()]); $user->setAbsenceStart($this->clock->now()); } else { + $this->logger->debug("make user present", ['userId' => $user->getId()]); $user->setAbsenceStart(null); } } diff --git a/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/MSUserAbsenceSyncTest.php b/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/MSUserAbsenceSyncTest.php index ddd92086d..1b0f1e416 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/MSUserAbsenceSyncTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/MSUserAbsenceSyncTest.php @@ -17,6 +17,7 @@ use Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph\MSUserAbsenceSync; use Chill\MainBundle\Entity\User; use PHPUnit\Framework\TestCase; use Prophecy\PhpUnit\ProphecyTrait; +use Psr\Log\NullLogger; use Symfony\Component\Clock\MockClock; /** @@ -37,7 +38,7 @@ class MSUserAbsenceSyncTest extends TestCase $clock = new MockClock(new \DateTimeImmutable('2023-07-01T12:00:00')); - $syncer = new MSUserAbsenceSync($userAbsenceReader->reveal(), $clock); + $syncer = new MSUserAbsenceSync($userAbsenceReader->reveal(), $clock, new NullLogger()); $syncer->syncUserAbsence($user); From 9b6e6ec20f6bf425245de6f1f08a21e46b7d4eae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 6 Jul 2023 21:34:43 +0200 Subject: [PATCH 278/724] add a changie --- .changes/unreleased/Feature-20230706-213428.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changes/unreleased/Feature-20230706-213428.yaml diff --git a/.changes/unreleased/Feature-20230706-213428.yaml b/.changes/unreleased/Feature-20230706-213428.yaml new file mode 100644 index 000000000..092e5a2e0 --- /dev/null +++ b/.changes/unreleased/Feature-20230706-213428.yaml @@ -0,0 +1,5 @@ +kind: Feature +body: 'Sync user absence / presence through microsoft outlook / graph api. ' +time: 2023-07-06T21:34:28.973144334+02:00 +custom: + Issue: "124" From 93a598b5497339590a4936b5dae4036082d04de6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 6 Jul 2023 21:45:29 +0200 Subject: [PATCH 279/724] improve php applying rector rules --- .../ChillCalendarBundle/Exception/UserAbsenceSyncException.php | 2 +- .../RemoteCalendar/Connector/MSGraph/MSUserAbsenceReader.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillCalendarBundle/Exception/UserAbsenceSyncException.php b/src/Bundle/ChillCalendarBundle/Exception/UserAbsenceSyncException.php index 558774fc5..a5e5a679a 100644 --- a/src/Bundle/ChillCalendarBundle/Exception/UserAbsenceSyncException.php +++ b/src/Bundle/ChillCalendarBundle/Exception/UserAbsenceSyncException.php @@ -13,7 +13,7 @@ namespace Chill\CalendarBundle\Exception; class UserAbsenceSyncException extends \LogicException { - public function __construct(string $message = "", int $code = 20230706, ?\Throwable $previous = null) + public function __construct(string $message = "", int $code = 20_230_706, ?\Throwable $previous = null) { parent::__construct($message, $code, $previous); } diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MSUserAbsenceReader.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MSUserAbsenceReader.php index 0e756c194..c70072a47 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MSUserAbsenceReader.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MSUserAbsenceReader.php @@ -53,7 +53,7 @@ final readonly class MSUserAbsenceReader implements MSUserAbsenceReaderInterface } if (!array_key_exists("status", $automaticRepliesSettings)) { - throw new \LogicException("no key \"status\" on automatic replies settings: " . json_encode($automaticRepliesSettings)); + throw new \LogicException("no key \"status\" on automatic replies settings: " . json_encode($automaticRepliesSettings, JSON_THROW_ON_ERROR)); } return match ($automaticRepliesSettings['status']) { From d3251075e978331ed9b003d223e83bd95f2f8fc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 6 Jul 2023 21:55:29 +0200 Subject: [PATCH 280/724] fix loading of kernel if ms calendar is not created --- .../MSGraph/MSGraphUserRepository.php | 84 ------------------- .../RemoteCalendarCompilerPass.php | 16 ++-- 2 files changed, 6 insertions(+), 94 deletions(-) delete mode 100644 src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MSGraphUserRepository.php diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MSGraphUserRepository.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MSGraphUserRepository.php deleted file mode 100644 index ae822669c..000000000 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MSGraphUserRepository.php +++ /dev/null @@ -1,84 +0,0 @@ -'msgraph' ?? 'subscription_events_expiration' - OR (attributes->'msgraph' ?? 'subscription_events_expiration' AND (attributes->'msgraph'->>'subscription_events_expiration')::int < EXTRACT(EPOCH FROM (NOW() + :interval::interval))) - LIMIT :limit OFFSET :offset - ; - SQL; - - private EntityManagerInterface $entityManager; - - public function __construct(EntityManagerInterface $entityManager) - { - $this->entityManager = $entityManager; - } - - public function countByMostOldSubscriptionOrWithoutSubscriptionOrData(DateInterval $interval): int - { - $rsm = new ResultSetMapping(); - $rsm->addScalarResult('c', 'c'); - - $sql = strtr(self::MOST_OLD_SUBSCRIPTION_OR_ANY_MS_GRAPH, [ - '{select}' => 'COUNT(u) AS c', - 'LIMIT :limit OFFSET :offset' => '', - ]); - - return $this->entityManager->createNativeQuery($sql, $rsm)->setParameters([ - 'interval' => $interval, - ])->getSingleScalarResult(); - } - - /** - * @return array - */ - public function findByMostOldSubscriptionOrWithoutSubscriptionOrData(DateInterval $interval, int $limit = 50, int $offset = 0): array - { - $rsm = new ResultSetMappingBuilder($this->entityManager); - $rsm->addRootEntityFromClassMetadata(User::class, 'u'); - - return $this->entityManager->createNativeQuery( - strtr(self::MOST_OLD_SUBSCRIPTION_OR_ANY_MS_GRAPH, ['{select}' => $rsm->generateSelectClause()]), - $rsm - )->setParameters([ - 'interval' => $interval, - 'limit' => $limit, - 'offset' => $offset, - ])->getResult(); - } -} diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/DependencyInjection/RemoteCalendarCompilerPass.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/DependencyInjection/RemoteCalendarCompilerPass.php index f56735de7..6a986c9db 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/DependencyInjection/RemoteCalendarCompilerPass.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/DependencyInjection/RemoteCalendarCompilerPass.php @@ -23,6 +23,8 @@ use Chill\CalendarBundle\Command\MapAndSubscribeUserCalendarCommand; use Chill\CalendarBundle\Controller\RemoteCalendarConnectAzureController; use Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph\MachineHttpClient; use Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph\MachineTokenStorage; +use Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph\MSUserAbsenceReaderInterface; +use Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph\MSUserAbsenceSync; use Chill\CalendarBundle\RemoteCalendar\Connector\MSGraphRemoteCalendarConnector; use Chill\CalendarBundle\RemoteCalendar\Connector\NullRemoteCalendarConnector; use Chill\CalendarBundle\RemoteCalendar\Connector\RemoteCalendarConnectorInterface; @@ -37,17 +39,13 @@ class RemoteCalendarCompilerPass implements CompilerPassInterface public function process(ContainerBuilder $container) { $config = $container->getParameter('chill_calendar'); - $connector = null; - if (!$config['remote_calendars_sync']['enabled']) { - $connector = NullRemoteCalendarConnector::class; - } - - if ($config['remote_calendars_sync']['microsoft_graph']['enabled']) { + if (true === $config['remote_calendars_sync']['microsoft_graph']['enabled']) { $connector = MSGraphRemoteCalendarConnector::class; $container->setAlias(HttpClientInterface::class . ' $machineHttpClient', MachineHttpClient::class); } else { + $connector = NullRemoteCalendarConnector::class; // remove services which cannot be loaded $container->removeDefinition(MapAndSubscribeUserCalendarCommand::class); $container->removeDefinition(AzureGrantAdminConsentAndAcquireToken::class); @@ -55,16 +53,14 @@ class RemoteCalendarCompilerPass implements CompilerPassInterface $container->removeDefinition(MachineTokenStorage::class); $container->removeDefinition(MachineHttpClient::class); $container->removeDefinition(MSGraphRemoteCalendarConnector::class); + $container->removeDefinition(MSUserAbsenceReaderInterface::class); + $container->removeDefinition(MSUserAbsenceSync::class); } if (!$container->hasAlias(Azure::class) && $container->hasDefinition('knpu.oauth2.client.azure')) { $container->setAlias(Azure::class, 'knpu.oauth2.provider.azure'); } - if (null === $connector) { - throw new RuntimeException('Could not configure remote calendar'); - } - foreach ([ NullRemoteCalendarConnector::class, MSGraphRemoteCalendarConnector::class, ] as $serviceId) { From 43b7139488dd0f3b99286b421ba5c1594b709d18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 6 Jul 2023 22:01:45 +0200 Subject: [PATCH 281/724] One more changie [ci-skip] --- .changes/unreleased/Fixed-20230706-220125.yaml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changes/unreleased/Fixed-20230706-220125.yaml diff --git a/.changes/unreleased/Fixed-20230706-220125.yaml b/.changes/unreleased/Fixed-20230706-220125.yaml new file mode 100644 index 000000000..b9449d514 --- /dev/null +++ b/.changes/unreleased/Fixed-20230706-220125.yaml @@ -0,0 +1,6 @@ +kind: Fixed +body: 'Command to subscribe on MS Graph users calendars: improve the loop to be more + efficient' +time: 2023-07-06T22:01:25.847374805+02:00 +custom: + Issue: "" From 7ccff61c254cea360b68bf33d74ea0988ee1a5e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 7 Jul 2023 09:17:36 +0200 Subject: [PATCH 282/724] Refactor ListAccompanyingPeriod to use a helper for most of the work --- .../Export/Export/ListAccompanyingPeriod.php | 313 +----------------- .../Helper/ListAccompanyingPeriodHelper.php | 306 +++++++++++++++++ .../translations/messages.fr.yml | 2 +- 3 files changed, 315 insertions(+), 306 deletions(-) create mode 100644 src/Bundle/ChillPersonBundle/Export/Helper/ListAccompanyingPeriodHelper.php diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php index af66ab312..3f7821bbc 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php @@ -29,6 +29,7 @@ use Chill\PersonBundle\Entity\Household\PersonHouseholdAddress; use Chill\PersonBundle\Entity\Person\PersonCenterHistory; use Chill\PersonBundle\Entity\SocialWork\SocialIssue; use Chill\PersonBundle\Export\Declarations; +use Chill\PersonBundle\Export\Helper\ListAccompanyingPeriodHelper; use Chill\PersonBundle\Repository\PersonRepository; use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository; use Chill\PersonBundle\Security\Authorization\PersonVoter; @@ -45,95 +46,13 @@ use Symfony\Component\Form\FormBuilderInterface; use Symfony\Contracts\Translation\TranslatorInterface; use function strlen; -class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface +final readonly class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface { - private const FIELDS = [ - 'id', - 'step', - 'stepSince', - 'openingDate', - 'closingDate', - 'referrer', - 'referrerSince', - 'administrativeLocation', - 'locationIsPerson', - 'locationIsTemp', - 'locationPersonName', - 'locationPersonId', - 'origin', - 'closingMotive', - 'confidential', - 'emergency', - 'intensity', - 'job', - 'isRequestorPerson', - 'isRequestorThirdParty', - 'requestorPerson', - 'requestorPersonId', - 'requestorThirdParty', - 'requestorThirdPartyId', - 'scopes', - 'socialIssues', - 'createdAt', - 'createdBy', - 'updatedAt', - 'updatedBy', - ]; - - private ExportAddressHelper $addressHelper; - - private DateTimeHelper $dateTimeHelper; - - private EntityManagerInterface $entityManager; - - private PersonRenderInterface $personRender; - - private PersonRepository $personRepository; - - private RollingDateConverterInterface $rollingDateConverter; - - private SocialIssueRender $socialIssueRender; - - private SocialIssueRepository $socialIssueRepository; - - private ThirdPartyRender $thirdPartyRender; - - private ThirdPartyRepository $thirdPartyRepository; - - private TranslatableStringHelperInterface $translatableStringHelper; - - private TranslatorInterface $translator; - - private UserHelper $userHelper; - public function __construct( - ExportAddressHelper $addressHelper, - DateTimeHelper $dateTimeHelper, - EntityManagerInterface $entityManager, - PersonRenderInterface $personRender, - PersonRepository $personRepository, - ThirdPartyRepository $thirdPartyRepository, - ThirdPartyRender $thirdPartyRender, - SocialIssueRepository $socialIssueRepository, - SocialIssueRender $socialIssueRender, - TranslatableStringHelperInterface $translatableStringHelper, - TranslatorInterface $translator, - RollingDateConverterInterface $rollingDateConverter, - UserHelper $userHelper + private EntityManagerInterface $entityManager, + private RollingDateConverterInterface $rollingDateConverter, + private ListAccompanyingPeriodHelper $listAccompanyingPeriodHelper, ) { - $this->addressHelper = $addressHelper; - $this->dateTimeHelper = $dateTimeHelper; - $this->entityManager = $entityManager; - $this->personRender = $personRender; - $this->personRepository = $personRepository; - $this->socialIssueRender = $socialIssueRender; - $this->socialIssueRepository = $socialIssueRepository; - $this->thirdPartyRender = $thirdPartyRender; - $this->thirdPartyRepository = $thirdPartyRepository; - $this->translatableStringHelper = $translatableStringHelper; - $this->translator = $translator; - $this->rollingDateConverter = $rollingDateConverter; - $this->userHelper = $userHelper; } public function buildForm(FormBuilderInterface $builder) @@ -169,141 +88,12 @@ class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface public function getLabels($key, array $values, $data) { - if (substr($key, 0, strlen('address_fields')) === 'address_fields') { - return $this->addressHelper->getLabel($key, $values, $data, 'address_fields'); - } - - switch ($key) { - case 'stepSince': - case 'openingDate': - case 'closingDate': - case 'referrerSince': - case 'createdAt': - case 'updatedAt': - return $this->dateTimeHelper->getLabel('export.list.acp.' . $key); - - case 'origin': - case 'closingMotive': - case 'job': - return function ($value) use ($key) { - if ('_header' === $value) { - return 'export.list.acp.' . $key; - } - - if (null === $value) { - return ''; - } - - return $this->translatableStringHelper->localize(json_decode($value, true, 512, JSON_THROW_ON_ERROR)); - }; - - case 'locationPersonName': - case 'requestorPerson': - return function ($value) use ($key) { - if ('_header' === $value) { - return 'export.list.acp.' . $key; - } - - if (null === $value || null === $person = $this->personRepository->find($value)) { - return ''; - } - - return $this->personRender->renderString($person, []); - }; - - case 'requestorThirdParty': - return function ($value) use ($key) { - if ('_header' === $value) { - return 'export.list.acp.' . $key; - } - - if (null === $value || null === $thirdparty = $this->thirdPartyRepository->find($value)) { - return ''; - } - - return $this->thirdPartyRender->renderString($thirdparty, []); - }; - - case 'scopes': - return function ($value) use ($key) { - if ('_header' === $value) { - return 'export.list.acp.' . $key; - } - - if (null === $value) { - return ''; - } - - return implode( - '|', - array_map( - fn ($s) => $this->translatableStringHelper->localize($s), - json_decode($value, true, 512, JSON_THROW_ON_ERROR) - ) - ); - }; - - case 'socialIssues': - return function ($value) use ($key) { - if ('_header' === $value) { - return 'export.list.acp.' . $key; - } - - if (null === $value) { - return ''; - } - - return implode( - '|', - array_map( - fn ($s) => $this->socialIssueRender->renderString($this->socialIssueRepository->find($s), []), - json_decode($value, true, 512, JSON_THROW_ON_ERROR) - ) - ); - }; - - case 'step': - return fn ($value) => match ($value) { - '_header' => 'export.list.acp.step', - null => '', - AccompanyingPeriod::STEP_DRAFT => $this->translator->trans('course.draft'), - AccompanyingPeriod::STEP_CONFIRMED => $this->translator->trans('course.confirmed'), - AccompanyingPeriod::STEP_CLOSED => $this->translator->trans('course.closed'), - AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_SHORT => $this->translator->trans('course.inactive_short'), - AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_LONG => $this->translator->trans('course.inactive_long'), - default => $value, - }; - - case 'intensity': - return fn ($value) => match ($value) { - '_header' => 'export.list.acp.intensity', - null => '', - AccompanyingPeriod::INTENSITY_OCCASIONAL => $this->translator->trans('occasional'), - AccompanyingPeriod::INTENSITY_REGULAR => $this->translator->trans('regular'), - default => $value, - }; - - default: - return static function ($value) use ($key) { - if ('_header' === $value) { - return 'export.list.acp.' . $key; - } - - if (null === $value) { - return ''; - } - - return $value; - }; - } + return $this->listAccompanyingPeriodHelper->getLabels($key, $values, $data); } public function getQueryKeys($data) { - return array_merge( - self::FIELDS, - $this->addressHelper->getKeys(ExportAddressHelper::F_ALL, 'address_fields') - ); + return $this->listAccompanyingPeriodHelper->getQueryKeys($data); } public function getResult($query, $data) @@ -341,7 +131,7 @@ class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface ->setParameter('list_acp_step', AccompanyingPeriod::STEP_DRAFT) ->setParameter('authorized_centers', $centers); - $this->addSelectClauses($qb, $this->rollingDateConverter->convert($data['calc_date'])); + $this->listAccompanyingPeriodHelper->addSelectClauses($qb, $this->rollingDateConverter->convert($data['calc_date'])); return $qb; } @@ -357,91 +147,4 @@ class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface Declarations::ACP_TYPE, ]; } - - private function addSelectClauses(QueryBuilder $qb, DateTimeImmutable $calcDate): void - { - // add the regular fields - foreach (['id', 'openingDate', 'closingDate', 'confidential', 'emergency', 'intensity', 'createdAt', 'updatedAt'] as $field) { - $qb->addSelect(sprintf('acp.%s AS %s', $field, $field)); - } - - // add the field which are simple association - foreach (['origin' => 'label', 'closingMotive' => 'name', 'job' => 'label', 'createdBy' => 'label', 'updatedBy' => 'label', 'administrativeLocation' => 'name'] as $entity => $field) { - $qb - ->leftJoin(sprintf('acp.%s', $entity), "{$entity}_t") - ->addSelect(sprintf('%s_t.%s AS %s', $entity, $field, $entity)); - } - - // step at date - $qb - ->addSelect('stepHistory.step AS step') - ->addSelect('stepHistory.startDate AS stepSince') - ->leftJoin('acp.stepHistories', 'stepHistory') - ->andWhere( - $qb->expr()->andX( - $qb->expr()->lte('stepHistory.startDate', ':calcDate'), - $qb->expr()->orX($qb->expr()->isNull('stepHistory.endDate'), $qb->expr()->gt('stepHistory.endDate', ':calcDate')) - ) - ); - - // referree at date - $qb - ->addSelect('referrer_t.label AS referrer') - ->addSelect('userHistory.startDate AS referrerSince') - ->leftJoin('acp.userHistories', 'userHistory') - ->leftJoin('userHistory.user', 'referrer_t') - ->andWhere( - $qb->expr()->orX( - $qb->expr()->isNull('userHistory'), - $qb->expr()->andX( - $qb->expr()->lte('userHistory.startDate', ':calcDate'), - $qb->expr()->orX($qb->expr()->isNull('userHistory.endDate'), $qb->expr()->gt('userHistory.endDate', ':calcDate')) - ) - ) - ); - - // location of the acp - $qb - ->addSelect('CASE WHEN locationHistory.personLocation IS NOT NULL THEN 1 ELSE 0 END AS locationIsPerson') - ->addSelect('CASE WHEN locationHistory.personLocation IS NOT NULL THEN 0 ELSE 1 END AS locationIsTemp') - ->addSelect('IDENTITY(locationHistory.personLocation) AS locationPersonName') - ->addSelect('IDENTITY(locationHistory.personLocation) AS locationPersonId') - ->leftJoin('acp.locationHistories', 'locationHistory') - ->andWhere( - $qb->expr()->orX( - $qb->expr()->isNull('locationHistory'), - $qb->expr()->andX( - $qb->expr()->lte('locationHistory.startDate', ':calcDate'), - $qb->expr()->orX($qb->expr()->isNull('locationHistory.endDate'), $qb->expr()->gt('locationHistory.endDate', ':calcDate')) - ) - ) - ) - ->leftJoin( - PersonHouseholdAddress::class, - 'personAddress', - Join::WITH, - 'locationHistory.personLocation = personAddress.person AND (personAddress.validFrom <= :calcDate AND (personAddress.validTo IS NULL OR personAddress.validTo > :calcDate))' - ) - ->leftJoin(Address::class, 'acp_address', Join::WITH, 'COALESCE(IDENTITY(locationHistory.addressLocation), IDENTITY(personAddress.address)) = acp_address.id'); - - $this->addressHelper->addSelectClauses(ExportAddressHelper::F_ALL, $qb, 'acp_address', 'address_fields'); - - // requestor - $qb - ->addSelect('CASE WHEN acp.requestorPerson IS NULL THEN 1 ELSE 0 END AS isRequestorPerson') - ->addSelect('CASE WHEN acp.requestorPerson IS NULL THEN 0 ELSE 1 END AS isRequestorThirdParty') - ->addSelect('IDENTITY(acp.requestorPerson) AS requestorPersonId') - ->addSelect('IDENTITY(acp.requestorThirdParty) AS requestorThirdPartyId') - ->addSelect('IDENTITY(acp.requestorPerson) AS requestorPerson') - ->addSelect('IDENTITY(acp.requestorThirdParty) AS requestorThirdParty'); - - $qb - // scopes - ->addSelect('(SELECT AGGREGATE(scope.name) FROM ' . Scope::class . ' scope WHERE scope MEMBER OF acp.scopes) AS scopes') - // social issues - ->addSelect('(SELECT AGGREGATE(socialIssue.id) FROM ' . SocialIssue::class . ' socialIssue WHERE socialIssue MEMBER OF acp.socialIssues) AS socialIssues'); - - // add parameter - $qb->setParameter('calcDate', $calcDate); - } } diff --git a/src/Bundle/ChillPersonBundle/Export/Helper/ListAccompanyingPeriodHelper.php b/src/Bundle/ChillPersonBundle/Export/Helper/ListAccompanyingPeriodHelper.php new file mode 100644 index 000000000..8671b4977 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Export/Helper/ListAccompanyingPeriodHelper.php @@ -0,0 +1,306 @@ +addressHelper->getKeys(ExportAddressHelper::F_ALL, 'address_fields') + ); + } + + public function getLabels($key, array $values, $data) + { + if (substr($key, 0, strlen('address_fields')) === 'address_fields') { + return $this->addressHelper->getLabel($key, $values, $data, 'address_fields'); + } + + switch ($key) { + case 'stepSince': + case 'openingDate': + case 'closingDate': + case 'referrerSince': + case 'createdAt': + case 'updatedAt': + return $this->dateTimeHelper->getLabel('export.list.acp.' . $key); + + case 'origin': + case 'closingMotive': + case 'job': + return function ($value) use ($key) { + if ('_header' === $value) { + return 'export.list.acp.' . $key; + } + + if (null === $value) { + return ''; + } + + return $this->translatableStringHelper->localize(json_decode($value, true, 512, JSON_THROW_ON_ERROR)); + }; + + case 'locationPersonName': + case 'requestorPerson': + return function ($value) use ($key) { + if ('_header' === $value) { + return 'export.list.acp.' . $key; + } + + if (null === $value || null === $person = $this->personRepository->find($value)) { + return ''; + } + + return $this->personRender->renderString($person, []); + }; + + case 'requestorThirdParty': + return function ($value) use ($key) { + if ('_header' === $value) { + return 'export.list.acp.' . $key; + } + + if (null === $value || null === $thirdparty = $this->thirdPartyRepository->find($value)) { + return ''; + } + + return $this->thirdPartyRender->renderString($thirdparty, []); + }; + + case 'scopes': + return function ($value) use ($key) { + if ('_header' === $value) { + return 'export.list.acp.' . $key; + } + + if (null === $value) { + return ''; + } + + return implode( + '|', + array_map( + fn ($s) => $this->translatableStringHelper->localize($s), + json_decode($value, true, 512, JSON_THROW_ON_ERROR) + ) + ); + }; + + case 'socialIssues': + return function ($value) use ($key) { + if ('_header' === $value) { + return 'export.list.acp.' . $key; + } + + if (null === $value) { + return ''; + } + + return implode( + '|', + array_map( + fn ($s) => $this->socialIssueRender->renderString($this->socialIssueRepository->find($s), []), + json_decode($value, true, 512, JSON_THROW_ON_ERROR) + ) + ); + }; + + case 'step': + return fn ($value) => match ($value) { + '_header' => 'export.list.acp.step', + null => '', + AccompanyingPeriod::STEP_DRAFT => $this->translator->trans('course.draft'), + AccompanyingPeriod::STEP_CONFIRMED => $this->translator->trans('course.confirmed'), + AccompanyingPeriod::STEP_CLOSED => $this->translator->trans('course.closed'), + AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_SHORT => $this->translator->trans('course.inactive_short'), + AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_LONG => $this->translator->trans('course.inactive_long'), + default => $value, + }; + + case 'intensity': + return fn ($value) => match ($value) { + '_header' => 'export.list.acp.intensity', + null => '', + AccompanyingPeriod::INTENSITY_OCCASIONAL => $this->translator->trans('occasional'), + AccompanyingPeriod::INTENSITY_REGULAR => $this->translator->trans('regular'), + default => $value, + }; + + default: + return static function ($value) use ($key) { + if ('_header' === $value) { + return 'export.list.acp.' . $key; + } + + if (null === $value) { + return ''; + } + + return $value; + }; + } + } + + public function addSelectClauses(QueryBuilder $qb, \DateTimeImmutable $calcDate): void + { + // add the regular fields + foreach (['id', 'openingDate', 'closingDate', 'confidential', 'emergency', 'intensity', 'createdAt', 'updatedAt'] as $field) { + $qb->addSelect(sprintf('acp.%s AS %s', $field, $field)); + } + + // add the field which are simple association + foreach (['origin' => 'label', 'closingMotive' => 'name', 'job' => 'label', 'createdBy' => 'label', 'updatedBy' => 'label', 'administrativeLocation' => 'name'] as $entity => $field) { + $qb + ->leftJoin(sprintf('acp.%s', $entity), "{$entity}_t") + ->addSelect(sprintf('%s_t.%s AS %s', $entity, $field, $entity)); + } + + // step at date + $qb + ->addSelect('stepHistory.step AS step') + ->addSelect('stepHistory.startDate AS stepSince') + ->leftJoin('acp.stepHistories', 'stepHistory') + ->andWhere( + $qb->expr()->andX( + $qb->expr()->lte('stepHistory.startDate', ':calcDate'), + $qb->expr()->orX($qb->expr()->isNull('stepHistory.endDate'), $qb->expr()->gt('stepHistory.endDate', ':calcDate')) + ) + ); + + // referree at date + $qb + ->addSelect('referrer_t.label AS referrer') + ->addSelect('userHistory.startDate AS referrerSince') + ->leftJoin('acp.userHistories', 'userHistory') + ->leftJoin('userHistory.user', 'referrer_t') + ->andWhere( + $qb->expr()->orX( + $qb->expr()->isNull('userHistory'), + $qb->expr()->andX( + $qb->expr()->lte('userHistory.startDate', ':calcDate'), + $qb->expr()->orX($qb->expr()->isNull('userHistory.endDate'), $qb->expr()->gt('userHistory.endDate', ':calcDate')) + ) + ) + ); + + // location of the acp + $qb + ->addSelect('CASE WHEN locationHistory.personLocation IS NOT NULL THEN 1 ELSE 0 END AS locationIsPerson') + ->addSelect('CASE WHEN locationHistory.personLocation IS NOT NULL THEN 0 ELSE 1 END AS locationIsTemp') + ->addSelect('IDENTITY(locationHistory.personLocation) AS locationPersonName') + ->addSelect('IDENTITY(locationHistory.personLocation) AS locationPersonId') + ->leftJoin('acp.locationHistories', 'locationHistory') + ->andWhere( + $qb->expr()->orX( + $qb->expr()->isNull('locationHistory'), + $qb->expr()->andX( + $qb->expr()->lte('locationHistory.startDate', ':calcDate'), + $qb->expr()->orX($qb->expr()->isNull('locationHistory.endDate'), $qb->expr()->gt('locationHistory.endDate', ':calcDate')) + ) + ) + ) + ->leftJoin( + PersonHouseholdAddress::class, + 'personAddress', + Join::WITH, + 'locationHistory.personLocation = personAddress.person AND (personAddress.validFrom <= :calcDate AND (personAddress.validTo IS NULL OR personAddress.validTo > :calcDate))' + ) + ->leftJoin(Address::class, 'acp_address', Join::WITH, 'COALESCE(IDENTITY(locationHistory.addressLocation), IDENTITY(personAddress.address)) = acp_address.id'); + + $this->addressHelper->addSelectClauses(ExportAddressHelper::F_ALL, $qb, 'acp_address', 'address_fields'); + + // requestor + $qb + ->addSelect('CASE WHEN acp.requestorPerson IS NULL THEN 1 ELSE 0 END AS isRequestorPerson') + ->addSelect('CASE WHEN acp.requestorPerson IS NULL THEN 0 ELSE 1 END AS isRequestorThirdParty') + ->addSelect('IDENTITY(acp.requestorPerson) AS requestorPersonId') + ->addSelect('IDENTITY(acp.requestorThirdParty) AS requestorThirdPartyId') + ->addSelect('IDENTITY(acp.requestorPerson) AS requestorPerson') + ->addSelect('IDENTITY(acp.requestorThirdParty) AS requestorThirdParty'); + + $qb + // scopes + ->addSelect('(SELECT AGGREGATE(scope.name) FROM ' . Scope::class . ' scope WHERE scope MEMBER OF acp.scopes) AS scopes') + // social issues + ->addSelect('(SELECT AGGREGATE(socialIssue.id) FROM ' . SocialIssue::class . ' socialIssue WHERE socialIssue MEMBER OF acp.socialIssues) AS socialIssues'); + + // add parameter + $qb->setParameter('calcDate', $calcDate); + } +} diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 2f7800e2b..08e51aeab 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -1175,7 +1175,7 @@ export: referrerSince: Référent depuis le locationIsPerson: Parcours localisé auprès d'un usager concerné locationIsTemp: Parcours avec une localisation temporaire - acpLocationPersonName: Usager auprès duquel le parcours est localisé + locationPersonName: Usager auprès duquel le parcours est localisé locationPersonId: Identifiant de l'usager auprès duquel le parcours est localisé acpaddress_fieldscountry: Pays de l'adresse isRequestorPerson: Le demandeur est-il un usager ? From 56d9072abe971cf69f07a55a931e8becabe8fb68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 7 Jul 2023 09:33:03 +0200 Subject: [PATCH 283/724] change id, to avoid collision between ListPersonHelper and ListAccompanyingPeriodHelper --- .../Export/Helper/ListAccompanyingPeriodHelper.php | 6 ++++-- .../ChillPersonBundle/Export/Helper/ListPersonHelper.php | 7 ++++++- src/Bundle/ChillPersonBundle/translations/messages.fr.yml | 4 +++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Export/Helper/ListAccompanyingPeriodHelper.php b/src/Bundle/ChillPersonBundle/Export/Helper/ListAccompanyingPeriodHelper.php index 8671b4977..a32d78904 100644 --- a/src/Bundle/ChillPersonBundle/Export/Helper/ListAccompanyingPeriodHelper.php +++ b/src/Bundle/ChillPersonBundle/Export/Helper/ListAccompanyingPeriodHelper.php @@ -32,7 +32,7 @@ use Symfony\Contracts\Translation\TranslatorInterface; final readonly class ListAccompanyingPeriodHelper { public const FIELDS = [ - 'id', + 'acpId', 'step', 'stepSince', 'openingDate', @@ -219,8 +219,10 @@ final readonly class ListAccompanyingPeriodHelper public function addSelectClauses(QueryBuilder $qb, \DateTimeImmutable $calcDate): void { + $qb->addSelect('acp.id AS acpId'); + // add the regular fields - foreach (['id', 'openingDate', 'closingDate', 'confidential', 'emergency', 'intensity', 'createdAt', 'updatedAt'] as $field) { + foreach (['openingDate', 'closingDate', 'confidential', 'emergency', 'intensity', 'createdAt', 'updatedAt'] as $field) { $qb->addSelect(sprintf('acp.%s AS %s', $field, $field)); } diff --git a/src/Bundle/ChillPersonBundle/Export/Helper/ListPersonHelper.php b/src/Bundle/ChillPersonBundle/Export/Helper/ListPersonHelper.php index 77a1d9c86..697019ca3 100644 --- a/src/Bundle/ChillPersonBundle/Export/Helper/ListPersonHelper.php +++ b/src/Bundle/ChillPersonBundle/Export/Helper/ListPersonHelper.php @@ -42,7 +42,7 @@ use function strlen; class ListPersonHelper { public const FIELDS = [ - 'id', + 'personId', 'civility', 'firstName', 'lastName', @@ -124,6 +124,11 @@ class ListPersonHelper } switch ($f) { + case 'personId': + $qb->addSelect('person.id AS personId'); + + break; + case 'countryOfBirth': case 'nationality': $qb->addSelect(sprintf('IDENTITY(person.%s) as %s', $f, $f)); diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 08e51aeab..0a82fc330 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -997,6 +997,8 @@ notification: Notify referrer: Notifier le référent Notify any: Notifier d'autres utilisateurs +personId: Identifiant de l'usager + export: export: acp_stats: @@ -1152,7 +1154,7 @@ export: Generate a list of accompanying periods, filtered on different parameters.: Génère une liste des parcours d'accompagnement, filtrée sur différents paramètres. Date of calculation for associated elements: Date de calcul des éléments associés The associated referree, localisation, and other elements will be valid at this date: Les éléments associés, comme la localisation, le référent et d'autres éléments seront valides à cette date - id: Identifiant du parcours + acpId: Identifiant du parcours openingDate: Date d'ouverture du parcours closingDate: Date de fermeture du parcours closingMotive: Motif de cloture From 7f30742fc3615311500931f9d22563f228e3c752 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 7 Jul 2023 09:36:39 +0200 Subject: [PATCH 284/724] Rename ListPersonWithAccompanyingPeriod to ListPersonHavingAccompanyingPeriod --- ...ngPeriod.php => ListPersonHavingAccompanyingPeriod.php} | 7 ++++++- .../ChillPersonBundle/config/services/exports_person.yaml | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) rename src/Bundle/ChillPersonBundle/Export/Export/{ListPersonWithAccompanyingPeriod.php => ListPersonHavingAccompanyingPeriod.php} (96%) diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Export/Export/ListPersonHavingAccompanyingPeriod.php similarity index 96% rename from src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriod.php rename to src/Bundle/ChillPersonBundle/Export/Export/ListPersonHavingAccompanyingPeriod.php index 370046232..f2e4de4e3 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListPersonHavingAccompanyingPeriod.php @@ -35,7 +35,12 @@ use function count; use function in_array; use function strlen; -class ListPersonWithAccompanyingPeriod implements ExportElementValidatedInterface, ListInterface, GroupedExportInterface +/** + * List the persons, having an accompanying period. + * + * Details of the accompanying period are not included + */ +class ListPersonHavingAccompanyingPeriod implements ExportElementValidatedInterface, ListInterface, GroupedExportInterface { private ExportAddressHelper $addressHelper; diff --git a/src/Bundle/ChillPersonBundle/config/services/exports_person.yaml b/src/Bundle/ChillPersonBundle/config/services/exports_person.yaml index 64360aee9..81875fafb 100644 --- a/src/Bundle/ChillPersonBundle/config/services/exports_person.yaml +++ b/src/Bundle/ChillPersonBundle/config/services/exports_person.yaml @@ -24,7 +24,7 @@ services: tags: - { name: chill.export, alias: list_person } - Chill\PersonBundle\Export\Export\ListPersonWithAccompanyingPeriod: + Chill\PersonBundle\Export\Export\ListPersonHavingAccompanyingPeriod: autowire: true autoconfigure: true tags: From 17d2b795b41d9aee8457ad9ade199e07d1c5be60 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Fri, 7 Jul 2023 11:38:00 +0200 Subject: [PATCH 285/724] update changelog --- .changes/unreleased/DX-20230623-122408.yaml | 5 --- .../unreleased/Feature-20230623-122530.yaml | 5 --- .../unreleased/Feature-20230623-122702.yaml | 6 --- .../unreleased/Feature-20230623-124438.yaml | 5 --- .../unreleased/Fixed-20230628-170055.yaml | 6 --- .../unreleased/Fixed-20230629-124412.yaml | 6 --- .../unreleased/Fixed-20230629-231503.yaml | 5 --- .../unreleased/Fixed-20230630-171119.yaml | 5 --- .../unreleased/Fixed-20230630-171153.yaml | 5 --- .changie.yaml | 2 + CHANGELOG.md | 37 +++++++++++++++++++ .../Resources/public/chill/scss/forms.scss | 2 +- 12 files changed, 40 insertions(+), 49 deletions(-) delete mode 100644 .changes/unreleased/DX-20230623-122408.yaml delete mode 100644 .changes/unreleased/Feature-20230623-122530.yaml delete mode 100644 .changes/unreleased/Feature-20230623-122702.yaml delete mode 100644 .changes/unreleased/Feature-20230623-124438.yaml delete mode 100644 .changes/unreleased/Fixed-20230628-170055.yaml delete mode 100644 .changes/unreleased/Fixed-20230629-124412.yaml delete mode 100644 .changes/unreleased/Fixed-20230629-231503.yaml delete mode 100644 .changes/unreleased/Fixed-20230630-171119.yaml delete mode 100644 .changes/unreleased/Fixed-20230630-171153.yaml diff --git a/.changes/unreleased/DX-20230623-122408.yaml b/.changes/unreleased/DX-20230623-122408.yaml deleted file mode 100644 index 58dd96180..000000000 --- a/.changes/unreleased/DX-20230623-122408.yaml +++ /dev/null @@ -1,5 +0,0 @@ -kind: DX -body: '[FilterOrderHelper] add entity choice and singleCheckbox' -time: 2023-06-23T12:24:08.133491895+02:00 -custom: - Issue: "" diff --git a/.changes/unreleased/Feature-20230623-122530.yaml b/.changes/unreleased/Feature-20230623-122530.yaml deleted file mode 100644 index 922750ea8..000000000 --- a/.changes/unreleased/Feature-20230623-122530.yaml +++ /dev/null @@ -1,5 +0,0 @@ -kind: Feature -body: '[activity list] add filtering for activities list' -time: 2023-06-23T12:25:30.49643551+02:00 -custom: - Issue: "" diff --git a/.changes/unreleased/Feature-20230623-122702.yaml b/.changes/unreleased/Feature-20230623-122702.yaml deleted file mode 100644 index e1d1b0e1f..000000000 --- a/.changes/unreleased/Feature-20230623-122702.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: Feature -body: '[activity list] in person context, show also the activities from the accompanying - periods where the person participates' -time: 2023-06-23T12:27:02.159041095+02:00 -custom: - Issue: "" diff --git a/.changes/unreleased/Feature-20230623-124438.yaml b/.changes/unreleased/Feature-20230623-124438.yaml deleted file mode 100644 index bc199d3bb..000000000 --- a/.changes/unreleased/Feature-20230623-124438.yaml +++ /dev/null @@ -1,5 +0,0 @@ -kind: Feature -body: '[activity list] add pagination to the list of activities' -time: 2023-06-23T12:44:38.879098862+02:00 -custom: - Issue: "" diff --git a/.changes/unreleased/Fixed-20230628-170055.yaml b/.changes/unreleased/Fixed-20230628-170055.yaml deleted file mode 100644 index 7f9ec3028..000000000 --- a/.changes/unreleased/Fixed-20230628-170055.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: Fixed -body: '[export] Rename label for CurrentActionFilter (on accompanying period work) - to make precision between "ouvert" and "sans date de fin"' -time: 2023-06-28T17:00:55.206937751+02:00 -custom: - Issue: "" diff --git a/.changes/unreleased/Fixed-20230629-124412.yaml b/.changes/unreleased/Fixed-20230629-124412.yaml deleted file mode 100644 index 7fc3d3eb0..000000000 --- a/.changes/unreleased/Fixed-20230629-124412.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: Fixed -body: Force the db to have either a person_location or a address_location, and avoid - to have both also internally in the entity -time: 2023-06-29T12:44:12.019663991+02:00 -custom: - Issue: "" diff --git a/.changes/unreleased/Fixed-20230629-231503.yaml b/.changes/unreleased/Fixed-20230629-231503.yaml deleted file mode 100644 index e021d1fda..000000000 --- a/.changes/unreleased/Fixed-20230629-231503.yaml +++ /dev/null @@ -1,5 +0,0 @@ -kind: Fixed -body: '[export] set rolling date on person age aggregator' -time: 2023-06-29T23:15:03.20841309+02:00 -custom: - Issue: "" diff --git a/.changes/unreleased/Fixed-20230630-171119.yaml b/.changes/unreleased/Fixed-20230630-171119.yaml deleted file mode 100644 index f3185ace2..000000000 --- a/.changes/unreleased/Fixed-20230630-171119.yaml +++ /dev/null @@ -1,5 +0,0 @@ -kind: Fixed -body: '[export] fix list when a person locating a course is without address' -time: 2023-06-30T17:11:19.454081914+02:00 -custom: - Issue: "" diff --git a/.changes/unreleased/Fixed-20230630-171153.yaml b/.changes/unreleased/Fixed-20230630-171153.yaml deleted file mode 100644 index c09bd93d0..000000000 --- a/.changes/unreleased/Fixed-20230630-171153.yaml +++ /dev/null @@ -1,5 +0,0 @@ -kind: Fixed -body: '[export] remove unused condition on course about duration participation' -time: 2023-06-30T17:11:53.076615549+02:00 -custom: - Issue: "" diff --git a/.changie.yaml b/.changie.yaml index 8a25ed695..cda69de65 100644 --- a/.changie.yaml +++ b/.changie.yaml @@ -30,6 +30,8 @@ kinds: auto: patch - label: DX auto: patch + - label: UX + auto: patch newlines: afterChangelogHeader: 1 beforeChangelogVersion: 1 diff --git a/CHANGELOG.md b/CHANGELOG.md index 93ff93556..1f51bf06e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,43 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html), and is generated by [Changie](https://github.com/miniscruff/changie). +## v2.4.0 - 2023-07-07 +### Feature +* [activity list] add filtering for activities list + + +* [activity list] in person context, show also the activities from the accompanying periods where the person participates + + +* [activity list] add pagination to the list of activities + + +* ([#118](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/118)) improve UX design for filterOrder box + + + + +### Fixed +* [export] Rename label for CurrentActionFilter (on accompanying period work) to make precision between "ouvert" and "sans date de fin" + + +* Force the db to have either a person_location or a address_location, and avoid to have both also internally in the entity + + +* [export] set rolling date on person age aggregator + + +* [export] fix list when a person locating a course is without address + + +* [export] remove unused condition on course about duration participation + + +### DX +* [FilterOrderHelper] add entity choice and singleCheckbox + + + ## v2.3.0 - 2023-06-27 ### Feature * ([#110](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/110)) Edit saved exports options: the saved exports options (forms, filters, aggregators) are now editable. diff --git a/src/Bundle/ChillMainBundle/Resources/public/chill/scss/forms.scss b/src/Bundle/ChillMainBundle/Resources/public/chill/scss/forms.scss index a517a5516..28c597bc0 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/chill/scss/forms.scss +++ b/src/Bundle/ChillMainBundle/Resources/public/chill/scss/forms.scss @@ -44,5 +44,5 @@ form { } .chill_filter_order { - background: $gray-100; + background: $gray-100; } \ No newline at end of file From c8146ded17b332a3566b58b7c824840259b7f7ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 7 Jul 2023 12:36:24 +0200 Subject: [PATCH 286/724] Feature: add a list for people with their associated accompanying course --- .../unreleased/Feature-20230707-123609.yaml | 5 + .../Export/ExportInterface.php | 2 +- ...istPersonWithAccompanyingPeriodDetails.php | 149 ++++++++++++++++++ .../Helper/ListAccompanyingPeriodHelper.php | 39 +++-- .../Export/Helper/ListPersonHelper.php | 42 ++--- .../config/services/exports_person.yaml | 20 +-- .../translations/messages.fr.yml | 10 +- 7 files changed, 213 insertions(+), 54 deletions(-) create mode 100644 .changes/unreleased/Feature-20230707-123609.yaml create mode 100644 src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriodDetails.php diff --git a/.changes/unreleased/Feature-20230707-123609.yaml b/.changes/unreleased/Feature-20230707-123609.yaml new file mode 100644 index 000000000..51ff94d4c --- /dev/null +++ b/.changes/unreleased/Feature-20230707-123609.yaml @@ -0,0 +1,5 @@ +kind: Feature +body: '[export] Add a list for people with their associated course' +time: 2023-07-07T12:36:09.596469063+02:00 +custom: + Issue: "125" diff --git a/src/Bundle/ChillMainBundle/Export/ExportInterface.php b/src/Bundle/ChillMainBundle/Export/ExportInterface.php index f357a9fdb..a11a51746 100644 --- a/src/Bundle/ChillMainBundle/Export/ExportInterface.php +++ b/src/Bundle/ChillMainBundle/Export/ExportInterface.php @@ -97,7 +97,7 @@ interface ExportInterface extends ExportElementInterface * @param mixed[] $values The values from the result. if there are duplicates, those might be given twice. Example: array('FR', 'BE', 'CZ', 'FR', 'BE', 'FR') * @param mixed $data The data from the export's form (as defined in `buildForm`) * - * @return callable(null|string|int|float|'_header' $value): string|int|\DateTimeInterface where the first argument is the value, and the function should return the label to show in the formatted file. Example : `function($countryCode) use ($countries) { return $countries[$countryCode]->getName(); }` + * @return (callable(null|string|int|float|'_header' $value): string|int|\DateTimeInterface) where the first argument is the value, and the function should return the label to show in the formatted file. Example : `function($countryCode) use ($countries) { return $countries[$countryCode]->getName(); }` */ public function getLabels($key, array $values, $data); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriodDetails.php b/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriodDetails.php new file mode 100644 index 000000000..295d87842 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriodDetails.php @@ -0,0 +1,149 @@ +add('address_date', PickRollingDateType::class, [ + 'label' => 'Data valid at this date', + 'help' => 'Data regarding center, addresses, and so on will be computed at this date', + ]); + } + public function getFormDefaultData(): array + { + return ['address_date' => new RollingDate(RollingDate::T_TODAY)]; + } + + public function getAllowedFormattersTypes() + { + return [FormatterInterface::TYPE_LIST]; + } + + public function getDescription() + { + return 'export.list.person_with_acp.Create a list of people having an accompaying periods with details of period, according to various filters.'; + } + + public function getGroup(): string + { + return 'Exports of persons'; + } + + public function getLabels($key, array $values, $data) + { + if (in_array($key, $this->listPersonHelper->getAllKeys(), true)) { + return $this->listPersonHelper->getLabels($key, $values, $data); + } + + return $this->listAccompanyingPeriodHelper->getLabels($key, $values, $data); + } + + public function getQueryKeys($data) + { + return array_merge( + $this->listPersonHelper->getAllKeys(), + $this->listAccompanyingPeriodHelper->getQueryKeys($data), + ); + } + + public function getResult($query, $data) + { + return $query->getQuery()->getResult(AbstractQuery::HYDRATE_SCALAR); + } + + public function getTitle() + { + return 'export.list.person_with_acp.List peoples having an accompanying period with period details'; + } + + public function getType() + { + return Declarations::PERSON_TYPE; + } + + /** + * param array{fields: string[], address_date: DateTimeImmutable} $data. + */ + public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) + { + $centers = array_map(static fn ($el) => $el['center'], $acl); + + $qb = $this->entityManager->createQueryBuilder(); + + $qb->from(Person::class, 'person') + ->join('person.accompanyingPeriodParticipations', 'acppart') + ->join('acppart.accompanyingPeriod', 'acp') + ->andWhere($qb->expr()->neq('acp.step', "'" . AccompanyingPeriod::STEP_DRAFT . "'")) + ->andWhere( + $qb->expr()->exists( + 'SELECT 1 FROM ' . PersonCenterHistory::class . ' pch WHERE pch.person = person.id AND pch.center IN (:authorized_centers)' + ) + )->setParameter('authorized_centers', $centers); + + $this->listPersonHelper->addSelect($qb, ListPersonHelper::FIELDS, $this->rollingDateConverter->convert($data['address_date'])); + $this->listAccompanyingPeriodHelper->addSelectClauses($qb, $this->rollingDateConverter->convert($data['address_date'])); + + return $qb; + } + + public function requiredRole(): string + { + return PersonVoter::LISTS; + } + + public function supportsModifiers() + { + return [Declarations::PERSON_TYPE, Declarations::PERSON_IMPLIED_IN, Declarations::ACP_TYPE]; + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Helper/ListAccompanyingPeriodHelper.php b/src/Bundle/ChillPersonBundle/Export/Helper/ListAccompanyingPeriodHelper.php index a32d78904..5fa2252cd 100644 --- a/src/Bundle/ChillPersonBundle/Export/Helper/ListAccompanyingPeriodHelper.php +++ b/src/Bundle/ChillPersonBundle/Export/Helper/ListAccompanyingPeriodHelper.php @@ -58,10 +58,10 @@ final readonly class ListAccompanyingPeriodHelper 'requestorThirdPartyId', 'scopes', 'socialIssues', - 'createdAt', - 'createdBy', - 'updatedAt', - 'updatedBy', + 'acpCreatedAt', + 'acpCreatedBy', + 'acpUpdatedAt', + 'acpUpdatedBy', ]; public function __construct( @@ -82,14 +82,14 @@ final readonly class ListAccompanyingPeriodHelper { return array_merge( ListAccompanyingPeriodHelper::FIELDS, - $this->addressHelper->getKeys(ExportAddressHelper::F_ALL, 'address_fields') + $this->addressHelper->getKeys(ExportAddressHelper::F_ALL, 'acp_address_fields') ); } public function getLabels($key, array $values, $data) { - if (substr($key, 0, strlen('address_fields')) === 'address_fields') { - return $this->addressHelper->getLabel($key, $values, $data, 'address_fields'); + if (str_starts_with($key, 'acp_address_fields')) { + return $this->addressHelper->getLabel($key, $values, $data, 'acp_address_fields'); } switch ($key) { @@ -97,8 +97,8 @@ final readonly class ListAccompanyingPeriodHelper case 'openingDate': case 'closingDate': case 'referrerSince': - case 'createdAt': - case 'updatedAt': + case 'acpCreatedAt': + case 'acpUpdatedAt': return $this->dateTimeHelper->getLabel('export.list.acp.' . $key); case 'origin': @@ -220,14 +220,23 @@ final readonly class ListAccompanyingPeriodHelper public function addSelectClauses(QueryBuilder $qb, \DateTimeImmutable $calcDate): void { $qb->addSelect('acp.id AS acpId'); + $qb->addSelect('acp.createdAt AS acpCreatedAt'); + $qb->addSelect('acp.updatedAt AS acpUpdatedAt'); // add the regular fields - foreach (['openingDate', 'closingDate', 'confidential', 'emergency', 'intensity', 'createdAt', 'updatedAt'] as $field) { + foreach (['openingDate', 'closingDate', 'confidential', 'emergency', 'intensity'] as $field) { $qb->addSelect(sprintf('acp.%s AS %s', $field, $field)); } // add the field which are simple association - foreach (['origin' => 'label', 'closingMotive' => 'name', 'job' => 'label', 'createdBy' => 'label', 'updatedBy' => 'label', 'administrativeLocation' => 'name'] as $entity => $field) { + $qb + ->leftJoin('acp.createdBy', "acp_created_by_t") + ->addSelect('acp_created_by_t.label AS acpCreatedBy'); + $qb + ->leftJoin('acp.updatedBy', "acp_updated_by_t") + ->addSelect('acp_updated_by_t.label AS acpUpdatedBy'); + + foreach (['origin' => 'label', 'closingMotive' => 'name', 'job' => 'label', 'administrativeLocation' => 'name'] as $entity => $field) { $qb ->leftJoin(sprintf('acp.%s', $entity), "{$entity}_t") ->addSelect(sprintf('%s_t.%s AS %s', $entity, $field, $entity)); @@ -279,13 +288,13 @@ final readonly class ListAccompanyingPeriodHelper ) ->leftJoin( PersonHouseholdAddress::class, - 'personAddress', + 'acpPersonAddress', Join::WITH, - 'locationHistory.personLocation = personAddress.person AND (personAddress.validFrom <= :calcDate AND (personAddress.validTo IS NULL OR personAddress.validTo > :calcDate))' + 'locationHistory.personLocation = acpPersonAddress.person AND (acpPersonAddress.validFrom <= :calcDate AND (acpPersonAddress.validTo IS NULL OR acpPersonAddress.validTo > :calcDate))' ) - ->leftJoin(Address::class, 'acp_address', Join::WITH, 'COALESCE(IDENTITY(locationHistory.addressLocation), IDENTITY(personAddress.address)) = acp_address.id'); + ->leftJoin(Address::class, 'acp_address', Join::WITH, 'COALESCE(IDENTITY(locationHistory.addressLocation), IDENTITY(acpPersonAddress.address)) = acp_address.id'); - $this->addressHelper->addSelectClauses(ExportAddressHelper::F_ALL, $qb, 'acp_address', 'address_fields'); + $this->addressHelper->addSelectClauses(ExportAddressHelper::F_ALL, $qb, 'acp_address', 'acp_address_fields'); // requestor $qb diff --git a/src/Bundle/ChillPersonBundle/Export/Helper/ListPersonHelper.php b/src/Bundle/ChillPersonBundle/Export/Helper/ListPersonHelper.php index 697019ca3..198794326 100644 --- a/src/Bundle/ChillPersonBundle/Export/Helper/ListPersonHelper.php +++ b/src/Bundle/ChillPersonBundle/Export/Helper/ListPersonHelper.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\PersonBundle\Export\Helper; +use Chill\MainBundle\Entity\Language; use Chill\MainBundle\Export\Helper\ExportAddressHelper; use Chill\MainBundle\Repository\CenterRepositoryInterface; use Chill\MainBundle\Repository\CivilityRepositoryInterface; @@ -114,7 +115,26 @@ class ListPersonHelper } /** - * @param array|value-of[] $fields + * Those keys are the "direct" keys, which are created when we decide to use to list all the keys. + * + * This method must be used in `getKeys` instead of the `self::FIELDS` + * + * @return array + */ + public function getAllKeys(): array + { + return [ + ...array_filter( + ListPersonHelper::FIELDS, + fn (string $key) => !in_array($key, ['address_fields', 'lifecycleUpdate'], true) + ), + ...$this->addressHelper->getKeys(ExportAddressHelper::F_ALL, 'address_fields'), + ...['createdAt', 'createdBy', 'updatedAt', 'updatedBy'], + ]; + } + + /** + * @param array> $fields */ public function addSelect(QueryBuilder $qb, array $fields, DateTimeImmutable $computedDate): void { @@ -143,25 +163,7 @@ class ListPersonHelper break; case 'spokenLanguages': - $qb - ->leftJoin('person.spokenLanguages', 'spokenLanguage') - ->addSelect('AGGREGATE(spokenLanguage.id) AS spokenLanguages') - ->addGroupBy('person'); - - if (in_array('center', $fields, true)) { - $qb->addGroupBy('center'); - } - - if (in_array('address_fields', $fields, true)) { - $qb - ->addGroupBy('address_fieldsid') - ->addGroupBy('address_fieldscountry_t.id') - ->addGroupBy('address_fieldspostcode_t.id'); - } - - if (in_array('household_id', $fields, true)) { - $qb->addGroupBy('household_id'); - } + $qb->addSelect('(SELECT AGGREGATE(language.id) FROM ' . Language::class . ' language WHERE language MEMBER OF person.spokenLanguages) AS spokenLanguages'); break; diff --git a/src/Bundle/ChillPersonBundle/config/services/exports_person.yaml b/src/Bundle/ChillPersonBundle/config/services/exports_person.yaml index 81875fafb..43f5556cf 100644 --- a/src/Bundle/ChillPersonBundle/config/services/exports_person.yaml +++ b/src/Bundle/ChillPersonBundle/config/services/exports_person.yaml @@ -4,35 +4,27 @@ services: autowire: true ## Indicators - chill.person.export.count_person: - class: Chill\PersonBundle\Export\Export\CountPerson - autowire: true - autoconfigure: true + Chill\PersonBundle\Export\Export\CountPerson: tags: - { name: chill.export, alias: count_person } - chill.person.export.count_person_with_accompanying_course: - class: Chill\PersonBundle\Export\Export\CountPersonWithAccompanyingCourse - autowire: true - autoconfigure: true + Chill\PersonBundle\Export\Export\CountPersonWithAccompanyingCourse: tags: - { name: chill.export, alias: count_person_with_accompanying_course } Chill\PersonBundle\Export\Export\ListPerson: - autowire: true - autoconfigure: true tags: - { name: chill.export, alias: list_person } Chill\PersonBundle\Export\Export\ListPersonHavingAccompanyingPeriod: - autowire: true - autoconfigure: true tags: - { name: chill.export, alias: list_person_with_acp } + Chill\PersonBundle\Export\Export\ListPersonWithAccompanyingPeriodDetails: + tags: + - { name: chill.export, alias: list_person_with_acp_details } + Chill\PersonBundle\Export\Export\ListAccompanyingPeriod: - autowire: true - autoconfigure: true tags: - { name: chill.export, alias: list_acp } diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 0a82fc330..1159b2c49 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -1148,7 +1148,9 @@ export: list: person_with_acp: List peoples having an accompanying period: Liste des usagers ayant un parcours d'accompagnement + List peoples having an accompanying period with period details: Liste des usagers concernés avec détail de chaque parcours Create a list of people having an accompaying periods, according to various filters.: Génère une liste des usagers ayant un parcours d'accompagnement, selon différents critères liés au parcours ou à l'usager + Create a list of people having an accompaying periods with details of period, according to various filters.: Génère une liste des usagers ayant un parcours d'accompagnement, selon différents critères liés au parcours ou à l'usager. Ajoute les détails du parcours à la liste. acp: List of accompanying periods: Liste des parcours d'accompagnements Generate a list of accompanying periods, filtered on different parameters.: Génère une liste des parcours d'accompagnement, filtrée sur différents paramètres. @@ -1162,14 +1164,14 @@ export: confidential: Confidentiel emergency: Urgent intensity: Intensité - createdAt: Créé le - updatedAt: Dernière mise à jour le + acpCreatedAt: Créé le + acpUpdatedAt: Dernière mise à jour le acpOrigin: Origine du parcours origin: Origine du parcours acpClosingMotive: Motif de fermeture acpJob: Métier du parcours - createdBy: Créé par - updatedBy: Dernière modification par + acpCreatedBy: Créé par + acpUpdatedBy: Dernière modification par administrativeLocation: Location administrative step: Etape stepSince: Dernière modification de l'étape From 63f9bd554897e1363d0b321c9e80c28e2b7745bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 7 Jul 2023 12:42:32 +0200 Subject: [PATCH 287/724] [export] Add ordering by person''s lastname or course opening date in list which concerns accompanying course or people --- .changes/unreleased/Feature-20230707-124132.yaml | 6 ++++++ .../Export/Export/ListAccompanyingPeriod.php | 5 +++++ .../Export/Export/ListPersonHavingAccompanyingPeriod.php | 5 +++++ .../Export/ListPersonWithAccompanyingPeriodDetails.php | 6 ++++++ 4 files changed, 22 insertions(+) create mode 100644 .changes/unreleased/Feature-20230707-124132.yaml diff --git a/.changes/unreleased/Feature-20230707-124132.yaml b/.changes/unreleased/Feature-20230707-124132.yaml new file mode 100644 index 000000000..4ad93ad22 --- /dev/null +++ b/.changes/unreleased/Feature-20230707-124132.yaml @@ -0,0 +1,6 @@ +kind: Feature +body: '[export] Add ordering by person''s lastname or course opening date in list + which concerns accompanying course or peoples' +time: 2023-07-07T12:41:32.112725962+02:00 +custom: + Issue: "" diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php index 3f7821bbc..ab9c0db2f 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php @@ -133,6 +133,11 @@ final readonly class ListAccompanyingPeriod implements ListInterface, GroupedExp $this->listAccompanyingPeriodHelper->addSelectClauses($qb, $this->rollingDateConverter->convert($data['calc_date'])); + $qb + ->addOrderBy('acp.openingDate') + ->addOrderBy('acp.closingDate') + ->addOrderBy('acp.id'); + return $qb; } diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListPersonHavingAccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Export/Export/ListPersonHavingAccompanyingPeriod.php index f2e4de4e3..408d0b3af 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListPersonHavingAccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListPersonHavingAccompanyingPeriod.php @@ -190,6 +190,11 @@ class ListPersonHavingAccompanyingPeriod implements ExportElementValidatedInterf $this->listPersonHelper->addSelect($qb, $fields, $data['address_date']); + $qb + ->addOrderBy('person.lastName') + ->addOrderBy('person.firstName') + ->addOrderBy('person.id'); + return $qb; } diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriodDetails.php b/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriodDetails.php index 295d87842..ddb16bb2d 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriodDetails.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListPersonWithAccompanyingPeriodDetails.php @@ -134,6 +134,12 @@ final readonly class ListPersonWithAccompanyingPeriodDetails implements ListInte $this->listPersonHelper->addSelect($qb, ListPersonHelper::FIELDS, $this->rollingDateConverter->convert($data['address_date'])); $this->listAccompanyingPeriodHelper->addSelectClauses($qb, $this->rollingDateConverter->convert($data['address_date'])); + $qb + ->addOrderBy('person.lastName') + ->addOrderBy('person.firstName') + ->addOrderBy('person.id') + ->addOrderBy('acp.id'); + return $qb; } From 197d69ef4a09fffd359305b8e1ad0a6f03f466b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 7 Jul 2023 13:21:22 +0200 Subject: [PATCH 288/724] release v2.4.0 --- .changes/unreleased/DX-20230629-160029.yaml | 5 --- .../unreleased/Feature-20230629-131558.yaml | 6 --- .../unreleased/Feature-20230629-173445.yaml | 5 --- .../unreleased/Feature-20230629-173509.yaml | 5 --- .../unreleased/Feature-20230629-173544.yaml | 5 --- .../unreleased/Feature-20230629-173617.yaml | 5 --- .../unreleased/Feature-20230629-173822.yaml | 5 --- .../unreleased/Feature-20230629-173844.yaml | 5 --- .../unreleased/Feature-20230705-220544.yaml | 6 --- .../unreleased/Feature-20230706-213428.yaml | 5 --- .../unreleased/Fixed-20230627-110233.yaml | 6 --- .../unreleased/Fixed-20230628-170055.yaml | 6 --- .../unreleased/Fixed-20230629-124412.yaml | 6 --- .../unreleased/Fixed-20230629-231503.yaml | 5 --- .../unreleased/Fixed-20230630-171119.yaml | 5 --- .../unreleased/Fixed-20230630-171153.yaml | 5 --- .../unreleased/Fixed-20230706-220125.yaml | 6 --- .changes/v2.4.0.md | 36 ++++++++++++++++++ CHANGELOG.md | 37 +++++++++++++++++++ 19 files changed, 73 insertions(+), 91 deletions(-) delete mode 100644 .changes/unreleased/DX-20230629-160029.yaml delete mode 100644 .changes/unreleased/Feature-20230629-131558.yaml delete mode 100644 .changes/unreleased/Feature-20230629-173445.yaml delete mode 100644 .changes/unreleased/Feature-20230629-173509.yaml delete mode 100644 .changes/unreleased/Feature-20230629-173544.yaml delete mode 100644 .changes/unreleased/Feature-20230629-173617.yaml delete mode 100644 .changes/unreleased/Feature-20230629-173822.yaml delete mode 100644 .changes/unreleased/Feature-20230629-173844.yaml delete mode 100644 .changes/unreleased/Feature-20230705-220544.yaml delete mode 100644 .changes/unreleased/Feature-20230706-213428.yaml delete mode 100644 .changes/unreleased/Fixed-20230627-110233.yaml delete mode 100644 .changes/unreleased/Fixed-20230628-170055.yaml delete mode 100644 .changes/unreleased/Fixed-20230629-124412.yaml delete mode 100644 .changes/unreleased/Fixed-20230629-231503.yaml delete mode 100644 .changes/unreleased/Fixed-20230630-171119.yaml delete mode 100644 .changes/unreleased/Fixed-20230630-171153.yaml delete mode 100644 .changes/unreleased/Fixed-20230706-220125.yaml create mode 100644 .changes/v2.4.0.md diff --git a/.changes/unreleased/DX-20230629-160029.yaml b/.changes/unreleased/DX-20230629-160029.yaml deleted file mode 100644 index b83befec6..000000000 --- a/.changes/unreleased/DX-20230629-160029.yaml +++ /dev/null @@ -1,5 +0,0 @@ -kind: DX -body: 'Rolling Date: can receive a null parameter' -time: 2023-06-29T16:00:29.664814895+02:00 -custom: - Issue: "" diff --git a/.changes/unreleased/Feature-20230629-131558.yaml b/.changes/unreleased/Feature-20230629-131558.yaml deleted file mode 100644 index 42d731c4f..000000000 --- a/.changes/unreleased/Feature-20230629-131558.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: Feature -body: '[export] on "filter by user working" on accompanying period, add two dates - to filters intervention within a period' -time: 2023-06-29T13:15:58.070316708+02:00 -custom: - Issue: "113" diff --git a/.changes/unreleased/Feature-20230629-173445.yaml b/.changes/unreleased/Feature-20230629-173445.yaml deleted file mode 100644 index 2d3642a85..000000000 --- a/.changes/unreleased/Feature-20230629-173445.yaml +++ /dev/null @@ -1,5 +0,0 @@ -kind: Feature -body: '[export] Add an aggregator by user''s job working on a course' -time: 2023-06-29T17:34:45.278993433+02:00 -custom: - Issue: "113" diff --git a/.changes/unreleased/Feature-20230629-173509.yaml b/.changes/unreleased/Feature-20230629-173509.yaml deleted file mode 100644 index 95fd23458..000000000 --- a/.changes/unreleased/Feature-20230629-173509.yaml +++ /dev/null @@ -1,5 +0,0 @@ -kind: Feature -body: '[export] add an aggregator by user''s scope working on a course' -time: 2023-06-29T17:35:09.548758741+02:00 -custom: - Issue: "113" diff --git a/.changes/unreleased/Feature-20230629-173544.yaml b/.changes/unreleased/Feature-20230629-173544.yaml deleted file mode 100644 index 94e79bc6d..000000000 --- a/.changes/unreleased/Feature-20230629-173544.yaml +++ /dev/null @@ -1,5 +0,0 @@ -kind: Feature -body: '[export] on aggregator "user working on a course"' -time: 2023-06-29T17:35:44.998468724+02:00 -custom: - Issue: "" diff --git a/.changes/unreleased/Feature-20230629-173617.yaml b/.changes/unreleased/Feature-20230629-173617.yaml deleted file mode 100644 index 445b85cff..000000000 --- a/.changes/unreleased/Feature-20230629-173617.yaml +++ /dev/null @@ -1,5 +0,0 @@ -kind: Feature -body: '[export] add a center aggregator for Person' -time: 2023-06-29T17:36:17.635876613+02:00 -custom: - Issue: "113" diff --git a/.changes/unreleased/Feature-20230629-173822.yaml b/.changes/unreleased/Feature-20230629-173822.yaml deleted file mode 100644 index 6a1569d00..000000000 --- a/.changes/unreleased/Feature-20230629-173822.yaml +++ /dev/null @@ -1,5 +0,0 @@ -kind: Feature -body: '[export] add a filter on "job working on a course"' -time: 2023-06-29T17:38:22.682951416+02:00 -custom: - Issue: "113" diff --git a/.changes/unreleased/Feature-20230629-173844.yaml b/.changes/unreleased/Feature-20230629-173844.yaml deleted file mode 100644 index f307ebf57..000000000 --- a/.changes/unreleased/Feature-20230629-173844.yaml +++ /dev/null @@ -1,5 +0,0 @@ -kind: Feature -body: '[export] Add a filter on "scope working on a course"' -time: 2023-06-29T17:38:44.238287822+02:00 -custom: - Issue: "113" diff --git a/.changes/unreleased/Feature-20230705-220544.yaml b/.changes/unreleased/Feature-20230705-220544.yaml deleted file mode 100644 index 4212f7646..000000000 --- a/.changes/unreleased/Feature-20230705-220544.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: Feature -body: Create a role "See Confidential Periods", separated from the "Reassign courses" - role -time: 2023-07-05T22:05:44.435112463+02:00 -custom: - Issue: "121" diff --git a/.changes/unreleased/Feature-20230706-213428.yaml b/.changes/unreleased/Feature-20230706-213428.yaml deleted file mode 100644 index 092e5a2e0..000000000 --- a/.changes/unreleased/Feature-20230706-213428.yaml +++ /dev/null @@ -1,5 +0,0 @@ -kind: Feature -body: 'Sync user absence / presence through microsoft outlook / graph api. ' -time: 2023-07-06T21:34:28.973144334+02:00 -custom: - Issue: "124" diff --git a/.changes/unreleased/Fixed-20230627-110233.yaml b/.changes/unreleased/Fixed-20230627-110233.yaml deleted file mode 100644 index 58bb23933..000000000 --- a/.changes/unreleased/Fixed-20230627-110233.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: Fixed -body: On the accompanying course page, open the action on view mode if the user does - not have right to update them (i.e. if the accompanying period is closed) -time: 2023-06-27T11:02:33.027807027+02:00 -custom: - Issue: "116" diff --git a/.changes/unreleased/Fixed-20230628-170055.yaml b/.changes/unreleased/Fixed-20230628-170055.yaml deleted file mode 100644 index 7f9ec3028..000000000 --- a/.changes/unreleased/Fixed-20230628-170055.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: Fixed -body: '[export] Rename label for CurrentActionFilter (on accompanying period work) - to make precision between "ouvert" and "sans date de fin"' -time: 2023-06-28T17:00:55.206937751+02:00 -custom: - Issue: "" diff --git a/.changes/unreleased/Fixed-20230629-124412.yaml b/.changes/unreleased/Fixed-20230629-124412.yaml deleted file mode 100644 index 7fc3d3eb0..000000000 --- a/.changes/unreleased/Fixed-20230629-124412.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: Fixed -body: Force the db to have either a person_location or a address_location, and avoid - to have both also internally in the entity -time: 2023-06-29T12:44:12.019663991+02:00 -custom: - Issue: "" diff --git a/.changes/unreleased/Fixed-20230629-231503.yaml b/.changes/unreleased/Fixed-20230629-231503.yaml deleted file mode 100644 index e021d1fda..000000000 --- a/.changes/unreleased/Fixed-20230629-231503.yaml +++ /dev/null @@ -1,5 +0,0 @@ -kind: Fixed -body: '[export] set rolling date on person age aggregator' -time: 2023-06-29T23:15:03.20841309+02:00 -custom: - Issue: "" diff --git a/.changes/unreleased/Fixed-20230630-171119.yaml b/.changes/unreleased/Fixed-20230630-171119.yaml deleted file mode 100644 index f3185ace2..000000000 --- a/.changes/unreleased/Fixed-20230630-171119.yaml +++ /dev/null @@ -1,5 +0,0 @@ -kind: Fixed -body: '[export] fix list when a person locating a course is without address' -time: 2023-06-30T17:11:19.454081914+02:00 -custom: - Issue: "" diff --git a/.changes/unreleased/Fixed-20230630-171153.yaml b/.changes/unreleased/Fixed-20230630-171153.yaml deleted file mode 100644 index c09bd93d0..000000000 --- a/.changes/unreleased/Fixed-20230630-171153.yaml +++ /dev/null @@ -1,5 +0,0 @@ -kind: Fixed -body: '[export] remove unused condition on course about duration participation' -time: 2023-06-30T17:11:53.076615549+02:00 -custom: - Issue: "" diff --git a/.changes/unreleased/Fixed-20230706-220125.yaml b/.changes/unreleased/Fixed-20230706-220125.yaml deleted file mode 100644 index b9449d514..000000000 --- a/.changes/unreleased/Fixed-20230706-220125.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: Fixed -body: 'Command to subscribe on MS Graph users calendars: improve the loop to be more - efficient' -time: 2023-07-06T22:01:25.847374805+02:00 -custom: - Issue: "" diff --git a/.changes/v2.4.0.md b/.changes/v2.4.0.md new file mode 100644 index 000000000..522957300 --- /dev/null +++ b/.changes/v2.4.0.md @@ -0,0 +1,36 @@ +## v2.4.0 - 2023-07-07 + +### Feature +* ([#113](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/113)) [export] on "filter by user working" on accompanying period, add two dates to filters intervention within a period +* ([#113](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/113)) [export] Add an aggregator by user's job working on a course +* ([#113](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/113)) [export] add an aggregator by user's scope working on a course +* [export] on aggregator "user working on a course" +* ([#113](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/113)) [export] add a center aggregator for Person +* ([#113](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/113)) [export] add a filter on "job working on a course" +* ([#113](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/113)) [export] Add a filter on "scope working on a course" +* ([#121](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/121)) Create a role "See Confidential Periods", separated from the "Reassign courses" role +* ([#124](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/124)) Sync user absence / presence through microsoft outlook / graph api. + +### Fixed +* ([#116](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/116)) On the accompanying course page, open the action on view mode if the user does not have right to update them (i.e. if the accompanying period is closed) +* [export] Rename label for CurrentActionFilter (on accompanying period work) to make precision between "ouvert" and "sans date de fin" +* Force the db to have either a person_location or a address_location, and avoid to have both also internally in the entity +* [export] set rolling date on person age aggregator +* [export] fix list when a person locating a course is without address +* [export] remove unused condition on course about duration participation +* Command to subscribe on MS Graph users calendars: improve the loop to be more efficient + +### DX +* Rolling Date: can receive a null parameter + +### Traduction francophone des principaux changements + +- sur le "filtre par intervenant", ajoute deux dates pour limiter la période d'intervention; +- ajout d'un regroupement par métier des intervenants sur un parcours; +- ajout d'un regroupement par service des intervenants sur un parcours; +- ajout d'un regroupement par utilisateur intervenant sur un parcours +- ajout d'un regroupement "par centre de l'usager"; +- ajout d'un filtre "par métier intervenant sur un parcours"; +- ajout d'un filtre "par service intervenant sur un parcours"; +- création d'un rôle spécifique pour voir les parcours confidentiels (et séparer de celui de la liste qui permet de ré-assigner les parcours en lot); +- synchronisation de l'absence des utilisateurs par microsoft graph api diff --git a/CHANGELOG.md b/CHANGELOG.md index 93ff93556..b74eea58d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,43 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html), and is generated by [Changie](https://github.com/miniscruff/changie). +## v2.4.0 - 2023-07-07 + +### Feature +* ([#113](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/113)) [export] on "filter by user working" on accompanying period, add two dates to filters intervention within a period +* ([#113](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/113)) [export] Add an aggregator by user's job working on a course +* ([#113](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/113)) [export] add an aggregator by user's scope working on a course +* [export] on aggregator "user working on a course" +* ([#113](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/113)) [export] add a center aggregator for Person +* ([#113](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/113)) [export] add a filter on "job working on a course" +* ([#113](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/113)) [export] Add a filter on "scope working on a course" +* ([#121](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/121)) Create a role "See Confidential Periods", separated from the "Reassign courses" role +* ([#124](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/124)) Sync user absence / presence through microsoft outlook / graph api. + +### Fixed +* ([#116](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/116)) On the accompanying course page, open the action on view mode if the user does not have right to update them (i.e. if the accompanying period is closed) +* [export] Rename label for CurrentActionFilter (on accompanying period work) to make precision between "ouvert" and "sans date de fin" +* Force the db to have either a person_location or a address_location, and avoid to have both also internally in the entity +* [export] set rolling date on person age aggregator +* [export] fix list when a person locating a course is without address +* [export] remove unused condition on course about duration participation +* Command to subscribe on MS Graph users calendars: improve the loop to be more efficient + +### DX +* Rolling Date: can receive a null parameter + +### Traduction francophone des principaux changements + +- sur le "filtre par intervenant", ajoute deux dates pour limiter la période d'intervention; +- ajout d'un regroupement par métier des intervenants sur un parcours; +- ajout d'un regroupement par service des intervenants sur un parcours; +- ajout d'un regroupement par utilisateur intervenant sur un parcours +- ajout d'un regroupement "par centre de l'usager"; +- ajout d'un filtre "par métier intervenant sur un parcours"; +- ajout d'un filtre "par service intervenant sur un parcours"; +- création d'un rôle spécifique pour voir les parcours confidentiels (et séparer de celui de la liste qui permet de ré-assigner les parcours en lot); +- synchronisation de l'absence des utilisateurs par microsoft graph api + ## v2.3.0 - 2023-06-27 ### Feature * ([#110](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/110)) Edit saved exports options: the saved exports options (forms, filters, aggregators) are now editable. From 20e64e87680d102c686000f1c35d0139d00eecdf Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Fri, 7 Jul 2023 15:41:29 +0200 Subject: [PATCH 289/724] test filterOrder in an accordion --- .../views/FilterOrder/base.html.twig | 162 ++++++++++-------- 1 file changed, 86 insertions(+), 76 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Resources/views/FilterOrder/base.html.twig b/src/Bundle/ChillMainBundle/Resources/views/FilterOrder/base.html.twig index b2673b60c..f642c82aa 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/FilterOrder/base.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/FilterOrder/base.html.twig @@ -1,92 +1,102 @@ {{ form_start(form) }} - {% set btnSubmit = 0 %} -
      -
      - {% if form.vars.has_search_box %} -
      -
      - {{ form_widget(form.q) }} - -
      -
      - {% endif %} -
      - {% if form.dateRanges is defined %} - {% set btnSubmit = 1 %} - {% if form.dateRanges|length > 0 %} - {% for dateRangeName, _o in form.dateRanges %} -
      - {% if form.dateRanges[dateRangeName].vars.label is not same as(false) %} - {{ form_label(form.dateRanges[dateRangeName])}} - {% else %} -
      {{ 'activity_filter.By date'|trans }}
      - {% endif %} -
      -
      - {{ 'chill_calendar.From'|trans }} - {{ form_widget(form.dateRanges[dateRangeName]['from']) }} - {{ 'chill_calendar.To'|trans }} - {{ form_widget(form.dateRanges[dateRangeName]['to']) }} -
      +
      +

      + +

      +
      + {% set btnSubmit = 0 %} +
      +
      + {% if form.vars.has_search_box %} +
      +
      + {{ form_widget(form.q) }} +
      - {% endfor %} + {% endif %} +
      + {% if form.dateRanges is defined %} + {% set btnSubmit = 1 %} + {% if form.dateRanges|length > 0 %} + {% for dateRangeName, _o in form.dateRanges %} +
      + {% if form.dateRanges[dateRangeName].vars.label is not same as(false) %} + {{ form_label(form.dateRanges[dateRangeName])}} + {% else %} +
      {{ 'activity_filter.By date'|trans }}
      + {% endif %} +
      +
      + {{ 'chill_calendar.From'|trans }} + {{ form_widget(form.dateRanges[dateRangeName]['from']) }} + {{ 'chill_calendar.To'|trans }} + {{ form_widget(form.dateRanges[dateRangeName]['to']) }} +
      +
      +
      + {% endfor %} + {% endif %} {% endif %} - {% endif %} - {% if form.checkboxes is defined %} - {% set btnSubmit = 1 %} - {% if form.checkboxes|length > 0 %} - {% for checkbox_name, options in form.checkboxes %} + {% if form.checkboxes is defined %} + {% set btnSubmit = 1 %} + {% if form.checkboxes|length > 0 %} + {% for checkbox_name, options in form.checkboxes %} +
      +
      {{ 'activity_filter.By'|trans }}
      +
      + {% for c in form['checkboxes'][checkbox_name].children %} + {{ form_widget(c) }} + {{ form_label(c) }} + {% endfor %} +
      +
      + {% endfor %} + {% endif %} + {% endif %} + {% if form.entity_choices is defined %} + {% set btnSubmit = 1 %} + {% if form.entity_choices |length > 0 %} + {% for checkbox_name, options in form.entity_choices %} +
      + {% if form.entity_choices[checkbox_name].vars.label is not same as(false) %} + {{ form_label(form.entity_choices[checkbox_name])}} + {% endif %} +
      + {% for c in form['entity_choices'][checkbox_name].children %} + {{ form_widget(c) }} + {{ form_label(c) }} + {% endfor %} +
      +
      + {% endfor %} + {% endif %} + {% endif %} + {% if form.single_checkboxes is defined %} + {% set btnSubmit = 1 %} + {% for name, _o in form.single_checkboxes %}
      {{ 'activity_filter.By'|trans }}
      - {% for c in form['checkboxes'][checkbox_name].children %} - {{ form_widget(c) }} - {{ form_label(c) }} - {% endfor %} + {{ form_widget(form.single_checkboxes[name]) }}
      {% endfor %} {% endif %} - {% endif %} - {% if form.entity_choices is defined %} - {% set btnSubmit = 1 %} - {% if form.entity_choices |length > 0 %} - {% for checkbox_name, options in form.entity_choices %} -
      - {% if form.entity_choices[checkbox_name].vars.label is not same as(false) %} - {{ form_label(form.entity_choices[checkbox_name])}} - {% endif %} -
      - {% for c in form['entity_choices'][checkbox_name].children %} - {{ form_widget(c) }} - {{ form_label(c) }} - {% endfor %} -
      -
      - {% endfor %} - {% endif %} - {% endif %} - {% if form.single_checkboxes is defined %} - {% set btnSubmit = 1 %} - {% for name, _o in form.single_checkboxes %} + + {% if btnSubmit == 1 %}
      -
      {{ 'activity_filter.By'|trans }}
      -
      - {{ form_widget(form.single_checkboxes[name]) }} -
      +
      - {% endfor %} - {% endif %} - - {% if btnSubmit == 1 %} -
      - -
      - {% endif %} + {% endif %} +
      +
      - {% for k,v in otherParameters %} - - {% endfor %} +{% for k,v in otherParameters %} + +{% endfor %} {{ form_end(form) }} + From 6bdb3e969538bc3cf0ad3458d5015d3ab180626e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 7 Jul 2023 21:49:36 +0200 Subject: [PATCH 290/724] fix typo which prevent to apply a filter on activity types --- .../ChillActivityBundle/Controller/ActivityController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php index 9b6e69bf0..1e911ff08 100644 --- a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php +++ b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php @@ -259,7 +259,7 @@ final class ActivityController extends AbstractController $filterArgs = [ 'my_activities' => $filter->getSingleCheckboxData('my_activities'), - 'types' => $filter->hasEntityChoice('activity_type') ? $filter->getEntityChoiceData('activity_types') : [], + 'types' => $filter->hasEntityChoice('activity_types') ? $filter->getEntityChoiceData('activity_types') : [], 'jobs' => $filter->hasEntityChoice('jobs') ? $filter->getEntityChoiceData('jobs') : [], 'before' => $filter->getDateRangeData('activity_date')['to'], 'after' => $filter->getDateRangeData('activity_date')['from'], From 39896ea6e26e3cb2392830b2e18c9bb8f396cefe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 10 Jul 2023 15:26:54 +0200 Subject: [PATCH 291/724] [FilterOrder] add a method to get all the active filters --- .../Form/Type/Listing/FilterOrderType.php | 25 +++--- .../views/FilterOrder/base.html.twig | 13 ++- .../Templating/Listing/FilterOrderHelper.php | 79 ++++++++++++++++--- .../Listing/FilterOrderHelperBuilder.php | 10 ++- .../Listing/FilterOrderHelperFactory.php | 8 +- .../Listing/FilterOrderPositionEnum.php | 12 +++ .../translations/messages+intl-icu.fr.yaml | 5 ++ 7 files changed, 126 insertions(+), 26 deletions(-) create mode 100644 src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderPositionEnum.php diff --git a/src/Bundle/ChillMainBundle/Form/Type/Listing/FilterOrderType.php b/src/Bundle/ChillMainBundle/Form/Type/Listing/FilterOrderType.php index 1f373400c..d16ce3813 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/Listing/FilterOrderType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/Listing/FilterOrderType.php @@ -47,16 +47,7 @@ final class FilterOrderType extends \Symfony\Component\Form\AbstractType $checkboxesBuilder = $builder->create('checkboxes', null, ['compound' => true]); foreach ($helper->getCheckboxes() as $name => $c) { - $choices = array_combine( - array_map(static function ($c, $t) { - if (null !== $t) { - return $t; - } - - return $c; - }, $c['choices'], $c['trans']), - $c['choices'] - ); + $choices = self::buildCheckboxChoices($c['choices'], $c['trans']); $checkboxesBuilder->add($name, ChoiceType::class, [ 'choices' => $choices, @@ -125,6 +116,20 @@ final class FilterOrderType extends \Symfony\Component\Form\AbstractType } } + public static function buildCheckboxChoices(array $choices, array $trans = []): array + { + return array_combine( + array_map(static function ($c, $t) { + if (null !== $t) { + return $t; + } + + return $c; + }, $choices, $trans), + $choices + ); + } + public function buildView(FormView $view, FormInterface $form, array $options) { /** @var FilterOrderHelper $helper */ diff --git a/src/Bundle/ChillMainBundle/Resources/views/FilterOrder/base.html.twig b/src/Bundle/ChillMainBundle/Resources/views/FilterOrder/base.html.twig index f642c82aa..4de7604cf 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/FilterOrder/base.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/FilterOrder/base.html.twig @@ -85,7 +85,7 @@
      {% endfor %} {% endif %} - + {% if btnSubmit == 1 %}
      @@ -93,6 +93,17 @@ {% endif %}
      + {% set active = helper.getActiveFilters() %} + {% if active|length > 0 %} +
      + {% for f in active %} + {% if f.label != '' %}{{ f.label|trans }} : {% endif %}{{ f.value }} + {% endfor %} +
      + {% endif %} +
      + +
      {% for k,v in otherParameters %} diff --git a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php index c0ef1cd89..a038dfd71 100644 --- a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php +++ b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php @@ -13,16 +13,19 @@ namespace Chill\MainBundle\Templating\Listing; use Chill\MainBundle\Form\Type\Listing\FilterOrderType; use DateTimeImmutable; -use Symfony\Component\Form\Extension\Core\Type\FormType; -use Symfony\Component\Form\Extension\Core\Type\HiddenType; use Symfony\Component\Form\FormFactoryInterface; use Symfony\Component\Form\FormInterface; use Symfony\Component\HttpFoundation\RequestStack; +use Symfony\Component\PropertyAccess\PropertyAccessor; +use Symfony\Component\PropertyAccess\PropertyAccessorInterface; +use Symfony\Component\PropertyAccess\PropertyPath; +use Symfony\Component\PropertyAccess\PropertyPathInterface; +use Symfony\Contracts\Translation\TranslatorInterface; use function array_merge; use function count; -class FilterOrderHelper +final class FilterOrderHelper { private array $checkboxes = []; @@ -33,16 +36,12 @@ class FilterOrderHelper private array $dateRanges = []; - private FormFactoryInterface $formFactory; - public const FORM_NAME = 'f'; private array $formOptions = []; private string $formType = FilterOrderType::class; - private RequestStack $requestStack; - private ?array $searchBoxFields = null; private ?array $submitted = null; @@ -52,12 +51,13 @@ class FilterOrderHelper */ private array $entityChoices = []; + public function __construct( - FormFactoryInterface $formFactory, - RequestStack $requestStack + private readonly FormFactoryInterface $formFactory, + private readonly RequestStack $requestStack, + private readonly TranslatorInterface $translator, + private readonly PropertyAccessorInterface $propertyAccessor, ) { - $this->formFactory = $formFactory; - $this->requestStack = $requestStack; } public function addSingleCheckbox(string $name, string $label): self @@ -199,6 +199,63 @@ class FilterOrderHelper return $this; } + /** + * Return all the data required to display the active filters + * + * @return array + */ + public function getActiveFilters(): array + { + $result = []; + + if ($this->hasSearchBox() && '' !== $this->getQueryString()) { + $result[] = ['label' => '', 'value' => $this->getQueryString(), 'position' => FilterOrderPositionEnum::SearchBox->value, 'name' => 'q']; + } + + foreach ($this->dateRanges as $name => ['label' => $label]) { + $base = ['position' => FilterOrderPositionEnum::DateRange->value, 'name' => $name, 'label' => (string) $label]; + + if (null !== ($from = $this->getDateRangeData($name)['from'] ?? null)) { + $result[] = ['value' => $this->translator->trans('filter_order.by_date.From', ['from_date' => $from]), ...$base]; + } + if (null !== ($to = $this->getDateRangeData($name)['to'] ?? null)) { + $result[] = ['value' => $this->translator->trans('filter_order.by_date.To', ['to_date' => $to]), ...$base]; + } + } + + foreach ($this->checkboxes as $name => ['choices' => $choices, 'trans' => $trans, 'options' => $options]) { + foreach ($this->getCheckboxData($name) as $keyChoice) { + $result[] = ['value' => $choices['keyChoice'], 'label' => $options['label'], 'position' => FilterOrderPositionEnum::Checkboxes->value, 'name' => $name]; + } + } + + foreach ($this->entityChoices as $name => ['label' => $label, 'class' => $class, 'choices' => $choices, 'options' => $options]) { + foreach ($this->getEntityChoiceData($name) as $selected) { + if (is_callable($options['choice_label'])) { + $value = call_user_func($options['choice_label'], $selected); + } elseif ($options['choice_label'] instanceof PropertyPathInterface || is_string($options['choice_label'])) { + $value = $this->propertyAccessor->getValue($selected, $options['choice_label']); + } else { + if (!$selected instanceof \Stringable) { + throw new \UnexpectedValueException(sprintf("we are not able to transform the value of %s to a string. Implements \Stringable or add a 'choice_label' option to the filterFormBuilder", get_class($selected))); + } + + $value = (string) $selected; + } + + $result[] = ['value' => $value, 'label' => $label, 'position' => FilterOrderPositionEnum::EntityChoice->value, 'name' => $name]; + } + } + + foreach ($this->singleCheckbox as $name => ['label' => $label]) { + if (true === $this->getSingleCheckboxData($name)) { + $result[] = ['label' => '', 'value' => $this->translator->trans($label), 'position' => FilterOrderPositionEnum::SingleCheckbox->value, 'name' => $name]; + } + } + + return $result; + } + private function getDefaultData(): array { $r = [ diff --git a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperBuilder.php b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperBuilder.php index e176e27c6..dfa361f6e 100644 --- a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperBuilder.php +++ b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperBuilder.php @@ -14,6 +14,8 @@ namespace Chill\MainBundle\Templating\Listing; use DateTimeImmutable; use Symfony\Component\Form\FormFactoryInterface; use Symfony\Component\HttpFoundation\RequestStack; +use Symfony\Component\PropertyAccess\PropertyAccessorInterface; +use Symfony\Contracts\Translation\TranslatorInterface; class FilterOrderHelperBuilder { @@ -39,7 +41,9 @@ class FilterOrderHelperBuilder public function __construct( FormFactoryInterface $formFactory, - RequestStack $requestStack + RequestStack $requestStack, + private readonly TranslatorInterface $translator, + private readonly PropertyAccessorInterface $propertyAccessor, ) { $this->formFactory = $formFactory; $this->requestStack = $requestStack; @@ -87,7 +91,9 @@ class FilterOrderHelperBuilder { $helper = new FilterOrderHelper( $this->formFactory, - $this->requestStack + $this->requestStack, + $this->translator, + $this->propertyAccessor ); $helper->setSearchBox($this->searchBoxFields); diff --git a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperFactory.php b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperFactory.php index c88c71af5..3fbb2864d 100644 --- a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperFactory.php +++ b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperFactory.php @@ -13,6 +13,8 @@ namespace Chill\MainBundle\Templating\Listing; use Symfony\Component\Form\FormFactoryInterface; use Symfony\Component\HttpFoundation\RequestStack; +use Symfony\Component\PropertyAccess\PropertyAccessorInterface; +use Symfony\Contracts\Translation\TranslatorInterface; class FilterOrderHelperFactory implements FilterOrderHelperFactoryInterface { @@ -22,7 +24,9 @@ class FilterOrderHelperFactory implements FilterOrderHelperFactoryInterface public function __construct( FormFactoryInterface $formFactory, - RequestStack $requestStack + RequestStack $requestStack, + private readonly TranslatorInterface $translator, + private readonly PropertyAccessorInterface $propertyAccessor, ) { $this->formFactory = $formFactory; $this->requestStack = $requestStack; @@ -30,6 +34,6 @@ class FilterOrderHelperFactory implements FilterOrderHelperFactoryInterface public function create(string $context, ?array $options = []): FilterOrderHelperBuilder { - return new FilterOrderHelperBuilder($this->formFactory, $this->requestStack); + return new FilterOrderHelperBuilder($this->formFactory, $this->requestStack, $this->translator, $this->propertyAccessor); } } diff --git a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderPositionEnum.php b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderPositionEnum.php new file mode 100644 index 000000000..cda8119f5 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderPositionEnum.php @@ -0,0 +1,12 @@ + Date: Mon, 10 Jul 2023 15:39:00 +0200 Subject: [PATCH 292/724] [filterOrder] fix error in method getActiveFilters when dealing with entityChoice with incorrect number of translation --- .../Templating/Listing/FilterOrderHelper.php | 13 ++++++++----- .../Templating/Listing/FilterOrderPositionEnum.php | 9 +++++++++ 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php index a038dfd71..701238208 100644 --- a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php +++ b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php @@ -84,9 +84,11 @@ final class FilterOrderHelper public function addCheckbox(string $name, array $choices, ?array $default = [], ?array $trans = [], array $options = []): self { - $missing = count($choices) - count($trans) - 1; + $missing = count($choices) - count($trans); + $this->checkboxes[$name] = [ - 'choices' => $choices, 'default' => $default, + 'choices' => $choices, + 'default' => $default, 'trans' => array_merge( $trans, 0 < $missing ? @@ -223,9 +225,10 @@ final class FilterOrderHelper } } - foreach ($this->checkboxes as $name => ['choices' => $choices, 'trans' => $trans, 'options' => $options]) { + foreach ($this->checkboxes as $name => ['choices' => $choices, 'trans' => $trans]) { + $translatedChoice = array_combine($choices, [...$trans]); foreach ($this->getCheckboxData($name) as $keyChoice) { - $result[] = ['value' => $choices['keyChoice'], 'label' => $options['label'], 'position' => FilterOrderPositionEnum::Checkboxes->value, 'name' => $name]; + $result[] = ['value' => $translatedChoice[$keyChoice], 'label' => '', 'position' => FilterOrderPositionEnum::Checkboxes->value, 'name' => $name]; } } @@ -237,7 +240,7 @@ final class FilterOrderHelper $value = $this->propertyAccessor->getValue($selected, $options['choice_label']); } else { if (!$selected instanceof \Stringable) { - throw new \UnexpectedValueException(sprintf("we are not able to transform the value of %s to a string. Implements \Stringable or add a 'choice_label' option to the filterFormBuilder", get_class($selected))); + throw new \UnexpectedValueException(sprintf("we are not able to transform the value of %s to a string. Implements \\Stringable or add a 'choice_label' option to the filterFormBuilder", get_class($selected))); } $value = (string) $selected; diff --git a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderPositionEnum.php b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderPositionEnum.php index cda8119f5..09e8d39aa 100644 --- a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderPositionEnum.php +++ b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderPositionEnum.php @@ -1,5 +1,14 @@ Date: Mon, 10 Jul 2023 15:55:05 +0200 Subject: [PATCH 293/724] render active filters like pills --- .../Resources/views/FilterOrder/base.html.twig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Resources/views/FilterOrder/base.html.twig b/src/Bundle/ChillMainBundle/Resources/views/FilterOrder/base.html.twig index 4de7604cf..7a05a2f80 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/FilterOrder/base.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/FilterOrder/base.html.twig @@ -95,9 +95,9 @@
      {% set active = helper.getActiveFilters() %} {% if active|length > 0 %} -
      +
      {% for f in active %} - {% if f.label != '' %}{{ f.label|trans }} : {% endif %}{{ f.value }} + {% if f.label != '' %}{{ f.label|trans }} : {% endif %}{{ f.value }} {% endfor %}
      {% endif %} From 0d365e16e58df1614b132fc4b1fa2dc655458e3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 10 Jul 2023 15:59:17 +0200 Subject: [PATCH 294/724] add missing translations --- .../ChillMainBundle/Templating/Listing/FilterOrderHelper.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php index 701238208..2b24ffa0d 100644 --- a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php +++ b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php @@ -228,7 +228,7 @@ final class FilterOrderHelper foreach ($this->checkboxes as $name => ['choices' => $choices, 'trans' => $trans]) { $translatedChoice = array_combine($choices, [...$trans]); foreach ($this->getCheckboxData($name) as $keyChoice) { - $result[] = ['value' => $translatedChoice[$keyChoice], 'label' => '', 'position' => FilterOrderPositionEnum::Checkboxes->value, 'name' => $name]; + $result[] = ['value' => $this->translator->trans($translatedChoice[$keyChoice]), 'label' => '', 'position' => FilterOrderPositionEnum::Checkboxes->value, 'name' => $name]; } } @@ -246,7 +246,7 @@ final class FilterOrderHelper $value = (string) $selected; } - $result[] = ['value' => $value, 'label' => $label, 'position' => FilterOrderPositionEnum::EntityChoice->value, 'name' => $name]; + $result[] = ['value' => $this->translator->trans($value), 'label' => $label, 'position' => FilterOrderPositionEnum::EntityChoice->value, 'name' => $name]; } } From bf93c1ddb21f2bcbb28d42094b4f0d7c4cc78ef5 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Tue, 11 Jul 2023 14:06:10 +0200 Subject: [PATCH 295/724] fix label color in active filters pills --- .../translations/messages.fr.yml | 3 --- .../Form/Type/Listing/FilterOrderType.php | 2 +- .../Resources/views/FilterOrder/base.html.twig | 16 ++++++++++++---- .../translations/messages+intl-icu.fr.yaml | 4 ++++ 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/translations/messages.fr.yml b/src/Bundle/ChillActivityBundle/translations/messages.fr.yml index 3099e99b0..c53a04f31 100644 --- a/src/Bundle/ChillActivityBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillActivityBundle/translations/messages.fr.yml @@ -96,9 +96,6 @@ activity_filter: My activities: Mes échanges (où j'interviens) Types: Par type d'échange Jobs: Par métier impliqué - By: Filtrer par - Search: Chercher dans la liste - By date: Filtrer par date #timeline '%user% has done an %activity_type%': '%user% a effectué un échange de type "%activity_type%"' diff --git a/src/Bundle/ChillMainBundle/Form/Type/Listing/FilterOrderType.php b/src/Bundle/ChillMainBundle/Form/Type/Listing/FilterOrderType.php index d16ce3813..f22b6bfba 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/Listing/FilterOrderType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/Listing/FilterOrderType.php @@ -39,7 +39,7 @@ final class FilterOrderType extends \Symfony\Component\Form\AbstractType 'label' => false, 'required' => false, 'attr' => [ - 'placeholder' => 'activity_filter.Search', + 'placeholder' => 'filter_order.Search', ] ]); } diff --git a/src/Bundle/ChillMainBundle/Resources/views/FilterOrder/base.html.twig b/src/Bundle/ChillMainBundle/Resources/views/FilterOrder/base.html.twig index 7a05a2f80..0dcc4ce3f 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/FilterOrder/base.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/FilterOrder/base.html.twig @@ -26,7 +26,7 @@ {% if form.dateRanges[dateRangeName].vars.label is not same as(false) %} {{ form_label(form.dateRanges[dateRangeName])}} {% else %} -
      {{ 'activity_filter.By date'|trans }}
      +
      {{ 'filter_order.By date'|trans }}
      {% endif %}
      @@ -45,7 +45,7 @@ {% if form.checkboxes|length > 0 %} {% for checkbox_name, options in form.checkboxes %}
      -
      {{ 'activity_filter.By'|trans }}
      +
      {{ 'filter_order.By'|trans }}
      {% for c in form['checkboxes'][checkbox_name].children %} {{ form_widget(c) }} @@ -78,7 +78,7 @@ {% set btnSubmit = 1 %} {% for name, _o in form.single_checkboxes %}
      -
      {{ 'activity_filter.By'|trans }}
      +
      {{ 'filter_order.By'|trans }}
      {{ form_widget(form.single_checkboxes[name]) }}
      @@ -97,7 +97,15 @@ {% if active|length > 0 %}
      {% for f in active %} - {% if f.label != '' %}{{ f.label|trans }} : {% endif %}{{ f.value }} + + {%- if f.label != '' %} + {{ f.label|trans }} : + {% endif -%} + {%- if f.position == 'search_box' and f.value is not null %} + {{ 'filter_order.search_box'|trans ~ ' :' }} + {% endif -%} + {{ f.value}}{# + #} {% endfor %}
      {% endif %} diff --git a/src/Bundle/ChillMainBundle/translations/messages+intl-icu.fr.yaml b/src/Bundle/ChillMainBundle/translations/messages+intl-icu.fr.yaml index e1dc89dc2..96b2edd98 100644 --- a/src/Bundle/ChillMainBundle/translations/messages+intl-icu.fr.yaml +++ b/src/Bundle/ChillMainBundle/translations/messages+intl-icu.fr.yaml @@ -59,3 +59,7 @@ filter_order: by_date: From: Depuis le {from_date, date, long} To: Jusqu'au {to_date, date, long} + By: Filtrer par + Search: Chercher dans la liste + By date: Filtrer par date + search_box: Filtrer par contenu From 88114e3ba69fbd97a27eb850600acc78e27f526a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 11 Jul 2023 14:17:02 +0200 Subject: [PATCH 296/724] Fixed: [filterOrder] refactor active filter helper to a dedicated class and fix loading of multiple entity choices --- .../views/FilterOrder/base.html.twig | 1 - .../FilterOrderGetActiveFilterHelper.php | 84 +++++++++++++++++++ .../Templating/Listing/FilterOrderHelper.php | 70 +--------------- .../Listing/FilterOrderHelperBuilder.php | 4 - .../Listing/FilterOrderHelperFactory.php | 4 +- .../Templating/Listing/Templating.php | 2 + 6 files changed, 91 insertions(+), 74 deletions(-) create mode 100644 src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderGetActiveFilterHelper.php diff --git a/src/Bundle/ChillMainBundle/Resources/views/FilterOrder/base.html.twig b/src/Bundle/ChillMainBundle/Resources/views/FilterOrder/base.html.twig index 0dcc4ce3f..b517eb154 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/FilterOrder/base.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/FilterOrder/base.html.twig @@ -93,7 +93,6 @@ {% endif %}
      - {% set active = helper.getActiveFilters() %} {% if active|length > 0 %}
      {% for f in active %} diff --git a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderGetActiveFilterHelper.php b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderGetActiveFilterHelper.php new file mode 100644 index 000000000..6b204e552 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderGetActiveFilterHelper.php @@ -0,0 +1,84 @@ + + */ + public function getActiveFilters(FilterOrderHelper $filterOrderHelper): array + { + $result = []; + + if ($filterOrderHelper->hasSearchBox() && '' !== $filterOrderHelper->getQueryString()) { + $result[] = ['label' => '', 'value' => $filterOrderHelper->getQueryString(), 'position' => FilterOrderPositionEnum::SearchBox->value, 'name' => 'q']; + } + + foreach ($filterOrderHelper->getDateRanges() as $name => ['label' => $label]) { + $base = ['position' => FilterOrderPositionEnum::DateRange->value, 'name' => $name, 'label' => (string)$label]; + + if (null !== ($from = $filterOrderHelper->getDateRangeData($name)['from'] ?? null)) { + $result[] = ['value' => $this->translator->trans('filter_order.by_date.From', ['from_date' => $from]), ...$base]; + } + if (null !== ($to = $filterOrderHelper->getDateRangeData($name)['to'] ?? null)) { + $result[] = ['value' => $this->translator->trans('filter_order.by_date.To', ['to_date' => $to]), ...$base]; + } + } + + foreach ($filterOrderHelper->getCheckboxes() as $name => ['choices' => $choices, 'trans' => $trans]) { + $translatedChoice = array_combine($choices, [...$trans]); + foreach ($filterOrderHelper->getCheckboxData($name) as $keyChoice) { + $result[] = ['value' => $this->translator->trans($translatedChoice[$keyChoice]), 'label' => '', 'position' => FilterOrderPositionEnum::Checkboxes->value, 'name' => $name]; + } + } + + foreach ($filterOrderHelper->getEntityChoices() as $name => ['label' => $label, 'class' => $class, 'choices' => $choices, 'options' => $options]) { + foreach ($filterOrderHelper->getEntityChoiceData($name) as $selected) { + if (is_callable($options['choice_label'])) { + $value = call_user_func($options['choice_label'], $selected); + } elseif ($options['choice_label'] instanceof PropertyPathInterface || is_string($options['choice_label'])) { + $value = $this->propertyAccessor->getValue($selected, $options['choice_label']); + } else { + if (!$selected instanceof \Stringable) { + throw new \UnexpectedValueException(sprintf("we are not able to transform the value of %s to a string. Implements \\Stringable or add a 'choice_label' option to the filterFormBuilder", get_class($selected))); + } + + $value = (string)$selected; + } + + $result[] = ['value' => $this->translator->trans($value), 'label' => $label, 'position' => FilterOrderPositionEnum::EntityChoice->value, 'name' => $name]; + } + } + + foreach ($filterOrderHelper->getSingleCheckbox() as $name => ['label' => $label]) { + if (true === $filterOrderHelper->getSingleCheckboxData($name)) { + $result[] = ['label' => '', 'value' => $this->translator->trans($label), 'position' => FilterOrderPositionEnum::SingleCheckbox->value, 'name' => $name]; + } + } + + return $result; + } +} diff --git a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php index 2b24ffa0d..84939a052 100644 --- a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php +++ b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php @@ -55,8 +55,6 @@ final class FilterOrderHelper public function __construct( private readonly FormFactoryInterface $formFactory, private readonly RequestStack $requestStack, - private readonly TranslatorInterface $translator, - private readonly PropertyAccessorInterface $propertyAccessor, ) { } @@ -84,16 +82,14 @@ final class FilterOrderHelper public function addCheckbox(string $name, array $choices, ?array $default = [], ?array $trans = [], array $options = []): self { - $missing = count($choices) - count($trans); + if ([] === $trans) { + $trans = $choices; + } $this->checkboxes[$name] = [ 'choices' => $choices, 'default' => $default, - 'trans' => array_merge( - $trans, - 0 < $missing ? - array_fill(0, $missing, null) : [] - ), + 'trans' => $trans, ...$options, ]; @@ -201,64 +197,6 @@ final class FilterOrderHelper return $this; } - /** - * Return all the data required to display the active filters - * - * @return array - */ - public function getActiveFilters(): array - { - $result = []; - - if ($this->hasSearchBox() && '' !== $this->getQueryString()) { - $result[] = ['label' => '', 'value' => $this->getQueryString(), 'position' => FilterOrderPositionEnum::SearchBox->value, 'name' => 'q']; - } - - foreach ($this->dateRanges as $name => ['label' => $label]) { - $base = ['position' => FilterOrderPositionEnum::DateRange->value, 'name' => $name, 'label' => (string) $label]; - - if (null !== ($from = $this->getDateRangeData($name)['from'] ?? null)) { - $result[] = ['value' => $this->translator->trans('filter_order.by_date.From', ['from_date' => $from]), ...$base]; - } - if (null !== ($to = $this->getDateRangeData($name)['to'] ?? null)) { - $result[] = ['value' => $this->translator->trans('filter_order.by_date.To', ['to_date' => $to]), ...$base]; - } - } - - foreach ($this->checkboxes as $name => ['choices' => $choices, 'trans' => $trans]) { - $translatedChoice = array_combine($choices, [...$trans]); - foreach ($this->getCheckboxData($name) as $keyChoice) { - $result[] = ['value' => $this->translator->trans($translatedChoice[$keyChoice]), 'label' => '', 'position' => FilterOrderPositionEnum::Checkboxes->value, 'name' => $name]; - } - } - - foreach ($this->entityChoices as $name => ['label' => $label, 'class' => $class, 'choices' => $choices, 'options' => $options]) { - foreach ($this->getEntityChoiceData($name) as $selected) { - if (is_callable($options['choice_label'])) { - $value = call_user_func($options['choice_label'], $selected); - } elseif ($options['choice_label'] instanceof PropertyPathInterface || is_string($options['choice_label'])) { - $value = $this->propertyAccessor->getValue($selected, $options['choice_label']); - } else { - if (!$selected instanceof \Stringable) { - throw new \UnexpectedValueException(sprintf("we are not able to transform the value of %s to a string. Implements \\Stringable or add a 'choice_label' option to the filterFormBuilder", get_class($selected))); - } - - $value = (string) $selected; - } - - $result[] = ['value' => $this->translator->trans($value), 'label' => $label, 'position' => FilterOrderPositionEnum::EntityChoice->value, 'name' => $name]; - } - } - - foreach ($this->singleCheckbox as $name => ['label' => $label]) { - if (true === $this->getSingleCheckboxData($name)) { - $result[] = ['label' => '', 'value' => $this->translator->trans($label), 'position' => FilterOrderPositionEnum::SingleCheckbox->value, 'name' => $name]; - } - } - - return $result; - } - private function getDefaultData(): array { $r = [ diff --git a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperBuilder.php b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperBuilder.php index dfa361f6e..f2bded220 100644 --- a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperBuilder.php +++ b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperBuilder.php @@ -42,8 +42,6 @@ class FilterOrderHelperBuilder public function __construct( FormFactoryInterface $formFactory, RequestStack $requestStack, - private readonly TranslatorInterface $translator, - private readonly PropertyAccessorInterface $propertyAccessor, ) { $this->formFactory = $formFactory; $this->requestStack = $requestStack; @@ -92,8 +90,6 @@ class FilterOrderHelperBuilder $helper = new FilterOrderHelper( $this->formFactory, $this->requestStack, - $this->translator, - $this->propertyAccessor ); $helper->setSearchBox($this->searchBoxFields); diff --git a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperFactory.php b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperFactory.php index 3fbb2864d..6665750dd 100644 --- a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperFactory.php +++ b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperFactory.php @@ -25,8 +25,6 @@ class FilterOrderHelperFactory implements FilterOrderHelperFactoryInterface public function __construct( FormFactoryInterface $formFactory, RequestStack $requestStack, - private readonly TranslatorInterface $translator, - private readonly PropertyAccessorInterface $propertyAccessor, ) { $this->formFactory = $formFactory; $this->requestStack = $requestStack; @@ -34,6 +32,6 @@ class FilterOrderHelperFactory implements FilterOrderHelperFactoryInterface public function create(string $context, ?array $options = []): FilterOrderHelperBuilder { - return new FilterOrderHelperBuilder($this->formFactory, $this->requestStack, $this->translator, $this->propertyAccessor); + return new FilterOrderHelperBuilder($this->formFactory, $this->requestStack); } } diff --git a/src/Bundle/ChillMainBundle/Templating/Listing/Templating.php b/src/Bundle/ChillMainBundle/Templating/Listing/Templating.php index b91cd86e8..2d32813cb 100644 --- a/src/Bundle/ChillMainBundle/Templating/Listing/Templating.php +++ b/src/Bundle/ChillMainBundle/Templating/Listing/Templating.php @@ -24,6 +24,7 @@ class Templating extends AbstractExtension { public function __construct( private readonly RequestStack $requestStack, + private readonly FilterOrderGetActiveFilterHelper $filterOrderGetActiveFilterHelper, ) { } @@ -68,6 +69,7 @@ class Templating extends AbstractExtension return $environment->render($template, [ 'helper' => $helper, + 'active' => $this->filterOrderGetActiveFilterHelper->getActiveFilters($helper), 'form' => $helper->buildForm()->createView(), 'options' => $options, 'otherParameters' => $otherParameters, From 6065680e1e0bc71c19dd05ef158d301324f61805 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 11 Jul 2023 15:01:32 +0200 Subject: [PATCH 297/724] Feature: [export] allow to group activities by location --- .../unreleased/Feature-20230711-150055.yaml | 5 ++ .../Aggregator/ActivityLocationAggregator.php | 80 +++++++++++++++++++ .../config/services/export.yaml | 4 + .../translations/messages.fr.yml | 3 + 4 files changed, 92 insertions(+) create mode 100644 .changes/unreleased/Feature-20230711-150055.yaml create mode 100644 src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityLocationAggregator.php diff --git a/.changes/unreleased/Feature-20230711-150055.yaml b/.changes/unreleased/Feature-20230711-150055.yaml new file mode 100644 index 000000000..ecee61b49 --- /dev/null +++ b/.changes/unreleased/Feature-20230711-150055.yaml @@ -0,0 +1,5 @@ +kind: Feature +body: '[Export] allow to group activities by localisation' +time: 2023-07-11T15:00:55.770070399+02:00 +custom: + Issue: "128" diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityLocationAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityLocationAggregator.php new file mode 100644 index 000000000..9103943e4 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityLocationAggregator.php @@ -0,0 +1,80 @@ +getAllAliases(), true)) { + $qb->leftJoin('activity.location', 'actloc'); + } + $qb->addSelect(sprintf('actloc.name AS %s', self::KEY)); + $qb->addGroupBy(self::KEY); + } + + public function applyOn(): string + { + return Declarations::ACTIVITY; + } + + public function buildForm(FormBuilderInterface $builder) + { + // no form required for this aggregator + } + public function getFormDefaultData(): array + { + return []; + } + + public function getLabels($key, array $values, $data): Closure + { + return function ($value): string { + if ('_header' === $value) { + return 'export.aggregator.activity.by_location.Activity Location'; + } + + if (null === $value || '' === $value) { + return ''; + } + + return $value; + }; + } + + public function getQueryKeys($data): array + { + return [self::KEY]; + } + + public function getTitle() + { + return 'export.aggregator.activity.by_location.Title'; + } +} diff --git a/src/Bundle/ChillActivityBundle/config/services/export.yaml b/src/Bundle/ChillActivityBundle/config/services/export.yaml index 09817d80e..03285c416 100644 --- a/src/Bundle/ChillActivityBundle/config/services/export.yaml +++ b/src/Bundle/ChillActivityBundle/config/services/export.yaml @@ -144,6 +144,10 @@ services: tags: - { name: chill.export_aggregator, alias: activity_common_type_aggregator } + Chill\ActivityBundle\Export\Aggregator\ActivityLocationAggregator: + tags: + - { name: chill.export_aggregator, alias: activity_common_location_aggregator } + chill.activity.export.user_aggregator: class: Chill\ActivityBundle\Export\Aggregator\ActivityUserAggregator tags: diff --git a/src/Bundle/ChillActivityBundle/translations/messages.fr.yml b/src/Bundle/ChillActivityBundle/translations/messages.fr.yml index abef160d3..037c24f3f 100644 --- a/src/Bundle/ChillActivityBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillActivityBundle/translations/messages.fr.yml @@ -372,6 +372,9 @@ export: is sent: envoyé is received: reçu Group activity by sentreceived: Grouper les échanges par envoyé / reçu + by_location: + Activity Location: Localisation de l'échange + Title: Grouper les échanges par localisation de l'échange generic_doc: filter: From 2882038efcd4be2b65db67df7cb4f2498fcb0f57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 11 Jul 2023 16:00:40 +0200 Subject: [PATCH 298/724] [export] Add a filter "filter course having an activity between two dates" --- .../unreleased/Feature-20230711-155929.yaml | 5 ++ ...PeriodHavingActivityBetweenDatesFilter.php | 90 +++++++++++++++++++ .../config/services/export.yaml | 4 + .../translations/messages+intl-icu.fr.yml | 5 ++ .../translations/messages.fr.yml | 6 ++ 5 files changed, 110 insertions(+) create mode 100644 .changes/unreleased/Feature-20230711-155929.yaml create mode 100644 src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/PeriodHavingActivityBetweenDatesFilter.php create mode 100644 src/Bundle/ChillActivityBundle/translations/messages+intl-icu.fr.yml diff --git a/.changes/unreleased/Feature-20230711-155929.yaml b/.changes/unreleased/Feature-20230711-155929.yaml new file mode 100644 index 000000000..329bbb677 --- /dev/null +++ b/.changes/unreleased/Feature-20230711-155929.yaml @@ -0,0 +1,5 @@ +kind: Feature +body: '[export] Add a filter "filter course having an activity between two dates"' +time: 2023-07-11T15:59:29.065329834+02:00 +custom: + Issue: "129" diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/PeriodHavingActivityBetweenDatesFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/PeriodHavingActivityBetweenDatesFilter.php new file mode 100644 index 000000000..27e012d0b --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/PeriodHavingActivityBetweenDatesFilter.php @@ -0,0 +1,90 @@ +add('start_date', PickRollingDateType::class, [ + 'label' => 'export.filter.activity.course_having_activity_between_date.Receiving an activity after' + ]) + ->add('end_date', PickRollingDateType::class, [ + 'label' => 'export.filter.activity.course_having_activity_between_date.Receiving an activity before' + ]); + } + + public function getFormDefaultData(): array + { + return [ + 'start_date' => new RollingDate(RollingDate::T_YEAR_CURRENT_START), + 'end_date' => new RollingDate(RollingDate::T_TODAY) + ]; + } + + public function describeAction($data, $format = 'string') + { + return [ + 'export.filter.activity.course_having_activity_between_date.Only course having an activity between from and to', + [ + 'from' => $this->rollingDateConverter->convert($data['start_date']), + 'to' => $this->rollingDateConverter->convert($data['end_date']), + ] + ]; + } + + public function addRole(): ?string + { + return null; + } + + public function alterQuery(QueryBuilder $qb, $data) + { + $alias = 'act_period_having_act_betw_date_alias'; + $from = 'act_period_having_act_betw_date_start'; + $to = 'act_period_having_act_betw_date_end'; + + $qb->andWhere( + $qb->expr()->exists( + 'SELECT 1 FROM ' . Activity::class . " {$alias} WHERE {$alias}.date >= :{$from} AND {$alias}.date < :{$to} AND {$alias}.accompanyingPeriod = acp" + ) + ); + + $qb + ->setParameter($from, $this->rollingDateConverter->convert($data['start_date'])) + ->setParameter($to, $this->rollingDateConverter->convert($data['end_date'])); + } + + public function applyOn() + { + return \Chill\PersonBundle\Export\Declarations::ACP_TYPE; + } +} diff --git a/src/Bundle/ChillActivityBundle/config/services/export.yaml b/src/Bundle/ChillActivityBundle/config/services/export.yaml index 09817d80e..932985083 100644 --- a/src/Bundle/ChillActivityBundle/config/services/export.yaml +++ b/src/Bundle/ChillActivityBundle/config/services/export.yaml @@ -135,6 +135,10 @@ services: tags: - { name: chill.export_filter, alias: 'accompanyingcourse_has_no_activity_filter' } + Chill\ActivityBundle\Export\Filter\ACPFilters\PeriodHavingActivityBetweenDatesFilter: + tags: + - { name: chill.export_filter, alias: 'period_having_activity_betw_dates_filter' } + ## Aggregators Chill\ActivityBundle\Export\Aggregator\PersonAggregators\ActivityReasonAggregator: tags: diff --git a/src/Bundle/ChillActivityBundle/translations/messages+intl-icu.fr.yml b/src/Bundle/ChillActivityBundle/translations/messages+intl-icu.fr.yml new file mode 100644 index 000000000..ab3b963ab --- /dev/null +++ b/src/Bundle/ChillActivityBundle/translations/messages+intl-icu.fr.yml @@ -0,0 +1,5 @@ +export: + filter: + activity: + course_having_activity_between_date: + Only course having an activity between from and to: Seulement les parcours ayant reçu au moins un échange entre le {from, date, short} et le {to, date, short} diff --git a/src/Bundle/ChillActivityBundle/translations/messages.fr.yml b/src/Bundle/ChillActivityBundle/translations/messages.fr.yml index abef160d3..551a63d27 100644 --- a/src/Bundle/ChillActivityBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillActivityBundle/translations/messages.fr.yml @@ -365,6 +365,12 @@ export: by_usersscope: Filter by users scope: Filtrer les échanges par services d'au moins un utilisateur participant 'Filtered activity by users scope: only %scopes%': 'Filtré par service d''au moins un utilisateur participant: seulement %scopes%' + course_having_activity_between_date: + Title: Filtre les parcours ayant reçu un échange entre deux dates + Receiving an activity after: Ayant reçu un échange après le + Receiving an activity before: Ayant reçu un échange avant le + + aggregator: activity: by_sent_received: From edd66f6a6cf3622dd82a8535a9f4a6272cc9bb1d Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 12 Jul 2023 09:04:15 +0200 Subject: [PATCH 299/724] FIX [budget][templates] reimplement display of all calculator results --- .../Resources/views/Budget/_macros.html.twig | 33 ++++++++++++++----- .../Resources/views/Person/index.html.twig | 2 +- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_macros.html.twig b/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_macros.html.twig index dfa286af4..a1fee19ce 100644 --- a/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_macros.html.twig +++ b/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_macros.html.twig @@ -1,11 +1,12 @@ -{% macro table_elements(elements, family) %} +{% macro table_elements(elements, type) %} + - - - - + + + + @@ -38,17 +39,17 @@
        {% if is_granted('CHILL_BUDGET_ELEMENT_SEE', f) %}
      • - +
      • {% endif %} {% if is_granted('CHILL_BUDGET_ELEMENT_UPDATE', f) %}
      • - +
      • {% endif %} {% if is_granted('CHILL_BUDGET_ELEMENT_DELETE', f) %}
      • - +
      • {% endif %}
      @@ -69,7 +70,7 @@
      {{ 'Budget element type'|trans }}{{ 'Amount'|trans }}{{ 'Validity period'|trans }} {{ 'Budget element type'|trans }}{{ 'Amount'|trans }}{{ 'Validity period'|trans }} 
      {% endmacro %} -{% macro table_results(actualCharges, actualResources) %} +{% macro table_results(actualCharges, actualResources, results) %} {% set totalCharges = 0 %} {% for c in actualCharges %} @@ -97,6 +98,20 @@ {{ result|format_currency('EUR') }} + {% for result in results %} + + {{ result.label }} + + {% if result.type == 'currency' %} + {{ result.result|format_currency('EUR') }} + {% elseif result.type == 'percentage' %} + {{ result.result|round(2, 'ceil') ~ '%' }} + {% else %} + {{ result.result|round(2, 'common') }} + {% endif %} + + + {% endfor %} {% endmacro %} diff --git a/src/Bundle/ChillBudgetBundle/Resources/views/Person/index.html.twig b/src/Bundle/ChillBudgetBundle/Resources/views/Person/index.html.twig index 18d04b889..aba564206 100644 --- a/src/Bundle/ChillBudgetBundle/Resources/views/Person/index.html.twig +++ b/src/Bundle/ChillBudgetBundle/Resources/views/Person/index.html.twig @@ -25,7 +25,7 @@

      {{ 'Budget calculator'|trans }}

      - {{ table_results(charges, resources) }} + {{ table_results(charges, resources, results) }}
      {% if is_granted('CHILL_BUDGET_ELEMENT_CREATE', person) %} From f7d385eba1877756c34ed64857d0e847aedccf9d Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 12 Jul 2023 09:06:08 +0200 Subject: [PATCH 300/724] DX add changie --- .changes/unreleased/Fixed-20230712-090514.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changes/unreleased/Fixed-20230712-090514.yaml diff --git a/.changes/unreleased/Fixed-20230712-090514.yaml b/.changes/unreleased/Fixed-20230712-090514.yaml new file mode 100644 index 000000000..51a8b9317 --- /dev/null +++ b/.changes/unreleased/Fixed-20230712-090514.yaml @@ -0,0 +1,5 @@ +kind: Fixed +body: reimplement the visualization of all calculator results (specific to AMLI) +time: 2023-07-12T09:05:14.416268226+02:00 +custom: + Issue: "" From e38b369149dc92c6db0a36963c562c2976088540 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 12 Jul 2023 10:26:22 +0200 Subject: [PATCH 301/724] [cron-job] add a new "lastExecution" data on CronJobExecution entity This column will store the results of the last execution --- .../Entity/CronJobExecution.php | 18 +++++++++- .../migrations/Version20230711152947.php | 33 +++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 src/Bundle/ChillMainBundle/migrations/Version20230711152947.php diff --git a/src/Bundle/ChillMainBundle/Entity/CronJobExecution.php b/src/Bundle/ChillMainBundle/Entity/CronJobExecution.php index 0cacffac9..2883055fc 100644 --- a/src/Bundle/ChillMainBundle/Entity/CronJobExecution.php +++ b/src/Bundle/ChillMainBundle/Entity/CronJobExecution.php @@ -31,7 +31,6 @@ class CronJobExecution private string $key; /** - * @var DateTimeImmutable * @ORM\Column(type="datetime_immutable", nullable=true, options={"default": null}) */ private ?DateTimeImmutable $lastEnd = null; @@ -46,6 +45,11 @@ class CronJobExecution */ private ?int $lastStatus = null; + /** + * @ORM\Column(type="json", options={"default": "'{}'::jsonb", "jsonb": true}) + */ + private array $lastExecutionData = []; + public function __construct(string $key) { $this->key = $key; @@ -92,4 +96,16 @@ class CronJobExecution return $this; } + + public function getLastExecutionData(): array + { + return $this->lastExecutionData; + } + + public function setLastExecutionData(array $lastExecutionData): CronJobExecution + { + $this->lastExecutionData = $lastExecutionData; + + return $this; + } } diff --git a/src/Bundle/ChillMainBundle/migrations/Version20230711152947.php b/src/Bundle/ChillMainBundle/migrations/Version20230711152947.php new file mode 100644 index 000000000..ed804473e --- /dev/null +++ b/src/Bundle/ChillMainBundle/migrations/Version20230711152947.php @@ -0,0 +1,33 @@ +addSql('ALTER TABLE chill_main_cronjob_execution ADD lastExecutionData JSONB DEFAULT \'{}\'::jsonb NOT NULL'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_main_cronjob_execution DROP COLUMN lastExecutionData'); + } +} From a2e705bd92e085007fb0313b163f194497bcb5bf Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Wed, 12 Jul 2023 10:38:11 +0200 Subject: [PATCH 302/724] fixed: error with parent joins in thirdparty api search query --- .../Controller/resquery.bad.sql | 21 +++++++++++++++++++ .../Controller/resquery.fixed.sql | 21 +++++++++++++++++++ .../Search/ThirdPartyApiSearch.php | 2 +- 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 src/Bundle/ChillMainBundle/Controller/resquery.bad.sql create mode 100644 src/Bundle/ChillMainBundle/Controller/resquery.fixed.sql diff --git a/src/Bundle/ChillMainBundle/Controller/resquery.bad.sql b/src/Bundle/ChillMainBundle/Controller/resquery.bad.sql new file mode 100644 index 000000000..1033ec28c --- /dev/null +++ b/src/Bundle/ChillMainBundle/Controller/resquery.bad.sql @@ -0,0 +1,21 @@ +SELECT +'tparty' AS key, jsonb_build_object('id', tparty.id) AS metadata, GREATEST( +STRICT_WORD_SIMILARITY(LOWER(UNACCENT('areams')), tparty.canonicalized), +STRICT_WORD_SIMILARITY(LOWER(UNACCENT('areams')), parent.canonicalized) +) + GREATEST( +(tparty.canonicalized LIKE '%s' || LOWER(UNACCENT('areams')) || '%')::int, +(parent.canonicalized LIKE '%s' || LOWER(UNACCENT('areams')) || '%')::int +) + COALESCE((LOWER(UNACCENT(cmpc.label)) LIKE '%' || LOWER(UNACCENT('areams')) || '%')::int * 0.3, 0) + COALESCE((LOWER(UNACCENT(cmpc_p.label)) LIKE '%' || LOWER(UNACCENT('areams')) || '%')::int * 0.3, 0) + 1 AS pertinence +FROM chill_3party.third_party AS tparty +LEFT JOIN chill_main_address cma ON cma.id = tparty.address_id +LEFT JOIN chill_main_postal_code cmpc ON cma.postcode_id = cmpc.id +LEFT JOIN chill_3party.third_party AS parent ON tparty.parent_id = parent.id +LEFT JOIN chill_main_address cma_p ON parent.address_id = cma_p.id +LEFT JOIN chill_main_postal_code cmpc_p ON cma_p.postcode_id = cmpc.id +WHERE (tparty.active IS TRUE) AND (((LOWER(UNACCENT('areams')) <<% tparty.canonicalized OR +tparty.canonicalized LIKE '%' || LOWER(UNACCENT('areams')) || '%') +OR +(LOWER(UNACCENT('areams')) <<% parent.canonicalized OR +parent.canonicalized LIKE '%' || LOWER(UNACCENT('areams')) || '%')) +AND tparty.active IS TRUE and (parent.active IS TRUE OR parent IS NULL)) +ORDER BY pertinence DESC LIMIT 50 OFFSET 0; diff --git a/src/Bundle/ChillMainBundle/Controller/resquery.fixed.sql b/src/Bundle/ChillMainBundle/Controller/resquery.fixed.sql new file mode 100644 index 000000000..dbb55f187 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Controller/resquery.fixed.sql @@ -0,0 +1,21 @@ +SELECT +'tparty' AS key, jsonb_build_object('id', tparty.id) AS metadata, GREATEST( +STRICT_WORD_SIMILARITY(LOWER(UNACCENT('areams')), tparty.canonicalized), +STRICT_WORD_SIMILARITY(LOWER(UNACCENT('areams')), parent.canonicalized) +) + GREATEST( +(tparty.canonicalized LIKE '%s' || LOWER(UNACCENT('areams')) || '%')::int, +(parent.canonicalized LIKE '%s' || LOWER(UNACCENT('areams')) || '%')::int +) + COALESCE((LOWER(UNACCENT(cmpc.label)) LIKE '%' || LOWER(UNACCENT('areams')) || '%')::int * 0.3, 0) + COALESCE((LOWER(UNACCENT(cmpc_p.label)) LIKE '%' || LOWER(UNACCENT('areams')) || '%')::int * 0.3, 0) + 1 AS pertinence +FROM chill_3party.third_party AS tparty +LEFT JOIN chill_main_address cma ON cma.id = tparty.address_id +LEFT JOIN chill_main_postal_code cmpc ON cma.postcode_id = cmpc.id +LEFT JOIN chill_3party.third_party AS parent ON tparty.parent_id = parent.id +LEFT JOIN chill_main_address cma_p ON parent.address_id = cma_p.id +LEFT JOIN chill_main_postal_code cmpc_p ON cma_p.postcode_id = cmpc_p.id +WHERE (tparty.active IS TRUE) AND (((LOWER(UNACCENT('areams')) <<% tparty.canonicalized OR +tparty.canonicalized LIKE '%' || LOWER(UNACCENT('areams')) || '%') +OR +(LOWER(UNACCENT('areams')) <<% parent.canonicalized OR +parent.canonicalized LIKE '%' || LOWER(UNACCENT('areams')) || '%')) +AND tparty.active IS TRUE and (parent.active IS TRUE OR parent IS NULL)) +ORDER BY pertinence DESC LIMIT 50 OFFSET 0; diff --git a/src/Bundle/ChillThirdPartyBundle/Search/ThirdPartyApiSearch.php b/src/Bundle/ChillThirdPartyBundle/Search/ThirdPartyApiSearch.php index 86c0fa9db..42b98622f 100644 --- a/src/Bundle/ChillThirdPartyBundle/Search/ThirdPartyApiSearch.php +++ b/src/Bundle/ChillThirdPartyBundle/Search/ThirdPartyApiSearch.php @@ -75,7 +75,7 @@ class ThirdPartyApiSearch implements SearchApiInterface LEFT JOIN chill_main_postal_code cmpc ON cma.postcode_id = cmpc.id LEFT JOIN chill_3party.third_party AS parent ON tparty.parent_id = parent.id LEFT JOIN chill_main_address cma_p ON parent.address_id = cma_p.id - LEFT JOIN chill_main_postal_code cmpc_p ON cma_p.postcode_id = cmpc.id') + LEFT JOIN chill_main_postal_code cmpc_p ON cma_p.postcode_id = cmpc_p.id') ->andWhereClause('tparty.active IS TRUE'); $strs = explode(' ', $pattern); From e8690d249fff6acac5b02054daff7833cc2ec893 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 12 Jul 2023 10:42:46 +0200 Subject: [PATCH 303/724] FIX [duplicate][delete] fix error messages for treating the accompaning_period_work linked to the person that will be deleted --- .../ChillPersonBundle/Actions/Remove/PersonMove.php | 10 ++++++++-- .../views/PersonDuplicate/_sidepane.html.twig | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Actions/Remove/PersonMove.php b/src/Bundle/ChillPersonBundle/Actions/Remove/PersonMove.php index 4e2f7468e..76a6f5b8d 100644 --- a/src/Bundle/ChillPersonBundle/Actions/Remove/PersonMove.php +++ b/src/Bundle/ChillPersonBundle/Actions/Remove/PersonMove.php @@ -133,8 +133,14 @@ class PersonMove $conditions = []; - foreach ($mapping['joinColumns'] as $columns) { - $conditions[] = sprintf('%s = %d', $columns['name'], $from->getId()); + if (array_key_exists('joinTable', $mapping)) { + foreach ($mapping['joinTable']['joinColumns'] as $columns) { + $conditions[] = sprintf('%s = %d', $columns['referencedColumnName'], $from->getId()); + } + } elseif (array_key_exists('joinColumns', $mapping)) { + foreach ($mapping['joinColumns'] as $columns) { + $conditions[] = sprintf('%s = %d', $columns['name'], $from->getId()); + } } return sprintf( diff --git a/src/Bundle/ChillPersonBundle/Resources/views/PersonDuplicate/_sidepane.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/PersonDuplicate/_sidepane.html.twig index 1e770062a..b8edcc437 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/PersonDuplicate/_sidepane.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/PersonDuplicate/_sidepane.html.twig @@ -4,7 +4,7 @@
    • {{ 'gender'|trans }}: {{ person.gender|trans }}
    • {{ 'maritalStatus'|trans }}: - {% if person.maritalStatus.name %}{{ person.maritalStatus.name|localize_translatable_string }}{% endif %}
    • + {% if person.maritalStatus %}{{ person.maritalStatus.name|localize_translatable_string }}{% endif %}
    • {{ 'birthdate'|trans }}: {% if person.birthdate is not null %}{{ person.birthdate|format_date('short') }}{% endif %}
    • {{ 'placeOfBirth'|trans }}: From f3829d3390ae7e22939f02a6bb71db305ebe060e Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Wed, 12 Jul 2023 10:50:17 +0200 Subject: [PATCH 304/724] adapt query to simplify join clauses (lightly improve perfs) --- .../Controller/resquery.good.sql | 19 +++++++++++++++++++ .../Search/ThirdPartyApiSearch.php | 10 +++------- 2 files changed, 22 insertions(+), 7 deletions(-) create mode 100644 src/Bundle/ChillMainBundle/Controller/resquery.good.sql diff --git a/src/Bundle/ChillMainBundle/Controller/resquery.good.sql b/src/Bundle/ChillMainBundle/Controller/resquery.good.sql new file mode 100644 index 000000000..5877b04f8 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Controller/resquery.good.sql @@ -0,0 +1,19 @@ +SELECT +'tparty' AS key, jsonb_build_object('id', tparty.id) AS metadata, GREATEST( +STRICT_WORD_SIMILARITY(LOWER(UNACCENT('areams')), tparty.canonicalized), +STRICT_WORD_SIMILARITY(LOWER(UNACCENT('areams')), parent.canonicalized) +) + GREATEST( +(tparty.canonicalized LIKE '%s' || LOWER(UNACCENT('areams')) || '%')::int, +(parent.canonicalized LIKE '%s' || LOWER(UNACCENT('areams')) || '%')::int +) + COALESCE((LOWER(UNACCENT(cmpc.label)) LIKE '%' || LOWER(UNACCENT('areams')) || '%')::int * 0.3, 0) + 1 AS pertinence +FROM chill_3party.third_party AS tparty +LEFT JOIN chill_3party.third_party AS parent ON tparty.parent_id = parent.id +LEFT JOIN chill_main_address cma ON cma.id = COALESCE(parent.address_id, tparty.address_id) +LEFT JOIN chill_main_postal_code cmpc ON cma.postcode_id = cmpc.id +WHERE (((LOWER(UNACCENT('areams')) <<% tparty.canonicalized OR +tparty.canonicalized LIKE '%' || LOWER(UNACCENT('areams')) || '%') +OR +(LOWER(UNACCENT('areams')) <<% parent.canonicalized OR +parent.canonicalized LIKE '%' || LOWER(UNACCENT('areams')) || '%')) +AND tparty.active IS TRUE and (parent.active IS TRUE OR parent IS NULL)) +ORDER BY pertinence DESC, tparty.id ASC LIMIT 500 OFFSET 0; diff --git a/src/Bundle/ChillThirdPartyBundle/Search/ThirdPartyApiSearch.php b/src/Bundle/ChillThirdPartyBundle/Search/ThirdPartyApiSearch.php index 42b98622f..bb5303143 100644 --- a/src/Bundle/ChillThirdPartyBundle/Search/ThirdPartyApiSearch.php +++ b/src/Bundle/ChillThirdPartyBundle/Search/ThirdPartyApiSearch.php @@ -71,12 +71,9 @@ class ThirdPartyApiSearch implements SearchApiInterface ->setSelectKey('tparty') ->setSelectJsonbMetadata("jsonb_build_object('id', tparty.id)") ->setFromClause('chill_3party.third_party AS tparty - LEFT JOIN chill_main_address cma ON cma.id = tparty.address_id - LEFT JOIN chill_main_postal_code cmpc ON cma.postcode_id = cmpc.id LEFT JOIN chill_3party.third_party AS parent ON tparty.parent_id = parent.id - LEFT JOIN chill_main_address cma_p ON parent.address_id = cma_p.id - LEFT JOIN chill_main_postal_code cmpc_p ON cma_p.postcode_id = cmpc_p.id') - ->andWhereClause('tparty.active IS TRUE'); + LEFT JOIN chill_main_address cma ON cma.id = COALESCE(parent.address_id, tparty.address_id) + LEFT JOIN chill_main_postal_code cmpc ON cma.postcode_id = cmpc.id'); $strs = explode(' ', $pattern); $wheres = []; @@ -102,8 +99,7 @@ class ThirdPartyApiSearch implements SearchApiInterface (parent.canonicalized LIKE '%s' || LOWER(UNACCENT(?)) || '%')::int ) + " . // take postcode label into account, but lower than the canonicalized field - "COALESCE((LOWER(UNACCENT(cmpc.label)) LIKE '%' || LOWER(UNACCENT(?)) || '%')::int * 0.3, 0) + " . - "COALESCE((LOWER(UNACCENT(cmpc_p.label)) LIKE '%' || LOWER(UNACCENT(?)) || '%')::int * 0.3, 0)"; + "COALESCE((LOWER(UNACCENT(cmpc.label)) LIKE '%' || LOWER(UNACCENT(?)) || '%')::int * 0.3, 0)"; $pertinenceArgs[] = [$str, $str, $str, $str, $str, $str]; } } From d825a8509bcf8aaf0df4037231c167495c6f3a41 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 12 Jul 2023 10:42:46 +0200 Subject: [PATCH 305/724] FIX [duplicate][delete] fix error messages for treating the accompaning_period_work linked to the person that will be deleted --- .../ChillPersonBundle/Actions/Remove/PersonMove.php | 10 ++++++++-- .../views/PersonDuplicate/_sidepane.html.twig | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Actions/Remove/PersonMove.php b/src/Bundle/ChillPersonBundle/Actions/Remove/PersonMove.php index 4e2f7468e..76a6f5b8d 100644 --- a/src/Bundle/ChillPersonBundle/Actions/Remove/PersonMove.php +++ b/src/Bundle/ChillPersonBundle/Actions/Remove/PersonMove.php @@ -133,8 +133,14 @@ class PersonMove $conditions = []; - foreach ($mapping['joinColumns'] as $columns) { - $conditions[] = sprintf('%s = %d', $columns['name'], $from->getId()); + if (array_key_exists('joinTable', $mapping)) { + foreach ($mapping['joinTable']['joinColumns'] as $columns) { + $conditions[] = sprintf('%s = %d', $columns['referencedColumnName'], $from->getId()); + } + } elseif (array_key_exists('joinColumns', $mapping)) { + foreach ($mapping['joinColumns'] as $columns) { + $conditions[] = sprintf('%s = %d', $columns['name'], $from->getId()); + } } return sprintf( diff --git a/src/Bundle/ChillPersonBundle/Resources/views/PersonDuplicate/_sidepane.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/PersonDuplicate/_sidepane.html.twig index 1e770062a..b8edcc437 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/PersonDuplicate/_sidepane.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/PersonDuplicate/_sidepane.html.twig @@ -4,7 +4,7 @@
    • {{ 'gender'|trans }}: {{ person.gender|trans }}
    • {{ 'maritalStatus'|trans }}: - {% if person.maritalStatus.name %}{{ person.maritalStatus.name|localize_translatable_string }}{% endif %}
    • + {% if person.maritalStatus %}{{ person.maritalStatus.name|localize_translatable_string }}{% endif %}
    • {{ 'birthdate'|trans }}: {% if person.birthdate is not null %}{{ person.birthdate|format_date('short') }}{% endif %}
    • {{ 'placeOfBirth'|trans }}: From efee2d8b44369e6546d13afa19d58b8a43d086db Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Wed, 12 Jul 2023 10:53:12 +0200 Subject: [PATCH 306/724] cleaning --- .../Controller/resquery.bad.sql | 21 ------------------- .../Controller/resquery.fixed.sql | 21 ------------------- .../Controller/resquery.good.sql | 19 ----------------- 3 files changed, 61 deletions(-) delete mode 100644 src/Bundle/ChillMainBundle/Controller/resquery.bad.sql delete mode 100644 src/Bundle/ChillMainBundle/Controller/resquery.fixed.sql delete mode 100644 src/Bundle/ChillMainBundle/Controller/resquery.good.sql diff --git a/src/Bundle/ChillMainBundle/Controller/resquery.bad.sql b/src/Bundle/ChillMainBundle/Controller/resquery.bad.sql deleted file mode 100644 index 1033ec28c..000000000 --- a/src/Bundle/ChillMainBundle/Controller/resquery.bad.sql +++ /dev/null @@ -1,21 +0,0 @@ -SELECT -'tparty' AS key, jsonb_build_object('id', tparty.id) AS metadata, GREATEST( -STRICT_WORD_SIMILARITY(LOWER(UNACCENT('areams')), tparty.canonicalized), -STRICT_WORD_SIMILARITY(LOWER(UNACCENT('areams')), parent.canonicalized) -) + GREATEST( -(tparty.canonicalized LIKE '%s' || LOWER(UNACCENT('areams')) || '%')::int, -(parent.canonicalized LIKE '%s' || LOWER(UNACCENT('areams')) || '%')::int -) + COALESCE((LOWER(UNACCENT(cmpc.label)) LIKE '%' || LOWER(UNACCENT('areams')) || '%')::int * 0.3, 0) + COALESCE((LOWER(UNACCENT(cmpc_p.label)) LIKE '%' || LOWER(UNACCENT('areams')) || '%')::int * 0.3, 0) + 1 AS pertinence -FROM chill_3party.third_party AS tparty -LEFT JOIN chill_main_address cma ON cma.id = tparty.address_id -LEFT JOIN chill_main_postal_code cmpc ON cma.postcode_id = cmpc.id -LEFT JOIN chill_3party.third_party AS parent ON tparty.parent_id = parent.id -LEFT JOIN chill_main_address cma_p ON parent.address_id = cma_p.id -LEFT JOIN chill_main_postal_code cmpc_p ON cma_p.postcode_id = cmpc.id -WHERE (tparty.active IS TRUE) AND (((LOWER(UNACCENT('areams')) <<% tparty.canonicalized OR -tparty.canonicalized LIKE '%' || LOWER(UNACCENT('areams')) || '%') -OR -(LOWER(UNACCENT('areams')) <<% parent.canonicalized OR -parent.canonicalized LIKE '%' || LOWER(UNACCENT('areams')) || '%')) -AND tparty.active IS TRUE and (parent.active IS TRUE OR parent IS NULL)) -ORDER BY pertinence DESC LIMIT 50 OFFSET 0; diff --git a/src/Bundle/ChillMainBundle/Controller/resquery.fixed.sql b/src/Bundle/ChillMainBundle/Controller/resquery.fixed.sql deleted file mode 100644 index dbb55f187..000000000 --- a/src/Bundle/ChillMainBundle/Controller/resquery.fixed.sql +++ /dev/null @@ -1,21 +0,0 @@ -SELECT -'tparty' AS key, jsonb_build_object('id', tparty.id) AS metadata, GREATEST( -STRICT_WORD_SIMILARITY(LOWER(UNACCENT('areams')), tparty.canonicalized), -STRICT_WORD_SIMILARITY(LOWER(UNACCENT('areams')), parent.canonicalized) -) + GREATEST( -(tparty.canonicalized LIKE '%s' || LOWER(UNACCENT('areams')) || '%')::int, -(parent.canonicalized LIKE '%s' || LOWER(UNACCENT('areams')) || '%')::int -) + COALESCE((LOWER(UNACCENT(cmpc.label)) LIKE '%' || LOWER(UNACCENT('areams')) || '%')::int * 0.3, 0) + COALESCE((LOWER(UNACCENT(cmpc_p.label)) LIKE '%' || LOWER(UNACCENT('areams')) || '%')::int * 0.3, 0) + 1 AS pertinence -FROM chill_3party.third_party AS tparty -LEFT JOIN chill_main_address cma ON cma.id = tparty.address_id -LEFT JOIN chill_main_postal_code cmpc ON cma.postcode_id = cmpc.id -LEFT JOIN chill_3party.third_party AS parent ON tparty.parent_id = parent.id -LEFT JOIN chill_main_address cma_p ON parent.address_id = cma_p.id -LEFT JOIN chill_main_postal_code cmpc_p ON cma_p.postcode_id = cmpc_p.id -WHERE (tparty.active IS TRUE) AND (((LOWER(UNACCENT('areams')) <<% tparty.canonicalized OR -tparty.canonicalized LIKE '%' || LOWER(UNACCENT('areams')) || '%') -OR -(LOWER(UNACCENT('areams')) <<% parent.canonicalized OR -parent.canonicalized LIKE '%' || LOWER(UNACCENT('areams')) || '%')) -AND tparty.active IS TRUE and (parent.active IS TRUE OR parent IS NULL)) -ORDER BY pertinence DESC LIMIT 50 OFFSET 0; diff --git a/src/Bundle/ChillMainBundle/Controller/resquery.good.sql b/src/Bundle/ChillMainBundle/Controller/resquery.good.sql deleted file mode 100644 index 5877b04f8..000000000 --- a/src/Bundle/ChillMainBundle/Controller/resquery.good.sql +++ /dev/null @@ -1,19 +0,0 @@ -SELECT -'tparty' AS key, jsonb_build_object('id', tparty.id) AS metadata, GREATEST( -STRICT_WORD_SIMILARITY(LOWER(UNACCENT('areams')), tparty.canonicalized), -STRICT_WORD_SIMILARITY(LOWER(UNACCENT('areams')), parent.canonicalized) -) + GREATEST( -(tparty.canonicalized LIKE '%s' || LOWER(UNACCENT('areams')) || '%')::int, -(parent.canonicalized LIKE '%s' || LOWER(UNACCENT('areams')) || '%')::int -) + COALESCE((LOWER(UNACCENT(cmpc.label)) LIKE '%' || LOWER(UNACCENT('areams')) || '%')::int * 0.3, 0) + 1 AS pertinence -FROM chill_3party.third_party AS tparty -LEFT JOIN chill_3party.third_party AS parent ON tparty.parent_id = parent.id -LEFT JOIN chill_main_address cma ON cma.id = COALESCE(parent.address_id, tparty.address_id) -LEFT JOIN chill_main_postal_code cmpc ON cma.postcode_id = cmpc.id -WHERE (((LOWER(UNACCENT('areams')) <<% tparty.canonicalized OR -tparty.canonicalized LIKE '%' || LOWER(UNACCENT('areams')) || '%') -OR -(LOWER(UNACCENT('areams')) <<% parent.canonicalized OR -parent.canonicalized LIKE '%' || LOWER(UNACCENT('areams')) || '%')) -AND tparty.active IS TRUE and (parent.active IS TRUE OR parent IS NULL)) -ORDER BY pertinence DESC, tparty.id ASC LIMIT 500 OFFSET 0; From fcd4c3b92eef7963b6ce0d1096648852ccbec88a Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 12 Jul 2023 11:12:22 +0200 Subject: [PATCH 307/724] DX add changie --- .changes/unreleased/Fixed-20230712-111206.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changes/unreleased/Fixed-20230712-111206.yaml diff --git a/.changes/unreleased/Fixed-20230712-111206.yaml b/.changes/unreleased/Fixed-20230712-111206.yaml new file mode 100644 index 000000000..7bec6095e --- /dev/null +++ b/.changes/unreleased/Fixed-20230712-111206.yaml @@ -0,0 +1,5 @@ +kind: Fixed +body: reinstate the fusion of duplicate persons +time: 2023-07-12T11:12:06.673925762+02:00 +custom: + Issue: "107" From 04235409769d55a3b5277e23b6c1f2e31a184218 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 12 Jul 2023 11:17:25 +0200 Subject: [PATCH 308/724] FIX [duplicate][personpicker] use dynamic person picker to assign duplicate manually --- .../Form/PersonFindManuallyDuplicateType.php | 4 ++-- .../views/PersonDuplicate/find_manually.html.twig | 12 ++++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Form/PersonFindManuallyDuplicateType.php b/src/Bundle/ChillPersonBundle/Form/PersonFindManuallyDuplicateType.php index b9dfad240..1d7697332 100644 --- a/src/Bundle/ChillPersonBundle/Form/PersonFindManuallyDuplicateType.php +++ b/src/Bundle/ChillPersonBundle/Form/PersonFindManuallyDuplicateType.php @@ -11,7 +11,7 @@ declare(strict_types=1); namespace Chill\PersonBundle\Form; -use Chill\PersonBundle\Form\Type\PickPersonType; +use Chill\PersonBundle\Form\Type\PickPersonDynamicType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\HiddenType; use Symfony\Component\Form\FormBuilderInterface; @@ -21,7 +21,7 @@ class PersonFindManuallyDuplicateType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { $builder - ->add('person', PickPersonType::class, [ + ->add('person', PickPersonDynamicType::class, [ 'label' => 'Find duplicate', 'mapped' => false, ]) diff --git a/src/Bundle/ChillPersonBundle/Resources/views/PersonDuplicate/find_manually.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/PersonDuplicate/find_manually.html.twig index 8769ae6da..982690f00 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/PersonDuplicate/find_manually.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/PersonDuplicate/find_manually.html.twig @@ -8,9 +8,9 @@ {% block content %}
      - +

      {{ 'Désigner un dossier doublon'|trans }}

      - + {{ form_start(form) }} {{ form_rest(form) }} @@ -29,3 +29,11 @@
      {% endblock %} + +{% block js %} + {{ encore_entry_script_tags('mod_pickentity_type') }} +{% endblock %} + +{% block css %} + {{ encore_entry_link_tags('mod_pickentity_type') }} +{% endblock %} From 3f66e1a862416658a3afce675dbc1cb29440fb24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 12 Jul 2023 11:36:26 +0200 Subject: [PATCH 309/724] [cron-job] allow a cronjob to pass data from one execution to another When a cronjob is executed, it may return an array of data. This data will be passed as parameter on the next execution --- .changes/unreleased/DX-20230712-113603.yaml | 6 ++ .../ChillMainBundle/Cron/CronJobInterface.php | 10 ++- .../ChillMainBundle/Cron/CronManager.php | 25 +++++- ...eographicalUnitMaterializedViewCronJob.php | 4 +- .../Cron/CronJobDatabaseInteractionTest.php | 87 +++++++++++++++++++ .../Tests/Cron/CronManagerTest.php | 12 +-- .../AccompanyingPeriodStepChangeCronjob.php | 4 +- 7 files changed, 137 insertions(+), 11 deletions(-) create mode 100644 .changes/unreleased/DX-20230712-113603.yaml create mode 100644 src/Bundle/ChillMainBundle/Tests/Cron/CronJobDatabaseInteractionTest.php diff --git a/.changes/unreleased/DX-20230712-113603.yaml b/.changes/unreleased/DX-20230712-113603.yaml new file mode 100644 index 000000000..518ac3ca9 --- /dev/null +++ b/.changes/unreleased/DX-20230712-113603.yaml @@ -0,0 +1,6 @@ +kind: DX +body: '[cronjob] when a cronjob is executed, it may return an array of data that will + be passed as argument on the next execution' +time: 2023-07-12T11:36:03.813179067+02:00 +custom: + Issue: "" diff --git a/src/Bundle/ChillMainBundle/Cron/CronJobInterface.php b/src/Bundle/ChillMainBundle/Cron/CronJobInterface.php index 4e1ca9ff6..69edf8464 100644 --- a/src/Bundle/ChillMainBundle/Cron/CronJobInterface.php +++ b/src/Bundle/ChillMainBundle/Cron/CronJobInterface.php @@ -19,5 +19,13 @@ interface CronJobInterface public function getKey(): string; - public function run(): void; + /** + * Execute the cronjob + * + * If data is returned, this data is passed as argument on the next execution + * + * @param array $lastExecutionData the data which was returned from the previous execution + * @return array|null optionally return an array with the same data than the previous execution + */ + public function run(array $lastExecutionData): null|array; } diff --git a/src/Bundle/ChillMainBundle/Cron/CronManager.php b/src/Bundle/ChillMainBundle/Cron/CronManager.php index f69dcba76..a3e82a170 100644 --- a/src/Bundle/ChillMainBundle/Cron/CronManager.php +++ b/src/Bundle/ChillMainBundle/Cron/CronManager.php @@ -14,6 +14,7 @@ namespace Chill\MainBundle\Cron; use Chill\MainBundle\Entity\CronJobExecution; use Chill\MainBundle\Repository\CronJobExecutionRepositoryInterface; use DateTimeImmutable; +use Doctrine\DBAL\Types\Types; use Doctrine\ORM\EntityManagerInterface; use Exception; use Psr\Log\LoggerInterface; @@ -46,6 +47,8 @@ class CronManager implements CronManagerInterface private const UPDATE_BEFORE_EXEC = 'UPDATE ' . CronJobExecution::class . ' cr SET cr.lastStart = :now WHERE cr.key = :key'; + private const UPDATE_LAST_EXECUTION_DATA = 'UPDATE ' . CronJobExecution::class . ' cr SET cr.lastExecutionData = :data WHERE cr.key = :key'; + private CronJobExecutionRepositoryInterface $cronJobExecutionRepository; private EntityManagerInterface $entityManager; @@ -85,6 +88,9 @@ class CronManager implements CronManagerInterface foreach ($orderedJobs as $job) { if ($job->canRun($lasts[$job->getKey()] ?? null)) { if (array_key_exists($job->getKey(), $lasts)) { + + $executionData = $lasts[$job->getKey()]->getLastExecutionData(); + $this->entityManager ->createQuery(self::UPDATE_BEFORE_EXEC) ->setParameters([ @@ -96,12 +102,17 @@ class CronManager implements CronManagerInterface $execution = new CronJobExecution($job->getKey()); $this->entityManager->persist($execution); $this->entityManager->flush(); + + $executionData = $execution->getLastExecutionData(); } $this->entityManager->clear(); + // note: at this step, the entity manager does not have any entity CronJobExecution + // into his internal memory + try { $this->logger->info(sprintf('%sWill run job', self::LOG_PREFIX), ['job' => $job->getKey()]); - $job->run(); + $result = $job->run($executionData); $this->entityManager ->createQuery(self::UPDATE_AFTER_EXEC) @@ -112,6 +123,14 @@ class CronManager implements CronManagerInterface ]) ->execute(); + if (null !== $result) { + $this->entityManager + ->createQuery(self::UPDATE_LAST_EXECUTION_DATA) + ->setParameter('data', $result, Types::JSON) + ->setParameter('key', $job->getKey(), Types::STRING) + ->execute(); + } + $this->logger->info(sprintf('%sSuccessfully run job', self::LOG_PREFIX), ['job' => $job->getKey()]); return; @@ -133,7 +152,7 @@ class CronManager implements CronManagerInterface } /** - * @return array<0: CronJobInterface[], 1: array> + * @return array{0: array, 1: array} */ private function getOrderedJobs(): array { @@ -174,7 +193,7 @@ class CronManager implements CronManagerInterface { foreach ($this->jobs as $job) { if ($job->getKey() === $forceJob) { - $job->run(); + $job->run([]); } } } diff --git a/src/Bundle/ChillMainBundle/Service/AddressGeographicalUnit/RefreshAddressToGeographicalUnitMaterializedViewCronJob.php b/src/Bundle/ChillMainBundle/Service/AddressGeographicalUnit/RefreshAddressToGeographicalUnitMaterializedViewCronJob.php index 9dbb38a3f..3a6ff8fb9 100644 --- a/src/Bundle/ChillMainBundle/Service/AddressGeographicalUnit/RefreshAddressToGeographicalUnitMaterializedViewCronJob.php +++ b/src/Bundle/ChillMainBundle/Service/AddressGeographicalUnit/RefreshAddressToGeographicalUnitMaterializedViewCronJob.php @@ -49,8 +49,10 @@ class RefreshAddressToGeographicalUnitMaterializedViewCronJob implements CronJob return 'refresh-materialized-view-address-to-geog-units'; } - public function run(): void + public function run(array $lastExecutionData): null|array { $this->connection->executeQuery('REFRESH MATERIALIZED VIEW view_chill_main_address_geographical_unit'); + + return null; } } diff --git a/src/Bundle/ChillMainBundle/Tests/Cron/CronJobDatabaseInteractionTest.php b/src/Bundle/ChillMainBundle/Tests/Cron/CronJobDatabaseInteractionTest.php new file mode 100644 index 000000000..0b80730fe --- /dev/null +++ b/src/Bundle/ChillMainBundle/Tests/Cron/CronJobDatabaseInteractionTest.php @@ -0,0 +1,87 @@ +entityManager = self::$container->get(EntityManagerInterface::class); + $this->cronJobExecutionRepository = self::$container->get(CronJobExecutionRepository::class); + } + + public function testCompleteLifeCycle(): void + { + $cronjob = $this->prophesize(CronJobInterface::class); + $cronjob->canRun(null)->willReturn(true); + $cronjob->canRun(Argument::type(CronJobExecution::class))->willReturn(true); + $cronjob->getKey()->willReturn('test-with-data'); + $cronjob->run([])->willReturn(['test' => 'execution-0']); + $cronjob->run(['test' => 'execution-0'])->willReturn(['test' => 'execution-1']); + + $cronjob->run([])->shouldBeCalledOnce(); + $cronjob->run(['test' => 'execution-0'])->shouldBeCalledOnce(); + + $manager = new CronManager( + $this->cronJobExecutionRepository, + $this->entityManager, + [$cronjob->reveal()], + new NullLogger() + ); + + // run a first time + $manager->run(); + + // run a second time + $manager->run(); + } + +} + +class JobWithReturn implements CronJobInterface +{ + public function canRun(?CronJobExecution $cronJobExecution): bool + { + return true; + } + + public function getKey(): string + { + return 'with-data'; + } + + public function run(array $lastExecutionData): null|array + { + return ['data' => 'test']; + } +} diff --git a/src/Bundle/ChillMainBundle/Tests/Cron/CronManagerTest.php b/src/Bundle/ChillMainBundle/Tests/Cron/CronManagerTest.php index 4b812ce2b..47c929a52 100644 --- a/src/Bundle/ChillMainBundle/Tests/Cron/CronManagerTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Cron/CronManagerTest.php @@ -40,7 +40,7 @@ final class CronManagerTest extends TestCase $jobToExecute = $this->prophesize(CronJobInterface::class); $jobToExecute->getKey()->willReturn('to-exec'); $jobToExecute->canRun(Argument::type(CronJobExecution::class))->willReturn(true); - $jobToExecute->run()->shouldBeCalled(); + $jobToExecute->run([])->shouldBeCalled(); $executions = [ ['key' => $jobOld1->getKey(), 'lastStart' => new DateTimeImmutable('yesterday'), 'lastEnd' => new DateTimeImmutable('1 hours ago'), 'lastStatus' => CronJobExecution::SUCCESS], @@ -64,7 +64,7 @@ final class CronManagerTest extends TestCase $jobAlreadyExecuted = new JobCanRun('k'); $jobNeverExecuted = $this->prophesize(CronJobInterface::class); $jobNeverExecuted->getKey()->willReturn('never-executed'); - $jobNeverExecuted->run()->shouldBeCalled(); + $jobNeverExecuted->run([])->shouldBeCalled(); $jobNeverExecuted->canRun(null)->willReturn(true); $executions = [ @@ -86,7 +86,7 @@ final class CronManagerTest extends TestCase $jobAlreadyExecuted = new JobCanRun('k'); $jobNeverExecuted = $this->prophesize(CronJobInterface::class); $jobNeverExecuted->getKey()->willReturn('never-executed'); - $jobNeverExecuted->run()->shouldBeCalled(); + $jobNeverExecuted->run([])->shouldBeCalled(); $jobNeverExecuted->canRun(null)->willReturn(true); $executions = [ @@ -178,8 +178,9 @@ class JobCanRun implements CronJobInterface return $this->key; } - public function run(): void + public function run(array $lastExecutionData): null|array { + return null; } } @@ -195,7 +196,8 @@ class JobCannotRun implements CronJobInterface return 'job-b'; } - public function run(): void + public function run(array $lastExecutionData): null|array { + return null; } } diff --git a/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Lifecycle/AccompanyingPeriodStepChangeCronjob.php b/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Lifecycle/AccompanyingPeriodStepChangeCronjob.php index f637e70b9..2ddf3415c 100644 --- a/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Lifecycle/AccompanyingPeriodStepChangeCronjob.php +++ b/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Lifecycle/AccompanyingPeriodStepChangeCronjob.php @@ -39,8 +39,10 @@ readonly class AccompanyingPeriodStepChangeCronjob implements CronJobInterface return 'accompanying-period-step-change'; } - public function run(): void + public function run(array $lastExecutionData): null|array { ($this->requestor)(); + + return null; } } From e82c7cdc6c174c6873775a43d20446668af3eb43 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Wed, 12 Jul 2023 13:24:23 +0200 Subject: [PATCH 310/724] Fixed: [homepage widget] repair my unread notification list with actions and evaluations documents --- .../public/vuejs/HomepageWidget/MyNotifications.vue | 8 ++++++++ .../Resources/public/vuejs/HomepageWidget/js/i18n.js | 1 + 2 files changed, 9 insertions(+) diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/HomepageWidget/MyNotifications.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/HomepageWidget/MyNotifications.vue index 06683f8fc..bfde741ac 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/HomepageWidget/MyNotifications.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/HomepageWidget/MyNotifications.vue @@ -66,6 +66,10 @@ export default { return appMessages.fr.the_activity; case 'Chill\\PersonBundle\\Entity\\AccompanyingPeriod': return appMessages.fr.the_course; + case 'Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWork': + return appMessages.fr.the_action; + case 'Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluationDocument': + return appMessages.fr.the_evaluation_document; case 'Chill\\MainBundle\\Entity\\Workflow\\EntityWorkflow': return appMessages.fr.the_workflow; default: @@ -78,6 +82,10 @@ export default { return `/fr/activity/${n.relatedEntityId}/show` case 'Chill\\PersonBundle\\Entity\\AccompanyingPeriod': return `/fr/parcours/${n.relatedEntityId}` + case 'Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWork': + return `/fr/person/accompanying-period/work/${n.relatedEntityId}/show` + case 'Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluationDocument': + return `/fr/notification/${n.id}/show` // to the notification case 'Chill\\MainBundle\\Entity\\Workflow\\EntityWorkflow': return `/fr/main/workflow/${n.relatedEntityId}/show` default: diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/HomepageWidget/js/i18n.js b/src/Bundle/ChillMainBundle/Resources/public/vuejs/HomepageWidget/js/i18n.js index 697074671..587f06fa9 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/HomepageWidget/js/i18n.js +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/HomepageWidget/js/i18n.js @@ -46,6 +46,7 @@ const appMessages = { the_course: "le parcours", the_action: "l'action", the_evaluation: "l'évaluation", + the_evaluation_document: "le document de l'évaluation", the_task: "la tâche", the_workflow: "le workflow", StartDate: "Date d'ouverture", From e0758215ba3c557fc26065591663be2389e1fe50 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 12 Jul 2023 15:17:03 +0200 Subject: [PATCH 311/724] FEATURE [repository] implement filter logic --- src/Bundle/ChillMainBundle/Entity/Address.php | 1 + .../Templating/Listing/FilterOrderHelper.php | 3 +- .../AccompanyingCourseWorkController.php | 4 +- .../AccompanyingPeriodWorkRepository.php | 42 ++++++++++++------- 4 files changed, 32 insertions(+), 18 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Entity/Address.php b/src/Bundle/ChillMainBundle/Entity/Address.php index 1bd1a453a..9fcb07fe5 100644 --- a/src/Bundle/ChillMainBundle/Entity/Address.php +++ b/src/Bundle/ChillMainBundle/Entity/Address.php @@ -255,6 +255,7 @@ class Address implements TrackCreationInterface, TrackUpdateInterface public function syncWithReference(AddressReference $addressReference): Address { + dump($addressReference); $this ->setPoint($addressReference->getPoint()) ->setPostcode($addressReference->getPostcode()) diff --git a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php index 8554b4431..6a4d07167 100644 --- a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php +++ b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\MainBundle\Templating\Listing; +use Chill\MainBundle\Entity\User; use Chill\MainBundle\Form\Type\Listing\FilterOrderType; use DateTimeImmutable; use Symfony\Component\Form\Extension\Core\Type\FormType; @@ -134,7 +135,7 @@ class FilterOrderHelper return $this->userPickers; } - public function getUserPickerData(string $name): array + public function getUserPickerData(string $name) { return $this->getFormData()['user_pickers'][$name]; } diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php index c56489afd..3eb6e67f5 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php @@ -161,7 +161,7 @@ class AccompanyingCourseWorkController extends AbstractController 'types' => $filter->getEntityChoiceData('typesFilter'), 'before' => $filter->getDateRangeData('dateFilter')['to'], 'after' => $filter->getDateRangeData('dateFilter')['from'], - 'users' => $filter->getUserPickerData('userFilter') + 'user' => $filter->getUserPickerData('userFilter') ]; $totalItems = $this->workRepository->countByAccompanyingPeriod($period); @@ -226,7 +226,7 @@ class AccompanyingCourseWorkController extends AbstractController ->addEntityChoice('typesFilter', 'accompanying_course_work.types_filter', \Chill\PersonBundle\Entity\SocialWork\SocialAction::class, $types, [ 'choice_label' => fn (SocialAction $sa) => $this->translatableStringHelper->localize($sa->getTitle()) ]) - ->addUserPicker('userFilter', 'accompanying_course_work.user_filter', ['required' => false]) + ->addUserPicker('userFilter', 'accompanying_course_work.user_filter', ['required' => false, 'multiple' => false]) ; return $filterBuilder->build(); diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php index a5e27afd5..6fc8ff86e 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php @@ -103,40 +103,52 @@ final class AccompanyingPeriodWorkRepository implements ObjectRepository $rsm->addRootEntityFromClassMetadata(AccompanyingPeriodWork::class, 'w'); $sql = "SELECT {$rsm} FROM chill_person_accompanying_period_work w - WHERE accompanyingPeriod_id = :periodId - ORDER BY - CASE WHEN enddate IS NULL THEN '-infinity'::timestamp ELSE 'infinity'::timestamp END ASC, - startdate DESC, - enddate DESC, - id DESC"; + WHERE accompanyingPeriod_id = :periodId"; // implement filters if([] !== ($filters['types'] ?? [])) { - $sql .= "AND WHERE w.socialAction IN (:types)"; + $sql .= " AND w.socialaction_id IN (:types)"; } if([] !== ($filters['users'] ?? [])) { - $sql .= "AND WHERE w.createdBy IN (:users)"; + $sql .= " AND w.createdBy = (:userCreated)"; - foreach ($filters['users'] as $key => $user) { - $sql .= "OR :user_" . $key . " IN w.referrers)"; + $sql .= " OR :userReferrer IN (w.referrers)"; + } - $nq = $this->em->createNativeQuery($sql, $rsm) - ->setParameter(':user_' . $key); - } - - // ... to be continued + if (null !== ($after = $filters['after'] ?? null) && null === $filters['before']) { + $sql .= " AND w.startdate::date >= :after"; + } elseif (null !== ($before = $filters['before'] ?? null) && null === $filters['after']) { + $sql .= " AND COALESCE(w.enddate::date, 'infinity'::date) <= :before"; + } elseif (null !== ($after = $filters['after'] ?? null) && null !== ($before = $filters['before'] ?? null)) { + $sql .= " AND w.startdate::date >= :after AND COALESCE(w.enddate::date, 'now'::date) <= :before"; } // set limit and offset + $sql .= " ORDER BY + CASE WHEN enddate IS NULL THEN '-infinity'::timestamp ELSE 'infinity'::timestamp END ASC, + startdate DESC, + enddate DESC, + id DESC"; + $sql .= " LIMIT :limit OFFSET :offset"; + $typeIds = []; + foreach ($filters['types'] as $type) { + $typeIds[] = $type->getId(); + } + $nq = $this->em->createNativeQuery($sql, $rsm) ->setParameter('periodId', $period->getId(), Types::INTEGER) + ->setParameter('types', $typeIds) + ->setParameter('userCreated', $filters['user']) + ->setParameter('userReferrer', $filters['user']) + ->setParameter('after', $filters['after']) + ->setParameter('before', $filters['before']) ->setParameter('limit', $limit, Types::INTEGER) ->setParameter('offset', $offset, Types::INTEGER); From 29306d2b66bcd6a1e3882391ed22c863140bbbc6 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Wed, 24 May 2023 19:55:17 +0200 Subject: [PATCH 312/724] UX: [vue][onTheFly] improve residential address position in modale --- .../_components/Entity/AddressRenderBox.vue | 2 +- .../_components/Entity/PersonRenderBox.vue | 93 +++++++------------ 2 files changed, 33 insertions(+), 62 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/Entity/AddressRenderBox.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/Entity/AddressRenderBox.vue index 14a376856..00fb2b996 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/Entity/AddressRenderBox.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/Entity/AddressRenderBox.vue @@ -1,6 +1,6 @@