diff --git a/.changes/unreleased/Feature-20230817-131059.yaml b/.changes/unreleased/Feature-20230817-131059.yaml deleted file mode 100644 index 29de8ec34..000000000 --- a/.changes/unreleased/Feature-20230817-131059.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: Feature -body: Add locations in Aside Activity. By default, suggest user location, otherwise - a select with all locations. -time: 2023-08-17T13:10:59.152278661+02:00 -custom: - Issue: "133" diff --git a/.changes/unreleased/Feature-20230817-131152.yaml b/.changes/unreleased/Feature-20230817-131152.yaml deleted file mode 100644 index bf9a165bf..000000000 --- a/.changes/unreleased/Feature-20230817-131152.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: Feature -body: 'Adapt Aside Activity exports: display location, filter by location, group by - location' -time: 2023-08-17T13:11:52.911356021+02:00 -custom: - Issue: "133" diff --git a/.changes/unreleased/Feature-20230926-164441.yaml b/.changes/unreleased/Feature-20230926-164441.yaml new file mode 100644 index 000000000..10ad686ec --- /dev/null +++ b/.changes/unreleased/Feature-20230926-164441.yaml @@ -0,0 +1,7 @@ +kind: Feature +body: "The regulation list load accompanying periods by exact postal code (address + associated with postal code), and not by the content of the postal code (postal + code with same code's string)" +time: 2023-09-26T16:44:41.414746336+02:00 +custom: + Issue: "155" diff --git a/.changes/unreleased/Fixed-20230817-131239.yaml b/.changes/unreleased/Fixed-20230817-131239.yaml deleted file mode 100644 index 6fc62f433..000000000 --- a/.changes/unreleased/Fixed-20230817-131239.yaml +++ /dev/null @@ -1,5 +0,0 @@ -kind: Fixed -body: Missing translation in Work Actions exports -time: 2023-08-17T13:12:39.159627128+02:00 -custom: - Issue: "" diff --git a/.changes/unreleased/Fixed-20230822-142809.yaml b/.changes/unreleased/Fixed-20230822-142809.yaml deleted file mode 100644 index b22477135..000000000 --- a/.changes/unreleased/Fixed-20230822-142809.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: Fixed -body: "Corrects a typing error in 2 filters, which caused an \nerror when trying to - reedit a saved export\n\n" -time: 2023-08-22T14:28:09.485466139+02:00 -custom: - Issue: "135" diff --git a/.changes/unreleased/Fixed-20230829-181332.yaml b/.changes/unreleased/Fixed-20230829-181332.yaml deleted file mode 100644 index bf77afcf9..000000000 --- a/.changes/unreleased/Fixed-20230829-181332.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: Fixed -body: '[household] when moving a person to a sharing position to a not-sharing position - on the same household on the same date, remove the previous household membership on the same household. This fix duplicate member.' -time: 2023-08-29T18:13:32.799479781+02:00 -custom: - Issue: "136" diff --git a/.changes/unreleased/Fixed-20230829-181837.yaml b/.changes/unreleased/Fixed-20230829-181837.yaml deleted file mode 100644 index 447e8379d..000000000 --- a/.changes/unreleased/Fixed-20230829-181837.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: Fixed -body: | - Add missing translation for comment field placeholder in repositionning household editor. -time: 2023-08-29T18:18:37.691526331+02:00 -custom: - Issue: "" diff --git a/.changes/unreleased/Fixed-20230906-154856.yaml b/.changes/unreleased/Fixed-20230906-154856.yaml deleted file mode 100644 index 73fb2dc48..000000000 --- a/.changes/unreleased/Fixed-20230906-154856.yaml +++ /dev/null @@ -1,5 +0,0 @@ -kind: Fixed -body: Do not send an email to creator twice when adding a comment to a notification -time: 2023-09-06T15:48:56.991246312+02:00 -custom: - Issue: "" diff --git a/.changes/unreleased/Fixed-20230913-115954.yaml b/.changes/unreleased/Fixed-20230913-115954.yaml new file mode 100644 index 000000000..df1eef370 --- /dev/null +++ b/.changes/unreleased/Fixed-20230913-115954.yaml @@ -0,0 +1,5 @@ +kind: Fixed +body: Fix the label of filter ActivityTypeFilter to a more obvious one +time: 2023-09-13T11:59:54.948009297+02:00 +custom: + Issue: "142" diff --git a/.changes/unreleased/Fixed-20230926-175815.yaml b/.changes/unreleased/Fixed-20230926-175815.yaml new file mode 100644 index 000000000..8eb833de7 --- /dev/null +++ b/.changes/unreleased/Fixed-20230926-175815.yaml @@ -0,0 +1,6 @@ +kind: Fixed +body: '[export] Fix association of filter "filter location by type" which did not + appears on "list of activities"' +time: 2023-09-26T17:58:15.871908118+02:00 +custom: + Issue: "140" diff --git a/.changes/unreleased/UX-20230829-181733.yaml b/.changes/unreleased/UX-20230829-181733.yaml deleted file mode 100644 index 981f2c272..000000000 --- a/.changes/unreleased/UX-20230829-181733.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: UX -body: | - Uniformize badge-person in household banner (background, size) -time: 2023-08-29T18:17:33.190396543+02:00 -custom: - Issue: "" diff --git a/.changes/v2.6.0.md b/.changes/v2.6.0.md new file mode 100644 index 000000000..656373532 --- /dev/null +++ b/.changes/v2.6.0.md @@ -0,0 +1,21 @@ +## v2.6.0 - 2023-09-14 +### Feature +* ([#133](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/133)) Add locations in Aside Activity. By default, suggest user location, otherwise a select with all locations. +* ([#133](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/133)) Adapt Aside Activity exports: display location, filter by location, group by location +* Use the CRUD controller for center entity + add the isActive property to be able to mask instances of Center that are no longer in use. +### Fixed +* ([#107](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/107)) reinstate the fusion of duplicate persons +* Missing translation in Work Actions exports +* Reimplement the mission type filter on tasks, only for instances that have a config parameter indicating true for this. +* ([#135](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/135)) Corrects a typing error in 2 filters, which caused an +error when trying to reedit a saved export + + +* ([#136](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/136)) [household] when moving a person to a sharing position to a not-sharing position on the same household on the same date, remove the previous household membership on the same household. This fix duplicate member. +* Add missing translation for comment field placeholder in repositionning household editor. + +* Do not send an email to creator twice when adding a comment to a notification +* ([#107](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/107)) Fix gestion doublon functionality to work with chill bundles v2 +### UX +* Uniformize badge-person in household banner (background, size) + diff --git a/.changes/v2.6.1.md b/.changes/v2.6.1.md new file mode 100644 index 000000000..4907b52e9 --- /dev/null +++ b/.changes/v2.6.1.md @@ -0,0 +1,3 @@ +## v2.6.1 - 2023-09-14 +### Fixed +* Filter out active centers in exports, which uses a different PickCenterType. diff --git a/.changes/v2.6.2.md b/.changes/v2.6.2.md new file mode 100644 index 000000000..4d5b6e293 --- /dev/null +++ b/.changes/v2.6.2.md @@ -0,0 +1,3 @@ +## v2.6.2 - 2023-09-18 +### Fixed +* Fix doctrine mapping of AbstractTaskPlaceEvent and SingleTaskPlaceEvent: id property moved. diff --git a/.changes/v2.6.3.md b/.changes/v2.6.3.md new file mode 100644 index 000000000..a70634785 --- /dev/null +++ b/.changes/v2.6.3.md @@ -0,0 +1,4 @@ +## v2.6.3 - 2023-09-19 +### Fixed +* Remove id property from document +mappedsuperclass diff --git a/CHANGELOG.md b/CHANGELOG.md index cd9f4683a..50b9fe257 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,41 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html), and is generated by [Changie](https://github.com/miniscruff/changie). +## v2.6.3 - 2023-09-19 +### Fixed +* Remove id property from document +mappedsuperclass + +## v2.6.2 - 2023-09-18 +### Fixed +* Fix doctrine mapping of AbstractTaskPlaceEvent and SingleTaskPlaceEvent: id property moved. + +## v2.6.1 - 2023-09-14 +### Fixed +* Filter out active centers in exports, which uses a different PickCenterType. + +## v2.6.0 - 2023-09-14 +### Feature +* ([#133](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/133)) Add locations in Aside Activity. By default, suggest user location, otherwise a select with all locations. +* ([#133](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/133)) Adapt Aside Activity exports: display location, filter by location, group by location +* Use the CRUD controller for center entity + add the isActive property to be able to mask instances of Center that are no longer in use. +### Fixed +* ([#107](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/107)) reinstate the fusion of duplicate persons +* Missing translation in Work Actions exports +* Reimplement the mission type filter on tasks, only for instances that have a config parameter indicating true for this. +* ([#135](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/135)) Corrects a typing error in 2 filters, which caused an +error when trying to reedit a saved export + + +* ([#136](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/136)) [household] when moving a person to a sharing position to a not-sharing position on the same household on the same date, remove the previous household membership on the same household. This fix duplicate member. +* Add missing translation for comment field placeholder in repositionning household editor. + +* Do not send an email to creator twice when adding a comment to a notification +* ([#107](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/107)) Fix gestion doublon functionality to work with chill bundles v2 +### UX +* Uniformize badge-person in household banner (background, size) + + ## v2.5.3 - 2023-07-20 ### Fixed * ([#132](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/132)) Rendez-vous documents created would appear in all documents lists of all persons with an accompanying period. Or statements are now added to the where clause to filter out documents that come from unrelated accompanying period/ or person rendez-vous. diff --git a/composer.json b/composer.json index 543f9e697..3195f732b 100644 --- a/composer.json +++ b/composer.json @@ -121,7 +121,8 @@ "ocramius/package-versions": true, "phpro/grumphp": true, "phpstan/extension-installer": true, - "roave/you-are-using-it-wrong": true + "roave/you-are-using-it-wrong": true, + "symfony/runtime": true }, "bin-dir": "bin", "optimize-autoloader": true, diff --git a/docs/source/development/FAQ.rst b/docs/source/development/FAQ.rst new file mode 100644 index 000000000..c0b7e37e8 --- /dev/null +++ b/docs/source/development/FAQ.rst @@ -0,0 +1,36 @@ +.. Copyright (C) 2014 Champs Libres Cooperative SCRLFS +Permission is granted to copy, distribute and/or modify this document +under the terms of the GNU Free Documentation License, Version 1.3 +or any later version published by the Free Software Foundation; +with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. +A copy of the license is included in the section entitled "GNU +Free Documentation License". + +.. _faq: + + +Frequently asked questions +#################### + +Continuous integration +*********** + +Pipeline fails, but php-cs-fixer doesn't alert me when running it locally ? +======================================== + +It is possible that you run php-cs-fixer on your local instance of chill and no fixes are made. +Everything seems fine, so you push. However once the pipeline is run in gitlab, you're notified that it failed due to php +cs errors. + +In this case it's likely that you have to update your version of php-cs-fixer. +php-cs-fixer is installed when building the docker image: https://gitea.champs-libres.be/Chill-project/chill-skeleton-basic/src/branch/main/Dockerfile#L50 + +Consequently, to update php-cs-fixer we have to update the image by building it again. + +For this the following commands can be used, + +.. code-block:: php + + docker compose build --pull php + # replace existing containers + docker compose up -d --force-recreate php diff --git a/docs/source/development/index.rst b/docs/source/development/index.rst index 768d29ce0..d48f92890 100644 --- a/docs/source/development/index.rst +++ b/docs/source/development/index.rst @@ -9,7 +9,7 @@ Development ########### -As Chill rely on the `symfony `_ framework, reading the framework's documentation should answer most of your questions. We are explaining here some tips to work with Chill, and things we provide to encounter our needs. +As Chill relies on the `symfony `_ framework, reading the framework's documentation should answer most of your questions. We are explaining here some tips to work with Chill, and help with things we've encountered. .. toctree:: :maxdepth: 2 @@ -37,6 +37,7 @@ As Chill rely on the `symfony `_ framework, reading the fram Cron Jobs Info about entities Info about database (in French) + Developer FAQ Layout and UI ************** diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByCreatorAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ByCreatorAggregator.php similarity index 94% rename from src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByCreatorAggregator.php rename to src/Bundle/ChillActivityBundle/Export/Aggregator/ByCreatorAggregator.php index a68a2b3e4..17fdaa7c0 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByCreatorAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ByCreatorAggregator.php @@ -9,7 +9,7 @@ declare(strict_types=1); * the LICENSE file that was distributed with this source code. */ -namespace Chill\ActivityBundle\Export\Aggregator\ACPAggregators; +namespace Chill\ActivityBundle\Export\Aggregator; use Chill\ActivityBundle\Export\Declarations; use Chill\MainBundle\Export\AggregatorInterface; @@ -35,7 +35,7 @@ class ByCreatorAggregator implements AggregatorInterface public function applyOn(): string { - return Declarations::ACTIVITY_ACP; + return Declarations::ACTIVITY; } public function buildForm(FormBuilderInterface $builder) diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByThirdpartyAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ByThirdpartyAggregator.php similarity index 94% rename from src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByThirdpartyAggregator.php rename to src/Bundle/ChillActivityBundle/Export/Aggregator/ByThirdpartyAggregator.php index 03b41a3fb..3190c6bda 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByThirdpartyAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ByThirdpartyAggregator.php @@ -9,7 +9,7 @@ declare(strict_types=1); * the LICENSE file that was distributed with this source code. */ -namespace Chill\ActivityBundle\Export\Aggregator\ACPAggregators; +namespace Chill\ActivityBundle\Export\Aggregator; use Chill\ActivityBundle\Export\Declarations; use Chill\MainBundle\Export\AggregatorInterface; @@ -40,7 +40,7 @@ class ByThirdpartyAggregator implements AggregatorInterface public function applyOn(): string { - return Declarations::ACTIVITY_ACP; + return Declarations::ACTIVITY; } public function buildForm(FormBuilderInterface $builder) diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/CreatorScopeAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/CreatorScopeAggregator.php similarity index 95% rename from src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/CreatorScopeAggregator.php rename to src/Bundle/ChillActivityBundle/Export/Aggregator/CreatorScopeAggregator.php index 8e9a17f53..581614832 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/CreatorScopeAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/CreatorScopeAggregator.php @@ -9,7 +9,7 @@ declare(strict_types=1); * the LICENSE file that was distributed with this source code. */ -namespace Chill\ActivityBundle\Export\Aggregator\ACPAggregators; +namespace Chill\ActivityBundle\Export\Aggregator; use Chill\ActivityBundle\Export\Declarations; use Chill\MainBundle\Export\AggregatorInterface; @@ -40,7 +40,7 @@ class CreatorScopeAggregator implements AggregatorInterface public function applyOn(): string { - return Declarations::ACTIVITY_ACP; + return Declarations::ACTIVITY; } public function buildForm(FormBuilderInterface $builder) diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/DateAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/DateAggregator.php similarity index 96% rename from src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/DateAggregator.php rename to src/Bundle/ChillActivityBundle/Export/Aggregator/DateAggregator.php index 59803bb61..f0a02dadd 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/DateAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/DateAggregator.php @@ -9,7 +9,7 @@ declare(strict_types=1); * the LICENSE file that was distributed with this source code. */ -namespace Chill\ActivityBundle\Export\Aggregator\ACPAggregators; +namespace Chill\ActivityBundle\Export\Aggregator; use Chill\ActivityBundle\Export\Declarations; use Chill\MainBundle\Export\AggregatorInterface; @@ -66,7 +66,7 @@ class DateAggregator implements AggregatorInterface public function applyOn(): string { - return Declarations::ACTIVITY_ACP; + return Declarations::ACTIVITY; } public function buildForm(FormBuilderInterface $builder) diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/LocationTypeAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/LocationTypeAggregator.php similarity index 95% rename from src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/LocationTypeAggregator.php rename to src/Bundle/ChillActivityBundle/Export/Aggregator/LocationTypeAggregator.php index 25cff1487..e302a2569 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/LocationTypeAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/LocationTypeAggregator.php @@ -9,7 +9,7 @@ declare(strict_types=1); * the LICENSE file that was distributed with this source code. */ -namespace Chill\ActivityBundle\Export\Aggregator\ACPAggregators; +namespace Chill\ActivityBundle\Export\Aggregator; use Chill\ActivityBundle\Export\Declarations; use Chill\MainBundle\Export\AggregatorInterface; @@ -40,7 +40,7 @@ class LocationTypeAggregator implements AggregatorInterface public function applyOn(): string { - return Declarations::ACTIVITY_ACP; + return Declarations::ACTIVITY; } public function buildForm(FormBuilderInterface $builder) diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php index 8afdf6e58..9a226f9c3 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php @@ -12,6 +12,7 @@ declare(strict_types=1); namespace Chill\ActivityBundle\Export\Export\LinkedToACP; use Chill\ActivityBundle\Entity\Activity; +use Chill\ActivityBundle\Export\Declarations; use Chill\ActivityBundle\Export\Export\ListActivityHelper; use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter; use Chill\MainBundle\Entity\Scope; @@ -141,6 +142,7 @@ class ListActivity implements ListInterface, GroupedExportInterface return array_merge( $this->helper->supportsModifiers(), [ + Declarations::ACTIVITY, \Chill\PersonBundle\Export\Declarations::ACP_TYPE, ] ); diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php index d4b86adab..f31e3faf8 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php @@ -281,7 +281,7 @@ class ListActivity implements ListInterface, GroupedExportInterface return [ Declarations::ACTIVITY, Declarations::ACTIVITY_PERSON, - //PersonDeclarations::PERSON_TYPE, + PersonDeclarations::PERSON_TYPE, ]; } } diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/StatActivityDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/StatActivityDuration.php index 9cd3743bf..e4ecbc963 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/StatActivityDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/StatActivityDuration.php @@ -148,7 +148,7 @@ class StatActivityDuration implements ExportInterface, GroupedExportInterface return [ Declarations::ACTIVITY, Declarations::ACTIVITY_PERSON, - //PersonDeclarations::PERSON_TYPE, + PersonDeclarations::PERSON_TYPE, ]; } } diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php index d07ee871c..bfa492fb9 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php @@ -23,7 +23,10 @@ use Symfony\Component\Form\FormBuilderInterface; class ActivityTypeFilter implements FilterInterface { - public function __construct(private readonly ActivityTypeRepositoryInterface $activityTypeRepository, private readonly TranslatableStringHelperInterface $translatableStringHelper) {} + public function __construct( + private readonly ActivityTypeRepositoryInterface $activityTypeRepository, + private readonly TranslatableStringHelperInterface $translatableStringHelper + ) {} public function addRole(): ?string { @@ -71,7 +74,7 @@ class ActivityTypeFilter implements FilterInterface $types[] = $this->translatableStringHelper->localize($aty->getName()); } - return ['Filtered by activity types: only %activitytypes%', [ + return ['export.filter.activity.acp_by_activity_type.acp_containing_at_least_one_%activitytypes%', [ '%activitytypes%' => implode(', ', $types), ]]; } diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/HasNoActivityFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/HasNoActivityFilter.php index b5dab4009..ab7331a65 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/HasNoActivityFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/HasNoActivityFilter.php @@ -17,6 +17,9 @@ use Chill\PersonBundle\Export\Declarations; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; +/** + * Filter accompanying periods to keep only the one without any activity + */ class HasNoActivityFilter implements FilterInterface { public function addRole(): ?string diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ByCreatorFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ByCreatorFilter.php similarity index 94% rename from src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ByCreatorFilter.php rename to src/Bundle/ChillActivityBundle/Export/Filter/ByCreatorFilter.php index 9d58170a8..285dc2e44 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ByCreatorFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ByCreatorFilter.php @@ -9,7 +9,7 @@ declare(strict_types=1); * the LICENSE file that was distributed with this source code. */ -namespace Chill\ActivityBundle\Export\Filter\ACPFilters; +namespace Chill\ActivityBundle\Export\Filter; use Chill\ActivityBundle\Export\Declarations; use Chill\MainBundle\Export\FilterInterface; @@ -38,7 +38,7 @@ class ByCreatorFilter implements FilterInterface public function applyOn(): string { - return Declarations::ACTIVITY_ACP; + return Declarations::ACTIVITY; } public function buildForm(FormBuilderInterface $builder) diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/EmergencyFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/EmergencyFilter.php similarity index 95% rename from src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/EmergencyFilter.php rename to src/Bundle/ChillActivityBundle/Export/Filter/EmergencyFilter.php index 51540b658..43090391e 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/EmergencyFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/EmergencyFilter.php @@ -9,7 +9,7 @@ declare(strict_types=1); * the LICENSE file that was distributed with this source code. */ -namespace Chill\ActivityBundle\Export\Filter\ACPFilters; +namespace Chill\ActivityBundle\Export\Filter; use Chill\ActivityBundle\Export\Declarations; use Chill\MainBundle\Export\FilterInterface; @@ -53,7 +53,7 @@ class EmergencyFilter implements FilterInterface public function applyOn(): string { - return Declarations::ACTIVITY_ACP; + return Declarations::ACTIVITY; } public function buildForm(FormBuilderInterface $builder) diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/LocationFilter.php similarity index 94% rename from src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationFilter.php rename to src/Bundle/ChillActivityBundle/Export/Filter/LocationFilter.php index 312f3a6a0..f5c7b4d16 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/LocationFilter.php @@ -9,7 +9,7 @@ declare(strict_types=1); * the LICENSE file that was distributed with this source code. */ -namespace Chill\ActivityBundle\Export\Filter\ACPFilters; +namespace Chill\ActivityBundle\Export\Filter; use Chill\ActivityBundle\Export\Declarations; use Chill\MainBundle\Export\FilterInterface; @@ -36,7 +36,7 @@ class LocationFilter implements FilterInterface public function applyOn(): string { - return Declarations::ACTIVITY_ACP; + return Declarations::ACTIVITY; } public function buildForm(FormBuilderInterface $builder) diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationTypeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/LocationTypeFilter.php similarity index 95% rename from src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationTypeFilter.php rename to src/Bundle/ChillActivityBundle/Export/Filter/LocationTypeFilter.php index 496e1414b..8395ff579 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationTypeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/LocationTypeFilter.php @@ -9,7 +9,7 @@ declare(strict_types=1); * the LICENSE file that was distributed with this source code. */ -namespace Chill\ActivityBundle\Export\Filter\ACPFilters; +namespace Chill\ActivityBundle\Export\Filter; use Chill\ActivityBundle\Export\Declarations; use Chill\MainBundle\Export\FilterInterface; @@ -50,7 +50,7 @@ class LocationTypeFilter implements FilterInterface public function applyOn(): string { - return Declarations::ACTIVITY_ACP; + return Declarations::ACTIVITY; } public function buildForm(FormBuilderInterface $builder) diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/SentReceivedFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/SentReceivedFilter.php similarity index 95% rename from src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/SentReceivedFilter.php rename to src/Bundle/ChillActivityBundle/Export/Filter/SentReceivedFilter.php index df65a3a07..c93158f2f 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/SentReceivedFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/SentReceivedFilter.php @@ -9,7 +9,7 @@ declare(strict_types=1); * the LICENSE file that was distributed with this source code. */ -namespace Chill\ActivityBundle\Export\Filter\ACPFilters; +namespace Chill\ActivityBundle\Export\Filter; use Chill\ActivityBundle\Entity\Activity; use Chill\ActivityBundle\Export\Declarations; @@ -54,7 +54,7 @@ class SentReceivedFilter implements FilterInterface public function applyOn(): string { - return Declarations::ACTIVITY_ACP; + return Declarations::ACTIVITY; } public function buildForm(FormBuilderInterface $builder) diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/UserFilter.php similarity index 95% rename from src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserFilter.php rename to src/Bundle/ChillActivityBundle/Export/Filter/UserFilter.php index 4af26c1f5..5fd08020e 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/UserFilter.php @@ -9,7 +9,7 @@ declare(strict_types=1); * the LICENSE file that was distributed with this source code. */ -namespace Chill\ActivityBundle\Export\Filter\ACPFilters; +namespace Chill\ActivityBundle\Export\Filter; use Chill\ActivityBundle\Export\Declarations; use Chill\MainBundle\Export\FilterInterface; @@ -46,7 +46,7 @@ class UserFilter implements FilterInterface public function applyOn(): string { - return Declarations::ACTIVITY_ACP; + return Declarations::ACTIVITY; } public function buildForm(FormBuilderInterface $builder) diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserScopeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/UserScopeFilter.php similarity index 96% rename from src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserScopeFilter.php rename to src/Bundle/ChillActivityBundle/Export/Filter/UserScopeFilter.php index 3b6e69cd8..a887eb201 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserScopeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/UserScopeFilter.php @@ -9,7 +9,7 @@ declare(strict_types=1); * the LICENSE file that was distributed with this source code. */ -namespace Chill\ActivityBundle\Export\Filter\ACPFilters; +namespace Chill\ActivityBundle\Export\Filter; use Chill\ActivityBundle\Export\Declarations; use Chill\MainBundle\Entity\Scope; @@ -52,7 +52,7 @@ class UserScopeFilter implements FilterInterface public function applyOn(): string { - return Declarations::ACTIVITY_ACP; + return Declarations::ACTIVITY; } public function buildForm(FormBuilderInterface $builder) diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/BySocialActionAggregatorTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/BySocialActionAggregatorTest.php index 657c9441e..e7d3f50ab 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/BySocialActionAggregatorTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/BySocialActionAggregatorTest.php @@ -12,7 +12,7 @@ declare(strict_types=1); namespace Chill\ActivityBundle\Tests\Export\Aggregator\ACPAggregators; use Chill\ActivityBundle\Entity\Activity; -use Chill\ActivityBundle\Export\Aggregator\ACPAggregators\BySocialActionAggregator; +use Chill\ActivityBundle\Export\Aggregator\BySocialActionAggregator; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; use Doctrine\ORM\EntityManagerInterface; diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/BySocialIssueAggregatorTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/BySocialIssueAggregatorTest.php index 86c999cf3..471c6ad21 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/BySocialIssueAggregatorTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/BySocialIssueAggregatorTest.php @@ -12,7 +12,7 @@ declare(strict_types=1); namespace Chill\ActivityBundle\Tests\Export\Aggregator\ACPAggregators; use Chill\ActivityBundle\Entity\Activity; -use Chill\ActivityBundle\Export\Aggregator\ACPAggregators\BySocialIssueAggregator; +use Chill\ActivityBundle\Export\Aggregator\BySocialIssueAggregator; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; use Doctrine\ORM\EntityManagerInterface; diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/ByThirdpartyAggregatorTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ByThirdpartyAggregatorTest.php similarity index 82% rename from src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/ByThirdpartyAggregatorTest.php rename to src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ByThirdpartyAggregatorTest.php index 4711733ef..e3bec0c06 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/ByThirdpartyAggregatorTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ByThirdpartyAggregatorTest.php @@ -9,10 +9,10 @@ declare(strict_types=1); * the LICENSE file that was distributed with this source code. */ -namespace Chill\ActivityBundle\Tests\Export\Aggregator\ACPAggregators; +namespace Chill\ActivityBundle\Tests\Export\Aggregator; use Chill\ActivityBundle\Entity\Activity; -use Chill\ActivityBundle\Export\Aggregator\ACPAggregators\ByThirdpartyAggregator; +use Chill\ActivityBundle\Export\Aggregator\ByThirdpartyAggregator; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; use Doctrine\ORM\EntityManagerInterface; @@ -28,7 +28,7 @@ final class ByThirdpartyAggregatorTest extends AbstractAggregatorTest { self::bootKernel(); - $this->aggregator = self::$container->get('chill.activity.export.bythirdparty_aggregator'); + $this->aggregator = self::$container->get(ByThirdpartyAggregator::class); } public function getAggregator() diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/ByUserAggregatorTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ByUserAggregatorTest.php similarity index 89% rename from src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/ByUserAggregatorTest.php rename to src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ByUserAggregatorTest.php index 44a62e9f8..04a2d68bf 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/ByUserAggregatorTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ByUserAggregatorTest.php @@ -9,10 +9,10 @@ declare(strict_types=1); * the LICENSE file that was distributed with this source code. */ -namespace Chill\ActivityBundle\Tests\Export\Aggregator\ACPAggregators; +namespace Chill\ActivityBundle\Tests\Export\Aggregator; use Chill\ActivityBundle\Entity\Activity; -use Chill\ActivityBundle\Export\Aggregator\ACPAggregators\ByCreatorAggregator; +use Chill\ActivityBundle\Export\Aggregator\ByCreatorAggregator; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; use Doctrine\ORM\EntityManagerInterface; diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/UserScopeAggregatorTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/CreatorScopeAggregatorTest.php similarity index 84% rename from src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/UserScopeAggregatorTest.php rename to src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/CreatorScopeAggregatorTest.php index 18f7f9080..ca4d0baa5 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/UserScopeAggregatorTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/CreatorScopeAggregatorTest.php @@ -9,10 +9,10 @@ declare(strict_types=1); * the LICENSE file that was distributed with this source code. */ -namespace Chill\ActivityBundle\Tests\Export\Aggregator\ACPAggregators; +namespace Chill\ActivityBundle\Tests\Export\Aggregator; use Chill\ActivityBundle\Entity\Activity; -use Chill\ActivityBundle\Export\Aggregator\ACPAggregators\CreatorScopeAggregator; +use Chill\ActivityBundle\Export\Aggregator\CreatorScopeAggregator; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; use Doctrine\ORM\EntityManagerInterface; @@ -20,7 +20,7 @@ use Doctrine\ORM\EntityManagerInterface; * @internal * @coversNothing */ -final class UserScopeAggregatorTest extends AbstractAggregatorTest +final class CreatorScopeAggregatorTest extends AbstractAggregatorTest { private CreatorScopeAggregator $aggregator; diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/DateAggregatorTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/DateAggregatorTest.php similarity index 84% rename from src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/DateAggregatorTest.php rename to src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/DateAggregatorTest.php index b39a501de..586edb86f 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/DateAggregatorTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/DateAggregatorTest.php @@ -9,10 +9,10 @@ declare(strict_types=1); * the LICENSE file that was distributed with this source code. */ -namespace Chill\ActivityBundle\Tests\Export\Aggregator\ACPAggregators; +namespace Chill\ActivityBundle\Tests\Export\Aggregator; use Chill\ActivityBundle\Entity\Activity; -use Chill\ActivityBundle\Export\Aggregator\ACPAggregators\DateAggregator; +use Chill\ActivityBundle\Export\Aggregator\DateAggregator; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; use Doctrine\ORM\EntityManagerInterface; @@ -28,7 +28,7 @@ final class DateAggregatorTest extends AbstractAggregatorTest { self::bootKernel(); - $this->aggregator = self::$container->get('chill.activity.export.date_aggregator'); + $this->aggregator = self::$container->get(DateAggregator::class); } public function getAggregator() diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/LocationTypeAggregatorTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/LocationTypeAggregatorTest.php similarity index 82% rename from src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/LocationTypeAggregatorTest.php rename to src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/LocationTypeAggregatorTest.php index b26008cf9..299f28b77 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/LocationTypeAggregatorTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/LocationTypeAggregatorTest.php @@ -9,10 +9,10 @@ declare(strict_types=1); * the LICENSE file that was distributed with this source code. */ -namespace Chill\ActivityBundle\Tests\Export\Aggregator\ACPAggregators; +namespace Chill\ActivityBundle\Tests\Export\Aggregator; use Chill\ActivityBundle\Entity\Activity; -use Chill\ActivityBundle\Export\Aggregator\ACPAggregators\LocationTypeAggregator; +use Chill\ActivityBundle\Export\Aggregator\LocationTypeAggregator; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; use Doctrine\ORM\EntityManagerInterface; @@ -28,7 +28,7 @@ final class LocationTypeAggregatorTest extends AbstractAggregatorTest { self::bootKernel(); - $this->aggregator = self::$container->get('chill.activity.export.locationtype_aggregator'); + $this->aggregator = self::$container->get(LocationTypeAggregator::class); } public function getAggregator() diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/ActivityTypeFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/ActivityTypeFilterTest.php index f5ca3d67d..92257f6ce 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/ActivityTypeFilterTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/ActivityTypeFilterTest.php @@ -13,9 +13,10 @@ namespace Chill\ActivityBundle\Tests\Export\Filter\ACPFilters; use Chill\ActivityBundle\Entity\Activity; use Chill\ActivityBundle\Entity\ActivityType; -use Chill\ActivityBundle\Export\Filter\ACPFilters\ActivityTypeFilter; +use Chill\ActivityBundle\Export\Filter\ActivityTypeFilter; use Chill\MainBundle\Test\Export\AbstractFilterTest; use Chill\PersonBundle\Entity\AccompanyingPeriod; +use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Query\Expr; @@ -25,13 +26,13 @@ use Doctrine\ORM\Query\Expr; */ final class ActivityTypeFilterTest extends AbstractFilterTest { - private ActivityTypeFilter $filter; + private \Chill\ActivityBundle\Export\Filter\ACPFilters\ActivityTypeFilter $filter; protected function setUp(): void { self::bootKernel(); - $this->filter = self::$container->get('chill.activity.export.filter_activitytype'); + $this->filter = self::$container->get(\Chill\ActivityBundle\Export\Filter\ACPFilters\ActivityTypeFilter::class); } public function getFilter() @@ -48,13 +49,14 @@ final class ActivityTypeFilterTest extends AbstractFilterTest ->from(ActivityType::class, 'at') ->select('at') ->getQuery() + ->setMaxResults(1) ->getResult(); $data = []; foreach ($array as $a) { $data[] = [ - 'accepted_activitytypes' => $a, + 'accepted_activitytypes' => new ArrayCollection([$a]), ]; } diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/ByCreatorFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/ByCreatorFilterTest.php index cde4b9136..225949e2c 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/ByCreatorFilterTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/ByCreatorFilterTest.php @@ -12,8 +12,7 @@ declare(strict_types=1); namespace Chill\ActivityBundle\Tests\Export\Filter\ACPFilters; use Chill\ActivityBundle\Entity\Activity; -use Chill\ActivityBundle\Export\Filter\ACPFilters\ByCreatorFilter; -use Chill\ActivityBundle\Export\Filter\ACPFilters\UserFilter; +use Chill\ActivityBundle\Export\Filter\ByCreatorFilter; use Chill\MainBundle\Entity\User; use Chill\MainBundle\Test\Export\AbstractFilterTest; use Doctrine\ORM\EntityManagerInterface; diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/BySocialActionFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/BySocialActionFilterTest.php index 8a5abb5d0..48bd32455 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/BySocialActionFilterTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/BySocialActionFilterTest.php @@ -12,7 +12,6 @@ declare(strict_types=1); namespace Chill\ActivityBundle\Tests\Export\Filter\ACPFilters; use Chill\ActivityBundle\Entity\Activity; -use Chill\ActivityBundle\Export\Filter\ACPFilters\BySocialActionFilter; use Chill\MainBundle\Test\Export\AbstractFilterTest; use Chill\PersonBundle\Entity\SocialWork\SocialAction; use Doctrine\Common\Collections\ArrayCollection; @@ -24,13 +23,13 @@ use Doctrine\ORM\EntityManagerInterface; */ final class BySocialActionFilterTest extends AbstractFilterTest { - private BySocialActionFilter $filter; + private \Chill\ActivityBundle\Export\Filter\ACPFilters\BySocialActionFilter $filter; protected function setUp(): void { self::bootKernel(); - $this->filter = self::$container->get('chill.activity.export.bysocialaction_filter'); + $this->filter = self::$container->get(\Chill\ActivityBundle\Export\Filter\ACPFilters\BySocialActionFilter::class); } public function getFilter() @@ -48,7 +47,6 @@ final class BySocialActionFilterTest extends AbstractFilterTest ->from(SocialAction::class, 'sa') ->select('sa') ->getQuery() - ->setMaxResults(4) ->getResult(); $data = []; diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/BySocialIssueFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/BySocialIssueFilterTest.php index 5f34a8f3b..ee2360a4e 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/BySocialIssueFilterTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/BySocialIssueFilterTest.php @@ -15,6 +15,7 @@ use Chill\ActivityBundle\Entity\Activity; use Chill\ActivityBundle\Export\Filter\ACPFilters\BySocialIssueFilter; use Chill\MainBundle\Test\Export\AbstractFilterTest; use Chill\PersonBundle\Entity\SocialWork\SocialIssue; +use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\EntityManagerInterface; /** @@ -29,7 +30,7 @@ final class BySocialIssueFilterTest extends AbstractFilterTest { self::bootKernel(); - $this->filter = self::$container->get('chill.activity.export.bysocialissue_filter'); + $this->filter = self::$container->get(BySocialIssueFilter::class); } public function getFilter() @@ -39,19 +40,21 @@ final class BySocialIssueFilterTest extends AbstractFilterTest public function getFormData(): array { + self::bootKernel(); $em = self::$container->get(EntityManagerInterface::class); $array = $em->createQueryBuilder() ->from(SocialIssue::class, 'si') ->select('si') ->getQuery() + ->setMaxResults(2) ->getResult(); $data = []; foreach ($array as $a) { $data[] = [ - 'accepted_socialissues' => $a, + 'accepted_socialissues' => new ArrayCollection([$a]), ]; } diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ActivityDateFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ActivityDateFilterTest.php index 1f5b7a3a8..88bcc9bb7 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ActivityDateFilterTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ActivityDateFilterTest.php @@ -30,7 +30,7 @@ final class ActivityDateFilterTest extends AbstractFilterTest { self::bootKernel(); - $this->filter = self::$container->get('chill.activity.export.date_filter'); + $this->filter = self::$container->get(ActivityDateFilter::class); } public function getFilter() diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ByCreatorFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ByCreatorFilterTest.php new file mode 100644 index 000000000..2a00bc2aa --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ByCreatorFilterTest.php @@ -0,0 +1,76 @@ +filter = self::$container->get(ByCreatorFilter::class); + } + + 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_users' => $a, + ]; + } + + return $data; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(activity.id)') + ->from(Activity::class, 'activity') + ->join('activity.users', 'actusers'), + ]; + } +} diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/EmergencyFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/EmergencyFilterTest.php similarity index 83% rename from src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/EmergencyFilterTest.php rename to src/Bundle/ChillActivityBundle/Tests/Export/Filter/EmergencyFilterTest.php index b3ba2cec1..22b109207 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/EmergencyFilterTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/EmergencyFilterTest.php @@ -9,10 +9,10 @@ declare(strict_types=1); * the LICENSE file that was distributed with this source code. */ -namespace Chill\ActivityBundle\Tests\Export\Filter\ACPFilters; +namespace Chill\ActivityBundle\Tests\Export\Filter; use Chill\ActivityBundle\Entity\Activity; -use Chill\ActivityBundle\Export\Filter\ACPFilters\EmergencyFilter; +use Chill\ActivityBundle\Export\Filter\EmergencyFilter; use Chill\MainBundle\Test\Export\AbstractFilterTest; use Doctrine\ORM\EntityManagerInterface; @@ -28,7 +28,7 @@ final class EmergencyFilterTest extends AbstractFilterTest { self::bootKernel(); - $this->filter = self::$container->get('chill.activity.export.emergency_filter'); + $this->filter = self::$container->get(EmergencyFilter::class); } public function getFilter() diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/LocationTypeFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/LocationTypeFilterTest.php similarity index 87% rename from src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/LocationTypeFilterTest.php rename to src/Bundle/ChillActivityBundle/Tests/Export/Filter/LocationTypeFilterTest.php index 7aa208da5..94537acb2 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/LocationTypeFilterTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/LocationTypeFilterTest.php @@ -9,10 +9,10 @@ declare(strict_types=1); * the LICENSE file that was distributed with this source code. */ -namespace Chill\ActivityBundle\Tests\Export\Filter\ACPFilters; +namespace Chill\ActivityBundle\Tests\Export\Filter; use Chill\ActivityBundle\Entity\Activity; -use Chill\ActivityBundle\Export\Filter\ACPFilters\LocationTypeFilter; +use Chill\ActivityBundle\Export\Filter\LocationTypeFilter; use Chill\MainBundle\Entity\LocationType; use Chill\MainBundle\Test\Export\AbstractFilterTest; use Doctrine\ORM\EntityManagerInterface; @@ -29,7 +29,7 @@ final class LocationTypeFilterTest extends AbstractFilterTest { self::bootKernel(); - $this->filter = self::$container->get('chill.activity.export.locationtype_filter'); + $this->filter = self::$container->get(LocationTypeFilter::class); } public function getFilter() diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/PersonFilters/PersonHavingActivityBetweenDateFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/PersonFilters/PersonHavingActivityBetweenDateFilterTest.php index 92d05f9cf..df14c2baf 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/PersonFilters/PersonHavingActivityBetweenDateFilterTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/PersonFilters/PersonHavingActivityBetweenDateFilterTest.php @@ -56,7 +56,7 @@ final class PersonHavingActivityBetweenDateFilterTest extends AbstractFilterTest $data[] = [ 'date_from' => DateTime::createFromFormat('Y-m-d', '2021-07-01'), 'date_to' => DateTime::createFromFormat('Y-m-d', '2022-07-01'), - 'reasons' => $a, + 'reasons' => [$a], ]; } @@ -74,7 +74,9 @@ final class PersonHavingActivityBetweenDateFilterTest extends AbstractFilterTest return [ $em->createQueryBuilder() ->select('count(activity.id)') - ->from(Activity::class, 'activity'), + ->from(Activity::class, 'activity') + ->join('activity.person', 'person') + , ]; } } diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/SentReceivedFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/SentReceivedFilterTest.php similarity index 84% rename from src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/SentReceivedFilterTest.php rename to src/Bundle/ChillActivityBundle/Tests/Export/Filter/SentReceivedFilterTest.php index 529c37864..2c87b00ce 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/SentReceivedFilterTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/SentReceivedFilterTest.php @@ -9,10 +9,10 @@ declare(strict_types=1); * the LICENSE file that was distributed with this source code. */ -namespace Chill\ActivityBundle\Tests\Export\Filter\ACPFilters; +namespace Chill\ActivityBundle\Tests\Export\Filter; use Chill\ActivityBundle\Entity\Activity; -use Chill\ActivityBundle\Export\Filter\ACPFilters\SentReceivedFilter; +use Chill\ActivityBundle\Export\Filter\SentReceivedFilter; use Chill\MainBundle\Test\Export\AbstractFilterTest; use Doctrine\ORM\EntityManagerInterface; @@ -28,7 +28,7 @@ final class SentReceivedFilterTest extends AbstractFilterTest { self::bootKernel(); - $this->filter = self::$container->get('chill.activity.export.sentreceived_filter'); + $this->filter = self::$container->get(SentReceivedFilter::class); } public function getFilter() diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/UserFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/UserFilterTest.php similarity index 87% rename from src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/UserFilterTest.php rename to src/Bundle/ChillActivityBundle/Tests/Export/Filter/UserFilterTest.php index de7e29241..d49739c7e 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/UserFilterTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/UserFilterTest.php @@ -9,10 +9,10 @@ declare(strict_types=1); * the LICENSE file that was distributed with this source code. */ -namespace Chill\ActivityBundle\Tests\Export\Filter\ACPFilters; +namespace Chill\ActivityBundle\Tests\Export\Filter; use Chill\ActivityBundle\Entity\Activity; -use Chill\ActivityBundle\Export\Filter\ACPFilters\UserFilter; +use Chill\ActivityBundle\Export\Filter\UserFilter; use Chill\MainBundle\Entity\User; use Chill\MainBundle\Test\Export\AbstractFilterTest; use Doctrine\ORM\EntityManagerInterface; @@ -29,7 +29,7 @@ final class UserFilterTest extends AbstractFilterTest { self::bootKernel(); - $this->filter = self::$container->get('chill.activity.export.user_filter'); + $this->filter = self::$container->get(UserFilter::class); } public function getFilter() diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/UserScopeFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/UserScopeFilterTest.php similarity index 87% rename from src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/UserScopeFilterTest.php rename to src/Bundle/ChillActivityBundle/Tests/Export/Filter/UserScopeFilterTest.php index 844293142..cc165c6ac 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/UserScopeFilterTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/UserScopeFilterTest.php @@ -9,10 +9,10 @@ declare(strict_types=1); * the LICENSE file that was distributed with this source code. */ -namespace Chill\ActivityBundle\Tests\Export\Filter\ACPFilters; +namespace Chill\ActivityBundle\Tests\Export\Filter; use Chill\ActivityBundle\Entity\Activity; -use Chill\ActivityBundle\Export\Filter\ACPFilters\UserScopeFilter; +use Chill\ActivityBundle\Export\Filter\UserScopeFilter; use Chill\MainBundle\Entity\Scope; use Chill\MainBundle\Test\Export\AbstractFilterTest; use Doctrine\ORM\EntityManagerInterface; @@ -29,7 +29,7 @@ final class UserScopeFilterTest extends AbstractFilterTest { self::bootKernel(); - $this->filter = self::$container->get('chill.activity.export.userscope_filter'); + $this->filter = self::$container->get(UserScopeFilter::class); } public function getFilter() diff --git a/src/Bundle/ChillActivityBundle/config/services/export.yaml b/src/Bundle/ChillActivityBundle/config/services/export.yaml index 5af2895e9..563ea7bf5 100644 --- a/src/Bundle/ChillActivityBundle/config/services/export.yaml +++ b/src/Bundle/ChillActivityBundle/config/services/export.yaml @@ -53,8 +53,7 @@ services: tags: - { name: chill.export_filter, alias: 'activity_type_filter' } - chill.activity.export.date_filter: - class: Chill\ActivityBundle\Export\Filter\ActivityDateFilter + Chill\ActivityBundle\Export\Filter\ActivityDateFilter: tags: - { name: chill.export_filter, alias: 'activity_date_filter' } @@ -74,52 +73,43 @@ services: name: chill.export_filter alias: 'activity_person_having_ac_bw_date_filter' - chill.activity.export.filter_activitytype: - class: Chill\ActivityBundle\Export\Filter\ACPFilters\ActivityTypeFilter + Chill\ActivityBundle\Export\Filter\ACPFilters\ActivityTypeFilter: tags: - { name: chill.export_filter, alias: 'accompanyingcourse_activitytype_filter' } - chill.activity.export.location_filter: - class: Chill\ActivityBundle\Export\Filter\ACPFilters\LocationFilter + Chill\ActivityBundle\Export\Filter\LocationFilter: tags: - { name: chill.export_filter, alias: 'activity_location_filter' } - chill.activity.export.locationtype_filter: - class: Chill\ActivityBundle\Export\Filter\ACPFilters\LocationTypeFilter + Chill\ActivityBundle\Export\Filter\LocationTypeFilter: tags: - { name: chill.export_filter, alias: 'activity_locationtype_filter' } - Chill\ActivityBundle\Export\Filter\ACPFilters\ByCreatorFilter: + Chill\ActivityBundle\Export\Filter\ByCreatorFilter: tags: - { name: chill.export_filter, alias: 'activity_bycreator_filter' } - chill.activity.export.emergency_filter: - class: Chill\ActivityBundle\Export\Filter\ACPFilters\EmergencyFilter + Chill\ActivityBundle\Export\Filter\EmergencyFilter: tags: - { name: chill.export_filter, alias: 'activity_emergency_filter' } - chill.activity.export.sentreceived_filter: - class: Chill\ActivityBundle\Export\Filter\ACPFilters\SentReceivedFilter + Chill\ActivityBundle\Export\Filter\SentReceivedFilter: tags: - { name: chill.export_filter, alias: 'activity_sentreceived_filter' } - chill.activity.export.bysocialaction_filter: - class: Chill\ActivityBundle\Export\Filter\ACPFilters\BySocialActionFilter + Chill\ActivityBundle\Export\Filter\ACPFilters\BySocialActionFilter: tags: - { name: chill.export_filter, alias: 'activity_bysocialaction_filter' } - chill.activity.export.bysocialissue_filter: - class: Chill\ActivityBundle\Export\Filter\ACPFilters\BySocialIssueFilter + Chill\ActivityBundle\Export\Filter\ACPFilters\BySocialIssueFilter: tags: - { name: chill.export_filter, alias: 'activity_bysocialissue_filter' } - chill.activity.export.user_filter: # Creator (M2O) - class: Chill\ActivityBundle\Export\Filter\ACPFilters\UserFilter + Chill\ActivityBundle\Export\Filter\UserFilter: tags: - { name: chill.export_filter, alias: 'activity_user_filter' } - chill.activity.export.userscope_filter: - class: Chill\ActivityBundle\Export\Filter\ACPFilters\UserScopeFilter + Chill\ActivityBundle\Export\Filter\UserScopeFilter: tags: - { name: chill.export_filter, alias: 'activity_userscope_filter' } @@ -157,22 +147,19 @@ services: tags: - { name: chill.export_aggregator, alias: activity_user_aggregator } - chill.activity.export.locationtype_aggregator: - class: Chill\ActivityBundle\Export\Aggregator\ACPAggregators\LocationTypeAggregator + Chill\ActivityBundle\Export\Aggregator\LocationTypeAggregator: tags: - { name: chill.export_aggregator, alias: activity_locationtype_aggregator } - chill.activity.export.date_aggregator: - class: Chill\ActivityBundle\Export\Aggregator\ACPAggregators\DateAggregator + Chill\ActivityBundle\Export\Aggregator\DateAggregator: tags: - { name: chill.export_aggregator, alias: activity_date_aggregator } - Chill\ActivityBundle\Export\Aggregator\ACPAggregators\ByCreatorAggregator: + Chill\ActivityBundle\Export\Aggregator\ByCreatorAggregator: tags: - { name: chill.export_aggregator, alias: activity_by_creator_aggregator } - chill.activity.export.bythirdparty_aggregator: - class: Chill\ActivityBundle\Export\Aggregator\ACPAggregators\ByThirdpartyAggregator + Chill\ActivityBundle\Export\Aggregator\ByThirdpartyAggregator: tags: - { name: chill.export_aggregator, alias: activity_bythirdparty_aggregator } @@ -186,7 +173,7 @@ services: tags: - { name: chill.export_aggregator, alias: activity_bysocialissue_aggregator } - Chill\ActivityBundle\Export\Aggregator\ACPAggregators\CreatorScopeAggregator: + Chill\ActivityBundle\Export\Aggregator\CreatorScopeAggregator: tags: - { name: chill.export_aggregator, alias: activity_creator_scope_aggregator } diff --git a/src/Bundle/ChillActivityBundle/translations/messages.fr.yml b/src/Bundle/ChillActivityBundle/translations/messages.fr.yml index 4ddad2292..ef2494f57 100644 --- a/src/Bundle/ChillActivityBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillActivityBundle/translations/messages.fr.yml @@ -377,6 +377,8 @@ export: Title: Filtre les parcours ayant reçu un échange entre deux dates Receiving an activity after: Ayant reçu un échange après le Receiving an activity before: Ayant reçu un échange avant le + acp_by_activity_type: + 'acp_containing_at_least_one_%activitytypes%': 'Parcours filtrés: uniquement ceux qui contiennent au moins un échange d''un des types suivants: %activitytypes%' aggregator: diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/AvgAsideActivityDuration.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/AvgAsideActivityDuration.php index fc0026618..b3c3f0eb2 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/AvgAsideActivityDuration.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/AvgAsideActivityDuration.php @@ -26,6 +26,7 @@ class AvgAsideActivityDuration implements ExportInterface, GroupedExportInterfac public function __construct(private readonly AsideActivityRepository $repository) {} public function buildForm(FormBuilderInterface $builder) {} + public function getFormDefaultData(): array { return []; diff --git a/src/Bundle/ChillDocStoreBundle/Entity/AccompanyingCourseDocument.php b/src/Bundle/ChillDocStoreBundle/Entity/AccompanyingCourseDocument.php index d0613f9a3..9da172b13 100644 --- a/src/Bundle/ChillDocStoreBundle/Entity/AccompanyingCourseDocument.php +++ b/src/Bundle/ChillDocStoreBundle/Entity/AccompanyingCourseDocument.php @@ -28,6 +28,13 @@ class AccompanyingCourseDocument extends Document implements HasScopesInterface, */ private ?AccompanyingPeriod $course = null; + /** + * @ORM\Id + * @ORM\GeneratedValue + * @ORM\Column(type="integer") + */ + private ?int $id = null; + public function getCenters(): ?iterable { return $this->course->getCenters(); @@ -38,6 +45,11 @@ class AccompanyingCourseDocument extends Document implements HasScopesInterface, return $this->course; } + public function getId() + { + return $this->id; + } + public function getScopes(): iterable { if (null === $this->course) { @@ -53,4 +65,5 @@ class AccompanyingCourseDocument extends Document implements HasScopesInterface, return $this; } + } diff --git a/src/Bundle/ChillDocStoreBundle/Entity/Document.php b/src/Bundle/ChillDocStoreBundle/Entity/Document.php index c06ef15bc..58adfe17a 100644 --- a/src/Bundle/ChillDocStoreBundle/Entity/Document.php +++ b/src/Bundle/ChillDocStoreBundle/Entity/Document.php @@ -49,13 +49,6 @@ class Document implements TrackCreationInterface, TrackUpdateInterface */ private string $description = ''; - /** - * @ORM\Id - * @ORM\GeneratedValue - * @ORM\Column(type="integer") - */ - private ?int $id = null; - /** * @ORM\ManyToOne( * targetEntity="Chill\DocStoreBundle\Entity\StoredObject", @@ -101,11 +94,6 @@ class Document implements TrackCreationInterface, TrackUpdateInterface return $this->description; } - public function getId() - { - return $this->id; - } - public function getObject(): ?StoredObject { return $this->object; diff --git a/src/Bundle/ChillDocStoreBundle/Entity/PersonDocument.php b/src/Bundle/ChillDocStoreBundle/Entity/PersonDocument.php index e646a5ed7..adc1eb75c 100644 --- a/src/Bundle/ChillDocStoreBundle/Entity/PersonDocument.php +++ b/src/Bundle/ChillDocStoreBundle/Entity/PersonDocument.php @@ -23,6 +23,13 @@ use Doctrine\ORM\Mapping as ORM; */ class PersonDocument extends Document implements HasCenterInterface, HasScopeInterface { + /** + * @ORM\Id + * @ORM\GeneratedValue + * @ORM\Column(type="integer") + */ + private ?int $id = null; + /** * @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\Person") */ @@ -40,6 +47,11 @@ class PersonDocument extends Document implements HasCenterInterface, HasScopeInt return $this->getPerson()->getCenter(); } + public function getId() + { + return $this->id; + } + public function getPerson(): Person { return $this->person; diff --git a/src/Bundle/ChillFamilyMembersBundle/ChillAMLIFamilyMembersBundle.php b/src/Bundle/ChillFamilyMembersBundle/ChillAMLIFamilyMembersBundle.php new file mode 100644 index 000000000..e69de29bb diff --git a/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php b/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php index 4b0a199c2..1b9778bed 100644 --- a/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php +++ b/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php @@ -474,7 +474,7 @@ class CRUDController extends AbstractController * 6. Launch rendering, the parameter is fetch using `getTemplateFor` * The parameters may be personnalized using `generateTemplateParameter`. * - * @param string $formClass + * @param class-string $formClass * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException */ protected function formEditAction(string $action, Request $request, mixed $id, ?string $formClass = null, array $formOptions = []): Response diff --git a/src/Bundle/ChillMainBundle/Controller/CenterController.php b/src/Bundle/ChillMainBundle/Controller/CenterController.php index c733dc653..8ae9c8a1c 100644 --- a/src/Bundle/ChillMainBundle/Controller/CenterController.php +++ b/src/Bundle/ChillMainBundle/Controller/CenterController.php @@ -11,177 +11,19 @@ declare(strict_types=1); namespace Chill\MainBundle\Controller; -use Chill\MainBundle\Entity\Center; -use Chill\MainBundle\Form\CenterType; -use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; -use Symfony\Component\Form\Extension\Core\Type\SubmitType; +use Chill\MainBundle\CRUD\Controller\CRUDController; +use Chill\MainBundle\Pagination\PaginatorInterface; use Symfony\Component\HttpFoundation\Request; /** * Class CenterController. */ -class CenterController extends AbstractController +class CenterController extends CRUDController { - /** - * Creates a new Center entity. - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/center/create", name="admin_center_create", methods={"POST"}) - */ - public function createAction(Request $request) + protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator) { - $center = new Center(); - $form = $this->createCreateForm($center); - $form->handleRequest($request); + $query->addOrderBy('e.name', 'ASC'); - if ($form->isSubmitted() && $form->isValid()) { - $em = $this->getDoctrine()->getManager(); - $em->persist($center); - $em->flush(); - - return $this->redirectToRoute('admin_center'); - } - - return $this->render('@ChillMain/Center/new.html.twig', [ - 'entity' => $center, - 'form' => $form->createView(), - ]); - } - - /** - * Displays a form to edit an existing Center entity. - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/center/{id}/edit", name="admin_center_edit") - */ - public function editAction(mixed $id) - { - $em = $this->getDoctrine()->getManager(); - - $center = $em->getRepository(\Chill\MainBundle\Entity\Center::class)->find($id); - - if (!$center) { - throw $this->createNotFoundException('Unable to find Center entity.'); - } - - $editForm = $this->createEditForm($center); - - return $this->render('@ChillMain/Center/edit.html.twig', [ - 'entity' => $center, - 'edit_form' => $editForm->createView(), - ]); - } - - /** - * Lists all Center entities. - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/center/", name="admin_center") - */ - public function indexAction() - { - $em = $this->getDoctrine()->getManager(); - - $entities = $em->getRepository(\Chill\MainBundle\Entity\Center::class)->findAll(); - - usort($entities, fn (Center $a, Center $b) => $a->getName() <=> $b->getName()); - - return $this->render('@ChillMain/Center/index.html.twig', [ - 'entities' => $entities, - ]); - } - - /** - * Displays a form to create a new Center entity. - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/center/new", name="admin_center_new") - */ - public function newAction() - { - $center = new Center(); - $form = $this->createCreateForm($center); - - return $this->render('@ChillMain/Center/new.html.twig', [ - 'entity' => $center, - 'form' => $form->createView(), - ]); - } - - /** - * Finds and displays a Center entity. - */ - public function showAction(mixed $id) - { - $em = $this->getDoctrine()->getManager(); - - $center = $em->getRepository(\Chill\MainBundle\Entity\Center::class)->find($id); - - if (!$center) { - throw $this->createNotFoundException('Unable to find Center entity.'); - } - - return $this->render('@ChillMain/Center/show.html.twig', [ - 'entity' => $center, - ]); - } - - /** - * Edits an existing Center entity. - * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/center/{id}/update", name="admin_center_update", methods={"POST", "PUT"}) - */ - public function updateAction(Request $request, mixed $id) - { - $em = $this->getDoctrine()->getManager(); - - $center = $em->getRepository(\Chill\MainBundle\Entity\Center::class)->find($id); - - if (!$center) { - throw $this->createNotFoundException('Unable to find Center entity.'); - } - - $editForm = $this->createEditForm($center); - $editForm->handleRequest($request); - - if ($editForm->isSubmitted() && $editForm->isValid()) { - $em->flush(); - - return $this->redirectToRoute('admin_center_edit', ['id' => $id]); - } - - return $this->render('@ChillMain/Center/edit.html.twig', [ - 'entity' => $center, - 'edit_form' => $editForm->createView(), - ]); - } - - /** - * Creates a form to create a Center entity. - * - * @param Center $center The entity - * - * @return \Symfony\Component\Form\Form The form - */ - private function createCreateForm(Center $center) - { - $form = $this->createForm(CenterType::class, $center, [ - 'action' => $this->generateUrl('admin_center_create'), - 'method' => 'POST', - ]); - - $form->add('submit', SubmitType::class, ['label' => 'Create']); - - return $form; - } - - /** - * Creates a form to edit a Center entity. - * - * @param Center $center The entity - * - * @return \Symfony\Component\Form\Form The form - */ - private function createEditForm(Center $center) - { - $form = $this->createForm(CenterType::class, $center, [ - 'action' => $this->generateUrl('admin_center_update', ['id' => $center->getId()]), - 'method' => 'PUT', - ]); - - $form->add('submit', SubmitType::class, ['label' => 'Update']); - - return $form; + return parent::orderQuery($action, $query, $request, $paginator); } } diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php index dd74b2c09..6760a798f 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php @@ -12,6 +12,7 @@ declare(strict_types=1); namespace Chill\MainBundle\DependencyInjection; use Chill\MainBundle\Controller\AddressApiController; +use Chill\MainBundle\Controller\CenterController; use Chill\MainBundle\Controller\CivilityApiController; use Chill\MainBundle\Controller\CivilityController; use Chill\MainBundle\Controller\CountryController; @@ -44,6 +45,7 @@ use Chill\MainBundle\Doctrine\DQL\Unaccent; use Chill\MainBundle\Doctrine\ORM\Hydration\FlatHierarchyEntityHydrator; use Chill\MainBundle\Doctrine\Type\NativeDateIntervalType; use Chill\MainBundle\Doctrine\Type\PointType; +use Chill\MainBundle\Entity\Center; use Chill\MainBundle\Entity\Civility; use Chill\MainBundle\Entity\Country; use Chill\MainBundle\Entity\GeographicalUnitLayer; @@ -53,6 +55,7 @@ use Chill\MainBundle\Entity\LocationType; use Chill\MainBundle\Entity\Regroupment; use Chill\MainBundle\Entity\User; use Chill\MainBundle\Entity\UserJob; +use Chill\MainBundle\Form\CenterType; use Chill\MainBundle\Form\CivilityType; use Chill\MainBundle\Form\CountryType; use Chill\MainBundle\Form\LanguageType; @@ -521,6 +524,27 @@ class ChillMainExtension extends Extension implements ], ], ], + [ + 'class' => Center::class, + 'name' => 'center', + 'base_path' => '/admin/center', + 'form_class' => CenterType::class, + 'controller' => CenterController::class, + 'actions' => [ + 'index' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillMain/Admin/Center/index.html.twig', + ], + 'new' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillMain/Admin/Center/new.html.twig', + ], + 'edit' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillMain/Admin/Center/edit.html.twig', + ], + ], + ], ], 'apis' => [ [ diff --git a/src/Bundle/ChillMainBundle/Entity/Center.php b/src/Bundle/ChillMainBundle/Entity/Center.php index 04695b113..b716d09fb 100644 --- a/src/Bundle/ChillMainBundle/Entity/Center.php +++ b/src/Bundle/ChillMainBundle/Entity/Center.php @@ -48,6 +48,11 @@ class Center implements HasCenterInterface, \Stringable */ private string $name = ''; + /** + * @ORM\Column(type="boolean") + */ + private bool $isActive = true; + /** * @var Collection * @ORM\ManyToMany(targetEntity=Regroupment::class, mappedBy="centers") @@ -121,6 +126,11 @@ class Center implements HasCenterInterface, \Stringable return $this->regroupments; } + public function getIsActive(): bool + { + return $this->isActive; + } + /** * @param $name * @@ -132,4 +142,11 @@ class Center implements HasCenterInterface, \Stringable return $this; } + + public function setIsActive(bool $isActive): self + { + $this->isActive = $isActive; + + return $this; + } } diff --git a/src/Bundle/ChillMainBundle/Form/CenterType.php b/src/Bundle/ChillMainBundle/Form/CenterType.php index ff758ca49..864d0a877 100644 --- a/src/Bundle/ChillMainBundle/Form/CenterType.php +++ b/src/Bundle/ChillMainBundle/Form/CenterType.php @@ -11,7 +11,10 @@ declare(strict_types=1); namespace Chill\MainBundle\Form; +use Chill\MainBundle\Entity\Center; +use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\Extension\Core\Type\CheckboxType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -21,24 +24,18 @@ class CenterType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { $builder - ->add('name', TextType::class); + ->add('name', TextType::class, [ + 'label' => 'Nom', + ]) + ->add('isActive', CheckboxType::class, [ + 'label' => 'Actif ?', + 'required' => false, + ]); } - /** - * @param OptionsResolverInterface $resolver - */ public function configureOptions(OptionsResolver $resolver) { - $resolver->setDefaults([ - 'data_class' => \Chill\MainBundle\Entity\Center::class, - ]); - } - - /** - * @return string - */ - public function getBlockPrefix() - { - return 'chill_mainbundle_center'; + $resolver + ->setDefault('class', Center::class); } } diff --git a/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php b/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php index 3d0981eee..36d82fffd 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php @@ -47,12 +47,14 @@ final class PickCenterType extends AbstractType $export->requiredRole() ); + $centersActive = array_filter($centers, fn (Center $c) => $c->getIsActive()); + // order alphabetically - usort($centers, fn (Center $a, Center $b) => $a->getCenter() <=> $b->getName()); + usort($centersActive, fn (Center $a, Center $b) => $a->getCenter() <=> $b->getName()); $builder->add('center', EntityType::class, [ 'class' => Center::class, - 'choices' => $centers, + 'choices' => $centersActive, 'label' => 'center', 'multiple' => true, 'expanded' => true, diff --git a/src/Bundle/ChillMainBundle/Form/Type/PickCenterType.php b/src/Bundle/ChillMainBundle/Form/Type/PickCenterType.php index c65e2b4cb..91bc8b2ab 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PickCenterType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PickCenterType.php @@ -47,6 +47,8 @@ class PickCenterType extends AbstractType { $centers = $this->getReachableCenters($options['role'], $options['scopes']); + $centersActive = array_filter($centers, fn (Center $c) => $c->getIsActive()); + if (count($centers) <= 1) { $multiple = $options['choice_options']['multiple'] ?? false; $builder->add('center', HiddenType::class); @@ -61,7 +63,7 @@ class PickCenterType extends AbstractType $options['choice_options'], [ 'class' => Center::class, - 'choices' => $centers, + 'choices' => $centersActive, ] ) ); diff --git a/src/Bundle/ChillMainBundle/Form/UserType.php b/src/Bundle/ChillMainBundle/Form/UserType.php index 474c5dabd..53f2949fc 100644 --- a/src/Bundle/ChillMainBundle/Form/UserType.php +++ b/src/Bundle/ChillMainBundle/Form/UserType.php @@ -57,6 +57,7 @@ class UserType extends AbstractType 'class' => Center::class, 'query_builder' => static function (EntityRepository $er) { $qb = $er->createQueryBuilder('c'); + $qb->where($qb->expr()->eq('c.isActive', 'true')); $qb->addOrderBy('c.name'); return $qb; diff --git a/src/Bundle/ChillMainBundle/Repository/CenterRepository.php b/src/Bundle/ChillMainBundle/Repository/CenterRepository.php index 1f498a666..0b507faa1 100644 --- a/src/Bundle/ChillMainBundle/Repository/CenterRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/CenterRepository.php @@ -29,9 +29,12 @@ final class CenterRepository implements CenterRepositoryInterface return $this->repository->find($id, $lockMode, $lockVersion); } + /** + * @return Center[] + */ public function findActive(): array { - return $this->findAll(); + return $this->repository->findBy(['isActive' => true], ['name' => 'ASC']); } /** diff --git a/src/Bundle/ChillMainBundle/Resources/views/Admin/Center/edit.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Admin/Center/edit.html.twig new file mode 100644 index 000000000..4d55c480c --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/views/Admin/Center/edit.html.twig @@ -0,0 +1,11 @@ +{% extends '@ChillMain/CRUD/Admin/index.html.twig' %} + +{% block title %} + {% include('@ChillMain/CRUD/_edit_title.html.twig') %} +{% endblock %} + +{% block admin_content %} + {% embed '@ChillMain/CRUD/_edit_content.html.twig' %} + {% block content_form_actions_save_and_show %}{% endblock %} + {% endembed %} +{% endblock admin_content %} diff --git a/src/Bundle/ChillMainBundle/Resources/views/Admin/Center/index.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Admin/Center/index.html.twig new file mode 100644 index 000000000..27c19c504 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/views/Admin/Center/index.html.twig @@ -0,0 +1,39 @@ +{% extends '@ChillMain/CRUD/Admin/index.html.twig' %} + +{% block admin_content %} + {% embed '@ChillMain/CRUD/_index.html.twig' %} + {% block table_entities_thead_tr %} + {{ 'Label'|trans }} + {{ 'Active'|trans }} +   + {% endblock %} + + {% block table_entities_tbody %} + {% for entity in entities %} + + {{ entity.name }} + + {% if entity.isActive %} + + {% else %} + + {% endif %} + + +
    +
  • + +
  • +
