From 283de2cab8a3fa6b7370993d7f8cd848d8ebbe6f Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 8 Sep 2022 11:03:20 +0200 Subject: [PATCH 01/51] add actionRender in construct, it was missing --- .../Aggregator/SocialWorkAggregators/ActionTypeAggregator.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregator.php index b76db495d..fb64b3e01 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregator.php @@ -29,6 +29,7 @@ final class ActionTypeAggregator implements AggregatorInterface SocialActionRender $actionRender ) { $this->socialActionRepository = $socialActionRepository; + $this->actionRender = $actionRender; } public function addRole(): ?string From 2127fb2b54642d734b4a5a524791869d591ad3d4 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 8 Sep 2022 11:08:34 +0200 Subject: [PATCH 02/51] rename files for coherence with naming elsewhere --- .../Export/{CountAppointments.php => CountCalendars.php} | 3 +-- ...tAppointmentAvgDuration.php => StatCalendarAvgDuration.php} | 2 +- ...tAppointmentSumDuration.php => StatCalendarSumDuration.php} | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) rename src/Bundle/ChillCalendarBundle/Export/Export/{CountAppointments.php => CountCalendars.php} (95%) rename src/Bundle/ChillCalendarBundle/Export/Export/{StatAppointmentAvgDuration.php => StatCalendarAvgDuration.php} (96%) rename src/Bundle/ChillCalendarBundle/Export/Export/{StatAppointmentSumDuration.php => StatCalendarSumDuration.php} (96%) diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/CountAppointments.php b/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php similarity index 95% rename from src/Bundle/ChillCalendarBundle/Export/Export/CountAppointments.php rename to src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php index b9da17114..edf654a10 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/CountAppointments.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php @@ -22,9 +22,8 @@ use Doctrine\ORM\AbstractQuery; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Process\Exception\LogicException; -use Symfony\Component\Security\Core\Role\Role; -class CountAppointments implements ExportInterface, GroupedExportInterface +class CountCalendars implements ExportInterface, GroupedExportInterface { private CalendarRepository $calendarRepository; diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/StatAppointmentAvgDuration.php b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php similarity index 96% rename from src/Bundle/ChillCalendarBundle/Export/Export/StatAppointmentAvgDuration.php rename to src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php index 491cb38b9..51e94a288 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/StatAppointmentAvgDuration.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php @@ -22,7 +22,7 @@ use Doctrine\ORM\QueryBuilder; use LogicException; use Symfony\Component\Form\FormBuilderInterface; -class StatAppointmentAvgDuration implements ExportInterface, GroupedExportInterface +class StatCalendarAvgDuration implements ExportInterface, GroupedExportInterface { private CalendarRepository $calendarRepository; diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/StatAppointmentSumDuration.php b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php similarity index 96% rename from src/Bundle/ChillCalendarBundle/Export/Export/StatAppointmentSumDuration.php rename to src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php index 286c73be5..51591c670 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/StatAppointmentSumDuration.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php @@ -22,7 +22,7 @@ use Doctrine\ORM\QueryBuilder; use LogicException; use Symfony\Component\Form\FormBuilderInterface; -class StatAppointmentSumDuration implements ExportInterface, GroupedExportInterface +class StatCalendarSumDuration implements ExportInterface, GroupedExportInterface { private CalendarRepository $calendarRepository; From f00e01d44e8508f0eeeccb095e1e20c877983899 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 8 Sep 2022 11:08:34 +0200 Subject: [PATCH 03/51] rename files for coherence with naming elsewhere --- ...untAppointments.php => CountCalendars.php} | 3 +-- ...ration.php => StatCalendarAvgDuration.php} | 2 +- ...ration.php => StatCalendarSumDuration.php} | 2 +- .../Resources/config/services/exports.yaml | 20 +++++++++---------- 4 files changed, 13 insertions(+), 14 deletions(-) rename src/Bundle/ChillCalendarBundle/Export/Export/{CountAppointments.php => CountCalendars.php} (95%) rename src/Bundle/ChillCalendarBundle/Export/Export/{StatAppointmentAvgDuration.php => StatCalendarAvgDuration.php} (96%) rename src/Bundle/ChillCalendarBundle/Export/Export/{StatAppointmentSumDuration.php => StatCalendarSumDuration.php} (96%) diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/CountAppointments.php b/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php similarity index 95% rename from src/Bundle/ChillCalendarBundle/Export/Export/CountAppointments.php rename to src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php index b9da17114..edf654a10 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/CountAppointments.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php @@ -22,9 +22,8 @@ use Doctrine\ORM\AbstractQuery; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Process\Exception\LogicException; -use Symfony\Component\Security\Core\Role\Role; -class CountAppointments implements ExportInterface, GroupedExportInterface +class CountCalendars implements ExportInterface, GroupedExportInterface { private CalendarRepository $calendarRepository; diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/StatAppointmentAvgDuration.php b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php similarity index 96% rename from src/Bundle/ChillCalendarBundle/Export/Export/StatAppointmentAvgDuration.php rename to src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php index 491cb38b9..51e94a288 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/StatAppointmentAvgDuration.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php @@ -22,7 +22,7 @@ use Doctrine\ORM\QueryBuilder; use LogicException; use Symfony\Component\Form\FormBuilderInterface; -class StatAppointmentAvgDuration implements ExportInterface, GroupedExportInterface +class StatCalendarAvgDuration implements ExportInterface, GroupedExportInterface { private CalendarRepository $calendarRepository; diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/StatAppointmentSumDuration.php b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php similarity index 96% rename from src/Bundle/ChillCalendarBundle/Export/Export/StatAppointmentSumDuration.php rename to src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php index 286c73be5..51591c670 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/StatAppointmentSumDuration.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php @@ -22,7 +22,7 @@ use Doctrine\ORM\QueryBuilder; use LogicException; use Symfony\Component\Form\FormBuilderInterface; -class StatAppointmentSumDuration implements ExportInterface, GroupedExportInterface +class StatCalendarSumDuration implements ExportInterface, GroupedExportInterface { private CalendarRepository $calendarRepository; diff --git a/src/Bundle/ChillCalendarBundle/Resources/config/services/exports.yaml b/src/Bundle/ChillCalendarBundle/Resources/config/services/exports.yaml index 56580dba1..a7508f3b5 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/config/services/exports.yaml +++ b/src/Bundle/ChillCalendarBundle/Resources/config/services/exports.yaml @@ -1,26 +1,26 @@ services: ## Indicators - chill.calendar.export.count_appointments: - class: Chill\CalendarBundle\Export\Export\CountAppointments + chill.calendar.export.count_calendars: + class: Chill\CalendarBundle\Export\Export\CountCalendars autowire: true autoconfigure: true tags: - - { name: chill.export, alias: count_appointments } + - { name: chill.export, alias: count_calendars } - chill.calendar.export.average_duration_appointments: - class: Chill\CalendarBundle\Export\Export\StatAppointmentAvgDuration + chill.calendar.export.average_duration_calendars: + class: Chill\CalendarBundle\Export\Export\StatCalendarAvgDuration autowire: true autoconfigure: true tags: - - { name: chill.export, alias: average_duration_appointments } + - { name: chill.export, alias: average_duration_calendars } - chill.calendar.export.sum_duration_appointments: - class: Chill\CalendarBundle\Export\Export\StatAppointmentSumDuration + chill.calendar.export.sum_duration_calendars: + class: Chill\CalendarBundle\Export\Export\StatCalendarSumDuration autowire: true autoconfigure: true tags: - - { name: chill.export, alias: sum_duration_appointments } + - { name: chill.export, alias: sum_duration_calendars } ## Filters @@ -101,4 +101,4 @@ services: autowire: true autoconfigure: true tags: - - { name: chill.export_aggregator, alias: month_aggregator } \ No newline at end of file + - { name: chill.export_aggregator, alias: month_aggregator } From 3822f685749e97c9205db897591f6cc98b7189ae Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 8 Sep 2022 11:20:27 +0200 Subject: [PATCH 04/51] add querybuilder method to repository --- .../ChillCalendarBundle/Repository/CalendarRepository.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Bundle/ChillCalendarBundle/Repository/CalendarRepository.php b/src/Bundle/ChillCalendarBundle/Repository/CalendarRepository.php index ed4b7b22d..626a9f29f 100644 --- a/src/Bundle/ChillCalendarBundle/Repository/CalendarRepository.php +++ b/src/Bundle/ChillCalendarBundle/Repository/CalendarRepository.php @@ -40,6 +40,11 @@ class CalendarRepository implements ObjectRepository return $this->repository->count(['accompanyingPeriod' => $period]); } + public function createQueryBuilder(string $alias, ?string $indexBy = null): QueryBuilder + { + return $this->repository->createQueryBuilder($alias, $indexBy); + } + public function countByUser(User $user, DateTimeImmutable $from, DateTimeImmutable $to): int { return $this->buildQueryByUser($user, $from, $to) From d0d7c0babf9e6d9a7665a38ca4fdbd44e0bcd009 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 8 Sep 2022 11:25:50 +0200 Subject: [PATCH 05/51] adjust property name to make it work with changes calendar bundle --- .../ChillCalendarBundle/Export/Aggregator/AgentAggregator.php | 2 +- src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/AgentAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/AgentAggregator.php index 57ec33cdd..2974fb875 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/AgentAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/AgentAggregator.php @@ -41,7 +41,7 @@ final class AgentAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { if (!in_array('caluser', $qb->getAllAliases(), true)) { - $qb->join('cal.user', 'caluser'); + $qb->join('cal.mainUser', 'caluser'); } $qb->addSelect('caluser.id AS agent_aggregator'); diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php index 263b1e160..fe33c1210 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php @@ -37,7 +37,7 @@ class AgentFilter implements FilterInterface public function alterQuery(QueryBuilder $qb, $data) { $where = $qb->getDQLPart('where'); - $clause = $qb->expr()->in('cal.user', ':agents'); + $clause = $qb->expr()->in('cal.mainUser', ':agents'); if ($where instanceof Andx) { $where->add($clause); From 48548e020f352f8eca4ea5259d375c9518a5ecca Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 8 Sep 2022 11:25:50 +0200 Subject: [PATCH 06/51] adjust property name to make it work with changes calendar bundle --- .../ChillCalendarBundle/Export/Aggregator/AgentAggregator.php | 2 +- .../ChillCalendarBundle/Export/Aggregator/JobAggregator.php | 2 +- .../ChillCalendarBundle/Export/Aggregator/ScopeAggregator.php | 2 +- src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php | 2 +- src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php | 2 +- src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/AgentAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/AgentAggregator.php index 57ec33cdd..2974fb875 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/AgentAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/AgentAggregator.php @@ -41,7 +41,7 @@ final class AgentAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { if (!in_array('caluser', $qb->getAllAliases(), true)) { - $qb->join('cal.user', 'caluser'); + $qb->join('cal.mainUser', 'caluser'); } $qb->addSelect('caluser.id AS agent_aggregator'); diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/JobAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/JobAggregator.php index 17905cf35..46fc6e63d 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/JobAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/JobAggregator.php @@ -41,7 +41,7 @@ final class JobAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { if (!in_array('caluser', $qb->getAllAliases(), true)) { - $qb->join('cal.user', 'caluser'); + $qb->join('cal.mainUser', 'caluser'); } $qb->addSelect('IDENTITY(caluser.userJob) as job_aggregator'); diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/ScopeAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/ScopeAggregator.php index 7605c3d5d..351451ead 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/ScopeAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/ScopeAggregator.php @@ -41,7 +41,7 @@ final class ScopeAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { if (!in_array('caluser', $qb->getAllAliases(), true)) { - $qb->join('cal.user', 'caluser'); + $qb->join('cal.mainUser', 'caluser'); } $qb->addSelect('IDENTITY(caluser.mainScope) as scope_aggregator'); diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php index 263b1e160..fe33c1210 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php @@ -37,7 +37,7 @@ class AgentFilter implements FilterInterface public function alterQuery(QueryBuilder $qb, $data) { $where = $qb->getDQLPart('where'); - $clause = $qb->expr()->in('cal.user', ':agents'); + $clause = $qb->expr()->in('cal.mainUser', ':agents'); if ($where instanceof Andx) { $where->add($clause); diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php index 03cd4857d..9248143c7 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php @@ -43,7 +43,7 @@ class JobFilter implements FilterInterface public function alterQuery(QueryBuilder $qb, $data) { if (!in_array('caluser', $qb->getAllAliases(), true)) { - $qb->join('cal.user', 'caluser'); + $qb->join('cal.mainUser', 'caluser'); } $where = $qb->getDQLPart('where'); diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php index cbd566e9e..10e9e699c 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php @@ -43,7 +43,7 @@ class ScopeFilter implements FilterInterface public function alterQuery(QueryBuilder $qb, $data) { if (!in_array('caluser', $qb->getAllAliases(), true)) { - $qb->join('cal.user', 'caluser'); + $qb->join('cal.mainUser', 'caluser'); } $where = $qb->getDQLPart('where'); From 2e3f977f3d602c698da9a49a7349ed5fe05b404f Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 8 Sep 2022 11:59:44 +0200 Subject: [PATCH 07/51] adjust property name to make it work with changes calendar bundle --- .../Export/Aggregator/AgentAggregator.php | 2 +- .../Export/Aggregator/CancelReasonAggregator.php | 4 ++-- .../Export/Aggregator/JobAggregator.php | 2 +- .../Export/Aggregator/LocationAggregator.php | 2 +- .../Export/Aggregator/LocationTypeAggregator.php | 2 +- .../Export/Aggregator/MonthYearAggregator.php | 8 ++++---- .../Export/Aggregator/ScopeAggregator.php | 2 +- .../ChillCalendarBundle/Export/Export/CountCalendars.php | 7 ++++--- .../Export/Export/StatCalendarAvgDuration.php | 4 ++-- .../Export/Export/StatCalendarSumDuration.php | 4 ++-- .../ChillCalendarBundle/Export/Filter/AgentFilter.php | 2 +- .../Export/Filter/BetweenDatesFilter.php | 4 ++-- .../ChillCalendarBundle/Export/Filter/JobFilter.php | 2 +- .../ChillCalendarBundle/Export/Filter/ScopeFilter.php | 2 +- 14 files changed, 24 insertions(+), 23 deletions(-) diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/AgentAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/AgentAggregator.php index 2974fb875..3c2b54855 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/AgentAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/AgentAggregator.php @@ -85,6 +85,6 @@ final class AgentAggregator implements AggregatorInterface public function getTitle(): string { - return 'Group appointments by agent'; + return 'Group calendars by agent'; } } diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/CancelReasonAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/CancelReasonAggregator.php index a07f052bf..854710a79 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/CancelReasonAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/CancelReasonAggregator.php @@ -40,7 +40,7 @@ class CancelReasonAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - // TODO: still needs to take into account appointments without a cancel reason somehow + // TODO: still needs to take into account calendars without a cancel reason somehow if (!in_array('calcancel', $qb->getAllAliases(), true)) { $qb->join('cal.cancelReason', 'calcancel'); } @@ -88,6 +88,6 @@ class CancelReasonAggregator implements AggregatorInterface public function getTitle(): string { - return 'Group appointments by cancel reason'; + return 'Group calendars by cancel reason'; } } diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/JobAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/JobAggregator.php index 46fc6e63d..51500f45f 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/JobAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/JobAggregator.php @@ -87,6 +87,6 @@ final class JobAggregator implements AggregatorInterface public function getTitle(): string { - return 'Group appointments by agent job'; + return 'Group calendars by agent job'; } } diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationAggregator.php index 236b1b74f..287dccec7 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationAggregator.php @@ -80,6 +80,6 @@ final class LocationAggregator implements AggregatorInterface public function getTitle(): string { - return 'Group appointments by location'; + return 'Group calendars by location'; } } diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationTypeAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationTypeAggregator.php index c8d02160f..5d7559b2d 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationTypeAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationTypeAggregator.php @@ -87,6 +87,6 @@ final class LocationTypeAggregator implements AggregatorInterface public function getTitle(): string { - return 'Group appointments by location type'; + return 'Group calendars by location type'; } } diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/MonthYearAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/MonthYearAggregator.php index 26329ad13..b4f01db12 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/MonthYearAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/MonthYearAggregator.php @@ -55,10 +55,10 @@ class MonthYearAggregator implements AggregatorInterface return 'by month and year'; } - $month = substr($value, 0, 2); - $year = substr($value, 3, 4); + $month = (int)substr($value, 0, 2); + $year = (int)substr($value, 3, 4); - return strftime('%B %G', mktime(0, 0, 0, $month, '1', $year)); + return strftime('%B %G', mktime(0, 0, 0, $month, 1, $year)); }; } @@ -69,6 +69,6 @@ class MonthYearAggregator implements AggregatorInterface public function getTitle(): string { - return 'Group appointments by month and year'; + return 'Group calendars by month and year'; } } diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/ScopeAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/ScopeAggregator.php index 351451ead..8d3685f96 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/ScopeAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/ScopeAggregator.php @@ -87,6 +87,6 @@ final class ScopeAggregator implements AggregatorInterface public function getTitle(): string { - return 'Group appointments by agent scope'; + return 'Group calendars by agent scope'; } } diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php b/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php index edf654a10..9d78d0f26 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php @@ -21,7 +21,8 @@ use Closure; use Doctrine\ORM\AbstractQuery; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Process\Exception\LogicException; +use Symfony\Component\Validator\Exception\LogicException; + class CountCalendars implements ExportInterface, GroupedExportInterface { @@ -44,7 +45,7 @@ class CountCalendars implements ExportInterface, GroupedExportInterface public function getDescription(): string { - return 'Count appointments by various parameters.'; + return 'Count calendars by various parameters.'; } public function getGroup(): string @@ -78,7 +79,7 @@ class CountCalendars implements ExportInterface, GroupedExportInterface public function getTitle(): string { - return 'Count appointments'; + return 'Count calendars'; } public function getType(): string diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php index 51e94a288..4649ef571 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php @@ -44,7 +44,7 @@ class StatCalendarAvgDuration implements ExportInterface, GroupedExportInterface public function getDescription(): string { - return 'Get the average of appointment duration according to various filters'; + return 'Get the average of calendar duration according to various filters'; } public function getGroup(): string @@ -78,7 +78,7 @@ class StatCalendarAvgDuration implements ExportInterface, GroupedExportInterface public function getTitle(): string { - return 'Average appointment duration'; + return 'Average calendar duration'; } public function getType(): string diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php index 51591c670..4e2ed6a63 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php @@ -44,7 +44,7 @@ class StatCalendarSumDuration implements ExportInterface, GroupedExportInterface public function getDescription(): string { - return 'Get the sum of appointment durations according to various filters'; + return 'Get the sum of calendar durations according to various filters'; } public function getGroup(): string @@ -78,7 +78,7 @@ class StatCalendarSumDuration implements ExportInterface, GroupedExportInterface public function getTitle(): string { - return 'Sum of appointment durations'; + return 'Sum of calendar durations'; } public function getType(): string diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php index fe33c1210..a0b77ece9 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php @@ -82,6 +82,6 @@ class AgentFilter implements FilterInterface public function getTitle(): string { - return 'Filter appointments by agent'; + return 'Filter calendars by agent'; } } diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/BetweenDatesFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/BetweenDatesFilter.php index c3aafc192..23e3ac4e6 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/BetweenDatesFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/BetweenDatesFilter.php @@ -66,7 +66,7 @@ class BetweenDatesFilter implements FilterInterface public function describeAction($data, $format = 'string'): array { - return ['Filtered by appointments between %dateFrom% and %dateTo%', [ + return ['Filtered by calendars between %dateFrom% and %dateTo%', [ '%dateFrom%' => $data['date_from']->format('d-m-Y'), '%dateTo%' => $data['date_to']->format('d-m-Y'), ]]; @@ -74,6 +74,6 @@ class BetweenDatesFilter implements FilterInterface public function getTitle(): string { - return 'Filter appointments between certain dates'; + return 'Filter calendars between certain dates'; } } diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php index 9248143c7..d5a70b3da 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php @@ -95,6 +95,6 @@ class JobFilter implements FilterInterface public function getTitle(): string { - return 'Filter appointments by agent job'; + return 'Filter calendars by agent job'; } } diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php index 10e9e699c..9f12cbf19 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php @@ -95,6 +95,6 @@ class ScopeFilter implements FilterInterface public function getTitle() { - return 'Filter appointments by agent scope'; + return 'Filter calendars by agent scope'; } } From 25cc728f6df7c922d8ed902f9406367087261651 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 8 Sep 2022 12:30:22 +0200 Subject: [PATCH 08/51] adjust translations --- .../translations/messages.fr.yml | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml b/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml index b8b1e2e56..a10b7d43d 100644 --- a/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml @@ -72,8 +72,8 @@ invite: # exports Exports of calendar: Exports des rendez-vous -Count appointments: Nombre de rendez-vous -Count appointments by various parameters.: Compte le nombre de rendez-vous en fonction de différents paramètres. +Count calendars: Nombre de rendez-vous +Count calendars by various parameters.: Compte le nombre de rendez-vous en fonction de différents paramètres. Average appointment duration: Moyenne de la durée des rendez-vous Get the average of appointment duration according to various filters: Calcule la moyenne des durées des rendez-vous en fonction de différents paramètres. @@ -82,21 +82,21 @@ Sum of appointment durations: Somme de la durée des rendez-vous Get the sum of appointment durations according to various filters: Calcule la somme des durées des rendez-vous en fonction de différents paramètres. 'Filtered by agent: only %agents%': "Filtré par agents: uniquement %agents%" -Filter appointments by agent: Filtrer les rendez-vous par agents -Filter appointments by agent job: Filtrer les rendez-vous par métiers des agents +Filter calendars by agent: Filtrer les rendez-vous par agents +Filter calendars by agent job: Filtrer les rendez-vous par métiers des agents 'Filtered by agent job: only %jobs%': 'Filtré par métiers des agents: uniquement les %jobs%' -Filter appointments by agent scope: Filtrer les rendez-vous par services des agents +Filter calendars by agent scope: Filtrer les rendez-vous par services des agents 'Filtered by agent scope: only %scopes%': 'Filtré par services des agents: uniquement les services %scopes%' -Filter appointments between certain dates: Filtrer les rendez-vous par date du rendez-vous -'Filtered by appointments between %dateFrom% and %dateTo%': 'Filtré par rendez-vous entre %dateFrom% et %dateTo%' +Filter calendars between certain dates: Filtrer les rendez-vous par date du rendez-vous +'Filtered by calendars between %dateFrom% and %dateTo%': 'Filtré par rendez-vous entre %dateFrom% et %dateTo%' -Group appointments by agent: Grouper les rendez-vous par agent -Group appointments by agent job: Grouper les rendez-vous par métier de l'agent -Group appointments by agent scope: Grouper les rendez-vous par service de l'agent -Group appointments by location type: Grouper les rendez-vous par type de localisation -Group appointments by location: Grouper les rendez-vous par lieu de rendez-vous -Group appointments by cancel reason: Grouper les rendez-vous par motif d'annulation -Group appointments by month and year: Grouper les rendez-vous par mois et année +Group calendars by agent: Grouper les rendez-vous par agent +Group calendars by agent job: Grouper les rendez-vous par métier de l'agent +Group calendars by agent scope: Grouper les rendez-vous par service de l'agent +Group calendars by location type: Grouper les rendez-vous par type de localisation +Group calendars by location: Grouper les rendez-vous par lieu de rendez-vous +Group calendars by cancel reason: Grouper les rendez-vous par motif d'annulation +Group calendars by month and year: Grouper les rendez-vous par mois et année Scope: Service Job: Métier Location type: Type de localisation From 318009c9c8af898f0b6c042d03921e4fa3e5fa7b Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Wed, 21 Sep 2022 11:02:09 +0200 Subject: [PATCH 09/51] exports: add new tests for calendar filters (untested) --- .../Tests/Export/Filter/AgentFilterTest.php | 81 ++++++++++++++++++ .../Export/Filter/BetweenDatesFilterTest.php | 69 ++++++++++++++++ .../Tests/Export/Filter/JobFilterTest.php | 82 +++++++++++++++++++ .../Tests/Export/Filter/ScopeFilterTest.php | 82 +++++++++++++++++++ 4 files changed, 314 insertions(+) create mode 100644 src/Bundle/ChillCalendarBundle/Tests/Export/Filter/AgentFilterTest.php create mode 100644 src/Bundle/ChillCalendarBundle/Tests/Export/Filter/BetweenDatesFilterTest.php create mode 100644 src/Bundle/ChillCalendarBundle/Tests/Export/Filter/JobFilterTest.php create mode 100644 src/Bundle/ChillCalendarBundle/Tests/Export/Filter/ScopeFilterTest.php diff --git a/src/Bundle/ChillCalendarBundle/Tests/Export/Filter/AgentFilterTest.php b/src/Bundle/ChillCalendarBundle/Tests/Export/Filter/AgentFilterTest.php new file mode 100644 index 000000000..de7d76601 --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/Tests/Export/Filter/AgentFilterTest.php @@ -0,0 +1,81 @@ +prophesize(); + + $request->willExtend(\Symfony\Component\HttpFoundation\Request::class); + $request->getLocale()->willReturn('fr'); + + $this->filter = self::$container->get('chill.calendar.export.agent_filter'); + } + + public function getFilter() + { + return $this->filter; + } + + public function getFormData(): array + { + $em = self::$container->get(EntityManagerInterface::class); + + $array = $em->createQueryBuilder() + ->from(User::class, 'u') + ->select('u') + ->getQuery() + ->getResult(); + + $data = []; + + foreach ($array as $a) { + $data[] = [ + 'accepted_agents' => $a + ]; + } + + return $data; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('cal.id') + ->from(Calendar::class, 'cal'), + ]; + } +} diff --git a/src/Bundle/ChillCalendarBundle/Tests/Export/Filter/BetweenDatesFilterTest.php b/src/Bundle/ChillCalendarBundle/Tests/Export/Filter/BetweenDatesFilterTest.php new file mode 100644 index 000000000..f51aa4474 --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/Tests/Export/Filter/BetweenDatesFilterTest.php @@ -0,0 +1,69 @@ +prophesize(); + + $request->willExtend(\Symfony\Component\HttpFoundation\Request::class); + $request->getLocale()->willReturn('fr'); + + $this->filter = self::$container->get('chill.calendar.export.between_dates_filter'); + } + + public function getFilter() + { + return $this->filter; + } + + public function getFormData(): array + { + return [ + [ + 'date_from' => \DateTime::createFromFormat('Y-m-d', '2022-05-01'), + 'date_to' => \DateTime::createFromFormat('Y-m-d', '2022-06-01'), + ] + ]; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('cal.id') + ->from(Calendar::class, 'cal'), + ]; + } +} diff --git a/src/Bundle/ChillCalendarBundle/Tests/Export/Filter/JobFilterTest.php b/src/Bundle/ChillCalendarBundle/Tests/Export/Filter/JobFilterTest.php new file mode 100644 index 000000000..b036f55fa --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/Tests/Export/Filter/JobFilterTest.php @@ -0,0 +1,82 @@ +prophesize(); + + $request->willExtend(\Symfony\Component\HttpFoundation\Request::class); + $request->getLocale()->willReturn('fr'); + + $this->filter = self::$container->get('chill.calendar.export.job_filter'); + } + + public function getFilter() + { + return $this->filter; + } + + public function getFormData(): array + { + $em = self::$container->get(EntityManagerInterface::class); + + $array = $em->createQueryBuilder() + ->from(UserJob::class, 'uj') + ->select('uj') + ->getQuery() + ->getResult(); + + $data = []; + + foreach ($array as $a) { + $data[] = [ + 'job' => $a + ]; + } + + return $data; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('cal.id') + ->from(Calendar::class, 'cal') + ->join('cal.user', 'caluser'), + ]; + } +} diff --git a/src/Bundle/ChillCalendarBundle/Tests/Export/Filter/ScopeFilterTest.php b/src/Bundle/ChillCalendarBundle/Tests/Export/Filter/ScopeFilterTest.php new file mode 100644 index 000000000..e249c194f --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/Tests/Export/Filter/ScopeFilterTest.php @@ -0,0 +1,82 @@ +prophesize(); + + $request->willExtend(\Symfony\Component\HttpFoundation\Request::class); + $request->getLocale()->willReturn('fr'); + + $this->filter = self::$container->get('chill.calendar.export.scope_filter'); + } + + public function getFilter() + { + return $this->filter; + } + + public function getFormData(): array + { + $em = self::$container->get(EntityManagerInterface::class); + + $array = $em->createQueryBuilder() + ->from(Scope::class, 's') + ->select('s') + ->getQuery() + ->getResult(); + + $data = []; + + foreach ($array as $a) { + $data[] = [ + 'scope' => $a + ]; + } + + return $data; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('cal.id') + ->from(Calendar::class, 'cal') + ->join('cal.user', 'caluser'), + ]; + } +} From e90ff67e33af4de4df3f9ae06154d5afc4996e45 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 21 Sep 2022 12:20:39 +0200 Subject: [PATCH 10/51] add urgent property to calendar entity --- .../ChillCalendarBundle/Entity/Calendar.php | 5 +++ .../migrations/Version20220921101643.php | 33 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 src/Bundle/ChillCalendarBundle/migrations/Version20220921101643.php diff --git a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php index 018f073bd..cb0d20fca 100644 --- a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php +++ b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php @@ -203,6 +203,11 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface */ private string $status = self::STATUS_VALID; + /** + * @ORM\Column(type="boolean", nullable=true) + */ + private ?bool $urgent = false; + public function __construct() { $this->comment = new CommentEmbeddable(); diff --git a/src/Bundle/ChillCalendarBundle/migrations/Version20220921101643.php b/src/Bundle/ChillCalendarBundle/migrations/Version20220921101643.php new file mode 100644 index 000000000..270c57da4 --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/migrations/Version20220921101643.php @@ -0,0 +1,33 @@ +addSql('ALTER TABLE chill_calendar.calendar ADD urgent BOOLEAN DEFAULT NULL'); + + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('ALTER TABLE chill_calendar.calendar DROP urgent'); + + } +} From 6405f2101f3992366335666ad54987693e88cbca Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Wed, 21 Sep 2022 12:45:31 +0200 Subject: [PATCH 11/51] exports: add new tests for calendar aggregators (untested) --- .../Export/Aggregator/AgentAggregatorTest.php | 58 +++++++++++++++++++ .../Aggregator/CancelReasonAggregatorTest.php | 58 +++++++++++++++++++ .../Export/Aggregator/JobAggregatorTest.php | 58 +++++++++++++++++++ .../Aggregator/LocationAggregatorTest.php | 58 +++++++++++++++++++ .../Aggregator/LocationTypeAggregatorTest.php | 58 +++++++++++++++++++ .../Aggregator/MonthYearAggregatorTest.php | 57 ++++++++++++++++++ .../Export/Aggregator/ScopeAggregatorTest.php | 58 +++++++++++++++++++ 7 files changed, 405 insertions(+) create mode 100644 src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/AgentAggregatorTest.php create mode 100644 src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/CancelReasonAggregatorTest.php create mode 100644 src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/JobAggregatorTest.php create mode 100644 src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/LocationAggregatorTest.php create mode 100644 src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/LocationTypeAggregatorTest.php create mode 100644 src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/MonthYearAggregatorTest.php create mode 100644 src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/ScopeAggregatorTest.php diff --git a/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/AgentAggregatorTest.php b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/AgentAggregatorTest.php new file mode 100644 index 000000000..6e50eebc4 --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/AgentAggregatorTest.php @@ -0,0 +1,58 @@ +aggregator = self::$container->get('chill.calendar.export.agent_aggregator'); + } + + public function getAggregator() + { + return $this->aggregator; + } + + public function getFormData(): array + { + return [ + [], + ]; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(cal.id)') + ->from(Calendar::class, 'cal') + ->join('cal.mainUser', 'caluser') + , + ]; + } +} diff --git a/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/CancelReasonAggregatorTest.php b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/CancelReasonAggregatorTest.php new file mode 100644 index 000000000..3d871d542 --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/CancelReasonAggregatorTest.php @@ -0,0 +1,58 @@ +aggregator = self::$container->get('chill.calendar.export.cancel_reason_aggregator'); + } + + public function getAggregator() + { + return $this->aggregator; + } + + public function getFormData(): array + { + return [ + [], + ]; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(cal.id)') + ->from(Calendar::class, 'cal') + ->join('cal.cancelReason', 'calcancel') + , + ]; + } +} diff --git a/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/JobAggregatorTest.php b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/JobAggregatorTest.php new file mode 100644 index 000000000..278bf2254 --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/JobAggregatorTest.php @@ -0,0 +1,58 @@ +aggregator = self::$container->get('chill.calendar.export.job_aggregator'); + } + + public function getAggregator() + { + return $this->aggregator; + } + + public function getFormData(): array + { + return [ + [], + ]; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(cal.id)') + ->from(Calendar::class, 'cal') + ->join('cal.user', 'caluser') + , + ]; + } +} diff --git a/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/LocationAggregatorTest.php b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/LocationAggregatorTest.php new file mode 100644 index 000000000..49d7530cf --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/LocationAggregatorTest.php @@ -0,0 +1,58 @@ +aggregator = self::$container->get('chill.calendar.export.location_aggregator'); + } + + public function getAggregator() + { + return $this->aggregator; + } + + public function getFormData(): array + { + return [ + [], + ]; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(cal.id)') + ->from(Calendar::class, 'cal') + ->join('cal.location', 'calloc') + , + ]; + } +} diff --git a/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/LocationTypeAggregatorTest.php b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/LocationTypeAggregatorTest.php new file mode 100644 index 000000000..c06d2f036 --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/LocationTypeAggregatorTest.php @@ -0,0 +1,58 @@ +aggregator = self::$container->get('chill.calendar.export.location_type_aggregator'); + } + + public function getAggregator() + { + return $this->aggregator; + } + + public function getFormData(): array + { + return [ + [], + ]; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(cal.id)') + ->from(Calendar::class, 'cal') + ->join('cal.location', 'calloc') + , + ]; + } +} diff --git a/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/MonthYearAggregatorTest.php b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/MonthYearAggregatorTest.php new file mode 100644 index 000000000..885344148 --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/MonthYearAggregatorTest.php @@ -0,0 +1,57 @@ +aggregator = self::$container->get('chill.calendar.export.month_aggregator'); + } + + public function getAggregator() + { + return $this->aggregator; + } + + public function getFormData(): array + { + return [ + [], + ]; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(cal.id)') + ->from(Calendar::class, 'cal') + , + ]; + } +} diff --git a/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/ScopeAggregatorTest.php b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/ScopeAggregatorTest.php new file mode 100644 index 000000000..b95fd6f86 --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/ScopeAggregatorTest.php @@ -0,0 +1,58 @@ +aggregator = self::$container->get('chill.calendar.export.scope_aggregator'); + } + + public function getAggregator() + { + return $this->aggregator; + } + + public function getFormData(): array + { + return [ + [], + ]; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(cal.id)') + ->from(Calendar::class, 'cal') + ->join('cal.user', 'caluser') + , + ]; + } +} From 9da410afb8349c299f10225e9b5328af8fa48d1e Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 21 Sep 2022 13:31:24 +0200 Subject: [PATCH 12/51] urgency and calendarrange exports --- .../Export/Aggregator/UrgencyAggregator.php | 91 +++++++++++++++ .../Export/Filter/CalendarRangeFilter.php | 104 ++++++++++++++++++ .../Resources/config/services/exports.yaml | 14 +++ .../translations/messages.fr.yml | 10 ++ 4 files changed, 219 insertions(+) create mode 100644 src/Bundle/ChillCalendarBundle/Export/Aggregator/UrgencyAggregator.php create mode 100644 src/Bundle/ChillCalendarBundle/Export/Filter/CalendarRangeFilter.php diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/UrgencyAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/UrgencyAggregator.php new file mode 100644 index 000000000..ad19ee7e1 --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/UrgencyAggregator.php @@ -0,0 +1,91 @@ +translator = $translator; + } + + public function addRole(): ?string + { + return null; + } + + public function alterQuery(QueryBuilder $qb, $data) + { + $qb->addSelect('cal.urgent AS urgency_aggregator'); + + $groupBy = $qb->getDQLPart('groupBy'); + + if (!empty($groupBy)) { + $qb->addGroupBy('urgency_aggregator'); + } else { + $qb->groupBy('urgency_aggregator'); + } + } + + public function applyOn(): string + { + return Declarations::CALENDAR_TYPE; + } + + public function buildForm(FormBuilderInterface $builder) + { + // no form + } + + public function getLabels($key, array $values, $data): Closure + { + return function ($value): string { + if ('_header' === $value) { + 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)); + } + }; + } + + public function getQueryKeys($data): array + { + return ['urgency_aggregator']; + } + + public function getTitle(): string + { + return 'Group calendars by urgency'; + } +} + diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/CalendarRangeFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/CalendarRangeFilter.php new file mode 100644 index 000000000..9900d58de --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/CalendarRangeFilter.php @@ -0,0 +1,104 @@ + true, + 'Made within a calendar range' => false + ]; + + private const DEFAULT_CHOICE = false; + + private TranslatorInterface $translator; + + public function __construct(TranslatorInterface $translator) + { + $this->translator = $translator; + } + + public function addRole(): ?string + { + return null; + } + + public function alterQuery(QueryBuilder $qb, $data) + { + $where = $qb->getDQLPart('where'); + + dump($data); + + if ($data['hasCalendarRange']) { + $clause = $qb->expr()->isNotNull('cal.calendarRange'); + } else { + $clause = $qb->expr()->isNull('cal.calendarRange'); + } + + + if ($where instanceof Andx) { + $where->add($clause); + } else { + $where = $qb->expr()->andX($clause); + } + + $qb->add('where', $where); + } + + public function applyOn(): string + { + return Declarations::CALENDAR_TYPE; + } + + public function buildForm(FormBuilderInterface $builder) + { + $builder->add('hasCalendarRange', ChoiceType::class, [ + 'choices' => self::CHOICES, + 'label' => 'has calendar range', + 'multiple' => false, + 'expanded' => true, + 'empty_data' => self::DEFAULT_CHOICE, + 'data' => self::DEFAULT_CHOICE, + ]); + } + + public function describeAction($data, $format = 'string'): array + { + foreach (self::CHOICES as $k => $v) { + if ($v === $data['hasCalendarRange']) { + $choice = $k; + } else { + $choice = 'Not made within a calendar range'; + } + } + + return [ + 'Filtered by calendar range: only %calendarRange%', [ + '%calendarRange%' => $this->translator->trans($choice), + ], + ]; + } + + public function getTitle(): string + { + return 'Filter by calendar range'; + } +} + diff --git a/src/Bundle/ChillCalendarBundle/Resources/config/services/exports.yaml b/src/Bundle/ChillCalendarBundle/Resources/config/services/exports.yaml index a7508f3b5..3eb4bbfdc 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/config/services/exports.yaml +++ b/src/Bundle/ChillCalendarBundle/Resources/config/services/exports.yaml @@ -52,6 +52,13 @@ services: tags: - { name: chill.export_filter, alias: between_dates_filter } + chill.calendar.export.calendar_range_filter: + class: Chill\CalendarBundle\Export\Filter\CalendarRangeFilter + autowire: true + autoconfigure: true + tags: + - { name: chill.export_filter, alias: calendar_range_filter } + ## Aggregator chill.calendar.export.agent_aggregator: @@ -102,3 +109,10 @@ services: autoconfigure: true tags: - { name: chill.export_aggregator, alias: month_aggregator } + + chill.calendar.export.urgency_aggregator: + class: Chill\CalendarBundle\Export\Aggregator\UrgencyAggregator + autowire: true + autoconfigure: true + tags: + - { name: chill.export_aggregator, alias: urgency_aggregator } diff --git a/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml b/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml index a10b7d43d..a03dd4015 100644 --- a/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml @@ -89,6 +89,8 @@ Filter calendars by agent scope: Filtrer les rendez-vous par services des agents 'Filtered by agent scope: only %scopes%': 'Filtré par services des agents: uniquement les services %scopes%' Filter calendars between certain dates: Filtrer les rendez-vous par date du rendez-vous 'Filtered by calendars between %dateFrom% and %dateTo%': 'Filtré par rendez-vous entre %dateFrom% et %dateTo%' +'Filtered by calendar range: only %calendarRange%': 'Filtré par rendez-vous par plage de disponibilité: uniquement les %calendarRange%' +Filter by calendar range: Filtrer par rendez-vous dans une plage de disponibilité ou non Group calendars by agent: Grouper les rendez-vous par agent Group calendars by agent job: Grouper les rendez-vous par métier de l'agent @@ -97,8 +99,16 @@ Group calendars by location type: Grouper les rendez-vous par type de localisati Group calendars by location: Grouper les rendez-vous par lieu de rendez-vous Group calendars by cancel reason: Grouper les rendez-vous par motif d'annulation Group calendars by month and year: Grouper les rendez-vous par mois et année +Group calendars by urgency: Grouper les rendez-vous par urgent ou non + Scope: Service Job: Métier Location type: Type de localisation Location: Lieu de rendez-vous by month and year: Par mois et année +is urgent: Urgent +is not urgent: Pas urgent +has calendar range: Dans une plage de disponibilité? +Not made within a calendar range: Rendez-vous dans une plage de disponibilité +Made within a calendar range: Rendez-vous en dehors d'une plage de disponibilité + From 642b1e43c85d32454f125b3d9a888acf77997d28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 5 Oct 2022 15:30:55 +0200 Subject: [PATCH 13/51] fix cs --- .../Controller/ActivityController.php | 2 -- .../ChillCalendarBundle/Entity/Calendar.php | 24 +++++++++---------- .../Entity/CalendarRange.php | 2 +- .../Export/Aggregator/MonthYearAggregator.php | 4 ++-- .../Export/Aggregator/UrgencyAggregator.php | 2 -- .../Export/Export/CountCalendars.php | 1 - .../Export/Filter/CalendarRangeFilter.php | 6 ++--- .../Connector/MSGraph/MapCalendarToUser.php | 2 +- .../Repository/CalendarRepository.php | 10 ++++---- .../Export/Aggregator/AgentAggregatorTest.php | 7 ++++-- .../Aggregator/CancelReasonAggregatorTest.php | 7 ++++-- .../Export/Aggregator/JobAggregatorTest.php | 7 ++++-- .../Aggregator/LocationAggregatorTest.php | 7 ++++-- .../Aggregator/LocationTypeAggregatorTest.php | 7 ++++-- .../Aggregator/MonthYearAggregatorTest.php | 7 ++++-- .../Export/Aggregator/ScopeAggregatorTest.php | 7 ++++-- .../Tests/Export/Filter/AgentFilterTest.php | 2 +- .../Export/Filter/BetweenDatesFilterTest.php | 7 +++--- .../Tests/Export/Filter/JobFilterTest.php | 2 +- .../Tests/Export/Filter/ScopeFilterTest.php | 2 +- .../migrations/Version20220921101643.php | 21 +++++++++------- .../PersonFilters/DeadOrAliveFilter.php | 2 +- 22 files changed, 79 insertions(+), 59 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php index b81d3937c..9a391d14d 100644 --- a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php +++ b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php @@ -90,7 +90,6 @@ final class ActivityController extends AbstractController SerializerInterface $serializer, UserRepositoryInterface $userRepository, CenterResolverManagerInterface $centerResolver - ) { $this->activityACLAwareRepository = $activityACLAwareRepository; $this->activityTypeRepository = $activityTypeRepository; @@ -106,7 +105,6 @@ final class ActivityController extends AbstractController $this->serializer = $serializer; $this->userRepository = $userRepository; $this->centerResolver = $centerResolver; - } /** diff --git a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php index 402b2b5a2..e519997d0 100644 --- a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php +++ b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php @@ -409,16 +409,16 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface return $this->status; } - public function getUrgent(): ?bool - { - return $this->urgent; - } - public function getThirdParties(): Collection { return $this->getProfessionals(); } + public function getUrgent(): ?bool + { + return $this->urgent; + } + /** * @return Collection|User[] * @Serializer\Groups({"calendar:read", "read"}) @@ -599,13 +599,6 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface return $this; } - public function setUrgent(bool $urgent): self - { - $this->urgent = $urgent; - - return $this; - } - public function setStartDate(DateTimeImmutable $startDate): self { $this->startDate = $startDate; @@ -623,4 +616,11 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface return $this; } + + public function setUrgent(bool $urgent): self + { + $this->urgent = $urgent; + + return $this; + } } diff --git a/src/Bundle/ChillCalendarBundle/Entity/CalendarRange.php b/src/Bundle/ChillCalendarBundle/Entity/CalendarRange.php index 013b465d5..beeb055e1 100644 --- a/src/Bundle/ChillCalendarBundle/Entity/CalendarRange.php +++ b/src/Bundle/ChillCalendarBundle/Entity/CalendarRange.php @@ -127,7 +127,7 @@ class CalendarRange implements TrackCreationInterface, TrackUpdateInterface public function setLocation(?Location $location): self { $this->location = $location; - + return $this; } diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/MonthYearAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/MonthYearAggregator.php index 1f494fe96..f5c0f5f17 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/MonthYearAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/MonthYearAggregator.php @@ -54,8 +54,8 @@ class MonthYearAggregator implements AggregatorInterface return 'by month and year'; } - $month = (int)substr($value, 0, 2); - $year = (int)substr($value, 3, 4); + $month = (int) substr($value, 0, 2); + $year = (int) substr($value, 3, 4); return strftime('%B %G', mktime(0, 0, 0, $month, 1, $year)); }; diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/UrgencyAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/UrgencyAggregator.php index ad19ee7e1..94204cc9a 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/UrgencyAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/UrgencyAggregator.php @@ -21,7 +21,6 @@ use Symfony\Contracts\Translation\TranslatorInterface; class UrgencyAggregator implements AggregatorInterface { - private TranslatorInterface $translator; public function __construct( @@ -88,4 +87,3 @@ class UrgencyAggregator implements AggregatorInterface return 'Group calendars by urgency'; } } - diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php b/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php index 9d78d0f26..4d246cafa 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php @@ -23,7 +23,6 @@ use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Validator\Exception\LogicException; - class CountCalendars implements ExportInterface, GroupedExportInterface { private CalendarRepository $calendarRepository; diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/CalendarRangeFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/CalendarRangeFilter.php index 9900d58de..3189d6df6 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/CalendarRangeFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/CalendarRangeFilter.php @@ -11,8 +11,8 @@ declare(strict_types=1); namespace Chill\CalendarBundle\Export\Filter; -use Chill\MainBundle\Export\FilterInterface; use Chill\CalendarBundle\Export\Declarations; +use Chill\MainBundle\Export\FilterInterface; use Doctrine\ORM\Query\Expr\Andx; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; @@ -23,7 +23,7 @@ class CalendarRangeFilter implements FilterInterface { private const CHOICES = [ 'Not made within a calendar range' => true, - 'Made within a calendar range' => false + 'Made within a calendar range' => false, ]; private const DEFAULT_CHOICE = false; @@ -52,7 +52,6 @@ class CalendarRangeFilter implements FilterInterface $clause = $qb->expr()->isNull('cal.calendarRange'); } - if ($where instanceof Andx) { $where->add($clause); } else { @@ -101,4 +100,3 @@ class CalendarRangeFilter implements FilterInterface return 'Filter by calendar range'; } } - diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MapCalendarToUser.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MapCalendarToUser.php index 7e7d55739..402da0b73 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MapCalendarToUser.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MapCalendarToUser.php @@ -143,7 +143,7 @@ class MapCalendarToUser public function writeMetadata(User $user): User { - if (null === $user->getEmail() OR '' === $user->getEmail()) { + if (null === $user->getEmail() || '' === $user->getEmail()) { return $user; } diff --git a/src/Bundle/ChillCalendarBundle/Repository/CalendarRepository.php b/src/Bundle/ChillCalendarBundle/Repository/CalendarRepository.php index 626a9f29f..28b2b72b9 100644 --- a/src/Bundle/ChillCalendarBundle/Repository/CalendarRepository.php +++ b/src/Bundle/ChillCalendarBundle/Repository/CalendarRepository.php @@ -40,11 +40,6 @@ class CalendarRepository implements ObjectRepository return $this->repository->count(['accompanyingPeriod' => $period]); } - public function createQueryBuilder(string $alias, ?string $indexBy = null): QueryBuilder - { - return $this->repository->createQueryBuilder($alias, $indexBy); - } - public function countByUser(User $user, DateTimeImmutable $from, DateTimeImmutable $to): int { return $this->buildQueryByUser($user, $from, $to) @@ -53,6 +48,11 @@ class CalendarRepository implements ObjectRepository ->getSingleScalarResult(); } + public function createQueryBuilder(string $alias, ?string $indexBy = null): QueryBuilder + { + return $this->repository->createQueryBuilder($alias, $indexBy); + } + public function find($id): ?Calendar { return $this->repository->find($id); diff --git a/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/AgentAggregatorTest.php b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/AgentAggregatorTest.php index 6e50eebc4..99f34358e 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/AgentAggregatorTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/AgentAggregatorTest.php @@ -16,6 +16,10 @@ use Chill\CalendarBundle\Export\Aggregator\AgentAggregator; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; use Doctrine\ORM\EntityManagerInterface; +/** + * @internal + * @coversNothing + */ final class AgentAggregatorTest extends AbstractAggregatorTest { private AgentAggregator $aggregator; @@ -51,8 +55,7 @@ final class AgentAggregatorTest extends AbstractAggregatorTest $em->createQueryBuilder() ->select('count(cal.id)') ->from(Calendar::class, 'cal') - ->join('cal.mainUser', 'caluser') - , + ->join('cal.mainUser', 'caluser'), ]; } } diff --git a/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/CancelReasonAggregatorTest.php b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/CancelReasonAggregatorTest.php index 3d871d542..b78ff4307 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/CancelReasonAggregatorTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/CancelReasonAggregatorTest.php @@ -16,6 +16,10 @@ use Chill\CalendarBundle\Export\Aggregator\CancelReasonAggregator; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; use Doctrine\ORM\EntityManagerInterface; +/** + * @internal + * @coversNothing + */ final class CancelReasonAggregatorTest extends AbstractAggregatorTest { private CancelReasonAggregator $aggregator; @@ -51,8 +55,7 @@ final class CancelReasonAggregatorTest extends AbstractAggregatorTest $em->createQueryBuilder() ->select('count(cal.id)') ->from(Calendar::class, 'cal') - ->join('cal.cancelReason', 'calcancel') - , + ->join('cal.cancelReason', 'calcancel'), ]; } } diff --git a/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/JobAggregatorTest.php b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/JobAggregatorTest.php index 278bf2254..7ee333486 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/JobAggregatorTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/JobAggregatorTest.php @@ -16,6 +16,10 @@ use Chill\CalendarBundle\Export\Aggregator\JobAggregator; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; use Doctrine\ORM\EntityManagerInterface; +/** + * @internal + * @coversNothing + */ final class JobAggregatorTest extends AbstractAggregatorTest { private JobAggregator $aggregator; @@ -51,8 +55,7 @@ final class JobAggregatorTest extends AbstractAggregatorTest $em->createQueryBuilder() ->select('count(cal.id)') ->from(Calendar::class, 'cal') - ->join('cal.user', 'caluser') - , + ->join('cal.user', 'caluser'), ]; } } diff --git a/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/LocationAggregatorTest.php b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/LocationAggregatorTest.php index 49d7530cf..b11b5304b 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/LocationAggregatorTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/LocationAggregatorTest.php @@ -16,6 +16,10 @@ use Chill\CalendarBundle\Export\Aggregator\LocationAggregator; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; use Doctrine\ORM\EntityManagerInterface; +/** + * @internal + * @coversNothing + */ final class LocationAggregatorTest extends AbstractAggregatorTest { private LocationAggregator $aggregator; @@ -51,8 +55,7 @@ final class LocationAggregatorTest extends AbstractAggregatorTest $em->createQueryBuilder() ->select('count(cal.id)') ->from(Calendar::class, 'cal') - ->join('cal.location', 'calloc') - , + ->join('cal.location', 'calloc'), ]; } } diff --git a/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/LocationTypeAggregatorTest.php b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/LocationTypeAggregatorTest.php index c06d2f036..ee2ae8ca5 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/LocationTypeAggregatorTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/LocationTypeAggregatorTest.php @@ -16,6 +16,10 @@ use Chill\CalendarBundle\Export\Aggregator\LocationTypeAggregator; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; use Doctrine\ORM\EntityManagerInterface; +/** + * @internal + * @coversNothing + */ final class LocationTypeAggregatorTest extends AbstractAggregatorTest { private LocationTypeAggregator $aggregator; @@ -51,8 +55,7 @@ final class LocationTypeAggregatorTest extends AbstractAggregatorTest $em->createQueryBuilder() ->select('count(cal.id)') ->from(Calendar::class, 'cal') - ->join('cal.location', 'calloc') - , + ->join('cal.location', 'calloc'), ]; } } diff --git a/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/MonthYearAggregatorTest.php b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/MonthYearAggregatorTest.php index 885344148..830e569a1 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/MonthYearAggregatorTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/MonthYearAggregatorTest.php @@ -16,6 +16,10 @@ use Chill\CalendarBundle\Export\Aggregator\MonthYearAggregator; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; use Doctrine\ORM\EntityManagerInterface; +/** + * @internal + * @coversNothing + */ final class MonthYearAggregatorTest extends AbstractAggregatorTest { private MonthYearAggregator $aggregator; @@ -50,8 +54,7 @@ final class MonthYearAggregatorTest extends AbstractAggregatorTest return [ $em->createQueryBuilder() ->select('count(cal.id)') - ->from(Calendar::class, 'cal') - , + ->from(Calendar::class, 'cal'), ]; } } diff --git a/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/ScopeAggregatorTest.php b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/ScopeAggregatorTest.php index b95fd6f86..9c90231cf 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/ScopeAggregatorTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/ScopeAggregatorTest.php @@ -16,6 +16,10 @@ use Chill\CalendarBundle\Export\Aggregator\ScopeAggregator; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; use Doctrine\ORM\EntityManagerInterface; +/** + * @internal + * @coversNothing + */ final class ScopeAggregatorTest extends AbstractAggregatorTest { private ScopeAggregator $aggregator; @@ -51,8 +55,7 @@ final class ScopeAggregatorTest extends AbstractAggregatorTest $em->createQueryBuilder() ->select('count(cal.id)') ->from(Calendar::class, 'cal') - ->join('cal.user', 'caluser') - , + ->join('cal.user', 'caluser'), ]; } } diff --git a/src/Bundle/ChillCalendarBundle/Tests/Export/Filter/AgentFilterTest.php b/src/Bundle/ChillCalendarBundle/Tests/Export/Filter/AgentFilterTest.php index de7d76601..a79775fd5 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Export/Filter/AgentFilterTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Export/Filter/AgentFilterTest.php @@ -57,7 +57,7 @@ final class AgentFilterTest extends AbstractFilterTest foreach ($array as $a) { $data[] = [ - 'accepted_agents' => $a + 'accepted_agents' => $a, ]; } diff --git a/src/Bundle/ChillCalendarBundle/Tests/Export/Filter/BetweenDatesFilterTest.php b/src/Bundle/ChillCalendarBundle/Tests/Export/Filter/BetweenDatesFilterTest.php index f51aa4474..260d9f4d2 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Export/Filter/BetweenDatesFilterTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Export/Filter/BetweenDatesFilterTest.php @@ -14,6 +14,7 @@ namespace Chill\CalendarBundle\Tests\Export\Filter; use Chill\CalendarBundle\Entity\Calendar; use Chill\CalendarBundle\Export\Filter\BetweenDatesFilter; use Chill\MainBundle\Test\Export\AbstractFilterTest; +use DateTime; use Doctrine\ORM\EntityManagerInterface; /** @@ -46,9 +47,9 @@ final class BetweenDatesFilterTest extends AbstractFilterTest { return [ [ - 'date_from' => \DateTime::createFromFormat('Y-m-d', '2022-05-01'), - 'date_to' => \DateTime::createFromFormat('Y-m-d', '2022-06-01'), - ] + 'date_from' => DateTime::createFromFormat('Y-m-d', '2022-05-01'), + 'date_to' => DateTime::createFromFormat('Y-m-d', '2022-06-01'), + ], ]; } diff --git a/src/Bundle/ChillCalendarBundle/Tests/Export/Filter/JobFilterTest.php b/src/Bundle/ChillCalendarBundle/Tests/Export/Filter/JobFilterTest.php index b036f55fa..fcb14bfb0 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Export/Filter/JobFilterTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Export/Filter/JobFilterTest.php @@ -57,7 +57,7 @@ final class JobFilterTest extends AbstractFilterTest foreach ($array as $a) { $data[] = [ - 'job' => $a + 'job' => $a, ]; } diff --git a/src/Bundle/ChillCalendarBundle/Tests/Export/Filter/ScopeFilterTest.php b/src/Bundle/ChillCalendarBundle/Tests/Export/Filter/ScopeFilterTest.php index e249c194f..727e0e258 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Export/Filter/ScopeFilterTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Export/Filter/ScopeFilterTest.php @@ -57,7 +57,7 @@ final class ScopeFilterTest extends AbstractFilterTest foreach ($array as $a) { $data[] = [ - 'scope' => $a + 'scope' => $a, ]; } diff --git a/src/Bundle/ChillCalendarBundle/migrations/Version20220921101643.php b/src/Bundle/ChillCalendarBundle/migrations/Version20220921101643.php index 270c57da4..6dd872540 100644 --- a/src/Bundle/ChillCalendarBundle/migrations/Version20220921101643.php +++ b/src/Bundle/ChillCalendarBundle/migrations/Version20220921101643.php @@ -1,5 +1,12 @@ addSql('ALTER TABLE chill_calendar.calendar DROP urgent'); + } + public function getDescription(): string { return 'Add urgent property to calendar entity'; @@ -21,13 +34,5 @@ final class Version20220921101643 extends AbstractMigration { // this up() migration is auto-generated, please modify it to your needs $this->addSql('ALTER TABLE chill_calendar.calendar ADD urgent BOOLEAN DEFAULT NULL'); - - } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('ALTER TABLE chill_calendar.calendar DROP urgent'); - } } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/DeadOrAliveFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/DeadOrAliveFilter.php index c764bdbb7..e069af849 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/DeadOrAliveFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/DeadOrAliveFilter.php @@ -42,7 +42,7 @@ class DeadOrAliveFilter implements FilterInterface 'person.birthdate', ':date_calc' ) - ), + ), $qb->expr()->andX( $qb->expr()->isNotNull('person.deathdate'), $qb->expr()->gt( From 7e65e97caf2e20232301009f1c75a319fc95d1d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 6 Oct 2022 10:21:16 +0200 Subject: [PATCH 14/51] fix cs: header and declare strict type order --- src/Bundle/ChillActivityBundle/ChillActivityBundle.php | 1 - .../Controller/ActivityReasonCategoryController.php | 1 - .../Controller/ActivityReasonController.php | 1 - .../Controller/AdminActivityPresenceController.php | 1 - .../Controller/AdminActivityTypeCategoryController.php | 1 - .../Controller/AdminActivityTypeController.php | 1 - .../ChillActivityBundle/Controller/AdminController.php | 1 - .../DataFixtures/ORM/LoadActivity.php | 1 - .../DataFixtures/ORM/LoadActivityNotifications.php | 1 - .../DataFixtures/ORM/LoadActivityReason.php | 1 - .../DataFixtures/ORM/LoadActivityReasonCategory.php | 1 - .../DataFixtures/ORM/LoadActivityType.php | 1 - .../DataFixtures/ORM/LoadActivityTypeCategory.php | 1 - .../DataFixtures/ORM/LoadActivitytACL.php | 1 - .../DependencyInjection/ChillActivityExtension.php | 1 - .../DependencyInjection/Configuration.php | 1 - src/Bundle/ChillActivityBundle/Entity/Activity.php | 1 - .../ChillActivityBundle/Entity/ActivityPresence.php | 1 - src/Bundle/ChillActivityBundle/Entity/ActivityReason.php | 1 - .../Entity/ActivityReasonCategory.php | 1 - .../ChillActivityBundle/Entity/ActivityTypeCategory.php | 1 - .../EntityListener/ActivityEntityListener.php | 1 - src/Bundle/ChillActivityBundle/Export/Declarations.php | 1 - .../Export/Filter/ACPFilters/ActivityTypeFilter.php | 1 - .../ChillActivityBundle/Form/ActivityPresenceType.php | 1 - .../Form/ActivityReasonCategoryType.php | 1 - .../ChillActivityBundle/Form/ActivityReasonType.php | 1 - src/Bundle/ChillActivityBundle/Form/ActivityType.php | 1 - .../Form/ActivityTypeCategoryType.php | 1 - src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php | 1 - .../Form/Type/ActivityFieldPresence.php | 1 - .../Form/Type/TranslatableActivityReason.php | 1 - .../Form/Type/TranslatableActivityReasonCategory.php | 1 - .../Menu/AccompanyingCourseMenuBuilder.php | 1 - src/Bundle/ChillActivityBundle/Menu/AdminMenuBuilder.php | 1 - .../ChillActivityBundle/Menu/PersonMenuBuilder.php | 1 - .../Notification/ActivityNotificationHandler.php | 1 - .../Repository/ActivityACLAwareRepository.php | 1 - .../Repository/ActivityACLAwareRepositoryInterface.php | 1 - .../Repository/ActivityReasonCategoryRepository.php | 1 - .../Repository/ActivityReasonRepository.php | 1 - .../Repository/ActivityRepository.php | 1 - .../Repository/ActivityTypeCategoryRepository.php | 1 - .../Repository/ActivityTypeRepositoryInterface.php | 1 - .../Security/Authorization/ActivityVoter.php | 1 - .../Service/DocGenerator/ActivityContext.php | 1 - .../ListActivitiesByAccompanyingPeriodContext.php | 1 - .../Templating/Entity/ActivityReasonRender.php | 1 - .../ChillActivityBundle/Test/PrepareActivityTrait.php | 1 - .../Tests/Controller/ActivityControllerTest.php | 1 - .../Controller/ActivityReasonCategoryControllerTest.php | 1 - .../Tests/Controller/ActivityReasonControllerTest.php | 1 - .../Tests/Controller/ActivityTypeControllerTest.php | 1 - .../ChillActivityBundle/Tests/Entity/ActivityTest.php | 1 - .../ACPAggregators/BySocialActionAggregatorTest.php | 1 - .../ACPAggregators/BySocialIssueAggregatorTest.php | 1 - .../ACPAggregators/ByThirdpartyAggregatorTest.php | 1 - .../Aggregator/ACPAggregators/ByUserAggregatorTest.php | 1 - .../Aggregator/ACPAggregators/DateAggregatorTest.php | 1 - .../ACPAggregators/LocationTypeAggregatorTest.php | 1 - .../ACPAggregators/UserScopeAggregatorTest.php | 1 - .../PersonAggregators/ActivityReasonAggregatorTest.php | 1 - .../Export/LinkedToACP/AvgActivityDurationTest.php | 1 - .../Export/LinkedToACP/AvgActivityVisitDurationTest.php | 1 - .../Export/Export/LinkedToACP/CountActivityTest.php | 1 - .../Export/LinkedToACP/SumActivityDurationTest.php | 1 - .../Export/LinkedToACP/SumActivityVisitDurationTest.php | 1 - .../Export/Export/LinkedToPerson/CountActivityTest.php | 1 - .../Export/Export/LinkedToPerson/ListActivityTest.php | 1 - .../Export/LinkedToPerson/StatActivityDurationTest.php | 1 - .../Export/Filter/ACPFilters/ActivityTypeFilterTest.php | 1 - .../Filter/ACPFilters/BySocialActionFilterTest.php | 1 - .../Export/Filter/ACPFilters/BySocialIssueFilterTest.php | 1 - .../Tests/Export/Filter/ACPFilters/ByUserFilterTest.php | 1 - .../Export/Filter/ACPFilters/EmergencyFilterTest.php | 1 - .../Export/Filter/ACPFilters/LocationTypeFilterTest.php | 1 - .../Export/Filter/ACPFilters/SentReceivedFilterTest.php | 1 - .../Tests/Export/Filter/ACPFilters/UserFilterTest.php | 1 - .../Export/Filter/ACPFilters/UserScopeFilterTest.php | 1 - .../Tests/Export/Filter/ActivityDateFilterTest.php | 1 - .../Tests/Export/Filter/ActivityTypeFilterTest.php | 1 - .../Filter/PersonFilters/ActivityReasonFilterTest.php | 1 - .../PersonHavingActivityBetweenDateFilterTest.php | 1 - .../ChillActivityBundle/Tests/Form/ActivityTypeTest.php | 1 - .../Tests/Form/Type/TranslatableActivityReasonTest.php | 1 - .../Tests/Form/Type/TranslatableActivityTypeTest.php | 1 - .../Tests/Security/Authorization/ActivityVoterTest.php | 1 - .../Tests/Timeline/TimelineProviderTest.php | 1 - .../Timeline/TimelineActivityProvider.php | 1 - .../Validator/Constraints/ActivityValidity.php | 1 - .../Validator/Constraints/ActivityValidityValidator.php | 1 - .../migrations/Version20150701091248.php | 1 - .../migrations/Version20150702093317.php | 1 - .../migrations/Version20150704091347.php | 1 - .../migrations/Version20160222103457.php | 1 - .../migrations/Version20161114085659.php | 1 - .../migrations/Version20210304154629.php | 1 - .../migrations/Version20210311114250.php | 1 - .../migrations/Version20210401090853.php | 1 - .../migrations/Version20210408122329.php | 1 - .../migrations/Version20210415113216.php | 1 - .../migrations/Version20210422073711.php | 1 - .../migrations/Version20210422123846.php | 1 - .../migrations/Version20210506071150.php | 1 - .../migrations/Version20210506090417.php | 1 - .../migrations/Version20210506094520.php | 1 - .../migrations/Version20210506112500.php | 1 - .../migrations/Version20210520095626.php | 1 - .../migrations/Version20210528161250.php | 1 - .../migrations/Version20210602103243.php | 1 - .../migrations/Version20211119173555.php | 1 - .../migrations/Version20211207152023.php | 1 - .../migrations/Version20220425133027.php | 1 - .../migrations/Version20220527124438.php | 1 - .../src/ChillAsideActivityBundle.php | 1 - .../src/Controller/AdminController.php | 1 - .../src/Controller/AsideActivityCategoryController.php | 1 - .../src/Controller/AsideActivityController.php | 1 - .../src/DataFixtures/ORM/LoadAsideActivity.php | 1 - .../src/DataFixtures/ORM/LoadAsideActivityCategory.php | 1 - .../DependencyInjection/ChillAsideActivityExtension.php | 1 - .../src/DependencyInjection/Configuration.php | 1 - .../src/Entity/AsideActivity.php | 1 - .../src/Entity/AsideActivityCategory.php | 1 - .../src/Form/AsideActivityCategoryType.php | 1 - .../src/Form/AsideActivityFormType.php | 1 - .../src/Menu/AdminMenuBuilder.php | 1 - .../src/Menu/SectionMenuBuilder.php | 1 - .../src/Menu/UserMenuBuilder.php | 1 - .../src/Repository/AsideActivityCategoryRepository.php | 1 - .../src/Repository/AsideActivityRepository.php | 1 - .../src/Templating/Entity/CategoryRender.php | 1 - .../src/Tests/Controller/AsideActivityControllerTest.php | 1 - .../src/migrations/Version20210706124644.php | 1 - .../src/migrations/Version20210804082249.php | 1 - .../src/migrations/Version20210806140343.php | 1 - .../src/migrations/Version20210806140710.php | 1 - .../src/migrations/Version20210810084456.php | 1 - .../src/migrations/Version20210922182907.php | 1 - .../src/migrations/Version20211004134012.php | 1 - .../ChillBudgetBundle/Calculator/CalculatorInterface.php | 1 - .../ChillBudgetBundle/Calculator/CalculatorManager.php | 1 - .../ChillBudgetBundle/Calculator/CalculatorResult.php | 1 - src/Bundle/ChillBudgetBundle/ChillBudgetBundle.php | 1 - src/Bundle/ChillBudgetBundle/Config/ConfigRepository.php | 1 - .../Controller/AbstractElementController.php | 1 - .../ChillBudgetBundle/Controller/ChargeController.php | 1 - .../ChillBudgetBundle/Controller/ElementController.php | 1 - .../ChillBudgetBundle/Controller/ResourceController.php | 1 - .../DependencyInjection/ChillBudgetExtension.php | 1 - .../Compiler/CalculatorCompilerPass.php | 1 - .../DependencyInjection/Configuration.php | 1 - src/Bundle/ChillBudgetBundle/Entity/AbstractElement.php | 1 - src/Bundle/ChillBudgetBundle/Entity/Charge.php | 1 - src/Bundle/ChillBudgetBundle/Entity/Resource.php | 1 - src/Bundle/ChillBudgetBundle/Form/ChargeType.php | 1 - src/Bundle/ChillBudgetBundle/Form/ResourceType.php | 1 - .../ChillBudgetBundle/Menu/HouseholdMenuBuilder.php | 1 - src/Bundle/ChillBudgetBundle/Menu/PersonMenuBuilder.php | 1 - .../ChillBudgetBundle/Repository/ChargeRepository.php | 1 - .../ChillBudgetBundle/Repository/ResourceRepository.php | 1 - .../Security/Authorization/BudgetElementVoter.php | 1 - .../ChillBudgetBundle/Service/Summary/SummaryBudget.php | 1 - .../Service/Summary/SummaryBudgetInterface.php | 1 - src/Bundle/ChillBudgetBundle/Templating/Twig.php | 1 - .../Tests/Controller/ElementControllerTest.php | 1 - .../migrations/Version20180522080432.php | 1 - .../migrations/Version20181219145631.php | 1 - .../migrations/Version20220224090319.php | 1 - src/Bundle/ChillCalendarBundle/ChillCalendarBundle.php | 1 - .../Command/AzureGrantAdminConsentAndAcquireToken.php | 9 ++++++++- .../Command/MapAndSubscribeUserCalendarCommand.php | 9 ++++++++- .../Command/SendShortMessageOnEligibleCalendar.php | 9 ++++++++- .../Command/SendTestShortMessageOnCalendarCommand.php | 9 ++++++++- .../ChillCalendarBundle/Controller/AdminController.php | 1 - .../Controller/CalendarAPIController.php | 1 - .../Controller/CalendarController.php | 1 - .../Controller/CalendarRangeAPIController.php | 1 - .../Controller/CancelReasonController.php | 1 - .../Controller/InviteApiController.php | 9 ++++++++- .../Controller/RemoteCalendarConnectAzureController.php | 9 ++++++++- .../Controller/RemoteCalendarMSGraphSyncController.php | 9 ++++++++- .../Controller/RemoteCalendarProxyController.php | 9 ++++++++- .../DataFixtures/ORM/LoadCalendarRange.php | 1 - .../DataFixtures/ORM/LoadCancelReason.php | 1 - .../ChillCalendarBundle/DataFixtures/ORM/LoadInvite.php | 1 - .../DependencyInjection/ChillCalendarExtension.php | 1 - .../DependencyInjection/Configuration.php | 1 - src/Bundle/ChillCalendarBundle/Entity/Calendar.php | 1 - src/Bundle/ChillCalendarBundle/Entity/CalendarRange.php | 1 - src/Bundle/ChillCalendarBundle/Entity/CancelReason.php | 1 - src/Bundle/ChillCalendarBundle/Entity/Invite.php | 1 - .../ChillCalendarBundle/Entity/RemoteCalendarTrait.php | 9 ++++++++- .../ChillCalendarBundle/Event/ListenToActivityCreate.php | 1 - .../Export/Aggregator/UrgencyAggregator.php | 9 ++++++++- src/Bundle/ChillCalendarBundle/Export/Declarations.php | 1 - .../Export/Filter/CalendarRangeFilter.php | 9 ++++++++- src/Bundle/ChillCalendarBundle/Form/CalendarType.php | 1 - src/Bundle/ChillCalendarBundle/Form/CancelReasonType.php | 1 - .../DataTransformer/IdToCalendarRangeDataTransformer.php | 9 ++++++++- .../Menu/AccompanyingCourseMenuBuilder.php | 1 - src/Bundle/ChillCalendarBundle/Menu/AdminMenuBuilder.php | 1 - src/Bundle/ChillCalendarBundle/Menu/UserMenuBuilder.php | 1 - .../Messenger/Doctrine/CalendarEntityListener.php | 9 ++++++++- .../Messenger/Doctrine/CalendarRangeEntityListener.php | 9 ++++++++- .../Handler/CalendarRangeRemoveToRemoteHandler.php | 9 ++++++++- .../Messenger/Handler/CalendarRangeToRemoteHandler.php | 9 ++++++++- .../Messenger/Handler/CalendarRemoveHandler.php | 9 ++++++++- .../Messenger/Handler/CalendarToRemoteHandler.php | 9 ++++++++- .../Messenger/Handler/InviteUpdateHandler.php | 9 ++++++++- .../Handler/MSGraphChangeNotificationHandler.php | 9 ++++++++- .../Messenger/Message/CalendarMessage.php | 9 ++++++++- .../Messenger/Message/CalendarRangeMessage.php | 9 ++++++++- .../Messenger/Message/CalendarRangeRemovedMessage.php | 9 ++++++++- .../Messenger/Message/CalendarRemovedMessage.php | 9 ++++++++- .../Messenger/Message/InviteUpdateMessage.php | 9 ++++++++- .../Message/MSGraphChangeNotificationMessage.php | 9 ++++++++- .../Connector/MSGraph/AddressConverter.php | 9 ++++++++- .../MSGraph/EventsOnUserSubscriptionCreator.php | 9 ++++++++- .../Connector/MSGraph/LocationConverter.php | 9 ++++++++- .../Connector/MSGraph/MSGraphUserRepository.php | 9 ++++++++- .../Connector/MSGraph/MachineHttpClient.php | 9 ++++++++- .../Connector/MSGraph/MachineTokenStorage.php | 9 ++++++++- .../Connector/MSGraph/MapCalendarToUser.php | 9 ++++++++- .../Connector/MSGraph/OnBehalfOfUserHttpClient.php | 9 ++++++++- .../Connector/MSGraph/OnBehalfOfUserTokenStorage.php | 9 ++++++++- .../Connector/MSGraph/RemoteEventConverter.php | 9 ++++++++- .../MSGraph/RemoteToLocalSync/CalendarRangeSyncer.php | 9 ++++++++- .../MSGraph/RemoteToLocalSync/CalendarSyncer.php | 9 ++++++++- .../Connector/MSGraphRemoteCalendarConnector.php | 9 ++++++++- .../Connector/NullRemoteCalendarConnector.php | 9 ++++++++- .../Connector/RemoteCalendarConnectorInterface.php | 9 ++++++++- .../DependencyInjection/RemoteCalendarCompilerPass.php | 9 ++++++++- .../RemoteCalendar/Model/RemoteEvent.php | 9 ++++++++- .../Repository/CalendarACLAwareRepository.php | 9 ++++++++- .../Repository/CalendarACLAwareRepositoryInterface.php | 9 ++++++++- .../Repository/CalendarRangeRepository.php | 1 - .../Repository/CalendarRepository.php | 1 - .../Repository/CancelReasonRepository.php | 1 - .../ChillCalendarBundle/Repository/InviteRepository.php | 1 - .../ChillCalendarBundle/Security/Voter/CalendarVoter.php | 9 ++++++++- .../ChillCalendarBundle/Security/Voter/InviteVoter.php | 9 ++++++++- .../BulkCalendarShortMessageSender.php | 9 ++++++++- .../CalendarForShortMessageProvider.php | 9 ++++++++- .../ShortMessageNotification/DefaultRangeGenerator.php | 9 ++++++++- .../DefaultShortMessageForCalendarBuilder.php | 9 ++++++++- .../ShortMessageNotification/RangeGeneratorInterface.php | 9 ++++++++- .../ShortMessageForCalendarBuilderInterface.php | 9 ++++++++- .../Tests/Controller/CalendarControllerTest.php | 1 - .../RemoteCalendarMSGraphSyncControllerTest.php | 9 ++++++++- .../ChillCalendarBundle/Tests/Entity/CalendarTest.php | 9 ++++++++- .../Tests/Export/Aggregator/AgentAggregatorTest.php | 9 ++++++++- .../Export/Aggregator/CancelReasonAggregatorTest.php | 9 ++++++++- .../Tests/Export/Aggregator/JobAggregatorTest.php | 9 ++++++++- .../Tests/Export/Aggregator/LocationAggregatorTest.php | 9 ++++++++- .../Export/Aggregator/LocationTypeAggregatorTest.php | 9 ++++++++- .../Tests/Export/Aggregator/MonthYearAggregatorTest.php | 9 ++++++++- .../Tests/Export/Aggregator/ScopeAggregatorTest.php | 9 ++++++++- .../Tests/Export/Filter/AgentFilterTest.php | 9 ++++++++- .../Tests/Export/Filter/BetweenDatesFilterTest.php | 9 ++++++++- .../Tests/Export/Filter/JobFilterTest.php | 9 ++++++++- .../Tests/Export/Filter/ScopeFilterTest.php | 9 ++++++++- .../ChillCalendarBundle/Tests/Form/CalendarTypeTest.php | 9 ++++++++- .../Connector/MSGraph/AddressConverterTest.php | 9 ++++++++- .../Connector/MSGraph/CalendarRangeSyncerTest.php | 9 ++++++++- .../Connector/MSGraph/CalendarSyncerTest.php | 9 ++++++++- .../Connector/MSGraph/LocationConverterTest.php | 9 ++++++++- .../BulkCalendarShortMessageSenderTest.php | 9 ++++++++- .../CalendarForShortMessageProviderTest.php | 9 ++++++++- .../DefaultRangeGeneratorTest.php | 9 ++++++++- .../DefaultShortMessageForCalendarBuilderTest.php | 9 ++++++++- .../migrations/Version20210715141731.php | 1 - .../migrations/Version20210723074557.php | 1 - .../migrations/Version20210723142003.php | 1 - .../migrations/Version20210723142842.php | 1 - .../migrations/Version20211119173557.php | 1 - .../migrations/Version20220510155609.php | 9 ++++++++- .../migrations/Version20220511134619.php | 9 ++++++++- .../migrations/Version20220525080633.php | 9 ++++++++- .../migrations/Version20220527124558.php | 1 - .../migrations/Version20220527234046.php | 1 - .../migrations/Version20220606153851.php | 9 ++++++++- .../migrations/Version20220606154119.php | 9 ++++++++- .../migrations/Version20220608084052.php | 9 ++++++++- .../migrations/Version20220609200857.php | 9 ++++++++- .../migrations/Version20220613202636.php | 9 ++++++++- .../migrations/Version20220629095515.php | 9 ++++++++- .../migrations/Version20220921101643.php | 9 ++++++++- .../ChillCustomFieldsBundle/ChillCustomFieldsBundle.php | 1 - .../Command/CreateFieldsOnGroupCommand.php | 1 - .../Controller/AdminController.php | 1 - .../Controller/CustomFieldController.php | 1 - .../Controller/CustomFieldsGroupController.php | 1 - .../CustomFields/AbstractCustomField.php | 1 - .../CustomFields/CustomFieldChoice.php | 1 - .../CustomFields/CustomFieldDate.php | 1 - .../CustomFields/CustomFieldInterface.php | 1 - .../CustomFields/CustomFieldLongChoice.php | 1 - .../CustomFields/CustomFieldNumber.php | 1 - .../CustomFields/CustomFieldText.php | 1 - .../CustomFields/CustomFieldTitle.php | 1 - .../DataFixtures/ORM/LoadOption.php | 1 - .../DependencyInjection/ChillCustomFieldsExtension.php | 1 - .../DependencyInjection/Configuration.php | 1 - .../DependencyInjection/CustomFieldCompilerPass.php | 1 - .../ChillCustomFieldsBundle/Entity/CustomField.php | 1 - .../Entity/CustomFieldLongChoice/Option.php | 1 - .../Entity/CustomFieldsDefaultGroup.php | 1 - .../ChillCustomFieldsBundle/Entity/CustomFieldsGroup.php | 1 - .../CustomFieldLongChoice/OptionRepository.php | 1 - .../ChillCustomFieldsBundle/Form/CustomFieldType.php | 1 - .../Form/CustomFieldsGroupType.php | 1 - .../Form/DataTransformer/CustomFieldDataTransformer.php | 1 - .../DataTransformer/CustomFieldsGroupToIdTransformer.php | 1 - .../JsonCustomFieldToArrayTransformer.php | 1 - .../Form/Extension/PostTextExtension.php | 1 - .../Form/Extension/PostTextIntegerExtension.php | 1 - .../Form/Extension/PostTextNumberExtension.php | 1 - .../Form/Type/ChoiceWithOtherType.php | 1 - .../Form/Type/ChoicesListType.php | 1 - .../ChillCustomFieldsBundle/Form/Type/ChoicesType.php | 1 - .../Form/Type/CustomFieldType.php | 1 - .../Form/Type/CustomFieldsTitleType.php | 1 - .../Form/Type/LinkedCustomFieldsType.php | 1 - .../ChillCustomFieldsBundle/Menu/AdminMenuBuilder.php | 1 - .../Service/CustomFieldProvider.php | 1 - .../Service/CustomFieldsHelper.php | 1 - .../Service/CustomFieldsHelperException.php | 1 - .../Templating/Twig/CustomFieldRenderingTwig.php | 1 - .../Templating/Twig/CustomFieldsGroupRenderingTwig.php | 1 - .../Tests/Config/ConfigCustomizablesEntitiesTest.php | 1 - .../Tests/Controller/CustomFieldControllerTest_TODO.php | 1 - .../Tests/Controller/CustomFieldsGroupControllerTest.php | 1 - .../Tests/CustomFieldTestHelper.php | 1 - .../Tests/CustomFields/CustomFieldsChoiceTest.php | 1 - .../Tests/CustomFields/CustomFieldsNumberTest.php | 1 - .../Tests/CustomFields/CustomFieldsTextTest.php | 1 - .../Form/Extension/PostTextIntegerExtensionTest.php | 1 - .../Tests/Form/Extension/PostTextNumberExtensionTest.php | 1 - .../Tests/Routing/RoutingLoaderTest.php | 1 - .../Tests/Service/CustomFieldsHelperTest.php | 1 - .../Templating/Twig/CustomFieldRenderingTwigTest.php | 1 - .../Twig/CustomFieldsGroupRenderingTwigTest.php | 1 - .../migrations/Version20141128195430.php | 1 - .../migrations/Version20150224164531.php | 1 - .../migrations/Version20151210155904.php | 1 - .../migrations/Version20151210205610.php | 1 - .../ChillDocGeneratorBundle/ChillDocGeneratorBundle.php | 1 - .../ChillDocGeneratorBundle/Context/ContextManager.php | 1 - .../Context/ContextManagerInterface.php | 1 - .../Context/DocGeneratorContextInterface.php | 1 - .../DocGeneratorContextWithAdminFormInterface.php | 1 - .../DocGeneratorContextWithPublicFormInterface.php | 1 - .../Context/Exception/ContextNotFoundException.php | 1 - .../Context/Exception/UnexpectedTypeException.php | 1 - .../Controller/AdminDocGeneratorTemplateController.php | 1 - .../Controller/DocGeneratorTemplateController.php | 1 - .../DataFixtures/ORM/LoadDocGeneratorTemplate.php | 1 - .../DependencyInjection/ChillDocGeneratorExtension.php | 1 - .../DependencyInjection/Configuration.php | 1 - .../Entity/DocGeneratorTemplate.php | 1 - .../Form/DocGeneratorTemplateType.php | 1 - .../GeneratorDriver/DriverInterface.php | 1 - .../GeneratorDriver/Exception/TemplateException.php | 1 - .../GeneratorDriver/RelatorioDriver.php | 1 - .../ChillDocGeneratorBundle/Menu/AdminMenuBuilder.php | 1 - .../Repository/DocGeneratorTemplateRepository.php | 1 - .../Serializer/Encoder/DocGenEncoder.php | 1 - .../Serializer/Helper/NormalizeNullValueHelper.php | 1 - .../Serializer/Normalizer/CollectionDocGenNormalizer.php | 1 - .../Serializer/Normalizer/DocGenObjectNormalizer.php | 1 - .../Service/Context/BaseContextData.php | 1 - .../migrations/Version20210805162522.php | 1 - .../migrations/Version20210812214310.php | 1 - .../migrations/Version20211103111010.php | 1 - .../migrations/Version20211119173556.php | 1 - .../migrations/Version20211201191757.php | 1 - .../tests/Serializer/Encoder/DocGenEncoderTest.php | 1 - .../Serializer/Normalizer/DocGenObjectNormalizerTest.php | 1 - .../tests/Service/Context/BaseContextDataTest.php | 1 - src/Bundle/ChillDocStoreBundle/ChillDocStoreBundle.php | 1 - .../ChillDocStoreBundle/Controller/AdminController.php | 1 - .../Controller/DocumentAccompanyingCourseController.php | 1 - .../Controller/DocumentCategoryController.php | 1 - .../Controller/DocumentPersonController.php | 1 - .../DataFixtures/ORM/LoadDocumentACL.php | 1 - .../DataFixtures/ORM/LoadDocumentCategory.php | 1 - .../DependencyInjection/ChillDocStoreExtension.php | 1 - .../DependencyInjection/Configuration.php | 1 - .../Entity/AccompanyingCourseDocument.php | 1 - src/Bundle/ChillDocStoreBundle/Entity/Document.php | 1 - .../ChillDocStoreBundle/Entity/DocumentCategory.php | 1 - src/Bundle/ChillDocStoreBundle/Entity/PersonDocument.php | 1 - src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php | 1 - .../AccompanyingCourseDocumentRepository.php | 1 - .../Exception/StoredObjectManagerException.php | 1 - .../Form/AccompanyingCourseDocumentType.php | 1 - .../ChillDocStoreBundle/Form/DocumentCategoryType.php | 1 - .../ChillDocStoreBundle/Form/PersonDocumentType.php | 1 - src/Bundle/ChillDocStoreBundle/Form/StoredObjectType.php | 1 - src/Bundle/ChillDocStoreBundle/Menu/AdminMenuBuilder.php | 1 - src/Bundle/ChillDocStoreBundle/Menu/MenuBuilder.php | 1 - .../Object/ObjectToAsyncFileTransformer.php | 1 - .../ChillDocStoreBundle/Object/PersistenceChecker.php | 1 - .../Repository/AccompanyingCourseDocumentRepository.php | 1 - .../Repository/DocumentCategoryRepository.php | 1 - .../Repository/PersonDocumentACLAwareRepository.php | 1 - .../PersonDocumentACLAwareRepositoryInterface.php | 1 - .../Repository/StoredObjectRepository.php | 1 - .../Authorization/AccompanyingCourseDocumentVoter.php | 1 - .../Security/Authorization/PersonDocumentVoter.php | 1 - .../Serializer/Normalizer/StoredObjectDenormalizer.php | 1 - .../ChillDocStoreBundle/Service/StoredObjectManager.php | 1 - .../Service/StoredObjectManagerInterface.php | 1 - .../Templating/WopiEditTwigExtension.php | 1 - .../Templating/WopiEditTwigExtensionRuntime.php | 1 - .../Tests/StoredObjectManagerTest.php | 1 - .../AccompanyingCourseDocumentWorkflowHandler.php | 1 - .../migrations/Version20180605102533.php | 1 - .../migrations/Version20180606133338.php | 1 - .../migrations/Version20210903091534.php | 1 - .../migrations/Version20210903123835.php | 1 - .../migrations/Version20210928182542.php | 1 - .../migrations/Version20211119173558.php | 1 - .../migrations/Version20220131093117.php | 1 - .../migrations/Version20220525141646.php | 1 - src/Bundle/ChillEventBundle/ChillEventBundle.php | 1 - .../ChillEventBundle/Controller/AdminController.php | 1 - .../ChillEventBundle/Controller/EventController.php | 1 - .../ChillEventBundle/Controller/EventTypeController.php | 1 - .../Controller/ParticipationController.php | 1 - .../ChillEventBundle/Controller/RoleController.php | 1 - .../ChillEventBundle/Controller/StatusController.php | 1 - .../ChillEventBundle/DataFixtures/ORM/LoadEventTypes.php | 1 - .../DataFixtures/ORM/LoadParticipation.php | 1 - .../ChillEventBundle/DataFixtures/ORM/LoadRolesACL.php | 1 - .../DependencyInjection/ChillEventExtension.php | 1 - .../DependencyInjection/Configuration.php | 1 - src/Bundle/ChillEventBundle/Entity/Event.php | 1 - src/Bundle/ChillEventBundle/Entity/EventType.php | 1 - src/Bundle/ChillEventBundle/Entity/Participation.php | 1 - src/Bundle/ChillEventBundle/Entity/Role.php | 1 - src/Bundle/ChillEventBundle/Entity/Status.php | 1 - .../Form/ChoiceLoader/EventChoiceLoader.php | 1 - src/Bundle/ChillEventBundle/Form/EventType.php | 1 - src/Bundle/ChillEventBundle/Form/EventTypeType.php | 1 - src/Bundle/ChillEventBundle/Form/ParticipationType.php | 1 - src/Bundle/ChillEventBundle/Form/RoleType.php | 1 - src/Bundle/ChillEventBundle/Form/StatusType.php | 1 - src/Bundle/ChillEventBundle/Form/Type/PickEventType.php | 1 - .../ChillEventBundle/Form/Type/PickEventTypeType.php | 1 - src/Bundle/ChillEventBundle/Form/Type/PickRoleType.php | 1 - src/Bundle/ChillEventBundle/Form/Type/PickStatusType.php | 1 - src/Bundle/ChillEventBundle/Menu/AdminMenuBuilder.php | 1 - src/Bundle/ChillEventBundle/Menu/PersonMenuBuilder.php | 1 - .../ChillEventBundle/Repository/EventRepository.php | 1 - .../Repository/ParticipationRepository.php | 1 - src/Bundle/ChillEventBundle/Search/EventSearch.php | 1 - .../Security/Authorization/EventVoter.php | 1 - .../Security/Authorization/ParticipationVoter.php | 1 - .../Tests/Controller/EventControllerTest.php | 1 - .../Tests/Controller/EventTypeControllerTest.php | 1 - .../Tests/Controller/ParticipationControllerTest.php | 1 - .../Tests/Controller/RoleControllerTest.php | 1 - .../Tests/Controller/StatusControllerTest.php | 1 - .../ChillEventBundle/Tests/Search/EventSearchTest.php | 1 - .../ChillEventBundle/Timeline/TimelineEventProvider.php | 1 - .../migrations/Version20160318111334.php | 1 - .../migrations/Version20190110140538.php | 1 - .../migrations/Version20190115140042.php | 1 - .../migrations/Version20190201143121.php | 1 - .../ChillAMLIFamilyMembersBundle.php | 1 - .../ChillFamilyMembersBundle/Config/ConfigRepository.php | 1 - .../Controller/FamilyMemberController.php | 1 - .../ChillAMLIFamilyMembersExtension.php | 1 - .../DependencyInjection/Configuration.php | 1 - .../Entity/AbstractFamilyMember.php | 1 - .../ChillFamilyMembersBundle/Entity/FamilyMember.php | 1 - .../ChillFamilyMembersBundle/Form/FamilyMemberType.php | 1 - .../ChillFamilyMembersBundle/Form/FamilyMembersType.php | 1 - .../ChillFamilyMembersBundle/Menu/UserMenuBuilder.php | 1 - .../Repository/FamilyMemberRepository.php | 1 - .../Resources/migrations/Version20180522142023.php | 1 - .../Security/Voter/FamilyMemberVoter.php | 1 - src/Bundle/ChillFamilyMembersBundle/Templating/Twig.php | 1 - .../Tests/Controller/FamilyMemberControllerTest.php | 1 - .../CRUD/CompilerPass/CRUDControllerCompilerPass.php | 1 - .../CRUD/Controller/AbstractCRUDController.php | 1 - .../ChillMainBundle/CRUD/Controller/ApiController.php | 1 - .../ChillMainBundle/CRUD/Controller/CRUDController.php | 1 - .../ChillMainBundle/CRUD/Form/CRUDDeleteEntityForm.php | 1 - src/Bundle/ChillMainBundle/CRUD/Resolver/Resolver.php | 1 - .../ChillMainBundle/CRUD/Routing/CRUDRoutesLoader.php | 1 - .../ChillMainBundle/CRUD/Templating/TwigCRUDResolver.php | 1 - .../ChillMainBundle/Center/GroupingCenterInterface.php | 1 - src/Bundle/ChillMainBundle/ChillMainBundle.php | 1 - .../ChillMainBundle/Command/ChillImportUsersCommand.php | 1 - .../Command/ChillUserSendRenewPasswordCodeCommand.php | 1 - .../Command/LoadAddressesBEFromBestAddressCommand.php | 1 - .../Command/LoadAddressesFRFromBANOCommand.php | 1 - .../Command/LoadAndUpdateLanguagesCommand.php | 1 - .../ChillMainBundle/Command/LoadCountriesCommand.php | 1 - src/Bundle/ChillMainBundle/Command/LoadPostalCodeFR.php | 1 - .../ChillMainBundle/Command/LoadPostalCodesCommand.php | 1 - .../ChillMainBundle/Command/SetPasswordCommand.php | 1 - .../ChillMainBundle/Controller/AddressApiController.php | 1 - .../Controller/AddressReferenceAPIController.php | 1 - .../ChillMainBundle/Controller/AdminController.php | 1 - .../ChillMainBundle/Controller/CenterController.php | 1 - .../ChillMainBundle/Controller/CivilityApiController.php | 1 - .../ChillMainBundle/Controller/CivilityController.php | 1 - .../ChillMainBundle/Controller/CountryController.php | 1 - .../ChillMainBundle/Controller/DefaultController.php | 1 - .../ChillMainBundle/Controller/LanguageController.php | 1 - .../ChillMainBundle/Controller/LocationApiController.php | 1 - .../ChillMainBundle/Controller/LocationController.php | 1 - .../Controller/LocationTypeApiController.php | 1 - .../Controller/LocationTypeController.php | 1 - .../ChillMainBundle/Controller/LoginController.php | 1 - src/Bundle/ChillMainBundle/Controller/MenuController.php | 1 - .../Controller/NotificationApiController.php | 1 - .../Controller/NotificationController.php | 1 - .../ChillMainBundle/Controller/PasswordController.php | 1 - .../Controller/PermissionApiController.php | 1 - .../Controller/PermissionsGroupController.php | 1 - .../Controller/PostalCodeAPIController.php | 1 - .../ChillMainBundle/Controller/PostalCodeController.php | 1 - .../ChillMainBundle/Controller/ScopeController.php | 1 - .../ChillMainBundle/Controller/SearchController.php | 1 - .../Controller/TimelineCenterController.php | 1 - src/Bundle/ChillMainBundle/Controller/UIController.php | 1 - .../ChillMainBundle/Controller/UserApiController.php | 1 - src/Bundle/ChillMainBundle/Controller/UserController.php | 1 - .../ChillMainBundle/Controller/UserJobApiController.php | 1 - .../ChillMainBundle/Controller/UserJobController.php | 1 - .../ChillMainBundle/Controller/WorkflowApiController.php | 1 - .../ChillMainBundle/Controller/WorkflowController.php | 1 - .../DataFixtures/ORM/LoadAbstractNotificationsTrait.php | 1 - .../DataFixtures/ORM/LoadAddressReferences.php | 1 - .../ChillMainBundle/DataFixtures/ORM/LoadCenters.php | 1 - .../ChillMainBundle/DataFixtures/ORM/LoadCivility.php | 1 - .../ChillMainBundle/DataFixtures/ORM/LoadCountries.php | 1 - .../DataFixtures/ORM/LoadGroupCenters.php | 1 - .../ChillMainBundle/DataFixtures/ORM/LoadLanguages.php | 1 - .../DataFixtures/ORM/LoadLocationType.php | 1 - .../DataFixtures/ORM/LoadPermissionsGroup.php | 1 - .../ChillMainBundle/DataFixtures/ORM/LoadPostalCodes.php | 1 - .../ChillMainBundle/DataFixtures/ORM/LoadRoleScopes.php | 1 - .../ChillMainBundle/DataFixtures/ORM/LoadScopes.php | 1 - .../ChillMainBundle/DataFixtures/ORM/LoadUsers.php | 1 - .../DependencyInjection/ChillMainExtension.php | 1 - .../CompilerPass/ACLFlagsCompilerPass.php | 1 - .../CompilerPass/ExportsCompilerPass.php | 1 - .../CompilerPass/GroupingCenterCompilerPass.php | 1 - .../CompilerPass/MenuCompilerPass.php | 1 - .../CompilerPass/NotificationCounterCompilerPass.php | 1 - .../CompilerPass/SearchableServicesCompilerPass.php | 1 - .../CompilerPass/ShortMessageCompilerPass.php | 9 ++++++++- .../CompilerPass/TimelineCompilerClass.php | 1 - .../CompilerPass/WidgetsCompilerPass.php | 1 - .../ConfigConsistencyCompilerPass.php | 1 - .../DependencyInjection/Configuration.php | 1 - .../DependencyInjection/MissingBundleException.php | 1 - .../DependencyInjection/RoleProvidersCompilerPass.php | 1 - .../Widget/AbstractWidgetsCompilerPass.php | 1 - .../Widget/AddWidgetConfigurationTrait.php | 1 - .../Widget/Factory/AbstractWidgetFactory.php | 1 - .../Widget/Factory/WidgetFactoryInterface.php | 1 - .../Widget/HasWidgetFactoriesExtensionInterface.php | 1 - src/Bundle/ChillMainBundle/Doctrine/DQL/Extract.php | 1 - .../ChillMainBundle/Doctrine/DQL/GetJsonFieldByKey.php | 1 - .../ChillMainBundle/Doctrine/DQL/JsonAggregate.php | 1 - .../ChillMainBundle/Doctrine/DQL/JsonbArrayLength.php | 1 - .../ChillMainBundle/Doctrine/DQL/JsonbExistsInArray.php | 1 - src/Bundle/ChillMainBundle/Doctrine/DQL/OverlapsI.php | 1 - src/Bundle/ChillMainBundle/Doctrine/DQL/Replace.php | 1 - src/Bundle/ChillMainBundle/Doctrine/DQL/STContains.php | 1 - src/Bundle/ChillMainBundle/Doctrine/DQL/Similarity.php | 1 - .../Doctrine/DQL/StrictWordSimilarityOPS.php | 1 - src/Bundle/ChillMainBundle/Doctrine/DQL/ToChar.php | 1 - src/Bundle/ChillMainBundle/Doctrine/DQL/Unaccent.php | 1 - .../Doctrine/Event/TrackCreateUpdateSubscriber.php | 1 - .../Doctrine/Migrations/VersionComparator.php | 1 - src/Bundle/ChillMainBundle/Doctrine/Model/Point.php | 1 - .../ChillMainBundle/Doctrine/Model/PointException.php | 1 - .../Doctrine/Model/TrackCreationInterface.php | 1 - .../Doctrine/Model/TrackCreationTrait.php | 1 - .../Doctrine/Model/TrackUpdateInterface.php | 1 - .../ChillMainBundle/Doctrine/Model/TrackUpdateTrait.php | 1 - .../ORM/Hydration/FlatHierarchyEntityHydrator.php | 1 - .../Doctrine/Type/NativeDateIntervalType.php | 1 - src/Bundle/ChillMainBundle/Doctrine/Type/PointType.php | 1 - src/Bundle/ChillMainBundle/Entity/Address.php | 1 - src/Bundle/ChillMainBundle/Entity/AddressReference.php | 1 - src/Bundle/ChillMainBundle/Entity/Center.php | 1 - src/Bundle/ChillMainBundle/Entity/Civility.php | 1 - src/Bundle/ChillMainBundle/Entity/Country.php | 1 - .../Entity/Embeddable/CommentEmbeddable.php | 1 - .../Entity/Embeddable/PrivateCommentEmbeddable.php | 1 - .../ChillMainBundle/Entity/GeographicalUnitLayer.php | 1 - src/Bundle/ChillMainBundle/Entity/GroupCenter.php | 1 - src/Bundle/ChillMainBundle/Entity/HasCenterInterface.php | 1 - .../ChillMainBundle/Entity/HasCentersInterface.php | 1 - src/Bundle/ChillMainBundle/Entity/HasScopeInterface.php | 1 - src/Bundle/ChillMainBundle/Entity/HasScopesInterface.php | 1 - src/Bundle/ChillMainBundle/Entity/Language.php | 1 - src/Bundle/ChillMainBundle/Entity/Location.php | 1 - src/Bundle/ChillMainBundle/Entity/LocationType.php | 1 - src/Bundle/ChillMainBundle/Entity/Notification.php | 1 - .../ChillMainBundle/Entity/NotificationComment.php | 1 - src/Bundle/ChillMainBundle/Entity/PermissionsGroup.php | 1 - src/Bundle/ChillMainBundle/Entity/PostalCode.php | 1 - src/Bundle/ChillMainBundle/Entity/RoleScope.php | 1 - src/Bundle/ChillMainBundle/Entity/Scope.php | 1 - src/Bundle/ChillMainBundle/Entity/User.php | 1 - src/Bundle/ChillMainBundle/Entity/UserJob.php | 1 - .../ChillMainBundle/Entity/Workflow/EntityWorkflow.php | 1 - .../Entity/Workflow/EntityWorkflowComment.php | 1 - .../Entity/Workflow/EntityWorkflowStep.php | 1 - .../ChillMainBundle/Export/AggregatorInterface.php | 1 - .../ChillMainBundle/Export/DirectExportInterface.php | 1 - .../ChillMainBundle/Export/ExportElementInterface.php | 1 - .../Export/ExportElementValidatedInterface.php | 1 - .../Export/ExportElementsProviderInterface.php | 1 - src/Bundle/ChillMainBundle/Export/FilterInterface.php | 1 - .../ChillMainBundle/Export/Formatter/CSVFormatter.php | 1 - .../Export/Formatter/CSVListFormatter.php | 1 - .../Export/Formatter/CSVPivotedListFormatter.php | 1 - .../Export/Formatter/SpreadsheetListFormatter.php | 1 - src/Bundle/ChillMainBundle/Export/FormatterInterface.php | 1 - .../ChillMainBundle/Export/GroupedExportInterface.php | 1 - src/Bundle/ChillMainBundle/Export/ListInterface.php | 1 - src/Bundle/ChillMainBundle/Form/AdvancedSearchType.php | 1 - src/Bundle/ChillMainBundle/Form/CenterType.php | 1 - .../Form/ChoiceLoader/PostalCodeChoiceLoader.php | 1 - src/Bundle/ChillMainBundle/Form/CivilityType.php | 1 - src/Bundle/ChillMainBundle/Form/CountryType.php | 1 - .../Form/DataMapper/AddressDataMapper.php | 1 - .../Form/DataMapper/PrivateCommentDataMapper.php | 1 - .../Form/DataMapper/ScopePickerDataMapper.php | 1 - .../Form/DataTransformer/IdToEntityDataTransformer.php | 9 ++++++++- .../Form/DataTransformer/IdToLocationDataTransformer.php | 9 ++++++++- .../Form/DataTransformer/IdToUserDataTransformer.php | 9 ++++++++- .../Form/DataTransformer/IdToUsersDataTransformer.php | 9 ++++++++- .../ChillMainBundle/Form/EntityWorkflowCommentType.php | 1 - .../ChillMainBundle/Form/Event/CustomizeFormEvent.php | 1 - src/Bundle/ChillMainBundle/Form/LanguageType.php | 1 - src/Bundle/ChillMainBundle/Form/LocationFormType.php | 1 - src/Bundle/ChillMainBundle/Form/LocationTypeType.php | 1 - .../ChillMainBundle/Form/NotificationCommentType.php | 1 - src/Bundle/ChillMainBundle/Form/NotificationType.php | 1 - src/Bundle/ChillMainBundle/Form/PermissionsGroupType.php | 1 - src/Bundle/ChillMainBundle/Form/ScopeType.php | 1 - src/Bundle/ChillMainBundle/Form/Type/AddressDateType.php | 1 - src/Bundle/ChillMainBundle/Form/Type/AddressType.php | 1 - .../Form/Type/AppendScopeChoiceTypeTrait.php | 1 - .../ChillMainBundle/Form/Type/ChillCollectionType.php | 1 - .../ChillMainBundle/Form/Type/ChillDateTimeType.php | 1 - src/Bundle/ChillMainBundle/Form/Type/ChillDateType.php | 1 - .../ChillMainBundle/Form/Type/ChillPhoneNumberType.php | 1 - .../ChillMainBundle/Form/Type/ChillTextareaType.php | 1 - src/Bundle/ChillMainBundle/Form/Type/CommentType.php | 1 - .../Form/Type/ComposedGroupCenterType.php | 1 - .../ChillMainBundle/Form/Type/ComposedRoleScopeType.php | 1 - .../Type/DataTransformer/AddressToIdDataTransformer.php | 1 - .../Form/Type/DataTransformer/CenterTransformer.php | 1 - .../Type/DataTransformer/DateIntervalTransformer.php | 1 - .../Type/DataTransformer/EntityToJsonTransformer.php | 1 - .../DataTransformer/MultipleObjectsToIdTransformer.php | 1 - .../Form/Type/DataTransformer/ObjectToIdTransformer.php | 1 - .../Form/Type/DataTransformer/ScopeTransformer.php | 1 - .../ChillMainBundle/Form/Type/DateIntervalType.php | 1 - .../ChillMainBundle/Form/Type/Export/AggregatorType.php | 1 - .../ChillMainBundle/Form/Type/Export/ExportType.php | 1 - .../ChillMainBundle/Form/Type/Export/FilterType.php | 1 - .../ChillMainBundle/Form/Type/Export/FormatterType.php | 1 - .../Form/Type/Export/PickFormatterType.php | 1 - .../Form/Type/Listing/FilterOrderType.php | 1 - src/Bundle/ChillMainBundle/Form/Type/PickAddressType.php | 1 - src/Bundle/ChillMainBundle/Form/Type/PickCenterType.php | 1 - .../ChillMainBundle/Form/Type/PickCivilityType.php | 1 - .../ChillMainBundle/Form/Type/PickUserDynamicType.php | 1 - src/Bundle/ChillMainBundle/Form/Type/PostalCodeType.php | 1 - .../ChillMainBundle/Form/Type/PrivateCommentType.php | 1 - src/Bundle/ChillMainBundle/Form/Type/ScopePickerType.php | 1 - .../ChillMainBundle/Form/Type/Select2ChoiceType.php | 1 - .../ChillMainBundle/Form/Type/Select2CountryType.php | 1 - .../ChillMainBundle/Form/Type/Select2EntityType.php | 1 - .../ChillMainBundle/Form/Type/Select2LanguageType.php | 1 - .../Form/Type/TranslatableStringFormType.php | 1 - src/Bundle/ChillMainBundle/Form/Type/UserPickerType.php | 1 - .../ChillMainBundle/Form/UserCurrentLocationType.php | 1 - src/Bundle/ChillMainBundle/Form/UserJobType.php | 1 - src/Bundle/ChillMainBundle/Form/UserPasswordType.php | 1 - src/Bundle/ChillMainBundle/Form/UserType.php | 1 - .../Form/Utils/PermissionsGroupFlagProvider.php | 1 - src/Bundle/ChillMainBundle/Form/WorkflowStepType.php | 1 - .../ChillMainBundle/Form/WorkflowTransitionType.php | 1 - .../Notification/Counter/NotificationByUserCounter.php | 1 - .../Notification/Email/NotificationMailer.php | 1 - .../PersistNotificationOnTerminateEventSubscriber.php | 1 - .../Exception/NotificationHandlerNotFound.php | 1 - src/Bundle/ChillMainBundle/Notification/Mailer.php | 1 - .../Notification/NotificationHandlerInterface.php | 1 - .../Notification/NotificationHandlerManager.php | 1 - .../Notification/NotificationPersister.php | 1 - .../Notification/NotificationPersisterInterface.php | 1 - .../Notification/NotificationPresence.php | 1 - .../Templating/NotificationTwigExtension.php | 1 - .../Templating/NotificationTwigExtensionRuntime.php | 1 - .../ChillMainBundle/Pagination/ChillItemsPerPageTwig.php | 1 - .../ChillMainBundle/Pagination/ChillPaginationTwig.php | 1 - src/Bundle/ChillMainBundle/Pagination/Page.php | 1 - src/Bundle/ChillMainBundle/Pagination/PageGenerator.php | 1 - src/Bundle/ChillMainBundle/Pagination/PageInterface.php | 1 - src/Bundle/ChillMainBundle/Pagination/Paginator.php | 1 - .../ChillMainBundle/Pagination/PaginatorFactory.php | 1 - .../ChillMainBundle/Pagination/PaginatorInterface.php | 1 - .../Phonenumber/PhoneNumberHelperInterface.php | 1 - .../ChillMainBundle/Phonenumber/PhonenumberHelper.php | 1 - src/Bundle/ChillMainBundle/Phonenumber/Templating.php | 1 - src/Bundle/ChillMainBundle/Redis/ChillRedis.php | 1 - .../ChillMainBundle/Redis/RedisConnectionFactory.php | 1 - .../Repository/AddressReferenceRepository.php | 1 - .../ChillMainBundle/Repository/AddressRepository.php | 1 - .../Repository/CenterRepositoryInterface.php | 1 - .../ChillMainBundle/Repository/CivilityRepository.php | 1 - .../ChillMainBundle/Repository/CountryRepository.php | 1 - .../Repository/GeographicalUnitLayerLayerRepository.php | 1 - .../GeographicalUnitLayerRepositoryInterface.php | 1 - .../Repository/GeographicalUnitRepository.php | 1 - .../Repository/GeographicalUnitRepositoryInterface.php | 1 - .../ChillMainBundle/Repository/GroupCenterRepository.php | 1 - .../ChillMainBundle/Repository/LanguageRepository.php | 1 - .../ChillMainBundle/Repository/LocationRepository.php | 1 - .../Repository/LocationTypeRepository.php | 1 - .../Repository/NotificationRepository.php | 1 - .../Repository/PermissionsGroupRepository.php | 1 - .../ChillMainBundle/Repository/PostalCodeRepository.php | 1 - .../ChillMainBundle/Repository/RoleScopeRepository.php | 1 - .../Repository/ScopeRepositoryInterface.php | 1 - .../Repository/UserACLAwareRepository.php | 1 - .../Repository/UserACLAwareRepositoryInterface.php | 1 - .../ChillMainBundle/Repository/UserJobRepository.php | 1 - src/Bundle/ChillMainBundle/Repository/UserRepository.php | 1 - .../Repository/UserRepositoryInterface.php | 9 ++++++++- .../Repository/Workflow/EntityWorkflowRepository.php | 1 - .../Repository/Workflow/EntityWorkflowStepRepository.php | 1 - .../ChillMainBundle/Routing/Loader/ChillRoutesLoader.php | 1 - .../Routing/LocalMenuBuilderInterface.php | 1 - .../Routing/MenuBuilder/AdminLanguageMenuBuilder.php | 1 - .../Routing/MenuBuilder/AdminLocationMenuBuilder.php | 1 - .../Routing/MenuBuilder/AdminUserMenuBuilder.php | 1 - .../Routing/MenuBuilder/SectionMenuBuilder.php | 1 - .../Routing/MenuBuilder/UserMenuBuilder.php | 1 - src/Bundle/ChillMainBundle/Routing/MenuComposer.php | 1 - src/Bundle/ChillMainBundle/Routing/MenuTwig.php | 1 - src/Bundle/ChillMainBundle/Search/AbstractSearch.php | 1 - .../Search/Entity/SearchUserApiProvider.php | 1 - .../Search/HasAdvancedSearchFormInterface.php | 1 - src/Bundle/ChillMainBundle/Search/Model/Result.php | 1 - src/Bundle/ChillMainBundle/Search/ParsingException.php | 1 - src/Bundle/ChillMainBundle/Search/SearchApi.php | 1 - src/Bundle/ChillMainBundle/Search/SearchApiInterface.php | 1 - .../ChillMainBundle/Search/SearchApiNoQueryException.php | 1 - src/Bundle/ChillMainBundle/Search/SearchApiQuery.php | 1 - src/Bundle/ChillMainBundle/Search/SearchApiResult.php | 1 - src/Bundle/ChillMainBundle/Search/SearchInterface.php | 1 - src/Bundle/ChillMainBundle/Search/SearchProvider.php | 1 - .../Search/UnknowSearchDomainException.php | 1 - .../ChillMainBundle/Search/UnknowSearchNameException.php | 1 - .../Search/Utils/ExtractDateFromPattern.php | 1 - .../Search/Utils/ExtractPhonenumberFromPattern.php | 1 - .../Search/Utils/SearchExtractionResult.php | 1 - .../Security/Authorization/AbstractChillVoter.php | 1 - .../Security/Authorization/AuthorizationHelper.php | 1 - .../Authorization/AuthorizationHelperInterface.php | 1 - .../Security/Authorization/ChillVoterInterface.php | 1 - .../Security/Authorization/DefaultVoterHelper.php | 1 - .../Security/Authorization/DefaultVoterHelperFactory.php | 1 - .../Authorization/DefaultVoterHelperGenerator.php | 1 - .../Security/Authorization/EntityWorkflowVoter.php | 1 - .../Security/Authorization/NotificationVoter.php | 1 - .../Security/Authorization/VoterGeneratorInterface.php | 1 - .../Authorization/VoterHelperFactoryInterface.php | 1 - .../Security/Authorization/VoterHelperInterface.php | 1 - .../Authorization/WorkflowEntityDeletionVoter.php | 1 - src/Bundle/ChillMainBundle/Security/ParentRoleHelper.php | 1 - .../Security/PasswordRecover/PasswordRecoverEvent.php | 1 - .../PasswordRecover/PasswordRecoverEventSubscriber.php | 1 - .../Security/PasswordRecover/PasswordRecoverLocker.php | 1 - .../Security/PasswordRecover/PasswordRecoverVoter.php | 1 - .../Security/PasswordRecover/RecoverPasswordHelper.php | 1 - .../Security/PasswordRecover/TokenManager.php | 1 - .../Security/ProvideRoleHierarchyInterface.php | 1 - .../ChillMainBundle/Security/ProvideRoleInterface.php | 1 - .../Security/Resolver/CenterResolverDispatcher.php | 1 - .../Resolver/CenterResolverDispatcherInterface.php | 1 - .../Security/Resolver/CenterResolverInterface.php | 1 - .../Security/Resolver/CenterResolverManager.php | 1 - .../Security/Resolver/CenterResolverManagerInterface.php | 1 - .../Security/Resolver/DefaultCenterResolver.php | 1 - .../Security/Resolver/DefaultScopeResolver.php | 1 - .../Security/Resolver/ResolverTwigExtension.php | 1 - .../Security/Resolver/ScopeResolverDispatcher.php | 1 - .../Security/Resolver/ScopeResolverInterface.php | 1 - src/Bundle/ChillMainBundle/Security/RoleProvider.php | 1 - .../Security/UserProvider/UserProvider.php | 1 - .../ChillMainBundle/Serializer/Model/Collection.php | 1 - src/Bundle/ChillMainBundle/Serializer/Model/Counter.php | 1 - .../Serializer/Normalizer/AddressNormalizer.php | 1 - .../Serializer/Normalizer/CenterNormalizer.php | 1 - .../Serializer/Normalizer/CollectionNormalizer.php | 1 - .../Normalizer/CommentEmbeddableDocGenNormalizer.php | 1 - .../Serializer/Normalizer/DateNormalizer.php | 1 - .../Normalizer/DiscriminatedObjectDenormalizer.php | 1 - .../Normalizer/DoctrineExistingEntityNormalizer.php | 1 - .../Serializer/Normalizer/EntityWorkflowNormalizer.php | 1 - .../Normalizer/EntityWorkflowStepNormalizer.php | 1 - .../Serializer/Normalizer/NotificationNormalizer.php | 1 - .../Serializer/Normalizer/PhonenumberNormalizer.php | 1 - .../Serializer/Normalizer/PointNormalizer.php | 1 - .../Normalizer/PrivateCommentEmbeddableNormalizer.php | 1 - .../Serializer/Normalizer/UserNormalizer.php | 1 - .../Service/Import/AddressReferenceBEFromBestAddress.php | 1 - .../Service/Import/AddressReferenceBaseImporter.php | 1 - .../Service/Import/AddressReferenceFromBano.php | 1 - .../Service/Import/GeographicalUnitBaseImporter.php | 1 - .../Service/Import/PostalCodeBEFromBestAddress.php | 1 - .../Service/Import/PostalCodeBaseImporter.php | 1 - .../Service/Import/PostalCodeFRFromOpenData.php | 1 - .../ChillMainBundle/Service/Mailer/ChillMailer.php | 1 - .../Service/ShortMessage/NullShortMessageSender.php | 9 ++++++++- .../Service/ShortMessage/ShortMessage.php | 9 ++++++++- .../Service/ShortMessage/ShortMessageHandler.php | 9 ++++++++- .../Service/ShortMessage/ShortMessageSenderInterface.php | 9 ++++++++- .../Service/ShortMessage/ShortMessageTransporter.php | 9 ++++++++- .../ShortMessage/ShortMessageTransporterInterface.php | 9 ++++++++- .../Service/ShortMessageOvh/OvhShortMessageSender.php | 9 ++++++++- src/Bundle/ChillMainBundle/Templating/CSVCellTwig.php | 1 - .../Templating/ChillMarkdownRenderExtension.php | 1 - .../ChillMainBundle/Templating/ChillTwigHelper.php | 1 - .../Templating/ChillTwigRoutingHelper.php | 1 - .../Templating/Entity/AbstractChillEntityRender.php | 1 - .../ChillMainBundle/Templating/Entity/AddressRender.php | 1 - .../Templating/Entity/ChillEntityRender.php | 1 - .../Templating/Entity/ChillEntityRenderExtension.php | 1 - .../Templating/Entity/ChillEntityRenderInterface.php | 1 - .../ChillMainBundle/Templating/Entity/CommentRender.php | 1 - .../ChillMainBundle/Templating/Entity/UserRender.php | 1 - .../Templating/Events/DelegatedBlockRenderingEvent.php | 1 - .../Templating/Listing/FilterOrderHelper.php | 1 - .../Templating/Listing/FilterOrderHelperBuilder.php | 1 - .../Templating/Listing/FilterOrderHelperFactory.php | 1 - .../Listing/FilterOrderHelperFactoryInterface.php | 1 - .../ChillMainBundle/Templating/Listing/Templating.php | 1 - .../Templating/TranslatableStringHelper.php | 1 - .../Templating/TranslatableStringHelperInterface.php | 1 - .../Templating/TranslatableStringTwig.php | 1 - .../Templating/UI/CountNotificationUser.php | 1 - .../Templating/UI/NotificationCounterInterface.php | 1 - .../Templating/Widget/WidgetInterface.php | 1 - .../Templating/Widget/WidgetRenderingTwig.php | 1 - .../Test/Export/AbstractAggregatorTest.php | 1 - .../ChillMainBundle/Test/Export/AbstractExportTest.php | 1 - .../ChillMainBundle/Test/Export/AbstractFilterTest.php | 1 - src/Bundle/ChillMainBundle/Test/PrepareCenterTrait.php | 1 - src/Bundle/ChillMainBundle/Test/PrepareCircleTrait.php | 1 - src/Bundle/ChillMainBundle/Test/PrepareClientTrait.php | 1 - src/Bundle/ChillMainBundle/Test/PrepareScopeTrait.php | 1 - src/Bundle/ChillMainBundle/Test/PrepareUserTrait.php | 1 - .../Tests/Authorization/ParentRoleHelperTest.php | 1 - .../Tests/Controller/AddressControllerTest.php | 1 - .../Controller/AddressReferenceApiControllerTest.php | 1 - .../Tests/Controller/CenterControllerTest.php | 1 - .../Tests/Controller/ExportControllerTest.php | 1 - .../Tests/Controller/LoginControllerTest.php | 1 - .../Tests/Controller/NotificationApiControllerTest.php | 1 - .../Tests/Controller/PermissionApiControllerTest.php | 1 - .../Tests/Controller/PermissionsGroupControllerTest.php | 1 - .../Tests/Controller/PostalCodeApiControllerTest.php | 1 - .../Tests/Controller/ScopeControllerTest.php | 1 - .../Tests/Controller/SearchApiControllerTest.php | 1 - .../Tests/Controller/SearchControllerTest.php | 1 - .../Tests/Controller/UserApiControllerTest.php | 1 - .../Tests/Controller/UserControllerTest.php | 1 - .../ChillMainBundle/Tests/Doctrine/Model/PointTest.php | 1 - .../ChillMainBundle/Tests/Entity/NotificationTest.php | 1 - .../Tests/Entity/Workflow/EntityWorkflowTest.php | 1 - .../ChillMainBundle/Tests/Export/ExportManagerTest.php | 1 - .../DataTransformer/IdToEntityDataTransformerTest.php | 9 ++++++++- .../Tests/Form/Type/PickCenterTypeTest.php | 1 - ...PersistNotificationOnTerminateEventSubscriberTest.php | 1 - src/Bundle/ChillMainBundle/Tests/Pagination/PageTest.php | 1 - .../ChillMainBundle/Tests/Pagination/PaginatorTest.php | 1 - .../Tests/Phonenumber/PhonenumberHelperTest.php | 1 - .../Tests/Routing/Loader/RouteLoaderTest.php | 1 - .../ChillMainBundle/Tests/Search/AbstractSearchTest.php | 1 - .../ChillMainBundle/Tests/Search/SearchApiQueryTest.php | 1 - .../ChillMainBundle/Tests/Search/SearchProviderTest.php | 1 - .../Tests/Search/Utils/ExtractDateFromPatternTest.php | 1 - .../Search/Utils/ExtractPhonenumberFromPatternTest.php | 1 - .../Security/Authorization/AuthorizationHelperTest.php | 1 - .../Tests/Security/PasswordRecover/TokenManagerTest.php | 1 - .../Security/Resolver/CenterResolverDispatcherTest.php | 1 - .../Tests/Security/Resolver/DefaultScopeResolverTest.php | 1 - .../Security/Resolver/ScopeResolverDispatcherTest.php | 1 - .../Tests/Serializer/Normalizer/DateNormalizerTest.php | 1 - .../Normalizer/DoctrineExistingEntityNormalizerTest.php | 1 - .../Serializer/Normalizer/PhonenumberNormalizerTest.php | 1 - .../Services/Import/AddressReferenceBaseImporterTest.php | 1 - .../Services/Import/GeographicalUnitBaseImporterTest.php | 1 - .../Tests/Services/Import/PostalCodeBaseImporterTest.php | 1 - .../ChillMainBundle/Tests/Services/MenuComposerTest.php | 1 - .../Templating/ChillMarkdownRenderExtensionTest.php | 1 - .../Tests/Templating/Entity/AddressRenderTest.php | 1 - src/Bundle/ChillMainBundle/Tests/TestHelper.php | 1 - .../ChillMainBundle/Tests/Util/CountriesInfoTest.php | 1 - .../ChillMainBundle/Tests/Util/DateRangeCoveringTest.php | 1 - .../EventSubscriber/NotificationOnTransitionTest.php | 1 - src/Bundle/ChillMainBundle/Timeline/TimelineBuilder.php | 1 - .../Timeline/TimelineProviderInterface.php | 1 - .../ChillMainBundle/Timeline/TimelineSingleQuery.php | 1 - src/Bundle/ChillMainBundle/Util/CountriesInfo.php | 1 - src/Bundle/ChillMainBundle/Util/DateRangeCovering.php | 1 - .../Validation/Constraint/PhonenumberConstraint.php | 1 - .../Constraint/RoleScopeScopePresenceConstraint.php | 1 - .../Constraint/UserUniqueEmailAndUsernameConstraint.php | 1 - .../Validation/Validator/RoleScopeScopePresence.php | 1 - .../Validation/Validator/UserUniqueEmailAndUsername.php | 1 - .../Validation/Validator/ValidPhonenumber.php | 1 - .../Constraints/Entity/UserCircleConsistency.php | 1 - .../Entity/UserCircleConsistencyValidator.php | 1 - .../Constraints/Export/ExportElementConstraint.php | 1 - .../Export/ExportElementConstraintValidator.php | 1 - .../Workflow/Counter/WorkflowByUserCounter.php | 1 - .../Workflow/EntityWorkflowHandlerInterface.php | 1 - .../ChillMainBundle/Workflow/EntityWorkflowManager.php | 1 - .../EntityWorkflowTransitionEventSubscriber.php | 1 - .../EventSubscriber/NotificationOnTransition.php | 1 - .../EventSubscriber/SendAccessKeyEventSubscriber.php | 1 - .../Workflow/Exception/HandlerNotFoundException.php | 1 - .../Workflow/Helper/MetadataExtractor.php | 1 - .../Notification/WorkflowNotificationHandler.php | 1 - .../Workflow/RelatedEntityWorkflowSupportsStrategy.php | 1 - .../Workflow/Templating/WorkflowTwigExtension.php | 1 - .../Workflow/Templating/WorkflowTwigExtensionRuntime.php | 1 - .../Workflow/Validator/EntityWorkflowCreation.php | 1 - .../Validator/EntityWorkflowCreationValidator.php | 1 - .../ChillMainBundle/Workflow/Validator/StepDestValid.php | 1 - .../Workflow/Validator/StepDestValidValidator.php | 1 - .../ChillMainBundle/migrations/Version20100000000000.php | 1 - .../ChillMainBundle/migrations/Version20141128194409.php | 1 - .../ChillMainBundle/migrations/Version20150821105642.php | 1 - .../ChillMainBundle/migrations/Version20150821122935.php | 1 - .../ChillMainBundle/migrations/Version20160310122322.php | 1 - .../ChillMainBundle/migrations/Version20180703191509.php | 1 - .../ChillMainBundle/migrations/Version20180709181423.php | 1 - .../ChillMainBundle/migrations/Version20180905101426.php | 1 - .../ChillMainBundle/migrations/Version20180911093642.php | 1 - .../ChillMainBundle/migrations/Version20200422122715.php | 1 - .../ChillMainBundle/migrations/Version20210304085819.php | 1 - .../ChillMainBundle/migrations/Version20210308111926.php | 1 - .../ChillMainBundle/migrations/Version20210414091001.php | 1 - .../ChillMainBundle/migrations/Version20210420115006.php | 1 - .../ChillMainBundle/migrations/Version20210503085107.php | 1 - .../ChillMainBundle/migrations/Version20210505153727.php | 1 - .../ChillMainBundle/migrations/Version20210525144016.php | 1 - .../ChillMainBundle/migrations/Version20210528090000.php | 1 - .../ChillMainBundle/migrations/Version20210610140248.php | 1 - .../ChillMainBundle/migrations/Version20210616134328.php | 1 - .../ChillMainBundle/migrations/Version20210903144853.php | 1 - .../ChillMainBundle/migrations/Version20210929192242.php | 1 - .../ChillMainBundle/migrations/Version20211006151653.php | 1 - .../ChillMainBundle/migrations/Version20211007150019.php | 1 - .../ChillMainBundle/migrations/Version20211012141336.php | 1 - .../ChillMainBundle/migrations/Version20211013124455.php | 1 - .../ChillMainBundle/migrations/Version20211015084653.php | 1 - .../ChillMainBundle/migrations/Version20211022094429.php | 1 - .../ChillMainBundle/migrations/Version20211116162847.php | 1 - .../ChillMainBundle/migrations/Version20211119173554.php | 1 - .../ChillMainBundle/migrations/Version20211123093355.php | 1 - .../ChillMainBundle/migrations/Version20211125142016.php | 1 - .../ChillMainBundle/migrations/Version20211125142017.php | 1 - .../ChillMainBundle/migrations/Version20211213112628.php | 1 - .../ChillMainBundle/migrations/Version20211216213649.php | 1 - .../ChillMainBundle/migrations/Version20211225231532.php | 1 - .../ChillMainBundle/migrations/Version20211228183221.php | 1 - .../ChillMainBundle/migrations/Version20211228215919.php | 1 - .../ChillMainBundle/migrations/Version20211229140308.php | 1 - .../ChillMainBundle/migrations/Version20211230003532.php | 1 - .../ChillMainBundle/migrations/Version20220112123436.php | 1 - .../ChillMainBundle/migrations/Version20220112150413.php | 1 - .../ChillMainBundle/migrations/Version20220112161136.php | 1 - .../ChillMainBundle/migrations/Version20220114132105.php | 1 - .../ChillMainBundle/migrations/Version20220114165950.php | 1 - .../ChillMainBundle/migrations/Version20220120155303.php | 1 - .../ChillMainBundle/migrations/Version20220124085957.php | 1 - .../ChillMainBundle/migrations/Version20220125134253.php | 1 - .../ChillMainBundle/migrations/Version20220128211748.php | 1 - .../ChillMainBundle/migrations/Version20220217133607.php | 1 - .../ChillMainBundle/migrations/Version20220223171457.php | 1 - .../ChillMainBundle/migrations/Version20220302132728.php | 1 - .../ChillMainBundle/migrations/Version20220325134944.php | 1 - .../ChillMainBundle/migrations/Version20220413154743.php | 1 - .../ChillMainBundle/migrations/Version20220413225830.php | 1 - .../ChillMainBundle/migrations/Version20220413230159.php | 1 - .../ChillMainBundle/migrations/Version20220506131307.php | 1 - .../ChillMainBundle/migrations/Version20220506145935.php | 1 - .../ChillMainBundle/migrations/Version20220506223243.php | 9 ++++++++- .../ChillMainBundle/migrations/Version20220513151853.php | 1 - .../ChillMainBundle/migrations/Version20220516085659.php | 1 - .../ChillMainBundle/migrations/Version20220711150006.php | 1 - .../ChillMainBundle/migrations/Version20220729205416.php | 1 - .../ChillMainBundle/migrations/Version20220730204216.php | 1 - .../ChillMainBundle/migrations/Version20220829132409.php | 1 - .../ChillMainBundle/migrations/Version20220913174922.php | 1 - .../ChillMainBundle/migrations/Version20221003112151.php | 1 - .../ChillMainBundle/migrations/Version20221003132620.php | 1 - .../Events/PersonAddressMoveEventSubscriber.php | 1 - .../AccompanyingPeriod/Events/UserRefEventSubscriber.php | 1 - ...anyingPeriodLinkedWithSocialIssuesEntityInterface.php | 1 - ...panyingPeriodSocialIssueConsistencyEntityListener.php | 1 - .../Suggestion/ReferralsSuggestion.php | 1 - .../Suggestion/ReferralsSuggestionInterface.php | 1 - src/Bundle/ChillPersonBundle/Actions/ActionEvent.php | 1 - .../ChillPersonBundle/Actions/Remove/PersonMove.php | 1 - .../CRUD/Controller/EntityPersonCRUDController.php | 1 - .../Controller/OneToOneEntityPersonCRUDController.php | 1 - src/Bundle/ChillPersonBundle/ChillPersonBundle.php | 1 - .../ChillPersonBundle/Command/ChillPersonMoveCommand.php | 1 - .../Command/ImportPeopleFromCSVCommand.php | 1 - .../Command/ImportSocialWorkMetadata.php | 1 - .../Command/RemoveOldDraftAccompanyingPeriodCommand.php | 1 - .../Config/ConfigPersonAltNamesHelper.php | 1 - .../Controller/AccompanyingCourseApiController.php | 1 - .../Controller/AccompanyingCourseCommentController.php | 1 - .../Controller/AccompanyingCourseController.php | 1 - .../Controller/AccompanyingCourseWorkApiController.php | 1 - .../Controller/AccompanyingCourseWorkController.php | 1 - .../Controller/AccompanyingPeriodController.php | 1 - .../AccompanyingPeriodRegulationListController.php | 1 - .../AccompanyingPeriodWorkEvaluationApiController.php | 1 - .../ChillPersonBundle/Controller/AdminController.php | 1 - .../Controller/ClosingMotiveController.php | 1 - .../Controller/HouseholdApiController.php | 1 - .../Controller/HouseholdCompositionController.php | 1 - .../Controller/HouseholdCompositionTypeApiController.php | 1 - .../Controller/HouseholdCompositionTypeController.php | 1 - .../ChillPersonBundle/Controller/HouseholdController.php | 1 - .../Controller/HouseholdMemberController.php | 1 - .../Controller/HouseholdPositionController.php | 1 - .../Controller/MaritalStatusController.php | 1 - .../Controller/OpeningApiController.php | 1 - .../ChillPersonBundle/Controller/OriginController.php | 1 - .../Controller/PersonAddressController.php | 1 - .../ChillPersonBundle/Controller/PersonApiController.php | 1 - .../ChillPersonBundle/Controller/PersonController.php | 1 - .../Controller/PersonDuplicateController.php | 1 - .../Controller/PersonResourceController.php | 1 - .../Controller/PersonResourceKindController.php | 1 - .../Controller/ReassignAccompanyingPeriodController.php | 1 - .../ChillPersonBundle/Controller/RelationController.php | 1 - .../Controller/RelationshipApiController.php | 1 - .../Controller/ResidentialAddressController.php | 1 - .../Controller/SocialIssueApiController.php | 1 - .../Controller/SocialWork/EvaluationController.php | 1 - .../Controller/SocialWork/GoalController.php | 1 - .../Controller/SocialWork/ResultController.php | 1 - .../Controller/SocialWork/SocialActionController.php | 1 - .../Controller/SocialWork/SocialIssueController.php | 1 - .../Controller/SocialWorkEvaluationApiController.php | 1 - .../Controller/SocialWorkGoalApiController.php | 1 - .../Controller/SocialWorkResultApiController.php | 1 - .../Controller/SocialWorkSocialActionApiController.php | 1 - .../Controller/TimelinePersonController.php | 1 - .../Controller/UserAccompanyingPeriodController.php | 1 - .../DataFixtures/Helper/PersonRandomHelper.php | 1 - .../DataFixtures/Helper/RandomPersonHelperTrait.php | 1 - .../ORM/LoadAccompanyingPeriodClosingMotive.php | 1 - .../ORM/LoadAccompanyingPeriodNotifications.php | 1 - .../DataFixtures/ORM/LoadAccompanyingPeriodOrigin.php | 1 - .../DataFixtures/ORM/LoadAccompanyingPeriodWork.php | 1 - .../DataFixtures/ORM/LoadCustomFields.php | 1 - .../ChillPersonBundle/DataFixtures/ORM/LoadHousehold.php | 1 - .../DataFixtures/ORM/LoadHouseholdCompositionType.php | 1 - .../DataFixtures/ORM/LoadHouseholdPosition.php | 1 - .../DataFixtures/ORM/LoadMaritalStatus.php | 1 - .../ChillPersonBundle/DataFixtures/ORM/LoadPeople.php | 1 - .../ChillPersonBundle/DataFixtures/ORM/LoadPersonACL.php | 1 - .../ChillPersonBundle/DataFixtures/ORM/LoadRelations.php | 1 - .../DataFixtures/ORM/LoadRelationships.php | 1 - .../DataFixtures/ORM/LoadSocialWorkMetadata.php | 1 - .../DependencyInjection/ChillPersonExtension.php | 1 - .../AccompanyingPeriodTimelineCompilerPass.php | 1 - .../DependencyInjection/Configuration.php | 1 - .../ChillPersonBundle/Doctrine/DQL/AddressPart.php | 1 - .../Doctrine/DQL/AddressPart/AddressPartAddressId.php | 1 - .../Doctrine/DQL/AddressPart/AddressPartCountryCode.php | 1 - .../Doctrine/DQL/AddressPart/AddressPartCountryId.php | 1 - .../Doctrine/DQL/AddressPart/AddressPartCountryName.php | 1 - .../Doctrine/DQL/AddressPart/AddressPartIsNoAddress.php | 1 - .../Doctrine/DQL/AddressPart/AddressPartPostCodeCode.php | 1 - .../Doctrine/DQL/AddressPart/AddressPartPostCodeId.php | 1 - .../DQL/AddressPart/AddressPartPostCodeLabel.php | 1 - .../DQL/AddressPart/AddressPartStreetAddress1.php | 1 - .../DQL/AddressPart/AddressPartStreetAddress2.php | 1 - .../Doctrine/DQL/AddressPart/AddressPartValidFrom.php | 1 - .../ChillPersonBundle/Entity/AccompanyingPeriod.php | 1 - .../AccompanyingPeriodLocationHistory.php | 1 - .../Entity/AccompanyingPeriod/AccompanyingPeriodWork.php | 1 - .../AccompanyingPeriodWorkEvaluation.php | 1 - .../AccompanyingPeriodWorkEvaluationDocument.php | 1 - .../AccompanyingPeriod/AccompanyingPeriodWorkGoal.php | 1 - .../Entity/AccompanyingPeriod/ClosingMotive.php | 1 - .../Entity/AccompanyingPeriod/Comment.php | 1 - .../Entity/AccompanyingPeriod/Origin.php | 1 - .../Entity/AccompanyingPeriod/Resource.php | 1 - .../Entity/AccompanyingPeriod/UserHistory.php | 1 - .../Entity/AccompanyingPeriodParticipation.php | 1 - src/Bundle/ChillPersonBundle/Entity/HasPerson.php | 1 - .../ChillPersonBundle/Entity/Household/Household.php | 1 - .../Entity/Household/HouseholdComposition.php | 1 - .../Entity/Household/HouseholdCompositionType.php | 1 - .../Entity/Household/HouseholdMember.php | 1 - .../Entity/Household/PersonHouseholdAddress.php | 1 - .../ChillPersonBundle/Entity/Household/Position.php | 1 - src/Bundle/ChillPersonBundle/Entity/MaritalStatus.php | 1 - .../Entity/Person/PersonCenterCurrent.php | 1 - .../Entity/Person/PersonCenterHistory.php | 1 - .../Entity/Person/PersonCurrentAddress.php | 1 - .../ChillPersonBundle/Entity/Person/PersonResource.php | 1 - .../Entity/Person/PersonResourceKind.php | 1 - .../Entity/Person/ResidentialAddress.php | 1 - src/Bundle/ChillPersonBundle/Entity/PersonAltName.php | 1 - .../ChillPersonBundle/Entity/PersonNotDuplicate.php | 1 - src/Bundle/ChillPersonBundle/Entity/PersonPhone.php | 1 - .../ChillPersonBundle/Entity/Relationships/Relation.php | 1 - .../Entity/Relationships/Relationship.php | 1 - .../ChillPersonBundle/Entity/SocialWork/Evaluation.php | 1 - src/Bundle/ChillPersonBundle/Entity/SocialWork/Goal.php | 1 - .../ChillPersonBundle/Entity/SocialWork/Result.php | 1 - .../ChillPersonBundle/Entity/SocialWork/SocialAction.php | 1 - .../ChillPersonBundle/Entity/SocialWork/SocialIssue.php | 1 - .../Event/Person/PersonAddressMoveEvent.php | 1 - .../AccompanyingPeriodWorkEventListener.php | 1 - .../EventListener/PersonEventListener.php | 1 - .../GeographicalUnitStatAggregator.php | 1 - .../ReferrerScopeAggregator.php | 1 - .../RequestorAggregator.php | 1 - .../PersonAggregators/GeographicalUnitAggregator.php | 1 - .../SocialWorkAggregators/GoalResultAggregator.php | 1 - src/Bundle/ChillPersonBundle/Export/Declarations.php | 1 - .../Filter/PersonFilters/GeographicalUnitFilter.php | 5 ++--- .../Export/Filter/PersonFilters/MaritalStatusFilter.php | 1 - .../Form/AccompanyingCourseCommentType.php | 1 - .../ChillPersonBundle/Form/AccompanyingCourseType.php | 1 - .../ChillPersonBundle/Form/AccompanyingPeriodType.php | 1 - .../Form/ChoiceLoader/PersonChoiceLoader.php | 1 - src/Bundle/ChillPersonBundle/Form/ClosingMotiveType.php | 1 - src/Bundle/ChillPersonBundle/Form/CreationPersonType.php | 1 - .../Form/DataMapper/PersonAltNameDataMapper.php | 1 - .../Form/DataTransformer/PersonToIdTransformer.php | 1 - .../Form/DataTransformer/PersonsToIdDataTransformer.php | 9 ++++++++- .../ChillPersonBundle/Form/HouseholdCompositionType.php | 1 - .../Form/HouseholdCompositionTypeType.php | 1 - .../ChillPersonBundle/Form/HouseholdMemberType.php | 1 - .../ChillPersonBundle/Form/HouseholdPositionType.php | 1 - src/Bundle/ChillPersonBundle/Form/HouseholdType.php | 1 - src/Bundle/ChillPersonBundle/Form/MaritalStatusType.php | 1 - src/Bundle/ChillPersonBundle/Form/OriginType.php | 1 - .../ChillPersonBundle/Form/PersonConfimDuplicateType.php | 1 - .../Form/PersonFindManuallyDuplicateType.php | 1 - .../ChillPersonBundle/Form/PersonResourceKindType.php | 1 - src/Bundle/ChillPersonBundle/Form/PersonResourceType.php | 1 - src/Bundle/ChillPersonBundle/Form/PersonType.php | 1 - src/Bundle/ChillPersonBundle/Form/RelationType.php | 1 - .../ChillPersonBundle/Form/ResidentialAddressType.php | 1 - .../ChillPersonBundle/Form/SocialWork/EvaluationType.php | 1 - .../ChillPersonBundle/Form/SocialWork/GoalType.php | 1 - .../ChillPersonBundle/Form/SocialWork/ResultType.php | 1 - .../Form/SocialWork/SocialActionType.php | 1 - .../Form/SocialWork/SocialIssueType.php | 1 - .../Form/Type/ClosingMotivePickerType.php | 1 - src/Bundle/ChillPersonBundle/Form/Type/GenderType.php | 1 - .../ChillPersonBundle/Form/Type/PersonAltNameType.php | 1 - .../ChillPersonBundle/Form/Type/PersonPhoneType.php | 1 - .../Form/Type/PickPersonDynamicType.php | 1 - .../ChillPersonBundle/Form/Type/PickPersonType.php | 1 - .../Form/Type/Select2MaritalStatusType.php | 1 - src/Bundle/ChillPersonBundle/Household/MembersEditor.php | 1 - .../ChillPersonBundle/Household/MembersEditorFactory.php | 1 - .../Menu/AccompanyingCourseMenuBuilder.php | 1 - .../Menu/AdminAccompanyingCourseMenuBuilder.php | 1 - .../ChillPersonBundle/Menu/AdminHouseholdMenuBuilder.php | 1 - .../ChillPersonBundle/Menu/AdminPersonMenuBuilder.php | 1 - .../Menu/AdminSocialWorkMenuBuilder.php | 1 - .../ChillPersonBundle/Menu/HouseholdMenuBuilder.php | 1 - src/Bundle/ChillPersonBundle/Menu/PersonMenuBuilder.php | 1 - src/Bundle/ChillPersonBundle/Menu/SectionMenuBuilder.php | 1 - src/Bundle/ChillPersonBundle/Menu/UserMenuBuilder.php | 1 - .../AccompanyingPeriodNotificationHandler.php | 1 - .../Privacy/AccompanyingPeriodPrivacyEvent.php | 1 - src/Bundle/ChillPersonBundle/Privacy/PrivacyEvent.php | 1 - .../ChillPersonBundle/Privacy/PrivacyEventSubscriber.php | 1 - ...ccompanyingPeriodWorkEvaluationDocumentRepository.php | 1 - .../AccompanyingPeriodWorkEvaluationRepository.php | 1 - .../AccompanyingPeriodWorkGoalRepository.php | 1 - .../AccompanyingPeriodWorkRepository.php | 1 - .../ClosingMotiveRepositoryInterface.php | 1 - .../Repository/AccompanyingPeriod/CommentRepository.php | 1 - .../Repository/AccompanyingPeriod/OriginRepository.php | 1 - .../Repository/AccompanyingPeriod/ResourceRepository.php | 1 - .../Repository/AccompanyingPeriodACLAwareRepository.php | 1 - .../AccompanyingPeriodACLAwareRepositoryInterface.php | 1 - .../AccompanyingPeriodParticipationRepository.php | 1 - .../Repository/AccompanyingPeriodRepository.php | 1 - .../Repository/Household/HouseholdACLAwareRepository.php | 1 - .../Household/HouseholdACLAwareRepositoryInterface.php | 1 - .../Household/HouseholdCompositionRepository.php | 1 - .../Household/HouseholdCompositionTypeRepository.php | 1 - .../Repository/Household/HouseholdMembersRepository.php | 1 - .../Repository/Household/HouseholdRepository.php | 1 - .../Household/PersonHouseholdAddressRepository.php | 1 - .../Repository/Household/PositionRepository.php | 1 - .../Repository/MaritalStatusRepository.php | 1 - .../Repository/Person/PersonCenterHistoryInterface.php | 1 - .../Repository/Person/PersonCenterHistoryRepository.php | 1 - .../Repository/PersonACLAwareRepositoryInterface.php | 1 - .../Repository/PersonAltNameRepository.php | 1 - .../Repository/PersonNotDuplicateRepository.php | 1 - .../ChillPersonBundle/Repository/PersonRepository.php | 1 - .../Repository/PersonResourceRepository.php | 1 - .../Repository/Relationships/RelationRepository.php | 1 - .../Repository/Relationships/RelationshipRepository.php | 1 - .../Repository/ResidentialAddressRepository.php | 1 - .../Repository/SocialWork/EvaluationRepository.php | 1 - .../Repository/SocialWork/GoalRepository.php | 1 - .../Repository/SocialWork/ResultRepository.php | 1 - .../Repository/SocialWork/SocialActionRepository.php | 1 - .../Repository/SocialWork/SocialIssueRepository.php | 1 - src/Bundle/ChillPersonBundle/Search/PersonSearch.php | 1 - .../Search/SearchHouseholdApiProvider.php | 1 - .../ChillPersonBundle/Search/SearchPersonApiProvider.php | 1 - .../ChillPersonBundle/Search/SimilarPersonMatcher.php | 1 - .../Authorization/AccompanyingPeriodCommentVoter.php | 1 - .../Authorization/AccompanyingPeriodResourceVoter.php | 1 - .../AccompanyingPeriodWorkEvaluationDocumentVoter.php | 1 - .../AccompanyingPeriodWorkEvaluationVoter.php | 1 - .../Authorization/AccompanyingPeriodWorkVoter.php | 1 - .../Security/Authorization/PersonVoter.php | 1 - .../Normalizer/AccompanyingPeriodDocGenNormalizer.php | 1 - .../Normalizer/AccompanyingPeriodOriginNormalizer.php | 1 - .../AccompanyingPeriodParticipationNormalizer.php | 1 - .../Normalizer/AccompanyingPeriodResourceNormalizer.php | 1 - .../Normalizer/AccompanyingPeriodWorkDenormalizer.php | 1 - .../AccompanyingPeriodWorkEvaluationDenormalizer.php | 1 - ...ccompanyingPeriodWorkEvaluationDocumentNormalizer.php | 1 - .../AccompanyingPeriodWorkEvaluationNormalizer.php | 1 - .../Normalizer/AccompanyingPeriodWorkNormalizer.php | 1 - .../Serializer/Normalizer/MembersEditorNormalizer.php | 1 - .../Serializer/Normalizer/PersonDocGenNormalizer.php | 1 - .../Serializer/Normalizer/PersonJsonNormalizer.php | 1 - .../Normalizer/PersonJsonNormalizerInterface.php | 1 - .../Normalizer/RelationshipDocGenNormalizer.php | 1 - .../Serializer/Normalizer/SocialActionNormalizer.php | 1 - .../Serializer/Normalizer/SocialIssueNormalizer.php | 1 - .../Serializer/Normalizer/WorkflowNormalizer.php | 1 - .../OldDraftAccompanyingPeriodRemover.php | 1 - .../OldDraftAccompanyingPeriodRemoverInterface.php | 1 - .../Service/DocGenerator/AccompanyingPeriodContext.php | 1 - .../DocGenerator/AccompanyingPeriodWorkContext.php | 1 - .../AccompanyingPeriodWorkEvaluationContext.php | 1 - .../Service/DocGenerator/PersonContext.php | 1 - .../ChillPersonBundle/Service/Import/ChillImporter.php | 1 - .../Service/Import/SocialWorkMetadata.php | 1 - .../Service/Import/SocialWorkMetadataInterface.php | 1 - .../Templating/Entity/ClosingMotiveRender.php | 1 - .../ChillPersonBundle/Templating/Entity/PersonRender.php | 1 - .../Templating/Entity/PersonRenderInterface.php | 1 - .../Templating/Entity/ResourceKindRender.php | 1 - .../Templating/Entity/SocialActionRender.php | 1 - .../Templating/Entity/SocialIssueRender.php | 1 - src/Bundle/ChillPersonBundle/Test/PreparePersonTrait.php | 1 - .../AccompanyingPeriodConfidentialTest.php | 1 - .../Events/PersonMoveEventSubscriberTest.php | 1 - ...ingPeriodSocialIssueConsistencyEntityListenerTest.php | 1 - .../Workflow/WorkflowEventSubscriberTest.php | 1 - .../Controller/AccompanyingCourseApiControllerTest.php | 1 - .../Controller/AccompanyingCourseControllerTest.php | 1 - .../Controller/AccompanyingPeriodControllerTest.php | 1 - .../AccompanyingPeriodRegulationListControllerTest.php | 1 - .../Tests/Controller/HouseholdApiControllerTest.php | 1 - .../Tests/Controller/HouseholdControllerTest.php | 1 - .../Tests/Controller/HouseholdMemberControllerTest.php | 1 - .../Tests/Controller/PersonAddressControllerTest.php | 1 - .../Tests/Controller/PersonApiControllerTest.php | 1 - .../Tests/Controller/PersonControllerCreateTest.php | 1 - .../Tests/Controller/PersonControllerUpdateTest.php | 1 - .../PersonControllerUpdateWithHiddenFieldsTest.php | 1 - .../Tests/Controller/PersonControllerViewTest.php | 1 - .../PersonControllerViewWithHiddenFieldsTest.php | 1 - .../Controller/PersonDuplicateControllerViewTest.php | 1 - .../Tests/Controller/RelationshipApiControllerTest.php | 1 - .../Tests/Controller/SocialIssueApiControllerTest.php | 1 - .../Tests/Entity/AccompanyingPeriod/ResourceTest.php | 1 - .../Tests/Entity/AccompanyingPeriodTest.php | 1 - .../Tests/Entity/Household/HouseholdMemberTest.php | 1 - .../Tests/Entity/Household/HouseholdTest.php | 1 - .../Tests/Entity/SocialWork/SocialIssueTest.php | 1 - .../Tests/Event/Person/PersonAddressMoveEventTest.php | 1 - .../Tests/EventListener/PersonCreateEventTest.php | 1 - .../AdministrativeLocationAggregatorTest.php | 1 - .../ClosingMotiveAggregatorTest.php | 1 - .../ConfidentialAggregatorTest.php | 1 - .../DurationAggregatorTest.php | 1 - .../EmergencyAggregatorTest.php | 1 - .../EvaluationAggregatorTest.php | 1 - .../GeographicalUnitStatAggregatorTest.php | 1 - .../IntensityAggregatorTest.php | 1 - .../AccompanyingCourseAggregators/JobAggregatorTest.php | 1 - .../OriginAggregatorTest.php | 1 - .../ReferrerAggregatorTest.php | 1 - .../ReferrerScopeAggregatorTest.php | 1 - .../RequestorAggregatorTest.php | 1 - .../ScopeAggregatorTest.php | 1 - .../SocialActionAggregatorTest.php | 1 - .../SocialIssueAggregatorTest.php | 1 - .../AccompanyingCourseAggregators/StepAggregatorTest.php | 1 - .../EvaluationTypeAggregatorTest.php | 1 - .../ChildrenNumberAggregatorTest.php | 1 - .../HouseholdAggregators/CompositionAggregatorTest.php | 1 - .../Aggregator/PersonAggregators/AgeAggregatorTest.php | 1 - .../PersonAggregators/CountryOfBirthAggregatorTest.php | 1 - .../PersonAggregators/GenderAggregatorTest.php | 1 - .../HouseholdPositionAggregatorTest.php | 1 - .../PersonAggregators/MaritalStatusAggregatorTest.php | 1 - .../PersonAggregators/NationalityAggregatorTest.php | 1 - .../SocialWorkAggregators/ActionTypeAggregatorTest.php | 1 - .../SocialWorkAggregators/GoalAggregatorTest.php | 1 - .../SocialWorkAggregators/GoalResultAggregatorTest.php | 1 - .../SocialWorkAggregators/JobAggregatorTest.php | 1 - .../SocialWorkAggregators/ReferrerAggregatorTest.php | 1 - .../SocialWorkAggregators/ResultAggregatorTest.php | 1 - .../SocialWorkAggregators/ScopeAggregatorTest.php | 1 - .../Tests/Export/Export/CountAccompanyingCourseTest.php | 1 - .../Tests/Export/Export/CountPersonTest.php | 1 - .../Tests/Export/Export/CountSocialWorkActionsTest.php | 1 - .../Export/Export/StatAccompanyingCourseDurationTest.php | 1 - .../AccompanyingCourseFilters/ActiveOnDateFilterTest.php | 1 - .../ActiveOneDayBetweenDatesFilterTest.php | 1 - .../AdministrativeLocationFilterTest.php | 1 - .../ClosingMotiveFilterTest.php | 1 - .../AccompanyingCourseFilters/ConfidentialFilterTest.php | 1 - .../CurrentUserJobFilterTest.php | 1 - .../CurrentUserScopeFilterTest.php | 1 - .../AccompanyingCourseFilters/EmergencyFilterTest.php | 1 - .../AccompanyingCourseFilters/EvaluationFilterTest.php | 1 - .../GeographicalUnitStatFilterTest.php | 1 - .../AccompanyingCourseFilters/IntensityFilterTest.php | 1 - .../OpenBetweenDatesFilterTest.php | 1 - .../AccompanyingCourseFilters/OriginFilterTest.php | 1 - .../AccompanyingCourseFilters/ReferrerFilterTest.php | 1 - .../AccompanyingCourseFilters/RequestorFilterTest.php | 1 - .../AccompanyingCourseFilters/SocialActionFilterTest.php | 1 - .../AccompanyingCourseFilters/SocialIssueFilterTest.php | 1 - .../Filter/AccompanyingCourseFilters/StepFilterTest.php | 1 - .../EvaluationFilters/EvaluationTypeFilterTest.php | 1 - .../Filter/EvaluationFilters/MaxDateFilterTest.php | 1 - .../Filter/HouseholdFilters/CompositionFilterTest.php | 1 - .../AccompanyingPeriodClosingFilterTest.php | 1 - .../PersonFilters/AccompanyingPeriodFilterTest.php | 1 - .../AccompanyingPeriodOpeningFilterTest.php | 1 - .../Tests/Export/Filter/PersonFilters/AgeFilterTest.php | 1 - .../Export/Filter/PersonFilters/BirthdateFilterTest.php | 1 - .../Filter/PersonFilters/DeadOrAliveFilterTest.php | 1 - .../Export/Filter/PersonFilters/DeathdateFilterTest.php | 1 - .../Export/Filter/PersonFilters/GenderFilterTest.php | 1 - .../Filter/PersonFilters/MaritalStatusFilterTest.php | 1 - .../Filter/PersonFilters/NationalityFilterTest.php | 1 - .../ResidentialAddressAtThirdpartyFilterTest.php | 1 - .../PersonFilters/ResidentialAddressAtUserFilterTest.php | 1 - .../Export/Filter/SocialWorkFilters/JobFilterTest.php | 1 - .../Filter/SocialWorkFilters/ReferrerFilterTest.php | 1 - .../Export/Filter/SocialWorkFilters/ScopeFilterTest.php | 1 - .../SocialWorkFilters/SocialWorkTypeFilterTest.php | 1 - .../Tests/Form/Type/PickPersonTypeTest.php | 1 - .../Tests/Household/MembersEditorTest.php | 1 - .../Tests/Repository/PersonACLAwareRepositoryTest.php | 1 - .../ChillPersonBundle/Tests/Search/PersonSearchTest.php | 1 - .../Tests/Security/Authorization/PersonVoterTest.php | 1 - .../AccompanyingPeriodDocGenNormalizerTest.php | 1 - .../AccompanyingPeriodWorkDocGenNormalizerTest.php | 1 - .../AccompanyingPeriodWorkEvaluationDenormalizerTest.php | 1 - .../Serializer/Normalizer/HouseholdNormalizerTest.php | 1 - .../Serializer/Normalizer/PersonDocGenNormalizerTest.php | 1 - .../Serializer/Normalizer/PersonJsonNormalizerTest.php | 1 - .../Normalizer/RelationshipDocGenNormalizerTest.php | 1 - .../Serializer/Normalizer/ResourceJsonNormalizerTest.php | 1 - .../Tests/Timeline/TimelineAccompanyingPeriodTest.php | 1 - .../AccompanyingPeriod/LocationValidityValidatorTest.php | 1 - .../HouseholdMembershipSequentialValidatorTest.php | 1 - .../Tests/Validator/Household/MaxHolderValidatorTest.php | 1 - .../Tests/Validator/Person/BirthdateValidatorTest.php | 1 - .../Validator/Person/PersonHasCenterValidatorTest.php | 1 - .../Tests/Validator/Person/PersonValidationTest.php | 1 - .../Tests/Workflows/AccompanyingPeriodLifecycle.php | 1 - .../Timeline/AbstractTimelineAccompanyingPeriod.php | 1 - .../Timeline/TimelineAccompanyingPeriodClosing.php | 1 - .../Timeline/TimelineAccompanyingPeriodOpening.php | 1 - .../AccompanyingPeriod/AccompanyingPeriodValidity.php | 1 - .../AccompanyingPeriodValidityValidator.php | 1 - .../ConfidentialCourseMustHaveReferrer.php | 1 - .../ConfidentialCourseMustHaveReferrerValidator.php | 1 - .../Constraints/AccompanyingPeriod/LocationValidity.php | 1 - .../AccompanyingPeriod/LocationValidityValidator.php | 1 - .../AccompanyingPeriod/ParticipationOverlap.php | 1 - .../AccompanyingPeriod/ParticipationOverlapValidator.php | 1 - .../AccompanyingPeriod/ResourceDuplicateCheck.php | 1 - .../ResourceDuplicateCheckValidator.php | 1 - .../Household/HouseholdMembershipSequential.php | 1 - .../Household/HouseholdMembershipSequentialValidator.php | 1 - .../Validator/Constraints/Household/MaxHolder.php | 1 - .../Constraints/Household/MaxHolderValidator.php | 1 - .../Validator/Constraints/Person/Birthdate.php | 1 - .../Validator/Constraints/Person/BirthdateValidator.php | 1 - .../Validator/Constraints/Person/PersonHasCenter.php | 1 - .../Constraints/Person/PersonHasCenterValidator.php | 1 - .../Constraints/Relationship/RelationshipNoDuplicate.php | 1 - .../Relationship/RelationshipNoDuplicateValidator.php | 1 - src/Bundle/ChillPersonBundle/Widget/AddAPersonWidget.php | 1 - src/Bundle/ChillPersonBundle/Widget/PersonListWidget.php | 1 - .../Widget/PersonListWidget/PersonFilteringInterface.php | 1 - .../ChillPersonBundle/Widget/PersonListWidgetFactory.php | 1 - ...anyingPeriodWorkEvaluationDocumentWorkflowHandler.php | 1 - .../AccompanyingPeriodWorkEvaluationWorkflowHandler.php | 1 - .../Workflow/AccompanyingPeriodWorkWorkflowHandler.php | 1 - .../migrations/Version20141129010948.php | 1 - .../migrations/Version20150212173934.php | 1 - .../migrations/Version20150607231010.php | 1 - .../migrations/Version20150811152608.php | 1 - .../migrations/Version20150812110708.php | 1 - .../migrations/Version20150820113409.php | 1 - .../migrations/Version20160310161006.php | 1 - .../migrations/Version20160422000000.php | 1 - .../migrations/Version20160818113633.php | 1 - .../migrations/Version20160818151130.php | 1 - .../migrations/Version20170117131924.php | 1 - .../migrations/Version20180518144221.php | 1 - .../migrations/Version20180820120000.php | 1 - .../migrations/Version20181005140249.php | 1 - .../migrations/Version20181023101621.php | 1 - .../migrations/Version20190701124238.php | 1 - .../migrations/Version20191106103452.php | 1 - .../migrations/Version20200128084445.php | 1 - .../migrations/Version20200130213446.php | 1 - .../migrations/Version20200310090632.php | 1 - .../migrations/Version20200422125935.php | 1 - .../migrations/Version20210128152747.php | 1 - .../migrations/Version20210318095831.php | 1 - .../migrations/Version20210325141540.php | 1 - .../migrations/Version20210326113045.php | 1 - .../migrations/Version20210329090904.php | 1 - .../migrations/Version20210329113152.php | 1 - .../migrations/Version20210329144338.php | 1 - .../migrations/Version20210330164922.php | 1 - .../migrations/Version20210331084527.php | 1 - .../migrations/Version20210419105054.php | 1 - .../migrations/Version20210419105940.php | 1 - .../migrations/Version20210419112619.php | 1 - .../migrations/Version20210426145930.php | 1 - .../migrations/Version20210427125700.php | 1 - .../migrations/Version20210505093408.php | 1 - .../migrations/Version20210505154316.php | 1 - .../migrations/Version20210518075908.php | 1 - .../migrations/Version20210518162439.php | 1 - .../migrations/Version20210519204938.php | 1 - .../migrations/Version20210525211214.php | 1 - .../migrations/Version20210528092625.php | 1 - .../migrations/Version20210528111624.php | 1 - .../migrations/Version20210528132405.php | 1 - .../migrations/Version20210528142121.php | 1 - .../migrations/Version20210614191600.php | 1 - .../migrations/Version20210615074857.php | 1 - .../migrations/Version20210616102900.php | 1 - .../migrations/Version20210617073504.php | 1 - .../migrations/Version20210618080702.php | 1 - .../migrations/Version20210620143757.php | 1 - .../migrations/Version20210623135043.php | 1 - .../migrations/Version20210623142046.php | 1 - .../migrations/Version20210624131722.php | 1 - .../migrations/Version20210624131723.php | 1 - .../migrations/Version20210727152826.php | 1 - .../migrations/Version20210729163023.php | 1 - .../migrations/Version20210730094514.php | 1 - .../migrations/Version20210730205407.php | 1 - .../migrations/Version20210802202838.php | 1 - .../migrations/Version20210820093927.php | 1 - .../migrations/Version20210820100407.php | 1 - .../migrations/Version20210831140339.php | 1 - .../migrations/Version20210910161858.php | 1 - .../migrations/Version20210915093624.php | 1 - .../migrations/Version20211020131133.php | 1 - .../migrations/Version20211021125359.php | 1 - .../migrations/Version20211025141226.php | 1 - .../migrations/Version20211029075117.php | 1 - .../migrations/Version20211108100849.php | 1 - .../migrations/Version20211112170027.php | 1 - .../migrations/Version20211119211101.php | 1 - .../migrations/Version20211119215630.php | 1 - .../migrations/Version20211213150253.php | 1 - .../migrations/Version20211213203147.php | 1 - .../migrations/Version20211213213755.php | 1 - .../migrations/Version20211216154008.php | 1 - .../migrations/Version20211223150721.php | 1 - .../migrations/Version20220104133334.php | 1 - .../migrations/Version20220119091025.php | 1 - .../migrations/Version20220119155944.php | 1 - .../migrations/Version20220121121310.php | 1 - .../migrations/Version20220128133039.php | 1 - .../migrations/Version20220214200327.php | 1 - .../migrations/Version20220215135509.php | 1 - .../migrations/Version20220224145951.php | 1 - .../migrations/Version20220303113855.php | 1 - .../migrations/Version20220310063629.php | 1 - .../migrations/Version20220310124318.php | 1 - .../migrations/Version20220425000000.php | 1 - .../migrations/Version20220427150431.php | 1 - .../migrations/Version20220429133023.php | 1 - .../migrations/Version20220527124737.php | 1 - .../migrations/Version20220926154347.php | 1 - src/Bundle/ChillReportBundle/ChillReportBundle.php | 1 - .../ChillReportBundle/Controller/ReportController.php | 1 - .../DataFixtures/ORM/LoadCustomField.php | 1 - .../DataFixtures/ORM/LoadCustomFieldsGroup.php | 1 - .../ChillReportBundle/DataFixtures/ORM/LoadReportACL.php | 1 - .../ChillReportBundle/DataFixtures/ORM/LoadReports.php | 1 - .../DependencyInjection/ChillReportExtension.php | 1 - .../DependencyInjection/Configuration.php | 1 - src/Bundle/ChillReportBundle/Entity/Report.php | 1 - .../Export/Export/ReportListProvider.php | 1 - src/Bundle/ChillReportBundle/Form/ReportType.php | 1 - src/Bundle/ChillReportBundle/Search/ReportSearch.php | 1 - .../Security/Authorization/ReportVoter.php | 1 - .../Tests/Controller/ReportControllerNextTest.php | 1 - .../Tests/Controller/ReportControllerTest.php | 1 - .../DependencyInjection/ChillReportExtensionTest.php | 1 - .../Tests/Export/Filter/ReportDateFilterTest.php | 1 - .../ChillReportBundle/Tests/Search/ReportSearchTest.php | 1 - .../Tests/Security/Authorization/ReportVoterTest.php | 1 - .../Tests/Timeline/TimelineProviderTest.php | 1 - .../Timeline/TimelineReportProvider.php | 1 - .../migrations/Version20141129012050.php | 1 - .../migrations/Version20150622233319.php | 1 - src/Bundle/ChillTaskBundle/ChillTaskBundle.php | 1 - .../ChillTaskBundle/Controller/SingleTaskController.php | 1 - src/Bundle/ChillTaskBundle/Controller/TaskController.php | 1 - .../ChillTaskBundle/DataFixtures/ORM/LoadTaskACL.php | 1 - .../DependencyInjection/ChillTaskExtension.php | 1 - .../Compiler/TaskWorkflowDefinitionCompilerPass.php | 1 - .../DependencyInjection/Configuration.php | 1 - src/Bundle/ChillTaskBundle/Entity/AbstractTask.php | 1 - src/Bundle/ChillTaskBundle/Entity/RecurringTask.php | 1 - src/Bundle/ChillTaskBundle/Entity/SingleTask.php | 1 - .../Entity/Task/AbstractTaskPlaceEvent.php | 1 - .../ChillTaskBundle/Entity/Task/SingleTaskPlaceEvent.php | 1 - .../Event/Lifecycle/TaskLifecycleEvent.php | 1 - src/Bundle/ChillTaskBundle/Event/TaskEvent.php | 1 - src/Bundle/ChillTaskBundle/Event/UI/UIEvent.php | 1 - src/Bundle/ChillTaskBundle/Form/SingleTaskListType.php | 1 - src/Bundle/ChillTaskBundle/Form/SingleTaskType.php | 1 - src/Bundle/ChillTaskBundle/Menu/MenuBuilder.php | 1 - src/Bundle/ChillTaskBundle/Menu/SectionMenuBuilder.php | 1 - src/Bundle/ChillTaskBundle/Menu/UserMenuBuilder.php | 1 - .../Repository/AbstractTaskRepository.php | 1 - .../Repository/RecurringTaskRepository.php | 1 - .../Repository/SingleTaskAclAwareRepositoryInterface.php | 1 - .../ChillTaskBundle/Repository/SingleTaskRepository.php | 1 - .../Security/Authorization/AuthorizationEvent.php | 1 - .../ChillTaskBundle/Security/Authorization/TaskVoter.php | 1 - .../ChillTaskBundle/Templating/TaskTwigExtension.php | 1 - .../Templating/UI/CountNotificationTask.php | 1 - .../Tests/Controller/SingleTaskControllerTest.php | 1 - .../Tests/Controller/TaskControllerTest.php | 1 - .../Repository/SingleTaskACLAwareRepositoryTest.php | 1 - .../SingleTaskTaskLifeCycleEventTimelineProvider.php | 1 - .../Timeline/TaskLifeCycleEventTimelineProvider.php | 1 - .../Workflow/Definition/DefaultTaskDefinition.php | 1 - .../Workflow/Event/DefaultTaskGuardEvent.php | 1 - .../ChillTaskBundle/Workflow/TaskWorkflowDefinition.php | 1 - .../ChillTaskBundle/Workflow/TaskWorkflowManager.php | 1 - .../ChillTaskBundle/migrations/Version20180413135614.php | 1 - .../ChillTaskBundle/migrations/Version20180413201023.php | 1 - .../ChillTaskBundle/migrations/Version20180426093011.php | 1 - .../ChillTaskBundle/migrations/Version20180502194119.php | 1 - .../ChillTaskBundle/migrations/Version20181113161925.php | 1 - .../ChillTaskBundle/migrations/Version20181113164108.php | 1 - .../ChillTaskBundle/migrations/Version20210909153533.php | 1 - .../ChillTaskBundle/migrations/Version20211029213909.php | 1 - .../ChillThirdPartyBundle/ChillThirdPartyBundle.php | 1 - .../ChillThirdPartyBundle/Controller/AdminController.php | 1 - .../Controller/ThirdPartyCategoryController.php | 1 - .../Controller/ThirdPartyController.php | 1 - .../DataFixtures/ORM/LoadThirdParty.php | 1 - .../DataFixtures/ORM/LoadThirdPartyCategory.php | 1 - .../DataFixtures/ORM/LoadThirdPartyProfession.php | 1 - .../DependencyInjection/ChillThirdPartyExtension.php | 1 - .../CompilerPass/ThirdPartyTypeCompilerPass.php | 1 - .../DependencyInjection/Configuration.php | 1 - src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php | 1 - .../ChillThirdPartyBundle/Entity/ThirdPartyCategory.php | 1 - .../Entity/ThirdPartyProfession.php | 1 - .../EventListener/ThirdPartyEventListener.php | 1 - .../Form/ChoiceLoader/ThirdPartyChoiceLoader.php | 1 - .../DataTransformer/ThirdPartiesToIdDataTransformer.php | 9 ++++++++- .../DataTransformer/ThirdPartyToIdDataTransformer.php | 9 ++++++++- .../Form/ThirdPartyCategoryType.php | 1 - src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php | 1 - .../Form/Type/PickThirdPartyType.php | 1 - .../Form/Type/PickThirdPartyTypeCategoryType.php | 1 - .../Form/Type/PickThirdpartyDynamicType.php | 1 - .../ChillThirdPartyBundle/Menu/AdminMenuBuilder.php | 1 - src/Bundle/ChillThirdPartyBundle/Menu/MenuBuilder.php | 1 - .../Repository/ThirdPartyACLAwareRepository.php | 1 - .../Repository/ThirdPartyACLAwareRepositoryInterface.php | 1 - .../Repository/ThirdPartyCategoryRepository.php | 1 - .../Repository/ThirdPartyProfessionRepository.php | 1 - .../Repository/ThirdPartyRepository.php | 1 - .../ChillThirdPartyBundle/Search/ThirdPartyApiSearch.php | 1 - .../ChillThirdPartyBundle/Search/ThirdPartySearch.php | 1 - .../Security/Voter/ThirdPartyVoter.php | 1 - .../Serializer/Normalizer/ThirdPartyNormalizer.php | 1 - .../Templating/Entity/ThirdPartyRender.php | 1 - .../Tests/Controller/ThirdPartyControllerTest.php | 1 - .../Tests/Entity/ThirdPartyTest.php | 1 - .../Normalizer/ThirdPartyDocGenNormalizerTest.php | 1 - .../Normalizer/ThirdPartyJsonDenormalizerTest.php | 1 - .../ThirdPartyType/ThirdPartyTypeManager.php | 1 - .../ThirdPartyType/ThirdPartyTypeProviderInterface.php | 1 - .../migrations/Version20190307111314.php | 1 - .../migrations/Version20190307131650.php | 1 - .../migrations/Version20190418090842.php | 1 - .../migrations/Version20190429171109.php | 1 - .../migrations/Version20190502144206.php | 1 - .../migrations/Version20210525211216.php | 1 - .../migrations/Version20210719105918.php | 1 - .../migrations/Version20211006200924.php | 1 - .../migrations/Version20211007150459.php | 1 - .../migrations/Version20211007165001.php | 1 - .../migrations/Version20211007194942.php | 1 - .../migrations/Version20220302143821.php | 1 - .../migrations/Version20220322095659.php | 1 - .../migrations/Version20220324175549.php | 1 - src/Bundle/ChillWopiBundle/src/ChillWopiBundle.php | 1 - src/Bundle/ChillWopiBundle/src/Controller/Editor.php | 1 - .../src/DependencyInjection/ChillWopiExtension.php | 1 - .../src/DependencyInjection/Configuration.php | 1 - .../src/Resources/config/routes/routes.php | 1 - .../ChillWopiBundle/src/Resources/config/services.php | 1 - .../ChillWopiBundle/src/Service/Controller/Responder.php | 1 - .../src/Service/Controller/ResponderInterface.php | 1 - .../src/Service/Wopi/ChillDocumentLockManager.php | 1 - .../src/Service/Wopi/ChillDocumentManager.php | 1 - .../ChillWopiBundle/src/Service/Wopi/ChillWopi.php | 1 - .../tests/Service/Wopi/ChillDocumentLockManagerTest.php | 1 - 1665 files changed, 826 insertions(+), 1667 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/ChillActivityBundle.php b/src/Bundle/ChillActivityBundle/ChillActivityBundle.php index 5c6a7f5d6..5f872a7dc 100644 --- a/src/Bundle/ChillActivityBundle/ChillActivityBundle.php +++ b/src/Bundle/ChillActivityBundle/ChillActivityBundle.php @@ -1,6 +1,5 @@ translatableStringHelper->localize($item->getLayer()->getName()) . ' > ' . $item->getUnitName(); - }, + return $this->translatableStringHelper->localize($item->getLayer()->getName()) . ' > ' . $item->getUnitName(); + }, $data['units']->toArray() ) ), diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/MaritalStatusFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/MaritalStatusFilter.php index f78f26e9b..a3d2260e3 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/MaritalStatusFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/MaritalStatusFilter.php @@ -1,6 +1,5 @@ Date: Mon, 10 Oct 2022 17:39:13 +0200 Subject: [PATCH 15/51] issue641: create 2 new Select2 formType (for actions and issues) --- .../ACPFilters/BySocialActionFilter.php | 12 ++--- .../Filter/ACPFilters/BySocialIssueFilter.php | 12 ++--- .../Form/Type/Select2SocialActionType.php | 51 +++++++++++++++++++ .../Form/Type/Select2SocialIssueType.php | 51 +++++++++++++++++++ .../config/services/form.yaml | 8 +++ .../translations/messages.fr.yml | 2 + 6 files changed, 118 insertions(+), 18 deletions(-) create mode 100644 src/Bundle/ChillPersonBundle/Form/Type/Select2SocialActionType.php create mode 100644 src/Bundle/ChillPersonBundle/Form/Type/Select2SocialIssueType.php diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialActionFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialActionFilter.php index e3ce8b287..4502450cb 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialActionFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialActionFilter.php @@ -13,11 +13,10 @@ namespace Chill\ActivityBundle\Export\Filter\ACPFilters; use Chill\ActivityBundle\Export\Declarations; use Chill\MainBundle\Export\FilterInterface; -use Chill\PersonBundle\Entity\SocialWork\SocialAction; +use Chill\PersonBundle\Form\Type\Select2SocialActionType; use Chill\PersonBundle\Templating\Entity\SocialActionRender; use Doctrine\ORM\Query\Expr\Andx; use Doctrine\ORM\QueryBuilder; -use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\FormBuilderInterface; use function in_array; @@ -62,13 +61,8 @@ class BySocialActionFilter implements FilterInterface public function buildForm(FormBuilderInterface $builder) { - $builder->add('accepted_socialactions', EntityType::class, [ - 'class' => SocialAction::class, - 'choice_label' => function (SocialAction $sa) { - return $this->actionRender->renderString($sa, []); - }, - 'multiple' => true, - 'expanded' => true, + $builder->add('accepted_socialactions', Select2SocialActionType::class, [ + 'multiple' => true ]); } diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialIssueFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialIssueFilter.php index f5d552011..59d79d21d 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialIssueFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialIssueFilter.php @@ -13,11 +13,10 @@ namespace Chill\ActivityBundle\Export\Filter\ACPFilters; use Chill\ActivityBundle\Export\Declarations; use Chill\MainBundle\Export\FilterInterface; -use Chill\PersonBundle\Entity\SocialWork\SocialIssue; +use Chill\PersonBundle\Form\Type\Select2SocialIssueType; use Chill\PersonBundle\Templating\Entity\SocialIssueRender; use Doctrine\ORM\Query\Expr\Andx; use Doctrine\ORM\QueryBuilder; -use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\FormBuilderInterface; use function in_array; @@ -62,13 +61,8 @@ class BySocialIssueFilter implements FilterInterface public function buildForm(FormBuilderInterface $builder) { - $builder->add('accepted_socialissues', EntityType::class, [ - 'class' => SocialIssue::class, - 'choice_label' => function (SocialIssue $si) { - return $this->issueRender->renderString($si, []); - }, - 'multiple' => true, - 'expanded' => true, + $builder->add('accepted_socialissues', Select2SocialIssueType::class, [ + 'multiple' => true ]); } diff --git a/src/Bundle/ChillPersonBundle/Form/Type/Select2SocialActionType.php b/src/Bundle/ChillPersonBundle/Form/Type/Select2SocialActionType.php new file mode 100644 index 000000000..f1e8cd913 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Form/Type/Select2SocialActionType.php @@ -0,0 +1,51 @@ +actionRender = $actionRender; + } + + public function buildForm(FormBuilderInterface $builder, array $options) + { + $builder->add('social_actions', EntityType::class, [ + 'class' => SocialAction::class, + 'choice_label' => function (SocialAction $sa) { + return $this->actionRender->renderString($sa, []); + }, + 'placeholder' => 'Pick a social action', + 'required' => false, + 'label' => $options['label'], + 'label_attr' => $options['label_attr'], + 'multiple' => $options['multiple'], + 'attr' => ['class' => 'select2'], + ]); + } + + public function configureOptions(OptionsResolver $resolver) + { + $resolver + ->setDefault('label', 'Social actions') + ->setDefault('label_attr', []) + ->setDefault('multiple', false) + ->setAllowedTypes('multiple', ['bool']) + ; + } + + public function getBlockPrefix(): string + { + return 'select2_social_action_type'; + } +} diff --git a/src/Bundle/ChillPersonBundle/Form/Type/Select2SocialIssueType.php b/src/Bundle/ChillPersonBundle/Form/Type/Select2SocialIssueType.php new file mode 100644 index 000000000..49ee6d574 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Form/Type/Select2SocialIssueType.php @@ -0,0 +1,51 @@ +issueRender = $issueRender; + } + + public function buildForm(FormBuilderInterface $builder, array $options) + { + $builder->add('social_issues', EntityType::class, [ + 'class' => SocialIssue::class, + 'choice_label' => function (SocialIssue $si) { + return $this->issueRender->renderString($si, []); + }, + 'placeholder' => 'Pick a social issue', + 'required' => false, + 'label' => $options['label'], + 'label_attr' => $options['label_attr'], + 'multiple' => $options['multiple'], + 'attr' => ['class' => 'select2'], + ]); + } + + public function configureOptions(OptionsResolver $resolver) + { + $resolver + ->setDefault('label', 'Social issues') + ->setDefault('label_attr', []) + ->setDefault('multiple', false) + ->setAllowedTypes('multiple', ['bool']) + ; + } + + public function getBlockPrefix(): string + { + return 'select2_social_issue_type'; + } +} diff --git a/src/Bundle/ChillPersonBundle/config/services/form.yaml b/src/Bundle/ChillPersonBundle/config/services/form.yaml index 52bf1f494..85b97c86b 100644 --- a/src/Bundle/ChillPersonBundle/config/services/form.yaml +++ b/src/Bundle/ChillPersonBundle/config/services/form.yaml @@ -27,3 +27,11 @@ services: $config: "%chill_person.accompanying_period_fields%" tags: - { name: form.type } + + Chill\PersonBundle\Form\Type\Select2SocialActionType: + autowire: true + autoconfigure: true + + Chill\PersonBundle\Form\Type\Select2SocialIssueType: + autowire: true + autoconfigure: true diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index a5040e6df..a755ce0f0 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -205,9 +205,11 @@ Resources: Interlocuteurs privilégiés Any requestor to this accompanying course: Aucun demandeur pour ce parcours Social action: Action d'accompagnement Social actions: Actions d'accompagnement +Pick a social action: Choisir une action d'accompagnement Last social actions: Les dernières actions d'accompagnement Social issue: Problématique sociale Social issues: Problématiques sociales +Pick a social issue: Choisir une problématique sociale Last events on accompanying course: Dernières actions de suivi Edit & activate accompanying course: Modifier et valider See accompanying periods: Voir toutes les périodes d'accompagnement From 9c709d4388a34658fde0d4aedb41644ff8df000a Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Mon, 10 Oct 2022 18:17:09 +0200 Subject: [PATCH 16/51] issue641: others filters use these new Select2...Type --- .../AccompanyingCourseFilters/SocialActionFilter.php | 10 ++-------- .../AccompanyingCourseFilters/SocialIssueFilter.php | 9 ++------- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php index c5c37ce21..6c78d703f 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php @@ -13,12 +13,11 @@ namespace Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters; use Chill\MainBundle\Export\FilterInterface; use Chill\MainBundle\Templating\TranslatableStringHelper; -use Chill\PersonBundle\Entity\SocialWork\SocialAction; use Chill\PersonBundle\Export\Declarations; +use Chill\PersonBundle\Form\Type\Select2SocialActionType; use Chill\PersonBundle\Templating\Entity\SocialActionRender; use Doctrine\ORM\Query\Expr\Andx; use Doctrine\ORM\QueryBuilder; -use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\FormBuilderInterface; use function in_array; @@ -71,13 +70,8 @@ class SocialActionFilter implements FilterInterface public function buildForm(FormBuilderInterface $builder) { - $builder->add('accepted_socialactions', EntityType::class, [ - 'class' => SocialAction::class, - 'choice_label' => function (SocialAction $sa) { - return $this->actionRender->renderString($sa, []); - }, + $builder->add('accepted_socialactions', Select2SocialActionType::class, [ 'multiple' => true, - 'expanded' => true, ]); } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php index d896d6395..b5f52b1fb 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php @@ -15,10 +15,10 @@ use Chill\MainBundle\Export\FilterInterface; use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\PersonBundle\Entity\SocialWork\SocialIssue; use Chill\PersonBundle\Export\Declarations; +use Chill\PersonBundle\Form\Type\Select2SocialIssueType; use Chill\PersonBundle\Templating\Entity\SocialIssueRender; use Doctrine\ORM\Query\Expr\Andx; use Doctrine\ORM\QueryBuilder; -use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Contracts\Translation\TranslatorInterface; use function in_array; @@ -78,13 +78,8 @@ class SocialIssueFilter implements FilterInterface public function buildForm(FormBuilderInterface $builder) { - $builder->add('accepted_socialissues', EntityType::class, [ - 'class' => SocialIssue::class, - 'choice_label' => function ($socialIssue) { - return $this->socialIssueRender->renderString($socialIssue, []); - }, + $builder->add('accepted_socialissues', Select2SocialIssueType::class, [ 'multiple' => true, - 'expanded' => true, ]); } From 5c6068e8a5a08145f0a1c77793e4532e91cbad0e Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Mon, 10 Oct 2022 18:52:38 +0200 Subject: [PATCH 17/51] fix cs --- .../Form/Type/Select2LocationTypeType.php | 12 +++- .../Form/Type/Select2UserLocationType.php | 3 +- .../Test/Export/AbstractAggregatorTest.php | 72 +++++++++---------- .../Test/Export/AbstractFilterTest.php | 72 +++++++++---------- .../AdministrativeLocationFilter.php | 2 - .../Form/Type/Select2SocialActionType.php | 12 +++- .../Form/Type/Select2SocialIssueType.php | 12 +++- 7 files changed, 103 insertions(+), 82 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Form/Type/Select2LocationTypeType.php b/src/Bundle/ChillMainBundle/Form/Type/Select2LocationTypeType.php index e680b06ca..783ec4e5c 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/Select2LocationTypeType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/Select2LocationTypeType.php @@ -1,5 +1,14 @@ setDefault('label', 'Location type') ->setDefault('label_attr', []) ->setDefault('multiple', false) - ->setAllowedTypes('multiple', ['bool']) - ; + ->setAllowedTypes('multiple', ['bool']); } public function getBlockPrefix(): string diff --git a/src/Bundle/ChillMainBundle/Form/Type/Select2UserLocationType.php b/src/Bundle/ChillMainBundle/Form/Type/Select2UserLocationType.php index de4a8537d..8fb100441 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/Select2UserLocationType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/Select2UserLocationType.php @@ -57,8 +57,7 @@ class Select2UserLocationType extends AbstractType ->setDefault('label', 'Current location') ->setDefault('label_attr', []) ->setDefault('multiple', false) - ->setAllowedTypes('multiple', ['bool']) - ; + ->setAllowedTypes('multiple', ['bool']); } public function getBlockPrefix(): string diff --git a/src/Bundle/ChillMainBundle/Test/Export/AbstractAggregatorTest.php b/src/Bundle/ChillMainBundle/Test/Export/AbstractAggregatorTest.php index d3f2849b7..115c364ad 100644 --- a/src/Bundle/ChillMainBundle/Test/Export/AbstractAggregatorTest.php +++ b/src/Bundle/ChillMainBundle/Test/Export/AbstractAggregatorTest.php @@ -29,6 +29,18 @@ use function is_string; */ abstract class AbstractAggregatorTest extends KernelTestCase { + /** + * provide data for `testAliasDidNotDisappears`. + */ + public function dataProviderAliasDidNotDisappears() + { + foreach ($this->getQueryBuilders() as $qb) { + foreach ($this->getFormData() as $data) { + yield [clone $qb, $data]; + } + } + } + /** * provide data for `testAlterQuery`. */ @@ -63,18 +75,6 @@ abstract class AbstractAggregatorTest extends KernelTestCase } } - /** - * provide data for `testAliasDidNotDisappears`. - */ - public function dataProviderAliasDidNotDisappears() - { - foreach ($this->getQueryBuilders() as $qb) { - foreach ($this->getFormData() as $data) { - yield [clone $qb, $data]; - } - } - } - /** * Create an aggregator instance which will be used in tests. * @@ -107,6 +107,30 @@ abstract class AbstractAggregatorTest extends KernelTestCase */ abstract public function getQueryBuilders(); + /** + * Compare aliases array before and after that aggregator alter query + * + * @dataProvider dataProviderAliasDidNotDisappears + * + * @param QueryBuilder $qb + * @param array $data + * @return void + */ + public function testAliasDidNotDisappears(QueryBuilder $qb, array $data) + { + $aliases = $qb->getAllAliases(); + + $this->getAggregator()->alterQuery($qb, $data); + + $alteredQuery = $qb->getAllAliases(); + + $this->assertGreaterThanOrEqual(count($aliases), count($alteredQuery)); + + foreach ($aliases as $alias) { + $this->assertContains($alias, $alteredQuery); + } + } + /** * test the alteration of query by the filter. * @@ -270,28 +294,4 @@ abstract class AbstractAggregatorTest extends KernelTestCase ); } - /** - * Compare aliases array before and after that aggregator alter query - * - * @dataProvider dataProviderAliasDidNotDisappears - * - * @param QueryBuilder $qb - * @param array $data - * @return void - */ - public function testAliasDidNotDisappears(QueryBuilder $qb, array $data) - { - $aliases = $qb->getAllAliases(); - - $this->getAggregator()->alterQuery($qb, $data); - - $alteredQuery = $qb->getAllAliases(); - - $this->assertGreaterThanOrEqual(count($aliases), count($alteredQuery)); - - foreach ($aliases as $alias) { - $this->assertContains($alias, $alteredQuery); - } - } - } diff --git a/src/Bundle/ChillMainBundle/Test/Export/AbstractFilterTest.php b/src/Bundle/ChillMainBundle/Test/Export/AbstractFilterTest.php index 8e8220b89..1525385aa 100644 --- a/src/Bundle/ChillMainBundle/Test/Export/AbstractFilterTest.php +++ b/src/Bundle/ChillMainBundle/Test/Export/AbstractFilterTest.php @@ -40,6 +40,18 @@ abstract class AbstractFilterTest extends KernelTestCase $this->prophet = $this->getProphet(); } + /** + * provide data for `testAliasDidNotDisappears`. + */ + public function dataProviderAliasDidNotDisappears() + { + foreach ($this->getQueryBuilders() as $qb) { + foreach ($this->getFormData() as $data) { + yield [clone $qb, $data]; + } + } + } + public function dataProviderAlterQuery() { foreach ($this->getQueryBuilders() as $qb) { @@ -56,18 +68,6 @@ abstract class AbstractFilterTest extends KernelTestCase } } - /** - * provide data for `testAliasDidNotDisappears`. - */ - public function dataProviderAliasDidNotDisappears() - { - foreach ($this->getQueryBuilders() as $qb) { - foreach ($this->getFormData() as $data) { - yield [clone $qb, $data]; - } - } - } - /** * Create a filter which will be used in tests. * @@ -99,6 +99,30 @@ abstract class AbstractFilterTest extends KernelTestCase */ abstract public function getQueryBuilders(); + /** + * Compare aliases array before and after that filter alter query + * + * @dataProvider dataProviderAliasDidNotDisappears + * + * @param QueryBuilder $qb + * @param array $data + * @return void + */ + public function testAliasDidNotDisappears(QueryBuilder $qb, array $data) + { + $aliases = $qb->getAllAliases(); + + $this->getFilter()->alterQuery($qb, $data); + + $alteredQuery = $qb->getAllAliases(); + + $this->assertGreaterThanOrEqual(count($aliases), count($alteredQuery)); + + foreach ($aliases as $alias) { + $this->assertContains($alias, $alteredQuery); + } + } + /** * test the alteration of query by the filter. * @@ -211,28 +235,4 @@ abstract class AbstractFilterTest extends KernelTestCase 'test that the title is not empty' ); } - - /** - * Compare aliases array before and after that filter alter query - * - * @dataProvider dataProviderAliasDidNotDisappears - * - * @param QueryBuilder $qb - * @param array $data - * @return void - */ - public function testAliasDidNotDisappears(QueryBuilder $qb, array $data) - { - $aliases = $qb->getAllAliases(); - - $this->getFilter()->alterQuery($qb, $data); - - $alteredQuery = $qb->getAllAliases(); - - $this->assertGreaterThanOrEqual(count($aliases), count($alteredQuery)); - - foreach ($aliases as $alias) { - $this->assertContains($alias, $alteredQuery); - } - } } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/AdministrativeLocationFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/AdministrativeLocationFilter.php index 9e54a2272..d289220af 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/AdministrativeLocationFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/AdministrativeLocationFilter.php @@ -20,7 +20,6 @@ use Symfony\Component\Form\FormBuilderInterface; class AdministrativeLocationFilter implements FilterInterface { - private TranslatableStringHelper $translatableStringHelper; public function __construct( @@ -49,7 +48,6 @@ class AdministrativeLocationFilter implements FilterInterface public function buildForm(FormBuilderInterface $builder) { - $builder->add('accepted_locations', Select2UserLocationType::class, [ 'label' => 'Accepted locations', 'label_attr' => [ diff --git a/src/Bundle/ChillPersonBundle/Form/Type/Select2SocialActionType.php b/src/Bundle/ChillPersonBundle/Form/Type/Select2SocialActionType.php index f1e8cd913..1365757c7 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/Select2SocialActionType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/Select2SocialActionType.php @@ -1,5 +1,14 @@ setDefault('label', 'Social actions') ->setDefault('label_attr', []) ->setDefault('multiple', false) - ->setAllowedTypes('multiple', ['bool']) - ; + ->setAllowedTypes('multiple', ['bool']); } public function getBlockPrefix(): string diff --git a/src/Bundle/ChillPersonBundle/Form/Type/Select2SocialIssueType.php b/src/Bundle/ChillPersonBundle/Form/Type/Select2SocialIssueType.php index 49ee6d574..04b2f723d 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/Select2SocialIssueType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/Select2SocialIssueType.php @@ -1,5 +1,14 @@ setDefault('label', 'Social issues') ->setDefault('label_attr', []) ->setDefault('multiple', false) - ->setAllowedTypes('multiple', ['bool']) - ; + ->setAllowedTypes('multiple', ['bool']); } public function getBlockPrefix(): string From a46c85d66cb5b13ddda1cb6b4698ad7e5f2b507d Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Sun, 16 Oct 2022 13:21:03 +0200 Subject: [PATCH 18/51] Fix nested forms problems with select2 FormTypes in issue 641 and 649 Select2UserLocationType.php is called in another context: UserController call UserCurrentLocationType which instanciate new Select2UserLocationType.php FormType --- .../Controller/UserController.php | 4 +-- .../Form/Type/Select2LocationTypeType.php | 35 +++++++------------ .../Form/Type/Select2UserLocationType.php | 26 +++++--------- .../Form/UserCurrentLocationType.php | 26 ++++++++++++++ .../Form/Type/Select2SocialActionType.php | 35 +++++++------------ .../Form/Type/Select2SocialIssueType.php | 35 +++++++------------ 6 files changed, 75 insertions(+), 86 deletions(-) create mode 100644 src/Bundle/ChillMainBundle/Form/UserCurrentLocationType.php diff --git a/src/Bundle/ChillMainBundle/Controller/UserController.php b/src/Bundle/ChillMainBundle/Controller/UserController.php index 03d8d2692..9d3941411 100644 --- a/src/Bundle/ChillMainBundle/Controller/UserController.php +++ b/src/Bundle/ChillMainBundle/Controller/UserController.php @@ -15,7 +15,7 @@ use Chill\MainBundle\CRUD\Controller\CRUDController; use Chill\MainBundle\Entity\GroupCenter; use Chill\MainBundle\Entity\User; use Chill\MainBundle\Form\Type\ComposedGroupCenterType; -use Chill\MainBundle\Form\Type\Select2UserLocationType; +use Chill\MainBundle\Form\UserCurrentLocationType; use Chill\MainBundle\Form\UserPasswordType; use Chill\MainBundle\Form\UserType; use Chill\MainBundle\Pagination\PaginatorInterface; @@ -234,7 +234,7 @@ class UserController extends CRUDController public function editCurrentLocationAction(Request $request) { $user = $this->getUser(); - $form = $this->createForm(Select2UserLocationType::class, $user) + $form = $this->createForm(UserCurrentLocationType::class, $user) ->add('submit', SubmitType::class, ['label' => 'Save']) ->handleRequest($request); diff --git a/src/Bundle/ChillMainBundle/Form/Type/Select2LocationTypeType.php b/src/Bundle/ChillMainBundle/Form/Type/Select2LocationTypeType.php index 783ec4e5c..33121f8bb 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/Select2LocationTypeType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/Select2LocationTypeType.php @@ -15,7 +15,6 @@ use Chill\MainBundle\Entity\LocationType; use Chill\MainBundle\Templating\TranslatableStringHelper; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; class Select2LocationTypeType extends AbstractType @@ -27,33 +26,25 @@ class Select2LocationTypeType extends AbstractType $this->translatableStringHelper = $translatableStringHelper; } - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder->add('locationtype', EntityType::class, [ - 'class' => LocationType::class, - 'choice_label' => function (LocationType $type) { - return $this->translatableStringHelper->localize($type->getTitle()); - }, - 'placeholder' => 'Pick a location type', - 'required' => false, - 'label' => $options['label'], - 'label_attr' => $options['label_attr'], - 'multiple' => $options['multiple'], - 'attr' => ['class' => 'select2'], - ]); - } - public function configureOptions(OptionsResolver $resolver) { $resolver - ->setDefault('label', 'Location type') - ->setDefault('label_attr', []) - ->setDefault('multiple', false) + ->setDefaults([ + 'class' => LocationType::class, + 'choice_label' => function (LocationType $type) { + return $this->translatableStringHelper->localize($type->getTitle()); + }, + 'placeholder' => 'Pick a location type', + 'required' => false, + 'attr' => ['class' => 'select2'], + 'label' => 'Location type', + 'multiple' => false, + ]) ->setAllowedTypes('multiple', ['bool']); } - public function getBlockPrefix(): string + public function getParent(): string { - return 'select2_location_type_type'; + return EntityType::class; } } diff --git a/src/Bundle/ChillMainBundle/Form/Type/Select2UserLocationType.php b/src/Bundle/ChillMainBundle/Form/Type/Select2UserLocationType.php index 8fb100441..3c1e51e68 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/Select2UserLocationType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/Select2UserLocationType.php @@ -16,7 +16,6 @@ use Chill\MainBundle\Repository\LocationRepository; use Chill\MainBundle\Templating\TranslatableStringHelper; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; class Select2UserLocationType extends AbstractType @@ -31,10 +30,10 @@ class Select2UserLocationType extends AbstractType $this->locationRepository = $locationRepository; } - public function buildForm(FormBuilderInterface $builder, array $options) + public function configureOptions(OptionsResolver $resolver) { - $builder - ->add('currentLocation', EntityType::class, [ + $resolver + ->setDefaults([ 'class' => Location::class, 'choices' => $this->locationRepository->findByPublicLocations(), 'choice_label' => function (Location $entity) { @@ -44,24 +43,15 @@ class Select2UserLocationType extends AbstractType }, 'placeholder' => 'Pick a location', 'required' => false, - 'label' => $options['label'], - 'label_attr' => $options['label_attr'], - 'multiple' => $options['multiple'], 'attr' => ['class' => 'select2'], - ]); - } - - public function configureOptions(OptionsResolver $resolver) - { - $resolver - ->setDefault('label', 'Current location') - ->setDefault('label_attr', []) - ->setDefault('multiple', false) + 'label' => 'Current location', + 'multiple' => false, + ]) ->setAllowedTypes('multiple', ['bool']); } - public function getBlockPrefix(): string + public function getParent(): string { - return 'select2_user_location_type'; + return EntityType::class; } } diff --git a/src/Bundle/ChillMainBundle/Form/UserCurrentLocationType.php b/src/Bundle/ChillMainBundle/Form/UserCurrentLocationType.php new file mode 100644 index 000000000..f1ef83a9f --- /dev/null +++ b/src/Bundle/ChillMainBundle/Form/UserCurrentLocationType.php @@ -0,0 +1,26 @@ +add('currentLocation', Select2UserLocationType::class); + } +} + diff --git a/src/Bundle/ChillPersonBundle/Form/Type/Select2SocialActionType.php b/src/Bundle/ChillPersonBundle/Form/Type/Select2SocialActionType.php index 1365757c7..b53960cad 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/Select2SocialActionType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/Select2SocialActionType.php @@ -15,7 +15,6 @@ use Chill\PersonBundle\Entity\SocialWork\SocialAction; use Chill\PersonBundle\Templating\Entity\SocialActionRender; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; class Select2SocialActionType extends AbstractType @@ -27,33 +26,25 @@ class Select2SocialActionType extends AbstractType $this->actionRender = $actionRender; } - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder->add('social_actions', EntityType::class, [ - 'class' => SocialAction::class, - 'choice_label' => function (SocialAction $sa) { - return $this->actionRender->renderString($sa, []); - }, - 'placeholder' => 'Pick a social action', - 'required' => false, - 'label' => $options['label'], - 'label_attr' => $options['label_attr'], - 'multiple' => $options['multiple'], - 'attr' => ['class' => 'select2'], - ]); - } - public function configureOptions(OptionsResolver $resolver) { $resolver - ->setDefault('label', 'Social actions') - ->setDefault('label_attr', []) - ->setDefault('multiple', false) + ->setDefaults([ + 'class' => SocialAction::class, + 'choice_label' => function (SocialAction $sa) { + return $this->actionRender->renderString($sa, []); + }, + 'placeholder' => 'Pick a social action', + 'required' => false, + 'attr' => ['class' => 'select2'], + 'label' => 'Social actions', + 'multiple' => false, + ]) ->setAllowedTypes('multiple', ['bool']); } - public function getBlockPrefix(): string + public function getParent(): string { - return 'select2_social_action_type'; + return EntityType::class; } } diff --git a/src/Bundle/ChillPersonBundle/Form/Type/Select2SocialIssueType.php b/src/Bundle/ChillPersonBundle/Form/Type/Select2SocialIssueType.php index 04b2f723d..aeaeafe34 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/Select2SocialIssueType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/Select2SocialIssueType.php @@ -15,7 +15,6 @@ use Chill\PersonBundle\Entity\SocialWork\SocialIssue; use Chill\PersonBundle\Templating\Entity\SocialIssueRender; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; class Select2SocialIssueType extends AbstractType @@ -27,33 +26,25 @@ class Select2SocialIssueType extends AbstractType $this->issueRender = $issueRender; } - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder->add('social_issues', EntityType::class, [ - 'class' => SocialIssue::class, - 'choice_label' => function (SocialIssue $si) { - return $this->issueRender->renderString($si, []); - }, - 'placeholder' => 'Pick a social issue', - 'required' => false, - 'label' => $options['label'], - 'label_attr' => $options['label_attr'], - 'multiple' => $options['multiple'], - 'attr' => ['class' => 'select2'], - ]); - } - public function configureOptions(OptionsResolver $resolver) { $resolver - ->setDefault('label', 'Social issues') - ->setDefault('label_attr', []) - ->setDefault('multiple', false) + ->setDefaults([ + 'class' => SocialIssue::class, + 'choice_label' => function (SocialIssue $si) { + return $this->issueRender->renderString($si, []); + }, + 'placeholder' => 'Pick a social issue', + 'required' => false, + 'attr' => ['class' => 'select2'], + 'label' => 'Social issues', + 'multiple' => false, + ]) ->setAllowedTypes('multiple', ['bool']); } - public function getBlockPrefix(): string + public function getParent(): string { - return 'select2_social_issue_type'; + return EntityType::class; } } From 6d40ef279f2425c21510964107bb8af4b0c374af Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Sun, 16 Oct 2022 13:53:05 +0200 Subject: [PATCH 19/51] issue641: simplify alterQuery where clause in concerned filters --- .../Filter/ACPFilters/BySocialActionFilter.php | 13 ++----------- .../Filter/ACPFilters/BySocialIssueFilter.php | 13 ++----------- .../SocialActionFilter.php | 12 ++---------- .../SocialIssueFilter.php | 15 ++------------- 4 files changed, 8 insertions(+), 45 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialActionFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialActionFilter.php index 4502450cb..f15d88bb0 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialActionFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialActionFilter.php @@ -15,7 +15,6 @@ use Chill\ActivityBundle\Export\Declarations; use Chill\MainBundle\Export\FilterInterface; use Chill\PersonBundle\Form\Type\Select2SocialActionType; use Chill\PersonBundle\Templating\Entity\SocialActionRender; -use Doctrine\ORM\Query\Expr\Andx; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; use function in_array; @@ -36,22 +35,14 @@ class BySocialActionFilter implements FilterInterface public function alterQuery(QueryBuilder $qb, $data) { - $where = $qb->getDQLPart('where'); - if (!in_array('actsocialaction', $qb->getAllAliases(), true)) { $qb->join('activity.socialActions', 'actsocialaction'); } $clause = $qb->expr()->in('actsocialaction.id', ':socialactions'); - if ($where instanceof Andx) { - $where->add($clause); - } else { - $where = $qb->expr()->andX($clause); - } - - $qb->add('where', $where); - $qb->setParameter('socialactions', $data['accepted_socialactions']); + $qb ->andWhere($clause) + ->setParameter('socialactions', $data['accepted_socialactions']); } public function applyOn(): string diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialIssueFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialIssueFilter.php index 59d79d21d..b9d1856c8 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialIssueFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialIssueFilter.php @@ -15,7 +15,6 @@ use Chill\ActivityBundle\Export\Declarations; use Chill\MainBundle\Export\FilterInterface; use Chill\PersonBundle\Form\Type\Select2SocialIssueType; use Chill\PersonBundle\Templating\Entity\SocialIssueRender; -use Doctrine\ORM\Query\Expr\Andx; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; use function in_array; @@ -36,22 +35,14 @@ class BySocialIssueFilter implements FilterInterface public function alterQuery(QueryBuilder $qb, $data) { - $where = $qb->getDQLPart('where'); - if (!in_array('actsocialissue', $qb->getAllAliases(), true)) { $qb->join('activity.socialIssues', 'actsocialissue'); } $clause = $qb->expr()->in('actsocialissue.id', ':socialissues'); - if ($where instanceof Andx) { - $where->add($clause); - } else { - $where = $qb->expr()->andX($clause); - } - - $qb->add('where', $where); - $qb->setParameter('socialissues', $data['accepted_socialissues']); + $qb ->andWhere($clause) + ->setParameter('socialissues', $data['accepted_socialissues']); } public function applyOn(): string diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php index 6c78d703f..7fb8b3b59 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php @@ -16,7 +16,6 @@ use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\PersonBundle\Export\Declarations; use Chill\PersonBundle\Form\Type\Select2SocialActionType; use Chill\PersonBundle\Templating\Entity\SocialActionRender; -use Doctrine\ORM\Query\Expr\Andx; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; use function in_array; @@ -50,17 +49,10 @@ class SocialActionFilter implements FilterInterface $qb->join('acpw.socialAction', 'acpwsocialaction'); } - $where = $qb->getDQLPart('where'); $clause = $qb->expr()->in('acpwsocialaction.id', ':socialactions'); - if ($where instanceof Andx) { - $where->add($clause); - } else { - $where = $qb->expr()->andX($clause); - } - - $qb->add('where', $where); - $qb->setParameter('socialactions', $data['accepted_socialactions']); + $qb ->andWhere($clause) + ->setParameter('socialactions', $data['accepted_socialactions']); } public function applyOn(): string diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php index b5f52b1fb..06215de55 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php @@ -17,7 +17,6 @@ use Chill\PersonBundle\Entity\SocialWork\SocialIssue; use Chill\PersonBundle\Export\Declarations; use Chill\PersonBundle\Form\Type\Select2SocialIssueType; use Chill\PersonBundle\Templating\Entity\SocialIssueRender; -use Doctrine\ORM\Query\Expr\Andx; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Contracts\Translation\TranslatorInterface; @@ -55,20 +54,10 @@ class SocialIssueFilter implements FilterInterface $qb->join('acp.socialIssues', 'acpsocialissue'); } - $where = $qb->getDQLPart('where'); $clause = $qb->expr()->in('acpsocialissue.id', ':socialissues'); - if ($where instanceof Andx) { - $where->add($clause); - } else { - $where = $qb->expr()->andX($clause); - } - - $qb->add('where', $where); - $qb->setParameter( - 'socialissues', - $this->addParentIssues($data['accepted_socialissues']) - ); + $qb ->andWhere($clause) + ->setParameter('socialissues', $this->addParentIssues($data['accepted_socialissues'])); } public function applyOn() From 8d7b6fea71dffcab2ff214ee9bd00e618df3ac9f Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Sun, 16 Oct 2022 15:34:11 +0200 Subject: [PATCH 20/51] issue641: remove method to add parents socialissues (bad understanding) --- .../SocialIssueFilter.php | 41 +------------------ 1 file changed, 2 insertions(+), 39 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php index 06215de55..a64dda2b8 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php @@ -13,7 +13,6 @@ namespace Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters; use Chill\MainBundle\Export\FilterInterface; use Chill\MainBundle\Templating\TranslatableStringHelper; -use Chill\PersonBundle\Entity\SocialWork\SocialIssue; use Chill\PersonBundle\Export\Declarations; use Chill\PersonBundle\Form\Type\Select2SocialIssueType; use Chill\PersonBundle\Templating\Entity\SocialIssueRender; @@ -57,7 +56,7 @@ class SocialIssueFilter implements FilterInterface $clause = $qb->expr()->in('acpsocialissue.id', ':socialissues'); $qb ->andWhere($clause) - ->setParameter('socialissues', $this->addParentIssues($data['accepted_socialissues'])); + ->setParameter('socialissues', $data['accepted_socialissues']); } public function applyOn() @@ -76,7 +75,7 @@ class SocialIssueFilter implements FilterInterface { $issues = []; - $socialissues = $this->addParentIssues($data['accepted_socialissues']); + $socialissues = $data['accepted_socialissues']; foreach ($socialissues as $i) { if ('null' === $i) { @@ -96,40 +95,4 @@ class SocialIssueFilter implements FilterInterface { return 'Filter by social issue'; } - - /** - * "Le filtre retiendra les parcours qui comportent cette problématique, - * ou une problématique parente à celles choisies.". - * - * Add parent of each socialissue selected, and remove duplicates - * - * @param $accepted_issues - */ - private function addParentIssues($accepted_issues): array - { - $array = []; - - foreach ($accepted_issues as $i) { - /** @var SocialIssue $i */ - if ($i->hasParent()) { - $array[] = $i->getParent(); - } - $array[] = $i; - } - - return $this->removeDuplicate($array); - } - - private function removeDuplicate(array $array): array - { - $ids = array_map(static function ($item) { - return $item->getId(); - }, $array); - - $unique_ids = array_unique($ids); - - return array_values( - array_intersect_key($array, $unique_ids) - ); - } } From de7ba29853544aa15c5d30827564457349397ef2 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Sun, 16 Oct 2022 18:38:00 +0200 Subject: [PATCH 21/51] issue641: form select2 list activated socialissues and sort by ordering --- .../Form/Type/Select2SocialIssueType.php | 11 +++++++++-- .../SocialWork/SocialIssueRepository.php | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Form/Type/Select2SocialIssueType.php b/src/Bundle/ChillPersonBundle/Form/Type/Select2SocialIssueType.php index aeaeafe34..615c2830d 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/Select2SocialIssueType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/Select2SocialIssueType.php @@ -12,6 +12,7 @@ declare(strict_types=1); namespace Chill\PersonBundle\Form\Type; use Chill\PersonBundle\Entity\SocialWork\SocialIssue; +use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository; use Chill\PersonBundle\Templating\Entity\SocialIssueRender; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; @@ -21,9 +22,14 @@ class Select2SocialIssueType extends AbstractType { private SocialIssueRender $issueRender; - public function __construct(SocialIssueRender $issueRender) - { + private SocialIssueRepository $issueRepository; + + public function __construct( + SocialIssueRender $issueRender, + SocialIssueRepository $issueRepository + ) { $this->issueRender = $issueRender; + $this->issueRepository = $issueRepository; } public function configureOptions(OptionsResolver $resolver) @@ -31,6 +37,7 @@ class Select2SocialIssueType extends AbstractType $resolver ->setDefaults([ 'class' => SocialIssue::class, + 'choices' => $this->issueRepository->findIssuesNotDesactivated(), 'choice_label' => function (SocialIssue $si) { return $this->issueRender->renderString($si, []); }, diff --git a/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialIssueRepository.php b/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialIssueRepository.php index 27b4ed4e9..0c18cd970 100644 --- a/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialIssueRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialIssueRepository.php @@ -14,6 +14,7 @@ namespace Chill\PersonBundle\Repository\SocialWork; use Chill\PersonBundle\Entity\SocialWork\SocialIssue; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; +use Doctrine\ORM\QueryBuilder; use Doctrine\Persistence\ObjectRepository; final class SocialIssueRepository implements ObjectRepository @@ -61,4 +62,21 @@ final class SocialIssueRepository implements ObjectRepository { return SocialIssue::class; } + + public function findIssuesNotDesactivated(): array + { + return $this->buildQueryWithDesactivatedDateCriteria()->getQuery()->getResult(); + } + + private function buildQueryWithDesactivatedDateCriteria(): QueryBuilder + { + $qb = $this->repository->createQueryBuilder('si'); + + $qb ->where('si.desactivationDate is null') + ->orWhere('si.desactivationDate > :now') + ->orderBy('si.ordering', 'ASC') + ->setParameter('now', new \DateTime('now')); + + return $qb; + } } From ccea6dd95cceef084b4c215024042ac02397f41b Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Sun, 16 Oct 2022 19:22:19 +0200 Subject: [PATCH 22/51] issue641: add descendants to selected in alterQuery --- .../SocialIssueFilter.php | 44 ++++++++++++++++--- 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php index a64dda2b8..aa689165f 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php @@ -13,6 +13,7 @@ namespace Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters; use Chill\MainBundle\Export\FilterInterface; use Chill\MainBundle\Templating\TranslatableStringHelper; +use Chill\PersonBundle\Entity\SocialWork\SocialIssue; use Chill\PersonBundle\Export\Declarations; use Chill\PersonBundle\Form\Type\Select2SocialIssueType; use Chill\PersonBundle\Templating\Entity\SocialIssueRender; @@ -56,7 +57,9 @@ class SocialIssueFilter implements FilterInterface $clause = $qb->expr()->in('acpsocialissue.id', ':socialissues'); $qb ->andWhere($clause) - ->setParameter('socialissues', $data['accepted_socialissues']); + ->setParameter('socialissues', + $this->addDescendantsIssues($data['accepted_socialissues']) + ); } public function applyOn() @@ -71,17 +74,18 @@ class SocialIssueFilter implements FilterInterface ]); } - public function describeAction($data, $format = 'string') + public function describeAction($data, $format = 'string'): array { $issues = []; $socialissues = $data['accepted_socialissues']; - foreach ($socialissues as $i) { - if ('null' === $i) { + foreach ($socialissues as $si) { + /** @var SocialIssue $si */ + if (null === $si) { $issues[] = $this->translator->trans('Not given'); } else { - $issues[] = $this->socialIssueRender->renderString($i, []); + $issues[] = $this->socialIssueRender->renderString($si, []); } } @@ -91,8 +95,36 @@ class SocialIssueFilter implements FilterInterface ], ]; } - public function getTitle() + public function getTitle(): string { return 'Filter by social issue'; } + + private function addDescendantsIssues($accepted_socialissues): array + { + $array = []; + + foreach ($accepted_socialissues as $si) { + /** @var SocialIssue $si */ + $array[] = $si; + if (!$si->hasParent()) { + $array = array_merge($array, $si->getDescendants()->toArray()); + } + } + + return $this->removeDuplicate($array); + } + + private function removeDuplicate(array $array): array + { + $ids = array_map(static function ($item) { + return $item->getId(); + }, $array); + + $unique_ids = array_unique($ids); + + return array_values( + array_intersect_key($array, $unique_ids) + ); + } } From 6b1155b9d8a6bb263737456768314ef0e0b038f2 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Sun, 16 Oct 2022 19:35:18 +0200 Subject: [PATCH 23/51] issue641: don't list all children if parent is chosen add mechanism to differenciate string in export --- .../SocialIssueFilter.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php index aa689165f..c72c78aa5 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php @@ -85,7 +85,8 @@ class SocialIssueFilter implements FilterInterface if (null === $si) { $issues[] = $this->translator->trans('Not given'); } else { - $issues[] = $this->socialIssueRender->renderString($si, []); + $issues[] = $this->renderIssue($si); + } } @@ -127,4 +128,17 @@ class SocialIssueFilter implements FilterInterface array_intersect_key($array, $unique_ids) ); } + + private function renderIssue(SocialIssue $si): string + { + $render_str = $this->socialIssueRender->renderString($si, []); + + if (!$si->hasParent()) { + if (count($si->getDescendants()) > 0) { + return $render_str . " (et dérivés)"; + } + } + + return $render_str; + } } From 71f989f00e05694173b08ae13c734276836bfaaa Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Sun, 16 Oct 2022 20:06:18 +0200 Subject: [PATCH 24/51] issue641: same for actions: take children, propose only associated and sort them by ordering --- .../SocialActionFilter.php | 56 +++++++++++++++++-- .../Form/Type/Select2SocialActionType.php | 11 +++- .../SocialWork/SocialActionRepository.php | 17 ++++++ 3 files changed, 77 insertions(+), 7 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php index 7fb8b3b59..138583ef2 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php @@ -13,6 +13,7 @@ namespace Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters; use Chill\MainBundle\Export\FilterInterface; use Chill\MainBundle\Templating\TranslatableStringHelper; +use Chill\PersonBundle\Entity\SocialWork\SocialAction; use Chill\PersonBundle\Export\Declarations; use Chill\PersonBundle\Form\Type\Select2SocialActionType; use Chill\PersonBundle\Templating\Entity\SocialActionRender; @@ -52,7 +53,9 @@ class SocialActionFilter implements FilterInterface $clause = $qb->expr()->in('acpwsocialaction.id', ':socialactions'); $qb ->andWhere($clause) - ->setParameter('socialactions', $data['accepted_socialactions']); + ->setParameter('socialactions', + $this->addDescendantsActions($data['accepted_socialactions']) + ); } public function applyOn(): string @@ -69,14 +72,16 @@ class SocialActionFilter implements FilterInterface public function describeAction($data, $format = 'string'): array { - $socialactions = []; + $actions = []; - foreach ($data['accepted_socialactions'] as $sa) { - $socialactions[] = $this->actionRender->renderString($sa, []); + $socialactions = $data['accepted_socialactions']; + + foreach ($socialactions as $action) { + $actions[] = $this->renderAction($action); } return ['Filtered by socialactions: only %socialactions%', [ - '%socialactions%' => implode(', ou ', $socialactions), + '%socialactions%' => implode(', ou ', $actions), ]]; } @@ -84,4 +89,45 @@ class SocialActionFilter implements FilterInterface { return 'Filter by socialaction'; } + + private function addDescendantsActions($accepted_socialactions): array + { + $array = []; + + foreach ($accepted_socialactions as $action) { + /** @var SocialAction $action */ + $array[] = $action; + if (!$action->hasParent()) { + $array = array_merge($array, $action->getDescendants()->toArray()); + } + } + + return $this->removeDuplicate($array); + } + + private function removeDuplicate(array $array): array + { + $ids = array_map(static function ($item) { + return $item->getId(); + }, $array); + + $unique_ids = array_unique($ids); + + return array_values( + array_intersect_key($array, $unique_ids) + ); + } + + private function renderAction(SocialAction $action): string + { + $render_str = $this->actionRender->renderString($action, []); + + if (!$action->hasParent()) { + if (count($action->getDescendants()) > 0) { + return $render_str . " (et dérivés)"; + } + } + + return $render_str; + } } diff --git a/src/Bundle/ChillPersonBundle/Form/Type/Select2SocialActionType.php b/src/Bundle/ChillPersonBundle/Form/Type/Select2SocialActionType.php index b53960cad..ab22f2972 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/Select2SocialActionType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/Select2SocialActionType.php @@ -12,6 +12,7 @@ declare(strict_types=1); namespace Chill\PersonBundle\Form\Type; use Chill\PersonBundle\Entity\SocialWork\SocialAction; +use Chill\PersonBundle\Repository\SocialWork\SocialActionRepository; use Chill\PersonBundle\Templating\Entity\SocialActionRender; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; @@ -21,9 +22,14 @@ class Select2SocialActionType extends AbstractType { private SocialActionRender $actionRender; - public function __construct(SocialActionRender $actionRender) - { + private SocialActionRepository $actionRepository; + + public function __construct( + SocialActionRender $actionRender, + SocialActionRepository $actionRepository + ) { $this->actionRender = $actionRender; + $this->actionRepository = $actionRepository; } public function configureOptions(OptionsResolver $resolver) @@ -31,6 +37,7 @@ class Select2SocialActionType extends AbstractType $resolver ->setDefaults([ 'class' => SocialAction::class, + 'choices' => $this->actionRepository->findActionsNotDesactivated(), 'choice_label' => function (SocialAction $sa) { return $this->actionRender->renderString($sa, []); }, diff --git a/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialActionRepository.php b/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialActionRepository.php index 052432741..3b8715d7e 100644 --- a/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialActionRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialActionRepository.php @@ -67,4 +67,21 @@ final class SocialActionRepository implements ObjectRepository { return SocialAction::class; } + + public function findActionsNotDesactivated(): array + { + return $this->buildQueryWithDesactivatedDateCriteria()->getQuery()->getResult(); + } + + private function buildQueryWithDesactivatedDateCriteria(): QueryBuilder + { + $qb = $this->repository->createQueryBuilder('sa'); + + $qb ->where('sa.desactivationDate is null') + ->orWhere('sa.desactivationDate > :now') + ->orderBy('sa.ordering', 'ASC') + ->setParameter('now', new \DateTime('now')); + + return $qb; + } } From 32ddc5465c02e97ffe078765a7d9c04e053aad03 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Mon, 17 Oct 2022 09:52:29 +0200 Subject: [PATCH 25/51] review: fix stuffs on socialAction and socialIssue filters: * filters call static entity method * add renderString option to manage add_children * add tests on new entity method getDescendantsWithThisFor..() * rename function in repository * rename 'Select2..' classes by 'Pick..' and replace all occurences --- .../ACPFilters/BySocialActionFilter.php | 17 ++++-- .../Filter/ACPFilters/BySocialIssueFilter.php | 17 ++++-- .../Filter/ACPFilters/LocationTypeFilter.php | 4 +- ...nTypeType.php => PickLocationTypeType.php} | 2 +- ...ationType.php => PickUserLocationType.php} | 2 +- .../Form/UserCurrentLocationType.php | 4 +- .../ChillMainBundle/config/services/form.yaml | 8 --- .../Entity/SocialWork/SocialAction.php | 22 +++++++ .../Entity/SocialWork/SocialIssue.php | 22 +++++++ .../AdministrativeLocationFilter.php | 4 +- .../SocialActionFilter.php | 57 +++-------------- .../SocialIssueFilter.php | 61 +++---------------- ...ctionType.php => PickSocialActionType.php} | 4 +- ...lIssueType.php => PickSocialIssueType.php} | 4 +- .../SocialWork/SocialActionRepository.php | 5 +- .../SocialWork/SocialIssueRepository.php | 5 +- .../Templating/Entity/SocialActionRender.php | 30 +++++++-- .../Templating/Entity/SocialIssueRender.php | 30 +++++++-- .../Entity/SocialWork/SocialActionTest.php | 53 ++++++++++++++++ .../Entity/SocialWork/SocialIssueTest.php | 29 +++++++++ .../config/services/form.yaml | 8 --- .../translations/messages.fr.yml | 7 +++ 22 files changed, 244 insertions(+), 151 deletions(-) rename src/Bundle/ChillMainBundle/Form/Type/{Select2LocationTypeType.php => PickLocationTypeType.php} (96%) rename src/Bundle/ChillMainBundle/Form/Type/{Select2UserLocationType.php => PickUserLocationType.php} (97%) rename src/Bundle/ChillPersonBundle/Form/Type/{Select2SocialActionType.php => PickSocialActionType.php} (92%) rename src/Bundle/ChillPersonBundle/Form/Type/{Select2SocialIssueType.php => PickSocialIssueType.php} (92%) create mode 100644 src/Bundle/ChillPersonBundle/Tests/Entity/SocialWork/SocialActionTest.php diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialActionFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialActionFilter.php index f15d88bb0..a7d6e5e3a 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialActionFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialActionFilter.php @@ -13,7 +13,8 @@ namespace Chill\ActivityBundle\Export\Filter\ACPFilters; use Chill\ActivityBundle\Export\Declarations; use Chill\MainBundle\Export\FilterInterface; -use Chill\PersonBundle\Form\Type\Select2SocialActionType; +use Chill\PersonBundle\Entity\SocialWork\SocialAction; +use Chill\PersonBundle\Form\Type\PickSocialActionType; use Chill\PersonBundle\Templating\Entity\SocialActionRender; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; @@ -41,8 +42,10 @@ class BySocialActionFilter implements FilterInterface $clause = $qb->expr()->in('actsocialaction.id', ':socialactions'); - $qb ->andWhere($clause) - ->setParameter('socialactions', $data['accepted_socialactions']); + $qb->andWhere($clause) + ->setParameter('socialactions', + SocialAction::getDescendantsWithThisForActions($data['accepted_socialactions']) + ); } public function applyOn(): string @@ -52,7 +55,7 @@ class BySocialActionFilter implements FilterInterface public function buildForm(FormBuilderInterface $builder) { - $builder->add('accepted_socialactions', Select2SocialActionType::class, [ + $builder->add('accepted_socialactions', PickSocialActionType::class, [ 'multiple' => true ]); } @@ -61,8 +64,10 @@ class BySocialActionFilter implements FilterInterface { $actions = []; - foreach ($data['accepted_socialactions'] as $sa) { - $actions[] = $this->actionRender->renderString($sa, []); + foreach ($data['accepted_socialactions'] as $action) { + $actions[] = $this->actionRender->renderString($action, [ + 'show_and_children' => true, + ]); } return ['Filtered activity by linked socialaction: only %actions%', [ diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialIssueFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialIssueFilter.php index b9d1856c8..94189169d 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialIssueFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialIssueFilter.php @@ -13,7 +13,8 @@ namespace Chill\ActivityBundle\Export\Filter\ACPFilters; use Chill\ActivityBundle\Export\Declarations; use Chill\MainBundle\Export\FilterInterface; -use Chill\PersonBundle\Form\Type\Select2SocialIssueType; +use Chill\PersonBundle\Entity\SocialWork\SocialIssue; +use Chill\PersonBundle\Form\Type\PickSocialIssueType; use Chill\PersonBundle\Templating\Entity\SocialIssueRender; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; @@ -41,8 +42,10 @@ class BySocialIssueFilter implements FilterInterface $clause = $qb->expr()->in('actsocialissue.id', ':socialissues'); - $qb ->andWhere($clause) - ->setParameter('socialissues', $data['accepted_socialissues']); + $qb->andWhere($clause) + ->setParameter('socialissues', + SocialIssue::getDescendantsWithThisForIssues($data['accepted_socialissues']) + ); } public function applyOn(): string @@ -52,7 +55,7 @@ class BySocialIssueFilter implements FilterInterface public function buildForm(FormBuilderInterface $builder) { - $builder->add('accepted_socialissues', Select2SocialIssueType::class, [ + $builder->add('accepted_socialissues', PickSocialIssueType::class, [ 'multiple' => true ]); } @@ -61,8 +64,10 @@ class BySocialIssueFilter implements FilterInterface { $issues = []; - foreach ($data['accepted_socialissues'] as $si) { - $issues[] = $this->issueRender->renderString($si, []); + foreach ($data['accepted_socialissues'] as $issue) { + $issues[] = $this->issueRender->renderString($issue, [ + 'show_and_children' => true, + ]); } return ['Filtered activity by linked socialissue: only %issues%', [ diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationTypeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationTypeFilter.php index 023882cf9..2c9244022 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationTypeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationTypeFilter.php @@ -13,7 +13,7 @@ namespace Chill\ActivityBundle\Export\Filter\ACPFilters; use Chill\ActivityBundle\Export\Declarations; use Chill\MainBundle\Export\FilterInterface; -use Chill\MainBundle\Form\Type\Select2LocationTypeType; +use Chill\MainBundle\Form\Type\PickLocationTypeType; use Chill\MainBundle\Templating\TranslatableStringHelper; use Doctrine\ORM\Query\Expr\Andx; use Doctrine\ORM\QueryBuilder; @@ -60,7 +60,7 @@ class LocationTypeFilter implements FilterInterface public function buildForm(FormBuilderInterface $builder) { - $builder->add('accepted_locationtype', Select2LocationTypeType::class, [ + $builder->add('accepted_locationtype', PickLocationTypeType::class, [ 'multiple' => true, //'label' => false, ]); diff --git a/src/Bundle/ChillMainBundle/Form/Type/Select2LocationTypeType.php b/src/Bundle/ChillMainBundle/Form/Type/PickLocationTypeType.php similarity index 96% rename from src/Bundle/ChillMainBundle/Form/Type/Select2LocationTypeType.php rename to src/Bundle/ChillMainBundle/Form/Type/PickLocationTypeType.php index 33121f8bb..6774e0941 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/Select2LocationTypeType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PickLocationTypeType.php @@ -17,7 +17,7 @@ use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; use Symfony\Component\OptionsResolver\OptionsResolver; -class Select2LocationTypeType extends AbstractType +class PickLocationTypeType extends AbstractType { private TranslatableStringHelper $translatableStringHelper; diff --git a/src/Bundle/ChillMainBundle/Form/Type/Select2UserLocationType.php b/src/Bundle/ChillMainBundle/Form/Type/PickUserLocationType.php similarity index 97% rename from src/Bundle/ChillMainBundle/Form/Type/Select2UserLocationType.php rename to src/Bundle/ChillMainBundle/Form/Type/PickUserLocationType.php index 3c1e51e68..792daa39e 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/Select2UserLocationType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PickUserLocationType.php @@ -18,7 +18,7 @@ use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; use Symfony\Component\OptionsResolver\OptionsResolver; -class Select2UserLocationType extends AbstractType +class PickUserLocationType extends AbstractType { private LocationRepository $locationRepository; diff --git a/src/Bundle/ChillMainBundle/Form/UserCurrentLocationType.php b/src/Bundle/ChillMainBundle/Form/UserCurrentLocationType.php index f1ef83a9f..657ba8942 100644 --- a/src/Bundle/ChillMainBundle/Form/UserCurrentLocationType.php +++ b/src/Bundle/ChillMainBundle/Form/UserCurrentLocationType.php @@ -11,7 +11,7 @@ declare(strict_types=1); namespace Chill\MainBundle\Form; -use Chill\MainBundle\Form\Type\Select2UserLocationType; +use Chill\MainBundle\Form\Type\PickUserLocationType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; @@ -20,7 +20,7 @@ class UserCurrentLocationType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { - $builder->add('currentLocation', Select2UserLocationType::class); + $builder->add('currentLocation', PickUserLocationType::class); } } diff --git a/src/Bundle/ChillMainBundle/config/services/form.yaml b/src/Bundle/ChillMainBundle/config/services/form.yaml index 34f5d1802..4408a7223 100644 --- a/src/Bundle/ChillMainBundle/config/services/form.yaml +++ b/src/Bundle/ChillMainBundle/config/services/form.yaml @@ -130,14 +130,6 @@ services: autowire: true autoconfigure: true - Chill\MainBundle\Form\Type\Select2UserLocationType: - autowire: true - autoconfigure: true - - Chill\MainBundle\Form\Type\Select2LocationTypeType: - autowire: true - autoconfigure: true - Chill\MainBundle\Form\Type\LocationFormType: ~ Chill\MainBundle\Form\WorkflowStepType: ~ diff --git a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php index bc81bc180..ea5df8fe0 100644 --- a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php +++ b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php @@ -227,6 +227,23 @@ class SocialAction return $descendants; } + /** + * @param Collection|SocialAction[] $socialActions + * @return Collection + */ + public static function getDescendantsWithThisForActions($socialActions): Collection + { + $unique = []; + + foreach ($socialActions as $action) { + foreach ($action->getDescendantsWithThis() as $child) { + $unique[spl_object_hash($child)] = $child; + } + } + + return new ArrayCollection(array_values($unique)); + } + public function getEvaluations(): Collection { return $this->evaluations; @@ -278,6 +295,11 @@ class SocialAction return $this->getParent() instanceof self; } + public function hasChildren(): bool + { + return 0 < $this->getChildren()->count(); + } + /** * Recursive method which return true if the current $action * is a descendant of the $action given in parameter. diff --git a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php index 06f05c91f..d36642977 100644 --- a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php +++ b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php @@ -215,6 +215,23 @@ class SocialIssue return $descendants; } + /** + * @param Collection|SocialIssue[] $socialIssues + * @return Collection + */ + public static function getDescendantsWithThisForIssues(Collection $socialIssues): Collection + { + $unique = []; + + foreach ($socialIssues as $issue) { + foreach ($issue->getDescendantsWithThis() as $child) { + $unique[spl_object_hash($child)] = $child; + } + } + + return new ArrayCollection(array_values($unique)); + } + public function getId(): ?int { return $this->id; @@ -267,6 +284,11 @@ class SocialIssue return null !== $this->parent; } + public function hasChildren(): bool + { + return 0 < $this->getChildren()->count(); + } + /** * Recursive method which return true if the current $issue is a descendant * of the $issue given in parameter. diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/AdministrativeLocationFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/AdministrativeLocationFilter.php index d289220af..19f1a6090 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/AdministrativeLocationFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/AdministrativeLocationFilter.php @@ -12,7 +12,7 @@ declare(strict_types=1); namespace Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters; use Chill\MainBundle\Export\FilterInterface; -use Chill\MainBundle\Form\Type\Select2UserLocationType; +use Chill\MainBundle\Form\Type\PickUserLocationType; use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\PersonBundle\Export\Declarations; use Doctrine\ORM\QueryBuilder; @@ -48,7 +48,7 @@ class AdministrativeLocationFilter implements FilterInterface public function buildForm(FormBuilderInterface $builder) { - $builder->add('accepted_locations', Select2UserLocationType::class, [ + $builder->add('accepted_locations', PickUserLocationType::class, [ 'label' => 'Accepted locations', 'label_attr' => [ //'class' => 'd-none' diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php index 138583ef2..a1834aa0e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php @@ -15,7 +15,7 @@ use Chill\MainBundle\Export\FilterInterface; use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\PersonBundle\Entity\SocialWork\SocialAction; use Chill\PersonBundle\Export\Declarations; -use Chill\PersonBundle\Form\Type\Select2SocialActionType; +use Chill\PersonBundle\Form\Type\PickSocialActionType; use Chill\PersonBundle\Templating\Entity\SocialActionRender; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; @@ -23,10 +23,10 @@ use function in_array; class SocialActionFilter implements FilterInterface { - private SocialActionRender $actionRender; - private TranslatableStringHelper $translatableStringHelper; + private SocialActionRender $actionRender; + public function __construct( TranslatableStringHelper $translatableStringHelper, SocialActionRender $actionRender @@ -52,9 +52,9 @@ class SocialActionFilter implements FilterInterface $clause = $qb->expr()->in('acpwsocialaction.id', ':socialactions'); - $qb ->andWhere($clause) + $qb->andWhere($clause) ->setParameter('socialactions', - $this->addDescendantsActions($data['accepted_socialactions']) + SocialAction::getDescendantsWithThisForActions($data['accepted_socialactions'])->toArray() ); } @@ -65,7 +65,7 @@ class SocialActionFilter implements FilterInterface public function buildForm(FormBuilderInterface $builder) { - $builder->add('accepted_socialactions', Select2SocialActionType::class, [ + $builder->add('accepted_socialactions', PickSocialActionType::class, [ 'multiple' => true, ]); } @@ -77,7 +77,9 @@ class SocialActionFilter implements FilterInterface $socialactions = $data['accepted_socialactions']; foreach ($socialactions as $action) { - $actions[] = $this->renderAction($action); + $actions[] = $this->actionRender->renderString($action, [ + 'show_and_children' => true, + ]); } return ['Filtered by socialactions: only %socialactions%', [ @@ -89,45 +91,4 @@ class SocialActionFilter implements FilterInterface { return 'Filter by socialaction'; } - - private function addDescendantsActions($accepted_socialactions): array - { - $array = []; - - foreach ($accepted_socialactions as $action) { - /** @var SocialAction $action */ - $array[] = $action; - if (!$action->hasParent()) { - $array = array_merge($array, $action->getDescendants()->toArray()); - } - } - - return $this->removeDuplicate($array); - } - - private function removeDuplicate(array $array): array - { - $ids = array_map(static function ($item) { - return $item->getId(); - }, $array); - - $unique_ids = array_unique($ids); - - return array_values( - array_intersect_key($array, $unique_ids) - ); - } - - private function renderAction(SocialAction $action): string - { - $render_str = $this->actionRender->renderString($action, []); - - if (!$action->hasParent()) { - if (count($action->getDescendants()) > 0) { - return $render_str . " (et dérivés)"; - } - } - - return $render_str; - } } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php index c72c78aa5..08ab7fca2 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php @@ -15,7 +15,7 @@ use Chill\MainBundle\Export\FilterInterface; use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\PersonBundle\Entity\SocialWork\SocialIssue; use Chill\PersonBundle\Export\Declarations; -use Chill\PersonBundle\Form\Type\Select2SocialIssueType; +use Chill\PersonBundle\Form\Type\PickSocialIssueType; use Chill\PersonBundle\Templating\Entity\SocialIssueRender; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; @@ -56,9 +56,9 @@ class SocialIssueFilter implements FilterInterface $clause = $qb->expr()->in('acpsocialissue.id', ':socialissues'); - $qb ->andWhere($clause) + $qb->andWhere($clause) ->setParameter('socialissues', - $this->addDescendantsIssues($data['accepted_socialissues']) + SocialIssue::getDescendantsWithThisForIssues($data['accepted_socialissues']) ); } @@ -69,7 +69,7 @@ class SocialIssueFilter implements FilterInterface public function buildForm(FormBuilderInterface $builder) { - $builder->add('accepted_socialissues', Select2SocialIssueType::class, [ + $builder->add('accepted_socialissues', PickSocialIssueType::class, [ 'multiple' => true, ]); } @@ -80,14 +80,10 @@ class SocialIssueFilter implements FilterInterface $socialissues = $data['accepted_socialissues']; - foreach ($socialissues as $si) { - /** @var SocialIssue $si */ - if (null === $si) { - $issues[] = $this->translator->trans('Not given'); - } else { - $issues[] = $this->renderIssue($si); - - } + foreach ($socialissues as $issue) { + $issues[] = $this->socialIssueRender->renderString($issue, [ + 'show_and_children' => true, + ]); } return [ @@ -100,45 +96,4 @@ class SocialIssueFilter implements FilterInterface { return 'Filter by social issue'; } - - private function addDescendantsIssues($accepted_socialissues): array - { - $array = []; - - foreach ($accepted_socialissues as $si) { - /** @var SocialIssue $si */ - $array[] = $si; - if (!$si->hasParent()) { - $array = array_merge($array, $si->getDescendants()->toArray()); - } - } - - return $this->removeDuplicate($array); - } - - private function removeDuplicate(array $array): array - { - $ids = array_map(static function ($item) { - return $item->getId(); - }, $array); - - $unique_ids = array_unique($ids); - - return array_values( - array_intersect_key($array, $unique_ids) - ); - } - - private function renderIssue(SocialIssue $si): string - { - $render_str = $this->socialIssueRender->renderString($si, []); - - if (!$si->hasParent()) { - if (count($si->getDescendants()) > 0) { - return $render_str . " (et dérivés)"; - } - } - - return $render_str; - } } diff --git a/src/Bundle/ChillPersonBundle/Form/Type/Select2SocialActionType.php b/src/Bundle/ChillPersonBundle/Form/Type/PickSocialActionType.php similarity index 92% rename from src/Bundle/ChillPersonBundle/Form/Type/Select2SocialActionType.php rename to src/Bundle/ChillPersonBundle/Form/Type/PickSocialActionType.php index ab22f2972..7c0da43b1 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/Select2SocialActionType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/PickSocialActionType.php @@ -18,7 +18,7 @@ use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; use Symfony\Component\OptionsResolver\OptionsResolver; -class Select2SocialActionType extends AbstractType +class PickSocialActionType extends AbstractType { private SocialActionRender $actionRender; @@ -37,7 +37,7 @@ class Select2SocialActionType extends AbstractType $resolver ->setDefaults([ 'class' => SocialAction::class, - 'choices' => $this->actionRepository->findActionsNotDesactivated(), + 'choices' => $this->actionRepository->findAllActive(), 'choice_label' => function (SocialAction $sa) { return $this->actionRender->renderString($sa, []); }, diff --git a/src/Bundle/ChillPersonBundle/Form/Type/Select2SocialIssueType.php b/src/Bundle/ChillPersonBundle/Form/Type/PickSocialIssueType.php similarity index 92% rename from src/Bundle/ChillPersonBundle/Form/Type/Select2SocialIssueType.php rename to src/Bundle/ChillPersonBundle/Form/Type/PickSocialIssueType.php index 615c2830d..e79c17191 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/Select2SocialIssueType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/PickSocialIssueType.php @@ -18,7 +18,7 @@ use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; use Symfony\Component\OptionsResolver\OptionsResolver; -class Select2SocialIssueType extends AbstractType +class PickSocialIssueType extends AbstractType { private SocialIssueRender $issueRender; @@ -37,7 +37,7 @@ class Select2SocialIssueType extends AbstractType $resolver ->setDefaults([ 'class' => SocialIssue::class, - 'choices' => $this->issueRepository->findIssuesNotDesactivated(), + 'choices' => $this->issueRepository->findAllActive(), 'choice_label' => function (SocialIssue $si) { return $this->issueRender->renderString($si, []); }, diff --git a/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialActionRepository.php b/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialActionRepository.php index 3b8715d7e..86e8e41a8 100644 --- a/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialActionRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialActionRepository.php @@ -68,7 +68,10 @@ final class SocialActionRepository implements ObjectRepository return SocialAction::class; } - public function findActionsNotDesactivated(): array + /** + * @return array|SocialAction[] + */ + public function findAllActive(): array { return $this->buildQueryWithDesactivatedDateCriteria()->getQuery()->getResult(); } diff --git a/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialIssueRepository.php b/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialIssueRepository.php index 0c18cd970..21831b432 100644 --- a/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialIssueRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialIssueRepository.php @@ -63,7 +63,10 @@ final class SocialIssueRepository implements ObjectRepository return SocialIssue::class; } - public function findIssuesNotDesactivated(): array + /** + * @return array|SocialIssue[] + */ + public function findAllActive(): array { return $this->buildQueryWithDesactivatedDateCriteria()->getQuery()->getResult(); } diff --git a/src/Bundle/ChillPersonBundle/Templating/Entity/SocialActionRender.php b/src/Bundle/ChillPersonBundle/Templating/Entity/SocialActionRender.php index f2ee13fc1..8f1bfaccb 100644 --- a/src/Bundle/ChillPersonBundle/Templating/Entity/SocialActionRender.php +++ b/src/Bundle/ChillPersonBundle/Templating/Entity/SocialActionRender.php @@ -15,7 +15,7 @@ use Chill\MainBundle\Templating\Entity\ChillEntityRenderInterface; use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\PersonBundle\Entity\SocialWork\SocialAction; use Symfony\Component\Templating\EngineInterface; - +use Symfony\Contracts\Translation\TranslatorInterface; use function array_merge; use function array_reverse; use function implode; @@ -25,6 +25,8 @@ class SocialActionRender implements ChillEntityRenderInterface public const DEFAULT_ARGS = [ self::SEPARATOR_KEY => ' > ', self::NO_BADGE => false, + self::SHOW_AND_CHILDREN => false, + self::AND_CHILDREN_MENTION => 'social_action.and children', ]; /** @@ -34,14 +36,28 @@ class SocialActionRender implements ChillEntityRenderInterface 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'; + + public const AND_CHILDREN_MENTION = 'show_and_children_mention'; + private EngineInterface $engine; private TranslatableStringHelper $translatableStringHelper; - public function __construct(TranslatableStringHelper $translatableStringHelper, EngineInterface $engine) - { + private TranslatorInterface $translator; + + public function __construct( + TranslatableStringHelper $translatableStringHelper, + EngineInterface $engine, + TranslatorInterface $translator + ) { $this->translatableStringHelper = $translatableStringHelper; $this->engine = $engine; + $this->translator = $translator; } public function renderBox($socialAction, array $options): string @@ -72,7 +88,13 @@ class SocialActionRender implements ChillEntityRenderInterface $titles = array_reverse($titles); - return implode($options[self::SEPARATOR_KEY], $titles); + $title = implode($options[self::SEPARATOR_KEY], $titles); + + if ($options[self::SHOW_AND_CHILDREN] && $socialAction->hasChildren()) { + $title .= ' (' . $this->translator->trans($options[self::AND_CHILDREN_MENTION]) . ')'; + } + + return $title; } public function supports($entity, array $options): bool diff --git a/src/Bundle/ChillPersonBundle/Templating/Entity/SocialIssueRender.php b/src/Bundle/ChillPersonBundle/Templating/Entity/SocialIssueRender.php index 014b23c8e..20a9c9fd2 100644 --- a/src/Bundle/ChillPersonBundle/Templating/Entity/SocialIssueRender.php +++ b/src/Bundle/ChillPersonBundle/Templating/Entity/SocialIssueRender.php @@ -15,7 +15,7 @@ use Chill\MainBundle\Templating\Entity\ChillEntityRenderInterface; use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\PersonBundle\Entity\SocialWork\SocialIssue; use Symfony\Component\Templating\EngineInterface; - +use Symfony\Contracts\Translation\TranslatorInterface; use function array_reverse; use function implode; @@ -23,18 +23,34 @@ final class SocialIssueRender implements ChillEntityRenderInterface { public const DEFAULT_ARGS = [ self::SEPARATOR_KEY => ' > ', + self::SHOW_AND_CHILDREN => false, + self::AND_CHILDREN_MENTION => 'social_issue.and children', ]; public const SEPARATOR_KEY = 'default.separator'; + /** + * Show a mention "and children" on each SocialIssue, if the social issue + * has at least one child + */ + public const SHOW_AND_CHILDREN = 'show_and_children'; + + public const AND_CHILDREN_MENTION = 'show_and_children_mention'; + private EngineInterface $engine; private TranslatableStringHelper $translatableStringHelper; - public function __construct(TranslatableStringHelper $translatableStringHelper, EngineInterface $engine) - { + private TranslatorInterface $translator; + + public function __construct( + TranslatableStringHelper $translatableStringHelper, + EngineInterface $engine, + TranslatorInterface $translator + ) { $this->translatableStringHelper = $translatableStringHelper; $this->engine = $engine; + $this->translator = $translator; } /** @@ -78,7 +94,13 @@ final class SocialIssueRender implements ChillEntityRenderInterface $titles = array_reverse($titles); - return implode($options[self::SEPARATOR_KEY], $titles); + $title = implode($options[self::SEPARATOR_KEY], $titles); + + if ($options[self::SHOW_AND_CHILDREN] && $socialIssue->hasChildren()) { + $title .= ' (' . $this->translator->trans($options[self::AND_CHILDREN_MENTION]) . ')'; + } + + return $title; } public function supports($entity, array $options): bool diff --git a/src/Bundle/ChillPersonBundle/Tests/Entity/SocialWork/SocialActionTest.php b/src/Bundle/ChillPersonBundle/Tests/Entity/SocialWork/SocialActionTest.php new file mode 100644 index 000000000..2e0b64d6d --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Entity/SocialWork/SocialActionTest.php @@ -0,0 +1,53 @@ +setParent($parentA); + $grandChildA = (new SocialAction())->setParent($childA); + $grandGrandChildA = (new SocialAction())->setParent($grandChildA); + $unrelatedA = new SocialAction(); + + $parentB = new SocialAction(); + $childB = (new SocialAction())->setParent($parentB); + $grandChildB = (new SocialAction())->setParent($childB); + $grandGrandChildB = (new SocialAction())->setParent($grandChildB); + $unrelatedB = new SocialAction(); + + $actual = SocialAction::getDescendantsWithThisForActions([$parentA, $parentB]); + + $this->assertContains($parentA, $actual); + $this->assertContains($parentB, $actual); + $this->assertContains($childA, $actual); + $this->assertContains($childB, $actual); + $this->assertContains($grandChildA, $actual); + $this->assertContains($grandChildB, $actual); + $this->assertContains($grandGrandChildA, $actual); + $this->assertContains($grandGrandChildB, $actual); + $this->assertCount(8, $actual); + $this->assertNotContains($unrelatedA, $actual); + $this->assertNotContains($unrelatedB, $actual); + } + +} \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/Tests/Entity/SocialWork/SocialIssueTest.php b/src/Bundle/ChillPersonBundle/Tests/Entity/SocialWork/SocialIssueTest.php index edc1e5474..aee4bec07 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Entity/SocialWork/SocialIssueTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Entity/SocialWork/SocialIssueTest.php @@ -77,4 +77,33 @@ final class SocialIssueTest extends TestCase $this->assertFalse($child->isDescendantOf($grandChild)); } + + public function testGetDescendantsWithThisForIssues() + { + $parentA = new SocialIssue(); + $childA = (new SocialIssue())->setParent($parentA); + $grandChildA = (new SocialIssue())->setParent($childA); + $grandGrandChildA = (new SocialIssue())->setParent($grandChildA); + $unrelatedA = new SocialIssue(); + + $parentB = new SocialIssue(); + $childB = (new SocialIssue())->setParent($parentB); + $grandChildB = (new SocialIssue())->setParent($childB); + $grandGrandChildB = (new SocialIssue())->setParent($grandChildB); + $unrelatedB = new SocialIssue(); + + $actual = SocialIssue::getDescendantsWithThisForIssues([$parentA, $parentB]); + + $this->assertContains($parentA, $actual); + $this->assertContains($parentB, $actual); + $this->assertContains($childA, $actual); + $this->assertContains($childB, $actual); + $this->assertContains($grandChildA, $actual); + $this->assertContains($grandChildB, $actual); + $this->assertContains($grandGrandChildA, $actual); + $this->assertContains($grandGrandChildB, $actual); + $this->assertCount(8, $actual); + $this->assertNotContains($unrelatedA, $actual); + $this->assertNotContains($unrelatedB, $actual); + } } diff --git a/src/Bundle/ChillPersonBundle/config/services/form.yaml b/src/Bundle/ChillPersonBundle/config/services/form.yaml index 85b97c86b..52bf1f494 100644 --- a/src/Bundle/ChillPersonBundle/config/services/form.yaml +++ b/src/Bundle/ChillPersonBundle/config/services/form.yaml @@ -27,11 +27,3 @@ services: $config: "%chill_person.accompanying_period_fields%" tags: - { name: form.type } - - Chill\PersonBundle\Form\Type\Select2SocialActionType: - autowire: true - autoconfigure: true - - Chill\PersonBundle\Form\Type\Select2SocialIssueType: - autowire: true - autoconfigure: true diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index a755ce0f0..5e4d9aada 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -951,3 +951,10 @@ export: Group course by referrer's scope: Grouper les parcours par service du référent Computation date for referrer: Date à laquelle le référent était actif Referrer's scope: Service du référent de parcours + + +social_action: + and children: et dérivés + +social_issue: + and children: et dérivés \ No newline at end of file From 531e05fc3abd8cb8b5f7a5b1e76a6854988a31e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 17 Oct 2022 17:54:50 +0200 Subject: [PATCH 26/51] DX: fix tests to find ancestor to all SocialAction and SocialIssue --- .../Entity/SocialWork/SocialAction.php | 2 ++ .../Entity/SocialWork/SocialIssue.php | 12 +++++++++--- .../Tests/Entity/SocialWork/SocialActionTest.php | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php index ea5df8fe0..bb393a3b5 100644 --- a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php +++ b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php @@ -389,6 +389,8 @@ class SocialAction { $this->parent = $parent; + $parent->addChild($this); + return $this; } diff --git a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php index d36642977..8708e34f3 100644 --- a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php +++ b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php @@ -71,11 +71,15 @@ class SocialIssue $this->socialActions = new ArrayCollection(); } + /** + * @internal use @see{SocialIssue::setParent} instead + * @param SocialIssue $child + * @return $this + */ public function addChild(self $child): self { if (!$this->children->contains($child)) { $this->children[] = $child; - $child->setParent($this); } return $this; @@ -216,10 +220,10 @@ class SocialIssue } /** - * @param Collection|SocialIssue[] $socialIssues + * @param array|SocialIssue[] $socialIssues * @return Collection */ - public static function getDescendantsWithThisForIssues(Collection $socialIssues): Collection + public static function getDescendantsWithThisForIssues(array $socialIssues): Collection { $unique = []; @@ -351,6 +355,8 @@ class SocialIssue { $this->parent = $parent; + $parent->addChild($this); + return $this; } diff --git a/src/Bundle/ChillPersonBundle/Tests/Entity/SocialWork/SocialActionTest.php b/src/Bundle/ChillPersonBundle/Tests/Entity/SocialWork/SocialActionTest.php index 2e0b64d6d..804ea2b1b 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Entity/SocialWork/SocialActionTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Entity/SocialWork/SocialActionTest.php @@ -50,4 +50,4 @@ final class SocialActionTest extends TestCase $this->assertNotContains($unrelatedB, $actual); } -} \ No newline at end of file +} From 9eb451e359e8eb10727e2acce2d7bff1dfc57c2c Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Tue, 18 Oct 2022 14:37:33 +0200 Subject: [PATCH 27/51] cs fixer --- .../ACPFilters/BySocialActionFilter.php | 5 +- .../Filter/ACPFilters/BySocialIssueFilter.php | 5 +- .../Form/UserCurrentLocationType.php | 2 - .../Test/Export/AbstractAggregatorTest.php | 2 +- .../Test/Export/AbstractFilterTest.php | 1 + .../Entity/SocialWork/SocialAction.php | 11 ++--- .../Entity/SocialWork/SocialIssue.php | 13 +++--- .../SocialActionFilter.php | 7 +-- .../SocialIssueFilter.php | 3 +- .../SocialWork/SocialActionRepository.php | 23 +++++----- .../SocialWork/SocialIssueRepository.php | 21 +++++---- .../Templating/Entity/SocialActionRender.php | 6 +-- .../Templating/Entity/SocialIssueRender.php | 8 ++-- .../Entity/SocialWork/SocialActionTest.php | 2 - .../Entity/SocialWork/SocialIssueTest.php | 46 +++++++++---------- 15 files changed, 79 insertions(+), 76 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialActionFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialActionFilter.php index a7d6e5e3a..b897cde8c 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialActionFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialActionFilter.php @@ -43,7 +43,8 @@ class BySocialActionFilter implements FilterInterface $clause = $qb->expr()->in('actsocialaction.id', ':socialactions'); $qb->andWhere($clause) - ->setParameter('socialactions', + ->setParameter( + 'socialactions', SocialAction::getDescendantsWithThisForActions($data['accepted_socialactions']) ); } @@ -56,7 +57,7 @@ class BySocialActionFilter implements FilterInterface public function buildForm(FormBuilderInterface $builder) { $builder->add('accepted_socialactions', PickSocialActionType::class, [ - 'multiple' => true + 'multiple' => true, ]); } diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialIssueFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialIssueFilter.php index 94189169d..f827c8c56 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialIssueFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialIssueFilter.php @@ -43,7 +43,8 @@ class BySocialIssueFilter implements FilterInterface $clause = $qb->expr()->in('actsocialissue.id', ':socialissues'); $qb->andWhere($clause) - ->setParameter('socialissues', + ->setParameter( + 'socialissues', SocialIssue::getDescendantsWithThisForIssues($data['accepted_socialissues']) ); } @@ -56,7 +57,7 @@ class BySocialIssueFilter implements FilterInterface public function buildForm(FormBuilderInterface $builder) { $builder->add('accepted_socialissues', PickSocialIssueType::class, [ - 'multiple' => true + 'multiple' => true, ]); } diff --git a/src/Bundle/ChillMainBundle/Form/UserCurrentLocationType.php b/src/Bundle/ChillMainBundle/Form/UserCurrentLocationType.php index 657ba8942..bf6a5d172 100644 --- a/src/Bundle/ChillMainBundle/Form/UserCurrentLocationType.php +++ b/src/Bundle/ChillMainBundle/Form/UserCurrentLocationType.php @@ -17,10 +17,8 @@ use Symfony\Component\Form\FormBuilderInterface; class UserCurrentLocationType extends AbstractType { - public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('currentLocation', PickUserLocationType::class); } } - diff --git a/src/Bundle/ChillMainBundle/Test/Export/AbstractAggregatorTest.php b/src/Bundle/ChillMainBundle/Test/Export/AbstractAggregatorTest.php index ffb7e4380..af0e3843a 100644 --- a/src/Bundle/ChillMainBundle/Test/Export/AbstractAggregatorTest.php +++ b/src/Bundle/ChillMainBundle/Test/Export/AbstractAggregatorTest.php @@ -111,6 +111,7 @@ abstract class AbstractAggregatorTest extends KernelTestCase * Compare aliases array before and after that aggregator alter query. * * @dataProvider dataProviderAliasDidNotDisappears + * * @return void */ public function testAliasDidNotDisappears(QueryBuilder $qb, array $data) @@ -290,5 +291,4 @@ abstract class AbstractAggregatorTest extends KernelTestCase 'test that the title is not empty' ); } - } diff --git a/src/Bundle/ChillMainBundle/Test/Export/AbstractFilterTest.php b/src/Bundle/ChillMainBundle/Test/Export/AbstractFilterTest.php index 5632ee022..e1c8665ec 100644 --- a/src/Bundle/ChillMainBundle/Test/Export/AbstractFilterTest.php +++ b/src/Bundle/ChillMainBundle/Test/Export/AbstractFilterTest.php @@ -103,6 +103,7 @@ abstract class AbstractFilterTest extends KernelTestCase * Compare aliases array before and after that filter alter query. * * @dataProvider dataProviderAliasDidNotDisappears + * * @return void */ public function testAliasDidNotDisappears(QueryBuilder $qb, array $data) diff --git a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php index 08fc4bf9e..29e8a413d 100644 --- a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php +++ b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php @@ -230,7 +230,6 @@ class SocialAction /** * @param Collection|SocialAction[] $socialActions - * @return Collection */ public static function getDescendantsWithThisForActions($socialActions): Collection { @@ -291,16 +290,16 @@ class SocialAction return $this->title; } - public function hasParent(): bool - { - return $this->getParent() instanceof self; - } - public function hasChildren(): bool { return 0 < $this->getChildren()->count(); } + public function hasParent(): bool + { + return $this->getParent() instanceof self; + } + /** * Recursive method which return true if the current $action * is a descendant of the $action given in parameter. diff --git a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php index 8708e34f3..42c8442c1 100644 --- a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php +++ b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php @@ -73,7 +73,9 @@ class SocialIssue /** * @internal use @see{SocialIssue::setParent} instead + * * @param SocialIssue $child + * * @return $this */ public function addChild(self $child): self @@ -221,7 +223,6 @@ class SocialIssue /** * @param array|SocialIssue[] $socialIssues - * @return Collection */ public static function getDescendantsWithThisForIssues(array $socialIssues): Collection { @@ -283,16 +284,16 @@ class SocialIssue return $this->title; } - public function hasParent(): bool - { - return null !== $this->parent; - } - public function hasChildren(): bool { return 0 < $this->getChildren()->count(); } + public function hasParent(): bool + { + return null !== $this->parent; + } + /** * Recursive method which return true if the current $issue is a descendant * of the $issue given in parameter. diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php index a1834aa0e..e3bf77af2 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php @@ -23,10 +23,10 @@ use function in_array; class SocialActionFilter implements FilterInterface { - private TranslatableStringHelper $translatableStringHelper; - private SocialActionRender $actionRender; + private TranslatableStringHelper $translatableStringHelper; + public function __construct( TranslatableStringHelper $translatableStringHelper, SocialActionRender $actionRender @@ -53,7 +53,8 @@ class SocialActionFilter implements FilterInterface $clause = $qb->expr()->in('acpwsocialaction.id', ':socialactions'); $qb->andWhere($clause) - ->setParameter('socialactions', + ->setParameter( + 'socialactions', SocialAction::getDescendantsWithThisForActions($data['accepted_socialactions'])->toArray() ); } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php index 08ab7fca2..083c15f91 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php @@ -57,7 +57,8 @@ class SocialIssueFilter implements FilterInterface $clause = $qb->expr()->in('acpsocialissue.id', ':socialissues'); $qb->andWhere($clause) - ->setParameter('socialissues', + ->setParameter( + 'socialissues', SocialIssue::getDescendantsWithThisForIssues($data['accepted_socialissues']) ); } diff --git a/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialActionRepository.php b/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialActionRepository.php index 86e8e41a8..370704aed 100644 --- a/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialActionRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialActionRepository.php @@ -12,6 +12,7 @@ declare(strict_types=1); namespace Chill\PersonBundle\Repository\SocialWork; use Chill\PersonBundle\Entity\SocialWork\SocialAction; +use DateTime; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; use Doctrine\ORM\QueryBuilder; @@ -44,6 +45,14 @@ final class SocialActionRepository implements ObjectRepository return $this->repository->findAll(); } + /** + * @return array|SocialAction[] + */ + public function findAllActive(): array + { + return $this->buildQueryWithDesactivatedDateCriteria()->getQuery()->getResult(); + } + /** * @param mixed|null $limit * @param mixed|null $offset @@ -68,22 +77,14 @@ final class SocialActionRepository implements ObjectRepository return SocialAction::class; } - /** - * @return array|SocialAction[] - */ - public function findAllActive(): array - { - return $this->buildQueryWithDesactivatedDateCriteria()->getQuery()->getResult(); - } - private function buildQueryWithDesactivatedDateCriteria(): QueryBuilder { $qb = $this->repository->createQueryBuilder('sa'); - - $qb ->where('sa.desactivationDate is null') + + $qb->where('sa.desactivationDate is null') ->orWhere('sa.desactivationDate > :now') ->orderBy('sa.ordering', 'ASC') - ->setParameter('now', new \DateTime('now')); + ->setParameter('now', new DateTime('now')); return $qb; } diff --git a/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialIssueRepository.php b/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialIssueRepository.php index 21831b432..8dd8f6a62 100644 --- a/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialIssueRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialIssueRepository.php @@ -12,6 +12,7 @@ declare(strict_types=1); namespace Chill\PersonBundle\Repository\SocialWork; use Chill\PersonBundle\Entity\SocialWork\SocialIssue; +use DateTime; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; use Doctrine\ORM\QueryBuilder; @@ -39,6 +40,14 @@ final class SocialIssueRepository implements ObjectRepository return $this->repository->findAll(); } + /** + * @return array|SocialIssue[] + */ + public function findAllActive(): array + { + return $this->buildQueryWithDesactivatedDateCriteria()->getQuery()->getResult(); + } + /** * @param mixed|null $limit * @param mixed|null $offset @@ -63,22 +72,14 @@ final class SocialIssueRepository implements ObjectRepository return SocialIssue::class; } - /** - * @return array|SocialIssue[] - */ - public function findAllActive(): array - { - return $this->buildQueryWithDesactivatedDateCriteria()->getQuery()->getResult(); - } - private function buildQueryWithDesactivatedDateCriteria(): QueryBuilder { $qb = $this->repository->createQueryBuilder('si'); - $qb ->where('si.desactivationDate is null') + $qb->where('si.desactivationDate is null') ->orWhere('si.desactivationDate > :now') ->orderBy('si.ordering', 'ASC') - ->setParameter('now', new \DateTime('now')); + ->setParameter('now', new DateTime('now')); return $qb; } diff --git a/src/Bundle/ChillPersonBundle/Templating/Entity/SocialActionRender.php b/src/Bundle/ChillPersonBundle/Templating/Entity/SocialActionRender.php index 8f1bfaccb..bfe49c0a4 100644 --- a/src/Bundle/ChillPersonBundle/Templating/Entity/SocialActionRender.php +++ b/src/Bundle/ChillPersonBundle/Templating/Entity/SocialActionRender.php @@ -22,6 +22,8 @@ use function implode; class SocialActionRender implements ChillEntityRenderInterface { + public const AND_CHILDREN_MENTION = 'show_and_children_mention'; + public const DEFAULT_ARGS = [ self::SEPARATOR_KEY => ' > ', self::NO_BADGE => false, @@ -38,12 +40,10 @@ class SocialActionRender implements ChillEntityRenderInterface /** * Show a mention "and children" on each SocialAction, if the social action - * has at least one child + * has at least one child. */ public const SHOW_AND_CHILDREN = 'show_and_children'; - public const AND_CHILDREN_MENTION = 'show_and_children_mention'; - private EngineInterface $engine; private TranslatableStringHelper $translatableStringHelper; diff --git a/src/Bundle/ChillPersonBundle/Templating/Entity/SocialIssueRender.php b/src/Bundle/ChillPersonBundle/Templating/Entity/SocialIssueRender.php index 20a9c9fd2..62d17f47e 100644 --- a/src/Bundle/ChillPersonBundle/Templating/Entity/SocialIssueRender.php +++ b/src/Bundle/ChillPersonBundle/Templating/Entity/SocialIssueRender.php @@ -21,6 +21,8 @@ use function implode; final class SocialIssueRender implements ChillEntityRenderInterface { + public const AND_CHILDREN_MENTION = 'show_and_children_mention'; + public const DEFAULT_ARGS = [ self::SEPARATOR_KEY => ' > ', self::SHOW_AND_CHILDREN => false, @@ -31,11 +33,9 @@ final class SocialIssueRender implements ChillEntityRenderInterface /** * Show a mention "and children" on each SocialIssue, if the social issue - * has at least one child + * has at least one child. */ - public const SHOW_AND_CHILDREN = 'show_and_children'; - - public const AND_CHILDREN_MENTION = 'show_and_children_mention'; + public const SHOW_AND_CHILDREN = 'show_and_children'; private EngineInterface $engine; diff --git a/src/Bundle/ChillPersonBundle/Tests/Entity/SocialWork/SocialActionTest.php b/src/Bundle/ChillPersonBundle/Tests/Entity/SocialWork/SocialActionTest.php index 804ea2b1b..2dcfa6b11 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Entity/SocialWork/SocialActionTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Entity/SocialWork/SocialActionTest.php @@ -12,7 +12,6 @@ declare(strict_types=1); namespace Chill\PersonBundle\Tests\Entity\SocialWork; use Chill\PersonBundle\Entity\SocialWork\SocialAction; -use Doctrine\Common\Collections\ArrayCollection; use PHPUnit\Framework\TestCase; /** @@ -49,5 +48,4 @@ final class SocialActionTest extends TestCase $this->assertNotContains($unrelatedA, $actual); $this->assertNotContains($unrelatedB, $actual); } - } diff --git a/src/Bundle/ChillPersonBundle/Tests/Entity/SocialWork/SocialIssueTest.php b/src/Bundle/ChillPersonBundle/Tests/Entity/SocialWork/SocialIssueTest.php index aee4bec07..b846ae5f4 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Entity/SocialWork/SocialIssueTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Entity/SocialWork/SocialIssueTest.php @@ -55,29 +55,6 @@ final class SocialIssueTest extends TestCase $this->assertCount(0, $unrelated->getAncestors(false)); } - public function testIsDescendantOf() - { - $parent = new SocialIssue(); - $child = (new SocialIssue())->setParent($parent); - $grandChild = (new SocialIssue())->setParent($child); - $grandGrandChild = (new SocialIssue())->setParent($grandChild); - $unrelated = new SocialIssue(); - - $this->assertTrue($grandGrandChild->isDescendantOf($parent)); - $this->assertTrue($grandGrandChild->isDescendantOf($grandChild)); - $this->assertTrue($grandGrandChild->isDescendantOf($child)); - $this->assertFalse($grandGrandChild->isDescendantOf($unrelated)); - - $this->assertTrue($grandChild->isDescendantOf($parent)); - $this->assertTrue($grandChild->isDescendantOf($child)); - $this->assertFalse($grandChild->isDescendantOf($unrelated)); - $this->assertFalse($grandChild->isDescendantOf($grandChild)); - - $this->assertFalse($unrelated->isDescendantOf($parent)); - - $this->assertFalse($child->isDescendantOf($grandChild)); - } - public function testGetDescendantsWithThisForIssues() { $parentA = new SocialIssue(); @@ -106,4 +83,27 @@ final class SocialIssueTest extends TestCase $this->assertNotContains($unrelatedA, $actual); $this->assertNotContains($unrelatedB, $actual); } + + public function testIsDescendantOf() + { + $parent = new SocialIssue(); + $child = (new SocialIssue())->setParent($parent); + $grandChild = (new SocialIssue())->setParent($child); + $grandGrandChild = (new SocialIssue())->setParent($grandChild); + $unrelated = new SocialIssue(); + + $this->assertTrue($grandGrandChild->isDescendantOf($parent)); + $this->assertTrue($grandGrandChild->isDescendantOf($grandChild)); + $this->assertTrue($grandGrandChild->isDescendantOf($child)); + $this->assertFalse($grandGrandChild->isDescendantOf($unrelated)); + + $this->assertTrue($grandChild->isDescendantOf($parent)); + $this->assertTrue($grandChild->isDescendantOf($child)); + $this->assertFalse($grandChild->isDescendantOf($unrelated)); + $this->assertFalse($grandChild->isDescendantOf($grandChild)); + + $this->assertFalse($unrelated->isDescendantOf($parent)); + + $this->assertFalse($child->isDescendantOf($grandChild)); + } } From a7a921ee4d8f188b9e90eb0fca0b2901d3999a08 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Tue, 18 Oct 2022 15:25:43 +0200 Subject: [PATCH 28/51] batch replacing ', ou' in filters --- .../Export/Filter/ACPFilters/ByCreatorFilter.php | 2 +- .../Export/Filter/ACPFilters/BySocialActionFilter.php | 2 +- .../Export/Filter/ACPFilters/BySocialIssueFilter.php | 2 +- .../Export/Filter/ACPFilters/LocationTypeFilter.php | 2 +- .../ChillActivityBundle/Export/Filter/ACPFilters/UserFilter.php | 2 +- .../Export/Filter/ACPFilters/UserScopeFilter.php | 2 +- .../ChillActivityBundle/Export/Filter/ActivityTypeFilter.php | 2 +- src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php | 2 +- src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php | 2 +- src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php | 2 +- .../AccompanyingCourseFilters/AdministrativeLocationFilter.php | 2 +- .../Filter/AccompanyingCourseFilters/ClosingMotiveFilter.php | 2 +- .../Filter/AccompanyingCourseFilters/EvaluationFilter.php | 2 +- .../Export/Filter/AccompanyingCourseFilters/OriginFilter.php | 2 +- .../Export/Filter/AccompanyingCourseFilters/ReferrerFilter.php | 2 +- .../Filter/AccompanyingCourseFilters/SocialActionFilter.php | 2 +- .../Filter/AccompanyingCourseFilters/SocialIssueFilter.php | 2 +- .../Export/Filter/EvaluationFilters/EvaluationTypeFilter.php | 2 +- .../Export/Filter/HouseholdFilters/CompositionFilter.php | 2 +- .../Export/Filter/SocialWorkFilters/JobFilter.php | 2 +- .../Export/Filter/SocialWorkFilters/ReferrerFilter.php | 2 +- .../Export/Filter/SocialWorkFilters/ScopeFilter.php | 2 +- 22 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ByCreatorFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ByCreatorFilter.php index ffabc5934..322393f32 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ByCreatorFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ByCreatorFilter.php @@ -62,7 +62,7 @@ class ByCreatorFilter implements FilterInterface } return ['Filtered activity by creator: only %users%', [ - '%users%' => implode(', ou ', $users), + '%users%' => implode(', ', $users), ]]; } diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialActionFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialActionFilter.php index b897cde8c..d0c1b0fc7 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialActionFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialActionFilter.php @@ -72,7 +72,7 @@ class BySocialActionFilter implements FilterInterface } return ['Filtered activity by linked socialaction: only %actions%', [ - '%actions%' => implode(', ou ', $actions), + '%actions%' => implode(', ', $actions), ]]; } diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialIssueFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialIssueFilter.php index f827c8c56..bbb882a65 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialIssueFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialIssueFilter.php @@ -72,7 +72,7 @@ class BySocialIssueFilter implements FilterInterface } return ['Filtered activity by linked socialissue: only %issues%', [ - '%issues%' => implode(', ou ', $issues), + '%issues%' => implode(', ', $issues), ]]; } diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationTypeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationTypeFilter.php index 2c9244022..5fe928b6c 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationTypeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationTypeFilter.php @@ -77,7 +77,7 @@ class LocationTypeFilter implements FilterInterface } return ['Filtered activity by locationtype: only %types%', [ - '%types%' => implode(', ou ', $types), + '%types%' => implode(', ', $types), ]]; } diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserFilter.php index 9f52c4694..6350f3ace 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserFilter.php @@ -71,7 +71,7 @@ class UserFilter implements FilterInterface } return ['Filtered activity by user: only %users%', [ - '%users%' => implode(', ou ', $users), + '%users%' => implode(', ', $users), ]]; } diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserScopeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserScopeFilter.php index 4568cd006..1906db75e 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserScopeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserScopeFilter.php @@ -85,7 +85,7 @@ class UserScopeFilter implements FilterInterface } return ['Filtered activity by userscope: only %scopes%', [ - '%scopes%' => implode(', ou ', $scopes), + '%scopes%' => implode(', ', $scopes), ]]; } diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php index 5338da791..d1758039a 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php @@ -91,7 +91,7 @@ class ActivityTypeFilter implements ExportElementValidatedInterface, FilterInter ); return ['Filtered by activity type: only %list%', [ - '%list%' => implode(', ou ', $reasonsNames), + '%list%' => implode(', ', $reasonsNames), ]]; } diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php index 7c5d8e80e..ae6589547 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php @@ -76,7 +76,7 @@ class AgentFilter implements FilterInterface return [ 'Filtered by agent: only %agents%', [ - '%agents' => implode(', ou ', $users), + '%agents' => implode(', ', $users), ], ]; } diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php index f25ccad07..c0838bdaa 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php @@ -90,7 +90,7 @@ class JobFilter implements FilterInterface } return ['Filtered by agent job: only %jobs%', [ - '%jobs%' => implode(', ou ', $userJobs), + '%jobs%' => implode(', ', $userJobs), ]]; } diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php index 15380c343..3e76fdae8 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php @@ -90,7 +90,7 @@ class ScopeFilter implements FilterInterface } return ['Filtered by agent scope: only %scopes%', [ - '%scopes%' => implode(', ou ', $scopes), + '%scopes%' => implode(', ', $scopes), ]]; } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/AdministrativeLocationFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/AdministrativeLocationFilter.php index 52f875a5e..c74e309b2 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/AdministrativeLocationFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/AdministrativeLocationFilter.php @@ -63,7 +63,7 @@ class AdministrativeLocationFilter implements FilterInterface } return ['Filtered by administratives locations: only %locations%', [ - '%locations%' => implode(', ou ', $locations), + '%locations%' => implode(', ', $locations), ]]; } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ClosingMotiveFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ClosingMotiveFilter.php index 00ea8210d..07e61b42e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ClosingMotiveFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ClosingMotiveFilter.php @@ -77,7 +77,7 @@ class ClosingMotiveFilter implements FilterInterface return [ 'Filtered by closingmotive: only %closingmotives%', [ - '%closingmotives%' => implode(', ou ', $motives), + '%closingmotives%' => implode(', ', $motives), ], ]; } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EvaluationFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EvaluationFilter.php index 996ff36e3..1839268e1 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EvaluationFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EvaluationFilter.php @@ -87,7 +87,7 @@ class EvaluationFilter implements FilterInterface } return ['Filtered by evaluations: only %evals%', [ - '%evals%' => implode(', ou ', $evaluations), + '%evals%' => implode(', ', $evaluations), ]]; } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OriginFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OriginFilter.php index 9f87f0ca3..445535734 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OriginFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OriginFilter.php @@ -76,7 +76,7 @@ class OriginFilter implements FilterInterface } return ['Filtered by origins: only %origins%', [ - '%origins%' => implode(', ou ', $origins), + '%origins%' => implode(', ', $origins), ]]; } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ReferrerFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ReferrerFilter.php index 8781f6cad..7d1aabc22 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ReferrerFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ReferrerFilter.php @@ -89,7 +89,7 @@ class ReferrerFilter implements FilterInterface return [ 'Filtered by referrer: only %referrers%', [ - '%referrers' => implode(', ou ', $users), + '%referrers' => implode(', ', $users), ], ]; } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php index e3bf77af2..bc1f368da 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php @@ -84,7 +84,7 @@ class SocialActionFilter implements FilterInterface } return ['Filtered by socialactions: only %socialactions%', [ - '%socialactions%' => implode(', ou ', $actions), + '%socialactions%' => implode(', ', $actions), ]]; } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php index 083c15f91..141a1a2db 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php @@ -89,7 +89,7 @@ class SocialIssueFilter implements FilterInterface return [ 'Filtered by socialissues: only %socialissues%', [ - '%socialissues%' => implode(', ou ', $issues), + '%socialissues%' => implode(', ', $issues), ], ]; } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/EvaluationTypeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/EvaluationTypeFilter.php index 2a5c143c7..65e38f41e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/EvaluationTypeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/EvaluationTypeFilter.php @@ -76,7 +76,7 @@ final class EvaluationTypeFilter implements FilterInterface } return ['Filtered by evaluation type: only %evals%', [ - '%evals%' => implode(', ou ', $evals), + '%evals%' => implode(', ', $evals), ]]; } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/HouseholdFilters/CompositionFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/HouseholdFilters/CompositionFilter.php index 9296717ce..3ff8cb63e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/HouseholdFilters/CompositionFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/HouseholdFilters/CompositionFilter.php @@ -95,7 +95,7 @@ class CompositionFilter implements FilterInterface } return ['Filtered by composition: only %compositions% on %ondate%', [ - '%compositions%' => implode(', ou ', $compositions), + '%compositions%' => implode(', ', $compositions), '%ondate%' => $data['on_date']->format('d-m-Y'), ]]; } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/JobFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/JobFilter.php index fd8e14c83..a69e1ac76 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/JobFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/JobFilter.php @@ -90,7 +90,7 @@ class JobFilter implements FilterInterface } return ['Filtered by treating agent job: only %jobs%', [ - '%jobs%' => implode(', ou ', $userjobs), + '%jobs%' => implode(', ', $userjobs), ]]; } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ReferrerFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ReferrerFilter.php index 65d97cbf1..febc57a17 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ReferrerFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ReferrerFilter.php @@ -81,7 +81,7 @@ class ReferrerFilter implements FilterInterface return [ 'Filtered by treating agent: only %agents%', [ - '%agents' => implode(', ou ', $users), + '%agents' => implode(', ', $users), ], ]; } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ScopeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ScopeFilter.php index 6d130ce75..8cb2f6421 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ScopeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ScopeFilter.php @@ -90,7 +90,7 @@ class ScopeFilter implements FilterInterface } return ['Filtered by treating agent scope: only %scopes%', [ - '%scopes%' => implode(', ou ', $scopes), + '%scopes%' => implode(', ', $scopes), ]]; } From a7ade9dac466df979811ea52d9b5b42ac1b8ec1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 18 Oct 2022 10:42:37 +0200 Subject: [PATCH 29/51] DX: use tags iterator to inject aggregators, filters and export during ExportManager's construct MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Squashed commit of the following: commit dc2bbc8f4da24549a1d42feb3b453af9f79ab2ff Author: Julien Fastré Date: Tue Oct 18 10:40:14 2022 +0200 Fixes: remove iterator_to_array on formatter, which causes a PHP crashes commit 4ce56a01a77103661fb790d0988df6625f1fb11b Author: Julien Fastré Date: Mon Oct 17 17:41:14 2022 +0200 DX: use tags and dependency injection to build ExportManager --- .../config/services/export.yaml | 12 +- .../CompilerPass/ExportsCompilerPass.php | 103 +----------------- .../ChillMainBundle/Export/ExportManager.php | 78 ++++--------- .../ChillMainBundle/config/services.yaml | 8 ++ 4 files changed, 35 insertions(+), 166 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/config/services/export.yaml b/src/Bundle/ChillActivityBundle/config/services/export.yaml index 69565e29a..d4548109e 100644 --- a/src/Bundle/ChillActivityBundle/config/services/export.yaml +++ b/src/Bundle/ChillActivityBundle/config/services/export.yaml @@ -4,18 +4,15 @@ services: autoconfigure: true ## Indicators - chill.activity.export.count_activity_linked_to_person: - class: Chill\ActivityBundle\Export\Export\LinkedToPerson\CountActivity + Chill\ActivityBundle\Export\Export\LinkedToPerson\CountActivity: tags: - { name: chill.export, alias: 'count_activity_linked_to_person' } - chill.activity.export.sum_activity_duration_linked_to_person: - class: Chill\ActivityBundle\Export\Export\LinkedToPerson\StatActivityDuration + Chill\ActivityBundle\Export\Export\LinkedToPerson\StatActivityDuration: tags: - { name: chill.export, alias: 'sum_activity_duration_linked_to_person' } - chill.activity.export.list_activity_linked_to_person: - class: Chill\ActivityBundle\Export\Export\LinkedToPerson\ListActivity + Chill\ActivityBundle\Export\Export\LinkedToPerson\ListActivity: tags: - { name: chill.export, alias: 'list_activity_linked_to_person' } @@ -116,8 +113,7 @@ services: - { name: chill.export_filter, alias: 'activity_userscope_filter' } ## Aggregators - chill.activity.export.reason_aggregator: - class: Chill\ActivityBundle\Export\Aggregator\PersonAggregators\ActivityReasonAggregator + Chill\ActivityBundle\Export\Aggregator\PersonAggregators\ActivityReasonAggregator: tags: - { name: chill.export_aggregator, alias: activity_reason_aggregator } diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/ExportsCompilerPass.php b/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/ExportsCompilerPass.php index ae85ba22c..5c351728a 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/ExportsCompilerPass.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/ExportsCompilerPass.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\MainBundle\DependencyInjection\CompilerPass; +use Chill\MainBundle\Export\ExportManager; use LogicException; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -30,53 +31,19 @@ class ExportsCompilerPass implements CompilerPassInterface { public function process(ContainerBuilder $container) { - if (!$container->has('Chill\MainBundle\Export\ExportManager')) { - throw new LogicException('service Chill\MainBundle\Export\ExportManager ' + if (!$container->has(ExportManager::class)) { + throw new LogicException('service ' . ExportManager::class . ' ' . 'is not defined. It is required by ExportsCompilerPass'); } $chillManagerDefinition = $container->findDefinition( - 'Chill\MainBundle\Export\ExportManager' + ExportManager::class ); - $this->compileExports($chillManagerDefinition, $container); - $this->compileFilters($chillManagerDefinition, $container); - $this->compileAggregators($chillManagerDefinition, $container); $this->compileFormatters($chillManagerDefinition, $container); $this->compileExportElementsProvider($chillManagerDefinition, $container); } - private function compileAggregators( - Definition $chillManagerDefinition, - ContainerBuilder $container - ) { - $taggedServices = $container->findTaggedServiceIds( - 'chill.export_aggregator' - ); - - $knownAliases = []; - - foreach ($taggedServices as $id => $tagAttributes) { - foreach ($tagAttributes as $attributes) { - if (!isset($attributes['alias'])) { - throw new LogicException("the 'alias' attribute is missing in your " . - "service '{$id}' definition"); - } - - if (array_search($attributes['alias'], $knownAliases, true)) { - throw new LogicException('There is already a chill.export_aggregator service with alias ' - . $attributes['alias'] . '. Choose another alias.'); - } - $knownAliases[] = $attributes['alias']; - - $chillManagerDefinition->addMethodCall( - 'addAggregator', - [new Reference($id), $attributes['alias']] - ); - } - } - } - private function compileExportElementsProvider( Definition $chillManagerDefinition, ContainerBuilder $container @@ -108,68 +75,6 @@ class ExportsCompilerPass implements CompilerPassInterface } } - private function compileExports( - Definition $chillManagerDefinition, - ContainerBuilder $container - ) { - $taggedServices = $container->findTaggedServiceIds( - 'chill.export' - ); - - $knownAliases = []; - - foreach ($taggedServices as $id => $tagAttributes) { - foreach ($tagAttributes as $attributes) { - if (!isset($attributes['alias'])) { - throw new LogicException("the 'alias' attribute is missing in your " . - "service '{$id}' definition"); - } - - if (array_search($attributes['alias'], $knownAliases, true)) { - throw new LogicException('There is already a chill.export service with alias ' - . $attributes['alias'] . '. Choose another alias.'); - } - $knownAliases[] = $attributes['alias']; - - $chillManagerDefinition->addMethodCall( - 'addExport', - [new Reference($id), $attributes['alias']] - ); - } - } - } - - private function compileFilters( - Definition $chillManagerDefinition, - ContainerBuilder $container - ) { - $taggedServices = $container->findTaggedServiceIds( - 'chill.export_filter' - ); - - $knownAliases = []; - - foreach ($taggedServices as $id => $tagAttributes) { - foreach ($tagAttributes as $attributes) { - if (!isset($attributes['alias'])) { - throw new LogicException("the 'alias' attribute is missing in your " . - "service '{$id}' definition"); - } - - if (array_search($attributes['alias'], $knownAliases, true)) { - throw new LogicException('There is already a chill.export_filter service with alias ' - . $attributes['alias'] . '. Choose another alias.'); - } - $knownAliases[] = $attributes['alias']; - - $chillManagerDefinition->addMethodCall( - 'addFilter', - [new Reference($id), $attributes['alias']] - ); - } - } - } - private function compileFormatters( Definition $chillManagerDefinition, ContainerBuilder $container diff --git a/src/Bundle/ChillMainBundle/Export/ExportManager.php b/src/Bundle/ChillMainBundle/Export/ExportManager.php index aec5998ff..f39926083 100644 --- a/src/Bundle/ChillMainBundle/Export/ExportManager.php +++ b/src/Bundle/ChillMainBundle/Export/ExportManager.php @@ -14,10 +14,8 @@ 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\EntityManagerInterface; use Doctrine\ORM\QueryBuilder; use Generator; -use InvalidArgumentException; use LogicException; use Psr\Log\LoggerInterface; use RuntimeException; @@ -50,8 +48,6 @@ class ExportManager private AuthorizationHelperInterface $authorizationHelper; - private EntityManagerInterface $em; - /** * Collected Exports, injected by DI. * @@ -82,16 +78,28 @@ class ExportManager public function __construct( LoggerInterface $logger, - EntityManagerInterface $em, AuthorizationCheckerInterface $authorizationChecker, AuthorizationHelperInterface $authorizationHelper, - TokenStorageInterface $tokenStorage + TokenStorageInterface $tokenStorage, + iterable $exports, + iterable $aggregators, + iterable $filters + //iterable $formatters, + //iterable $exportElementProvider ) { $this->logger = $logger; - $this->em = $em; $this->authorizationChecker = $authorizationChecker; $this->authorizationHelper = $authorizationHelper; $this->user = $tokenStorage->getToken()->getUser(); + $this->exports = iterator_to_array($exports); + $this->aggregators = iterator_to_array($aggregators); + $this->filters = iterator_to_array($filters); + // NOTE: PHP crashes on the next line (exit error code 11). This is desactivated until further investigation + //$this->formatters = iterator_to_array($formatters); + + //foreach ($exportElementProvider as $prefix => $provider) { + // $this->addExportElementsProvider($provider, $prefix); + //} } /** @@ -141,52 +149,17 @@ class ExportManager } } - /** - * add an aggregator. - * - * @internal used by DI - * - * @param string $alias - */ - public function addAggregator(AggregatorInterface $aggregator, $alias) - { - $this->aggregators[$alias] = $aggregator; - } - - /** - * add an export. - * - * @internal used by DI - * - * @param DirectExportInterface|ExportInterface $export - * @param type $alias - */ - public function addExport($export, $alias) - { - if ($export instanceof ExportInterface || $export instanceof DirectExportInterface) { - $this->exports[$alias] = $export; - } else { - throw new InvalidArgumentException(sprintf( - 'The export with alias %s ' - . 'does not implements %s or %s.', - $alias, - ExportInterface::class, - DirectExportInterface::class - )); - } - } - public function addExportElementsProvider(ExportElementsProviderInterface $provider, $prefix) { foreach ($provider->getExportElements() as $suffix => $element) { $alias = $prefix . '_' . $suffix; if ($element instanceof ExportInterface) { - $this->addExport($element, $alias); + $this->exports[$alias] = $element; } elseif ($element instanceof FilterInterface) { - $this->addFilter($element, $alias); + $this->filters[$alias] = $element; } elseif ($element instanceof AggregatorInterface) { - $this->addAggregator($element, $alias); + $this->aggregators[$alias] = $element; } elseif ($element instanceof FormatterInterface) { $this->addFormatter($element, $alias); } else { @@ -196,24 +169,12 @@ class ExportManager } } - /** - * add a Filter. - * - * @internal Normally used by the dependency injection - * - * @param string $alias - */ - public function addFilter(FilterInterface $filter, $alias) - { - $this->filters[$alias] = $filter; - } - /** * add a formatter. * * @internal used by DI * - * @param type $alias + * @param string $alias */ public function addFormatter(FormatterInterface $formatter, $alias) { @@ -231,7 +192,6 @@ class ExportManager public function generate($exportAlias, array $pickedCentersData, array $data, array $formatterData) { $export = $this->getExport($exportAlias); - //$qb = $this->em->createQueryBuilder(); $centers = $this->getPickedCenters($pickedCentersData); if ($export instanceof DirectExportInterface) { diff --git a/src/Bundle/ChillMainBundle/config/services.yaml b/src/Bundle/ChillMainBundle/config/services.yaml index 74c495bff..040db1a9f 100644 --- a/src/Bundle/ChillMainBundle/config/services.yaml +++ b/src/Bundle/ChillMainBundle/config/services.yaml @@ -90,6 +90,14 @@ services: Chill\MainBundle\Export\ExportManager: autoconfigure: true autowire: true + arguments: + $exports: !tagged_iterator { tag: chill.export, index_by: alias } + $aggregators: !tagged_iterator { tag: chill.export_aggregator, index_by: alias } + $filters: !tagged_iterator { tag: chill.export_filter, index_by: alias } + # for an unknown reason, iterator_to_array($formatter) cause a segmentation fault error (php-fpm code 11). removed temporarily + # $formatters: !tagged_iterator { tag: chill.export_formatter, index_by: alias } + # remove until we can properly test it + # $exportElementProvider: !tagged_iterator { tag: chill.export_elements_provider, index_by: prefix } Chill\MainBundle\Security\Resolver\CenterResolverDispatcherInterface: '@Chill\MainBundle\Security\Resolver\CenterResolverDispatcher' From 7b3fcad251cd30abb2870bc6d4d6e4043464ebfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 18 Oct 2022 16:25:11 +0200 Subject: [PATCH 30/51] Feature: [export][activity] Filter activities by users scope and job --- .../Export/Filter/UsersJobFilter.php | 81 +++++++++++++++++ .../Export/Filter/UsersScopeFilter.php | 88 +++++++++++++++++++ .../config/services/export.yaml | 8 ++ .../translations/messages.fr.yml | 28 ++++-- .../translations/messages.fr.yml | 1 + 5 files changed, 197 insertions(+), 9 deletions(-) create mode 100644 src/Bundle/ChillActivityBundle/Export/Filter/UsersJobFilter.php create mode 100644 src/Bundle/ChillActivityBundle/Export/Filter/UsersScopeFilter.php diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/UsersJobFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/UsersJobFilter.php new file mode 100644 index 000000000..dcdacd84a --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Export/Filter/UsersJobFilter.php @@ -0,0 +1,81 @@ +translatableStringHelper = $translatableStringHelper; + } + + public function addRole(): ?string + { + return null; + } + + public function alterQuery(QueryBuilder $qb, $data) + { + $qb + ->andWhere( + $qb->expr()->exists( + 'SELECT 1 FROM ' . Activity::class . ' activity_users_job_filter_act + JOIN activity_users_job_filter_act.users users WHERE users.userJob IN (:activity_users_job_filter_jobs) AND activity_users_job_filter_act = activity ' + ) + ) + ->setParameter('activity_users_job_filter_jobs', $data['jobs']); + } + + public function applyOn() + { + return Declarations::ACTIVITY; + } + + public function buildForm(FormBuilderInterface $builder) + { + $builder->add('jobs', EntityType::class, [ + 'class' => UserJob::class, + 'choice_label' => fn (UserJob $j) => $this->translatableStringHelper->localize($j->getLabel()), + 'multiple' => true, + 'expanded' => true, + ]); + } + + public function describeAction($data, $format = 'string') + { + return ['export.filter.activity.by_usersjob.Filtered activity by users job: only %jobs%', [ + '%jobs%' => implode( + ', ', + array_map( + fn (UserJob $job) => $this->translatableStringHelper->localize($job->getLabel()), + $data['jobs']->toArray() + ) + ), + ]]; + } + + public function getTitle() + { + return 'export.filter.activity.by_usersjob.Filter by users job'; + } +} diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/UsersScopeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/UsersScopeFilter.php new file mode 100644 index 000000000..61b12264e --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Export/Filter/UsersScopeFilter.php @@ -0,0 +1,88 @@ +scopeRepository = $scopeRepository; + $this->translatableStringHelper = $translatableStringHelper; + } + + public function addRole(): ?string + { + return null; + } + + public function alterQuery(QueryBuilder $qb, $data) + { + $qb + ->andWhere( + $qb->expr()->exists( + 'SELECT 1 FROM ' . Activity::class . ' activity_users_scope_filter_act + JOIN activity_users_scope_filter_act.users users WHERE users.mainScope IN (:activity_users_scope_filter_scopes) AND activity_users_scope_filter_act = activity ' + ) + ) + ->setParameter('activity_users_scope_filter_scopes', $data['scopes']); + } + + public function applyOn() + { + return Declarations::ACTIVITY; + } + + public function buildForm(FormBuilderInterface $builder) + { + $builder->add('scopes', EntityType::class, [ + 'class' => Scope::class, + 'choices' => $this->scopeRepository->findAllActive(), + 'choice_label' => fn (Scope $s) => $this->translatableStringHelper->localize($s->getName()), + 'multiple' => true, + 'expanded' => true, + ]); + } + + public function describeAction($data, $format = 'string') + { + return ['export.filter.activity.by_usersscope.Filtered activity by users scope: only %scopes%', [ + '%scopes%' => implode( + ', ', + array_map( + fn (Scope $s) => $this->translatableStringHelper->localize($s->getName()), + $data['scopes']->toArray() + ) + ), + ]]; + } + + public function getTitle() + { + return 'export.filter.activity.by_usersscope.Filter by users scope'; + } +} diff --git a/src/Bundle/ChillActivityBundle/config/services/export.yaml b/src/Bundle/ChillActivityBundle/config/services/export.yaml index d4548109e..224075e6f 100644 --- a/src/Bundle/ChillActivityBundle/config/services/export.yaml +++ b/src/Bundle/ChillActivityBundle/config/services/export.yaml @@ -112,6 +112,14 @@ services: tags: - { name: chill.export_filter, alias: 'activity_userscope_filter' } + Chill\ActivityBundle\Export\Filter\UsersJobFilter: + tags: + - { name: chill.export_filter, alias: 'activity_usersjob_filter' } + + Chill\ActivityBundle\Export\Filter\UsersScopeFilter: + tags: + - { name: chill.export_filter, alias: 'activity_usersscope_filter' } + ## Aggregators Chill\ActivityBundle\Export\Aggregator\PersonAggregators\ActivityReasonAggregator: tags: diff --git a/src/Bundle/ChillActivityBundle/translations/messages.fr.yml b/src/Bundle/ChillActivityBundle/translations/messages.fr.yml index 3a6ff1f05..6873b3736 100644 --- a/src/Bundle/ChillActivityBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillActivityBundle/translations/messages.fr.yml @@ -119,15 +119,15 @@ Activity Presences: Presences aux activités # Crud crud: - activity_type: - title_new: Nouveau type d'activité - title_edit: Edition d'un type d'activité - activity_type_category: - title_new: Nouvelle catégorie de type d'activité - title_edit: Edition d'une catégorie de type d'activité - activity_presence: - title_new: Nouvelle Présence aux activités - title_edit: Edition d'une Présence aux activités + activity_type: + title_new: Nouveau type d'activité + title_edit: Edition d'un type d'activité + activity_type_category: + title_new: Nouvelle catégorie de type d'activité + title_edit: Edition d'une catégorie de type d'activité + activity_presence: + title_new: Nouvelle Présence aux activités + title_edit: Edition d'une Présence aux activités # activity reason admin ActivityReason list: Liste des sujets @@ -322,3 +322,13 @@ docgen: A basic context for activity: Contexte pour les échanges Accompanying period with a list of activities: Parcours d'accompagnement avec liste des échanges Accompanying period with a list of activities description: Ce contexte reprend les informations du parcours, et tous les échanges pour un parcours. Les échanges ne sont pas filtrés. + +export: + filter: + activity: + by_usersjob: + Filter by users job: Filtrer les activités par métier d'au moins un utilisateur participant + 'Filtered activity by users job: only %jobs%': 'Filtré par métier d''au moins un utilisateur participant: seulement %jobs%' + by_usersscope: + Filter by users scope: Filtrer les activités 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%' diff --git a/src/Bundle/ChillMainBundle/translations/messages.fr.yml b/src/Bundle/ChillMainBundle/translations/messages.fr.yml index d14b4a7c1..b4ce910c4 100644 --- a/src/Bundle/ChillMainBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillMainBundle/translations/messages.fr.yml @@ -189,6 +189,7 @@ Main scope: Cercle Main center: Centre user job: Métier de l'utilisateur Job: Métier +Jobs: Métiers Choose a main center: Choisir un centre Choose a main scope: Choisir un cercle choose a job: Choisir un métier From 530c778d8cc6337c7b820ce6a05176cb601be376 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 18 Oct 2022 21:42:39 +0200 Subject: [PATCH 31/51] DX: [person][household composition] create interface for repositories --- .../HouseholdCompositionRepository.php | 3 +- ...ouseholdCompositionRepositoryInterface.php | 45 +++++++++++++++++++ .../HouseholdCompositionTypeRepository.php | 3 +- ...holdCompositionTypeRepositoryInterface.php | 42 +++++++++++++++++ 4 files changed, 89 insertions(+), 4 deletions(-) create mode 100644 src/Bundle/ChillPersonBundle/Repository/Household/HouseholdCompositionRepositoryInterface.php create mode 100644 src/Bundle/ChillPersonBundle/Repository/Household/HouseholdCompositionTypeRepositoryInterface.php diff --git a/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdCompositionRepository.php b/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdCompositionRepository.php index 453d32a4d..e25d0c867 100644 --- a/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdCompositionRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdCompositionRepository.php @@ -15,9 +15,8 @@ use Chill\PersonBundle\Entity\Household\Household; use Chill\PersonBundle\Entity\Household\HouseholdComposition; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; -use Doctrine\Persistence\ObjectRepository; -class HouseholdCompositionRepository implements ObjectRepository +final class HouseholdCompositionRepository implements HouseholdCompositionRepositoryInterface { private EntityRepository $repository; diff --git a/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdCompositionRepositoryInterface.php b/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdCompositionRepositoryInterface.php new file mode 100644 index 000000000..84c62392b --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdCompositionRepositoryInterface.php @@ -0,0 +1,45 @@ + Date: Tue, 18 Oct 2022 21:43:33 +0200 Subject: [PATCH 32/51] Feature: [export][acp] group courses by household composition --- .../ByHouseholdCompositionAggregator.php | 131 ++++++++++++++++++ .../services/exports_accompanying_course.yaml | 81 +---------- .../translations/messages.fr.yml | 5 +- 3 files changed, 141 insertions(+), 76 deletions(-) create mode 100644 src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ByHouseholdCompositionAggregator.php diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ByHouseholdCompositionAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ByHouseholdCompositionAggregator.php new file mode 100644 index 000000000..e96c8a228 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ByHouseholdCompositionAggregator.php @@ -0,0 +1,131 @@ +householdCompositionTypeRepository = $householdCompositionTypeRepository; + $this->translatableStringHelper = $translatableStringHelper; + } + + public function addRole(): ?string + { + return null; + } + + public function alterQuery(QueryBuilder $qb, $data) + { + $p = self::PREFIX; + + if (!in_array('acppart', $qb->getAllAliases(), true)) { + $qb->leftJoin('acp.participations', 'acppart'); + } + + $qb + ->leftJoin( + HouseholdMember::class, + "{$p}_hm", + Join::WITH, + $qb->expr()->orX( + $qb->expr()->isNull("{$p}_hm"), + $qb->expr()->andX( + $qb->expr()->lte("{$p}_hm.startDate", ":{$p}_date"), + $qb->expr()->orX( + $qb->expr()->isNull("{$p}_hm.endDate"), + $qb->expr()->gt("{$p}_hm.endDate", ":{$p}_date") + ) + ) + ) + ) + ->leftJoin( + HouseholdComposition::class, + "{$p}_compo", + Join::WITH, + $qb->expr()->orX( + $qb->expr()->isNull("{$p}_compo"), + $qb->expr()->andX( + $qb->expr()->lte("{$p}_compo.startDate", ":{$p}_date"), + $qb->expr()->orX( + $qb->expr()->isNull("{$p}_compo.endDate"), + $qb->expr()->gt("{$p}_compo.endDate", ":{$p}_date") + ) + ) + ) + ) + ->addSelect("IDENTITY({$p}_compo.householdCompositionType) AS {$p}_select") + ->setParameter("{$p}_date", $data['date_calc']) + ->addGroupBy("{$p}_select"); + } + + public function applyOn() + { + return Declarations::ACP_TYPE; + } + + public function buildForm(FormBuilderInterface $builder) + { + $builder->add('date_calc', ChillDateType::class, [ + 'label' => 'export.aggregator.course.by_household_composition.Calc date', + 'input_format' => 'datetime_immutable', + 'data' => new \DateTimeImmutable('now'), + ]); + } + + public function getLabels($key, array $values, $data) + { + return function ($value) { + if ('_header' === $value) { + return 'export.aggregator.course.by_household_composition.Household composition'; + } + + if (null === $value) { + return ''; + } + + if (null === $o = $this->householdCompositionTypeRepository->find($value)) { + return ''; + } + + return $this->translatableStringHelper->localize($o->getLabel()); + }; + } + + public function getQueryKeys($data) + { + return [self::PREFIX . '_select']; + } + + public function getTitle() + { + return 'export.aggregator.course.by_household_composition.Group course by household composition'; + } +} diff --git a/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_course.yaml b/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_course.yaml index ba79b4166..04d5d8371 100644 --- a/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_course.yaml +++ b/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_course.yaml @@ -1,262 +1,193 @@ services: + _defaults: + autowire: true + autoconfigure: true ## Indicators chill.person.export.count_accompanyingcourse: class: Chill\PersonBundle\Export\Export\CountAccompanyingCourse - autowire: true - autoconfigure: true tags: - { name: chill.export, alias: count_accompanyingcourse } chill.person.export.avg_accompanyingcourse_duration: class: Chill\PersonBundle\Export\Export\StatAccompanyingCourseDuration - autowire: true - autoconfigure: true tags: - { name: chill.export, alias: avg_accompanyingcourse_duration } ## Filters Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\UserScopeFilter: - autowire: true - autoconfigure: true tags: - { name: chill.export_filter, alias: accompanyingcourse_userscope_filter } Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\UserJobFilter: - autowire: true - autoconfigure: true tags: - { name: chill.export_filter, alias: accompanyingcourse_userjob_filter } chill.person.export.filter_socialissue: class: Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\SocialIssueFilter - autowire: true - autoconfigure: true tags: - { name: chill.export_filter, alias: accompanyingcourse_socialissue_filter } chill.person.export.filter_step: class: Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\StepFilter - autowire: true - autoconfigure: true tags: - { name: chill.export_filter, alias: accompanyingcourse_step_filter } chill.person.export.filter_geographicalunitstat: class: Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\GeographicalUnitStatFilter - autowire: true - autoconfigure: true tags: - { name: chill.export_filter, alias: accompanyingcourse_geographicalunitstat_filter } chill.person.export.filter_socialaction: class: Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\SocialActionFilter - autowire: true - autoconfigure: true tags: - { name: chill.export_filter, alias: accompanyingcourse_socialaction_filter } chill.person.export.filter_evaluation: class: Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\EvaluationFilter - autowire: true - autoconfigure: true tags: - { name: chill.export_filter, alias: accompanyingcourse_evaluation_filter } chill.person.export.filter_origin: class: Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\OriginFilter - autowire: true - autoconfigure: true tags: - { name: chill.export_filter, alias: accompanyingcourse_origin_filter } chill.person.export.filter_closingmotive: class: Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\ClosingMotiveFilter - autowire: true - autoconfigure: true tags: - { name: chill.export_filter, alias: accompanyingcourse_closingmotive_filter } chill.person.export.filter_administrative_location: class: Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\AdministrativeLocationFilter - autowire: true - autoconfigure: true tags: - { name: chill.export_filter, alias: accompanyingcourse_administrative_location_filter } chill.person.export.filter_requestor: class: Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\RequestorFilter - autowire: true - autoconfigure: true tags: - { name: chill.export_filter, alias: accompanyingcourse_requestor_filter } chill.person.export.filter_confidential: class: Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\ConfidentialFilter - autowire: true - autoconfigure: true tags: - { name: chill.export_filter, alias: accompanyingcourse_confidential_filter } chill.person.export.filter_emergency: class: Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\EmergencyFilter - autowire: true - autoconfigure: true tags: - { name: chill.export_filter, alias: accompanyingcourse_emergency_filter } chill.person.export.filter_intensity: class: Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\IntensityFilter - autowire: true - autoconfigure: true tags: - { name: chill.export_filter, alias: accompanyingcourse_intensity_filter } chill.person.export.filter_activeondate: class: Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\ActiveOnDateFilter - autowire: true - autoconfigure: true tags: - { name: chill.export_filter, alias: accompanyingcourse_activeondate_filter } chill.person.export.filter_activeonedaybetweendates: class: Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\ActiveOneDayBetweenDatesFilter - autowire: true - autoconfigure: true tags: - { name: chill.export_filter, alias: accompanyingcourse_activeonedaybetweendates_filter } chill.person.export.filter_referrer: class: Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\ReferrerFilter - autowire: true - autoconfigure: true tags: - { name: chill.export_filter, alias: accompanyingcourse_referrer_filter } chill.person.export.filter_openbetweendates: class: Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\OpenBetweenDatesFilter - autowire: true - autoconfigure: true tags: - { name: chill.export_filter, alias: accompanyingcourse_openbetweendates_filter } ## Aggregators chill.person.export.aggregator_referrer_scope: class: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\ScopeAggregator - autowire: true - autoconfigure: true tags: - { name: chill.export_aggregator, alias: accompanyingcourse_scope_aggregator } chill.person.export.aggregator_referrer_job: class: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\JobAggregator - autowire: true - autoconfigure: true tags: - { name: chill.export_aggregator, alias: accompanyingcourse_referrer_job_aggregator } chill.person.export.aggregator_socialissue: class: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\SocialIssueAggregator - autowire: true - autoconfigure: true tags: - { name: chill.export_aggregator, alias: accompanyingcourse_socialissue_aggregator } chill.person.export.aggregator_step: class: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\StepAggregator - autowire: true - autoconfigure: true tags: - { name: chill.export_aggregator, alias: accompanyingcourse_step_aggregator } chill.person.export.aggregator_geographicalunitstat: class: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\GeographicalUnitStatAggregator - autowire: true - autoconfigure: true tags: - { name: chill.export_aggregator, alias: accompanyingcourse_geographicalunitstat_aggregator } chill.person.export.aggregator_socialaction: class: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\SocialActionAggregator - autowire: true - autoconfigure: true tags: - { name: chill.export_aggregator, alias: accompanyingcourse_socialaction_aggregator } chill.person.export.aggregator_evaluation: class: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\EvaluationAggregator - autowire: true - autoconfigure: true tags: - { name: chill.export_aggregator, alias: accompanyingcourse_evaluation_aggregator } chill.person.export.aggregator_origin: class: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\OriginAggregator - autowire: true - autoconfigure: true tags: - { name: chill.export_aggregator, alias: accompanyingcourse_origin_aggregator } chill.person.export.aggregator_closingmotive: class: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\ClosingMotiveAggregator - autowire: true - autoconfigure: true tags: - { name: chill.export_aggregator, alias: accompanyingcourse_closingmotive_aggregator } chill.person.export.aggregator_administrative_location: class: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\AdministrativeLocationAggregator - autowire: true - autoconfigure: true tags: - { name: chill.export_aggregator, alias: accompanyingcourse_administrative_location_aggregator } chill.person.export.aggregator_requestor: class: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\RequestorAggregator - autowire: true - autoconfigure: true tags: - { name: chill.export_aggregator, alias: accompanyingcourse_requestor_aggregator } chill.person.export.aggregator_confidential: class: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\ConfidentialAggregator - autowire: true - autoconfigure: true tags: - { name: chill.export_aggregator, alias: accompanyingcourse_confidential_aggregator } chill.person.export.aggregator_emergency: class: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\EmergencyAggregator - autowire: true - autoconfigure: true tags: - { name: chill.export_aggregator, alias: accompanyingcourse_emergency_aggregator } chill.person.export.aggregator_intensity: class: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\IntensityAggregator - autowire: true - autoconfigure: true tags: - { name: chill.export_aggregator, alias: accompanyingcourse_intensity_aggregator } chill.person.export.aggregator_referrer: class: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\ReferrerAggregator - autowire: true - autoconfigure: true tags: - { name: chill.export_aggregator, alias: accompanyingcourse_referrer_aggregator } chill.person.export.aggregator_duration: class: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\DurationAggregator - autowire: true - autoconfigure: true tags: - { name: chill.export_aggregator, alias: accompanyingcourse_duration_aggregator } Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\ReferrerScopeAggregator: - autoconfigure: true - autowire: true tags: - { name: chill.export_aggregator, alias: accompanyingcourse_ref_scope_aggregator } - + Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\ByHouseholdCompositionAggregator: + tags: + - { name: chill.export_aggregator, alias: accompanyingcourse_by_household_compo_aggregator } diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index ede58394c..191ef6091 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -955,12 +955,15 @@ export: Group course by referrer's scope: Grouper les parcours par service du référent Computation date for referrer: Date à laquelle le référent était actif Referrer's scope: Service du référent de parcours - duration: day: Durée du parcours en jours week: Durée du parcours en semaines month: Durée du parcours en mois Precision: Unité de la durée + by_household_composition: + Household composition: Composition du ménage + Group course by household composition: Grouper les parcours par composition familiale des ménages des usagers concernés + Calc date: Date de calcul de la composition du ménage filter: course: by_user_scope: From 31f048b8e8c82305e011839fadd79d003688f018 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 19 Oct 2022 14:12:47 +0200 Subject: [PATCH 33/51] Feature: [person][docgen] Add a title to document in person docgen context --- .../Service/DocGenerator/PersonContext.php | 28 +++++++++++++------ .../DocGenerator/PersonContextTest.php | 27 ++++++++++++++++-- 2 files changed, 43 insertions(+), 12 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php b/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php index a9ebdc0bb..af6c6e114 100644 --- a/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php +++ b/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php @@ -11,8 +11,6 @@ declare(strict_types=1); namespace Chill\PersonBundle\Service\DocGenerator; -use Chill\DocGeneratorBundle\Context\DocGeneratorContextWithAdminFormInterface; -use Chill\DocGeneratorBundle\Context\DocGeneratorContextWithPublicFormInterface; use Chill\DocGeneratorBundle\Context\Exception\UnexpectedTypeException; use Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate; use Chill\DocGeneratorBundle\Service\Context\BaseContextData; @@ -34,6 +32,7 @@ use Doctrine\ORM\EntityRepository; use LogicException; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; +use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Security\Core\Security; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; @@ -42,7 +41,7 @@ use Symfony\Contracts\Translation\TranslatorInterface; use function array_key_exists; use function count; -class PersonContext implements DocGeneratorContextWithAdminFormInterface, DocGeneratorContextWithPublicFormInterface +final class PersonContext implements PersonContextInterface { private AuthorizationHelperInterface $authorizationHelper; @@ -129,6 +128,7 @@ class PersonContext implements DocGeneratorContextWithAdminFormInterface, DocGen 'choice_label' => function ($entity = null) { return $entity ? $this->translatableStringHelper->localize($entity->getName()) : ''; }, + 'required' => true, ]); } @@ -137,11 +137,19 @@ class PersonContext implements DocGeneratorContextWithAdminFormInterface, DocGen */ public function buildPublicForm(FormBuilderInterface $builder, DocGeneratorTemplate $template, $entity): void { - $builder->add('scope', ScopePickerType::class, [ - 'center' => $this->centerResolverManager->resolveCenters($entity), - 'role' => PersonDocumentVoter::CREATE, - 'label' => 'Scope', + $builder->add('title', TextType::class, [ + 'required' => true, + 'label' => 'docgen.Document title', + 'data' => $this->translatableStringHelper->localize($template->getName()), ]); + + if ($this->isScopeNecessary($entity)) { + $builder->add('scope', ScopePickerType::class, [ + 'center' => $this->centerResolverManager->resolveCenters($entity), + 'role' => PersonDocumentVoter::CREATE, + 'label' => 'Scope', + ]); + } } public function getData(DocGeneratorTemplate $template, $entity, array $contextGenerationData = []): array @@ -200,7 +208,7 @@ class PersonContext implements DocGeneratorContextWithAdminFormInterface, DocGen */ public function hasPublicForm(DocGeneratorTemplate $template, $entity): bool { - return $this->isScopeNecessary($entity); + return true; } /** @@ -210,7 +218,9 @@ class PersonContext implements DocGeneratorContextWithAdminFormInterface, DocGen { $doc = new PersonDocument(); $doc->setTemplate($template) - ->setTitle($this->translatableStringHelper->localize($template->getName())) + ->setTitle( + $contextGenerationData['title'] ?? $this->translatableStringHelper->localize($template->getName()) + ) ->setDate(new DateTime()) ->setDescription($this->translatableStringHelper->localize($template->getName())) ->setPerson($entity) diff --git a/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextTest.php b/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextTest.php index c7c9a00e4..44414cdba 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextTest.php @@ -21,6 +21,7 @@ use Chill\DocStoreBundle\Security\Authorization\PersonDocumentVoter; use Chill\MainBundle\Entity\Center; use Chill\MainBundle\Entity\Scope; use Chill\MainBundle\Entity\User; +use Chill\MainBundle\Form\Type\ScopePickerType; use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface; use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface; use Chill\MainBundle\Templating\TranslatableStringHelperInterface; @@ -33,6 +34,8 @@ use Prophecy\Exception\Prediction\FailedPredictionException; use Prophecy\PhpUnit\ProphecyTrait; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; +use Symfony\Component\Form\Extension\Core\Type\TextType; +use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Security\Core\Security; use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; @@ -82,7 +85,7 @@ final class PersonContextTest extends TestCase $parameter ); - $this->assertFalse($personContext->hasPublicForm($docGen, $person)); + $personContext->buildPublicForm($this->buildFormBuilder(false), $docGen, $person); $personContext->storeGenerated( $docGen, @@ -126,7 +129,7 @@ final class PersonContextTest extends TestCase $em->reveal(), ); - $this->assertTrue($personContext->hasPublicForm($docGen, $person)); + $personContext->buildPublicForm($this->buildFormBuilder(true), $docGen, $person); $personContext->storeGenerated( $docGen, @@ -170,7 +173,7 @@ final class PersonContextTest extends TestCase $em->reveal(), ); - $this->assertTrue($personContext->hasPublicForm($docGen, $person)); + $personContext->buildPublicForm($this->buildFormBuilder(true), $docGen, $person); $personContext->storeGenerated( $docGen, @@ -180,6 +183,24 @@ final class PersonContextTest extends TestCase ); } + private function buildFormBuilder(bool $withScope): FormBuilderInterface + { + $builder = $this->prophesize(FormBuilderInterface::class); + + $builder->add('title', TextType::class, Argument::type('array')) + ->shouldBeCalled(1); + + if ($withScope) { + $builder->add('scope', ScopePickerType::class, Argument::type('array')) + ->shouldBeCalled(); + } else { + $builder->add('scope', ScopePickerType::class, Argument::type('array')) + ->shouldNotBeCalled(); + } + + return $builder->reveal(); + } + private function buildPersonContext( ?AuthorizationHelperInterface $authorizationHelper = null, ?BaseContextData $baseContextData = null, From 1b5d5a28fdf6898708ff42fdb2fd4792bc7b90e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 19 Oct 2022 14:16:20 +0200 Subject: [PATCH 34/51] DX: [main] Validation phone number: add some parameters for debugging --- .../ChillMainBundle/Validation/Validator/ValidPhonenumber.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bundle/ChillMainBundle/Validation/Validator/ValidPhonenumber.php b/src/Bundle/ChillMainBundle/Validation/Validator/ValidPhonenumber.php index 905ca1185..9305cbf09 100644 --- a/src/Bundle/ChillMainBundle/Validation/Validator/ValidPhonenumber.php +++ b/src/Bundle/ChillMainBundle/Validation/Validator/ValidPhonenumber.php @@ -72,7 +72,7 @@ final class ValidPhonenumber extends ConstraintValidator } if (false === $isValid) { - $this->context->addViolation($message, ['%phonenumber%' => $value]); + $this->context->addViolation($message, ['%phonenumber%' => $value, '%formatted%' => $this->phonenumberHelper->format($value)]); } } } From ea5f8c9d0898416094acfdcb386f0c83baab3871 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 19 Oct 2022 14:16:59 +0200 Subject: [PATCH 35/51] Feature: [docgen][person] add a new context to generate document with a third party This allow to prepare, for instance, mail (letters) to a thirdparty about a Person --- .../views/Generator/basic_form.html.twig | 8 ++ .../DocGenerator/PersonContextInterface.php | 55 ++++++++ .../PersonContextWithThirdParty.php | 130 ++++++++++++++++++ .../PersonContextWithThirdPartyTest.php | 93 +++++++++++++ .../translations/messages.fr.yml | 4 + .../Entity/ThirdParty.php | 2 +- 6 files changed, 291 insertions(+), 1 deletion(-) create mode 100644 src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContextInterface.php create mode 100644 src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContextWithThirdParty.php create mode 100644 src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextWithThirdPartyTest.php diff --git a/src/Bundle/ChillDocGeneratorBundle/Resources/views/Generator/basic_form.html.twig b/src/Bundle/ChillDocGeneratorBundle/Resources/views/Generator/basic_form.html.twig index 7b24eae0d..35fa6e319 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Resources/views/Generator/basic_form.html.twig +++ b/src/Bundle/ChillDocGeneratorBundle/Resources/views/Generator/basic_form.html.twig @@ -2,6 +2,14 @@ {% block title 'docgen.Generate a document'|trans %} +{% block js %} + {{ encore_entry_script_tags('mod_pickentity_type') }} +{% endblock %} + +{% block css %} + {{ encore_entry_link_tags('mod_pickentity_type') }} +{% endblock %} + {% block content %}

{{ block('title') }}

diff --git a/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContextInterface.php b/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContextInterface.php new file mode 100644 index 000000000..58a6b5863 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContextInterface.php @@ -0,0 +1,55 @@ +personContext = $personContext; + $this->normalizer = $normalizer; + } + + public function adminFormReverseTransform(array $data): array + { + return array_merge( + $this->personContext->adminFormReverseTransform($data), + ['label' => $data['label']] + ); + } + + public function adminFormTransform(array $data): array + { + return array_merge( + $this->personContext->adminFormTransform($data), + ['label' => $data['label'] ?? ''] + ); + } + + public function buildAdminForm(FormBuilderInterface $builder): void + { + $this->personContext->buildAdminForm($builder); + + $builder->add('label', TextType::class, [ + 'label' => 'docgen.Label for third party', + 'required' => true, + ]); + } + + public function buildPublicForm(FormBuilderInterface $builder, DocGeneratorTemplate $template, $entity): void + { + $this->personContext->buildPublicForm($builder, $template, $entity); + + $builder->add('thirdParty', PickThirdpartyDynamicType::class, [ + 'multiple' => false, + 'label' => $template->getOptions()['label'] ?? 'ThirdParty', + 'validation_groups' => ['__none__'], + ]); + } + + public function getData(DocGeneratorTemplate $template, $entity, array $contextGenerationData = []): array + { + $data = $this->personContext->getData($template, $entity, $contextGenerationData); + + $data['thirdParty'] = $this->normalizer->normalize( + $contextGenerationData['thirdParty'], + 'docgen', + ['docgen:expects' => ThirdParty::class, 'groups' => ['docgen:read']] + ); + + return $data; + } + + public function getDescription(): string + { + return 'docgen.A context for person with a third party (for sending mail)'; + } + + public function getEntityClass(): string + { + return $this->personContext->getEntityClass(); + } + + public function getFormData(DocGeneratorTemplate $template, $entity): array + { + return $this->personContext->getFormData($template, $entity); + } + + public static function getKey(): string + { + return self::class; + } + + public function getName(): string + { + return 'docgen.Person with third party'; + } + + public function hasAdminForm(): bool + { + return true; + } + + public function hasPublicForm(DocGeneratorTemplate $template, $entity): bool + { + return true; + } + + public function storeGenerated(DocGeneratorTemplate $template, StoredObject $storedObject, object $entity, array $contextGenerationData): void + { + $this->personContext->storeGenerated($template, $storedObject, $entity, $contextGenerationData); + } +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextWithThirdPartyTest.php b/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextWithThirdPartyTest.php new file mode 100644 index 000000000..a4f08e7c1 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextWithThirdPartyTest.php @@ -0,0 +1,93 @@ +buildPersonContextWithThirdParty(); + + $actual = $personContext->adminFormReverseTransform(['label' => 'bloup']); + + $this->assertArrayHasKey('category', $actual); + $this->assertArrayHasKey('label', $actual); + $this->assertEquals('bloup', $actual['label']); + } + + public function testAdminFormTransform() + { + $personContext = $this->buildPersonContextWithThirdParty(); + + $actual = $personContext->adminFormTransform(['label' => 'bloup']); + + $this->assertArrayHasKey('from_person', $actual); + $this->assertArrayHasKey('label', $actual); + $this->assertEquals('bloup', $actual['label']); + } + + public function testGetData() + { + $personContext = $this->buildPersonContextWithThirdParty(); + + $actual = $personContext->getData( + (new DocGeneratorTemplate())->setOptions(['label' => 'bloup']), + new Person(), + ['thirdParty' => $tp = new ThirdParty()] + ); + + $this->assertArrayHasKey('person', $actual); + $this->assertArrayHasKey('thirdParty', $actual); + $this->assertEquals(spl_object_hash($tp), $actual['thirdParty']['hash']); + } + + private function buildPersonContextWithThirdParty(): PersonContextWithThirdParty + { + $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])]; + }); + + $personContext = $this->prophesize(PersonContextInterface::class); + + $personContext->adminFormReverseTransform(Argument::type('array'))->willReturn( + ['category' => ['idInsideBundle' => 1, 'bundleId' => 'abc']] + ); + $personContext->adminFormTransform(Argument::type('array'))->willReturn( + ['from_person' => 'kept'] + ); + $personContext->getData(Argument::type(DocGeneratorTemplate::class), Argument::type(Person::class), Argument::type('array')) + ->willReturn(['person' => 'data']); + + return new PersonContextWithThirdParty( + $personContext->reveal(), + $normalizer->reveal() + ); + } +} diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 6ad3737b7..dc2e5020f 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -858,6 +858,10 @@ docgen: A context for accompanying period work evaluation: Contexte pour les évaluations dans les actions d'accompagnement Person basic: Personne (basique) A basic context for person: Contexte pour les personnes + Person with third party: Personne avec choix d'un tiers + A context for person with a third party (for sending mail): Un contexte d'une personne avec un tiers (pour envoyer un courrier à ce tiers, par exemple) + Label for third party: Label à afficher aux utilisateurs + Document title: Titre du document généré period_notification: period_designated_subject: Vous êtes référent d'un parcours d'accompagnement diff --git a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php index 119afff11..2e8cebfb6 100644 --- a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php +++ b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php @@ -214,7 +214,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface /** * @ORM\Column(name="kind", type="string", length="20", options={"default": ""}) - * @Groups({"write"}) + * @Groups({"write", "docgen:read", "docgen:read:3party:parent"}) */ private ?string $kind = ''; From 719256913c4a9dd21a1574526962280edcb11dd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 19 Oct 2022 16:07:12 +0200 Subject: [PATCH 36/51] Feature: [docgen] Add a new variable createdAtDate, which contains date without date and time This is useful when generating a letter, to fill the today's date in the letter's header. --- .../Service/Context/BaseContextData.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Bundle/ChillDocGeneratorBundle/Service/Context/BaseContextData.php b/src/Bundle/ChillDocGeneratorBundle/Service/Context/BaseContextData.php index cbeeaeb16..e7b56ed88 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Service/Context/BaseContextData.php +++ b/src/Bundle/ChillDocGeneratorBundle/Service/Context/BaseContextData.php @@ -42,6 +42,9 @@ class BaseContextData $data['createdAt'] = $this->normalizer->normalize(new DateTimeImmutable(), 'docgen', [ 'docgen:expects' => DateTimeImmutable::class, 'groups' => ['docgen:read'], ]); + $data['createdAtDate'] = $this->normalizer->normalize(new DateTimeImmutable('today'), 'docgen', [ + 'docgen:expects' => DateTimeImmutable::class, 'groups' => ['docgen:read'], + ]); $data['location'] = $this->normalizer->normalize( $user instanceof User ? $user->getCurrentLocation() : null, 'docgen', From 2a782044e6d3a55e0b0f39ba37c2f181c7680fa9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 19 Oct 2022 17:11:10 +0200 Subject: [PATCH 37/51] DX: [docgen] add more test for docgenObjectNormalizer and AccompanyingPeriodResourceNormalizer --- .../Normalizer/DocGenObjectNormalizerTest.php | 45 +++++++++++++ ...companyingPeriodResourceNormalizerTest.php | 67 +++++++++++++++++++ 2 files changed, 112 insertions(+) create mode 100644 src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/AccompanyingPeriodResourceNormalizerTest.php diff --git a/src/Bundle/ChillDocGeneratorBundle/tests/Serializer/Normalizer/DocGenObjectNormalizerTest.php b/src/Bundle/ChillDocGeneratorBundle/tests/Serializer/Normalizer/DocGenObjectNormalizerTest.php index de2a8775a..3250d4d5a 100644 --- a/src/Bundle/ChillDocGeneratorBundle/tests/Serializer/Normalizer/DocGenObjectNormalizerTest.php +++ b/src/Bundle/ChillDocGeneratorBundle/tests/Serializer/Normalizer/DocGenObjectNormalizerTest.php @@ -77,6 +77,19 @@ final class DocGenObjectNormalizerTest extends KernelTestCase $this->assertArrayNotHasKey('baz', $actual['child']); } + public function testNormalizableBooleanPropertyOrMethodOnNull() + { + $actual = $this->normalizer->normalize(null, 'docgen', [AbstractNormalizer::GROUPS => ['docgen:read'], 'docgen:expects' => TestableClassWithBool::class]); + + $expected = [ + 'foo' => null, + 'thing' => null, + 'isNull' => true, + ]; + + $this->assertEquals($expected, $actual); + } + public function testNormalizationBasic() { $scope = new Scope(); @@ -93,6 +106,22 @@ final class DocGenObjectNormalizerTest extends KernelTestCase $this->assertEquals($expected, $normalized, 'test normalization fo a scope'); } + public function testNormalizeBooleanPropertyOrMethod() + { + $testable = new TestableClassWithBool(); + $testable->foo = false; + + $actual = $this->normalizer->normalize($testable, 'docgen', [AbstractNormalizer::GROUPS => ['docgen:read'], 'docgen:expects' => TestableClassWithBool::class]); + + $expected = [ + 'foo' => false, + 'thing' => true, + 'isNull' => false, + ]; + + $this->assertEquals($expected, $actual); + } + public function testNormalizeNull() { $actual = $this->normalizer->normalize(null, 'docgen', [AbstractNormalizer::GROUPS => ['docgen:read'], 'docgen:expects' => Scope::class]); @@ -170,3 +199,19 @@ class TestableChildClass */ public string $foo = 'bar'; } + +class TestableClassWithBool +{ + /** + * @Serializer\Groups("docgen:read") + */ + public bool $foo; + + /** + * @Serializer\Groups("docgen:read") + */ + public function getThing(): bool + { + return true; + } +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/AccompanyingPeriodResourceNormalizerTest.php b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/AccompanyingPeriodResourceNormalizerTest.php new file mode 100644 index 000000000..0c4188826 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/AccompanyingPeriodResourceNormalizerTest.php @@ -0,0 +1,67 @@ +normalizer = self::$container->get(NormalizerInterface::class); + } + + public function testNormalizeNullHasSameValueAsNotNull() + { + $nullResource = $this->normalizer->normalize(null, 'docgen', ['groups' => 'docgen:read', 'docgen:expects' => Resource::class]); + $notNull = $this->normalizer->normalize(new Resource(), 'docgen', ['groups' => 'docgen:read', 'docgen:expects' => Resource::class]); + + $this->assertEqualsCanonicalizing(array_keys($notNull), array_keys($nullResource)); + } + + public function testNormalizeResource() + { + $resource = new Resource(); + $resource + ->setComment('blabla') + ->setResource(new ThirdParty()); + + $expected = [ + 'type' => 'accompanying_period_resource', + 'isNull' => false, + 'comment' => 'blabla', + ]; + + $actual = $this->normalizer->normalize($resource, 'docgen', ['groups' => 'docgen:read', 'docgen:expects' => Resource::class]); + + // we do not test for sub array (person, thirdparty). We then check first for base value... + foreach ($expected as $key => $value) { + $this->assertArrayHasKey($key, $actual); + $this->assertEquals($value, $actual[$key]); + } + + // ... and then for the existence of some values + $this->assertArrayHasKey('person', $actual); + $this->assertArrayHasKey('thirdParty', $actual); + } +} From 0cbe12a32c5cf967e23a8bb2ac3533e472bcf7ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 19 Oct 2022 17:44:36 +0200 Subject: [PATCH 38/51] DX: [dql] add a function JSON_EXTRACT This might be used to sort lines which contains translatable string. --- .../ChillMainExtension.php | 2 + .../Doctrine/DQL/JsonExtract.php | 43 +++++++++++++++ .../Tests/Doctrine/DQL/JsonExtractTest.php | 52 +++++++++++++++++++ 3 files changed, 97 insertions(+) create mode 100644 src/Bundle/ChillMainBundle/Doctrine/DQL/JsonExtract.php create mode 100644 src/Bundle/ChillMainBundle/Tests/Doctrine/DQL/JsonExtractTest.php diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php index 463a84e81..627841364 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php @@ -27,6 +27,7 @@ use Chill\MainBundle\Doctrine\DQL\GetJsonFieldByKey; use Chill\MainBundle\Doctrine\DQL\JsonAggregate; use Chill\MainBundle\Doctrine\DQL\JsonbArrayLength; use Chill\MainBundle\Doctrine\DQL\JsonbExistsInArray; +use Chill\MainBundle\Doctrine\DQL\JsonExtract; use Chill\MainBundle\Doctrine\DQL\OverlapsI; use Chill\MainBundle\Doctrine\DQL\Replace; use Chill\MainBundle\Doctrine\DQL\Similarity; @@ -231,6 +232,7 @@ class ChillMainExtension extends Extension implements 'GET_JSON_FIELD_BY_KEY' => GetJsonFieldByKey::class, 'AGGREGATE' => JsonAggregate::class, 'REPLACE' => Replace::class, + 'JSON_EXTRACT' => JsonExtract::class, ], 'numeric_functions' => [ 'JSONB_EXISTS_IN_ARRAY' => JsonbExistsInArray::class, diff --git a/src/Bundle/ChillMainBundle/Doctrine/DQL/JsonExtract.php b/src/Bundle/ChillMainBundle/Doctrine/DQL/JsonExtract.php new file mode 100644 index 000000000..9f93c437e --- /dev/null +++ b/src/Bundle/ChillMainBundle/Doctrine/DQL/JsonExtract.php @@ -0,0 +1,43 @@ +>%s', $this->element->dispatch($sqlWalker), $this->keyToExtract->dispatch($sqlWalker)); + } + + public function parse(Parser $parser) + { + $parser->match(Lexer::T_IDENTIFIER); + $parser->match(Lexer::T_OPEN_PARENTHESIS); + + $this->element = $parser->ArithmeticPrimary(); + + $parser->match(Lexer::T_COMMA); + + $this->keyToExtract = $parser->ArithmeticExpression(); + + $parser->match(Lexer::T_CLOSE_PARENTHESIS); + } +} diff --git a/src/Bundle/ChillMainBundle/Tests/Doctrine/DQL/JsonExtractTest.php b/src/Bundle/ChillMainBundle/Tests/Doctrine/DQL/JsonExtractTest.php new file mode 100644 index 000000000..3f2b3eb2f --- /dev/null +++ b/src/Bundle/ChillMainBundle/Tests/Doctrine/DQL/JsonExtractTest.php @@ -0,0 +1,52 @@ +em = self::$container->get(EntityManagerInterface::class); + } + + public function dataGenerateDql(): iterable + { + yield ['SELECT JSON_EXTRACT(c.name, \'fr\') FROM ' . Country::class . ' c', []]; + + yield ['SELECT JSON_EXTRACT(c.name, :lang) FROM ' . Country::class . ' c', ['lang' => 'fr']]; + } + + /** + * @dataProvider dataGenerateDql + */ + public function testJsonExtract(string $dql, array $args) + { + $results = $this->em->createQuery($dql) + ->setMaxResults(2) + ->setParameters($args) + ->getResult(); + + $this->assertIsArray($results, 'simply test that the query return a result'); + } +} From 83ba8131600db24cbcf4b6d50db04a4b27b7d26e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 19 Oct 2022 17:56:10 +0200 Subject: [PATCH 39/51] Feature: [docgen] order document template by name in list and in admin --- .../AdminDocGeneratorTemplateController.php | 14 ++++++++++++++ .../Repository/DocGeneratorTemplateRepository.php | 11 +++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillDocGeneratorBundle/Controller/AdminDocGeneratorTemplateController.php b/src/Bundle/ChillDocGeneratorBundle/Controller/AdminDocGeneratorTemplateController.php index bb65fb5b2..c365b5e06 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Controller/AdminDocGeneratorTemplateController.php +++ b/src/Bundle/ChillDocGeneratorBundle/Controller/AdminDocGeneratorTemplateController.php @@ -14,6 +14,8 @@ namespace Chill\DocGeneratorBundle\Controller; use Chill\DocGeneratorBundle\Context\ContextManager; use Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate; use Chill\MainBundle\CRUD\Controller\CRUDController; +use Chill\MainBundle\Pagination\PaginatorInterface; +use Doctrine\ORM\QueryBuilder; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; @@ -84,4 +86,16 @@ class AdminDocGeneratorTemplateController extends CRUDController return $entity; } + + /** + * @param QueryBuilder $query + * + * @return QueryBuilder|mixed + */ + protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator) + { + return $query->addSelect('JSON_EXTRACT(e.name, :lang) AS HIDDEN name_lang') + ->setParameter('lang', $request->getLocale()) + ->addOrderBy('name_lang', 'ASC'); + } } diff --git a/src/Bundle/ChillDocGeneratorBundle/Repository/DocGeneratorTemplateRepository.php b/src/Bundle/ChillDocGeneratorBundle/Repository/DocGeneratorTemplateRepository.php index 4f800fd6a..6a80c34dc 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Repository/DocGeneratorTemplateRepository.php +++ b/src/Bundle/ChillDocGeneratorBundle/Repository/DocGeneratorTemplateRepository.php @@ -15,14 +15,18 @@ use Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; use Doctrine\Persistence\ObjectRepository; +use Symfony\Component\HttpFoundation\RequestStack; final class DocGeneratorTemplateRepository implements ObjectRepository { private EntityRepository $repository; - public function __construct(EntityManagerInterface $entityManager) + private RequestStack $requestStack; + + public function __construct(EntityManagerInterface $entityManager, RequestStack $requestStack) { $this->repository = $entityManager->getRepository(DocGeneratorTemplate::class); + $this->requestStack = $requestStack; } public function countByEntity(string $entity): int @@ -71,7 +75,10 @@ final class DocGeneratorTemplateRepository implements ObjectRepository $builder ->where('t.entity LIKE :entity') ->andWhere($builder->expr()->eq('t.active', "'TRUE'")) - ->setParameter('entity', addslashes($entity)); + ->setParameter('entity', addslashes($entity)) + ->addSelect('JSON_EXTRACT(t.name, :lang) AS HIDDEN name_lang') + ->setParameter('lang', $this->requestStack->getCurrentRequest()->getLocale()) + ->addOrderBy('name_lang', 'ASC'); return $builder ->getQuery() From b580bda2fbe4576fcf1851a70bf2d66cfb3a4cc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 19 Oct 2022 22:02:43 +0200 Subject: [PATCH 40/51] DX: [calendar] docgen normalization on Calendar entity --- .../ChillCalendarBundle/Entity/Calendar.php | 26 +++-- .../Normalizer/CalendarNormalizerTest.php | 109 ++++++++++++++++++ 2 files changed, 126 insertions(+), 9 deletions(-) create mode 100644 src/Bundle/ChillCalendarBundle/Tests/Serializer/Normalizer/CalendarNormalizerTest.php diff --git a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php index f23f07610..24cd0f758 100644 --- a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php +++ b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php @@ -44,6 +44,9 @@ use function in_array; * uniqueConstraints={@ORM\UniqueConstraint(name="idx_calendar_remote", columns={"remoteId"}, options={"where": "remoteId <> ''"})} * ) * @ORM\Entity + * @Serializer\DiscriminatorMap(typeProperty="type", mapping={ + * "chill_calendar_calendar": Calendar::class + * }) */ class Calendar implements TrackCreationInterface, TrackUpdateInterface { @@ -109,13 +112,13 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface /** * @ORM\Embedded(class=CommentEmbeddable::class, columnPrefix="comment_") - * @Serializer\Groups({"calendar:read", "read"}) + * @Serializer\Groups({"calendar:read", "read", "docgen:read"}) */ private CommentEmbeddable $comment; /** * @ORM\Column(type="datetime_immutable", nullable=false) - * @Serializer\Groups({"calendar:read", "read", "calendar:light"}) + * @Serializer\Groups({"calendar:read", "read", "calendar:light", "docgen:read"}) * @Assert\NotNull(message="calendar.An end date is required") */ private ?DateTimeImmutable $endDate = null; @@ -124,7 +127,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") - * @Serializer\Groups({"calendar:read", "read", "calendar:light"}) + * @Serializer\Groups({"calendar:read", "read", "calendar:light", "docgen:read"}) */ private ?int $id = null; @@ -136,20 +139,20 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface * cascade={"persist", "remove", "merge", "detach"} * ) * @ORM\JoinTable(name="chill_calendar.calendar_to_invites") - * @Serializer\Groups({"read"}) + * @Serializer\Groups({"read", "docgen:read"}) */ private Collection $invites; /** * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Location") - * @Serializer\Groups({"read"}) + * @Serializer\Groups({"read", "docgen:read"}) * @Assert\NotNull(message="calendar.A location is required") */ private ?Location $location = null; /** * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User") - * @Serializer\Groups({"calendar:read", "read", "calendar:light"}) + * @Serializer\Groups({"calendar:read", "read", "calendar:light", "docgen:read"}) * @Serializer\Context(normalizationContext={"read"}, groups={"calendar:light"}) * @Assert\NotNull(message="calendar.A main user is mandatory") */ @@ -158,7 +161,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface /** * @ORM\ManyToMany(targetEntity="Chill\PersonBundle\Entity\Person", inversedBy="calendars") * @ORM\JoinTable(name="chill_calendar.calendar_to_persons") - * @Serializer\Groups({"calendar:read", "read", "calendar:light"}) + * @Serializer\Groups({"calendar:read", "read", "calendar:light", "docgen:read"}) * @Serializer\Context(normalizationContext={"read"}, groups={"calendar:light"}) * @Assert\Count(min=1, minMessage="calendar.At least {{ limit }} person is required.") */ @@ -173,13 +176,14 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface /** * @ORM\ManyToMany(targetEntity="Chill\ThirdPartyBundle\Entity\ThirdParty") * @ORM\JoinTable(name="chill_calendar.calendar_to_thirdparties") - * @Serializer\Groups({"calendar:read", "read", "calendar:light"}) + * @Serializer\Groups({"calendar:read", "read", "calendar:light", "docgen:read"}) * @Serializer\Context(normalizationContext={"read"}, groups={"calendar:light"}) */ private Collection $professionals; /** * @ORM\Column(type="boolean", nullable=true) + * @Serializer\Groups({"docgen:read"}) */ private ?bool $sendSMS = false; @@ -190,7 +194,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface /** * @ORM\Column(type="datetime_immutable", nullable=false) - * @Serializer\Groups({"calendar:read", "read", "calendar:light"}) + * @Serializer\Groups({"calendar:read", "read", "calendar:light", "docgen:read"}) * @Serializer\Context(normalizationContext={"read"}, groups={"calendar:light"}) * @Assert\NotNull(message="calendar.A start date is required") */ @@ -205,6 +209,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface /** * @ORM\Column(type="boolean", nullable=true) + * @Serializer\Groups({"docgen:read"}) */ private ?bool $urgent = false; @@ -282,6 +287,9 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface return $this->comment; } + /** + * @Serializer\Groups({"docgen:read"}) + */ public function getDuration(): ?DateInterval { if ($this->getStartDate() === null || $this->getEndDate() === null) { diff --git a/src/Bundle/ChillCalendarBundle/Tests/Serializer/Normalizer/CalendarNormalizerTest.php b/src/Bundle/ChillCalendarBundle/Tests/Serializer/Normalizer/CalendarNormalizerTest.php new file mode 100644 index 000000000..2a0975206 --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/Tests/Serializer/Normalizer/CalendarNormalizerTest.php @@ -0,0 +1,109 @@ +normalizer = self::$container->get(NormalizerInterface::class); + } + + public function testNormalizationCalendar() + { + $calendar = (new Calendar()) + ->setComment( + $comment = new CommentEmbeddable() + ) + ->setStartDate(DateTimeImmutable::createFromFormat(DateTimeImmutable::ATOM, '2020-10-15T15:00:00+0000')) + ->setEndDate(DateTimeImmutable::createFromFormat(DateTimeImmutable::ATOM, '2020-15-15T15:30:00+0000')) + ->addPerson(new Person()) + ->addPerson(new Person()) + ->addUser(new User()) + ->addProfessional(new ThirdParty()); + + $expected = [ + 'type' => 'chill_calendar_calendar', + 'isNull' => false, + 'urgent' => false, + 'sendSMS' => false, + ]; + + $actual = $this->normalizer->normalize( + $calendar, + 'docgen', + ['groups' => ['docgen:read'], 'docgen:expects' => Calendar::class] + ); + + // we first check for the known key/value... + foreach ($expected as $key => $value) { + $this->assertArrayHasKey($key, $actual); + $this->assertEquals($value, $actual[$key]); + } + + // ... and then check for some other values + $this->assertArrayHasKey('persons', $actual); + $this->assertIsArray($actual['persons']); + $this->assertArrayHasKey('invites', $actual); + $this->assertIsArray($actual['invites']); + $this->assertArrayHasKey('startDate', $actual); + $this->assertIsArray($actual['startDate']); + $this->assertArrayHasKey('endDate', $actual); + $this->assertIsArray($actual['endDate']); + $this->assertArrayHasKey('professionals', $actual); + $this->assertIsArray($actual['professionals']); + $this->assertArrayHasKey('location', $actual); + $this->assertIsArray($actual['location']); + $this->assertArrayHasKey('mainUser', $actual); + $this->assertIsArray($actual['mainUser']); + $this->assertArrayHasKey('comment', $actual); + $this->assertIsArray($actual['comment']); + $this->assertArrayHasKey('duration', $actual); + $this->assertIsArray($actual['duration']); + } + + public function testNormalizationOnNullHasSameKeys() + { + $calendar = new Calendar(); + + $notNullCalendar = $this->normalizer->normalize( + $calendar, + 'docgen', + ['groups' => ['docgen:read'], 'docgen:expects' => Calendar::class] + ); + + $isNullCalendar = $this->normalizer->normalize( + null, + 'docgen', + ['groups' => ['docgen:read'], 'docgen:expects' => Calendar::class] + ); + + $this->assertEqualsCanonicalizing(array_keys($notNullCalendar), array_keys($isNullCalendar)); + } +} From e91d2c9e93a9635f5606a692bfe1f6332d5ce178 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Thu, 20 Oct 2022 09:55:42 +0200 Subject: [PATCH 41/51] complete chill documentation about csfixer and phpstan --- docs/source/installation/index.rst | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/docs/source/installation/index.rst b/docs/source/installation/index.rst index 00f27ed69..01a8c4aee 100644 --- a/docs/source/installation/index.rst +++ b/docs/source/installation/index.rst @@ -265,7 +265,7 @@ Tests reside inside the installed bundles. You must `cd` into that directory, do **Note**: some bundle require the fixture to be executed. See the dedicated _how-tos_. -Exemple, for running test inside `main` bundle: +Exemple, for running unit test inside `main` bundle: .. code-block:: bash @@ -280,6 +280,30 @@ Exemple, for running test inside `main` bundle: # run tests bin/phpunit src/Bundle/path/to/your/test +Or for running tests to check code style and php conventions with csfixer and phpstan: + +.. code-block:: bash + + # run code style fixer + bin/grumphp run --tasks=phpcsfixer + # run phpstan + bin/grumphp run --tasks=phpstan + + +.. note:: + + To avoid phpstan block your commits: + + .. code-block:: bash + + git commit -n ... + + To avoid phpstan block your commits permanently: + + .. code-block:: bash + + ./bin/grumphp git:deinit + How to run webpack interactively ================================ From 2b1d9cabff2b1b69c0e1e2b965aa666bce5b80e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 20 Oct 2022 21:35:57 +0200 Subject: [PATCH 42/51] Feature: [calendar] associate document with calendar --- .../ChillCalendarBundle/Entity/Calendar.php | 62 ++++++++ .../Entity/CalendarDoc.php | 135 ++++++++++++++++++ .../Repository/CalendarDocRepository.php | 52 +++++++ .../CalendarDocRepositoryInterface.php | 33 +++++ .../migrations/Version20221020101547.php | 47 ++++++ 5 files changed, 329 insertions(+) create mode 100644 src/Bundle/ChillCalendarBundle/Entity/CalendarDoc.php create mode 100644 src/Bundle/ChillCalendarBundle/Repository/CalendarDocRepository.php create mode 100644 src/Bundle/ChillCalendarBundle/Repository/CalendarDocRepositoryInterface.php create mode 100644 src/Bundle/ChillCalendarBundle/migrations/Version20221020101547.php diff --git a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php index 24cd0f758..2c8992aa0 100644 --- a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php +++ b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php @@ -116,6 +116,17 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface */ private CommentEmbeddable $comment; + /** + * @ORM\Column(type="integer", nullable=false, options={"default": 0}) + */ + private int $dateTimeVersion = 0; + + /** + * @var Collection + * @ORM\OneToMany(targetEntity=CalendarDoc::class, mappedBy="calendar", orphanRemoval=true) + */ + private Collection $documents; + /** * @ORM\Column(type="datetime_immutable", nullable=false) * @Serializer\Groups({"calendar:read", "read", "calendar:light", "docgen:read"}) @@ -216,12 +227,25 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface public function __construct() { $this->comment = new CommentEmbeddable(); + $this->documents = new ArrayCollection(); $this->privateComment = new PrivateCommentEmbeddable(); $this->persons = new ArrayCollection(); $this->professionals = new ArrayCollection(); $this->invites = new ArrayCollection(); } + /** + * @internal use @{CalendarDoc::__construct} instead + */ + public function addDocument(CalendarDoc $calendarDoc): self + { + if ($this->documents->contains($calendarDoc)) { + $this->documents[] = $calendarDoc; + } + + return $this; + } + /** * @internal Use {@link (Calendar::addUser)} instead */ @@ -287,6 +311,19 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface return $this->comment; } + /** + * Each time the date and time is update, this version is incremented. + */ + public function getDateTimeVersion(): int + { + return $this->dateTimeVersion; + } + + public function getDocuments(): Collection + { + return $this->documents; + } + /** * @Serializer\Groups({"docgen:read"}) */ @@ -472,6 +509,18 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface ])); } + /** + * @internal use @{CalendarDoc::setCalendar} with null instead + */ + public function removeDocument(CalendarDoc $calendarDoc): self + { + if ($calendarDoc->getCalendar() !== $this) { + throw new LogicException('cannot remove document of another calendar'); + } + + return $this; + } + /** * @internal Use {@link (Calendar::removeUser)} instead */ @@ -562,6 +611,10 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface public function setEndDate(DateTimeImmutable $endDate): self { + if ($this->endDate->getTimestamp() !== $endDate->getTimestamp()) { + $this->increaseaDatetimeVersion(); + } + $this->endDate = $endDate; return $this; @@ -609,6 +662,10 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface public function setStartDate(DateTimeImmutable $startDate): self { + if ($this->startDate->getTimestamp() !== $startDate->getTimestamp()) { + $this->increaseaDatetimeVersion(); + } + $this->startDate = $startDate; return $this; @@ -631,4 +688,9 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface return $this; } + + private function increaseaDatetimeVersion(): void + { + ++$this->dateTimeVersion; + } } diff --git a/src/Bundle/ChillCalendarBundle/Entity/CalendarDoc.php b/src/Bundle/ChillCalendarBundle/Entity/CalendarDoc.php new file mode 100644 index 000000000..458f38654 --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/Entity/CalendarDoc.php @@ -0,0 +1,135 @@ +setCalendar($calendar); + + $this->storedObject = $storedObject; + $this->datetimeVersion = $calendar->getDateTimeVersion(); + } + + public function getCalendar(): Calendar + { + return $this->calendar; + } + + public function getDatetimeVersion(): int + { + return $this->datetimeVersion; + } + + public function getId(): ?int + { + return $this->id; + } + + public function getStoredObject(): StoredObject + { + return $this->storedObject; + } + + public function isTrackDateTimeVersion(): bool + { + return $this->trackDateTimeVersion; + } + + /** + * @internal use @see{Calendar::removeDocument} instead + * + * @param Calendar $calendar + */ + public function setCalendar(?Calendar $calendar): CalendarDoc + { + if (null === $calendar) { + $this->calendar->removeDocument($this); + } else { + $calendar->addDocument($this); + } + + $this->calendar = $calendar; + + $this->datetimeVersion = $calendar->getDateTimeVersion(); + + return $this; + } + + public function setDatetimeVersion(int $datetimeVersion): CalendarDoc + { + $this->datetimeVersion = $datetimeVersion; + + return $this; + } + + public function setStoredObject(StoredObject $storedObject): CalendarDoc + { + $this->storedObject = $storedObject; + + return $this; + } + + public function setTrackDateTimeVersion(bool $trackDateTimeVersion): CalendarDoc + { + $this->trackDateTimeVersion = $trackDateTimeVersion; + + return $this; + } +} diff --git a/src/Bundle/ChillCalendarBundle/Repository/CalendarDocRepository.php b/src/Bundle/ChillCalendarBundle/Repository/CalendarDocRepository.php new file mode 100644 index 000000000..bd1074b5f --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/Repository/CalendarDocRepository.php @@ -0,0 +1,52 @@ +repository = $entityManager->getRepository($this->getClassName()); + } + + public function find($id): ?CalendarDoc + { + return $this->repository->find($id); + } + + public function findAll(): array + { + 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): ?CalendarDoc + { + return $this->findOneBy($criteria); + } + + public function getClassName() + { + return CalendarDoc::class; + } +} diff --git a/src/Bundle/ChillCalendarBundle/Repository/CalendarDocRepositoryInterface.php b/src/Bundle/ChillCalendarBundle/Repository/CalendarDocRepositoryInterface.php new file mode 100644 index 000000000..d2b1951df --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/Repository/CalendarDocRepositoryInterface.php @@ -0,0 +1,33 @@ +addSql('DROP SEQUENCE chill_calendar.calendar_doc_id_seq CASCADE'); + $this->addSql('DROP TABLE chill_calendar.calendar_doc'); + $this->addSql('ALTER TABLE chill_calendar.calendar DROP dateTimeVersion'); + } + + public function getDescription(): string + { + return 'Add calendardoc on Calendar'; + } + + public function up(Schema $schema): void + { + $this->addSql('CREATE SEQUENCE chill_calendar.calendar_doc_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE TABLE chill_calendar.calendar_doc (id INT NOT NULL, calendar_id INT NOT NULL, datetimeVersion INT DEFAULT 0 NOT NULL, trackDateTimeVersion BOOLEAN DEFAULT false NOT NULL, createdAt TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, updatedAt TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, storedObject_id INT NOT NULL, createdBy_id INT DEFAULT NULL, updatedBy_id INT DEFAULT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE INDEX IDX_4FD11573A40A2C8 ON chill_calendar.calendar_doc (calendar_id)'); + $this->addSql('CREATE INDEX IDX_4FD115736C99C13A ON chill_calendar.calendar_doc (storedObject_id)'); + $this->addSql('CREATE INDEX IDX_4FD115733174800F ON chill_calendar.calendar_doc (createdBy_id)'); + $this->addSql('CREATE INDEX IDX_4FD1157365FF1AEC ON chill_calendar.calendar_doc (updatedBy_id)'); + $this->addSql('COMMENT ON COLUMN chill_calendar.calendar_doc.createdAt IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('COMMENT ON COLUMN chill_calendar.calendar_doc.updatedAt IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('ALTER TABLE chill_calendar.calendar_doc ADD CONSTRAINT FK_4FD11573A40A2C8 FOREIGN KEY (calendar_id) REFERENCES chill_calendar.calendar (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_calendar.calendar_doc ADD CONSTRAINT FK_4FD115736C99C13A FOREIGN KEY (storedObject_id) REFERENCES chill_doc.stored_object (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_calendar.calendar_doc ADD CONSTRAINT FK_4FD115733174800F FOREIGN KEY (createdBy_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_calendar.calendar_doc ADD CONSTRAINT FK_4FD1157365FF1AEC FOREIGN KEY (updatedBy_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_calendar.calendar ADD dateTimeVersion INT DEFAULT 0 NOT NULL'); + } +} From 63f3010395dbed3e958918e40e106540ba6a17a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 20 Oct 2022 21:36:44 +0200 Subject: [PATCH 43/51] Feature: [calendar][docgen] generation context for Calendar --- .../ChillCalendarBundle/Entity/Invite.php | 4 +- .../Service/DocGenerator/CalendarContext.php | 249 ++++++++++++++++++ .../DocGenerator/CalendarContextInterface.php | 63 +++++ .../DocGenerator/CalendarContextTest.php | 236 +++++++++++++++++ .../translations/messages.fr.yml | 11 + 5 files changed, 561 insertions(+), 2 deletions(-) create mode 100644 src/Bundle/ChillCalendarBundle/Service/DocGenerator/CalendarContext.php create mode 100644 src/Bundle/ChillCalendarBundle/Service/DocGenerator/CalendarContextInterface.php create mode 100644 src/Bundle/ChillCalendarBundle/Tests/Service/DocGenerator/CalendarContextTest.php diff --git a/src/Bundle/ChillCalendarBundle/Entity/Invite.php b/src/Bundle/ChillCalendarBundle/Entity/Invite.php index 0489d0a00..c2d79aff2 100644 --- a/src/Bundle/ChillCalendarBundle/Entity/Invite.php +++ b/src/Bundle/ChillCalendarBundle/Entity/Invite.php @@ -73,14 +73,14 @@ class Invite implements TrackUpdateInterface, TrackCreationInterface /** * @ORM\Column(type="text", nullable=false, options={"default": "pending"}) - * @Serializer\Groups(groups={"calendar:read", "read"}) + * @Serializer\Groups(groups={"calendar:read", "read", "docgen:read"}) */ private string $status = self::PENDING; /** * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User") * @ORM\JoinColumn(nullable=false) - * @Serializer\Groups(groups={"calendar:read", "read"}) + * @Serializer\Groups(groups={"calendar:read", "read", "docgen:read"}) */ private ?User $user = null; diff --git a/src/Bundle/ChillCalendarBundle/Service/DocGenerator/CalendarContext.php b/src/Bundle/ChillCalendarBundle/Service/DocGenerator/CalendarContext.php new file mode 100644 index 000000000..9ba9e36b4 --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/Service/DocGenerator/CalendarContext.php @@ -0,0 +1,249 @@ +baseContextData = $baseContextData; + $this->entityManager = $entityManager; + $this->normalizer = $normalizer; + $this->personRender = $personRender; + $this->thirdPartyRender = $thirdPartyRender; + $this->translatableStringHelper = $translatableStringHelper; + } + + public function adminFormReverseTransform(array $data): array + { + return array_merge( + [ + 'trackDatetime' => true, + 'askMainPerson' => true, + 'mainPersonLabel' => 'docgen.calendar.Destinee', + 'askThirdParty' => false, + 'thirdPartyLabel' => 'Third party', + ], + $data + ); + } + + public function adminFormTransform(array $data): array + { + return $data; + } + + public function buildAdminForm(FormBuilderInterface $builder): void + { + $builder + ->add('trackDatetime', CheckboxType::class, [ + 'required' => false, + 'label' => 'docgen.calendar.Track changes on datetime and warn user if date time is updated after the doc generation', + ]) + ->add('askMainPerson', CheckboxType::class, [ + 'required' => false, + 'label' => 'docgen.calendar.Ask main person', + ]) + ->add('mainPersonLabel', TextType::class, [ + 'required' => false, + 'label' => 'docgen.calendar.Main person label', + ]) + ->add('askThirdParty', CheckboxType::class, [ + 'required' => false, + 'label' => 'docgen.calendar.Ask third party', + ]) + ->add('thirdPartyLabel', TextType::class, [ + 'required' => false, + 'label' => 'docgen.calendar.Third party label', + ]); + } + + public function buildPublicForm(FormBuilderInterface $builder, DocGeneratorTemplate $template, $entity): void + { + $options = $this->getOptions($template); + + $builder->add('title', TextType::class, [ + 'required' => true, + 'label' => 'docgen.calendar.title of the generated document', + 'data' => $this->translatableStringHelper->localize($template->getName()), + ]); + + if ($options['askMainPerson']) { + $builder->add('mainPerson', EntityType::class, [ + 'class' => Person::class, + 'multiple' => false, + 'label' => $options['mainPersonLabel'] ?? 'docgen.calendar.Main person label', + 'required' => false, + 'choices' => $entity->getPersons(), + 'choice_label' => fn (Person $p) => $this->personRender->renderString($p, []), + 'expanded' => false, + ]); + } + + if ($options['askThirdParty']) { + $builder->add('thirdParty', EntityType::class, [ + 'class' => ThirdParty::class, + 'multiple' => false, + 'label' => $options['thirdPartyLabel'] ?? 'Third party', + 'choices' => $entity->getProfessionals(), + 'choice_label' => fn (ThirdParty $tp) => $this->thirdPartyRender->renderString($tp, []), + 'expanded' => false, + ]); + } + } + + /** + * @param array{mainPerson?: Person, thirdParty?: ThirdParty, title: string} $contextGenerationData + * @param mixed $entity + */ + public function getData(DocGeneratorTemplate $template, $entity, array $contextGenerationData = []): array + { + $options = $this->getOptions($template); + + $data = array_merge( + $this->baseContextData->getData(), + [ + 'calendar' => $this->normalizer->normalize($entity, 'docgen', ['docgen:expects' => Calendar::class, 'groups' => ['docgen:read']]), + ] + ); + + if ($options['askMainPerson']) { + $data['mainPerson'] = $this->normalizer->normalize($contextGenerationData['mainPerson'] ?? null, 'docgen', [ + 'docgen:expects' => Person::class, + 'groups' => ['docgen:read'], + 'docgen:person:with-household' => true, + 'docgen:person:with-relations' => true, + 'docgen:person:with-budget' => true, + ]); + } + + if ($options['askThirdParty']) { + $data['thirdParty'] = $this->normalizer->normalize($contextGenerationData['thirdParty'] ?? null, 'docgen', [ + 'docgen:expects' => ThirdParty::class, + 'groups' => ['docgen:read'], + ]); + } + + return $data; + } + + public function getDescription(): string + { + return 'docgen.calendar.A base context for generating document on calendar'; + } + + public function getEntityClass(): string + { + return Calendar::class; + } + + public function getFormData(DocGeneratorTemplate $template, $entity): array + { + $options = $this->getOptions($template); + $data = []; + + if ($options['askMainPerson']) { + $data['mainPerson'] = null; + + if (1 === count($entity->getPersons())) { + $data['mainPerson'] = $entity->getPersons()->first(); + } + } + + if ($options['askThirdParty']) { + $data['thirdParty'] = null; + + if (1 === count($entity->getProfessionals())) { + $data['thirdParty'] = $entity->getProfessionals()->first(); + } + } + + return $data; + } + + public static function getKey(): string + { + return self::class; + } + + public function getName(): string + { + return 'docgen.calendar.Base context for calendar'; + } + + public function hasAdminForm(): bool + { + return true; + } + + public function hasPublicForm(DocGeneratorTemplate $template, $entity): bool + { + return true; + } + + /** + * @param array{mainPerson?: Person, thirdParty?: ThirdParty, title: string} $contextGenerationData + */ + public function storeGenerated(DocGeneratorTemplate $template, StoredObject $storedObject, object $entity, array $contextGenerationData): void + { + $options = $this->getOptions($template); + $storedObject->setTitle($contextGenerationData['title']); + $doc = new CalendarDoc($entity, $storedObject); + $doc->setTrackDateTimeVersion($options['trackDatetime']); + + $this->entityManager->persist($doc); + } + + /** + * @return array{askMainPerson: bool, mainPersonLabel: ?string, askThirdParty: bool, thirdPartyLabel: ?string, trackDateTime: bool} $options + */ + private function getOptions(DocGeneratorTemplate $template): array + { + return $template->getOptions(); + } +} diff --git a/src/Bundle/ChillCalendarBundle/Service/DocGenerator/CalendarContextInterface.php b/src/Bundle/ChillCalendarBundle/Service/DocGenerator/CalendarContextInterface.php new file mode 100644 index 000000000..d02cdc2c2 --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/Service/DocGenerator/CalendarContextInterface.php @@ -0,0 +1,63 @@ + true, + 'askMainPerson' => true, + 'mainPersonLabel' => 'docgen.calendar.Destinee', + 'askThirdParty' => false, + 'thirdPartyLabel' => 'Third party', + ]; + + $this->assertEqualsCanonicalizing($expected, $this->buildCalendarContext()->adminFormReverseTransform([])); + } + + public function testAdminFormTransform() + { + $expected = + [ + 'track_datetime' => true, + 'askMainPerson' => true, + 'mainPersonLabel' => 'docgen.calendar.Destinee', + 'askThirdParty' => false, + 'thirdPartyLabel' => 'Third party', + ]; + + $this->assertEqualsCanonicalizing($expected, $this->buildCalendarContext()->adminFormTransform($expected)); + } + + public function testBuildPublicForm() + { + $formBuilder = $this->prophesize(FormBuilderInterface::class); + $calendar = new Calendar(); + $calendar + ->addProfessional($tp1 = new ThirdParty()) + ->addProfessional($tp2 = new ThirdParty()) + ->addPerson($p1 = new Person()); + + // we will try once with askThirdParty = true, once with askPerson = true, and once with both + // so, we expect the call to be twice for each method + $formBuilder->add('thirdParty', EntityType::class, Argument::type('array')) + ->should(static function ($calls, $object, $method) use ($tp1, $tp2) { + if (2 !== count($calls)) { + throw new FailedPredictionException(sprintf('the $builder->add should be called exactly 2, %d receivved', count($calls))); + } + + $opts = $calls[0]->getArguments()[2]; + + if (!array_key_exists('label', $opts)) { + throw new FailedPredictionException('the $builder->add should have a label key'); + } + + if ('tplabel' !== $opts['label']) { + throw new FailedPredictionException('third party label not expected'); + } + + if (!$opts['choices']->contains($tp1) || !$opts['choices']->contains($tp2)) { + throw new FailedPredictionException('third party not present'); + } + }); + $formBuilder->add('mainPerson', EntityType::class, Argument::type('array')) + ->should(static function ($calls, $object, $method) use ($p1) { + if (2 !== count($calls)) { + throw new FailedPredictionException(sprintf('the $builder->add should be called exactly 2, %d receivved', count($calls))); + } + + $opts = $calls[0]->getArguments()[2]; + + if (!array_key_exists('label', $opts)) { + throw new FailedPredictionException('the $builder->add should have a label key'); + } + + if ('personLabel' !== $opts['label']) { + throw new FailedPredictionException('person label not expected'); + } + + if (!$opts['choices']->contains($p1)) { + throw new FailedPredictionException('person not present'); + } + }); + + $formBuilder->add('title', TextType::class, Argument::type('array')) + ->shouldBeCalledTimes(3); + + foreach ([ + ['askMainPerson' => true, 'mainPersonLabel' => 'personLabel', 'askThirdParty' => true, 'thirdPartyLabel' => 'tplabel'], + ['askMainPerson' => false, 'mainPersonLabel' => 'personLabel', 'askThirdParty' => true, 'thirdPartyLabel' => 'tplabel'], + ['askMainPerson' => true, 'mainPersonLabel' => 'personLabel', 'askThirdParty' => false, 'thirdPartyLabel' => 'tplabel'], + ] as $options) { + $template = new DocGeneratorTemplate(); + $template->setOptions($options); + + $this->buildCalendarContext()->buildPublicForm($formBuilder->reveal(), $template, $calendar); + } + } + + public function testGetData() + { + $calendar = (new Calendar()) + ->addPerson($p1 = new Person()) + ->addProfessional($t1 = new ThirdParty()); + $template = (new DocGeneratorTemplate())->setOptions( + ['askMainPerson' => true, 'mainPersonLabel' => 'personLabel', 'askThirdParty' => true, 'thirdPartyLabel' => 'tplabel'], + ); + $contextData = [ + 'mainPerson' => $p1, + 'thirdParty' => $t1, + ]; + + $normalizer = $this->prophesize(NormalizerInterface::class); + $normalizer->normalize($p1, 'docgen', Argument::type('array'))->willReturn(['person' => '1']); + $normalizer->normalize($t1, 'docgen', Argument::type('array'))->willReturn(['tp' => '1']); + $normalizer->normalize($calendar, 'docgen', Argument::type('array'))->willReturn(['calendar' => '1']); + + $actual = $this->buildCalendarContext(null, $normalizer->reveal()) + ->getData($template, $calendar, $contextData); + + $this->assertEqualsCanonicalizing([ + 'calendar' => ['calendar' => '1'], + 'mainPerson' => ['person' => '1'], + 'thirdParty' => ['tp' => '1'], + 'base_context' => 'data', + ], $actual); + } + + public function testStoreGenerated() + { + $calendar = new Calendar(); + $storedObject = new StoredObject(); + $contextData = ['title' => 'blabla']; + $template = (new DocGeneratorTemplate())->setOptions(['trackDatetime' => true]); + + $em = $this->prophesize(EntityManagerInterface::class); + $em->persist(Argument::type(CalendarDoc::class))->should( + static function ($calls, $object, $method) use ($storedObject) { + if (1 !== count($calls)) { + throw new FailedPredictionException('the persist method should be called once'); + } + + /** @var CalendarDoc $calendarDoc */ + $calendarDoc = $calls[0]->getArguments()[0]; + + if ($calendarDoc->getStoredObject() !== $storedObject) { + throw new FailedPredictionException('the stored object is not correct'); + } + + if ($calendarDoc->getStoredObject()->getTitle() !== 'blabla') { + throw new FailedPredictionException('the doc title should be the one provided'); + } + + if (!$calendarDoc->isTrackDateTimeVersion()) { + throw new FailedPredictionException('the track date time should be true'); + } + } + ); + + $this->buildCalendarContext($em->reveal())->storeGenerated($template, $storedObject, $calendar, $contextData); + } + + private function buildCalendarContext( + ?EntityManagerInterface $entityManager = null, + ?NormalizerInterface $normalizer = null + ): CalendarContext { + $baseContext = $this->prophesize(BaseContextData::class); + $baseContext->getData()->willReturn(['base_context' => 'data']); + + $personRender = $this->prophesize(PersonRender::class); + $personRender->renderString(Argument::type(Person::class), [])->willReturn('person name'); + + $thirdPartyRender = $this->prophesize(ThirdPartyRender::class); + $thirdPartyRender->renderString(Argument::type(ThirdParty::class), [])->willReturn('third party name'); + + $translatableStringHelper = $this->prophesize(TranslatableStringHelperInterface::class); + $translatableStringHelper->localize(Argument::type('array'))->willReturn('blabla'); + + if (null === $normalizer) { + $normalizer = $this->prophesize(NormalizerInterface::class)->reveal(); + } + + if (null === $entityManager) { + $entityManager = $this->prophesize(EntityManagerInterface::class)->reveal(); + } + + return new CalendarContext( + $baseContext->reveal(), + $entityManager, + $normalizer, + $personRender->reveal(), + $thirdPartyRender->reveal(), + $translatableStringHelper->reveal() + ); + } +} diff --git a/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml b/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml index a03dd4015..53bf3d337 100644 --- a/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml @@ -112,3 +112,14 @@ has calendar range: Dans une plage de disponibilité? Not made within a calendar range: Rendez-vous dans une plage de disponibilité Made within a calendar range: Rendez-vous en dehors d'une plage de disponibilité +docgen: + calendar: + Base context for calendar: 'Rendez-vous: contexte de base' + A base context for generating document on calendar: Contexte pour générer des documents à partir des rendez-vous + Track changes on datetime and warn user if date time is updated after the doc generation: Suivre les changements sur le document et prévenir les utilisateurs que la date et l'heure ont été modifiée après la génération du document + Ask main person: Demander de choisir une personne parmi les participants aux rendez-vous + Main person label: Label pour choisir la personne + Ask third party: Demander de choisir un tiers parmi les participants aux rendez-vous + Third party label: Label pour choisir le tiers + Destinee: Destinataire + None: Aucun choix From e107e39ffd2dca980010302b7ba7e4f0b28ceceb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 20 Oct 2022 22:32:21 +0200 Subject: [PATCH 44/51] Fixed: when counting doc generator template by entity, take 'active' into account --- .../Repository/DocGeneratorTemplateRepository.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Bundle/ChillDocGeneratorBundle/Repository/DocGeneratorTemplateRepository.php b/src/Bundle/ChillDocGeneratorBundle/Repository/DocGeneratorTemplateRepository.php index 6a80c34dc..c00dc7474 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Repository/DocGeneratorTemplateRepository.php +++ b/src/Bundle/ChillDocGeneratorBundle/Repository/DocGeneratorTemplateRepository.php @@ -36,6 +36,7 @@ final class DocGeneratorTemplateRepository implements ObjectRepository $builder ->select('count(t)') ->where('t.entity LIKE :entity') + ->andWhere($builder->expr()->eq('t.active', "'TRUE'")) ->setParameter('entity', addslashes($entity)); return $builder->getQuery()->getSingleScalarResult(); From 6ae03806b4db49c8cd5a6afdf837f15d458b1991 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 20 Oct 2022 22:33:23 +0200 Subject: [PATCH 45/51] Feature: [calendar][docgen] controller and UI to generate a document from a calendar --- .../Controller/CalendarController.php | 9 +- .../Controller/CalendarDocController.php | 82 +++++++++++++++++++ .../listByAccompanyingCourse.html.twig | 9 +- .../views/CalendarDoc/pick_template.html.twig | 24 ++++++ .../translations/messages.fr.yml | 2 + 5 files changed, 121 insertions(+), 5 deletions(-) create mode 100644 src/Bundle/ChillCalendarBundle/Controller/CalendarDocController.php create mode 100644 src/Bundle/ChillCalendarBundle/Resources/views/CalendarDoc/pick_template.html.twig diff --git a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php index 595eceb36..ff470842c 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php @@ -15,7 +15,7 @@ use Chill\CalendarBundle\Entity\Calendar; use Chill\CalendarBundle\Form\CalendarType; use Chill\CalendarBundle\RemoteCalendar\Connector\RemoteCalendarConnectorInterface; use Chill\CalendarBundle\Repository\CalendarACLAwareRepositoryInterface; -use Chill\CalendarBundle\Repository\CalendarRepository; +use Chill\DocGeneratorBundle\Repository\DocGeneratorTemplateRepository; use Chill\MainBundle\Entity\User; use Chill\MainBundle\Pagination\PaginatorFactory; use Chill\MainBundle\Repository\UserRepository; @@ -42,7 +42,7 @@ class CalendarController extends AbstractController { private CalendarACLAwareRepositoryInterface $calendarACLAwareRepository; - private CalendarRepository $calendarRepository; + private DocGeneratorTemplateRepository $docGeneratorTemplateRepository; private FilterOrderHelperFactoryInterface $filterOrderHelperFactory; @@ -57,8 +57,8 @@ class CalendarController extends AbstractController private UserRepository $userRepository; public function __construct( - CalendarRepository $calendarRepository, CalendarACLAwareRepositoryInterface $calendarACLAwareRepository, + DocGeneratorTemplateRepository $docGeneratorTemplateRepository, FilterOrderHelperFactoryInterface $filterOrderHelperFactory, LoggerInterface $logger, PaginatorFactory $paginator, @@ -66,8 +66,8 @@ class CalendarController extends AbstractController SerializerInterface $serializer, UserRepository $userRepository ) { - $this->calendarRepository = $calendarRepository; $this->calendarACLAwareRepository = $calendarACLAwareRepository; + $this->docGeneratorTemplateRepository = $docGeneratorTemplateRepository; $this->filterOrderHelperFactory = $filterOrderHelperFactory; $this->logger = $logger; $this->paginator = $paginator; @@ -214,6 +214,7 @@ class CalendarController extends AbstractController 'accompanyingCourse' => $accompanyingPeriod, 'paginator' => $paginator, 'filterOrder' => $filterOrder, + 'hasDocs' => 0 < $this->docGeneratorTemplateRepository->countByEntity(Calendar::class), ]); } diff --git a/src/Bundle/ChillCalendarBundle/Controller/CalendarDocController.php b/src/Bundle/ChillCalendarBundle/Controller/CalendarDocController.php new file mode 100644 index 000000000..2c9074488 --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/Controller/CalendarDocController.php @@ -0,0 +1,82 @@ +security = $security; + $this->docGeneratorTemplateRepository = $docGeneratorTemplateRepository; + $this->urlGenerator = $urlGenerator; + $this->engine = $engine; + } + + /** + * @Route("/{_locale}/calendar/docgen/pick/{id}", name="chill_calendar_calendardoc_pick_template") + */ + public function pickTemplate(Calendar $calendar): Response + { + if (!$this->security->isGranted(CalendarVoter::SEE, $calendar)) { + throw new AccessDeniedException('Not authorized to see this calendar'); + } + + if (0 === $number = $this->docGeneratorTemplateRepository->countByEntity(Calendar::class)) { + throw new RuntimeException('should not be redirected to this page if no template'); + } + + if (1 === $number) { + $templates = $this->docGeneratorTemplateRepository->findByEntity(Calendar::class); + + return new RedirectResponse( + $this->urlGenerator->generate( + 'chill_docgenerator_generate_from_template', + [ + 'template' => $templates[0]->getId(), + 'entityClassName' => Calendar::class, + 'entityId' => $calendar->getId(), + ] + ) + ); + } + + return new Response( + $this->engine->render('@ChillCalendar/CalendarDoc/pick_template.html.twig', [ + 'calendar' => $calendar, + 'accompanyingCourse' => $calendar->getAccompanyingPeriod(), + ]) + ); + } +} diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/listByAccompanyingCourse.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/listByAccompanyingCourse.html.twig index e71c3f7d4..03e4c85c2 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/listByAccompanyingCourse.html.twig +++ b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/listByAccompanyingCourse.html.twig @@ -128,7 +128,14 @@
+ + + {% endfor %} - - {% endfor %} + {% if calendarItems|length < paginator.getTotalItems %} + {{ chill_pagination(paginator) }} + {% endif %} - {% if calendarItems|length < paginator.getTotalItems %} - {{ chill_pagination(paginator) }} + + {% endif %} + + + {% endblock %} diff --git a/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml b/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml index 7e8717003..95d99b867 100644 --- a/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml @@ -51,6 +51,7 @@ chill_calendar: To: Au Next calendars: Prochains rendez-vous Add a document: Ajouter un document + Documents: Documents remote_ms_graph: @@ -125,3 +126,4 @@ docgen: Third party label: Label pour choisir le tiers Destinee: Destinataire None: Aucun choix + title of the generated document: Titre du document généré diff --git a/src/Bundle/ChillMainBundle/Resources/public/chill/scss/record_actions.scss b/src/Bundle/ChillMainBundle/Resources/public/chill/scss/record_actions.scss index d72b77e04..b8f60e250 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/chill/scss/record_actions.scss +++ b/src/Bundle/ChillMainBundle/Resources/public/chill/scss/record_actions.scss @@ -5,6 +5,10 @@ ul.record_actions { justify-content: flex-end; padding: 0.5em 0; + &.inline { + display: inline-block; + } + &.column { flex-direction: column; } @@ -18,6 +22,13 @@ ul.record_actions { padding-right: 1em; } + &.small { + .btn { + padding: .25rem .5rem; + font-size: .75rem; + } + } + li { display: inline-block; list-style-type: none; From 2c5fa82380ac423db0c5879b1a33162ea4ccc613 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 21 Oct 2022 10:40:51 +0200 Subject: [PATCH 47/51] Feature: [calendar] Add button to generate document immediatly after saving the calendar --- .../Controller/CalendarController.php | 18 ++++++++++++++++-- .../ChillCalendarBundle/Entity/Calendar.php | 4 ++-- .../Resources/views/Calendar/edit.html.twig | 11 ++++++----- .../Resources/views/Calendar/new.html.twig | 7 ++++--- .../translations/messages.fr.yml | 2 ++ 5 files changed, 30 insertions(+), 12 deletions(-) diff --git a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php index ff470842c..487d50e3a 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php @@ -152,7 +152,10 @@ class CalendarController extends AbstractController $view = '@ChillCalendar/Calendar/editByUser.html.twig'; } - $form = $this->createForm(CalendarType::class, $entity); + $form = $this->createForm(CalendarType::class, $entity) + ->add('save', SubmitType::class) + ->add('save_and_create_doc', SubmitType::class); + $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { @@ -162,6 +165,10 @@ class CalendarController extends AbstractController $params = $this->buildParamsToUrl($user, $accompanyingPeriod); + if ($form->get('save_and_create_doc')->isClicked()) { + return $this->redirectToRoute('chill_calendar_calendardoc_pick_template', ['id' => $entity->getId()]); + } + return $this->redirectToRoute('chill_calendar_calendar_list_by_period', $params); } @@ -277,7 +284,10 @@ class CalendarController extends AbstractController $entity->setAccompanyingPeriod($accompanyingPeriod); } - $form = $this->createForm(CalendarType::class, $entity); + $form = $this->createForm(CalendarType::class, $entity) + ->add('save', SubmitType::class) + ->add('save_and_create_doc', SubmitType::class); + $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { @@ -288,6 +298,10 @@ class CalendarController extends AbstractController $params = $this->buildParamsToUrl($user, $accompanyingPeriod); + if ($form->get('save_and_create_doc')->isClicked()) { + return $this->redirectToRoute('chill_calendar_calendardoc_pick_template', ['id' => $entity->getId()]); + } + return $this->redirectToRoute('chill_calendar_calendar_list_by_period', $params); } diff --git a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php index 2c8992aa0..9104f6131 100644 --- a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php +++ b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php @@ -611,7 +611,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface public function setEndDate(DateTimeImmutable $endDate): self { - if ($this->endDate->getTimestamp() !== $endDate->getTimestamp()) { + if (null === $this->endDate || $this->endDate->getTimestamp() !== $endDate->getTimestamp()) { $this->increaseaDatetimeVersion(); } @@ -662,7 +662,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface public function setStartDate(DateTimeImmutable $startDate): self { - if ($this->startDate->getTimestamp() !== $startDate->getTimestamp()) { + if (null === $this->startDate || $this->startDate->getTimestamp() !== $startDate->getTimestamp()) { $this->increaseaDatetimeVersion(); } diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/edit.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/edit.html.twig index f609b9d44..fce022ac4 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/edit.html.twig +++ b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/edit.html.twig @@ -77,11 +77,12 @@ {{ 'Cancel'|trans|chill_return_path_label }} -
  • - -
  • +
  • + {{ form_widget(form.save_and_create_doc, { 'attr' : { 'class' : 'btn btn-create' }, 'label': 'chill_calendar.Save and add a document'|trans }) }} +
  • +
  • + {{ form_widget(form.save, { 'attr' : { 'class' : 'btn btn-create' }, 'label': 'Save'|trans }) }} +
  • {{ form_end(form) }} diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/new.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/new.html.twig index 26ce25655..2e2ca9ce1 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/new.html.twig +++ b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/new.html.twig @@ -78,9 +78,10 @@
  • - + {{ form_widget(form.save_and_create_doc, { 'attr' : { 'class' : 'btn btn-create' }, 'label': 'chill_calendar.Create and add a document'|trans }) }} +
  • +
  • + {{ form_widget(form.save, { 'attr' : { 'class' : 'btn btn-create' }, 'label': 'Create'|trans }) }}
  • {{ form_end(form) }} diff --git a/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml b/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml index 95d99b867..bd9182e85 100644 --- a/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml @@ -52,6 +52,8 @@ chill_calendar: Next calendars: Prochains rendez-vous Add a document: Ajouter un document Documents: Documents + Create and add a document: Créer et ajouter un document + Save and add a document: Enregistrer et ajouter un document remote_ms_graph: From c04e408d9d05b07a8bb7ece7c6d4f29224df1545 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 21 Oct 2022 11:08:31 +0200 Subject: [PATCH 48/51] DX: [calendar] simplify menu builder injection deps --- .../Menu/UserMenuBuilder.php | 38 ++++--------------- 1 file changed, 7 insertions(+), 31 deletions(-) diff --git a/src/Bundle/ChillCalendarBundle/Menu/UserMenuBuilder.php b/src/Bundle/ChillCalendarBundle/Menu/UserMenuBuilder.php index db9276680..525039910 100644 --- a/src/Bundle/ChillCalendarBundle/Menu/UserMenuBuilder.php +++ b/src/Bundle/ChillCalendarBundle/Menu/UserMenuBuilder.php @@ -12,51 +12,27 @@ declare(strict_types=1); namespace Chill\CalendarBundle\Menu; use Chill\MainBundle\Routing\LocalMenuBuilderInterface; -use Chill\TaskBundle\Templating\UI\CountNotificationTask; use Knp\Menu\MenuItem; -use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; -use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; +use Symfony\Component\Security\Core\Security; use Symfony\Contracts\Translation\TranslatorInterface; class UserMenuBuilder implements LocalMenuBuilderInterface { - /** - * @var AuthorizationCheckerInterface - */ - public $authorizationChecker; + public TranslatorInterface $translator; - /** - * @var CountNotificationTask - */ - public $counter; - - /** - * @var TokenStorageInterface - */ - public $tokenStorage; - - /** - * @var TranslatorInterface - */ - public $translator; + private Security $security; public function __construct( - CountNotificationTask $counter, - TokenStorageInterface $tokenStorage, - TranslatorInterface $translator, - AuthorizationCheckerInterface $authorizationChecker + Security $security, + TranslatorInterface $translator ) { - $this->counter = $counter; - $this->tokenStorage = $tokenStorage; + $this->security = $security; $this->translator = $translator; - $this->authorizationChecker = $authorizationChecker; } public function buildMenu($menuId, MenuItem $menu, array $parameters) { - $user = $this->tokenStorage->getToken()->getUser(); - - if ($this->authorizationChecker->isGranted('ROLE_USER')) { + if ($this->security->isGranted('ROLE_USER')) { $menu->addChild('My calendar list', [ 'route' => 'chill_calendar_calendar_list_my', ]) From 43dcb46d38473d34baf083ab7c7bd10332149e7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 21 Oct 2022 11:28:59 +0200 Subject: [PATCH 49/51] Feature: [calendar] associate a calendar with a person: update schema --- .../ChillCalendarBundle/Entity/Calendar.php | 18 ++++++++++ .../migrations/Version20221021092541.php | 35 +++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 src/Bundle/ChillCalendarBundle/migrations/Version20221021092541.php diff --git a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php index 9104f6131..760b36efb 100644 --- a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php +++ b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php @@ -169,6 +169,12 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface */ private ?User $mainUser = null; + /** + * @ORM\ManyToOne(targetEntity=Person::class) + * @ORM\JoinColumn(nullable=true) + */ + private ?Person $person; + /** * @ORM\ManyToMany(targetEntity="Chill\PersonBundle\Entity\Person", inversedBy="calendars") * @ORM\JoinTable(name="chill_calendar.calendar_to_persons") @@ -379,6 +385,11 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface return $this->mainUser; } + public function getPerson(): ?Person + { + return $this->person; + } + /** * @return Collection|Person[] */ @@ -639,6 +650,13 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface return $this; } + public function setPerson(?Person $person): Calendar + { + $this->person = $person; + + return $this; + } + public function setPrivateComment(PrivateCommentEmbeddable $privateComment): self { $this->privateComment = $privateComment; diff --git a/src/Bundle/ChillCalendarBundle/migrations/Version20221021092541.php b/src/Bundle/ChillCalendarBundle/migrations/Version20221021092541.php new file mode 100644 index 000000000..732b975e3 --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/migrations/Version20221021092541.php @@ -0,0 +1,35 @@ +addSql('ALTER TABLE chill_calendar.calendar DROP person_id'); + } + + public function getDescription(): string + { + return 'Associate a calendar with a person'; + } + + public function up(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_calendar.calendar ADD person_id INT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_calendar.calendar ADD CONSTRAINT FK_712315AC217BBB47 FOREIGN KEY (person_id) REFERENCES chill_person_person (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('CREATE INDEX IDX_712315AC217BBB47 ON chill_calendar.calendar (person_id)'); + } +} From bc1a7c1d7bf24b6a368f5313a0e80fb5a372aba4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 21 Oct 2022 13:24:02 +0200 Subject: [PATCH 50/51] Feature: [calendar] allow to create and generate calendar by person --- .../views/Activity/concernedGroups.html.twig | 8 +- .../Controller/CalendarController.php | 165 +++++++++------- .../ChillCalendarBundle/Entity/Calendar.php | 20 +- .../Menu/PersonMenuBuilder.php | 52 +++++ .../Repository/CalendarACLAwareRepository.php | 80 +++++++- .../CalendarACLAwareRepositoryInterface.php | 18 ++ .../Resources/views/Calendar/_list.html.twig | 177 ++++++++++++++++++ .../Calendar/confirm_deleteByPerson.html.twig | 16 ++ .../views/Calendar/editByPerson.html.twig | 34 ++++ .../listByAccompanyingCourse.html.twig | 165 +--------------- .../views/Calendar/listByPerson.html.twig | 52 +++++ .../Resources/views/Calendar/new.html.twig | 2 +- .../views/Calendar/newByPerson.html.twig | 34 ++++ .../Security/Voter/CalendarVoter.php | 21 +++ .../CalendarACLAwareRepositoryTest.php | 78 ++++++++ 15 files changed, 677 insertions(+), 245 deletions(-) create mode 100644 src/Bundle/ChillCalendarBundle/Menu/PersonMenuBuilder.php create mode 100644 src/Bundle/ChillCalendarBundle/Resources/views/Calendar/_list.html.twig create mode 100644 src/Bundle/ChillCalendarBundle/Resources/views/Calendar/confirm_deleteByPerson.html.twig create mode 100644 src/Bundle/ChillCalendarBundle/Resources/views/Calendar/editByPerson.html.twig create mode 100644 src/Bundle/ChillCalendarBundle/Resources/views/Calendar/listByPerson.html.twig create mode 100644 src/Bundle/ChillCalendarBundle/Resources/views/Calendar/newByPerson.html.twig create mode 100644 src/Bundle/ChillCalendarBundle/Tests/Repository/CalendarACLAwareRepositoryTest.php diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/concernedGroups.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/concernedGroups.html.twig index 9b64403b1..96cfef39b 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/concernedGroups.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/concernedGroups.html.twig @@ -29,7 +29,7 @@ {% endmacro %} {% set blocks = [] %} -{% if context == 'calendar_accompanyingCourse' or entity.activityType.personsVisible %} +{% if context == 'calendar_accompanyingCourse' or context == 'calendar_person' or entity.activityType.personsVisible %} {% if context == 'person' %} {% set blocks = blocks|merge([{ 'title': 'Others persons'|trans, @@ -54,7 +54,7 @@ }]) %} {% endif %} {% endif %} -{% if context == 'calendar_accompanyingCourse' or entity.activityType.thirdPartiesVisible %} +{% if context == 'calendar_accompanyingCourse' or context == 'calendar_person' or entity.activityType.thirdPartiesVisible %} {% set blocks = blocks|merge([{ 'title': 'Third parties'|trans, 'items': entity.thirdParties, @@ -63,7 +63,7 @@ 'key' : 'id', }]) %} {% endif %} -{% if context == 'calendar_accompanyingCourse' or entity.activityType.usersVisible %} +{% if context == 'calendar_accompanyingCourse' or context == 'calendar_person' or entity.activityType.usersVisible %} {% set blocks = blocks|merge([{ 'title': 'Users concerned'|trans, 'items': entity.users, @@ -143,7 +143,7 @@ {% if bloc.type == 'user' %} {{ item|chill_entity_render_box({'render': 'raw', 'addAltNames': false }) }} - {%- if context == 'calendar_accompanyingCourse' %} + {%- if context == 'calendar_accompanyingCourse' or context == 'calendar_person' %} {% set invite = entity.inviteForUser(item) %} {% if invite is not null %} {{ invite.invite_span(invite) }} diff --git a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php index 487d50e3a..16aea6cca 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php @@ -18,15 +18,19 @@ use Chill\CalendarBundle\Repository\CalendarACLAwareRepositoryInterface; use Chill\DocGeneratorBundle\Repository\DocGeneratorTemplateRepository; use Chill\MainBundle\Entity\User; use Chill\MainBundle\Pagination\PaginatorFactory; -use Chill\MainBundle\Repository\UserRepository; use Chill\MainBundle\Templating\Listing\FilterOrderHelper; use Chill\MainBundle\Templating\Listing\FilterOrderHelperFactoryInterface; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\Person; +use Chill\PersonBundle\Repository\AccompanyingPeriodRepository; +use Chill\PersonBundle\Repository\PersonRepository; +use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; +use Chill\PersonBundle\Security\Authorization\PersonVoter; use Chill\ThirdPartyBundle\Entity\ThirdParty; use DateTimeImmutable; use Exception; use Psr\Log\LoggerInterface; +use RuntimeException; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\Form; @@ -40,6 +44,8 @@ use Symfony\Component\Serializer\SerializerInterface; class CalendarController extends AbstractController { + private AccompanyingPeriodRepository $accompanyingPeriodRepository; + private CalendarACLAwareRepositoryInterface $calendarACLAwareRepository; private DocGeneratorTemplateRepository $docGeneratorTemplateRepository; @@ -50,12 +56,12 @@ class CalendarController extends AbstractController private PaginatorFactory $paginator; + private PersonRepository $personRepository; + private RemoteCalendarConnectorInterface $remoteCalendarConnector; private SerializerInterface $serializer; - private UserRepository $userRepository; - public function __construct( CalendarACLAwareRepositoryInterface $calendarACLAwareRepository, DocGeneratorTemplateRepository $docGeneratorTemplateRepository, @@ -64,7 +70,8 @@ class CalendarController extends AbstractController PaginatorFactory $paginator, RemoteCalendarConnectorInterface $remoteCalendarConnector, SerializerInterface $serializer, - UserRepository $userRepository + PersonRepository $personRepository, + AccompanyingPeriodRepository $accompanyingPeriodRepository ) { $this->calendarACLAwareRepository = $calendarACLAwareRepository; $this->docGeneratorTemplateRepository = $docGeneratorTemplateRepository; @@ -73,7 +80,8 @@ class CalendarController extends AbstractController $this->paginator = $paginator; $this->remoteCalendarConnector = $remoteCalendarConnector; $this->serializer = $serializer; - $this->userRepository = $userRepository; + $this->personRepository = $personRepository; + $this->accompanyingPeriodRepository = $accompanyingPeriodRepository; } /** @@ -83,19 +91,21 @@ class CalendarController extends AbstractController */ public function deleteAction(Request $request, Calendar $entity) { - $view = null; $em = $this->getDoctrine()->getManager(); - $accompanyingPeriod = $entity->getAccompanyingPeriod(); - $user = null; // TODO legacy code ? remove it ? + [$person, $accompanyingPeriod] = [$entity->getPerson(), $entity->getAccompanyingPeriod()]; if ($accompanyingPeriod instanceof AccompanyingPeriod) { $view = '@ChillCalendar/Calendar/confirm_deleteByAccompanyingCourse.html.twig'; - } elseif ($user instanceof User) { - $view = '@ChillCalendar/Calendar/confirm_deleteByUser.html.twig'; + $redirectRoute = $this->generateUrl('chill_calendar_calendar_list_by_period', ['id' => $accompanyingPeriod->getId()]); + } elseif ($person instanceof Person) { + $view = '@ChillCalendar/Calendar/confirm_deleteByPerson.html.twig'; + $redirectRoute = $this->generateUrl('chill_calendar_calendar_list_by_person', ['id' => $person->getId()]); + } else { + throw new RuntimeException('nor person or accompanying period'); } - $form = $this->createDeleteForm($entity->getId(), $user, $accompanyingPeriod); + $form = $this->createDeleteForm($entity); if ($request->getMethod() === Request::METHOD_DELETE) { $form->handleRequest($request); @@ -112,20 +122,15 @@ class CalendarController extends AbstractController $this->addFlash('success', $this->get('translator') ->trans('The calendar item has been successfully removed.')); - $params = $this->buildParamsToUrl($user, $accompanyingPeriod); - - return $this->redirectToRoute('chill_calendar_calendar_list_by_period', $params); + return new RedirectResponse($redirectRoute); } } - if (null === $view) { - throw $this->createNotFoundException('Template not found'); - } - return $this->render($view, [ 'calendar' => $entity, 'delete_form' => $form->createView(), 'accompanyingCourse' => $accompanyingPeriod, + 'person' => $person, ]); } @@ -143,13 +148,16 @@ class CalendarController extends AbstractController $view = null; $em = $this->getDoctrine()->getManager(); - [$user, $accompanyingPeriod] = $this->getEntity($request); + [$person, $accompanyingPeriod] = [$entity->getPerson(), $entity->getAccompanyingPeriod()]; if ($accompanyingPeriod instanceof AccompanyingPeriod) { $view = '@ChillCalendar/Calendar/editByAccompanyingCourse.html.twig'; - } elseif ($user instanceof User) { - throw new Exception('to analyze'); - $view = '@ChillCalendar/Calendar/editByUser.html.twig'; + $redirectRoute = $this->generateUrl('chill_calendar_calendar_list_by_period', ['id' => $accompanyingPeriod->getId()]); + } elseif ($person instanceof Person) { + $view = '@ChillCalendar/Calendar/editByPerson.html.twig'; + $redirectRoute = $this->generateUrl('chill_calendar_calendar_list_by_person', ['id' => $person->getId()]); + } else { + throw new RuntimeException('no person nor accompanying period'); } $form = $this->createForm(CalendarType::class, $entity) @@ -163,33 +171,24 @@ class CalendarController extends AbstractController $this->addFlash('success', $this->get('translator')->trans('Success : calendar item updated!')); - $params = $this->buildParamsToUrl($user, $accompanyingPeriod); - if ($form->get('save_and_create_doc')->isClicked()) { return $this->redirectToRoute('chill_calendar_calendardoc_pick_template', ['id' => $entity->getId()]); } - return $this->redirectToRoute('chill_calendar_calendar_list_by_period', $params); + return new RedirectResponse($redirectRoute); } if ($form->isSubmitted() && !$form->isValid()) { $this->addFlash('error', $this->get('translator')->trans('This form contains errors')); } - $deleteForm = $this->createDeleteForm($entity->getId(), $user, $accompanyingPeriod); - - if (null === $view) { - throw $this->createNotFoundException('Template not found'); - } - $entity_array = $this->serializer->normalize($entity, 'json', ['groups' => 'read']); return $this->render($view, [ 'entity' => $entity, 'form' => $form->createView(), - 'delete_form' => $deleteForm->createView(), - 'accompanyingCourse' => $accompanyingPeriod, - // 'user' => $user, + 'accompanyingCourse' => $entity->getAccompanyingPeriod(), + 'person' => $entity->getPerson(), 'entity_json' => $entity_array, ]); } @@ -225,6 +224,37 @@ class CalendarController extends AbstractController ]); } + /** + * Lists all Calendar entities on a person. + * + * @Route("/{_locale}/calendar/calendar/by-person/{id}", name="chill_calendar_calendar_list_by_person") + */ + public function listActionByPerson(Person $person): Response + { + $filterOrder = $this->buildListFilterOrder(); + ['from' => $from, 'to' => $to] = $filterOrder->getDateRangeData('startDate'); + + $total = $this->calendarACLAwareRepository + ->countByPerson($person, $from, $to); + $paginator = $this->paginator->create($total); + $calendarItems = $this->calendarACLAwareRepository->findByPerson( + $person, + $from, + $to, + ['startDate' => 'DESC'], + $paginator->getCurrentPageFirstItemNumber(), + $paginator->getItemsPerPage() + ); + + return $this->render('@ChillCalendar/Calendar/listByPerson.html.twig', [ + 'calendarItems' => $calendarItems, + 'person' => $person, + 'paginator' => $paginator, + 'filterOrder' => $filterOrder, + 'hasDocs' => 0 < $this->docGeneratorTemplateRepository->countByEntity(Calendar::class), + ]); + } + /** * @Route("/{_locale}/calendar/calendar/my", name="chill_calendar_calendar_list_my") */ @@ -261,27 +291,22 @@ class CalendarController extends AbstractController $view = null; $em = $this->getDoctrine()->getManager(); - [$user, $accompanyingPeriod] = $this->getEntity($request); - - if ($accompanyingPeriod instanceof AccompanyingPeriod) { - $view = '@ChillCalendar/Calendar/newByAccompanyingCourse.html.twig'; - } - // elseif ($user instanceof User) { - // $view = '@ChillCalendar/Calendar/newUser.html.twig'; - // } + [$person, $accompanyingPeriod] = $this->getEntity($request); $entity = new Calendar(); - if ($request->query->has('mainUser')) { - $entity->setMainUser($this->userRepository->find($request->query->getInt('mainUser'))); + if ($accompanyingPeriod instanceof AccompanyingPeriod) { + $view = '@ChillCalendar/Calendar/newByAccompanyingCourse.html.twig'; + $entity->setAccompanyingPeriod($accompanyingPeriod); + $redirectRoute = $this->generateUrl('chill_calendar_calendar_list_by_period', ['id' => $accompanyingPeriod->getId()]); + } elseif ($person) { + $view = '@ChillCalendar/Calendar/newByPerson.html.twig'; + $entity->setPerson($person)->addPerson($person); + $redirectRoute = $this->generateUrl('chill_calendar_calendar_list_by_person', ['id' => $person->getId()]); } - // if ($user instanceof User) { - // $entity->setPerson($user); - // } - - if ($accompanyingPeriod instanceof AccompanyingPeriod) { - $entity->setAccompanyingPeriod($accompanyingPeriod); + if ($request->query->has('mainUser')) { + $entity->setMainUser($this->userRepository->find($request->query->getInt('mainUser'))); } $form = $this->createForm(CalendarType::class, $entity) @@ -296,13 +321,11 @@ class CalendarController extends AbstractController $this->addFlash('success', $this->get('translator')->trans('Success : calendar item created!')); - $params = $this->buildParamsToUrl($user, $accompanyingPeriod); - if ($form->get('save_and_create_doc')->isClicked()) { return $this->redirectToRoute('chill_calendar_calendardoc_pick_template', ['id' => $entity->getId()]); } - return $this->redirectToRoute('chill_calendar_calendar_list_by_period', $params); + return new RedirectResponse($redirectRoute); } if ($form->isSubmitted() && !$form->isValid()) { @@ -316,7 +339,8 @@ class CalendarController extends AbstractController $entity_array = $this->serializer->normalize($entity, 'json', ['groups' => 'read']); return $this->render($view, [ - 'user' => $user, + 'context' => $entity->getContext(), + 'person' => $person, 'accompanyingCourse' => $accompanyingPeriod, 'entity' => $entity, 'form' => $form->createView(), @@ -331,6 +355,7 @@ class CalendarController extends AbstractController */ public function showAction(Request $request, int $id): Response { + throw new Exception('not implemented'); $view = null; $em = $this->getDoctrine()->getManager(); @@ -465,49 +490,45 @@ class CalendarController extends AbstractController /** * Creates a form to delete a Calendar entity by id. */ - private function createDeleteForm(int $id, ?User $user, ?AccompanyingPeriod $accompanyingPeriod): FormInterface + private function createDeleteForm(Calendar $calendar): FormInterface { - $params = $this->buildParamsToUrl($user, $accompanyingPeriod); - $params['id'] = $id; - return $this->createFormBuilder() - ->setAction($this->generateUrl('chill_calendar_calendar_delete', $params)) + ->setAction($this->generateUrl('chill_calendar_calendar_delete', ['id' => $calendar->getId()])) ->setMethod('DELETE') ->add('submit', SubmitType::class, ['label' => 'Delete']) ->getForm(); } + /** + * @return array{0: ?Person, 1: ?AccompanyingPeriod} + */ private function getEntity(Request $request): array { $em = $this->getDoctrine()->getManager(); - $user = $accompanyingPeriod = null; + $person = $accompanyingPeriod = null; - if ($request->query->has('user_id')) { - $user_id = $request->get('user_id'); - $user = $em->getRepository(User::class)->find($user_id); + if ($request->query->has('person_id')) { + $person = $this->personRepository->find($request->query->getInt('person_id')); - if (null === $user) { - throw $this->createNotFoundException('User not found'); + if (null === $person) { + throw $this->createNotFoundException('Person not found'); } - // TODO Add permission - // $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $user); + $this->denyAccessUnlessGranted(PersonVoter::SEE, $person); } elseif ($request->query->has('accompanying_period_id')) { - $accompanying_period_id = $request->get('accompanying_period_id'); - $accompanyingPeriod = $em->getRepository(AccompanyingPeriod::class)->find($accompanying_period_id); + $accompanyingPeriod = $this->accompanyingPeriodRepository->find($request->query->getInt('accompanying_period_id')); if (null === $accompanyingPeriod) { throw $this->createNotFoundException('Accompanying Period not found'); } - // TODO Add permission - // $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person); + $this->denyAccessUnlessGranted(AccompanyingPeriodVoter::SEE, $accompanyingPeriod); } else { throw $this->createNotFoundException('Person or Accompanying Period not found'); } return [ - $user, $accompanyingPeriod, + $person, $accompanyingPeriod, ]; } } diff --git a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php index 760b36efb..351954492 100644 --- a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php +++ b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php @@ -92,7 +92,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface /** * @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod", inversedBy="calendars") */ - private AccompanyingPeriod $accompanyingPeriod; + private ?AccompanyingPeriod $accompanyingPeriod = null; /** * @ORM\ManyToOne(targetEntity="Chill\ActivityBundle\Entity\Activity") @@ -173,7 +173,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface * @ORM\ManyToOne(targetEntity=Person::class) * @ORM\JoinColumn(nullable=true) */ - private ?Person $person; + private ?Person $person = null; /** * @ORM\ManyToMany(targetEntity="Chill\PersonBundle\Entity\Person", inversedBy="calendars") @@ -317,6 +317,22 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface return $this->comment; } + /** + * @return 'person'|'accompanying_period'|null + */ + public function getContext(): ?string + { + if ($this->getAccompanyingPeriod() !== null) { + return 'accompanying_period'; + } + + if ($this->getPerson() !== null) { + return 'person'; + } + + return null; + } + /** * Each time the date and time is update, this version is incremented. */ diff --git a/src/Bundle/ChillCalendarBundle/Menu/PersonMenuBuilder.php b/src/Bundle/ChillCalendarBundle/Menu/PersonMenuBuilder.php new file mode 100644 index 000000000..eccbe1ffb --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/Menu/PersonMenuBuilder.php @@ -0,0 +1,52 @@ +security = $security; + $this->translator = $translator; + } + + public function buildMenu($menuId, MenuItem $menu, array $parameters) + { + $person = $parameters['person']; + + if ($this->security->isGranted(CalendarVoter::SEE, $person)) { + $menu->addChild($this->translator->trans('Calendar'), [ + 'route' => 'chill_calendar_calendar_list_by_person', + 'routeParameters' => [ + 'id' => $person->getId(), + ], ]) + ->setExtras(['order' => 198]); + } + } + + public static function getMenuIds(): array + { + return ['person']; + } +} diff --git a/src/Bundle/ChillCalendarBundle/Repository/CalendarACLAwareRepository.php b/src/Bundle/ChillCalendarBundle/Repository/CalendarACLAwareRepository.php index c331a3d3c..15d0d83c0 100644 --- a/src/Bundle/ChillCalendarBundle/Repository/CalendarACLAwareRepository.php +++ b/src/Bundle/ChillCalendarBundle/Repository/CalendarACLAwareRepository.php @@ -20,16 +20,24 @@ namespace Chill\CalendarBundle\Repository; use Chill\CalendarBundle\Entity\Calendar; use Chill\PersonBundle\Entity\AccompanyingPeriod; +use Chill\PersonBundle\Entity\Person; +use Chill\PersonBundle\Repository\AccompanyingPeriodACLAwareRepositoryInterface; +use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; use DateTimeImmutable; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\QueryBuilder; class CalendarACLAwareRepository implements CalendarACLAwareRepositoryInterface { + private AccompanyingPeriodACLAwareRepositoryInterface $accompanyingPeriodACLAwareRepository; + private EntityManagerInterface $em; - public function __construct(EntityManagerInterface $em) - { + public function __construct( + AccompanyingPeriodACLAwareRepositoryInterface $accompanyingPeriodACLAwareRepository, + EntityManagerInterface $em + ) { + $this->accompanyingPeriodACLAwareRepository = $accompanyingPeriodACLAwareRepository; $this->em = $em; } @@ -56,6 +64,46 @@ class CalendarACLAwareRepository implements CalendarACLAwareRepositoryInterface return $qb; } + /** + * Base implementation. The list of allowed accompanying period is retrieved "manually" from @see{AccompanyingPeriodACLAwareRepository}. + */ + public function buildQueryByPerson(Person $person, ?DateTimeImmutable $startDate, ?DateTimeImmutable $endDate): QueryBuilder + { + // find the reachable accompanying periods for person + $periods = $this->accompanyingPeriodACLAwareRepository->findByPerson($person, AccompanyingPeriodVoter::SEE); + + $qb = $this->em->createQueryBuilder() + ->from(Calendar::class, 'c'); + + $qb + ->where( + $qb->expr()->orX( + // the calendar where the person is the main person: + $qb->expr()->eq('c.person', ':person'), + // when the calendar is in a reachable period, and contains person + $qb->expr()->andX( + $qb->expr()->in('c.accompanyingPeriod', ':periods'), + $qb->expr()->isMemberOf(':person', 'c.persons') + ) + ) + ) + ->setParameter('person', $person) + ->setParameter('periods', $periods); + + // filter by date + if (null !== $startDate) { + $qb->andWhere($qb->expr()->gte('c.startDate', ':startDate')) + ->setParameter('startDate', $startDate); + } + + if (null !== $endDate) { + $qb->andWhere($qb->expr()->lte('c.endDate', ':endDate')) + ->setParameter('endDate', $endDate); + } + + return $qb; + } + public function countByAccompanyingPeriod(AccompanyingPeriod $period, ?DateTimeImmutable $startDate, ?DateTimeImmutable $endDate): int { $qb = $this->buildQueryByAccompanyingPeriod($period, $startDate, $endDate)->select('count(c)'); @@ -63,6 +111,14 @@ class CalendarACLAwareRepository implements CalendarACLAwareRepositoryInterface return $qb->getQuery()->getSingleScalarResult(); } + public function countByPerson(Person $person, ?DateTimeImmutable $startDate, ?DateTimeImmutable $endDate): int + { + return $this->buildQueryByPerson($person, $startDate, $endDate) + ->select('COUNT(c)') + ->getQuery() + ->getSingleScalarResult(); + } + /** * @return array|Calendar[] */ @@ -84,4 +140,24 @@ class CalendarACLAwareRepository implements CalendarACLAwareRepositoryInterface return $qb->getQuery()->getResult(); } + + public function findByPerson(Person $person, ?DateTimeImmutable $startDate, ?DateTimeImmutable $endDate, ?array $orderBy = [], ?int $offset = null, ?int $limit = null): array + { + $qb = $this->buildQueryByPerson($person, $startDate, $endDate) + ->select('c'); + + foreach ($orderBy as $sort => $order) { + $qb->addOrderBy('c.' . $sort, $order); + } + + if (null !== $offset) { + $qb->setFirstResult($offset); + } + + if (null !== $limit) { + $qb->setMaxResults($limit); + } + + return $qb->getQuery()->getResult(); + } } diff --git a/src/Bundle/ChillCalendarBundle/Repository/CalendarACLAwareRepositoryInterface.php b/src/Bundle/ChillCalendarBundle/Repository/CalendarACLAwareRepositoryInterface.php index a90f6a28c..d860c3470 100644 --- a/src/Bundle/ChillCalendarBundle/Repository/CalendarACLAwareRepositoryInterface.php +++ b/src/Bundle/ChillCalendarBundle/Repository/CalendarACLAwareRepositoryInterface.php @@ -20,14 +20,32 @@ namespace Chill\CalendarBundle\Repository; use Chill\CalendarBundle\Entity\Calendar; use Chill\PersonBundle\Entity\AccompanyingPeriod; +use Chill\PersonBundle\Entity\Person; use DateTimeImmutable; interface CalendarACLAwareRepositoryInterface { public function countByAccompanyingPeriod(AccompanyingPeriod $period, ?DateTimeImmutable $startDate, ?DateTimeImmutable $endDate): int; + /** + * Return the number or calendars associated with a person. See condition on @see{self::findByPerson}. + */ + public function countByPerson(Person $person, ?DateTimeImmutable $startDate, ?DateTimeImmutable $endDate): int; + /** * @return array|Calendar[] */ public function findByAccompanyingPeriod(AccompanyingPeriod $period, ?DateTimeImmutable $startDate, ?DateTimeImmutable $endDate, ?array $orderBy = [], ?int $offset = null, ?int $limit = null): array; + + /** + * Return all the calendars which are associated with a person, either on @see{Calendar::person} or within. + * + * @see{Calendar::persons}. The calendar may be associated with a person, or an accompanyingPeriod. + * + * The method may assume that the user is allowed to see the person, but must check that the user is allowed + * to see the calendar's accompanyingPeriod, if any. + * + * @return array|Calendar[] + */ + public function findByPerson(Person $person, ?DateTimeImmutable $startDate, ?DateTimeImmutable $endDate, ?array $orderBy = [], ?int $offset = null, ?int $limit = null): array; } diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/_list.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/_list.html.twig new file mode 100644 index 000000000..3eb1d6634 --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/_list.html.twig @@ -0,0 +1,177 @@ +{# list used in context of person or accompanyingPeriod #} + +{{ filterOrder|chill_render_filter_order_helper }} + +{% if calendarItems|length > 0 %} +
    + + {% for calendar in calendarItems %} + +
    +
    +
    +
    +
    +
    +

    + {% if context == 'person' and calendar.context == 'accompanying_period' %} + + + {{ calendar.accompanyingPeriod.id }} + + + {% endif %} + {% if calendar.endDate.diff(calendar.startDate).days >= 1 %} + {{ calendar.startDate|format_datetime('short', 'short') }} + - {{ calendar.endDate|format_datetime('short', 'short') }} + {% else %} + {{ calendar.startDate|format_datetime('short', 'short') }} + - {{ calendar.endDate|format_datetime('none', 'short') }} + {% endif %} +

    + +
    + + {{ calendar.duration|date('%H:%I') }} + {% if false == calendar.sendSMS or null == calendar.sendSMS %} + + {% else %} + {% if calendar.smsStatus == 'sms_sent' %} + + + + + {% else %} + + + + + {% endif %} + {% endif %} +
    + +
    +
    +
    + +
    +
      + {% if calendar.mainUser is not empty %} + {{ calendar.mainUser|chill_entity_render_box }} + {% endif %} +
    +
    + +
    +
    + + {% if calendar.comment.comment is not empty + or calendar.users|length > 0 + or calendar.thirdParties|length > 0 + or calendar.users|length > 0 %} +
    +
    + {% include 'ChillActivityBundle:Activity:concernedGroups.html.twig' with { + 'context': calendar.context == 'person' ? 'calendar_person' : 'calendar_accompanyingCourse', + 'render': 'wrap-list', + 'entity': calendar + } %} +
    + +
    + {% endif %} + + {% if calendar.comment.comment is not empty %} +
    +
    + {{ calendar.comment|chill_entity_render_box( { 'limit_lines': 3, 'metadata': false } ) }} +
    +
    + {% endif %} + + {% if calendar.location is not empty %} +
    +
    + {% if calendar.location.address is not same as(null) and calendar.location.name is not empty %} + {% endif %} + {% if calendar.location.name is not empty %}{{ calendar.location.name }}{% endif %} + {% if calendar.location.address is not same as(null) %}{{ calendar.location.address|chill_entity_render_box({'multiline': false, 'with_picto': (calendar.location.name is empty)}) }}{% else %} + {% endif %} + {% if calendar.location.phonenumber1 is not empty %} {{ calendar.location.phonenumber1|chill_format_phonenumber }}{% endif %} + {% if calendar.location.phonenumber2 is not empty %} {{ calendar.location.phonenumber2|chill_format_phonenumber }}{% endif %} +
    +
    + {% endif %} + +
    +
    + + {{ include('@ChillCalendar/Calendar/_documents.twig.html') }} +
    +
    + +
    +
      + {% if is_granted('CHILL_CALENDAR_CALENDAR_SEE', calendar) and hasDocs %} +
    • + + {{ 'chill_calendar.Add a document'|trans }} + +
    • + {% endif %} + {% if accompanyingCourse is defined and is_granted('CHILL_ACTIVITY_CREATE', accompanyingCourse) and calendar.activity is null %} +
    • + + {{ 'Transform to activity'|trans }} + +
    • + {% endif %} + + {% if (calendar.isInvited(app.user)) %} + {% set invite = calendar.inviteForUser(app.user) %} +
    • +
      +
    • + {% endif %} + {% if false %} +
    • + +
    • + {% endif %} + {# TOOD + {% if is_granted('CHILL_ACTIVITY_UPDATE', calendar) %} + #} +
    • + +
    • + {# TOOD + {% endif %} + {% if is_granted('CHILL_ACTIVITY_DELETE', calendar) %} + #} +
    • + +
    • + {# + {% endif %} + #} +
    + +
    + +
    + {% endfor %} + + {% if calendarItems|length < paginator.getTotalItems %} + {{ chill_pagination(paginator) }} + {% endif %} + +
    +{% endif %} diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/confirm_deleteByPerson.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/confirm_deleteByPerson.html.twig new file mode 100644 index 000000000..f72d0d21b --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/confirm_deleteByPerson.html.twig @@ -0,0 +1,16 @@ +{% extends "@ChillPerson/Person/layout.html.twig" %} + +{% set activeRouteKey = 'chill_calendar_calendar_list' %} + +{% block title 'Remove calendar item'|trans %} + +{% block content %} + {{ include('@ChillMain/Util/confirmation_template.html.twig', + { + 'title' : 'Remove calendar item'|trans, + 'confirm_question' : 'Are you sure you want to remove the calendar item?'|trans, + 'cancel_route' : 'chill_calendar_calendar_list_by_period', + 'cancel_parameters' : { 'id' : person.id }, + 'form' : delete_form + } ) }} +{% endblock %} diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/editByPerson.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/editByPerson.html.twig new file mode 100644 index 000000000..fc5319849 --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/editByPerson.html.twig @@ -0,0 +1,34 @@ +{% extends "@ChillPerson/Person/layout.html.twig" %} + +{% set activeRouteKey = 'chill_calendar_calendar_list' %} + +{% block title 'Update calendar'|trans %} + +{% block content %} +
    + + {% include 'ChillCalendarBundle:Calendar:edit.html.twig' with {'context': 'person'} %} + +
    +{% endblock %} + +{% block js %} + {{ parent() }} + + {{ encore_entry_script_tags('vue_calendar') }} +{% endblock %} + +{% block css %} + {{ parent() }} + {{ encore_entry_link_tags('vue_calendar') }} + {{ encore_entry_link_tags('page_calendar') }} +{% endblock %} + +{% block block_post_menu %} +
    +{% endblock %} diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/listByAccompanyingCourse.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/listByAccompanyingCourse.html.twig index 56d9a667d..f1b0c6110 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/listByAccompanyingCourse.html.twig +++ b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/listByAccompanyingCourse.html.twig @@ -22,7 +22,6 @@ {% block content %}

    {{ 'Calendar list' |trans }}

    - {{ filterOrder|chill_render_filter_order_helper }} {% if calendarItems|length == 0 %}

    @@ -31,171 +30,9 @@ class="btn btn-create button-small">

    {% else %} - -
    - - {% for calendar in calendarItems %} - -
    -
    -
    -
    -
    -
    - {% if calendar.endDate.diff(calendar.startDate).days >= 1 %} -

    {{ calendar.startDate|format_datetime('short', 'short') }} - - {{ calendar.endDate|format_datetime('short', 'short') }}

    - {% else %} -

    {{ calendar.startDate|format_datetime('short', 'short') }} - - {{ calendar.endDate|format_datetime('none', 'short') }}

    - {% endif %} - -
    - - {{ calendar.duration|date('%H:%I') }} - {% if false == calendar.sendSMS or null == calendar.sendSMS %} - - {% else %} - {% if calendar.smsStatus == 'sms_sent' %} - - - - - {% else %} - - - - - {% endif %} - {% endif %} -
    - -
    -
    -
    - -
    -
      - {% if calendar.mainUser is not empty %} - {{ calendar.mainUser|chill_entity_render_box }} - {% endif %} -
    -
    - -
    -
    - - {% if calendar.comment.comment is not empty - or calendar.users|length > 0 - or calendar.thirdParties|length > 0 - or calendar.users|length > 0 %} -
    -
    - {% include 'ChillActivityBundle:Activity:concernedGroups.html.twig' with { - 'context': 'calendar_accompanyingCourse', - 'render': 'wrap-list', - 'entity': calendar - } %} -
    - -
    - {% endif %} - - {% if calendar.comment.comment is not empty %} -
    -
    - {{ calendar.comment|chill_entity_render_box( { 'limit_lines': 3, 'metadata': false } ) }} -
    -
    - {% endif %} - - {% if calendar.location is not empty %} -
    -
    - {% if calendar.location.address is not same as(null) and calendar.location.name is not empty %} - {% endif %} - {% if calendar.location.name is not empty %}{{ calendar.location.name }}{% endif %} - {% if calendar.location.address is not same as(null) %}{{ calendar.location.address|chill_entity_render_box({'multiline': false, 'with_picto': (calendar.location.name is empty)}) }}{% else %} - {% endif %} - {% if calendar.location.phonenumber1 is not empty %} {{ calendar.location.phonenumber1|chill_format_phonenumber }}{% endif %} - {% if calendar.location.phonenumber2 is not empty %} {{ calendar.location.phonenumber2|chill_format_phonenumber }}{% endif %} -
    -
    - {% endif %} - -
    -
    - - {{ include('@ChillCalendar/Calendar/_documents.twig.html') }} -
    -
    - -
    -
      - {% if is_granted('CHILL_CALENDAR_CALENDAR_SEE', calendar) and hasDocs %} -
    • - - {{ 'chill_calendar.Add a document'|trans }} - -
    • - {% endif %} - {% if is_granted('CHILL_ACTIVITY_CREATE', accompanyingCourse) and calendar.activity is null %} -
    • - - {{ 'Transform to activity'|trans }} - -
    • - {% endif %} - {% if (calendar.isInvited(app.user)) %} - {% set invite = calendar.inviteForUser(app.user) %} -
    • -
      -
    • - {% endif %} - {% if false %} -
    • - -
    • - {% endif %} - {# TOOD - {% if is_granted('CHILL_ACTIVITY_UPDATE', calendar) %} - #} -
    • - -
    • - {# TOOD - {% endif %} - {% if is_granted('CHILL_ACTIVITY_DELETE', calendar) %} - #} -
    • - -
    • - {# - {% endif %} - #} -
    - -
    - -
    - {% endfor %} - - {% if calendarItems|length < paginator.getTotalItems %} - {{ chill_pagination(paginator) }} - {% endif %} - -
    + {{ include('@ChillCalendar/Calendar/_list.html.twig', {context: 'accompanying_course'}) }} {% endif %} -