+ + + {% endfor %} + {% endblock %} + + {% block actions_before %} +
  • + {{'Back to the admin'|trans}} +
  • + {% endblock %} + {% endembed %} +{% endblock %} diff --git a/src/Bundle/ChillMainBundle/Resources/views/Admin/Center/new.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Admin/Center/new.html.twig new file mode 100644 index 000000000..7c204dddd --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/views/Admin/Center/new.html.twig @@ -0,0 +1,11 @@ +{% extends '@ChillMain/CRUD/Admin/index.html.twig' %} + +{% block title %} + {% include('@ChillMain/CRUD/_new_title.html.twig') %} +{% endblock %} + +{% block admin_content %} + {% embed '@ChillMain/CRUD/_new_content.html.twig' %} + {% block content_form_actions_save_and_show %}{% endblock %} + {% endembed %} +{% endblock admin_content %} diff --git a/src/Bundle/ChillMainBundle/Resources/views/Center/edit.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Center/edit.html.twig deleted file mode 100644 index 1894a1402..000000000 --- a/src/Bundle/ChillMainBundle/Resources/views/Center/edit.html.twig +++ /dev/null @@ -1,23 +0,0 @@ -{% extends '@ChillMain/Admin/layoutWithVerticalMenu.html.twig' %} - -{% block title %}{{ 'Center edit'|trans }}{% endblock %} - -{% block admin_content -%} -

    {{ 'Center edit'|trans }}

    - - {{ form_start(edit_form) }} - {{ form_row(edit_form.name) }} - - - - {{ form_end(edit_form) }} -{% endblock %} diff --git a/src/Bundle/ChillMainBundle/Resources/views/Center/index.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Center/index.html.twig deleted file mode 100644 index cb2da8a62..000000000 --- a/src/Bundle/ChillMainBundle/Resources/views/Center/index.html.twig +++ /dev/null @@ -1,50 +0,0 @@ -{% extends '@ChillMain/CRUD/Admin/index.html.twig' %} - -{% block title %}{{ 'Center list'|trans }}{% endblock %} - -{% block admin_content -%} - {% embed '@ChillMain/CRUD/_index.html.twig' %} - - {% block index_header %} -

    {{ 'Center list'|trans }}

    - {% endblock %} - - {% block filter_order %}{% endblock %} - - {% block table_entities_thead_tr %} - id - {{ 'Name'|trans }} - {{ 'Actions'|trans }} - {% endblock %} - - {% block table_entities_tbody %} - {% for entity in entities %} - - {{ entity.id }} - {{ entity.name }} - - - - - {% endfor %} - {% endblock %} - - {% block pagination %}{% endblock %} - - {% block list_actions %} - - {% endblock list_actions %} - - {% endembed %} -{% endblock %} diff --git a/src/Bundle/ChillMainBundle/Resources/views/Center/new.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Center/new.html.twig deleted file mode 100644 index cc64b37c2..000000000 --- a/src/Bundle/ChillMainBundle/Resources/views/Center/new.html.twig +++ /dev/null @@ -1,23 +0,0 @@ -{% extends '@ChillMain/Admin/layoutWithVerticalMenu.html.twig' %} - -{% block title %}{{ 'Center creation'|trans }}{% endblock %} - -{% block admin_content -%} -

    {{ 'Center creation'|trans }}

    - - {{ form_start(form) }} - {{ form_row(form.name) }} - - - - {{ form_end(form) }} -{% endblock %} diff --git a/src/Bundle/ChillMainBundle/Routing/MenuBuilder/AdminUserMenuBuilder.php b/src/Bundle/ChillMainBundle/Routing/MenuBuilder/AdminUserMenuBuilder.php index 4a2ad04ad..809733287 100644 --- a/src/Bundle/ChillMainBundle/Routing/MenuBuilder/AdminUserMenuBuilder.php +++ b/src/Bundle/ChillMainBundle/Routing/MenuBuilder/AdminUserMenuBuilder.php @@ -46,7 +46,7 @@ class AdminUserMenuBuilder implements LocalMenuBuilderInterface ]); $menu->addChild('Center list', [ - 'route' => 'admin_center', + 'route' => 'chill_crud_center_index', ])->setExtras(['order' => 1010]); $menu->addChild('Regroupements des centres', [ diff --git a/src/Bundle/ChillMainBundle/Serializer/Normalizer/CenterNormalizer.php b/src/Bundle/ChillMainBundle/Serializer/Normalizer/CenterNormalizer.php index d84c8c6dd..dacea7e23 100644 --- a/src/Bundle/ChillMainBundle/Serializer/Normalizer/CenterNormalizer.php +++ b/src/Bundle/ChillMainBundle/Serializer/Normalizer/CenterNormalizer.php @@ -58,6 +58,7 @@ class CenterNormalizer implements DenormalizerInterface, NormalizerInterface 'id' => $center->getId(), 'type' => 'center', 'name' => $center->getName(), + 'isActive' => $center->getIsActive() ]; } diff --git a/src/Bundle/ChillMainBundle/migrations/Version20230906134410.php b/src/Bundle/ChillMainBundle/migrations/Version20230906134410.php new file mode 100644 index 000000000..ac18c9c29 --- /dev/null +++ b/src/Bundle/ChillMainBundle/migrations/Version20230906134410.php @@ -0,0 +1,36 @@ +addSql('ALTER TABLE centers ADD isActive BOOLEAN DEFAULT true NOT NULL'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE centers DROP isActive'); + } +} diff --git a/src/Bundle/ChillMainBundle/translations/messages.fr.yml b/src/Bundle/ChillMainBundle/translations/messages.fr.yml index 6a6136a41..6cbb1fef4 100644 --- a/src/Bundle/ChillMainBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillMainBundle/translations/messages.fr.yml @@ -425,6 +425,12 @@ crud: add_new: Ajouter un regroupement title_new: Nouveau regroupement title_edit: Modifier un regroupement + center: + index: + title: Liste des centres + add_new: Ajouter un centre + title_new: Nouveau centre + title_edit: Modifier un centre No entities: Aucun élément diff --git a/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveAccompanyingPeriodParticipationHandler.php b/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveAccompanyingPeriodParticipationHandler.php new file mode 100644 index 000000000..1b4c07469 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveAccompanyingPeriodParticipationHandler.php @@ -0,0 +1,46 @@ +getId(), $from->getId(), $to->getId()); + + $deleteSql = sprintf(<<<'SQL' + DELETE FROM chill_person_accompanying_period_participation WHERE person_id = %d; + SQL, $from->getId()); + + return [$insertSql, $deleteSql]; + } +} diff --git a/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveCenterHistoryHandler.php b/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveCenterHistoryHandler.php new file mode 100644 index 000000000..3bf8da3d3 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveCenterHistoryHandler.php @@ -0,0 +1,73 @@ +centerHistoryRepository->findBy(['person' => $from]); + foreach ($centerHistoriesA as $ch) { + if ($oldestDateA === null || ($ch->getStartDate() < $oldestDateA)) { + $oldestDateA = $ch->getStartDate(); + $oldestCenterHistoryA = $ch; + } + } + + $centerHistoriesB = $this->centerHistoryRepository->findBy(['person' => $to]); + foreach ($centerHistoriesB as $ch) { + if ($oldestDateB === null || ($ch->getStartDate() < $oldestDateB)) { + $oldestDateB = $ch->getStartDate(); + $oldestCenterHistoryB = $ch; + } + } + + $sqlDelete = sprintf(<<<'SQL' + DELETE FROM chill_person_person_center_history WHERE person_id = %d; + SQL, $from->getId()); + + $sqlStatements = [$sqlDelete]; + + if ((null !== $oldestDateA && null !== $oldestDateB) && $oldestDateA <= $oldestDateB) { + + $sqlInsert = sprintf(<<<'SQL' + UPDATE chill_person_person_center_history SET startDate = '%s' WHERE id = %d; + SQL, $oldestDateA->format('Y-m-d'), $oldestCenterHistoryB->getId()); + + $sqlStatements = [$sqlInsert, $sqlDelete]; + } + + return $sqlStatements; + + } + +} diff --git a/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveHouseholdHandler.php b/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveHouseholdHandler.php new file mode 100644 index 000000000..d617e12ed --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveHouseholdHandler.php @@ -0,0 +1,47 @@ +getId(), $from->getId(), $to->getId()); + + $deleteSql = sprintf(<<<'SQL' + DELETE FROM chill_person_household_members WHERE person_id = %d; + SQL, $from->getId()); + + return [$sqlInsert, $deleteSql]; + } + +} diff --git a/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveRelationHandler.php b/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveRelationHandler.php new file mode 100644 index 000000000..2c2f68ca9 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveRelationHandler.php @@ -0,0 +1,47 @@ +getId(), $from->getId(), $to->getId(), $from->getId(), $from->getId(), $to->getId()); + + $deleteSql = [ + sprintf("DELETE FROM chill_person_relationships WHERE fromperson_id = %d", $from->getId()), + sprintf("DELETE FROM chill_person_relationships WHERE toperson_id = %d", $from->getId()) + ]; + + return [$insertSql, ...$deleteSql]; + } +} diff --git a/src/Bundle/ChillPersonBundle/Actions/Remove/PersonMove.php b/src/Bundle/ChillPersonBundle/Actions/Remove/PersonMove.php index 0166639fb..80fde1367 100644 --- a/src/Bundle/ChillPersonBundle/Actions/Remove/PersonMove.php +++ b/src/Bundle/ChillPersonBundle/Actions/Remove/PersonMove.php @@ -35,23 +35,11 @@ use function in_array; */ class PersonMove { - /** - * @var EntityManagerInterface - */ - protected $em; - - /** - * @var EventDispatcherInterface - */ - protected $eventDispatcher; - public function __construct( - EntityManagerInterface $em, - EventDispatcherInterface $eventDispatcher - ) { - $this->em = $em; - $this->eventDispatcher = $eventDispatcher; - } + private EntityManagerInterface $em, + private PersonMoveManager $personMoveManager, + private EventDispatcherInterface $eventDispatcher + ) {} /** * Return the sql used to move or delete entities associated to a person to @@ -88,9 +76,16 @@ class PersonMove } foreach ($metadata->getAssociationMappings() as $field => $mapping) { + + if ($this->personMoveManager->hasHandler($metadata->getName(), $field)) { + $sqls = array_merge($sqls, $this->personMoveManager->getSqls($metadata->getName(), $field, $from, $to)); + continue; + } + if (in_array($mapping['sourceEntity'], $this->getIgnoredEntities(), true)) { continue; } + if (Person::class === $mapping['targetEntity'] and true === $mapping['isOwningSide']) { if (in_array($mapping['sourceEntity'], $toDelete, true)) { $sql = $this->createDeleteSQL($metadata, $from, $field); @@ -100,26 +95,18 @@ class PersonMove $sql, ['to' => $to->getId(), 'original_action' => 'move'] ); - $this->eventDispatcher->dispatch($event, ActionEvent::DELETE); + $this->eventDispatcher->dispatch(ActionEvent::DELETE, $event); + $sqls = array_merge($sqls, $event->getPreSql(), [$event->getSqlStatement()], $event->getPostSql()); } else { - $sql = $this->createMoveSQL($metadata, $from, $to, $field); - $event = new ActionEvent( - $from->getId(), - $metadata->getName(), - $sql, - ['to' => $to->getId(), 'original_action' => 'move'] - ); - $this->eventDispatcher->dispatch($event, ActionEvent::MOVE); + $sqls = array_merge($sqls, $this->createMoveSQLs($metadata, $from, $to, $field)); } - - $sqls = array_merge($sqls, $event->getPreSql(), [$event->getSqlStatement()], $event->getPostSql()); } } } $personMetadata = $this->em->getClassMetadata(Person::class); $sqls[] = sprintf( - 'DELETE FROM %s WHERE id = %d', + 'DELETE FROM %s WHERE id = %d;', $this->getTableName($personMetadata), $from->getId() ); @@ -133,18 +120,24 @@ class PersonMove $conditions = []; - foreach ($mapping['joinColumns'] as $columns) { - $conditions[] = sprintf('%s = %d', $columns['name'], $from->getId()); + if (array_key_exists('joinTable', $mapping)) { + foreach ($mapping['joinTable']['joinColumns'] as $columns) { + $conditions[] = sprintf('%s = %d', $columns['referencedColumnName'], $from->getId()); + } + } elseif (array_key_exists('joinColumns', $mapping)) { + foreach ($mapping['joinColumns'] as $columns) { + $conditions[] = sprintf('%s = %d', $columns['name'], $from->getId()); + } } return sprintf( - 'DELETE FROM %s WHERE %s', + 'DELETE FROM %s WHERE %s;', $this->getTableName($metadata), implode(' AND ', $conditions) ); } - private function createMoveSQL(ClassMetadata $metadata, Person $from, Person $to, $field): string + private function createMoveSQLs($metadata, Person $from, Person $to, $field): array { $mapping = $metadata->getAssociationMapping($field); @@ -154,9 +147,29 @@ class PersonMove $tableName = ''; if (array_key_exists('joinTable', $mapping)) { + // there is a join_table: we have to find conflict $tableName = (null !== ($mapping['joinTable']['schema'] ?? null) ? $mapping['joinTable']['schema'] . '.' : '') . $mapping['joinTable']['name']; + $sqlInsert = sprintf( + "INSERT INTO %s (%s, %s) SELECT %d, %s FROM %s WHERE %s = %d ON CONFLICT DO NOTHING;", + $tableName, + $mapping['joinTable']['inverseJoinColumns'][0]['name'], // person_id + $mapping['joinTable']['joinColumns'][0]['name'], // something_else_id + $to->getId(), + $mapping['joinTable']['joinColumns'][0]['name'], // something_else_id + $tableName, + $mapping['joinTable']['inverseJoinColumns'][0]['name'], // person_id + $from->getId() + ); + + $deleteSql = sprintf( + "DELETE FROM %s WHERE %s = %d;", + $tableName, + $mapping['joinTable']['inverseJoinColumns'][0]['name'], // person_id + $from->getId() + ); + foreach ($mapping['joinTable']['inverseJoinColumns'] as $columns) { $sets[] = sprintf('%s = %d', $columns['name'], $to->getId()); } @@ -164,24 +177,29 @@ class PersonMove foreach ($mapping['joinTable']['inverseJoinColumns'] as $columns) { $conditions[] = sprintf('%s = %d', $columns['name'], $from->getId()); } - } elseif (array_key_exists('joinColumns', $mapping)) { + + return [ + $sqlInsert, $deleteSql + ]; + + } + if (array_key_exists('joinColumns', $mapping)) { $tableName = $this->getTableName($metadata); foreach ($mapping['joinColumns'] as $columns) { $sets[] = sprintf('%s = %d', $columns['name'], $to->getId()); } - foreach ($mapping['joinColumns'] as $columns) { $conditions[] = sprintf('%s = %d', $columns['name'], $from->getId()); } } - return sprintf( - 'UPDATE %s SET %s WHERE %s', + return [sprintf( + 'UPDATE %s SET %s WHERE %s;', $tableName, implode(' ', $sets), implode(' AND ', $conditions) - ); + )]; } /** @@ -191,9 +209,6 @@ class PersonMove private function getDeleteEntities(): array { return [ - Person\PersonCenterHistory::class, - HouseholdMember::class, - AccompanyingPeriodParticipation::class, AccompanyingPeriod\AccompanyingPeriodWork::class, Relationship::class ]; diff --git a/src/Bundle/ChillPersonBundle/Actions/Remove/PersonMoveManager.php b/src/Bundle/ChillPersonBundle/Actions/Remove/PersonMoveManager.php new file mode 100644 index 000000000..854b9e99e --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Actions/Remove/PersonMoveManager.php @@ -0,0 +1,55 @@ + + */ + private iterable $handlers, + ) {} + + /** + * @param class-string $className + * @param string $field + * @return bool + */ + public function hasHandler(string $className, string $field): bool + { + foreach ($this->handlers as $handler) { + if ($handler->supports($className, $field)) { + return true; + } + } + + return false; + } + + /** + * @param class-string $className + * @return array + */ + public function getSqls(string $className, string $field, Person $from, Person $to): array + { + foreach ($this->handlers as $handler) { + if ($handler->supports($className, $field)) { + return $handler->getSqls($className, $field, $from, $to); + } + } + return []; + } + +} diff --git a/src/Bundle/ChillPersonBundle/Actions/Remove/PersonMoveSqlHandlerInterface.php b/src/Bundle/ChillPersonBundle/Actions/Remove/PersonMoveSqlHandlerInterface.php new file mode 100644 index 000000000..c1b47127d --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Actions/Remove/PersonMoveSqlHandlerInterface.php @@ -0,0 +1,28 @@ + + */ + public function getSqls(string $className, string $field, Person $from, Person $to): array; +} diff --git a/src/Bundle/ChillPersonBundle/ChillPersonBundle.php b/src/Bundle/ChillPersonBundle/ChillPersonBundle.php index 5f82be2ac..8a48cccba 100644 --- a/src/Bundle/ChillPersonBundle/ChillPersonBundle.php +++ b/src/Bundle/ChillPersonBundle/ChillPersonBundle.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\PersonBundle; +use Chill\PersonBundle\Actions\Remove\PersonMoveSqlHandlerInterface; use Chill\PersonBundle\DependencyInjection\CompilerPass\AccompanyingPeriodTimelineCompilerPass; use Chill\PersonBundle\Service\EntityInfo\AccompanyingPeriodInfoUnionQueryPartInterface; use Chill\PersonBundle\Widget\PersonListWidgetFactory; @@ -29,5 +30,7 @@ class ChillPersonBundle extends Bundle $container->addCompilerPass(new AccompanyingPeriodTimelineCompilerPass(), \Symfony\Component\DependencyInjection\Compiler\PassConfig::TYPE_BEFORE_OPTIMIZATION, 0); $container->registerForAutoconfiguration(AccompanyingPeriodInfoUnionQueryPartInterface::class) ->addTag('chill_person.accompanying_period_info_part'); + $container->registerForAutoconfiguration(PersonMoveSqlHandlerInterface::class) + ->addTag('chill_person.person_move_handler'); } } diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php b/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php index f7265537d..94f08d9ba 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php @@ -13,6 +13,7 @@ namespace Chill\PersonBundle\Controller; use Chill\MainBundle\CRUD\Controller\ApiController; use Chill\MainBundle\Entity\Address; +use Chill\MainBundle\Entity\Center; use Chill\PersonBundle\Config\ConfigPersonAltNamesHelper; use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation; use Chill\PersonBundle\Entity\Person; @@ -50,7 +51,7 @@ class PersonApiController extends ApiController ['showCenters' => $this->showCenters, 'centers' => $centers], Response::HTTP_OK, [], - ['gropus' => ['read']] + ['groups' => ['read']] ); } diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php b/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php index 9060b5f5b..4291a1a69 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php @@ -86,6 +86,7 @@ class PersonDuplicateController extends \Symfony\Bundle\FrameworkBundle\Controll $connection->beginTransaction(); foreach ($sqls as $sql) { + dump($sql); $connection->executeQuery($sql); } $connection->commit(); diff --git a/src/Bundle/ChillPersonBundle/Entity/Person.php b/src/Bundle/ChillPersonBundle/Entity/Person.php index fb307443c..832afb987 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person.php @@ -1595,6 +1595,15 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI return $this; } + public function addCenterHistory(PersonCenterHistory $newCenterHistory): self + { + if (!$this->centerHistory->contains($newCenterHistory)) { + $this->centerHistory[] = $newCenterHistory; + $newCenterHistory->setPerson($this); + } + return $this; + } + public function setCFData(?array $cFData): self { $this->cFData = $cFData; diff --git a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php index 4ace48639..5c9f1a9c4 100644 --- a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php +++ b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php @@ -225,7 +225,7 @@ class SocialIssue /** * @param array|SocialIssue[] $socialIssues */ - public static function getDescendantsWithThisForIssues(array $socialIssues): Collection + public static function getDescendantsWithThisForIssues(array|Collection $socialIssues): Collection { $unique = []; diff --git a/src/Bundle/ChillPersonBundle/Form/PersonFindManuallyDuplicateType.php b/src/Bundle/ChillPersonBundle/Form/PersonFindManuallyDuplicateType.php index b9dfad240..1d7697332 100644 --- a/src/Bundle/ChillPersonBundle/Form/PersonFindManuallyDuplicateType.php +++ b/src/Bundle/ChillPersonBundle/Form/PersonFindManuallyDuplicateType.php @@ -11,7 +11,7 @@ declare(strict_types=1); namespace Chill\PersonBundle\Form; -use Chill\PersonBundle\Form\Type\PickPersonType; +use Chill\PersonBundle\Form\Type\PickPersonDynamicType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\HiddenType; use Symfony\Component\Form\FormBuilderInterface; @@ -21,7 +21,7 @@ class PersonFindManuallyDuplicateType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { $builder - ->add('person', PickPersonType::class, [ + ->add('person', PickPersonDynamicType::class, [ 'label' => 'Find duplicate', 'mapped' => false, ]) diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php index 4193055fa..e1fbf6d58 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php @@ -66,11 +66,10 @@ final readonly class AccompanyingPeriodACLAwareRepository implements Accompanyin Join::WITH, 'COALESCE(IDENTITY(person_address.address), IDENTITY(location_history.addressLocation)) = address.id' ) - ->join('address.postcode', 'postcode') ->andWhere( - $qb->expr()->in('postcode.code', ':postal_codes') + $qb->expr()->in('address.postcode', ':postal_codes') ) - ->setParameter('postal_codes', array_map(fn (PostalCode $postalCode) => $postalCode->getCode(), $postalCodes)); + ->setParameter('postal_codes', $postalCodes); } return $qb; diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue index 16a76c780..46d78b77c 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue @@ -329,12 +329,13 @@ export default { if (this.action !== 'create') { this.loadData(); } else { - console.log('show centers', this.showCenters); + // console.log('show centers', this.showCenters); getCentersForPersonCreation() .then(params => { - this.config.centers = params.centers; + this.config.centers = params.centers.filter(c => c.isActive); this.showCenters = params.showCenters; - console.log('show centers inside', this.showCenters); + // console.log('centers', this.config.centers) + // console.log('show centers inside', this.showCenters); if (this.showCenters && this.config.centers.length === 1) { this.person.center = this.config.centers[0]; } diff --git a/src/Bundle/ChillPersonBundle/Resources/views/PersonDuplicate/_sidepane.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/PersonDuplicate/_sidepane.html.twig index 1e770062a..b8edcc437 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/PersonDuplicate/_sidepane.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/PersonDuplicate/_sidepane.html.twig @@ -4,7 +4,7 @@
  • {{ 'gender'|trans }}: {{ person.gender|trans }}
  • {{ 'maritalStatus'|trans }}: - {% if person.maritalStatus.name %}{{ person.maritalStatus.name|localize_translatable_string }}{% endif %}
  • + {% if person.maritalStatus %}{{ person.maritalStatus.name|localize_translatable_string }}{% endif %}
  • {{ 'birthdate'|trans }}: {% if person.birthdate is not null %}{{ person.birthdate|format_date('short') }}{% endif %}
  • {{ 'placeOfBirth'|trans }}: diff --git a/src/Bundle/ChillPersonBundle/Resources/views/PersonDuplicate/find_manually.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/PersonDuplicate/find_manually.html.twig index 8769ae6da..982690f00 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/PersonDuplicate/find_manually.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/PersonDuplicate/find_manually.html.twig @@ -8,9 +8,9 @@ {% block content %}
    - +

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

    - + {{ form_start(form) }} {{ form_rest(form) }} @@ -29,3 +29,11 @@
    {% endblock %} + +{% block js %} + {{ encore_entry_script_tags('mod_pickentity_type') }} +{% endblock %} + +{% block css %} + {{ encore_entry_link_tags('mod_pickentity_type') }} +{% endblock %} diff --git a/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/Workflow/WorkflowEventSubscriberTest.php b/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/Workflow/WorkflowEventSubscriberTest.php new file mode 100644 index 000000000..e69de29bb diff --git a/src/Bundle/ChillPersonBundle/Tests/Action/Remove/PersonMoveTest.php b/src/Bundle/ChillPersonBundle/Tests/Action/Remove/PersonMoveTest.php new file mode 100644 index 000000000..0b2201b37 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Action/Remove/PersonMoveTest.php @@ -0,0 +1,275 @@ + + */ + private static $entitiesToDelete = []; + + public function setUp(): void + { + self::bootKernel(); + $this->em = self::$container->get(EntityManagerInterface::class); + $this->personMoveManager = self::$container->get(PersonMoveManager::class); + $this->eventDispatcher = self::$container->get(EventDispatcherInterface::class); + $this->centerRepository = self::$container->get(CenterRepositoryInterface::class); + } + + public static function tearDownAfterClass(): void + { + self::bootKernel(); + $em = self::$container->get(EntityManagerInterface::class); + + foreach (self::$entitiesToDelete as [$class, $id]) { + $entity = $em->find($class, $id); + + if (null !== $entity) { + $em->remove($entity); + } + } + + $em->flush(); + } + + /** + * @dataProvider dataProviderMovePerson + */ + public function testMovePersonSimple(Person $personA, Person $personB, string $message): void + { + $move = new PersonMove($this->em, $this->personMoveManager, $this->eventDispatcher); + $sqls = $move->getSQL($personA, $personB); + $this->em->getConnection()->transactional(function (Connection $conn) use ($personA, $personB, $sqls) { + foreach ($sqls as $sql) { + $conn->executeStatement($sql); + } + }); + + $personsByIdOfA = $this->em->createQuery("SELECT p FROM " . Person::class . " p WHERE p.id = :id") + ->setParameter('id', $personA->getId()) + ->getResult(); + $personB = $this->em->find(Person::class, $personB->getId()); + + self::assertCount(0, $personsByIdOfA); + self::assertNotNull($personB?->getId(), $message); + } + + public function testMovePersonCenterHistory(): void + { + $personA = new Person(); + $personB = new Person(); + [$centerA, $centerB] = $this->centerRepository->findAll(); + + $this->em->persist($personA); + $this->em->persist($personB); + + $personCenterHistoryAFirst = (new Person\PersonCenterHistory())->setCenter($centerA) + ->setStartDate(new \DateTimeImmutable('2023-01-01')) + ->setEndDate(new \DateTimeImmutable('2023-06-30')); + $personCenterHistoryASecond = (new Person\PersonCenterHistory())->setCenter($centerB) + ->setStartDate(new \DateTimeImmutable('2023-06-30')) + ->setEndDate(new \DateTimeImmutable('2023-09-30')); + $personCenterHistoryBFirst = (new Person\PersonCenterHistory())->setCenter($centerA) + ->setStartDate(new \DateTimeImmutable('2023-03-01')) + ->setEndDate(new \DateTimeImmutable('2023-07-15')); + $personCenterHistoryBSecond = (new Person\PersonCenterHistory())->setCenter($centerB) + ->setStartDate(new \DateTimeImmutable('2023-07-15')) + ->setEndDate(new \DateTimeImmutable('2023-09-30')); + + $this->em->persist($personCenterHistoryAFirst); + $this->em->persist($personCenterHistoryASecond); + $this->em->persist($personCenterHistoryBFirst); + $this->em->persist($personCenterHistoryBSecond); + + $personA->addCenterHistory($personCenterHistoryAFirst); + $personA->addCenterHistory($personCenterHistoryASecond); + $personB->addCenterHistory($personCenterHistoryBFirst); + $personB->addCenterHistory($personCenterHistoryBSecond); + + $this->em->flush(); + $this->em->clear(); + + $move = new PersonMove($this->em, $this->personMoveManager, $this->eventDispatcher); + $sqls = $move->getSQL($personA, $personB); + $this->em->getConnection()->transactional(function (Connection $conn) use ($personA, $personB, $sqls) { + foreach ($sqls as $sql) { + $conn->executeStatement($sql); + } + }); + + $personsByIdOfA = $this->em->createQuery("SELECT p FROM " . Person::class . " p WHERE p.id = :id") + ->setParameter('id', $personA->getId()) + ->getResult(); + /** @var Person $personB */ + $personB = $this->em->find(Person::class, $personB->getId()); + $message = 'Move persons with overlapping center histories'; + + $this->em->refresh($personB); + + self::assertCount(0, $personsByIdOfA); + self::assertNotNull($personB?->getId(), $message); + + $centerHistoriesB = $personB->getCenterHistory(); + $oldestDate = new \DateTimeImmutable('2023-01-01'); + + $this->em->refresh($centerHistoriesB->first()); + + self::assertCount(2, $centerHistoriesB); + self::assertEquals($oldestDate, $centerHistoriesB->first()->getStartDate()); + + self::$entitiesToDelete[] = [Person::class, $personA]; + self::$entitiesToDelete[] = [Person::class, $personB]; + self::$entitiesToDelete[] = [Person\PersonCenterHistory::class, $personCenterHistoryAFirst]; + self::$entitiesToDelete[] = [Person\PersonCenterHistory::class, $personCenterHistoryASecond]; + self::$entitiesToDelete[] = [Person\PersonCenterHistory::class, $personCenterHistoryBFirst]; + self::$entitiesToDelete[] = [Person\PersonCenterHistory::class, $personCenterHistoryBSecond]; + } + + public function dataProviderMovePerson(): iterable + { + $this->setUp(); + + $personA = new Person(); + $personB = new Person(); + + $this->em->persist($personA); + $this->em->persist($personB); + + self::$entitiesToDelete[] = [Person::class, $personA]; + self::$entitiesToDelete[] = [Person::class, $personB]; + + yield [$personA, $personB, "move 2 people without any associated data"]; + + $personA = new Person(); + $personB = new Person(); + + $activity = new Activity(); + $activity->setDate(new \DateTime('today')); + $activity->addPerson($personA); + $activity->addPerson($personB); + + $this->em->persist($personA); + $this->em->persist($personB); + $this->em->persist($activity); + + self::$entitiesToDelete[] = [Person::class, $personA]; + self::$entitiesToDelete[] = [Person::class, $personB]; + self::$entitiesToDelete[] = [Activity::class, $activity]; + + yield [$personA, $personB, "move 2 people having an activity"]; + + $personA = new Person(); + $personB = new Person(); + $household = new Household(); + $household->addMember( + $memberA = (new HouseholdMember())->setPerson($personA)->setShareHousehold(true) + ->setStartDate(new \DateTimeImmutable('2023-01-01')) + ); + $household->addMember( + $memberB = (new HouseholdMember())->setPerson($personB)->setShareHousehold(true) + ->setStartDate(new \DateTimeImmutable('2023-01-01')) + ); + + $this->em->persist($personA); + $this->em->persist($personB); + $this->em->persist($household); + $this->em->persist($memberA); + $this->em->persist($memberB); + + self::$entitiesToDelete[] = [Person::class, $personA]; + self::$entitiesToDelete[] = [Person::class, $personB]; + self::$entitiesToDelete[] = [HouseholdMember::class, $memberA]; + self::$entitiesToDelete[] = [HouseholdMember::class, $memberB]; + self::$entitiesToDelete[] = [Household::class, $household]; + + yield [$personA, $personB, "move 2 people having the same household at the same time"]; + + $personA = new Person(); + $personB = new Person(); + $parcours = new AccompanyingPeriod(); + + $parcours->addPerson($personA); + $parcours->addPerson($personB); + + $this->em->persist($personA); + $this->em->persist($personB); + $this->em->persist($parcours); + + self::$entitiesToDelete[] = [Person::class, $personA]; + self::$entitiesToDelete[] = [Person::class, $personB]; + self::$entitiesToDelete[] = [AccompanyingPeriod::class, $parcours]; + + yield [$personA, $personB, "move 2 people participating to the same parcours"]; + + $personA = new Person(); + $personB = new Person(); + $relationship = new Relationship(); + $relation = new Relation(); + $user = (new User())->setUsername(uniqid())->setEmail(uniqid() . '@foo.com'); + + $relationship->setRelation($relation); + $relationship->setToPerson($personA); + $relationship->setFromPerson($personB); + $relationship->setReverse(false); + $relationship->setCreatedBy($user); + + $this->em->persist($personA); + $this->em->persist($personB); + $this->em->persist($relation); + $this->em->persist($user); + $this->em->persist($relationship); + + self::$entitiesToDelete[] = [Person::class, $personA]; + self::$entitiesToDelete[] = [Person::class, $personB]; + self::$entitiesToDelete[] = [Relation::class, $relation]; + self::$entitiesToDelete[] = [User::class, $user]; + self::$entitiesToDelete[] = [Relationship::class, $relationship]; + + yield [$personA, $personB, "move 2 people with a relationship"]; + + $this->em->flush(); + $this->em->clear(); + } +} diff --git a/src/Bundle/ChillPersonBundle/config/services/actions.yaml b/src/Bundle/ChillPersonBundle/config/services/actions.yaml index e92dbc62a..d6e2c80a5 100644 --- a/src/Bundle/ChillPersonBundle/config/services/actions.yaml +++ b/src/Bundle/ChillPersonBundle/config/services/actions.yaml @@ -1,5 +1,13 @@ services: - Chill\PersonBundle\Actions\Remove\PersonMove: + _defaults: + autowire: true + autoconfigure: true + + Chill\PersonBundle\Actions\Remove\PersonMove: ~ + + Chill\PersonBundle\Actions\Remove\PersonMoveManager: arguments: - $em: '@Doctrine\ORM\EntityManagerInterface' - $eventDispatcher: '@Symfony\Contracts\EventDispatcher\EventDispatcherInterface' \ No newline at end of file + $handlers: !tagged_iterator chill_person.person_move_handler + + Chill\PersonBundle\Actions\Remove\Handler\: + resource: '../../Actions/Remove/Handler' diff --git a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php index 7fc71b240..2881e695d 100644 --- a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php +++ b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php @@ -26,6 +26,7 @@ use Chill\TaskBundle\Event\TaskEvent; use Chill\TaskBundle\Event\UI\UIEvent; use Chill\TaskBundle\Form\SingleTaskType; use Chill\TaskBundle\Repository\SingleTaskAclAwareRepositoryInterface; +use Chill\TaskBundle\Repository\SingleTaskRepository; use Chill\TaskBundle\Repository\SingleTaskStateRepository; use Chill\TaskBundle\Security\Authorization\TaskVoter; use LogicException; @@ -57,7 +58,8 @@ final class SingleTaskController extends AbstractController private readonly TimelineBuilder $timelineBuilder, private readonly LoggerInterface $logger, private readonly FilterOrderHelperFactoryInterface $filterOrderHelperFactory, - private readonly SingleTaskStateRepository $singleTaskStateRepository + private readonly SingleTaskStateRepository $singleTaskStateRepository, + private readonly SingleTaskRepository $singleTaskRepository, ) {} /** @@ -267,7 +269,9 @@ final class SingleTaskController extends AbstractController ) { $this->denyAccessUnlessGranted(TaskVoter::SHOW, null); - $filterOrder = $this->buildFilterOrder(); + $showMissionTypeFilter = $this->singleTaskRepository->countByDistinctTypes() > 1; + + $filterOrder = $this->buildFilterOrder(true, $showMissionTypeFilter); $filteredUsers = $filterOrder->getUserPickerData('userPicker'); @@ -275,9 +279,15 @@ final class SingleTaskController extends AbstractController $filterOrder->getCheckboxData('status'), array_map(static fn ($i) => 'state_' . $i, $filterOrder->hasCheckboxData('states') ? $filterOrder->getCheckboxData('states') : []) ); + + if ($showMissionTypeFilter) { + $types = $filterOrder->getCheckboxData('missionTypePicker'); + } + $nb = $this->singleTaskAclAwareRepository->countByAllViewable( $filterOrder->getQueryString(), $flags, + $types ?? [], $filteredUsers ); $paginator = $this->paginatorFactory->create($nb); @@ -286,6 +296,7 @@ final class SingleTaskController extends AbstractController $tasks = $this->singleTaskAclAwareRepository->findByAllViewable( $filterOrder->getQueryString(), $flags, + $types ?? [], $filteredUsers, $paginator->getCurrentPageFirstItemNumber(), $paginator->getItemsPerPage(), @@ -631,7 +642,7 @@ final class SingleTaskController extends AbstractController return $form; } - private function buildFilterOrder($includeFilterByUser = true): FilterOrderHelper + private function buildFilterOrder($includeFilterByUser = true, $includeMissionType = false): FilterOrderHelper { $statuses = ['no-alert', 'warning', 'alert']; $statusTrans = [ @@ -639,6 +650,7 @@ final class SingleTaskController extends AbstractController 'Tasks near deadline', 'Tasks over deadline', ]; + $arrayOfTypes = []; $filterBuilder = $this->filterOrderHelperFactory ->create(self::class) @@ -658,6 +670,16 @@ final class SingleTaskController extends AbstractController ->addUserPicker('userPicker', 'Filter by user', ['multiple' => true, 'required' => false]); } + if ($includeMissionType) { + $filterBuilder->addCheckbox( + 'missionTypePicker', + array_map( + fn ($row) => $row['type'], + $this->singleTaskRepository->findAllTaskDistinctTypes() + ) + ); + } + return $filterBuilder->build(); } diff --git a/src/Bundle/ChillTaskBundle/Entity/Task/SingleTaskPlaceEvent.php b/src/Bundle/ChillTaskBundle/Entity/Task/SingleTaskPlaceEvent.php index 4cb7c013a..a2524c748 100644 --- a/src/Bundle/ChillTaskBundle/Entity/Task/SingleTaskPlaceEvent.php +++ b/src/Bundle/ChillTaskBundle/Entity/Task/SingleTaskPlaceEvent.php @@ -31,6 +31,15 @@ use Doctrine\ORM\Mapping as ORM; */ class SingleTaskPlaceEvent extends AbstractTaskPlaceEvent { + /** + * @var int + * + * @ORM\Column(name="id", type="integer") + * @ORM\Id + * @ORM\GeneratedValue(strategy="AUTO") + */ + private ?int $id = null; + /** * @var SingleTask * @ORM\ManyToOne( @@ -51,4 +60,14 @@ class SingleTaskPlaceEvent extends AbstractTaskPlaceEvent return $this; } + + /** + * Get id. + * + * @return int + */ + public function getId() + { + return $this->id; + } } diff --git a/src/Bundle/ChillTaskBundle/Repository/SingleTaskAclAwareRepository.php b/src/Bundle/ChillTaskBundle/Repository/SingleTaskAclAwareRepository.php index cc0dd90c8..4c64bab0e 100644 --- a/src/Bundle/ChillTaskBundle/Repository/SingleTaskAclAwareRepository.php +++ b/src/Bundle/ChillTaskBundle/Repository/SingleTaskAclAwareRepository.php @@ -34,6 +34,7 @@ final readonly class SingleTaskAclAwareRepository implements SingleTaskAclAwareR public function buildBaseQuery( ?string $pattern = null, ?array $flags = [], + ?array $types = [], ?array $users = [] ): QueryBuilder { $qb = $this->em->createQueryBuilder(); @@ -59,8 +60,12 @@ final readonly class SingleTaskAclAwareRepository implements SingleTaskAclAwareR if ($orXUser->count() > 0) { $qb->andWhere($orXUser); } + } - return $qb; + if (null !== $types && count($types) > 0) { + $qb->andWhere($qb->expr()->in('t.type', ':types')); + + $qb->setParameter('types', $types); } if (null !== $flags && count($flags) > 0) { @@ -185,9 +190,10 @@ final readonly class SingleTaskAclAwareRepository implements SingleTaskAclAwareR public function countByAllViewable( ?string $pattern = null, ?array $flags = [], + ?array $types = [], ?array $users = [] ): int { - $qb = $this->buildBaseQuery($pattern, $flags, $users); + $qb = $this->buildBaseQuery($pattern, $flags, $types, $users); return $this ->addACLGlobal($qb) @@ -233,12 +239,13 @@ final readonly class SingleTaskAclAwareRepository implements SingleTaskAclAwareR public function findByAllViewable( ?string $pattern = null, ?array $flags = [], + ?array $types = [], ?array $users = [], ?int $start = 0, ?int $limit = 50, ?array $orderBy = [] ): array { - $qb = $this->buildBaseQuery($pattern, $flags, $users); + $qb = $this->buildBaseQuery($pattern, $flags, $types, $users); $qb = $this->addACLGlobal($qb); return $this->getResult($qb, $start, $limit, $orderBy); diff --git a/src/Bundle/ChillTaskBundle/Repository/SingleTaskAclAwareRepositoryInterface.php b/src/Bundle/ChillTaskBundle/Repository/SingleTaskAclAwareRepositoryInterface.php index 7d2870c67..bb63c0caa 100644 --- a/src/Bundle/ChillTaskBundle/Repository/SingleTaskAclAwareRepositoryInterface.php +++ b/src/Bundle/ChillTaskBundle/Repository/SingleTaskAclAwareRepositoryInterface.php @@ -19,6 +19,7 @@ interface SingleTaskAclAwareRepositoryInterface public function countByAllViewable( ?string $pattern = null, ?array $flags = [], + ?array $types = [], ?array $users = [] ): int; @@ -39,6 +40,7 @@ interface SingleTaskAclAwareRepositoryInterface public function findByAllViewable( ?string $pattern = null, ?array $flags = [], + ?array $types = [], ?array $users = [], ?int $start = 0, ?int $limit = 50, diff --git a/src/Bundle/ChillTaskBundle/Repository/SingleTaskRepository.php b/src/Bundle/ChillTaskBundle/Repository/SingleTaskRepository.php index 636203a9e..57b6f3702 100644 --- a/src/Bundle/ChillTaskBundle/Repository/SingleTaskRepository.php +++ b/src/Bundle/ChillTaskBundle/Repository/SingleTaskRepository.php @@ -306,4 +306,28 @@ class SingleTaskRepository extends EntityRepository ->add($qb->expr()->isNull('st.endDate')) ->add($qb->expr()->isNull('st.warningInterval')); } + + public function countByDistinctTypes() + { + $qb = $this->createQueryBuilder('st') + ->select('COUNT(DISTINCT st.type)'); + + $this->buildQuery($qb, []); + + return (int) $qb + ->getQuery() + ->getSingleScalarResult(); + } + + public function findAllTaskDistinctTypes() + { + $qb = $this->createQueryBuilder('st') + ->select('DISTINCT st.type'); + + $this->buildQuery($qb, []); + + return $qb + ->getQuery() + ->getResult(); + } }