From a90e87b1be8f278113b191816e88ad6619bf3101 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 5 Oct 2022 10:22:30 +0200 Subject: [PATCH 1/3] more explanation for installation instructions --- docs/source/installation/index.rst | 86 ++++++++++++++++++------------ 1 file changed, 51 insertions(+), 35 deletions(-) diff --git a/docs/source/installation/index.rst b/docs/source/installation/index.rst index 9c44d81dd..00f27ed69 100644 --- a/docs/source/installation/index.rst +++ b/docs/source/installation/index.rst @@ -14,6 +14,13 @@ Installation & Usage #################### +.. toctree:: + :maxdepth: 2 + + prod.rst + prod-calendar-sms-sending.rst + msgraph-configure.rst + Requirements ************ @@ -46,6 +53,35 @@ Clone or download the chill-skeleton project and `cd` into the main directory. As a developer, the code will stay on your computer and will be executed in docker container. To avoid permission problem, the code should be run with the same uid/gid from your current user. This is why we get your current user id with the command ``id -u`` in each following scripts. +2. Prepare composer to download the sources +=========================================== + +As you are running in dev, you must configure an auth token for getting the source code. + +.. warning + + If you skip this part, the code will be downloaded from dist instead of source (with git repository). You will probably replace the source manually, but the next time you will run ```composer update```, your repository will be replaced and you might loose something. + +1. Create a personal access token from https://gitlab.com/-/profile/personal_access_tokens, with the `read_api` scope. +2. add a file called ```.composer/auth.json``` with this content: + + .. code-block:: json + + { + "gitlab-token": { + "gitlab.com": "glXXX-XXXXXXXXXXXXXXXXXXXX" + } + } + +2. Prepare your variables and environment +========================================= + +Copy ```docker-compose.override.dev.yml``` into ```docker-compose.override.yml``` + +.. code-block:: bash + + cp docker-compose.override.dev.template.yml docker-compose.override.yml + 2. Prepare your variables and docker-compose ============================================ @@ -74,7 +110,7 @@ This script can be run using `make` This script will : 1. force docker-compose to, eventually, pull the base images and build the image used by this project ; -2. run an install script to download `composer `_ ; +2. run an install script to download `composer `_ ; 3. install the php dependencies 4. build assets @@ -136,30 +172,6 @@ The password is always ``password``. Now, read `Operations` below. -Prepare for development -*********************** - -Add a Gitlab token to ensure that you get always the source code: - -1. generate a gitlab token there: https://gitlab.com/oauth/token -2. run this command (in php container, at the app's root): :code:`composer config gitlab-token.gitlab.com ` - - The auth token should appears now in the directory :code:`.composer`: - - .. code-block: bash - - $ cat .composer/auth.json - { - "gitlab-token": { - "gitlab.com": "" - } - } -3. run ``composer update`` again (into the php container) - - - -See also "how to switch branch and get new dependencies". - Operations ********** @@ -167,7 +179,7 @@ Operations Build assets ============ -run those commands: +run those commands: .. code-block:: bash @@ -180,7 +192,7 @@ How to execute the console ? # if a container is running ./docker-php.sh - # if not + # if not docker-compose run --user $(id -u) php bin/console How to create the database schema (= run migrations) ? @@ -191,7 +203,7 @@ How to create the database schema (= run migrations) ? # if a container is running ./docker-php.sh bin/console doctrine:migrations:migrate - # if not + # if not docker-compose run --user $(id -u) php bin/console doctrine:migrations:migrate @@ -210,7 +222,7 @@ How to load fixtures ? (development mode only) # if a container is running ./docker-php.sh bin/console doctrine:fixtures:load - # if not + # if not docker-compose run --user $(id -u) php bin/console doctrine:fixtures:load How to open a terminal in the project @@ -220,7 +232,7 @@ How to open a terminal in the project # if a container is running ./docker-php.sh - # if not + # if not docker-compose run --user $(id -u) php /bin/bash How to run composer ? @@ -231,7 +243,7 @@ How to run composer ? # if a container is running ./docker-php.sh composer - # if not + # if not docker-compose run --user $(id -u) php composer How to access to PGADMIN ? @@ -253,7 +265,7 @@ Tests reside inside the installed bundles. You must `cd` into that directory, do **Note**: some bundle require the fixture to be executed. See the dedicated _how-tos_. -Exemple, for running test inside `main` bundle: +Exemple, for running test inside `main` bundle: .. code-block:: bash @@ -278,10 +290,14 @@ How to switch the branch for chill-bundles, and get new dependencies During development, you will switch to new branches for chill-bundles. As long as the dependencies are equals, this does not cause any problem. But sometimes, a new branch introduces a new dependency, and you must download it. +.. warning:: + + Ensure that you have gitlab-token ready before updating your branches. See above. + In order to do that without pain, use those steps: 0. Ensuire you have a token, set -1. at the app's root, update the `composer.json` to your current branch: +1. at the app's root, update the ``composer.json`` to your current branch: .. code-block:: json @@ -290,7 +306,7 @@ In order to do that without pain, use those steps: "chill-bundles": "dev-@dev" } -2. mount into the php container, and run `composer update` +2. mount into the php container (``./docker-php.sh``), and run ``composer update`` Error `An exception has been thrown during the rendering of a template ("Asset manifest file "/var/www/app/web/build/manifest.json" does not exist.").` on first run ==================================================================================================================================================================== @@ -304,7 +320,7 @@ Currently, to run this software in production, the *state of the art* is the fol 1. Run the software locally and tweak the configuration to your needs ; 2. Build the image and store them into a private container registry. This can be done using :code:`make build-and-push-image`. - + To be sure to target the correct container registry, you have to adapt the image names into your ``docker-compose.override.yml`` file. 3. Push the image on your registry, or upload them to the destination machine using ``docker image save`` and ``docker image load``. 3. Run the image on your production server, using docker-compose or eventually docker stack. You have to customize the variable set in docker-compose. From c1d96af85f89a50c3b8a3f24f1871b9217f561e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 5 Oct 2022 15:08:53 +0200 Subject: [PATCH 2/3] fix cs --- .../BySocialActionAggregator.php | 69 +++---- .../BySocialIssueAggregator.php | 74 ++++---- .../ACPAggregators/ByThirdpartyAggregator.php | 73 ++++---- .../ACPAggregators/ByUserAggregator.php | 73 ++++---- .../ACPAggregators/DateAggregator.php | 122 +++++++------ .../ACPAggregators/LocationTypeAggregator.php | 72 ++++---- .../ACPAggregators/UserScopeAggregator.php | 72 ++++---- .../Aggregator/ActivityTypeAggregator.php | 3 +- .../Aggregator/ActivityUserAggregator.php | 4 +- .../Export/Declarations.php | 4 +- .../LinkedToACP/AvgActivityDuration.php | 37 ++-- .../LinkedToACP/AvgActivityVisitDuration.php | 37 ++-- .../Export/LinkedToACP/CountActivity.php | 17 +- .../LinkedToACP/SumActivityDuration.php | 37 ++-- .../LinkedToACP/SumActivityVisitDuration.php | 36 ++-- .../Export/LinkedToPerson/CountActivity.php | 18 +- .../Export/LinkedToPerson/ListActivity.php | 14 +- .../LinkedToPerson/StatActivityDuration.php | 12 +- .../ACPFilters/BySocialActionFilter.php | 77 ++++---- .../Filter/ACPFilters/BySocialIssueFilter.php | 75 ++++---- .../Export/Filter/ACPFilters/ByUserFilter.php | 78 ++++---- .../Filter/ACPFilters/EmergencyFilter.php | 74 ++++---- .../Filter/ACPFilters/LocationTypeFilter.php | 82 +++++---- .../Filter/ACPFilters/SentReceivedFilter.php | 67 +++---- .../Export/Filter/ACPFilters/UserFilter.php | 76 ++++---- .../Filter/ACPFilters/UserScopeFilter.php | 85 +++++---- .../Export/Filter/ActivityDateFilter.php | 3 +- .../Config/ConfigRepository.php | 4 +- .../Export/Aggregator/AgentAggregator.php | 19 +- .../Aggregator/CancelReasonAggregator.php | 72 ++++---- .../Export/Aggregator/JobAggregator.php | 72 ++++---- .../Export/Aggregator/LocationAggregator.php | 68 +++---- .../Aggregator/LocationTypeAggregator.php | 71 ++++---- .../Export/Aggregator/MonthYearAggregator.php | 70 ++++---- .../Export/Aggregator/ScopeAggregator.php | 72 ++++---- .../Export/Export/CountAppointments.php | 29 +-- .../Export/StatAppointmentAvgDuration.php | 38 ++-- .../Export/StatAppointmentSumDuration.php | 37 ++-- .../Export/Filter/AgentFilter.php | 74 ++++---- .../Export/Filter/BetweenDatesFilter.php | 68 +++---- .../Export/Filter/JobFilter.php | 57 +++--- .../Export/Filter/ScopeFilter.php | 59 +++--- .../Controller/ExportController.php | 32 ++-- .../ChillMainBundle/Doctrine/DQL/Extract.php | 15 +- .../ChillMainBundle/Doctrine/DQL/ToChar.php | 14 +- .../ChillMainBundle/Export/ExportManager.php | 4 +- .../Import/AddressReferenceBaseImporter.php | 5 +- .../AddressReferenceBaseImporterTest.php | 34 +++- .../Import/PostalCodeBaseImporterTest.php | 36 ++-- .../NotificationOnTransitionTest.php | 34 ++-- ...ntityWorkflowTransitionEventSubscriber.php | 35 ++-- .../NotificationOnTransition.php | 8 +- .../migrations/Version20220730204216.php | 17 +- .../migrations/Version20220829132409.php | 21 ++- .../HouseholdCompositionTypeController.php | 2 +- .../ChillPersonExtension.php | 1 + .../Entity/MaritalStatus.php | 1 - .../AdministrativeLocationAggregator.php | 89 ++++------ .../ClosingMotiveAggregator.php | 93 +++++----- .../ConfidentialAggregator.php | 105 +++++------ .../DurationAggregator.php | 118 ++++++------ .../EmergencyAggregator.php | 105 +++++------ .../EvaluationAggregator.php | 95 +++++----- .../IntensityAggregator.php | 99 +++++------ .../JobAggregator.php | 94 +++++----- .../OriginAggregator.php | 96 +++++----- .../ReferrerAggregator.php | 6 +- .../ScopeAggregator.php | 94 +++++----- .../SocialActionAggregator.php | 91 +++++----- .../SocialIssueAggregator.php | 92 ++++------ .../StepAggregator.php | 114 ++++++------ .../EvaluationTypeAggregator.php | 88 ++++----- .../ChildrenNumberAggregator.php | 101 +++++------ .../CompositionAggregator.php | 104 +++++------ .../HouseholdPositionAggregator.php | 6 +- .../MaritalStatusAggregator.php | 1 - .../NationalityAggregator.php | 7 +- .../ActionTypeAggregator.php | 1 - .../SocialWorkAggregators/GoalAggregator.php | 1 - .../SocialWorkAggregators/JobAggregator.php | 94 +++++----- .../ReferrerAggregator.php | 6 +- .../ResultAggregator.php | 1 - .../SocialWorkAggregators/ScopeAggregator.php | 94 +++++----- .../ChillPersonBundle/Export/Declarations.php | 12 +- .../Export/Export/CountAccompanyingCourse.php | 24 +-- .../Export/Export/CountEvaluation.php | 68 +++---- .../Export/Export/CountHousehold.php | 67 +++---- .../Export/Export/CountPerson.php | 11 +- .../CountPersonWithAccompanyingCourse.php | 69 +++---- .../Export/Export/CountSocialWorkActions.php | 27 ++- .../Export/Export/ListPerson.php | 13 +- .../Export/Export/ListPersonDuplicate.php | 10 +- .../Export/StatAccompanyingCourseDuration.php | 66 ++----- .../ActiveOnDateFilter.php | 73 ++++---- .../ActiveOneDayBetweenDatesFilter.php | 81 ++++----- .../ActivityTypeFilter.php | 95 +++++----- .../AdministrativeLocationFilter.php | 92 +++++----- .../ClosingMotiveFilter.php | 96 +++++----- .../ConfidentialFilter.php | 84 +++++---- .../CurrentUserJobFilter.php | 26 +-- .../CurrentUserScopeFilter.php | 31 ++-- .../EmergencyFilter.php | 80 +++++---- .../EvaluationFilter.php | 95 +++++----- .../GeographicalUnitStatFilter.php | 89 +++++----- .../IntensityFilter.php | 80 +++++---- .../OpenBetweenDatesFilter.php | 81 ++++----- .../OriginFilter.php | 93 +++++----- .../ReferrerFilter.php | 93 +++++----- .../RequestorFilter.php | 101 +++++------ .../SocialActionFilter.php | 84 ++++----- .../SocialIssueFilter.php | 168 +++++++++--------- .../AccompanyingCourseFilters/StepFilter.php | 66 +++---- .../EvaluationTypeFilter.php | 93 +++++----- .../EvaluationFilters/MaxDateFilter.php | 85 ++++----- .../HouseholdFilters/CompositionFilter.php | 112 ++++++------ .../Export/Filter/PersonFilters/AgeFilter.php | 8 +- .../Filter/PersonFilters/BirthdateFilter.php | 5 +- .../PersonFilters/DeadOrAliveFilter.php | 10 +- .../PersonFilters/FamilySituationFilter.php | 2 - .../ResidentialAddressAtThirdpartyFilter.php | 41 +++-- .../ResidentialAddressAtUserFilter.php | 6 +- .../Filter/SocialWorkFilters/JobFilter.php | 60 +++---- .../SocialWorkFilters/ReferrerFilter.php | 93 +++++----- .../Filter/SocialWorkFilters/ScopeFilter.php | 59 +++--- .../SocialWorkTypeFilter.php | 168 +++++++++--------- .../Form/HouseholdCompositionTypeType.php | 3 +- .../AccompanyingPeriodWorkRepository.php | 10 +- .../Repository/PersonRepository.php | 10 +- .../Authorization/AccompanyingPeriodVoter.php | 15 +- .../Export/CountAccompanyingCourseTest.php | 24 +-- .../Export/CountSocialWorkActionsTest.php | 25 +-- .../StatAccompanyingCourseDurationTest.php | 18 +- .../Export/Filter/ActiveOnDateFilterTest.php | 29 +-- .../ActiveOneDayBetweenDatesFilterTest.php | 31 ++-- .../Export/Filter/ActivityTypeFilterTest.php | 29 +-- .../AdministrativeLocationFilterTest.php | 28 +-- .../Export/Filter/ClosingMotiveFilterTest.php | 29 +-- .../Export/Filter/ConfidentialFilterTest.php | 29 +-- .../Export/Filter/EmergencyFilterTest.php | 20 ++- .../Export/Filter/EvaluationFilterTest.php | 28 +-- .../Filter/GeographicalUnitStatFilterTest.php | 31 ++-- .../Export/Filter/IntensityFilterTest.php | 29 +-- .../Tests/Export/Filter/JobFilterTest.php | 28 +-- .../Filter/OpenBetweenDatesFilterTest.php | 31 ++-- .../Tests/Export/Filter/OriginFilterTest.php | 29 +-- .../Export/Filter/ReferrerFilterTest.php | 28 +-- .../Export/Filter/RequestorFilterTest.php | 27 +-- .../Tests/Export/Filter/ScopeFilterTest.php | 29 +-- .../Export/Filter/SocialActionFilterTest.php | 28 +-- .../Export/Filter/SocialIssueFilterTest.php | 29 +-- .../Tests/Export/Filter/StepFilterTest.php | 27 +-- .../Tests/Export/Filter/UserJobFilterTest.php | 27 +-- .../Export/Filter/UserScopeFilterTest.php | 28 +-- 153 files changed, 3797 insertions(+), 3874 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialActionAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialActionAggregator.php index 269924a8a..62b160bc1 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialActionAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialActionAggregator.php @@ -1,5 +1,12 @@ actionRepository = $actionRepository; } - public function getLabels($key, array $values, $data) - { - return function($value) { - if ('_header' === $value) { - return 'Social action'; - } - - $sa = $this->actionRepository->find($value); - - return $this->actionRender->renderString($sa, []); - }; - } - - public function getQueryKeys($data): array - { - return ['socialaction_aggregator']; - } - - public function buildForm(FormBuilderInterface $builder) - { - // no form - } - - public function getTitle(): string - { - return 'Group activity by linked socialaction'; - } - public function addRole() { return null; @@ -61,7 +40,7 @@ class BySocialActionAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - if(!in_array('socialaction', $qb->getAllAliases())) { + if (!in_array('socialaction', $qb->getAllAliases(), true)) { $qb->join('activity.socialActions', 'socialaction'); } @@ -80,4 +59,32 @@ class BySocialActionAggregator implements AggregatorInterface { return Declarations::ACTIVITY_ACP; } -} \ No newline at end of file + + public function buildForm(FormBuilderInterface $builder) + { + // no form + } + + public function getLabels($key, array $values, $data) + { + return function ($value) { + if ('_header' === $value) { + return 'Social action'; + } + + $sa = $this->actionRepository->find($value); + + return $this->actionRender->renderString($sa, []); + }; + } + + public function getQueryKeys($data): array + { + return ['socialaction_aggregator']; + } + + public function getTitle(): string + { + return 'Group activity by linked socialaction'; + } +} diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialIssueAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialIssueAggregator.php index 0e4b9ab8e..ff70e54b9 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialIssueAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialIssueAggregator.php @@ -1,5 +1,12 @@ issueRender = $issueRender; } - public function getLabels($key, array $values, $data) - { - return function ($value): string { - - if ($value === '_header') { - return 'Social issues'; - } - - $i = $this->issueRepository->find($value); - - return $this->issueRender->renderString($i, []); - }; - } - - public function getQueryKeys($data): array - { - return ['socialissue_aggregator']; - } - - public function buildForm(FormBuilderInterface $builder) - { - // no form - } - - public function getTitle(): string - { - return 'Group activity by linked socialissue'; - } - public function addRole() { return null; @@ -62,7 +40,7 @@ class BySocialIssueAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - if (!in_array('socialissue', $qb->getAllAliases())) { + if (!in_array('socialissue', $qb->getAllAliases(), true)) { $qb->join('activity.socialIssues', 'socialissue'); } @@ -81,4 +59,32 @@ class BySocialIssueAggregator implements AggregatorInterface { return Declarations::ACTIVITY_ACP; } -} \ No newline at end of file + + public function buildForm(FormBuilderInterface $builder) + { + // no form + } + + public function getLabels($key, array $values, $data) + { + return function ($value): string { + if ('_header' === $value) { + return 'Social issues'; + } + + $i = $this->issueRepository->find($value); + + return $this->issueRender->renderString($i, []); + }; + } + + public function getQueryKeys($data): array + { + return ['socialissue_aggregator']; + } + + public function getTitle(): string + { + return 'Group activity by linked socialissue'; + } +} diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByThirdpartyAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByThirdpartyAggregator.php index 5a9e633ef..ce70a9ddb 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByThirdpartyAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByThirdpartyAggregator.php @@ -1,5 +1,12 @@ thirdPartyRender = $thirdPartyRender; } - public function getLabels($key, array $values, $data) - { - return function ($value): string { - if ($value === '_header') { - return 'Accepted thirdparty'; - } - - $tp = $this->thirdPartyRepository->find($value); - - return $this->thirdPartyRender->renderString($tp, []); - }; - } - - public function getQueryKeys($data): array - { - return ['thirdparty_aggregator']; - } - - public function buildForm(FormBuilderInterface $builder) - { - // no form - } - - public function getTitle(): string - { - return 'Group activity by linked thirdparties'; - } - public function addRole() { return null; @@ -61,7 +40,7 @@ class ByThirdpartyAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - if (!in_array('thirdparty', $qb->getAllAliases())) { + if (!in_array('thirdparty', $qb->getAllAliases(), true)) { $qb->join('activity.thirdParties', 'thirdparty'); } @@ -80,4 +59,32 @@ class ByThirdpartyAggregator implements AggregatorInterface { return Declarations::ACTIVITY_ACP; } -} \ No newline at end of file + + public function buildForm(FormBuilderInterface $builder) + { + // no form + } + + public function getLabels($key, array $values, $data) + { + return function ($value): string { + if ('_header' === $value) { + return 'Accepted thirdparty'; + } + + $tp = $this->thirdPartyRepository->find($value); + + return $this->thirdPartyRender->renderString($tp, []); + }; + } + + public function getQueryKeys($data): array + { + return ['thirdparty_aggregator']; + } + + public function getTitle(): string + { + return 'Group activity by linked thirdparties'; + } +} diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByUserAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByUserAggregator.php index 95c9998b8..d57410c4b 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByUserAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByUserAggregator.php @@ -1,5 +1,12 @@ userRender = $userRender; } - public function getLabels($key, array $values, $data) - { - return function ($value): string { - if ($value === '_header') { - return 'Accepted users'; - } - - $u = $this->userRepository->find($value); - - return $this->userRender->renderString($u, []); - }; - } - - public function getQueryKeys($data): array - { - return ['users_aggregator']; - } - - public function buildForm(FormBuilderInterface $builder) - { - // no form - } - - public function getTitle(): string - { - return 'Group activity by linked users'; - } - public function addRole() { return null; @@ -61,7 +40,7 @@ class ByUserAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - if (!in_array('user', $qb->getAllAliases())) { + if (!in_array('user', $qb->getAllAliases(), true)) { $qb->join('activity.users', 'user'); } @@ -80,4 +59,32 @@ class ByUserAggregator implements AggregatorInterface { return Declarations::ACTIVITY_ACP; } -} \ No newline at end of file + + public function buildForm(FormBuilderInterface $builder) + { + // no form + } + + public function getLabels($key, array $values, $data) + { + return function ($value): string { + if ('_header' === $value) { + return 'Accepted users'; + } + + $u = $this->userRepository->find($value); + + return $this->userRender->renderString($u, []); + }; + } + + public function getQueryKeys($data): array + { + return ['users_aggregator']; + } + + public function getTitle(): string + { + return 'Group activity by linked users'; + } +} diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/DateAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/DateAggregator.php index 1c2f02d3b..3463b1c59 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/DateAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/DateAggregator.php @@ -1,12 +1,19 @@ 'year', ]; - private CONST DEFAULT_CHOICE = 'year'; + private const DEFAULT_CHOICE = 'year'; private TranslatorInterface $translator; @@ -31,54 +38,6 @@ class DateAggregator implements AggregatorInterface $this->translator = $translator; } - public function getLabels($key, array $values, $data) - { - return function ($value) use ($data): string { - if ($value === '_header') { - return 'by '. $data['frequency']; - } - switch ($data['frequency']) { - case 'month': - $month = \DateTime::createFromFormat('!m', $value); - return sprintf( - "%02d (%s)", - $value, - $month->format('M') - ); - - case 'week': - //return $this->translator->trans('for week') .' '. $value ; - - case 'year': - //return $this->translator->trans('in year') .' '. $value ; - - default: - return $value; - } - }; - } - - public function getQueryKeys($data): array - { - return ['date_aggregator']; - } - - public function buildForm(FormBuilderInterface $builder) - { - $builder->add('frequency', ChoiceType::class, [ - 'choices' => self::CHOICES, - 'multiple' => false, - 'expanded' => true, - 'empty_data' => self::DEFAULT_CHOICE, - 'data' => self::DEFAULT_CHOICE, - ]); - } - - public function getTitle(): string - { - return 'Group activity by date'; - } - public function addRole() { return null; @@ -90,13 +49,19 @@ class DateAggregator implements AggregatorInterface switch ($data['frequency']) { case 'month': - $fmt = 'MM'; break; + $fmt = 'MM'; + +break; case 'week': - $fmt = 'IW'; break; + $fmt = 'IW'; + +break; case 'year': - $fmt = 'YYYY'; $order = 'DESC'; break; + $fmt = 'YYYY'; $order = 'DESC'; + +break; default: throw new RuntimeException(sprintf("The frequency data '%s' is invalid.", $data['frequency'])); @@ -126,4 +91,53 @@ class DateAggregator implements AggregatorInterface return Declarations::ACTIVITY_ACP; } -} \ No newline at end of file + public function buildForm(FormBuilderInterface $builder) + { + $builder->add('frequency', ChoiceType::class, [ + 'choices' => self::CHOICES, + 'multiple' => false, + 'expanded' => true, + 'empty_data' => self::DEFAULT_CHOICE, + 'data' => self::DEFAULT_CHOICE, + ]); + } + + public function getLabels($key, array $values, $data) + { + return static function ($value) use ($data): string { + if ('_header' === $value) { + return 'by ' . $data['frequency']; + } + + switch ($data['frequency']) { + case 'month': + $month = DateTime::createFromFormat('!m', $value); + + return sprintf( + '%02d (%s)', + $value, + $month->format('M') + ); + + case 'week': + //return $this->translator->trans('for week') .' '. $value ; + + case 'year': + //return $this->translator->trans('in year') .' '. $value ; + + default: + return $value; + } + }; + } + + public function getQueryKeys($data): array + { + return ['date_aggregator']; + } + + public function getTitle(): string + { + return 'Group activity by date'; + } +} diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/LocationTypeAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/LocationTypeAggregator.php index aa5052aaa..c5f43cc64 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/LocationTypeAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/LocationTypeAggregator.php @@ -1,5 +1,12 @@ translatableStringHelper = $translatableStringHelper; } - public function getLabels($key, array $values, $data) - { - return function ($value): string { - if ($value === '_header') { - return 'Accepted locationtype'; - } - - $lt = $this->locationTypeRepository->find($value); - - return $this->translatableStringHelper->localize( - $lt->getTitle() - ); - }; - } - - public function getQueryKeys($data): array - { - return ['locationtype_aggregator']; - } - - public function buildForm(FormBuilderInterface $builder) - { - // no form - } - - public function getTitle(): string - { - return 'Group activity by locationtype'; - } - public function addRole() { return null; @@ -63,7 +40,7 @@ class LocationTypeAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - if (!in_array('location', $qb->getAllAliases())) { + if (!in_array('location', $qb->getAllAliases(), true)) { $qb->join('activity.location', 'location'); } @@ -83,4 +60,33 @@ class LocationTypeAggregator implements AggregatorInterface return Declarations::ACTIVITY_ACP; } -} \ No newline at end of file + public function buildForm(FormBuilderInterface $builder) + { + // no form + } + + public function getLabels($key, array $values, $data) + { + return function ($value): string { + if ('_header' === $value) { + return 'Accepted locationtype'; + } + + $lt = $this->locationTypeRepository->find($value); + + return $this->translatableStringHelper->localize( + $lt->getTitle() + ); + }; + } + + public function getQueryKeys($data): array + { + return ['locationtype_aggregator']; + } + + public function getTitle(): string + { + return 'Group activity by locationtype'; + } +} diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/UserScopeAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/UserScopeAggregator.php index 4d6cef24a..67c2d8db1 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/UserScopeAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/UserScopeAggregator.php @@ -1,5 +1,12 @@ translatableStringHelper = $translatableStringHelper; } - public function getLabels($key, array $values, $data) - { - return function ($value): string { - if ($value === '_header') { - return 'Scope'; - } - - $s = $this->scopeRepository->find($value); - - return $this->translatableStringHelper->localize( - $s->getName() - ); - }; - } - - public function getQueryKeys($data): array - { - return ['userscope_aggregator']; - } - - public function buildForm(FormBuilderInterface $builder) - { - // no form - } - - public function getTitle(): string - { - return 'Group activity by userscope'; - } - public function addRole() { return null; @@ -63,7 +40,7 @@ class UserScopeAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - if (!in_array('user', $qb->getAllAliases())) { + if (!in_array('user', $qb->getAllAliases(), true)) { $qb->join('activity.user', 'user'); } @@ -83,4 +60,33 @@ class UserScopeAggregator implements AggregatorInterface return Declarations::ACTIVITY_ACP; } -} \ No newline at end of file + public function buildForm(FormBuilderInterface $builder) + { + // no form + } + + public function getLabels($key, array $values, $data) + { + return function ($value): string { + if ('_header' === $value) { + return 'Scope'; + } + + $s = $this->scopeRepository->find($value); + + return $this->translatableStringHelper->localize( + $s->getName() + ); + }; + } + + public function getQueryKeys($data): array + { + return ['userscope_aggregator']; + } + + public function getTitle(): string + { + return 'Group activity by userscope'; + } +} diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php index cedd2df8c..3637d70c6 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php @@ -21,6 +21,7 @@ use Doctrine\ORM\Query\Expr\Join; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Security\Core\Role\Role; +use function in_array; class ActivityTypeAggregator implements AggregatorInterface { @@ -45,7 +46,7 @@ class ActivityTypeAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - if (!in_array('type', $qb->getAllAliases())) { + if (!in_array('type', $qb->getAllAliases(), true)) { $qb->join('activity.activityType', 'type'); } diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUserAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUserAggregator.php index 675098c60..6d6d3a837 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUserAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUserAggregator.php @@ -25,10 +25,10 @@ class ActivityUserAggregator implements AggregatorInterface { public const KEY = 'activity_user_id'; - private UserRepository $userRepository; - private UserRender $userRender; + private UserRepository $userRepository; + public function __construct( UserRepository $userRepository, UserRender $userRender diff --git a/src/Bundle/ChillActivityBundle/Export/Declarations.php b/src/Bundle/ChillActivityBundle/Export/Declarations.php index 7a5b47028..82f01bcb2 100644 --- a/src/Bundle/ChillActivityBundle/Export/Declarations.php +++ b/src/Bundle/ChillActivityBundle/Export/Declarations.php @@ -18,7 +18,7 @@ abstract class Declarations { public const ACTIVITY = 'activity'; - public const ACTIVITY_ACP = "activity_linked_to_acp"; + public const ACTIVITY_ACP = 'activity_linked_to_acp'; - public const ACTIVITY_PERSON = "activity_linked_to_person"; + public const ACTIVITY_PERSON = 'activity_linked_to_person'; } diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php index 1ae5d1830..d06116787 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php @@ -1,5 +1,14 @@ getQuery()->getResult(Query::HYDRATE_SCALAR); } + public function getTitle(): string + { + return 'Average activity linked to an accompanying period duration'; + } + public function getType(): string { return Declarations::ACTIVITY; @@ -73,8 +85,7 @@ class AvgActivityDuration implements ExportInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { $qb = $this->repository->createQueryBuilder('activity') - ->join('activity.accompanyingPeriod', 'acp') - ; + ->join('activity.accompanyingPeriod', 'acp'); $qb->select('AVG(activity.durationTime) as export_avg_activity_duration'); @@ -94,10 +105,4 @@ class AvgActivityDuration implements ExportInterface, GroupedExportInterface //PersonDeclarations::ACP_TYPE, ]; } - - public function getGroup(): string - { - return 'Exports of activities linked to an accompanying period'; - } - -} \ No newline at end of file +} diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php index b03378b16..535fe3d85 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php @@ -1,5 +1,14 @@ getQuery()->getResult(Query::HYDRATE_SCALAR); } + public function getTitle(): string + { + return 'Average activity linked to an accompanying period visit duration'; + } + public function getType(): string { return Declarations::ACTIVITY; @@ -73,8 +85,7 @@ class AvgActivityVisitDuration implements ExportInterface, GroupedExportInterfac public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { $qb = $this->repository->createQueryBuilder('activity') - ->join('activity.accompanyingPeriod', 'acp') - ; + ->join('activity.accompanyingPeriod', 'acp'); $qb->select('AVG(activity.travelTime) as export_avg_activity_visit_duration'); @@ -94,10 +105,4 @@ class AvgActivityVisitDuration implements ExportInterface, GroupedExportInterfac //PersonDeclarations::ACP_TYPE, ]; } - - public function getGroup(): string - { - return 'Exports of activities linked to an accompanying period'; - } - -} \ No newline at end of file +} diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php index 55c0a1974..cefb5e0e9 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php @@ -30,7 +30,7 @@ class CountActivity implements ExportInterface, GroupedExportInterface protected EntityRepository $repository; public function __construct( - EntityManagerInterface $em + EntityManagerInterface $em ) { $this->repository = $em->getRepository(Activity::class); } @@ -49,6 +49,11 @@ class CountActivity implements ExportInterface, GroupedExportInterface return 'Count activities linked to an accompanying period by various parameters.'; } + public function getGroup(): string + { + return 'Exports of activities linked to an accompanying period'; + } + public function getLabels($key, array $values, $data) { if ('export_count_activity' !== $key) { @@ -81,11 +86,10 @@ class CountActivity implements ExportInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { $qb = $this->repository->createQueryBuilder('activity') - ->join('activity.accompanyingPeriod', 'acp') - ; + ->join('activity.accompanyingPeriod', 'acp'); $qb->select('COUNT(activity.id) as export_count_activity'); - + return $qb; } @@ -102,9 +106,4 @@ class CountActivity implements ExportInterface, GroupedExportInterface //PersonDeclarations::ACP_TYPE, ]; } - - public function getGroup(): string - { - return 'Exports of activities linked to an accompanying period'; - } } diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php index 3ab192702..7ba914ee5 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php @@ -1,5 +1,14 @@ getQuery()->getResult(Query::HYDRATE_SCALAR); } + public function getTitle(): string + { + return 'Sum activity linked to an accompanying period duration'; + } + public function getType(): string { return Declarations::ACTIVITY; @@ -73,8 +85,7 @@ class SumActivityDuration implements ExportInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { $qb = $this->repository->createQueryBuilder('activity') - ->join('activity.accompanyingPeriod', 'acp') - ; + ->join('activity.accompanyingPeriod', 'acp'); $qb->select('SUM(activity.durationTime) as export_sum_activity_duration'); @@ -94,10 +105,4 @@ class SumActivityDuration implements ExportInterface, GroupedExportInterface //PersonDeclarations::ACP_TYPE, ]; } - - public function getGroup(): string - { - return 'Exports of activities linked to an accompanying period'; - } - -} \ No newline at end of file +} diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php index 452fc4de7..c3f7ef243 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php @@ -1,5 +1,14 @@ getQuery()->getResult(Query::HYDRATE_SCALAR); } + public function getTitle(): string + { + return 'Sum activity linked to an accompanying period visit duration'; + } + public function getType(): string { return Declarations::ACTIVITY; @@ -73,8 +85,7 @@ class SumActivityVisitDuration implements ExportInterface, GroupedExportInterfac public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { $qb = $this->repository->createQueryBuilder('activity') - ->join('activity.accompanyingPeriod', 'acp') - ; + ->join('activity.accompanyingPeriod', 'acp'); $qb->select('SUM(activity.travelTime) as export_sum_activity_visit_duration'); @@ -94,9 +105,4 @@ class SumActivityVisitDuration implements ExportInterface, GroupedExportInterfac //PersonDeclarations::ACP_TYPE, ]; } - - public function getGroup(): string - { - return 'Exports of activities linked to an accompanying period'; - } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/CountActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/CountActivity.php index 75d3122c3..84baf657a 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/CountActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/CountActivity.php @@ -11,12 +11,12 @@ declare(strict_types=1); namespace Chill\ActivityBundle\Export\Export\LinkedToPerson; +use Chill\ActivityBundle\Export\Declarations; use Chill\ActivityBundle\Repository\ActivityRepository; use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter; use Chill\MainBundle\Export\ExportInterface; use Chill\MainBundle\Export\FormatterInterface; use Chill\MainBundle\Export\GroupedExportInterface; -use Chill\ActivityBundle\Export\Declarations; use Chill\PersonBundle\Export\Declarations as PersonDeclarations; use Doctrine\ORM\Query; use LogicException; @@ -47,6 +47,11 @@ class CountActivity implements ExportInterface, GroupedExportInterface return 'Count activities linked to a person by various parameters.'; } + public function getGroup(): string + { + return 'Exports of activities linked to a person'; + } + public function getLabels($key, array $values, $data) { if ('export_count_activity' !== $key) { @@ -81,15 +86,13 @@ class CountActivity implements ExportInterface, GroupedExportInterface $centers = array_map(static fn ($el) => $el['center'], $acl); $qb = $this->activityRepository->createQueryBuilder('activity') - ->join('activity.person', 'person') - ; + ->join('activity.person', 'person'); $qb->select('COUNT(activity.id) as export_count_activity'); $qb ->where($qb->expr()->in('person.center', ':centers')) - ->setParameter('centers', $centers) - ; + ->setParameter('centers', $centers); return $qb; } @@ -107,9 +110,4 @@ class CountActivity implements ExportInterface, GroupedExportInterface //PersonDeclarations::PERSON_TYPE, ]; } - - public function getGroup(): string - { - return 'Exports of activities linked to a person'; - } } diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php index 21a68fb93..387ea8821 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php @@ -12,12 +12,14 @@ declare(strict_types=1); namespace Chill\ActivityBundle\Export\Export\LinkedToPerson; use Chill\ActivityBundle\Entity\ActivityReason; +use Chill\ActivityBundle\Export\Declarations; use Chill\ActivityBundle\Repository\ActivityRepository; use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter; use Chill\MainBundle\Export\FormatterInterface; use Chill\MainBundle\Export\GroupedExportInterface; use Chill\MainBundle\Export\ListInterface; use Chill\MainBundle\Templating\TranslatableStringHelperInterface; +use Chill\PersonBundle\Export\Declarations as PersonDeclarations; use DateTime; use Doctrine\DBAL\Exception\InvalidArgumentException; use Doctrine\ORM\EntityManagerInterface; @@ -28,8 +30,6 @@ use Symfony\Component\Security\Core\Role\Role; use Symfony\Component\Validator\Constraints\Callback; use Symfony\Component\Validator\Context\ExecutionContextInterface; use Symfony\Contracts\Translation\TranslatorInterface; -use Chill\ActivityBundle\Export\Declarations; -use Chill\PersonBundle\Export\Declarations as PersonDeclarations; use function array_key_exists; use function count; @@ -100,6 +100,11 @@ class ListActivity implements ListInterface, GroupedExportInterface return 'List activities linked to a person description'; } + public function getGroup(): string + { + return 'Exports of activities linked to a person'; + } + public function getLabels($key, array $values, $data) { switch ($key) { @@ -283,9 +288,4 @@ class ListActivity implements ListInterface, GroupedExportInterface //PersonDeclarations::PERSON_TYPE, ]; } - - public function getGroup(): string - { - return 'Exports of activities linked to a person'; - } } diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/StatActivityDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/StatActivityDuration.php index 5fae246f8..ebba5ad82 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/StatActivityDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/StatActivityDuration.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\ActivityBundle\Export\Export\LinkedToPerson; +use Chill\ActivityBundle\Export\Declarations; use Chill\ActivityBundle\Repository\ActivityRepository; use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter; use Chill\MainBundle\Entity\Center; @@ -18,7 +19,6 @@ use Chill\MainBundle\Export\ExportInterface; use Chill\MainBundle\Export\FormatterInterface; use Chill\MainBundle\Export\GroupedExportInterface; use Chill\PersonBundle\Export\Declarations as PersonDeclarations; -use Chill\ActivityBundle\Export\Declarations; use Doctrine\ORM\Query; use LogicException; use Symfony\Component\Form\FormBuilderInterface; @@ -67,6 +67,11 @@ class StatActivityDuration implements ExportInterface, GroupedExportInterface } } + public function getGroup(): string + { + return 'Exports of activities linked to a person'; + } + public function getLabels($key, array $values, $data) { if ('export_stat_activity' !== $key) { @@ -135,9 +140,4 @@ class StatActivityDuration implements ExportInterface, GroupedExportInterface //PersonDeclarations::PERSON_TYPE, ]; } - - public function getGroup(): string - { - return 'Exports of activities linked to a person'; - } } diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialActionFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialActionFilter.php index 58d77c73e..d110a829f 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialActionFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialActionFilter.php @@ -1,17 +1,25 @@ actionRender = $actionRender; } - public function buildForm(FormBuilderInterface $builder) - { - $builder->add('accepted_socialactions', EntityType::class, [ - 'class' => SocialAction::class, - 'choice_label' => function (SocialAction $sa) { - return $this->actionRender->renderString($sa, []); - }, - 'multiple' => true, - 'expanded' => true, - ]); - } - - public function getTitle(): string - { - return 'Filter activity by linked socialaction'; - } - - public function describeAction($data, $format = 'string'): array - { - $actions = []; - - foreach ($data['accepted_socialactions'] as $sa) { - $actions[] = $this->actionRender->renderString($sa, []); - } - - return ['Filtered activity by linked socialaction: only %actions%', [ - '%actions%' => implode(", ou ", $actions) - ]]; - } - public function addRole() { return null; @@ -61,7 +39,7 @@ class BySocialActionFilter implements FilterInterface { $where = $qb->getDQLPart('where'); - if (!in_array('socialaction', $qb->getAllAliases())) { + if (!in_array('socialaction', $qb->getAllAliases(), true)) { $qb->join('activity.socialActions', 'socialaction'); } @@ -77,9 +55,38 @@ class BySocialActionFilter implements FilterInterface $qb->setParameter('socialactions', $data['accepted_socialactions']); } - public function applyOn(): string + public function applyOn(): string { - return Declarations::ACTIVITY_ACP; + return Declarations::ACTIVITY_ACP; } -} \ No newline at end of file + public function buildForm(FormBuilderInterface $builder) + { + $builder->add('accepted_socialactions', EntityType::class, [ + 'class' => SocialAction::class, + 'choice_label' => function (SocialAction $sa) { + return $this->actionRender->renderString($sa, []); + }, + 'multiple' => true, + 'expanded' => true, + ]); + } + + public function describeAction($data, $format = 'string'): array + { + $actions = []; + + foreach ($data['accepted_socialactions'] as $sa) { + $actions[] = $this->actionRender->renderString($sa, []); + } + + return ['Filtered activity by linked socialaction: only %actions%', [ + '%actions%' => implode(', ou ', $actions), + ]]; + } + + public function getTitle(): string + { + return 'Filter activity by linked socialaction'; + } +} diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialIssueFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialIssueFilter.php index 052b780ff..66fa92dd4 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialIssueFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialIssueFilter.php @@ -1,17 +1,25 @@ issueRender = $issueRender; } - public function buildForm(FormBuilderInterface $builder) - { - $builder->add('accepted_socialissues', EntityType::class, [ - 'class' => SocialIssue::class, - 'choice_label' => function(SocialIssue $si) { - return $this->issueRender->renderString($si, []); - }, - 'multiple' => true, - 'expanded' => true, - ]); - } - - public function getTitle(): string - { - return 'Filter activity by linked socialissue'; - } - - public function describeAction($data, $format = 'string'): array - { - $issues = []; - - foreach ($data['accepted_socialissues'] as $si) { - $issues[] = $this->issueRender->renderString($si, []); - } - - return ['Filtered activity by linked socialissue: only %issues%', [ - '%issues%' => implode(", ou ", $issues) - ]]; - } - public function addRole() { return null; @@ -61,7 +39,7 @@ class BySocialIssueFilter implements FilterInterface { $where = $qb->getDQLPart('where'); - if (!in_array('socialissue', $qb->getAllAliases())) { + if (!in_array('socialissue', $qb->getAllAliases(), true)) { $qb->join('activity.socialIssues', 'socialissue'); } @@ -77,9 +55,38 @@ class BySocialIssueFilter implements FilterInterface $qb->setParameter('socialissues', $data['accepted_socialissues']); } - public function applyOn(): string + public function applyOn(): string { return Declarations::ACTIVITY_ACP; } -} \ No newline at end of file + public function buildForm(FormBuilderInterface $builder) + { + $builder->add('accepted_socialissues', EntityType::class, [ + 'class' => SocialIssue::class, + 'choice_label' => function (SocialIssue $si) { + return $this->issueRender->renderString($si, []); + }, + 'multiple' => true, + 'expanded' => true, + ]); + } + + public function describeAction($data, $format = 'string'): array + { + $issues = []; + + foreach ($data['accepted_socialissues'] as $si) { + $issues[] = $this->issueRender->renderString($si, []); + } + + return ['Filtered activity by linked socialissue: only %issues%', [ + '%issues%' => implode(', ou ', $issues), + ]]; + } + + public function getTitle(): string + { + return 'Filter activity by linked socialissue'; + } +} diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ByUserFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ByUserFilter.php index b128b03aa..512dce874 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ByUserFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ByUserFilter.php @@ -1,17 +1,25 @@ userRender = $userRender; } - public function buildForm(FormBuilderInterface $builder) - { - $builder->add('accepted_users', EntityType::class, [ - 'class' => User::class, - 'choice_label' => function (User $u) { - return $this->userRender->renderString($u, []); - }, - 'multiple' => true, - 'expanded' => true, - ]); - } - - public function getTitle(): string - { - return 'Filter activity by linked users'; - } - - public function describeAction($data, $format = 'string'): array - { - $users = []; - - foreach ($data['accepted_users'] as $u) { - $users[] = $this->userRender->renderString($u, []); - } - - return ['Filtered activity by linked users: only %users%', [ - '%users%' => implode(", ou ", $users) - ]]; - } - public function addRole() { return null; @@ -61,7 +39,7 @@ class ByUserFilter implements FilterInterface { $where = $qb->getDQLPart('where'); - if (!in_array('user', $qb->getAllAliases())) { + if (!in_array('user', $qb->getAllAliases(), true)) { $qb->join('activity.users', 'user'); } @@ -77,8 +55,38 @@ class ByUserFilter implements FilterInterface $qb->setParameter('users', $data['accepted_users']); } - public function applyOn(): string + public function applyOn(): string { - return Declarations::ACTIVITY_ACP; + return Declarations::ACTIVITY_ACP; } -} \ No newline at end of file + + public function buildForm(FormBuilderInterface $builder) + { + $builder->add('accepted_users', EntityType::class, [ + 'class' => User::class, + 'choice_label' => function (User $u) { + return $this->userRender->renderString($u, []); + }, + 'multiple' => true, + 'expanded' => true, + ]); + } + + public function describeAction($data, $format = 'string'): array + { + $users = []; + + foreach ($data['accepted_users'] as $u) { + $users[] = $this->userRender->renderString($u, []); + } + + return ['Filtered activity by linked users: only %users%', [ + '%users%' => implode(', ou ', $users), + ]]; + } + + public function getTitle(): string + { + return 'Filter activity by linked users'; + } +} diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/EmergencyFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/EmergencyFilter.php index d7a823891..612ef3d3d 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/EmergencyFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/EmergencyFilter.php @@ -1,11 +1,18 @@ false, ]; - private CONST DEFAULT_CHOICE = false; + private const DEFAULT_CHOICE = false; private TranslatorInterface $translator; @@ -28,35 +35,6 @@ class EmergencyFilter implements FilterInterface $this->translator = $translator; } - public function buildForm(FormBuilderInterface $builder) - { - $builder->add('accepted_emergency', ChoiceType::class, [ - 'choices' => self::CHOICES, - 'multiple' => false, - 'expanded' => true, - 'empty_data' => self::DEFAULT_CHOICE, - 'data' => self::DEFAULT_CHOICE, - ]); - } - - public function getTitle(): string - { - return 'Filter activity by emergency'; - } - - public function describeAction($data, $format = 'string'): array - { - foreach (self::CHOICES as $k => $v) { - if ($v === $data['accepted_emergency']) { - $choice = $k; - } - } - - return ['Filtered activity by emergency: only %emergency%', [ - '%emergency%' => $this->translator->trans($choice) - ]]; - } - public function addRole() { return null; @@ -78,9 +56,37 @@ class EmergencyFilter implements FilterInterface $qb->setParameter('emergency', $data['accepted_emergency']); } - public function applyOn(): string + public function applyOn(): string { - return Declarations::ACTIVITY_ACP; + return Declarations::ACTIVITY_ACP; } -} \ No newline at end of file + public function buildForm(FormBuilderInterface $builder) + { + $builder->add('accepted_emergency', ChoiceType::class, [ + 'choices' => self::CHOICES, + 'multiple' => false, + 'expanded' => true, + 'empty_data' => self::DEFAULT_CHOICE, + 'data' => self::DEFAULT_CHOICE, + ]); + } + + public function describeAction($data, $format = 'string'): array + { + foreach (self::CHOICES as $k => $v) { + if ($v === $data['accepted_emergency']) { + $choice = $k; + } + } + + return ['Filtered activity by emergency: only %emergency%', [ + '%emergency%' => $this->translator->trans($choice), + ]]; + } + + public function getTitle(): string + { + return 'Filter activity by emergency'; + } +} diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationTypeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationTypeFilter.php index cf29f20f2..4519dd63a 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationTypeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationTypeFilter.php @@ -1,17 +1,25 @@ translatableStringHelper = $translatableStringHelper; } - public function buildForm(FormBuilderInterface $builder) - { - $builder->add('accepted_locationtype', EntityType::class, [ - 'class' => LocationType::class, - 'choice_label' => function(LocationType $type) { - return $this->translatableStringHelper->localize($type->getTitle()); - }, - 'multiple' => true, - 'expanded' => true, - ]); - } - - public function getTitle(): string - { - return 'Filter activity by locationtype'; - } - - public function describeAction($data, $format = 'string'): array - { - $types = []; - - foreach ($data['accepted_locationtype'] as $type) { - $types[] = $this->translatableStringHelper->localize( - $type->getTitle() - ); - } - - return ['Filtered activity by locationtype: only %types%', [ - '%types%' => implode(", ou ", $types) - ]]; - } - public function addRole() { return null; @@ -61,7 +37,7 @@ class LocationTypeFilter implements FilterInterface public function alterQuery(QueryBuilder $qb, $data) { - if (!in_array('location', $qb->getAllAliases())) { + if (!in_array('location', $qb->getAllAliases(), true)) { $qb->join('activity.location', 'location'); } @@ -78,8 +54,40 @@ class LocationTypeFilter implements FilterInterface $qb->setParameter('locationtype', $data['accepted_locationtype']); } - public function applyOn(): string + public function applyOn(): string { - return Declarations::ACTIVITY_ACP; + return Declarations::ACTIVITY_ACP; } -} \ No newline at end of file + + public function buildForm(FormBuilderInterface $builder) + { + $builder->add('accepted_locationtype', EntityType::class, [ + 'class' => LocationType::class, + 'choice_label' => function (LocationType $type) { + return $this->translatableStringHelper->localize($type->getTitle()); + }, + 'multiple' => true, + 'expanded' => true, + ]); + } + + public function describeAction($data, $format = 'string'): array + { + $types = []; + + foreach ($data['accepted_locationtype'] as $type) { + $types[] = $this->translatableStringHelper->localize( + $type->getTitle() + ); + } + + return ['Filtered activity by locationtype: only %types%', [ + '%types%' => implode(', ou ', $types), + ]]; + } + + public function getTitle(): string + { + return 'Filter activity by locationtype'; + } +} diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/SentReceivedFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/SentReceivedFilter.php index 409c974ac..7c878ac75 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/SentReceivedFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/SentReceivedFilter.php @@ -1,12 +1,19 @@ Activity::SENTRECEIVED_RECEIVED, ]; - private CONST DEFAULT_CHOICE = Activity::SENTRECEIVED_SENT; + private const DEFAULT_CHOICE = Activity::SENTRECEIVED_SENT; private TranslatorInterface $translator; @@ -29,31 +36,6 @@ class SentReceivedFilter implements FilterInterface $this->translator = $translator; } - public function buildForm(FormBuilderInterface $builder) - { - $builder->add('accepted_sentreceived', ChoiceType::class, [ - 'choices' => self::CHOICES, - 'multiple' => false, - 'expanded' => true, - 'empty_data' => self::DEFAULT_CHOICE, - 'data' => self::DEFAULT_CHOICE, - ]); - } - - public function getTitle(): string - { - return 'Filter activity by sentreceived'; - } - - public function describeAction($data, $format = 'string'): array - { - $sentreceived = array_flip(self::CHOICES)[$data['accepted_sentreceived']]; - - return ['Filtered activity by sentreceived: only %sentreceived%', [ - '%sentreceived%' => $this->translator->trans($sentreceived) - ]]; - } - public function addRole() { return null; @@ -75,8 +57,33 @@ class SentReceivedFilter implements FilterInterface $qb->setParameter('sentreceived', $data['accepted_sentreceived']); } - public function applyOn(): string + public function applyOn(): string { - return Declarations::ACTIVITY_ACP; + return Declarations::ACTIVITY_ACP; } -} \ No newline at end of file + + public function buildForm(FormBuilderInterface $builder) + { + $builder->add('accepted_sentreceived', ChoiceType::class, [ + 'choices' => self::CHOICES, + 'multiple' => false, + 'expanded' => true, + 'empty_data' => self::DEFAULT_CHOICE, + 'data' => self::DEFAULT_CHOICE, + ]); + } + + public function describeAction($data, $format = 'string'): array + { + $sentreceived = array_flip(self::CHOICES)[$data['accepted_sentreceived']]; + + return ['Filtered activity by sentreceived: only %sentreceived%', [ + '%sentreceived%' => $this->translator->trans($sentreceived), + ]]; + } + + public function getTitle(): string + { + return 'Filter activity by sentreceived'; + } +} diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserFilter.php index d1455ea89..ef865b3a8 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserFilter.php @@ -1,12 +1,19 @@ userRender = $userRender; } - public function buildForm(FormBuilderInterface $builder) - { - $builder->add('accepted_users', EntityType::class, [ - 'class' => User::class, - 'choice_label' => function (User $u) { - return $this->userRender->renderString($u, []); - }, - 'multiple' => true, - 'expanded' => true, - 'label' => 'Creators' - ]); - } - - public function getTitle(): string - { - return 'Filter activity by user'; - } - - public function describeAction($data, $format = 'string'): array - { - $users = []; - - foreach ($data['accepted_users'] as $u) { - $users[] = $this->userRender->renderString($u, []); - } - - return ['Filtered activity by user: only %users%', [ - '%users%' => implode(", ou ", $users) - ]]; - } - public function addRole() { return null; @@ -74,9 +50,39 @@ class UserFilter implements FilterInterface $qb->setParameter('users', $data['accepted_users']); } - public function applyOn(): string + public function applyOn(): string { - return Declarations::ACTIVITY_ACP; + return Declarations::ACTIVITY_ACP; } -} \ No newline at end of file + public function buildForm(FormBuilderInterface $builder) + { + $builder->add('accepted_users', EntityType::class, [ + 'class' => User::class, + 'choice_label' => function (User $u) { + return $this->userRender->renderString($u, []); + }, + 'multiple' => true, + 'expanded' => true, + 'label' => 'Creators', + ]); + } + + public function describeAction($data, $format = 'string'): array + { + $users = []; + + foreach ($data['accepted_users'] as $u) { + $users[] = $this->userRender->renderString($u, []); + } + + return ['Filtered activity by user: only %users%', [ + '%users%' => implode(', ou ', $users), + ]]; + } + + public function getTitle(): string + { + return 'Filter activity by user'; + } +} diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserScopeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserScopeFilter.php index 987704ab8..ae2ad2629 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserScopeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/UserScopeFilter.php @@ -1,17 +1,25 @@ translatableStringHelper = $translatableStringHelper; } - public function buildForm(FormBuilderInterface $builder) - { - $builder->add('accepted_userscope', EntityType::class, [ - 'class' => Scope::class, - 'choice_label' => function (Scope $s) { - return $this->translatableStringHelper->localize( - $s->getName() - ); - }, - 'multiple' => true, - 'expanded' => true - ]); - } - - public function getTitle(): string - { - return 'Filter activity by userscope'; - } - - public function describeAction($data, $format = 'string'): array - { - $scopes = []; - - foreach ($data['accepted_userscope'] as $s) { - $scopes[] = $this->translatableStringHelper->localize( - $s->getName() - ); - } - - return ['Filtered activity by userscope: only %scopes%', [ - '%scopes%' => implode(", ou ", $scopes) - ]]; - } - public function addRole() { return null; @@ -63,7 +37,7 @@ class UserScopeFilter implements FilterInterface public function alterQuery(QueryBuilder $qb, $data) { - if (!in_array('user', $qb->getAllAliases())) { + if (!in_array('user', $qb->getAllAliases(), true)) { $qb->join('activity.user', 'user'); } @@ -81,9 +55,42 @@ class UserScopeFilter implements FilterInterface $qb->setParameter('userscope', $data['accepted_userscope']); } - public function applyOn(): string + public function applyOn(): string { - return Declarations::ACTIVITY_ACP; + return Declarations::ACTIVITY_ACP; } -} \ No newline at end of file + public function buildForm(FormBuilderInterface $builder) + { + $builder->add('accepted_userscope', EntityType::class, [ + 'class' => Scope::class, + 'choice_label' => function (Scope $s) { + return $this->translatableStringHelper->localize( + $s->getName() + ); + }, + 'multiple' => true, + 'expanded' => true, + ]); + } + + public function describeAction($data, $format = 'string'): array + { + $scopes = []; + + foreach ($data['accepted_userscope'] as $s) { + $scopes[] = $this->translatableStringHelper->localize( + $s->getName() + ); + } + + return ['Filtered activity by userscope: only %scopes%', [ + '%scopes%' => implode(', ou ', $scopes), + ]]; + } + + public function getTitle(): string + { + return 'Filter activity by userscope'; + } +} diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityDateFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityDateFilter.php index 4b20553af..65057cb1e 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityDateFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityDateFilter.php @@ -73,8 +73,7 @@ class ActivityDateFilter implements FilterInterface ->add('date_to', ChillDateType::class, [ 'label' => 'Activities before this date', 'data' => new DateTime(), - ]) - ; + ]); $builder->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) { /** @var \Symfony\Component\Form\FormInterface $filterForm */ diff --git a/src/Bundle/ChillBudgetBundle/Config/ConfigRepository.php b/src/Bundle/ChillBudgetBundle/Config/ConfigRepository.php index e498ba5a3..6443eeaf7 100644 --- a/src/Bundle/ChillBudgetBundle/Config/ConfigRepository.php +++ b/src/Bundle/ChillBudgetBundle/Config/ConfigRepository.php @@ -70,14 +70,14 @@ class ConfigRepository private function getCharges(bool $onlyActive = false): array { return $onlyActive ? - array_filter($this->charges, function ($el) { return $el['active']; }) + array_filter($this->charges, static function ($el) { return $el['active']; }) : $this->charges; } private function getResources(bool $onlyActive = false): array { return $onlyActive ? - array_filter($this->resources, function ($el) { return $el['active']; }) + array_filter($this->resources, static function ($el) { return $el['active']; }) : $this->resources; } diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/AgentAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/AgentAggregator.php index ed7c265ff..af96dd474 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/AgentAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/AgentAggregator.php @@ -1,20 +1,30 @@ groupBy('agent_aggregator'); } - } public function applyOn(): string @@ -54,7 +63,7 @@ final class AgentAggregator implements AggregatorInterface // no form } - public function getLabels($key, array $values, $data): \Closure + public function getLabels($key, array $values, $data): Closure { return function ($value): string { if ('_header' === $value) { @@ -76,4 +85,4 @@ final class AgentAggregator implements AggregatorInterface { return 'Group by agent'; } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/CancelReasonAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/CancelReasonAggregator.php index 583153a7d..2010fb90c 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/CancelReasonAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/CancelReasonAggregator.php @@ -1,11 +1,21 @@ translatableStringHelper = $translatableStringHelper; } - public function getLabels($key, array $values, $data): \Closure - { - return function($value): string { - if ($value === '_header') { - return 'Cancel reason'; - } - - $j = $this->cancelReasonRepository->find($value); - - return $this->translatableStringHelper->localize( - $j->getName() - ); - }; - } - - public function getQueryKeys($data): array - { - return ['cancel_reason_aggregator']; - } - - public function buildForm(FormBuilderInterface $builder) - { - // no form - } - - public function getTitle(): string - { - return 'Group by cancel reason'; - } - public function addRole() { return null; @@ -78,4 +58,34 @@ class CancelReasonAggregator implements AggregatorInterface { return Declarations::CALENDAR_TYPE; } -} \ No newline at end of file + + public function buildForm(FormBuilderInterface $builder) + { + // no form + } + + public function getLabels($key, array $values, $data): Closure + { + return function ($value): string { + if ('_header' === $value) { + return 'Cancel reason'; + } + + $j = $this->cancelReasonRepository->find($value); + + return $this->translatableStringHelper->localize( + $j->getName() + ); + }; + } + + public function getQueryKeys($data): array + { + return ['cancel_reason_aggregator']; + } + + public function getTitle(): string + { + return 'Group by cancel reason'; + } +} diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/JobAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/JobAggregator.php index b019cc21b..a2b300f24 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/JobAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/JobAggregator.php @@ -1,11 +1,21 @@ translatableStringHelper = $translatableStringHelper; } - public function getLabels($key, array $values, $data): \Closure - { - return function($value): string { - if ($value === '_header') { - return 'Job'; - } - - $j = $this->jobRepository->find($value); - - return $this->translatableStringHelper->localize( - $j->getLabel() - ); - }; - } - - public function getQueryKeys($data): array - { - return ['job_aggregator']; - } - - public function buildForm(FormBuilderInterface $builder) - { - // no form - } - - public function getTitle(): string - { - return 'Group by agent job'; - } - public function addRole() { return null; @@ -77,4 +57,34 @@ final class JobAggregator implements AggregatorInterface { return Declarations::CALENDAR_TYPE; } -} \ No newline at end of file + + public function buildForm(FormBuilderInterface $builder) + { + // no form + } + + public function getLabels($key, array $values, $data): Closure + { + return function ($value): string { + if ('_header' === $value) { + return 'Job'; + } + + $j = $this->jobRepository->find($value); + + return $this->translatableStringHelper->localize( + $j->getLabel() + ); + }; + } + + public function getQueryKeys($data): array + { + return ['job_aggregator']; + } + + public function getTitle(): string + { + return 'Group by agent job'; + } +} diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationAggregator.php index bc921c9c7..6d5a6476d 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationAggregator.php @@ -1,10 +1,20 @@ locationRepository = $locationRepository; } - public function getLabels($key, array $values, $data): \Closure - { - return function($value): string { - if ($value === '_header') { - return 'Location'; - } - - $l = $this->locationRepository->find($value); - - return $l->getName(); - - }; - } - - public function getQueryKeys($data): array - { - return ['location_aggregator']; - } - - public function buildForm(FormBuilderInterface $builder) - { - // no form - } - - public function getTitle(): string - { - return 'Group by location'; - } - public function addRole(): ?Role { return null; @@ -72,4 +53,31 @@ final class LocationAggregator implements AggregatorInterface return Declarations::CALENDAR_TYPE; } -} \ No newline at end of file + public function buildForm(FormBuilderInterface $builder) + { + // no form + } + + public function getLabels($key, array $values, $data): Closure + { + return function ($value): string { + if ('_header' === $value) { + return 'Location'; + } + + $l = $this->locationRepository->find($value); + + return $l->getName(); + }; + } + + public function getQueryKeys($data): array + { + return ['location_aggregator']; + } + + public function getTitle(): string + { + return 'Group by location'; + } +} diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationTypeAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationTypeAggregator.php index 3b3b9105a..4ead075d5 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationTypeAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationTypeAggregator.php @@ -1,11 +1,21 @@ translatableStringHelper = $translatableStringHelper; } - public function getLabels($key, array $values, $data): \Closure - { - return function($value): string { - if ($value === '_header') { - return 'Location type'; - } - - $j = $this->locationTypeRepository->find($value); - - return $this->translatableStringHelper->localize( - $j->getTitle() - ); - }; - } - - public function getQueryKeys($data): array - { - return ['location_type_aggregator']; - } - - public function buildForm(FormBuilderInterface $builder) - { - // no form - } - - public function getTitle(): string - { - return 'Group by location type'; - } - public function addRole() { return null; @@ -78,4 +58,33 @@ final class LocationTypeAggregator implements AggregatorInterface return Declarations::CALENDAR_TYPE; } -} \ No newline at end of file + public function buildForm(FormBuilderInterface $builder) + { + // no form + } + + public function getLabels($key, array $values, $data): Closure + { + return function ($value): string { + if ('_header' === $value) { + return 'Location type'; + } + + $j = $this->locationTypeRepository->find($value); + + return $this->translatableStringHelper->localize( + $j->getTitle() + ); + }; + } + + public function getQueryKeys($data): array + { + return ['location_type_aggregator']; + } + + public function getTitle(): string + { + return 'Group by location type'; + } +} diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/MonthYearAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/MonthYearAggregator.php index 71a0e75bb..42bac218d 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/MonthYearAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/MonthYearAggregator.php @@ -1,5 +1,14 @@ translatableStringHelper = $translatableStringHelper; } - public function getLabels($key, array $values, $data): \Closure - { - return function ($value): string { - if ($value === '_header') { - return 'Scope'; - } - - $s = $this->scopeRepository->find($value); - - return $this->translatableStringHelper->localize( - $s->getName() - ); - }; - } - - public function getQueryKeys($data): array - { - return ['scope_aggregator']; - } - - public function buildForm(FormBuilderInterface $builder) - { - // no form - } - - public function getTitle(): string - { - return 'Group by agent scope'; - } - public function addRole() { return null; @@ -77,4 +57,34 @@ final class ScopeAggregator implements AggregatorInterface { return Declarations::CALENDAR_TYPE; } -} \ No newline at end of file + + public function buildForm(FormBuilderInterface $builder) + { + // no form + } + + public function getLabels($key, array $values, $data): Closure + { + return function ($value): string { + if ('_header' === $value) { + return 'Scope'; + } + + $s = $this->scopeRepository->find($value); + + return $this->translatableStringHelper->localize( + $s->getName() + ); + }; + } + + public function getQueryKeys($data): array + { + return ['scope_aggregator']; + } + + public function getTitle(): string + { + return 'Group by agent scope'; + } +} diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/CountAppointments.php b/src/Bundle/ChillCalendarBundle/Export/Export/CountAppointments.php index e47288edc..36864e92e 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/CountAppointments.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/CountAppointments.php @@ -1,13 +1,23 @@ getQuery()->getResult(Query::HYDRATE_SCALAR); } + public function getTitle(): string + { + return 'Average appointment duration'; + } + public function getType(): string { return Declarations::CALENDAR_TYPE; @@ -91,13 +105,7 @@ class StatAppointmentAvgDuration implements ExportInterface, GroupedExportInterf public function supportsModifiers(): array { return [ - Declarations::CALENDAR_TYPE + Declarations::CALENDAR_TYPE, ]; } - - public function getGroup(): string - { - return 'Exports of calendar'; - } - -} \ No newline at end of file +} diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/StatAppointmentSumDuration.php b/src/Bundle/ChillCalendarBundle/Export/Export/StatAppointmentSumDuration.php index 0e362d766..1960af2e4 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/StatAppointmentSumDuration.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/StatAppointmentSumDuration.php @@ -1,5 +1,14 @@ getQuery()->getResult(Query::HYDRATE_SCALAR); } + public function getTitle(): string + { + return 'Sum of appointment durations'; + } + public function getType(): string { return Declarations::CALENDAR_TYPE; @@ -90,13 +105,7 @@ class StatAppointmentSumDuration implements ExportInterface, GroupedExportInterf public function supportsModifiers(): array { return [ - Declarations::CALENDAR_TYPE + Declarations::CALENDAR_TYPE, ]; } - - public function getGroup(): string - { - return 'Exports of calendar'; - } - -} \ No newline at end of file +} diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php index 5c16d0728..ee4e82350 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php @@ -1,5 +1,14 @@ userRender = $userRender; } - public function buildForm(FormBuilderInterface $builder) - { - $builder->add('accepted_agents', EntityType::class, [ - 'class' => User::class, - 'choice_label' => function (User $u) { - return $this->userRender->renderString($u, []); - }, - 'multiple' => true, - 'expanded' => true - ]); - - } - - public function getTitle(): string - { - return 'Filter by agent'; - } - - public function describeAction($data, $format = 'string'): array - { - $users = []; - - foreach ($data['accepted_agents'] as $r) { - $users[] = $r; - } - - return [ - 'Filtered by agent: only %agents%', [ - '%agents' => implode(", ou ", $users) - ]]; - } - public function addRole() { return null; @@ -76,4 +53,35 @@ class AgentFilter implements FilterInterface { return Declarations::CALENDAR_TYPE; } -} \ No newline at end of file + + public function buildForm(FormBuilderInterface $builder) + { + $builder->add('accepted_agents', EntityType::class, [ + 'class' => User::class, + 'choice_label' => function (User $u) { + return $this->userRender->renderString($u, []); + }, + 'multiple' => true, + 'expanded' => true, + ]); + } + + public function describeAction($data, $format = 'string'): array + { + $users = []; + + foreach ($data['accepted_agents'] as $r) { + $users[] = $r; + } + + return [ + 'Filtered by agent: only %agents%', [ + '%agents' => implode(', ou ', $users), + ], ]; + } + + public function getTitle(): string + { + return 'Filter by agent'; + } +} diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/BetweenDatesFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/BetweenDatesFilter.php index a23c76d98..74b481abe 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/BetweenDatesFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/BetweenDatesFilter.php @@ -1,42 +1,26 @@ add('date_from', ChillDateType::class, [ - 'data' => new \DateTime(), - ]) - ->add('date_to', ChillDateType::class, [ - 'data' => new \DateTime(), - ]) - ; - } - - public function getTitle(): string - { - return 'Filter by appointments between certain dates'; - } - - public function describeAction($data, $format = 'string'): array - { - return ['Filtered by appointments between %dateFrom% and %dateTo%', [ - '%dateFrom%' => $data['date_from']->format('d-m-Y'), - '%dateTo%' => $data['date_to']->format('d-m-Y'), - ]]; - } - public function addRole() { return null; @@ -47,9 +31,9 @@ class BetweenDatesFilter implements FilterInterface $where = $qb->getDQLPart('where'); $clause = $qb->expr()->andX( - $qb->expr()->gte('cal.startDate', ':dateFrom'), - $qb->expr()->lte('cal.endDate', ':dateTo') - ); + $qb->expr()->gte('cal.startDate', ':dateFrom'), + $qb->expr()->lte('cal.endDate', ':dateTo') + ); if ($where instanceof Andx) { $where->add($clause); @@ -67,4 +51,28 @@ class BetweenDatesFilter implements FilterInterface { return Declarations::CALENDAR_TYPE; } -} \ No newline at end of file + + public function buildForm(FormBuilderInterface $builder) + { + $builder + ->add('date_from', ChillDateType::class, [ + 'data' => new DateTime(), + ]) + ->add('date_to', ChillDateType::class, [ + 'data' => new DateTime(), + ]); + } + + public function describeAction($data, $format = 'string'): array + { + return ['Filtered by appointments between %dateFrom% and %dateTo%', [ + '%dateFrom%' => $data['date_from']->format('d-m-Y'), + '%dateTo%' => $data['date_to']->format('d-m-Y'), + ]]; + } + + public function getTitle(): string + { + return 'Filter by appointments between certain dates'; + } +} diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php index 42e03e239..562c3281e 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php @@ -23,7 +23,6 @@ use Symfony\Contracts\Translation\TranslatorInterface; class JobFilter implements FilterInterface { - protected TranslatorInterface $translator; private TranslatableStringHelper $translatableStringHelper; @@ -36,34 +35,6 @@ class JobFilter implements FilterInterface $this->translatableStringHelper = $translatableStringHelper; } - public function buildForm(FormBuilderInterface $builder) - { - $builder->add('job', EntityType::class, [ - 'class' => UserJob::class, - 'choice_label' => function (UserJob $j) { - return $this->translatableStringHelper->localize( - $j->getLabel() - ); - }, - 'multiple' => true, - 'expanded' => true - ]); - } - - public function describeAction($data, $format = 'string'): array - { - $userJobs = []; - - foreach ($data['job'] as $j) { - $userJobs[] = $this->translatableStringHelper->localize( - $j->getLabel()); - } - - return ['Filtered by agent job: only %jobs%', [ - '%jobs%' => implode(', ou ', $userJobs) - ]]; - } - public function addRole() { return null; @@ -91,6 +62,34 @@ class JobFilter implements FilterInterface return Declarations::CALENDAR_TYPE; } + public function buildForm(FormBuilderInterface $builder) + { + $builder->add('job', EntityType::class, [ + 'class' => UserJob::class, + 'choice_label' => function (UserJob $j) { + return $this->translatableStringHelper->localize( + $j->getLabel() + ); + }, + 'multiple' => true, + 'expanded' => true, + ]); + } + + public function describeAction($data, $format = 'string'): array + { + $userJobs = []; + + foreach ($data['job'] as $j) { + $userJobs[] = $this->translatableStringHelper->localize( + $j->getLabel() + ); + } + + return ['Filtered by agent job: only %jobs%', [ + '%jobs%' => implode(', ou ', $userJobs), + ]]; + } public function getTitle(): string { diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php index c3fc7b1e4..3ac1d0f1b 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php @@ -23,7 +23,6 @@ use Symfony\Contracts\Translation\TranslatorInterface; class ScopeFilter implements FilterInterface { - protected TranslatorInterface $translator; private TranslatableStringHelper $translatableStringHelper; @@ -36,34 +35,6 @@ class ScopeFilter implements FilterInterface $this->translatableStringHelper = $translatableStringHelper; } - public function buildForm(FormBuilderInterface $builder) - { - $builder->add('scope', EntityType::class, [ - 'class' => Scope::class, - 'choice_label' => function (Scope $s) { - return $this->translatableStringHelper->localize( - $s->getName() - ); - }, - 'multiple' => true, - 'expanded' => true - ]); - } - - public function describeAction($data, $format = 'string') - { - $scopes = []; - - foreach ($data['scope'] as $s) { - $scopes[] = $this->translatableStringHelper->localize( - $s->getName()); - } - - return ['Filtered by agent scope: only %scopes%', [ - '%scopes%' => implode(', ou ', $scopes) - ]]; - } - public function addRole() { return null; @@ -91,9 +62,37 @@ class ScopeFilter implements FilterInterface return Declarations::CALENDAR_TYPE; } + public function buildForm(FormBuilderInterface $builder) + { + $builder->add('scope', EntityType::class, [ + 'class' => Scope::class, + 'choice_label' => function (Scope $s) { + return $this->translatableStringHelper->localize( + $s->getName() + ); + }, + 'multiple' => true, + 'expanded' => true, + ]); + } + + public function describeAction($data, $format = 'string') + { + $scopes = []; + + foreach ($data['scope'] as $s) { + $scopes[] = $this->translatableStringHelper->localize( + $s->getName() + ); + } + + return ['Filtered by agent scope: only %scopes%', [ + '%scopes%' => implode(', ou ', $scopes), + ]]; + } public function getTitle() { return 'Filter by agent scope'; } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillMainBundle/Controller/ExportController.php b/src/Bundle/ChillMainBundle/Controller/ExportController.php index aba48474f..49d0e3959 100644 --- a/src/Bundle/ChillMainBundle/Controller/ExportController.php +++ b/src/Bundle/ChillMainBundle/Controller/ExportController.php @@ -446,7 +446,7 @@ class ExportController extends AbstractController $this->logger->notice('[export] choices for an export unserialized', [ 'key' => $key, - 'rawData' => json_encode($rawData) + 'rawData' => json_encode($rawData), ]); $alias = $rawData['alias']; @@ -531,6 +531,21 @@ class ExportController extends AbstractController ); } + private function getExportGroup($target): string + { + $exportManager = $this->exportManager; + + $groups = $exportManager->getExportsGrouped(true); + + foreach ($groups as $group => $array) { + foreach ($array as $alias => $export) { + if ($export === $target) { + return $group; + } + } + } + } + /** * get the next step. If $reverse === true, the previous step is returned. * @@ -578,19 +593,4 @@ class ExportController extends AbstractController throw new LogicException("the step {$step} is not defined."); } } - - private function getExportGroup($target): string - { - $exportManager = $this->exportManager; - - $groups = $exportManager->getExportsGrouped(true); - - foreach ($groups as $group => $array) { - foreach ($array as $alias => $export) { - if ($export === $target) { - return $group; - } - } - } - } } diff --git a/src/Bundle/ChillMainBundle/Doctrine/DQL/Extract.php b/src/Bundle/ChillMainBundle/Doctrine/DQL/Extract.php index 72ca2b461..7d8809582 100644 --- a/src/Bundle/ChillMainBundle/Doctrine/DQL/Extract.php +++ b/src/Bundle/ChillMainBundle/Doctrine/DQL/Extract.php @@ -1,10 +1,18 @@ EXTRACT(field FROM interval) @@ -50,5 +58,4 @@ class Extract extends FunctionNode $parser->match(Lexer::T_CLOSE_PARENTHESIS); } - -} \ No newline at end of file +} diff --git a/src/Bundle/ChillMainBundle/Doctrine/DQL/ToChar.php b/src/Bundle/ChillMainBundle/Doctrine/DQL/ToChar.php index c634555dc..51ff5a9dd 100644 --- a/src/Bundle/ChillMainBundle/Doctrine/DQL/ToChar.php +++ b/src/Bundle/ChillMainBundle/Doctrine/DQL/ToChar.php @@ -1,5 +1,14 @@ fmt = $parser->StringExpression(); $parser->match(Lexer::T_CLOSE_PARENTHESIS); } - -} \ No newline at end of file +} diff --git a/src/Bundle/ChillMainBundle/Export/ExportManager.php b/src/Bundle/ChillMainBundle/Export/ExportManager.php index dee69237f..31092a23b 100644 --- a/src/Bundle/ChillMainBundle/Export/ExportManager.php +++ b/src/Bundle/ChillMainBundle/Export/ExportManager.php @@ -278,16 +278,14 @@ class ExportManager $this->handleAggregators($export, $query, $data[ExportType::AGGREGATOR_KEY], $centers); $this->logger->notice('[export] will execute this qb in export', [ - 'dql' => $query->getDQL() + 'dql' => $query->getDQL(), ]); - } else { throw new UnexpectedValueException('The method `intiateQuery` should return ' . 'a `\\Doctrine\\ORM\\NativeQuery` or a `Doctrine\\ORM\\QueryBuilder` ' . 'object.'); } - $result = $export->getResult($query, $data[ExportType::EXPORT_KEY]); if (!is_iterable($result)) { diff --git a/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceBaseImporter.php b/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceBaseImporter.php index 6f1d218a9..474cb53de 100644 --- a/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceBaseImporter.php +++ b/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceBaseImporter.php @@ -16,6 +16,7 @@ use Doctrine\DBAL\Statement; use Exception; use LogicException; use Psr\Log\LoggerInterface; +use RuntimeException; use function array_key_exists; use function count; @@ -159,8 +160,8 @@ final class AddressReferenceBaseImporter try { $affected = $statement->executeStatement(array_merge(...$this->waitingForInsert)); - if ($affected === 0) { - throw new \RuntimeException('no row affected'); + if (0 === $affected) { + throw new RuntimeException('no row affected'); } } catch (Exception $e) { // in some case, we can add debug code here diff --git a/src/Bundle/ChillMainBundle/Tests/Services/Import/AddressReferenceBaseImporterTest.php b/src/Bundle/ChillMainBundle/Tests/Services/Import/AddressReferenceBaseImporterTest.php index cb23634f1..0ed1f2059 100644 --- a/src/Bundle/ChillMainBundle/Tests/Services/Import/AddressReferenceBaseImporterTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Services/Import/AddressReferenceBaseImporterTest.php @@ -1,5 +1,14 @@ setRefPostalCodeId($postalCodeId = '1234'.uniqid()) + ->setRefPostalCodeId($postalCodeId = '1234' . uniqid()) ->setPostalCodeSource('testing') ->setCode('TEST456') ->setName('testing'); @@ -54,7 +70,8 @@ class AddressReferenceBaseImporterTest extends KernelTestCase $addresses = $this->addressReferenceRepository->findByPostalCodePattern( $postalCode, - 'Rue test abcc guessed'); + 'Rue test abcc guessed' + ); $this->assertCount(1, $addresses); $this->assertEquals('Rue test abccc-guessed', $addresses[0]->getStreet()); @@ -79,12 +96,11 @@ class AddressReferenceBaseImporterTest extends KernelTestCase $addresses = $this->addressReferenceRepository->findByPostalCodePattern( $postalCode, - 'abcc guessed fixed'); + 'abcc guessed fixed' + ); $this->assertCount('1', $addresses); - $this->assertEquals( 'Rue test abccc guessed fixed', $addresses[0]->getStreet()); + $this->assertEquals('Rue test abccc guessed fixed', $addresses[0]->getStreet()); $this->assertEquals($previousAddressId, $addresses[0]->getId()); } - - -} \ No newline at end of file +} diff --git a/src/Bundle/ChillMainBundle/Tests/Services/Import/PostalCodeBaseImporterTest.php b/src/Bundle/ChillMainBundle/Tests/Services/Import/PostalCodeBaseImporterTest.php index 826e581ac..ce40d40bf 100644 --- a/src/Bundle/ChillMainBundle/Tests/Services/Import/PostalCodeBaseImporterTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Services/Import/PostalCodeBaseImporterTest.php @@ -1,5 +1,14 @@ importer->importCode( 'BE', - 'tested with pattern '. ($uniqid = uniqid()), + 'tested with pattern ' . ($uniqid = uniqid()), '12345', - $refPostalCodeId = 'test'.uniqid(), + $refPostalCodeId = 'test' . uniqid(), 'test', 50.0, 5.0, @@ -46,8 +59,8 @@ class PostalCodeBaseImporterTest extends KernelTestCase $this->importer->finalize(); $postalCodes = $this->postalCodeRepository->findByPattern( - 'with pattern '.$uniqid, - $this->countryRepository->findOneBy(['countryCode' => 'BE']) + 'with pattern ' . $uniqid, + $this->countryRepository->findOneBy(['countryCode' => 'BE']) ); $this->assertCount(1, $postalCodes); @@ -59,7 +72,7 @@ class PostalCodeBaseImporterTest extends KernelTestCase $this->importer->importCode( 'BE', - 'tested with adapted pattern '. ($uniqid = uniqid()), + 'tested with adapted pattern ' . ($uniqid = uniqid()), '12345', $refPostalCodeId, 'test', @@ -71,7 +84,7 @@ class PostalCodeBaseImporterTest extends KernelTestCase $this->importer->finalize(); $postalCodes = $this->postalCodeRepository->findByPattern( - 'with pattern '.$uniqid, + 'with pattern ' . $uniqid, $this->countryRepository->findOneBy(['countryCode' => 'BE']) ); @@ -79,7 +92,4 @@ class PostalCodeBaseImporterTest extends KernelTestCase $this->assertStringStartsWith('tested with adapted pattern', $postalCodes[0]->getName()); $this->assertEquals($previousId, $postalCodes[0]->getId()); } - - - -} \ No newline at end of file +} diff --git a/src/Bundle/ChillMainBundle/Tests/Workflow/EventSubscriber/NotificationOnTransitionTest.php b/src/Bundle/ChillMainBundle/Tests/Workflow/EventSubscriber/NotificationOnTransitionTest.php index 3aa2c71b1..365b01a67 100644 --- a/src/Bundle/ChillMainBundle/Tests/Workflow/EventSubscriber/NotificationOnTransitionTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Workflow/EventSubscriber/NotificationOnTransitionTest.php @@ -1,5 +1,14 @@ setWorkflowName('workflow_name') - ->setRelatedEntityClass(\stdClass::class) - ->setRelatedEntityId(1) - ; + ->setRelatedEntityClass(stdClass::class) + ->setRelatedEntityId(1); // force an id to entityWorkflow: - $reflection = new \ReflectionClass($entityWorkflow); + $reflection = new ReflectionClass($entityWorkflow); $id = $reflection->getProperty('id'); $id->setAccessible(true); $id->setValue($entityWorkflow, 1); @@ -48,12 +62,11 @@ class NotificationOnTransitionTest extends TestCase $step = new EntityWorkflowStep(); $entityWorkflow->addStep($step); $step->addDestUser($dest) - ->setCurrentStep('to_state') - ; + ->setCurrentStep('to_state'); $em = $this->prophesize(EntityManagerInterface::class); $em->persist(Argument::type(Notification::class))->should( - function($args) use ($dest) { + static function ($args) use ($dest) { /** @var Call[] $args */ if (1 !== count($args)) { throw new FailedPredictionException('no notification sent'); @@ -68,7 +81,8 @@ class NotificationOnTransitionTest extends TestCase if (!$notification->getAddressees()->contains($dest)) { throw new FailedPredictionException('the dest is not notified'); } - }); + } + ); $engine = $this->prophesize(EngineInterface::class); $engine->render(Argument::type('string'), Argument::type('array')) diff --git a/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/EntityWorkflowTransitionEventSubscriber.php b/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/EntityWorkflowTransitionEventSubscriber.php index 2510f9460..0f6a4799a 100644 --- a/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/EntityWorkflowTransitionEventSubscriber.php +++ b/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/EntityWorkflowTransitionEventSubscriber.php @@ -41,6 +41,24 @@ class EntityWorkflowTransitionEventSubscriber implements EventSubscriberInterfac $this->userRender = $userRender; } + public function addDests(Event $event): void + { + if (!$event->getSubject() instanceof EntityWorkflow) { + return; + } + + /** @var EntityWorkflow $entityWorkflow */ + $entityWorkflow = $event->getSubject(); + + foreach ($entityWorkflow->futureDestUsers as $user) { + $entityWorkflow->getCurrentStep()->addDestUser($user); + } + + foreach ($entityWorkflow->futureDestEmails as $email) { + $entityWorkflow->getCurrentStep()->addDestEmail($email); + } + } + public static function getSubscribedEvents(): array { return [ @@ -55,23 +73,6 @@ class EntityWorkflowTransitionEventSubscriber implements EventSubscriberInterfac ]; } - public function addDests(Event $event): void - { - if (!$event->getSubject() instanceof EntityWorkflow) { - return; - } - - /** @var EntityWorkflow $entityWorkflow */ - $entityWorkflow = $event->getSubject(); - foreach ($entityWorkflow->futureDestUsers as $user) { - $entityWorkflow->getCurrentStep()->addDestUser($user); - } - - foreach ($entityWorkflow->futureDestEmails as $email) { - $entityWorkflow->getCurrentStep()->addDestEmail($email); - } - } - public function guardEntityWorkflow(GuardEvent $event) { if (!$event->getSubject() instanceof EntityWorkflow) { diff --git a/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/NotificationOnTransition.php b/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/NotificationOnTransition.php index 982a7024e..c56dc34ce 100644 --- a/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/NotificationOnTransition.php +++ b/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/NotificationOnTransition.php @@ -57,14 +57,15 @@ class NotificationOnTransition implements EventSubscriberInterface } /** - * Send a notification to: + * Send a notification to:. * * * the dests of the new step; * * the users which subscribed to workflow, on each step, or on final * * **Warning** take care that this method must be executed **after** the dest users are added to - * the step (@link{EntityWorkflowStep::addDestUser}). Currently, this is done during - * @link{EntityWorkflowTransitionEventSubscriber::addDests}. + * the step (@see{EntityWorkflowStep::addDestUser}). Currently, this is done during + * + * @see{EntityWorkflowTransitionEventSubscriber::addDests}. */ public function onCompletedSendNotification(Event $event): void { @@ -77,6 +78,7 @@ class NotificationOnTransition implements EventSubscriberInterface /** @var array $dests array of unique values, where keys is the object's hash */ $dests = []; + foreach (array_merge( // the subscriber to each step $entityWorkflow->getSubscriberToStep()->toArray(), diff --git a/src/Bundle/ChillMainBundle/migrations/Version20220730204216.php b/src/Bundle/ChillMainBundle/migrations/Version20220730204216.php index 4ed1b2918..e4ad98318 100644 --- a/src/Bundle/ChillMainBundle/migrations/Version20220730204216.php +++ b/src/Bundle/ChillMainBundle/migrations/Version20220730204216.php @@ -1,5 +1,12 @@ addSql('DROP INDEX chill_main_address_reference_unicity'); + } + public function getDescription(): string { return 'Add an unique constraint on addresses references'; @@ -18,9 +30,4 @@ final class Version20220730204216 extends AbstractMigration { $this->addSql('CREATE UNIQUE INDEX chill_main_address_reference_unicity ON chill_main_address_reference (refId, source)'); } - - public function down(Schema $schema): void - { - $this->addSql('DROP INDEX chill_main_address_reference_unicity'); - } } diff --git a/src/Bundle/ChillMainBundle/migrations/Version20220829132409.php b/src/Bundle/ChillMainBundle/migrations/Version20220829132409.php index 0bb09ef74..0da81d182 100644 --- a/src/Bundle/ChillMainBundle/migrations/Version20220829132409.php +++ b/src/Bundle/ChillMainBundle/migrations/Version20220829132409.php @@ -1,5 +1,12 @@ addSql('DROP SEQUENCE chill_main_geographical_unit_id_seq CASCADE'); + $this->addSql('DROP TABLE chill_main_geographical_unit'); + } + public function getDescription(): string { return 'Add new entity GeographicalUnit'; @@ -22,10 +35,4 @@ final class Version20220829132409 extends AbstractMigration $this->addSql('CREATE SEQUENCE chill_main_geographical_unit_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); $this->addSql('CREATE TABLE chill_main_geographical_unit (id INT NOT NULL, geom TEXT DEFAULT NULL, layerName VARCHAR(255) DEFAULT NULL, unitName VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id))'); } - - public function down(Schema $schema): void - { - $this->addSql('DROP SEQUENCE chill_main_geographical_unit_id_seq CASCADE'); - $this->addSql('DROP TABLE chill_main_geographical_unit'); - } } diff --git a/src/Bundle/ChillPersonBundle/Controller/HouseholdCompositionTypeController.php b/src/Bundle/ChillPersonBundle/Controller/HouseholdCompositionTypeController.php index eb1dc1ea9..e7fc5b203 100644 --- a/src/Bundle/ChillPersonBundle/Controller/HouseholdCompositionTypeController.php +++ b/src/Bundle/ChillPersonBundle/Controller/HouseholdCompositionTypeController.php @@ -23,4 +23,4 @@ class HouseholdCompositionTypeController extends CRUDController return parent::orderQuery($action, $query, $request, $paginator); } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php index efbb972c1..47b414ce2 100644 --- a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php +++ b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php @@ -95,6 +95,7 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac $loader->load('services/accompanyingPeriodConsistency.yaml'); $loader->load('services/exports_person.yaml'); + if ($container->getParameter('chill_person.accompanying_period') !== 'hidden') { $loader->load('services/exports_accompanying_period.yaml'); } diff --git a/src/Bundle/ChillPersonBundle/Entity/MaritalStatus.php b/src/Bundle/ChillPersonBundle/Entity/MaritalStatus.php index 649830b4a..05f47ffcf 100644 --- a/src/Bundle/ChillPersonBundle/Entity/MaritalStatus.php +++ b/src/Bundle/ChillPersonBundle/Entity/MaritalStatus.php @@ -31,7 +31,6 @@ class MaritalStatus private ?string $id; /** - * @var array * @ORM\Column(type="json") */ private array $name; diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/AdministrativeLocationAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/AdministrativeLocationAggregator.php index 8d421f369..69d1b265d 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/AdministrativeLocationAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/AdministrativeLocationAggregator.php @@ -1,8 +1,16 @@ translatableStringHelper = $translatableStringHelper; } - /** - * @inheritDoc - */ - public function getLabels($key, array $values, $data) - { - return function ($value): string { - if ('_header' === $value) { - return 'Administrative location'; - } - - $l = $this->locationRepository->find($value); - - return $l->getName() .' ('. $this->translatableStringHelper->localize($l->getLocationType()->getTitle()) . ')'; - }; - } - - /** - * @inheritDoc - */ - public function getQueryKeys($data): array - { - return ['location_aggregator']; - } - - /** - * @inheritDoc - */ - public function buildForm(FormBuilderInterface $builder) - { - // no form - } - - /** - * @inheritDoc - */ - public function getTitle() - { - return 'Group by administrative location'; - } - - /** - * @inheritDoc - */ public function addRole() { return null; } - /** - * @inheritDoc - */ public function alterQuery(QueryBuilder $qb, $data) { $qb->join('acp.administrativeLocation', 'al'); @@ -90,11 +52,36 @@ class AdministrativeLocationAggregator implements AggregatorInterface } } - /** - * @inheritDoc - */ public function applyOn(): string { return Declarations::ACP_TYPE; } -} \ No newline at end of file + + public function buildForm(FormBuilderInterface $builder) + { + // no form + } + + public function getLabels($key, array $values, $data) + { + return function ($value): string { + if ('_header' === $value) { + return 'Administrative location'; + } + + $l = $this->locationRepository->find($value); + + return $l->getName() . ' (' . $this->translatableStringHelper->localize($l->getLocationType()->getTitle()) . ')'; + }; + } + + public function getQueryKeys($data): array + { + return ['location_aggregator']; + } + + public function getTitle() + { + return 'Group by administrative location'; + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregator.php index 198cacea7..d525f2f9b 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregator.php @@ -1,12 +1,20 @@ translatableStringHelper = $translatableStringHelper; } - /** - * @inheritDoc - */ - public function getLabels($key, array $values, $data) - { - return function ($value): string { - if ('_header' === $value) { - return 'Closing motive'; - } - - $cm = $this->motiveRepository->find($value); - - return $this->translatableStringHelper->localize( - $cm->getName() - ); - }; - } - - /** - * @inheritDoc - */ - public function getQueryKeys($data) - { - return ['closingmotive_aggregator']; - } - - /** - * @inheritDoc - */ - public function buildForm(FormBuilderInterface $builder) - { - // no form - } - - /** - * @inheritDoc - */ - public function getTitle(): string - { - return 'Group by closing motive'; - } - - /** - * @inheritDoc - */ public function addRole() { return null; } - /** - * @inheritDoc - */ public function alterQuery(QueryBuilder $qb, $data) { $qb->join('acp.closingMotive', 'cm'); @@ -93,11 +53,38 @@ class ClosingMotiveAggregator implements AggregatorInterface } } - /** - * @inheritDoc - */ public function applyOn(): string { return Declarations::ACP_TYPE; } -} \ No newline at end of file + + public function buildForm(FormBuilderInterface $builder) + { + // no form + } + + public function getLabels($key, array $values, $data) + { + return function ($value): string { + if ('_header' === $value) { + return 'Closing motive'; + } + + $cm = $this->motiveRepository->find($value); + + return $this->translatableStringHelper->localize( + $cm->getName() + ); + }; + } + + public function getQueryKeys($data) + { + return ['closingmotive_aggregator']; + } + + public function getTitle(): string + { + return 'Group by closing motive'; + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ConfidentialAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ConfidentialAggregator.php index d2bec5c32..534ef268a 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ConfidentialAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ConfidentialAggregator.php @@ -1,5 +1,14 @@ translator = $translator; } - /** - * @inheritDoc - */ - public function getLabels($key, array $values, $data) - { - return function ($value): string { - if ($value === '_header') { - return 'Confidentiality'; - } - switch ($value) { - - case true: - return $this->translator->trans('is confidential'); - - case false: - return $this->translator->trans('is not confidential'); - - default: - throw new LogicException(sprintf('The value %s is not valid', $value)); - } - return $value; - }; - } - - /** - * @inheritDoc - */ - public function getQueryKeys($data): array - { - return ['confidential_aggregator']; - } - - /** - * @inheritDoc - */ - public function buildForm(FormBuilderInterface $builder) - { - // no form - } - - /** - * @inheritDoc - */ - public function getTitle(): string - { - return 'Group by confidential'; - } - - /** - * @inheritDoc - */ public function addRole() { return null; } - /** - * @inheritDoc - */ public function alterQuery(QueryBuilder $qb, $data) { $qb->addSelect('acp.confidential AS confidential_aggregator'); @@ -90,11 +45,45 @@ class ConfidentialAggregator implements AggregatorInterface } } - /** - * @inheritDoc - */ public function applyOn(): string { return Declarations::ACP_TYPE; } -} \ No newline at end of file + + public function buildForm(FormBuilderInterface $builder) + { + // no form + } + + public function getLabels($key, array $values, $data) + { + return function ($value): string { + if ('_header' === $value) { + return 'Confidentiality'; + } + + switch ($value) { + case true: + return $this->translator->trans('is confidential'); + + case false: + return $this->translator->trans('is not confidential'); + + default: + throw new LogicException(sprintf('The value %s is not valid', $value)); + } + + return $value; + }; + } + + public function getQueryKeys($data): array + { + return ['confidential_aggregator']; + } + + public function getTitle(): string + { + return 'Group by confidential'; + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/DurationAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/DurationAggregator.php index 2a0215e82..ba6a1d3df 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/DurationAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/DurationAggregator.php @@ -1,14 +1,19 @@ translator = $translator; } - /** - * @inheritDoc - */ - public function getLabels($key, array $values, $data) - { - return function ($value) use ($data): string { - - if ($value === '_header') { - return $this->translator->trans('Rounded month duration'); - } - - if ($value === null) { - return $this->translator->trans('current duration'); // when closingDate is null - } - - if ($value === 0) { - return $this->translator->trans("duration 0 month"); - } - - return ''. $value . $this->translator->trans(' months'); - }; - } - - /** - * @inheritDoc - */ - public function getQueryKeys($data): array - { - return ['duration_aggregator']; - } - - /** - * @inheritDoc - */ - public function buildForm(FormBuilderInterface $builder) - { - // no form - } - - /** - * @inheritDoc - */ - public function getTitle(): string - { - return 'Group by duration'; - } - - /** - * @inheritDoc - */ public function addRole() { return null; } - /** - * @inheritDoc - */ public function alterQuery(QueryBuilder $qb, $data) { $qb // OUI - ->addSelect(' - (acp.closingDate - acp.openingDate +15) *12/365 + ->addSelect( + ' + (acp.closingDate - acp.openingDate +15) *12/365 AS duration_aggregator' ) //->addSelect('DATE_DIFF(acp.closingDate, acp.openingDate) AS duration_aggregator') @@ -124,8 +77,8 @@ class DurationAggregator implements AggregatorInterface ELSE EXTRACT(month FROM DATE_DIFF(acp.closingDate, acp.openingDate)) END ) AS duration_aggregator ') - */ - ; + */ +; $groupBy = $qb->getDQLPart('groupBy'); @@ -138,11 +91,42 @@ class DurationAggregator implements AggregatorInterface $qb->orderBy('duration_aggregator'); } - /** - * @inheritDoc - */ public function applyOn(): string { return Declarations::ACP_TYPE; } -} \ No newline at end of file + + public function buildForm(FormBuilderInterface $builder) + { + // no form + } + + public function getLabels($key, array $values, $data) + { + return function ($value): string { + if ('_header' === $value) { + return $this->translator->trans('Rounded month duration'); + } + + if (null === $value) { + return $this->translator->trans('current duration'); // when closingDate is null + } + + if (0 === $value) { + return $this->translator->trans('duration 0 month'); + } + + return '' . $value . $this->translator->trans(' months'); + }; + } + + public function getQueryKeys($data): array + { + return ['duration_aggregator']; + } + + public function getTitle(): string + { + return 'Group by duration'; + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EmergencyAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EmergencyAggregator.php index c5991e7f0..4bee25a39 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EmergencyAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EmergencyAggregator.php @@ -1,5 +1,14 @@ translator = $translator; } - /** - * @inheritDoc - */ - public function getLabels($key, array $values, $data) - { - return function ($value): string { - if ($value === '_header') { - return 'Emergency'; - } - switch ($value) { - - case true: - return $this->translator->trans('is emergency'); - - case false: - return $this->translator->trans('is not emergency'); - - default: - throw new LogicException(sprintf('The value %s is not valid', $value)); - } - return $value; - }; - } - - /** - * @inheritDoc - */ - public function getQueryKeys($data): array - { - return ['emergency_aggregator']; - } - - /** - * @inheritDoc - */ - public function buildForm(FormBuilderInterface $builder) - { - // no form - } - - /** - * @inheritDoc - */ - public function getTitle(): string - { - return 'Group by emergency'; - } - - /** - * @inheritDoc - */ public function addRole() { return null; } - /** - * @inheritDoc - */ public function alterQuery(QueryBuilder $qb, $data) { $qb->addSelect('acp.emergency AS emergency_aggregator'); @@ -90,11 +45,45 @@ class EmergencyAggregator implements AggregatorInterface } } - /** - * @inheritDoc - */ public function applyOn(): string { return Declarations::ACP_TYPE; } -} \ No newline at end of file + + public function buildForm(FormBuilderInterface $builder) + { + // no form + } + + public function getLabels($key, array $values, $data) + { + return function ($value): string { + if ('_header' === $value) { + return 'Emergency'; + } + + switch ($value) { + case true: + return $this->translator->trans('is emergency'); + + case false: + return $this->translator->trans('is not emergency'); + + default: + throw new LogicException(sprintf('The value %s is not valid', $value)); + } + + return $value; + }; + } + + public function getQueryKeys($data): array + { + return ['emergency_aggregator']; + } + + public function getTitle(): string + { + return 'Group by emergency'; + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EvaluationAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EvaluationAggregator.php index 3f98c7003..4c9fefe31 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EvaluationAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EvaluationAggregator.php @@ -1,5 +1,14 @@ translatableStringHelper = $translatableStringHelper; } - /** - * @inheritDoc - */ - public function getLabels($key, array $values, $data) - { - return function ($value): string { - if ('_header' === $value) { - return 'Evaluation'; - } - - $e = $this->evaluationRepository->find($value); - - return $this->translatableStringHelper->localize( - $e->getTitle() - ); - }; - } - - /** - * @inheritDoc - */ - public function getQueryKeys($data): array - { - return ['evaluation_aggregator']; - } - - /** - * @inheritDoc - */ - public function buildForm(FormBuilderInterface $builder) - { - // no form - } - - /** - * @inheritDoc - */ - public function getTitle(): string - { - return 'Group by evaluation'; - } - - /** - * @inheritDoc - */ public function addRole() { return null; } - /** - * @inheritDoc - */ public function alterQuery(QueryBuilder $qb, $data) { - if (!in_array('acpw', $qb->getAllAliases())) { + if (!in_array('acpw', $qb->getAllAliases(), true)) { $qb->join('acp.works', 'acpw'); } $qb->join('acpw.accompanyingPeriodWorkEvaluations', 'we'); @@ -94,11 +56,38 @@ final class EvaluationAggregator implements AggregatorInterface } } - /** - * @inheritDoc - */ public function applyOn(): string { return Declarations::ACP_TYPE; } -} \ No newline at end of file + + public function buildForm(FormBuilderInterface $builder) + { + // no form + } + + public function getLabels($key, array $values, $data) + { + return function ($value): string { + if ('_header' === $value) { + return 'Evaluation'; + } + + $e = $this->evaluationRepository->find($value); + + return $this->translatableStringHelper->localize( + $e->getTitle() + ); + }; + } + + public function getQueryKeys($data): array + { + return ['evaluation_aggregator']; + } + + public function getTitle(): string + { + return 'Group by evaluation'; + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/IntensityAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/IntensityAggregator.php index 8da38b766..5962654c0 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/IntensityAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/IntensityAggregator.php @@ -1,5 +1,14 @@ translator = $translator; } - /** - * @inheritDoc - */ - public function getLabels($key, array $values, $data) - { - return function ($value): string { - if ($value === '_header') { - return 'Intensity'; - } - switch ($value) { - case 'occasional': - return $this->translator->trans('is occasional'); - case 'regular': - return $this->translator->trans('is regular'); - default: - throw new LogicException(sprintf('The value %s is not valid', $value)); - } - }; - } - - /** - * @inheritDoc - */ - public function getQueryKeys($data): array - { - return ['intensity_aggregator']; - } - - /** - * @inheritDoc - */ - public function buildForm(FormBuilderInterface $builder) - { - // no form - } - - /** - * @inheritDoc - */ - public function getTitle(): string - { - return 'Group by intensity'; - } - - /** - * @inheritDoc - */ public function addRole() { return null; } - /** - * @inheritDoc - */ public function alterQuery(QueryBuilder $qb, $data) { $qb->addSelect('acp.intensity AS intensity_aggregator'); @@ -86,11 +45,43 @@ class IntensityAggregator implements AggregatorInterface } } - /** - * @inheritDoc - */ public function applyOn(): string { return Declarations::ACP_TYPE; } -} \ No newline at end of file + + public function buildForm(FormBuilderInterface $builder) + { + // no form + } + + public function getLabels($key, array $values, $data) + { + return function ($value): string { + if ('_header' === $value) { + return 'Intensity'; + } + + switch ($value) { + case 'occasional': + return $this->translator->trans('is occasional'); + + case 'regular': + return $this->translator->trans('is regular'); + + default: + throw new LogicException(sprintf('The value %s is not valid', $value)); + } + }; + } + + public function getQueryKeys($data): array + { + return ['intensity_aggregator']; + } + + public function getTitle(): string + { + return 'Group by intensity'; + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/JobAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/JobAggregator.php index 31b3fca66..c5c9c3180 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/JobAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/JobAggregator.php @@ -1,18 +1,25 @@ translatableStringHelper = $translatableStringHelper; } - /** - * @inheritDoc - */ - public function getLabels($key, array $values, $data) - { - return function($value): string { - if ($value === '_header') { - return 'Job'; - } - - $j = $this->jobRepository->find($value); - - return $this->translatableStringHelper->localize( - $j->getLabel() - ); - }; - } - - /** - * @inheritDoc - */ - public function getQueryKeys($data): array - { - return ['job_aggregator']; - } - - /** - * @inheritDoc - */ - public function buildForm(FormBuilderInterface $builder) - { - // no form - } - - /** - * @inheritDoc - */ - public function getTitle(): string - { - return 'Group by user job'; - } - - /** - * @inheritDoc - */ public function addRole() { return null; } - /** - * @inheritDoc - */ public function alterQuery(QueryBuilder $qb, $data) { $qb->join('acp.job', 'j'); @@ -93,11 +52,38 @@ final class JobAggregator implements AggregatorInterface } } - /** - * @inheritDoc - */ public function applyOn(): string { return Declarations::ACP_TYPE; } -} \ No newline at end of file + + public function buildForm(FormBuilderInterface $builder) + { + // no form + } + + public function getLabels($key, array $values, $data) + { + return function ($value): string { + if ('_header' === $value) { + return 'Job'; + } + + $j = $this->jobRepository->find($value); + + return $this->translatableStringHelper->localize( + $j->getLabel() + ); + }; + } + + public function getQueryKeys($data): array + { + return ['job_aggregator']; + } + + public function getTitle(): string + { + return 'Group by user job'; + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/OriginAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/OriginAggregator.php index 2bb131435..7c4ad76fd 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/OriginAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/OriginAggregator.php @@ -1,5 +1,14 @@ translatableStringHelper = $translatableStringHelper; } - /** - * @inheritDoc - */ - public function getLabels($key, array $values, $data) - { - return function ($value): string { - if ('_header' === $value) { - return 'Origin'; - } - - $o = $this->repository->find($value); - - return $this->translatableStringHelper->localize( - $o->getLabel() - ); - }; - } - - /** - * @inheritDoc - */ - public function getQueryKeys($data): array - { - return ['origin_aggregator']; - } - - /** - * @inheritDoc - */ - public function buildForm(FormBuilderInterface $builder) - { - // no form - } - - /** - * @inheritDoc - */ - public function getTitle(): string - { - return 'Group by origin'; - } - - /** - * @inheritDoc - */ public function addRole() { return null; } - /** - * @inheritDoc - */ public function alterQuery(QueryBuilder $qb, $data) { $qb->join('acp.origin', 'o'); @@ -93,11 +54,38 @@ final class OriginAggregator implements AggregatorInterface } } - /** - * @inheritDoc - */ public function applyOn(): string { return Declarations::ACP_TYPE; } -} \ No newline at end of file + + public function buildForm(FormBuilderInterface $builder) + { + // no form + } + + public function getLabels($key, array $values, $data) + { + return function ($value): string { + if ('_header' === $value) { + return 'Origin'; + } + + $o = $this->repository->find($value); + + return $this->translatableStringHelper->localize( + $o->getLabel() + ); + }; + } + + public function getQueryKeys($data): array + { + return ['origin_aggregator']; + } + + public function getTitle(): string + { + return 'Group by origin'; + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerAggregator.php index 56522f2ed..323a17e26 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerAggregator.php @@ -15,16 +15,15 @@ use Chill\MainBundle\Export\AggregatorInterface; use Chill\MainBundle\Repository\UserRepository; use Chill\MainBundle\Templating\Entity\UserRender; use Chill\PersonBundle\Export\Declarations; -use Doctrine\ORM\Query\Expr\From; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; final class ReferrerAggregator implements AggregatorInterface { - private UserRepository $userRepository; - private UserRender $userRender; + private UserRepository $userRepository; + public function __construct( UserRepository $userRepository, UserRender $userRender @@ -51,7 +50,6 @@ final class ReferrerAggregator implements AggregatorInterface } else { $qb->groupBy('referrer_aggregator'); } - } public function applyOn(): string diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ScopeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ScopeAggregator.php index 5bddac42b..46187d558 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ScopeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ScopeAggregator.php @@ -1,18 +1,25 @@ translatableStringHelper = $translatableStringHelper; } - /** - * @inheritDoc - */ - public function getLabels($key, array $values, $data) - { - return function ($value): string { - if ($value === '_header') { - return 'Scope'; - } - - $s = $this->scopeRepository->find($value); - - return $this->translatableStringHelper->localize( - $s->getName() - ); - }; - } - - /** - * @inheritDoc - */ - public function getQueryKeys($data): array - { - return ['scope_aggregator']; - } - - /** - * @inheritDoc - */ - public function buildForm(FormBuilderInterface $builder) - { - // no form - } - - /** - * @inheritDoc - */ - public function getTitle(): string - { - return 'Group by user scope'; - } - - /** - * @inheritDoc - */ public function addRole() { return null; } - /** - * @inheritDoc - */ public function alterQuery(QueryBuilder $qb, $data) { $qb->join('acp.scopes', 's'); @@ -93,11 +52,38 @@ final class ScopeAggregator implements AggregatorInterface } } - /** - * @inheritDoc - */ public function applyOn(): string { return Declarations::ACP_TYPE; } -} \ No newline at end of file + + public function buildForm(FormBuilderInterface $builder) + { + // no form + } + + public function getLabels($key, array $values, $data) + { + return function ($value): string { + if ('_header' === $value) { + return 'Scope'; + } + + $s = $this->scopeRepository->find($value); + + return $this->translatableStringHelper->localize( + $s->getName() + ); + }; + } + + public function getQueryKeys($data): array + { + return ['scope_aggregator']; + } + + public function getTitle(): string + { + return 'Group by user scope'; + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialActionAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialActionAggregator.php index a9257bd8e..f28cd559b 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialActionAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialActionAggregator.php @@ -1,5 +1,14 @@ actionRepository = $actionRepository; } - /** - * @inheritDoc - */ - public function getLabels($key, array $values, $data) - { - return function($value) { - if ('_header' === $value) { - return 'Social action'; - } - - $sa = $this->actionRepository->find($value); - - return $this->actionRender->renderString($sa, []); - }; - } - - /** - * @inheritDoc - */ - public function getQueryKeys($data): array - { - return ['socialaction_aggregator']; - } - - /** - * @inheritDoc - */ - public function buildForm(FormBuilderInterface $builder) - { - // no form - } - - /** - * @inheritDoc - */ - public function getTitle(): string - { - return 'Group by social action'; - } - - /** - * @inheritDoc - */ public function addRole() { return null; } - /** - * @inheritDoc - */ public function alterQuery(QueryBuilder $qb, $data) { - if (!in_array('acpw', $qb->getAllAliases())) { + if (!in_array('acpw', $qb->getAllAliases(), true)) { $qb->join('acp.works', 'acpw'); } @@ -91,11 +55,36 @@ final class SocialActionAggregator implements AggregatorInterface } } - /** - * @inheritDoc - */ public function applyOn(): string { return Declarations::ACP_TYPE; } -} \ No newline at end of file + + public function buildForm(FormBuilderInterface $builder) + { + // no form + } + + public function getLabels($key, array $values, $data) + { + return function ($value) { + if ('_header' === $value) { + return 'Social action'; + } + + $sa = $this->actionRepository->find($value); + + return $this->actionRender->renderString($sa, []); + }; + } + + public function getQueryKeys($data): array + { + return ['socialaction_aggregator']; + } + + public function getTitle(): string + { + return 'Group by social action'; + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialIssueAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialIssueAggregator.php index fe2830d00..362d8e666 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialIssueAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialIssueAggregator.php @@ -1,5 +1,14 @@ issueRender = $issueRender; } - /** - * @inheritDoc - */ - public function getLabels($key, array $values, $data) - { - return function ($value): string { - - if ($value === '_header') { - return 'Social issues'; - } - - $i = $this->issueRepository->find($value); - - return $this->issueRender->renderString($i, []); - }; - } - - /** - * @inheritDoc - */ - public function getQueryKeys($data): array - { - return ['socialissue_aggregator']; - } - - /** - * @inheritDoc - */ - public function buildForm(FormBuilderInterface $builder) - { - // no form - } - - /** - * @inheritDoc - */ - public function getTitle(): string - { - return 'Group by social issue'; - } - - /** - * @inheritDoc - */ public function addRole() { return null; } - /** - * @inheritDoc - */ public function alterQuery(QueryBuilder $qb, $data) { $qb->join('acp.socialIssues', 'si'); @@ -90,11 +51,36 @@ final class SocialIssueAggregator implements AggregatorInterface } } - /** - * @inheritDoc - */ public function applyOn(): string { return Declarations::ACP_TYPE; } -} \ No newline at end of file + + public function buildForm(FormBuilderInterface $builder) + { + // no form + } + + public function getLabels($key, array $values, $data) + { + return function ($value): string { + if ('_header' === $value) { + return 'Social issues'; + } + + $i = $this->issueRepository->find($value); + + return $this->issueRender->renderString($i, []); + }; + } + + public function getQueryKeys($data): array + { + return ['socialissue_aggregator']; + } + + public function getTitle(): string + { + return 'Group by social issue'; + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/StepAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/StepAggregator.php index 9b21373a8..7d3423a04 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/StepAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/StepAggregator.php @@ -1,5 +1,14 @@ translator = $translator; } - /** - * @inheritDoc - */ - public function getLabels($key, array $values, $data) - { - return function ($value): string { - switch ($value) { - - case AccompanyingPeriod::STEP_DRAFT: - return $this->translator->trans('Draft'); - - case AccompanyingPeriod::STEP_CONFIRMED: - return $this->translator->trans('Confirmed'); - - case AccompanyingPeriod::STEP_CLOSED: - return $this->translator->trans('Closed'); - - case '_header': - return 'Step'; - - default: - throw new LogicException(sprintf('The value %s is not valid', $value)); - } - }; - } - - /** - * @inheritDoc - */ - public function getQueryKeys($data): array - { - return ['step_aggregator']; - } - - /** - * @inheritDoc - */ - public function buildForm(FormBuilderInterface $builder) - { - $builder->add('on_date', ChillDateType::class, [ - 'data' => new \DateTime(), - ]); - } - - /** - * @inheritDoc - */ - public function getTitle(): string - { - return 'Group by step'; - } - - /** - * @inheritDoc - */ public function addRole() { return null; } - /** - * @inheritDoc - */ public function alterQuery(QueryBuilder $qb, $data) { $qb->addSelect('acp.step AS step_aggregator'); @@ -119,14 +71,50 @@ final class StepAggregator implements AggregatorInterface //, FilterInterface $qb->setParameter('ondate', $data['on_date'], Types::DATE_MUTABLE); } - /** - * @inheritDoc - */ public function applyOn(): string { return Declarations::ACP_TYPE; } + public function buildForm(FormBuilderInterface $builder) + { + $builder->add('on_date', ChillDateType::class, [ + 'data' => new DateTime(), + ]); + } + + public function getLabels($key, array $values, $data) + { + return function ($value): string { + switch ($value) { + case AccompanyingPeriod::STEP_DRAFT: + return $this->translator->trans('Draft'); + + case AccompanyingPeriod::STEP_CONFIRMED: + return $this->translator->trans('Confirmed'); + + case AccompanyingPeriod::STEP_CLOSED: + return $this->translator->trans('Closed'); + + case '_header': + return 'Step'; + + default: + throw new LogicException(sprintf('The value %s is not valid', $value)); + } + }; + } + + public function getQueryKeys($data): array + { + return ['step_aggregator']; + } + + public function getTitle(): string + { + return 'Group by step'; + } + /* * TODO check if we need to add FilterInterface and DescribeAction Method to describe date filter ?? * @@ -138,5 +126,5 @@ final class StepAggregator implements AggregatorInterface //, FilterInterface ] ]; } - */ -} \ No newline at end of file + */ +} diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/EvaluationTypeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/EvaluationTypeAggregator.php index e94290925..6c20ae548 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/EvaluationTypeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/EvaluationTypeAggregator.php @@ -1,5 +1,14 @@ translatableStringHelper = $translatableStringHelper; } - /** - * @inheritDoc - */ - public function getLabels($key, array $values, $data) - { - return function ($value): string { - if ($value === '_header') { - return 'Evaluation type'; - } - - $ev = $this->evaluationRepository->find($value); - - return $this->translatableStringHelper->localize($ev->getTitle()); - }; - } - - /** - * @inheritDoc - */ - public function getQueryKeys($data): array - { - return ['evaluationtype_aggregator']; - } - - /** - * @inheritDoc - */ - public function buildForm(FormBuilderInterface $builder) - { - // no form - } - - /** - * @inheritDoc - */ - public function getTitle(): string - { - return 'Group by evaluation type'; - } - - /** - * @inheritDoc - */ public function addRole() { return null; } - /** - * @inheritDoc - */ public function alterQuery(QueryBuilder $qb, $data) { $qb->addSelect('IDENTITY(eval.evaluation) AS evaluationtype_aggregator'); @@ -87,11 +50,36 @@ class EvaluationTypeAggregator implements AggregatorInterface } } - /** - * @inheritDoc - */ public function applyOn(): string { return Declarations::EVAL_TYPE; } -} \ No newline at end of file + + public function buildForm(FormBuilderInterface $builder) + { + // no form + } + + public function getLabels($key, array $values, $data) + { + return function ($value): string { + if ('_header' === $value) { + return 'Evaluation type'; + } + + $ev = $this->evaluationRepository->find($value); + + return $this->translatableStringHelper->localize($ev->getTitle()); + }; + } + + public function getQueryKeys($data): array + { + return ['evaluationtype_aggregator']; + } + + public function getTitle(): string + { + return 'Group by evaluation type'; + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/ChildrenNumberAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/ChildrenNumberAggregator.php index df50b76f0..417941a04 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/ChildrenNumberAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/ChildrenNumberAggregator.php @@ -1,13 +1,24 @@ translator = $translator; } - /** - * @inheritDoc - */ - public function getLabels($key, array $values, $data) - { - return function ($value): string { - - if ($value === '_header') { - return 'Number of children'; - } - - return $this->translator->trans( - 'household_composition.numberOfChildren children in household', [ - 'numberOfChildren' => $value - ]); - }; - } - - /** - * @inheritDoc - */ - public function getQueryKeys($data): array - { - return ['childrennumber_aggregator']; - } - - /** - * @inheritDoc - */ - public function buildForm(FormBuilderInterface $builder) - { - $builder->add('on_date', ChillDateType::class, [ - 'data' => new \DateTime('now'), - ]); - } - - /** - * @inheritDoc - */ - public function getTitle(): string - { - return 'Group by number of children'; - } - - /** - * @inheritDoc - */ public function addRole() { return null; } - /** - * @inheritDoc - */ public function alterQuery(QueryBuilder $qb, $data) { - if (!in_array('composition', $qb->getAllAliases())) { + if (!in_array('composition', $qb->getAllAliases(), true)) { $qb->join('household.compositions', 'composition'); } @@ -102,11 +63,41 @@ class ChildrenNumberAggregator implements AggregatorInterface ); } - /** - * @inheritDoc - */ public function applyOn(): string { return Declarations::HOUSEHOLD_TYPE; } -} \ No newline at end of file + + public function buildForm(FormBuilderInterface $builder) + { + $builder->add('on_date', ChillDateType::class, [ + 'data' => new DateTime('now'), + ]); + } + + public function getLabels($key, array $values, $data) + { + return function ($value): string { + if ('_header' === $value) { + return 'Number of children'; + } + + return $this->translator->trans( + 'household_composition.numberOfChildren children in household', + [ + 'numberOfChildren' => $value, + ] + ); + }; + } + + public function getQueryKeys($data): array + { + return ['childrennumber_aggregator']; + } + + public function getTitle(): string + { + return 'Group by number of children'; + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/CompositionAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/CompositionAggregator.php index 2c6ab174f..429431af6 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/CompositionAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/CompositionAggregator.php @@ -1,5 +1,14 @@ translatableStringHelper = $translatableStringHelper; } - /** - * @inheritDoc - */ - public function getLabels($key, array $values, $data) - { - return function ($value): string { - if ($value === '_header') { - return 'Composition'; - } - - $c = $this->typeRepository->find($value); - - return $this->translatableStringHelper->localize( - $c->getLabel() - ); - }; - } - - /** - * @inheritDoc - */ - public function getQueryKeys($data): array - { - return ['composition_aggregator']; - } - - /** - * @inheritDoc - */ - public function buildForm(FormBuilderInterface $builder) - { - $builder->add('on_date', ChillDateType::class, [ - 'data' => new \DateTime('now'), - ]); - } - - /** - * @inheritDoc - */ - public function getTitle(): string - { - return 'Group by composition'; - } - - /** - * @inheritDoc - */ public function addRole() { return null; } - /** - * @inheritDoc - */ public function alterQuery(QueryBuilder $qb, $data) { - if (!in_array('composition', $qb->getAllAliases())) { + if (!in_array('composition', $qb->getAllAliases(), true)) { $qb->join('household.compositions', 'composition'); } @@ -118,11 +79,40 @@ class CompositionAggregator implements AggregatorInterface $qb->setParameter('ondate', $data['on_date'], Types::DATE_MUTABLE); } - /** - * @inheritDoc - */ public function applyOn(): string { return Declarations::HOUSEHOLD_TYPE; } -} \ No newline at end of file + + public function buildForm(FormBuilderInterface $builder) + { + $builder->add('on_date', ChillDateType::class, [ + 'data' => new DateTime('now'), + ]); + } + + public function getLabels($key, array $values, $data) + { + return function ($value): string { + if ('_header' === $value) { + return 'Composition'; + } + + $c = $this->typeRepository->find($value); + + return $this->translatableStringHelper->localize( + $c->getLabel() + ); + }; + } + + public function getQueryKeys($data): array + { + return ['composition_aggregator']; + } + + public function getTitle(): string + { + return 'Group by composition'; + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/HouseholdPositionAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/HouseholdPositionAggregator.php index ec4a270ac..872b3f9f5 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/HouseholdPositionAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/HouseholdPositionAggregator.php @@ -18,19 +18,18 @@ use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\PersonBundle\Repository\Household\PositionRepository; use DateTime; use Doctrine\ORM\QueryBuilder; -use Symfony\Component\Form\Extension\Core\Type\DateType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Validator\Context\ExecutionContextInterface; use Symfony\Contracts\Translation\TranslatorInterface; final class HouseholdPositionAggregator implements AggregatorInterface, ExportElementValidatedInterface { - private TranslatorInterface $translator; - private PositionRepository $positionRepository; private TranslatableStringHelper $translatableStringHelper; + private TranslatorInterface $translator; + public function __construct(TranslatorInterface $translator, TranslatableStringHelper $translatableStringHelper, PositionRepository $positionRepository) { $this->translator = $translator; @@ -70,7 +69,6 @@ final class HouseholdPositionAggregator implements AggregatorInterface, ExportEl } else { $qb->groupBy('household_position_aggregator'); } - } public function applyOn() diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/MaritalStatusAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/MaritalStatusAggregator.php index 3d4c1f7cd..4a9534a6d 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/MaritalStatusAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/MaritalStatusAggregator.php @@ -18,7 +18,6 @@ use Chill\PersonBundle\Repository\MaritalStatusRepository; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; - final class MaritalStatusAggregator implements AggregatorInterface { private MaritalStatusRepository $maritalStatusRepository; diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/NationalityAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/NationalityAggregator.php index 8c3c0e9a7..fcae239cb 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/NationalityAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/NationalityAggregator.php @@ -124,19 +124,17 @@ final class NationalityAggregator implements AggregatorInterface, ExportElementV ->getQuery() ->getResult(\Doctrine\ORM\Query::HYDRATE_SCALAR); - // initialize array and add blank key for null values $labels = [ '' => $this->translator->trans('without data'), '_header' => $this->translator->trans('Nationality'), ]; - foreach ($countries as $row) { $labels[$row['c_countryCode']] = $this->translatableStringHelper->localize($row['c_name']); } } - + if ('continent' === $data['group_by_level']) { $labels = [ 'EU' => $this->translator->trans('Europe'), @@ -151,10 +149,9 @@ final class NationalityAggregator implements AggregatorInterface, ExportElementV ]; } - return function ($value) use ($labels): string { + return static function ($value) use ($labels): string { return $labels[$value]; }; - } public function getQueryKeys($data) diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregator.php index d8f485561..3ead139ab 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregator.php @@ -47,7 +47,6 @@ final class ActionTypeAggregator implements AggregatorInterface } else { $qb->groupBy('action_type_aggregator'); } - } public function applyOn() diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalAggregator.php index cb908ef3e..b39f8bee0 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalAggregator.php @@ -47,7 +47,6 @@ final class GoalAggregator implements AggregatorInterface } else { $qb->groupBy('goal_aggregator'); } - } public function applyOn() diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/JobAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/JobAggregator.php index ddab1f7cd..c89219f2e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/JobAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/JobAggregator.php @@ -1,18 +1,25 @@ translatableStringHelper = $translatableStringHelper; } - /** - * @inheritDoc - */ - public function getLabels($key, array $values, $data) - { - return function($value): string { - if ($value === '_header') { - return 'Job'; - } - - $j = $this->jobRepository->find($value); - - return $this->translatableStringHelper->localize( - $j->getLabel() - ); - }; - } - - /** - * @inheritDoc - */ - public function getQueryKeys($data): array - { - return ['job_aggregator']; - } - - /** - * @inheritDoc - */ - public function buildForm(FormBuilderInterface $builder) - { - // no form - } - - /** - * @inheritDoc - */ - public function getTitle(): string - { - return 'Group by treating agent job'; - } - - /** - * @inheritDoc - */ public function addRole() { return null; } - /** - * @inheritDoc - */ public function alterQuery(QueryBuilder $qb, $data) { $qb->join('acpw.referrers', 'u'); @@ -93,11 +52,38 @@ final class JobAggregator implements AggregatorInterface } } - /** - * @inheritDoc - */ public function applyOn(): string { return Declarations::SOCIAL_WORK_ACTION_TYPE; } -} \ No newline at end of file + + public function buildForm(FormBuilderInterface $builder) + { + // no form + } + + public function getLabels($key, array $values, $data) + { + return function ($value): string { + if ('_header' === $value) { + return 'Job'; + } + + $j = $this->jobRepository->find($value); + + return $this->translatableStringHelper->localize( + $j->getLabel() + ); + }; + } + + public function getQueryKeys($data): array + { + return ['job_aggregator']; + } + + public function getTitle(): string + { + return 'Group by treating agent job'; + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ReferrerAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ReferrerAggregator.php index 1815ecc19..a6ae042e5 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ReferrerAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ReferrerAggregator.php @@ -15,16 +15,15 @@ use Chill\MainBundle\Export\AggregatorInterface; use Chill\MainBundle\Repository\UserRepository; use Chill\MainBundle\Templating\Entity\UserRender; use Chill\PersonBundle\Export\Declarations; -use Doctrine\ORM\Query\Expr\From; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; final class ReferrerAggregator implements AggregatorInterface { - private UserRepository $userRepository; - private UserRender $userRender; + private UserRepository $userRepository; + public function __construct( UserRepository $userRepository, UserRender $userRender @@ -51,7 +50,6 @@ final class ReferrerAggregator implements AggregatorInterface } else { $qb->groupBy('referrer_aggregator'); } - } public function applyOn(): string diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ResultAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ResultAggregator.php index fc602f973..fa750b486 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ResultAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ResultAggregator.php @@ -49,7 +49,6 @@ final class ResultAggregator implements AggregatorInterface } else { $qb->groupBy('result_aggregator'); } - } public function applyOn() diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ScopeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ScopeAggregator.php index 74a73537c..0e1a7a044 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ScopeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ScopeAggregator.php @@ -1,18 +1,25 @@ translatableStringHelper = $translatableStringHelper; } - /** - * @inheritDoc - */ - public function getLabels($key, array $values, $data) - { - return function ($value): string { - if ($value === '_header') { - return 'Scope'; - } - - $s = $this->scopeRepository->find($value); - - return $this->translatableStringHelper->localize( - $s->getName() - ); - }; - } - - /** - * @inheritDoc - */ - public function getQueryKeys($data): array - { - return ['scope_aggregator']; - } - - /** - * @inheritDoc - */ - public function buildForm(FormBuilderInterface $builder) - { - // no form - } - - /** - * @inheritDoc - */ - public function getTitle(): string - { - return 'Group by treating agent scope'; - } - - /** - * @inheritDoc - */ public function addRole() { return null; } - /** - * @inheritDoc - */ public function alterQuery(QueryBuilder $qb, $data) { $qb->join('acpw.referrers', 'u'); @@ -93,11 +52,38 @@ final class ScopeAggregator implements AggregatorInterface } } - /** - * @inheritDoc - */ public function applyOn(): string { return Declarations::SOCIAL_WORK_ACTION_TYPE; } -} \ No newline at end of file + + public function buildForm(FormBuilderInterface $builder) + { + // no form + } + + public function getLabels($key, array $values, $data) + { + return function ($value): string { + if ('_header' === $value) { + return 'Scope'; + } + + $s = $this->scopeRepository->find($value); + + return $this->translatableStringHelper->localize( + $s->getName() + ); + }; + } + + public function getQueryKeys($data): array + { + return ['scope_aggregator']; + } + + public function getTitle(): string + { + return 'Group by treating agent scope'; + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Declarations.php b/src/Bundle/ChillPersonBundle/Export/Declarations.php index f6c870e4d..0f4d84e3c 100644 --- a/src/Bundle/ChillPersonBundle/Export/Declarations.php +++ b/src/Bundle/ChillPersonBundle/Export/Declarations.php @@ -16,15 +16,15 @@ namespace Chill\PersonBundle\Export; */ abstract class Declarations { - public const PERSON_IMPLIED_IN = 'person_implied_in'; - - public const PERSON_TYPE = 'person'; - public const ACP_TYPE = 'accompanying_period'; - public const SOCIAL_WORK_ACTION_TYPE = 'social_actions'; - public const EVAL_TYPE = 'evaluation'; public const HOUSEHOLD_TYPE = 'household'; + + public const PERSON_IMPLIED_IN = 'person_implied_in'; + + public const PERSON_TYPE = 'person'; + + public const SOCIAL_WORK_ACTION_TYPE = 'social_actions'; } diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php b/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php index a842284f5..72ef72119 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php @@ -21,9 +21,9 @@ use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; use Doctrine\ORM\Query; use Doctrine\ORM\QueryBuilder; +use LogicException; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Security\Core\Role\Role; -use LogicException; class CountAccompanyingCourse implements ExportInterface, GroupedExportInterface { @@ -40,11 +40,6 @@ class CountAccompanyingCourse implements ExportInterface, GroupedExportInterface // TODO: Implement buildForm() method. } - public function getTitle(): string - { - return 'Count accompanying courses'; - } - public function getAllowedFormattersTypes(): array { return [FormatterInterface::TYPE_TABULAR]; @@ -55,6 +50,11 @@ class CountAccompanyingCourse implements ExportInterface, GroupedExportInterface return 'Count accompanying courses by various parameters'; } + public function getGroup(): string + { + return 'Exports of accompanying courses'; + } + public function getLabels($key, array $values, $data) { if ('export_result' !== $key) { @@ -79,6 +79,11 @@ class CountAccompanyingCourse implements ExportInterface, GroupedExportInterface return $qb->getQuery()->getResult(Query::HYDRATE_SCALAR); } + public function getTitle(): string + { + return 'Count accompanying courses'; + } + public function getType(): string { return Declarations::ACP_TYPE; @@ -104,9 +109,4 @@ class CountAccompanyingCourse implements ExportInterface, GroupedExportInterface Declarations::ACP_TYPE, ]; } - - public function getGroup(): string - { - return 'Exports of accompanying courses'; - } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php b/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php index 1e703754e..a329afee1 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php @@ -1,5 +1,14 @@ repository = $em->getRepository(AccompanyingPeriod::class); } - /** - * @inheritDoc - */ public function buildForm(FormBuilderInterface $builder) { // TODO: Implement buildForm() method. } - /** - * @inheritDoc - */ - public function getTitle(): string - { - return 'Count evaluations'; - } - - /** - * @inheritDoc - */ public function getAllowedFormattersTypes(): array { return [FormatterInterface::TYPE_TABULAR]; } - /** - * @inheritDoc - */ public function getDescription(): string { return 'Count evaluation by various parameters.'; } - /** - * @inheritDoc - */ + public function getGroup(): string + { + return 'Exports of evaluations'; + } + public function getLabels($key, array $values, $data) { if ('export_result' !== $key) { @@ -74,56 +67,42 @@ class CountEvaluation implements ExportInterface, GroupedExportInterface }; } - /** - * @inheritDoc - */ public function getQueryKeys($data): array { return ['export_result']; } - /** - * @inheritDoc - */ public function getResult($qb, $data) { return $qb->getQuery()->getResult(Query::HYDRATE_SCALAR); } - /** - * @inheritDoc - */ + public function getTitle(): string + { + return 'Count evaluations'; + } + public function getType(): string { return Declarations::EVAL_TYPE; } - /** - * @inheritDoc - */ public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { $qb = $this->repository->createQueryBuilder('acp') ->join('acp.works', 'acpw') - ->join('acpw.accompanyingPeriodWorkEvaluations', 'eval') - ; + ->join('acpw.accompanyingPeriodWorkEvaluations', 'eval'); $qb->select('COUNT(eval.id) AS export_result'); return $qb; } - /** - * @inheritDoc - */ public function requiredRole() { return new Role(AccompanyingPeriodVoter::STATS); } - /** - * @inheritDoc - */ public function supportsModifiers(): array { return [ @@ -132,9 +111,4 @@ class CountEvaluation implements ExportInterface, GroupedExportInterface //Declarations::SOCIAL_WORK_ACTION_TYPE, ]; } - - public function getGroup(): string - { - return 'Exports of evaluations'; - } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php b/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php index a43345ff3..791c42772 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php @@ -1,5 +1,14 @@ repository = $em->getRepository(AccompanyingPeriod::class); } - /** - * @inheritDoc - */ public function buildForm(FormBuilderInterface $builder) { // TODO: Implement buildForm() method. } - /** - * @inheritDoc - */ - public function getTitle(): string - { - return 'Count households'; - } - - /** - * @inheritDoc - */ public function getAllowedFormattersTypes(): array { return [FormatterInterface::TYPE_TABULAR]; } - /** - * @inheritDoc - */ public function getDescription(): string { return 'Count household by various parameters.'; } - /** - * @inheritDoc - */ + public function getGroup(): string + { + return 'Exports of households'; + } + public function getLabels($key, array $values, $data) { if ('export_result' !== $key) { @@ -73,59 +67,45 @@ class CountHousehold implements ExportInterface, GroupedExportInterface }; } - /** - * @inheritDoc - */ public function getQueryKeys($data): array { return ['export_result']; } - /** - * @inheritDoc - */ public function getResult($qb, $data) { return $qb->getQuery()->getResult(Query::HYDRATE_SCALAR); } - /** - * @inheritDoc - */ + public function getTitle(): string + { + return 'Count households'; + } + public function getType(): string { return Declarations::HOUSEHOLD_TYPE; } - /** - * @inheritDoc - */ public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { $qb = $this->repository->createQueryBuilder('acp') ->join('acp.participations', 'acppart') ->join('acppart.person', 'person') ->join('person.householdParticipations', 'householdmember') - ->join('householdmember.household', 'household') - ; + ->join('householdmember.household', 'household'); $qb->select('COUNT(DISTINCT householdmember.household) AS export_result'); return $qb; } - /** - * @inheritDoc - */ public function requiredRole() { // TODO HouseholdVoter::STATS !?? return new Role(AccompanyingPeriodVoter::STATS); } - /** - * @inheritDoc - */ public function supportsModifiers(): array { return [ @@ -133,9 +113,4 @@ class CountHousehold implements ExportInterface, GroupedExportInterface //Declarations::ACP_TYPE ]; } - - public function getGroup(): string - { - return 'Exports of households'; - } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountPerson.php b/src/Bundle/ChillPersonBundle/Export/Export/CountPerson.php index 3ef74a69e..729e5a202 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountPerson.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountPerson.php @@ -25,7 +25,6 @@ use Symfony\Component\Security\Core\Role\Role; class CountPerson implements ExportInterface, GroupedExportInterface { - protected PersonRepository $personRepository; public function __construct( @@ -49,6 +48,11 @@ class CountPerson implements ExportInterface, GroupedExportInterface return 'Count people by various parameters.'; } + public function getGroup(): string + { + return 'Exports of persons'; + } + public function getLabels($key, array $values, $data) { if ('export_result' !== $key) { @@ -117,9 +121,4 @@ class CountPerson implements ExportInterface, GroupedExportInterface //Declarations::ACP_TYPE ]; } - - public function getGroup(): string - { - return 'Exports of persons'; - } } diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountPersonWithAccompanyingCourse.php b/src/Bundle/ChillPersonBundle/Export/Export/CountPersonWithAccompanyingCourse.php index d271bd3da..152793f97 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountPersonWithAccompanyingCourse.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountPersonWithAccompanyingCourse.php @@ -1,5 +1,14 @@ repository = $em->getRepository(AccompanyingPeriod::class); } - /** - * @inheritDoc - */ public function buildForm(FormBuilderInterface $builder) { // TODO: Implement buildForm() method. } - /** - * @inheritDoc - */ - public function getTitle(): string - { - return 'Count people participating in an accompanying course'; - } - - /** - * @inheritDoc - */ public function getAllowedFormattersTypes(): array { return [FormatterInterface::TYPE_TABULAR]; } - /** - * @inheritDoc - */ public function getDescription(): string { return 'Count people participating in an accompanying course by various parameters.'; } - /** - * @inheritDoc - */ + public function getGroup(): string + { + return 'Exports of persons'; + } + public function getLabels($key, array $values, $data) { if ('export_result' !== $key) { @@ -73,66 +67,47 @@ class CountPersonWithAccompanyingCourse implements ExportInterface, GroupedExpor }; } - /** - * @inheritDoc - */ public function getQueryKeys($data): array { return ['export_result']; } - /** - * @inheritDoc - */ public function getResult($qb, $data) { return $qb->getQuery()->getResult(Query::HYDRATE_SCALAR); } - /** - * @inheritDoc - */ + public function getTitle(): string + { + return 'Count people participating in an accompanying course'; + } + public function getType(): string { return Declarations::HOUSEHOLD_TYPE; } - /** - * @inheritDoc - */ public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { $qb = $this->repository->createQueryBuilder('acp') ->join('acp.participations', 'acppart') - ->join('acppart.person', 'person') - ; + ->join('acppart.person', 'person'); $qb->select('COUNT(DISTINCT person.id) AS export_result'); return $qb; } - /** - * @inheritDoc - */ public function requiredRole() { return new Role(AccompanyingPeriodVoter::STATS); } - /** - * @inheritDoc - */ public function supportsModifiers(): array { return [ Declarations::ACP_TYPE, - Declarations::PERSON_TYPE + Declarations::PERSON_TYPE, ]; } - - public function getGroup(): string - { - return 'Exports of persons'; - } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountSocialWorkActions.php b/src/Bundle/ChillPersonBundle/Export/Export/CountSocialWorkActions.php index cfea1f0c1..e19a40a0f 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountSocialWorkActions.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountSocialWorkActions.php @@ -21,8 +21,8 @@ use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; use Doctrine\ORM\Query; use Doctrine\ORM\QueryBuilder; -use Symfony\Component\Form\FormBuilderInterface; use LogicException; +use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Security\Core\Role\Role; class CountSocialWorkActions implements ExportInterface, GroupedExportInterface @@ -40,11 +40,6 @@ class CountSocialWorkActions implements ExportInterface, GroupedExportInterface // No form necessary? } - public function getTitle(): string - { - return 'Count social work actions'; - } - public function getAllowedFormattersTypes(): array { return [FormatterInterface::TYPE_TABULAR]; @@ -55,6 +50,11 @@ class CountSocialWorkActions implements ExportInterface, GroupedExportInterface return 'Count social work actions by various parameters'; } + public function getGroup(): string + { + return 'Exports of social work actions'; + } + public function getLabels($key, array $values, $data) { if ('export_result' !== $key) { @@ -79,6 +79,11 @@ class CountSocialWorkActions implements ExportInterface, GroupedExportInterface return $qb->getQuery()->getResult(Query::HYDRATE_SCALAR); } + public function getTitle(): string + { + return 'Count social work actions'; + } + public function getType(): string { return Declarations::SOCIAL_WORK_ACTION_TYPE; @@ -87,8 +92,7 @@ class CountSocialWorkActions implements ExportInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []): QueryBuilder { $qb = $this->repository->createQueryBuilder('acp') - ->join('acp.works', 'acpw') - ; + ->join('acp.works', 'acpw'); $qb->select('COUNT(acpw.id) as export_result'); @@ -107,9 +111,4 @@ class CountSocialWorkActions implements ExportInterface, GroupedExportInterface Declarations::SOCIAL_WORK_ACTION_TYPE, ]; } - - public function getGroup(): string - { - return 'Exports of social work actions'; - } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php b/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php index f2f72aa29..5f519e647 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php @@ -136,6 +136,11 @@ class ListPerson implements ExportElementValidatedInterface, ListInterface, Grou return 'Create a list of people according to various filters.'; } + public function getGroup(): string + { + return 'Exports of persons'; + } + public function getLabels($key, array $values, $data) { switch ($key) { @@ -426,9 +431,11 @@ class ListPerson implements ExportElementValidatedInterface, ListInterface, Grou if ('_header' === $value) { return $this->translatableStringHelper->localize($cf->getName()); } + if (null === $value) { return ''; } + return $this->customFieldProvider ->getCustomFieldByType($cf->getType()) ->render(json_decode($value, true), $cf, 'csv'); @@ -437,6 +444,7 @@ class ListPerson implements ExportElementValidatedInterface, ListInterface, Grou if ($cfType instanceof CustomFieldChoice && $cfType->isMultiple($cf)) { return function ($value) use ($cf, $cfType, $key) { $slugChoice = $this->extractInfosFromSlug($key)['additionnalInfos']['choiceSlug']; + if (null === $value) { return ''; } @@ -475,9 +483,4 @@ class ListPerson implements ExportElementValidatedInterface, ListInterface, Grou return $uid; } - - public function getGroup(): string - { - return 'Exports of persons'; - } } diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListPersonDuplicate.php b/src/Bundle/ChillPersonBundle/Export/Export/ListPersonDuplicate.php index 2c65acb84..7f8688493 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListPersonDuplicate.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListPersonDuplicate.php @@ -129,6 +129,11 @@ class ListPersonDuplicate implements DirectExportInterface, ExportElementValidat return 'Create a list of duplicate people'; } + public function getGroup(): string + { + return 'Exports of persons'; + } + /** * @return string */ @@ -197,9 +202,4 @@ class ListPersonDuplicate implements DirectExportInterface, ExportElementValidat return $result->fetchAllAssociative(); } - - public function getGroup(): string - { - return 'Exports of persons'; - } } diff --git a/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php b/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php index 417411f98..718d04643 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php @@ -18,6 +18,7 @@ use Chill\MainBundle\Form\Type\ChillDateType; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Export\Declarations; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; +use DateTime; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; use Doctrine\ORM\Query; @@ -27,7 +28,6 @@ use Symfony\Component\Security\Core\Role\Role; class StatAccompanyingCourseDuration implements ExportInterface, GroupedExportInterface { - private EntityRepository $repository; public function __construct( @@ -36,44 +36,29 @@ class StatAccompanyingCourseDuration implements ExportInterface, GroupedExportIn $this->repository = $em->getRepository(AccompanyingPeriod::class); } - /** - * @inheritDoc - */ public function buildForm(FormBuilderInterface $builder): void { $builder->add('closingdate', ChillDateType::class, [ 'label' => 'Closingdate to apply', - 'data' => new \DateTime('now'), + 'data' => new DateTime('now'), ]); } - /** - * @inheritDoc - */ - public function getTitle(): string - { - return 'Accompanying courses duration'; - } - - /** - * @inheritDoc - */ public function getAllowedFormattersTypes(): array { return [FormatterInterface::TYPE_TABULAR]; } - /** - * @inheritDoc - */ public function getDescription(): string { return 'Create an average of accompanying courses duration according to various filters'; } - /** - * @inheritDoc - */ + public function getGroup(): string + { + return 'Exports of accompanying courses'; + } + public function getLabels($key, array $values, $data) { if ('export_result' !== $key) { @@ -88,33 +73,26 @@ class StatAccompanyingCourseDuration implements ExportInterface, GroupedExportIn }; } - /** - * @inheritDoc - */ public function getQueryKeys($data): array { return ['export_result']; } - /** - * @inheritDoc - */ public function getResult($qb, $data) { return $qb->getQuery()->getResult(Query::HYDRATE_SCALAR); } - /** - * @inheritDoc - */ + public function getTitle(): string + { + return 'Accompanying courses duration'; + } + public function getType(): string { return Declarations::ACP_TYPE; } - /** - * @inheritDoc - */ public function initiateQuery(array $requiredModifiers, array $acl, array $data = []): QueryBuilder { $qb = $this->repository->createQueryBuilder('acp'); @@ -125,34 +103,22 @@ class StatAccompanyingCourseDuration implements ExportInterface, GroupedExportIn WHEN acp.closingDate IS NOT NULL THEN acp.closingDate ELSE :force_closingDate - END ) - acp.openingDate + END ) - acp.openingDate ) AS export_result') - ->setParameter('force_closingDate', $data['closingdate']) - ; + ->setParameter('force_closingDate', $data['closingdate']); return $qb; } - /** - * @inheritDoc - */ public function requiredRole(): Role { return new Role(AccompanyingPeriodVoter::STATS); } - /** - * @inheritDoc - */ public function supportsModifiers(): array { return [ - Declarations::ACP_TYPE + Declarations::ACP_TYPE, ]; } - - public function getGroup(): string - { - return 'Exports of accompanying courses'; - } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOnDateFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOnDateFilter.php index 933350134..6b1ad6612 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOnDateFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOnDateFilter.php @@ -1,60 +1,32 @@ add('on_date', ChillDateType::class, [ - 'data' => new DateTime(), - ]) - ; - } - - /** - * @inheritDoc - */ - public function getTitle(): string - { - return 'Filter by active on date'; - } - - /** - * @inheritDoc - */ - public function describeAction($data, $format = 'string'): array - { - return ['Filtered by actives courses: active on %ondate%', [ - '%ondate%' => $data['on_date']->format('d-m-Y') - ]]; - } - - /** - * @inheritDoc - */ public function addRole() { return null; } - /** - * @inheritDoc - */ public function alterQuery(QueryBuilder $qb, $data) { $where = $qb->getDQLPart('where'); @@ -77,11 +49,28 @@ class ActiveOnDateFilter implements FilterInterface $qb->setParameter('ondate', $data['on_date'], Types::DATE_MUTABLE); } - /** - * @inheritDoc - */ public function applyOn(): string { return Declarations::ACP_TYPE; } -} \ No newline at end of file + + public function buildForm(FormBuilderInterface $builder) + { + $builder + ->add('on_date', ChillDateType::class, [ + 'data' => new DateTime(), + ]); + } + + public function describeAction($data, $format = 'string'): array + { + return ['Filtered by actives courses: active on %ondate%', [ + '%ondate%' => $data['on_date']->format('d-m-Y'), + ]]; + } + + public function getTitle(): string + { + return 'Filter by active on date'; + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOneDayBetweenDatesFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOneDayBetweenDatesFilter.php index 2f83667c9..c37097d30 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOneDayBetweenDatesFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOneDayBetweenDatesFilter.php @@ -1,64 +1,32 @@ add('date_from', ChillDateType::class, [ - 'data' => new DateTime(), - ]) - ->add('date_to', ChillDateType::class, [ - 'data' => new DateTime(), - ]) - ; - } - - /** - * @inheritDoc - */ - public function getTitle(): string - { - return 'Filter by active at least one day between dates'; - } - - /** - * @inheritDoc - */ - public function describeAction($data, $format = 'string'): array - { - return ['Filtered by actives courses: at least one day between %datefrom% and %dateto%', [ - '%datefrom%' => $data['date_from']->format('d-m-Y'), - '%dateto%' => $data['date_to']->format('d-m-Y'), - ]]; - } - - /** - * @inheritDoc - */ public function addRole() { return null; } - /** - * @inheritDoc - */ public function alterQuery(QueryBuilder $qb, $data) { $where = $qb->getDQLPart('where'); @@ -83,11 +51,32 @@ class ActiveOneDayBetweenDatesFilter implements FilterInterface $qb->setParameter('dateto', $data['date_to'], Types::DATE_MUTABLE); } - /** - * @inheritDoc - */ public function applyOn(): string { return Declarations::ACP_TYPE; } -} \ No newline at end of file + + public function buildForm(FormBuilderInterface $builder) + { + $builder + ->add('date_from', ChillDateType::class, [ + 'data' => new DateTime(), + ]) + ->add('date_to', ChillDateType::class, [ + 'data' => new DateTime(), + ]); + } + + public function describeAction($data, $format = 'string'): array + { + return ['Filtered by actives courses: at least one day between %datefrom% and %dateto%', [ + '%datefrom%' => $data['date_from']->format('d-m-Y'), + '%dateto%' => $data['date_to']->format('d-m-Y'), + ]]; + } + + public function getTitle(): string + { + return 'Filter by active at least one day between dates'; + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActivityTypeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActivityTypeFilter.php index 938a4e4b4..6efe29233 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActivityTypeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActivityTypeFilter.php @@ -1,5 +1,14 @@ translatableStringHelper = $translatableStringHelper; } - /** - * @inheritDoc - */ - public function buildForm(FormBuilderInterface $builder) - { - $builder->add('accepted_activitytypes', EntityType::class, [ - 'class' => ActivityType::class, - 'choice_label' => function (ActivityType $aty) { - return $this->translatableStringHelper->localize($aty->getName()); - }, - 'multiple' => true, - 'expanded' => true - ]); - } - - /** - * @inheritDoc - */ - public function getTitle(): string - { - return 'Filter accompanying course by activity type'; - } - - /** - * @inheritDoc - */ - public function describeAction($data, $format = 'string'): array - { - $types = []; - - foreach ($data['accepted_activitytypes'] as $aty) { - $types[] = $this->translatableStringHelper->localize($aty->getName()); - } - - return ['Filtered by activity types: only %activitytypes%', [ - '%activitytypes%' => implode(", ou ", $types) - ]]; - } - - /** - * @inheritDoc - */ public function addRole() { return null; } - /** - * @inheritDoc - */ public function alterQuery(QueryBuilder $qb, $data) { // One2many between activity and accompanyingperiod is not reversed ! @@ -83,8 +47,7 @@ class ActivityTypeFilter implements FilterInterface $qb ->join('act.accompanyingPeriod', 'acp') - ->join('act.activityType', 'aty') - ; + ->join('act.activityType', 'aty'); $where = $qb->getDQLPart('where'); $clause = $qb->expr()->in('aty.id', ':activitytypes'); @@ -97,14 +60,40 @@ class ActivityTypeFilter implements FilterInterface $qb->add('where', $where); $qb->setParameter('activitytypes', $data['accepted_activitytypes']); - } - /** - * @inheritDoc - */ public function applyOn() { return Declarations::ACP_TYPE; } -} \ No newline at end of file + + public function buildForm(FormBuilderInterface $builder) + { + $builder->add('accepted_activitytypes', EntityType::class, [ + 'class' => ActivityType::class, + 'choice_label' => function (ActivityType $aty) { + return $this->translatableStringHelper->localize($aty->getName()); + }, + 'multiple' => true, + 'expanded' => true, + ]); + } + + public function describeAction($data, $format = 'string'): array + { + $types = []; + + foreach ($data['accepted_activitytypes'] as $aty) { + $types[] = $this->translatableStringHelper->localize($aty->getName()); + } + + return ['Filtered by activity types: only %activitytypes%', [ + '%activitytypes%' => implode(', ou ', $types), + ]]; + } + + public function getTitle(): string + { + return 'Filter accompanying course by activity type'; + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/AdministrativeLocationFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/AdministrativeLocationFilter.php index d3fde5b91..7bea4eb7f 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/AdministrativeLocationFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/AdministrativeLocationFilter.php @@ -1,5 +1,14 @@ translatableStringHelper = $translatableStringHelper; } - /** - * @inheritDoc - */ - public function buildForm(FormBuilderInterface $builder) - { - $builder->add('accepted_locations', EntityType::class, [ - 'class' => Location::class, - 'choice_label' => function (Location $l) { - return $l->getName() .' ('. $this->translatableStringHelper->localize($l->getLocationType()->getTitle()) . ')'; - }, - 'multiple' => true, - 'expanded' => true, - ]); - } - - /** - * @inheritDoc - */ - public function getTitle(): string - { - return 'Filter by administrative location'; - } - - /** - * @inheritDoc - */ - public function describeAction($data, $format = 'string'): array - { - $locations = []; - - foreach ($data['accepted_locations'] as $l) { - $locations[] = $l->getName(); - } - - return ['Filtered by administratives locations: only %locations%', [ - '%locations%' => implode(", ou ", $locations) - ]]; - } - - /** - * @inheritDoc - */ public function addRole() { return null; } - /** - * @inheritDoc - */ public function alterQuery(QueryBuilder $qb, $data) { $where = $qb->getDQLPart('where'); @@ -89,11 +50,38 @@ class AdministrativeLocationFilter implements FilterInterface $qb->setParameter('locations', $data['accepted_locations']); } - /** - * @inheritDoc - */ public function applyOn(): string { return Declarations::ACP_TYPE; } -} \ No newline at end of file + + public function buildForm(FormBuilderInterface $builder) + { + $builder->add('accepted_locations', EntityType::class, [ + 'class' => Location::class, + 'choice_label' => function (Location $l) { + return $l->getName() . ' (' . $this->translatableStringHelper->localize($l->getLocationType()->getTitle()) . ')'; + }, + 'multiple' => true, + 'expanded' => true, + ]); + } + + public function describeAction($data, $format = 'string'): array + { + $locations = []; + + foreach ($data['accepted_locations'] as $l) { + $locations[] = $l->getName(); + } + + return ['Filtered by administratives locations: only %locations%', [ + '%locations%' => implode(', ou ', $locations), + ]]; + } + + public function getTitle(): string + { + return 'Filter by administrative location'; + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ClosingMotiveFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ClosingMotiveFilter.php index 23fce3f40..150a66ed1 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ClosingMotiveFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ClosingMotiveFilter.php @@ -1,21 +1,27 @@ translatableStringHelper = $translatableStringHelper; } - /** - * @inheritDoc - */ - public function buildForm(FormBuilderInterface $builder) - { - $builder->add('accepted_closingmotives', EntityType::class, [ - 'class' => ClosingMotive::class, - 'choice_label' => function (ClosingMotive $cm) { - return $this->translatableStringHelper->localize($cm->getName()); - }, - 'multiple' => true, - 'expanded' => true, - ]); - } - - /** - * @inheritDoc - */ - public function getTitle(): string - { - return 'Filter by closing motive'; - } - - /** - * @inheritDoc - */ - public function describeAction($data, $format = 'string'): array - { - $motives = []; - - foreach ($data['accepted_closingmotives'] as $k => $v) { - $motives[] = $this->translatableStringHelper->localize($v->getName()); - } - - return [ - 'Filtered by closingmotive: only %closingmotives%', [ - '%closingmotives%' => implode(', ou ', $motives) - ]]; - } - - /** - * @inheritDoc - */ public function addRole() { return null; } - /** - * @inheritDoc - */ public function alterQuery(QueryBuilder $qb, $data) { $where = $qb->getDQLPart('where'); @@ -90,11 +50,39 @@ class ClosingMotiveFilter implements FilterInterface $qb->setParameter('closingmotive', $data['accepted_closingmotives']); } - /** - * @inheritDoc - */ public function applyOn(): string { return Declarations::ACP_TYPE; } -} \ No newline at end of file + + public function buildForm(FormBuilderInterface $builder) + { + $builder->add('accepted_closingmotives', EntityType::class, [ + 'class' => ClosingMotive::class, + 'choice_label' => function (ClosingMotive $cm) { + return $this->translatableStringHelper->localize($cm->getName()); + }, + 'multiple' => true, + 'expanded' => true, + ]); + } + + public function describeAction($data, $format = 'string'): array + { + $motives = []; + + foreach ($data['accepted_closingmotives'] as $k => $v) { + $motives[] = $this->translatableStringHelper->localize($v->getName()); + } + + return [ + 'Filtered by closingmotive: only %closingmotives%', [ + '%closingmotives%' => implode(', ou ', $motives), + ], ]; + } + + public function getTitle(): string + { + return 'Filter by closing motive'; + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ConfidentialFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ConfidentialFilter.php index 23286f941..6fedf37f0 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ConfidentialFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ConfidentialFilter.php @@ -1,5 +1,14 @@ false, 'is confidential' => true, ]; - - private CONST DEFAULT_CHOICE = false; - + + private const DEFAULT_CHOICE = false; + private TranslatorInterface $translator; - + public function __construct(TranslatorInterface $translator) { $this->translator = $translator; } - public function buildForm(FormBuilderInterface $builder) - { - $builder->add('accepted_confidentials', ChoiceType::class, [ - 'choices' => self::CHOICES, - 'multiple' => false, - 'expanded' => true, - 'empty_data' => self::DEFAULT_CHOICE, - 'data' => self::DEFAULT_CHOICE, - ]); - } - - public function getTitle(): string - { - return 'Filter by confidential'; - } - - public function describeAction($data, $format = 'string'): array - { - dump($data, self::CHOICES); - - foreach (self::CHOICES as $k => $v) { - if ($v === $data['accepted_confidentials']) { - $choice = $k; - } - } - - return [ - 'Filtered by confidential: only %confidential%', [ - '%confidential%' => $this->translator->trans($choice) - ] - ]; - } - public function addRole() { return null; @@ -84,4 +60,36 @@ class ConfidentialFilter implements FilterInterface return Declarations::ACP_TYPE; } -} \ No newline at end of file + public function buildForm(FormBuilderInterface $builder) + { + $builder->add('accepted_confidentials', ChoiceType::class, [ + 'choices' => self::CHOICES, + 'multiple' => false, + 'expanded' => true, + 'empty_data' => self::DEFAULT_CHOICE, + 'data' => self::DEFAULT_CHOICE, + ]); + } + + public function describeAction($data, $format = 'string'): array + { + dump($data, self::CHOICES); + + foreach (self::CHOICES as $k => $v) { + if ($v === $data['accepted_confidentials']) { + $choice = $k; + } + } + + return [ + 'Filtered by confidential: only %confidential%', [ + '%confidential%' => $this->translator->trans($choice), + ], + ]; + } + + public function getTitle(): string + { + return 'Filter by confidential'; + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CurrentUserJobFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CurrentUserJobFilter.php index ddebbdc6f..76ba40a59 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CurrentUserJobFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CurrentUserJobFilter.php @@ -35,17 +35,6 @@ class CurrentUserJobFilter implements FilterInterface $this->security = $security; } - public function describeAction($data, $format = 'string') - { - return [ - 'Filtered by user job: only %job%', [ - '%job%' => $this->translatableStringHelper->localize( - $this->getUserJob()->getLabel() - ) - ], - ]; - } - public function addRole() { return null; @@ -75,16 +64,27 @@ class CurrentUserJobFilter implements FilterInterface { } + public function describeAction($data, $format = 'string') + { + return [ + 'Filtered by user job: only %job%', [ + '%job%' => $this->translatableStringHelper->localize( + $this->getUserJob()->getLabel() + ), + ], + ]; + } + public function getTitle() { return 'Filter by user job'; } - private function getUserJob():UserJob + private function getUserJob(): UserJob { /** @var User $user */ $user = $this->security->getUser(); return $user->getUserJob(); } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CurrentUserScopeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CurrentUserScopeFilter.php index e6c56f11e..37dcac27c 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CurrentUserScopeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CurrentUserScopeFilter.php @@ -18,7 +18,6 @@ use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\PersonBundle\Export\Declarations; use Doctrine\ORM\Query\Expr\Andx; use Doctrine\ORM\QueryBuilder; -use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Security\Core\Security; @@ -26,9 +25,6 @@ class CurrentUserScopeFilter implements FilterInterface { private Security $security; - /** - * @var TranslatableStringHelper - */ private TranslatableStringHelper $translatableStringHelper; public function __construct( @@ -39,17 +35,6 @@ class CurrentUserScopeFilter implements FilterInterface $this->security = $security; } - public function describeAction($data, $format = 'string') - { - return [ - 'Filtered by user main scope: only %scope%', [ - '%scope%' => $this->translatableStringHelper->localize( - $this->getUserMainScope()->getName() - ) - ] - ]; - } - public function addRole() { return null; @@ -70,7 +55,6 @@ class CurrentUserScopeFilter implements FilterInterface $qb->add('where', $where); $qb->setParameter('userscope', $this->getUserMainScope()); - } public function applyOn() @@ -82,16 +66,27 @@ class CurrentUserScopeFilter implements FilterInterface { } + public function describeAction($data, $format = 'string') + { + return [ + 'Filtered by user main scope: only %scope%', [ + '%scope%' => $this->translatableStringHelper->localize( + $this->getUserMainScope()->getName() + ), + ], + ]; + } + public function getTitle() { return 'Filter by user scope'; } - private function getUserMainScope():Scope + private function getUserMainScope(): Scope { /** @var User $user */ $user = $this->security->getUser(); return $user->getMainScope(); } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EmergencyFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EmergencyFilter.php index ed874be2b..6a755638b 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EmergencyFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EmergencyFilter.php @@ -1,5 +1,14 @@ true, 'is not emergency' => false, ]; - - private CONST DEFAULT_CHOICE = false; - + + private const DEFAULT_CHOICE = false; + private TranslatorInterface $translator; - + public function __construct(TranslatorInterface $translator) { $this->translator = $translator; } - public function buildForm(FormBuilderInterface $builder) - { - $builder->add('accepted_emergency', ChoiceType::class, [ - 'choices' => self::CHOICES, - 'multiple' => false, - 'expanded' => true, - 'empty_data' => self::DEFAULT_CHOICE, - 'data' => self::DEFAULT_CHOICE, - ]); - } - - public function getTitle(): string - { - return 'Filter by emergency'; - } - - public function describeAction($data, $format = 'string'): array - { - foreach (self::CHOICES as $k => $v) { - if ($v === $data['accepted_emergency']) { - $choice = $k; - } - } - - return [ - 'Filtered by emergency: only %emergency%', [ - '%emergency%' => $this->translator->trans($choice) - ] - ]; - } - public function addRole() { return null; @@ -82,4 +60,34 @@ class EmergencyFilter implements FilterInterface return Declarations::ACP_TYPE; } -} \ No newline at end of file + public function buildForm(FormBuilderInterface $builder) + { + $builder->add('accepted_emergency', ChoiceType::class, [ + 'choices' => self::CHOICES, + 'multiple' => false, + 'expanded' => true, + 'empty_data' => self::DEFAULT_CHOICE, + 'data' => self::DEFAULT_CHOICE, + ]); + } + + public function describeAction($data, $format = 'string'): array + { + foreach (self::CHOICES as $k => $v) { + if ($v === $data['accepted_emergency']) { + $choice = $k; + } + } + + return [ + 'Filtered by emergency: only %emergency%', [ + '%emergency%' => $this->translator->trans($choice), + ], + ]; + } + + public function getTitle(): string + { + return 'Filter by emergency'; + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EvaluationFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EvaluationFilter.php index 4756f06c2..ab47c1cc7 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EvaluationFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EvaluationFilter.php @@ -1,5 +1,14 @@ translatableStringHelper = $translatableStringHelper; } - /** - * @inheritDoc - */ - public function buildForm(FormBuilderInterface $builder) - { - $builder->add('accepted_evaluations', EntityType::class, [ - 'class' => Evaluation::class, - 'choice_label' => function (Evaluation $ev) { - return $this->translatableStringHelper->localize($ev->getTitle()); - }, - 'multiple' => true, - 'expanded' => true, - ]); - } - - /** - * @inheritDoc - */ - public function getTitle(): string - { - return 'Filter by evaluation'; - } - - /** - * @inheritDoc - */ - public function describeAction($data, $format = 'string'): array - { - $evaluations = []; - - foreach ($data['accepted_evaluations'] as $ev) { - $evaluations[] = $this->translatableStringHelper->localize($ev->getTitle()); - } - - return ['Filtered by evaluations: only %evals%', [ - '%evals%' => implode(", ou ", $evaluations) - ]]; - } - - /** - * @inheritDoc - */ public function addRole() { return null; } - /** - * @inheritDoc - */ public function alterQuery(QueryBuilder $qb, $data) { $qb ->join('acp.works', 'acpw') ->join('acpw.accompanyingPeriodWorkEvaluations', 'we') - ->join('we.evaluation', 'ev') - ; + ->join('we.evaluation', 'ev'); $where = $qb->getDQLPart('where'); $clause = $qb->expr()->in('ev.id', ':evaluations'); @@ -95,11 +55,38 @@ class EvaluationFilter implements FilterInterface $qb->setParameter('evaluations', $data['accepted_evaluations']); } - /** - * @inheritDoc - */ public function applyOn(): string { return Declarations::ACP_TYPE; } -} \ No newline at end of file + + public function buildForm(FormBuilderInterface $builder) + { + $builder->add('accepted_evaluations', EntityType::class, [ + 'class' => Evaluation::class, + 'choice_label' => function (Evaluation $ev) { + return $this->translatableStringHelper->localize($ev->getTitle()); + }, + 'multiple' => true, + 'expanded' => true, + ]); + } + + public function describeAction($data, $format = 'string'): array + { + $evaluations = []; + + foreach ($data['accepted_evaluations'] as $ev) { + $evaluations[] = $this->translatableStringHelper->localize($ev->getTitle()); + } + + return ['Filtered by evaluations: only %evals%', [ + '%evals%' => implode(', ou ', $evaluations), + ]]; + } + + public function getTitle(): string + { + return 'Filter by evaluation'; + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php index 5445e20a4..5a1d74c1f 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php @@ -1,11 +1,21 @@ add('date', ChillDateType::class, [ - 'data' => new \DateTime(), - ]) - ->add('accepted_loctype', EntityType::class, [ - 'class' => GeographicalUnit::class, - 'choice_label' => function (GeographicalUnit $u) { - return $u->getUnitName(); - }, - 'multiple' => true, - 'expanded' => true, - ]) - ; - } - - /** - * @inheritDoc - */ - public function getTitle(): string - { - return 'Filter by geographical unit'; - } - - /** - * @inheritDoc - */ - public function describeAction($data, $format = 'string'): array - { - return ['Filtered by geographic unit: only %date%', [ - '%date%' => $data['date']->format('d-m-Y'), - ]]; - } - - /** - * @inheritDoc - */ public function addRole() { return null; } - /** - * @inheritDoc - */ public function alterQuery(QueryBuilder $qb, $data) { $where = $qb->getDQLPart('where'); @@ -89,11 +55,36 @@ class GeographicalUnitStatFilter implements FilterInterface $qb->setParameter('loctype', $data['accepted_loctype']); } - /** - * @inheritDoc - */ public function applyOn(): string { return Declarations::ACP_TYPE; } -} \ No newline at end of file + + public function buildForm(FormBuilderInterface $builder) + { + $builder + ->add('date', ChillDateType::class, [ + 'data' => new DateTime(), + ]) + ->add('accepted_loctype', EntityType::class, [ + 'class' => GeographicalUnit::class, + 'choice_label' => static function (GeographicalUnit $u) { + return $u->getUnitName(); + }, + 'multiple' => true, + 'expanded' => true, + ]); + } + + public function describeAction($data, $format = 'string'): array + { + return ['Filtered by geographic unit: only %date%', [ + '%date%' => $data['date']->format('d-m-Y'), + ]]; + } + + public function getTitle(): string + { + return 'Filter by geographical unit'; + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/IntensityFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/IntensityFilter.php index c433c724f..22a1e2415 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/IntensityFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/IntensityFilter.php @@ -1,5 +1,14 @@ 'occasional', 'is regular' => 'regular', ]; - - private CONST DEFAULT_CHOICE = 'occasional'; - + + private const DEFAULT_CHOICE = 'occasional'; + private TranslatorInterface $translator; - + public function __construct(TranslatorInterface $translator) { $this->translator = $translator; } - public function buildForm(FormBuilderInterface $builder) - { - $builder->add('accepted_intensities', ChoiceType::class, [ - 'choices' => self::CHOICES, - 'multiple' => false, - 'expanded' => true, - 'empty_data' => self::DEFAULT_CHOICE, - 'data' => self::DEFAULT_CHOICE, - ]); - } - - public function getTitle(): string - { - return 'Filter by intensity'; - } - - public function describeAction($data, $format = 'string'): array - { - foreach (self::CHOICES as $k => $v) { - if ($v === $data['accepted_intensities']) { - $choice = $k; - } - } - - return [ - 'Filtered by intensity: only %intensity%', [ - '%intensity%' => $this->translator->trans($choice) - ] - ]; - } - public function addRole() { return null; @@ -82,4 +60,34 @@ class IntensityFilter implements FilterInterface return Declarations::ACP_TYPE; } -} \ No newline at end of file + public function buildForm(FormBuilderInterface $builder) + { + $builder->add('accepted_intensities', ChoiceType::class, [ + 'choices' => self::CHOICES, + 'multiple' => false, + 'expanded' => true, + 'empty_data' => self::DEFAULT_CHOICE, + 'data' => self::DEFAULT_CHOICE, + ]); + } + + public function describeAction($data, $format = 'string'): array + { + foreach (self::CHOICES as $k => $v) { + if ($v === $data['accepted_intensities']) { + $choice = $k; + } + } + + return [ + 'Filtered by intensity: only %intensity%', [ + '%intensity%' => $this->translator->trans($choice), + ], + ]; + } + + public function getTitle(): string + { + return 'Filter by intensity'; + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OpenBetweenDatesFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OpenBetweenDatesFilter.php index 400ab7a14..205707831 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OpenBetweenDatesFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OpenBetweenDatesFilter.php @@ -1,64 +1,32 @@ add('date_from', ChillDateType::class, [ - 'data' => new DateTime(), - ]) - ->add('date_to', ChillDateType::class, [ - 'data' => new DateTime(), - ]) - ; - } - - /** - * @inheritDoc - */ - public function getTitle(): string - { - return 'Filter by opened between dates'; - } - - /** - * @inheritDoc - */ - public function describeAction($data, $format = 'string'): array - { - return ['Filtered by opening dates: between %datefrom% and %dateto%', [ - '%datefrom%' => $data['date_from']->format('d-m-Y'), - '%dateto%' => $data['date_to']->format('d-m-Y'), - ]]; - } - - /** - * @inheritDoc - */ public function addRole() { return null; } - /** - * @inheritDoc - */ public function alterQuery(QueryBuilder $qb, $data) { $where = $qb->getDQLPart('where'); @@ -79,11 +47,32 @@ class OpenBetweenDatesFilter implements FilterInterface $qb->setParameter('dateto', $data['date_to'], Types::DATE_MUTABLE); } - /** - * @inheritDoc - */ public function applyOn(): string { return Declarations::ACP_TYPE; } -} \ No newline at end of file + + public function buildForm(FormBuilderInterface $builder) + { + $builder + ->add('date_from', ChillDateType::class, [ + 'data' => new DateTime(), + ]) + ->add('date_to', ChillDateType::class, [ + 'data' => new DateTime(), + ]); + } + + public function describeAction($data, $format = 'string'): array + { + return ['Filtered by opening dates: between %datefrom% and %dateto%', [ + '%datefrom%' => $data['date_from']->format('d-m-Y'), + '%dateto%' => $data['date_to']->format('d-m-Y'), + ]]; + } + + public function getTitle(): string + { + return 'Filter by opened between dates'; + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OriginFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OriginFilter.php index 3cda93577..a67a0157c 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OriginFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OriginFilter.php @@ -1,5 +1,14 @@ translatableStringHelper = $translatableStringHelper; } - /** - * @inheritDoc - */ - public function buildForm(FormBuilderInterface $builder) - { - $builder->add('accepted_origins', EntityType::class, [ - 'class' => Origin::class, - 'choice_label' => function (Origin $o) { - return $this->translatableStringHelper->localize($o->getLabel()); - }, - 'multiple' => true, - 'expanded' => true - ]); - } - - /** - * @inheritDoc - */ - public function getTitle(): string - { - return 'Filter by origin'; - } - - /** - * @inheritDoc - */ - public function describeAction($data, $format = 'string'): array - { - $origins = []; - - foreach ($data['accepted_origins'] as $v) { - $origins[] = $this->translatableStringHelper->localize($v->getLabel()); - } - - return ['Filtered by origins: only %origins%', [ - '%origins%' => implode(', ou ', $origins) - ]]; - } - - /** - * @inheritDoc - */ public function addRole() { return null; } - /** - * @inheritDoc - */ public function alterQuery(QueryBuilder $qb, $data) { $where = $qb->getDQLPart('where'); @@ -90,11 +50,38 @@ class OriginFilter implements FilterInterface $qb->setParameter('origin', $data['accepted_origins']); } - /** - * @inheritDoc - */ public function applyOn(): string { return Declarations::ACP_TYPE; } -} \ No newline at end of file + + public function buildForm(FormBuilderInterface $builder) + { + $builder->add('accepted_origins', EntityType::class, [ + 'class' => Origin::class, + 'choice_label' => function (Origin $o) { + return $this->translatableStringHelper->localize($o->getLabel()); + }, + 'multiple' => true, + 'expanded' => true, + ]); + } + + public function describeAction($data, $format = 'string'): array + { + $origins = []; + + foreach ($data['accepted_origins'] as $v) { + $origins[] = $this->translatableStringHelper->localize($v->getLabel()); + } + + return ['Filtered by origins: only %origins%', [ + '%origins%' => implode(', ou ', $origins), + ]]; + } + + public function getTitle(): string + { + return 'Filter by origin'; + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ReferrerFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ReferrerFilter.php index 89b306678..94bf7a74c 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ReferrerFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ReferrerFilter.php @@ -1,5 +1,14 @@ userRender = $userRender; } - /** - * @inheritDoc - */ - public function buildForm(FormBuilderInterface $builder) - { - $builder->add('accepted_referrers', EntityType::class, [ - 'class' => User::class, - 'choice_label' => function (User $u) { - return $this->userRender->renderString($u, []); - }, - 'multiple' => true, - 'expanded' => true - ]); - - } - - /** - * @inheritDoc - */ - public function getTitle(): string - { - return 'Filter by referrers'; - } - - /** - * @inheritDoc - */ - public function describeAction($data, $format = 'string'): array - { - $users = []; - - foreach ($data['accepted_referrers'] as $r) { - $users[] = $r; - } - - return [ - 'Filtered by referrer: only %referrers%', [ - '%referrers' => implode(", ou ", $users) - ]]; - } - - /** - * @inheritDoc - */ public function addRole() { return null; } - /** - * @inheritDoc - */ public function alterQuery(QueryBuilder $qb, $data) { $where = $qb->getDQLPart('where'); @@ -88,11 +49,39 @@ class ReferrerFilter implements FilterInterface $qb->setParameter('referrers', $data['accepted_referrers']); } - /** - * @inheritDoc - */ public function applyOn(): string { return Declarations::ACP_TYPE; } -} \ No newline at end of file + + public function buildForm(FormBuilderInterface $builder) + { + $builder->add('accepted_referrers', EntityType::class, [ + 'class' => User::class, + 'choice_label' => function (User $u) { + return $this->userRender->renderString($u, []); + }, + 'multiple' => true, + 'expanded' => true, + ]); + } + + public function describeAction($data, $format = 'string'): array + { + $users = []; + + foreach ($data['accepted_referrers'] as $r) { + $users[] = $r; + } + + return [ + 'Filtered by referrer: only %referrers%', [ + '%referrers' => implode(', ou ', $users), + ], ]; + } + + public function getTitle(): string + { + return 'Filter by referrers'; + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/RequestorFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/RequestorFilter.php index 180775f01..3b9ed950c 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/RequestorFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/RequestorFilter.php @@ -1,5 +1,14 @@ 'participation', @@ -21,12 +32,10 @@ class RequestorFilter implements FilterInterface 'no requestor' => 'no_requestor', ]; - private const DEFAULT_CHOICE = 'participation'; + protected EntityManagerInterface $em; protected TranslatorInterface $translator; - protected EntityManagerInterface $em; - public function __construct( TranslatorInterface $translator, EntityManagerInterface $em @@ -35,75 +44,35 @@ class RequestorFilter implements FilterInterface $this->em = $em; } - /** - * @inheritDoc - */ - public function buildForm(FormBuilderInterface $builder) - { - $builder->add('accepted_choices', ChoiceType::class, [ - 'choices' => self::REQUESTOR_CHOICES, - 'multiple' => false, - 'expanded' => true, - 'empty_data' => self::DEFAULT_CHOICE, - 'data' => self::DEFAULT_CHOICE, - ]); - } - - /** - * @inheritDoc - */ - public function getTitle(): string - { - return 'Filter by requestor'; - } - - /** - * @inheritDoc - */ - public function describeAction($data, $format = 'string'): array - { - $choice = array_flip(self::REQUESTOR_CHOICES)[$data['accepted_choices']]; - - return ['Filtered by requestor: only %choice%', [ - '%choice%' => $this->translator->trans($choice) - ]]; - } - - /** - * @inheritDoc - */ public function addRole() { return null; } - /** - * @inheritDoc - */ public function alterQuery(QueryBuilder $qb, $data) { $where = $qb->getDQLPart('where'); switch ($data['accepted_choices']) { case 'participation': - $qb->join('acp.participations', 'part'); $clause = $qb->expr()->andX( $qb->expr()->isNotNull('acp.requestorPerson'), $qb->expr()->eq('acp.requestorPerson', 'part.person') ); + break; case 'other_person': - $expr = $this->em->getExpressionBuilder(); - $qb->join('acp.participations','part'); + $qb->join('acp.participations', 'part'); $clause = $expr->andX( $expr->isNotNull('acp.requestorPerson'), - $expr->notIn('acp.requestorPerson', + $expr->notIn( + 'acp.requestorPerson', // subquery $this->em->createQueryBuilder() @@ -112,26 +81,26 @@ class RequestorFilter implements FilterInterface ->join('acp2.participations', 'part2') ->where($expr->eq('acp2.requestorPerson', 'part2.person')) ->getDQL() - ) ); + break; case 'thirdparty': - $clause = $qb->expr()->isNotNull('acp.requestorThirdParty'); + break; case 'no_requestor': - $clause = $qb->expr()->andX( $qb->expr()->isNull('acp.requestorPerson'), $qb->expr()->isNull('acp.requestorThirdParty') ); + break; default: - throw new \Exception('Uncaught choice exception'); + throw new Exception('Uncaught choice exception'); } if ($where instanceof Andx) { @@ -143,11 +112,33 @@ class RequestorFilter implements FilterInterface $qb->add('where', $where); } - /** - * @inheritDoc - */ public function applyOn(): string { return Declarations::ACP_TYPE; } -} \ No newline at end of file + + public function buildForm(FormBuilderInterface $builder) + { + $builder->add('accepted_choices', ChoiceType::class, [ + 'choices' => self::REQUESTOR_CHOICES, + 'multiple' => false, + 'expanded' => true, + 'empty_data' => self::DEFAULT_CHOICE, + 'data' => self::DEFAULT_CHOICE, + ]); + } + + public function describeAction($data, $format = 'string'): array + { + $choice = array_flip(self::REQUESTOR_CHOICES)[$data['accepted_choices']]; + + return ['Filtered by requestor: only %choice%', [ + '%choice%' => $this->translator->trans($choice), + ]]; + } + + public function getTitle(): string + { + return 'Filter by requestor'; + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php index d96d0ca44..979793def 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php @@ -1,5 +1,14 @@ actionRender = $actionRender; } - public function buildForm(FormBuilderInterface $builder) - { - $builder->add('accepted_socialactions', EntityType::class, [ - 'class' => SocialAction::class, - 'choice_label' => function (SocialAction $sa) { - return $this->actionRender->renderString($sa, []); - }, - 'multiple' => true, - 'expanded' => true, - ]); - } - - public function getTitle(): string - { - return 'Filter by socialaction'; - } - - public function describeAction($data, $format = 'string'): array - { - $socialactions = []; - - foreach ($data['accepted_socialactions'] as $sa) { - $socialactions[] = $this->actionRender->renderString($sa, []); - } - - return ['Filtered by socialactions: only %socialactions%', [ - '%socialactions%' => implode(", ou ", $socialactions) - ]]; - } - public function addRole() { return null; @@ -69,7 +43,7 @@ class SocialActionFilter implements FilterInterface public function alterQuery(QueryBuilder $qb, $data) { - if (!in_array('acpw', $qb->getAllAliases())) { + if (!in_array('acpw', $qb->getAllAliases(), true)) { $qb->join('acp.works', 'acpw'); } $qb->join('acpw.socialAction', 'sa'); @@ -91,4 +65,34 @@ class SocialActionFilter implements FilterInterface { return Declarations::ACP_TYPE; } -} \ No newline at end of file + + public function buildForm(FormBuilderInterface $builder) + { + $builder->add('accepted_socialactions', EntityType::class, [ + 'class' => SocialAction::class, + 'choice_label' => function (SocialAction $sa) { + return $this->actionRender->renderString($sa, []); + }, + 'multiple' => true, + 'expanded' => true, + ]); + } + + public function describeAction($data, $format = 'string'): array + { + $socialactions = []; + + foreach ($data['accepted_socialactions'] as $sa) { + $socialactions[] = $this->actionRender->renderString($sa, []); + } + + return ['Filtered by socialactions: only %socialactions%', [ + '%socialactions%' => implode(', ou ', $socialactions), + ]]; + } + + public function getTitle(): string + { + return 'Filter by socialaction'; + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php index c2f9b1a06..f707ab9e2 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php @@ -1,5 +1,14 @@ socialIssueRender = $socialIssueRender; } - public function buildForm(FormBuilderInterface $builder) - { - $builder->add('accepted_socialissues', EntityType::class, [ - 'class' => SocialIssue::class, - 'choice_label' => function ($socialIssue) { - return $this->socialIssueRender->renderString($socialIssue, []); - }, - 'multiple' => true, - 'expanded' => true, - ]); - } - - public function getTitle() - { - return 'Filter by social issue'; - } - - public function describeAction($data, $format = 'string') - { - $issues = []; - - $socialissues = $this->addParentIssues($data['accepted_socialissues']); - - foreach ($socialissues as $i) { - if ('null' === $i) { - $issues[] = $this->translator->trans('Not given'); - } else { - $issues[] = $this->socialIssueRender->renderString($i, []); - } - } - - return [ - 'Filtered by socialissues: only %socialissues%', [ - '%socialissues%' => implode(', ou ', $issues) - ]]; - } - public function addRole() { return null; @@ -96,49 +62,87 @@ class SocialIssueFilter implements FilterInterface } $qb->add('where', $where); - $qb->setParameter('socialissues', + $qb->setParameter( + 'socialissues', $this->addParentIssues($data['accepted_socialissues']) ); } - /** - * "Le filtre retiendra les parcours qui comportent cette problématique, - * ou une problématique parente à celles choisies." - * - * Add parent of each socialissue selected, and remove duplicates - * - * @param $accepted_issues - * @return array - */ - private function addParentIssues($accepted_issues): array - { - $array = []; - foreach ($accepted_issues as $i) - { - /** @var SocialIssue $i */ - if ($i->hasParent()) { - $array[] = $i->getParent(); - } - $array[] = $i; - } - return $this->removeDuplicate($array); - } - - private function removeDuplicate(array $array): array - { - $ids = array_map(function ($item) { - return $item->getId(); - }, $array); - - $unique_ids = array_unique($ids); - - return array_values( - array_intersect_key($array, $unique_ids)); - } - public function applyOn() { return Declarations::ACP_TYPE; } -} \ No newline at end of file + public function buildForm(FormBuilderInterface $builder) + { + $builder->add('accepted_socialissues', EntityType::class, [ + 'class' => SocialIssue::class, + 'choice_label' => function ($socialIssue) { + return $this->socialIssueRender->renderString($socialIssue, []); + }, + 'multiple' => true, + 'expanded' => true, + ]); + } + + public function describeAction($data, $format = 'string') + { + $issues = []; + + $socialissues = $this->addParentIssues($data['accepted_socialissues']); + + foreach ($socialissues as $i) { + if ('null' === $i) { + $issues[] = $this->translator->trans('Not given'); + } else { + $issues[] = $this->socialIssueRender->renderString($i, []); + } + } + + return [ + 'Filtered by socialissues: only %socialissues%', [ + '%socialissues%' => implode(', ou ', $issues), + ], ]; + } + + public function getTitle() + { + return 'Filter by social issue'; + } + + /** + * "Le filtre retiendra les parcours qui comportent cette problématique, + * ou une problématique parente à celles choisies.". + * + * Add parent of each socialissue selected, and remove duplicates + * + * @param $accepted_issues + */ + private function addParentIssues($accepted_issues): array + { + $array = []; + + foreach ($accepted_issues as $i) { + /** @var SocialIssue $i */ + if ($i->hasParent()) { + $array[] = $i->getParent(); + } + $array[] = $i; + } + + return $this->removeDuplicate($array); + } + + private function removeDuplicate(array $array): array + { + $ids = array_map(static function ($item) { + return $item->getId(); + }, $array); + + $unique_ids = array_unique($ids); + + return array_values( + array_intersect_key($array, $unique_ids) + ); + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/StepFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/StepFilter.php index 1985031de..a7d218acc 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/StepFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/StepFilter.php @@ -1,21 +1,28 @@ AccompanyingPeriod::STEP_DRAFT, @@ -23,8 +30,6 @@ class StepFilter implements FilterInterface 'Closed' => AccompanyingPeriod::STEP_CLOSED, ]; - private const DEFAULT_CHOICE = AccompanyingPeriod::STEP_CONFIRMED; - /** * @var TranslatorInterface */ @@ -35,31 +40,6 @@ class StepFilter implements FilterInterface $this->translator = $translator; } - public function buildForm(FormBuilderInterface $builder) - { - $builder->add('accepted_steps', ChoiceType::class, [ - 'choices' => self::STEPS, - 'multiple' => false, - 'expanded' => true, - 'empty_data' => self::DEFAULT_CHOICE, - 'data' => self::DEFAULT_CHOICE, - ]); - } - - public function getTitle() - { - return 'Filter by step'; - } - - public function describeAction($data, $format = 'string') - { - $step = array_flip(self::STEPS)[$data['accepted_steps']]; - - return ["Filtered by steps: only %step%", [ - '%step%' => $this->translator->trans($step) - ]]; - } - public function addRole() { return null; @@ -85,4 +65,28 @@ class StepFilter implements FilterInterface return Declarations::ACP_TYPE; } -} \ No newline at end of file + public function buildForm(FormBuilderInterface $builder) + { + $builder->add('accepted_steps', ChoiceType::class, [ + 'choices' => self::STEPS, + 'multiple' => false, + 'expanded' => true, + 'empty_data' => self::DEFAULT_CHOICE, + 'data' => self::DEFAULT_CHOICE, + ]); + } + + public function describeAction($data, $format = 'string') + { + $step = array_flip(self::STEPS)[$data['accepted_steps']]; + + return ['Filtered by steps: only %step%', [ + '%step%' => $this->translator->trans($step), + ]]; + } + + public function getTitle() + { + return 'Filter by step'; + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/EvaluationTypeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/EvaluationTypeFilter.php index 6df5e38bf..d467679de 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/EvaluationTypeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/EvaluationTypeFilter.php @@ -1,5 +1,14 @@ translatableStringHelper = $translatableStringHelper; } - /** - * @inheritDoc - */ - public function buildForm(FormBuilderInterface $builder) - { - $builder->add('accepted_evaluationtype', EntityType::class, [ - 'class' => Evaluation::class, - 'choice_label' => function (Evaluation $ev): string { - return $this->translatableStringHelper->localize($ev->getTitle()); - }, - 'multiple' => true, - 'expanded' => true - ]); - } - - /** - * @inheritDoc - */ - public function getTitle(): string - { - return 'Filter by evaluation type'; - } - - /** - * @inheritDoc - */ - public function describeAction($data, $format = 'string'): array - { - $evals = []; - - foreach ($data['accepted_evaluationtype'] as $ev) { - $evals[] = $this->translatableStringHelper->localize($ev->getTitle()); - } - - return ['Filtered by evaluation type: only %evals%', [ - '%evals%' => implode(", ou ", $evals) - ]]; - } - - /** - * @inheritDoc - */ public function addRole() { return null; } - /** - * @inheritDoc - */ public function alterQuery(QueryBuilder $qb, $data) { $where = $qb->getDQLPart('where'); $clause = $qb->expr()->in('eval.evaluation', ':evaluationtype'); - + if ($where instanceof Andx) { $where->add($clause); } else { @@ -86,11 +50,38 @@ final class EvaluationTypeFilter implements FilterInterface $qb->setParameter('evaluationtype', $data['accepted_evaluationtype']); } - /** - * @inheritDoc - */ public function applyOn(): string { return Declarations::EVAL_TYPE; } -} \ No newline at end of file + + public function buildForm(FormBuilderInterface $builder) + { + $builder->add('accepted_evaluationtype', EntityType::class, [ + 'class' => Evaluation::class, + 'choice_label' => function (Evaluation $ev): string { + return $this->translatableStringHelper->localize($ev->getTitle()); + }, + 'multiple' => true, + 'expanded' => true, + ]); + } + + public function describeAction($data, $format = 'string'): array + { + $evals = []; + + foreach ($data['accepted_evaluationtype'] as $ev) { + $evals[] = $this->translatableStringHelper->localize($ev->getTitle()); + } + + return ['Filtered by evaluation type: only %evals%', [ + '%evals%' => implode(', ou ', $evals), + ]]; + } + + public function getTitle(): string + { + return 'Filter by evaluation type'; + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/MaxDateFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/MaxDateFilter.php index c69e15d9e..0524e3bba 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/MaxDateFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/MaxDateFilter.php @@ -1,5 +1,14 @@ translator = $translator; } - /** - * @inheritDoc - */ - public function buildForm(FormBuilderInterface $builder) - { - $builder->add('maxdate', ChoiceType::class, [ - 'choices' => self::MAXDATE_CHOICES, - 'multiple' => false, - 'expanded' => true - ]); - } - - /** - * @inheritDoc - */ - public function getTitle(): string - { - return 'Filter by maxdate'; - } - - /** - * @inheritDoc - */ - public function describeAction($data, $format = 'string'): array - { - foreach (self::MAXDATE_CHOICES as $k => $v) { - if ($v === $data['maxdate']) { - $choice = $k; - } - } - - return ['Filtered by maxdate: only %choice%', [ - '%choice%' => $this->translator->trans($choice) - ]]; - } - - /** - * @inheritDoc - */ public function addRole() { return null; } - /** - * @inheritDoc - */ public function alterQuery(QueryBuilder $qb, $data) { $where = $qb->getDQLPart('where'); - if ($data['maxdate'] === true) { + if (true === $data['maxdate']) { $clause = $qb->expr()->isNotNull('eval.maxDate'); } else { $clause = $qb->expr()->isNull('eval.maxDate'); @@ -90,11 +57,35 @@ class MaxDateFilter implements FilterInterface $qb->add('where', $where); } - /** - * @inheritDoc - */ public function applyOn(): string { return Declarations::EVAL_TYPE; } -} \ No newline at end of file + + public function buildForm(FormBuilderInterface $builder) + { + $builder->add('maxdate', ChoiceType::class, [ + 'choices' => self::MAXDATE_CHOICES, + 'multiple' => false, + 'expanded' => true, + ]); + } + + public function describeAction($data, $format = 'string'): array + { + foreach (self::MAXDATE_CHOICES as $k => $v) { + if ($v === $data['maxdate']) { + $choice = $k; + } + } + + return ['Filtered by maxdate: only %choice%', [ + '%choice%' => $this->translator->trans($choice), + ]]; + } + + public function getTitle(): string + { + return 'Filter by maxdate'; + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/HouseholdFilters/CompositionFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/HouseholdFilters/CompositionFilter.php index 78aba8bf7..95170cb10 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/HouseholdFilters/CompositionFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/HouseholdFilters/CompositionFilter.php @@ -1,5 +1,14 @@ translatableStringHelper = $translatableStringHelper; } - /** - * @inheritDoc - */ - public function buildForm(FormBuilderInterface $builder) - { - $builder - ->add('accepted_composition', EntityType::class, [ - 'class' => HouseholdCompositionType::class, - 'choice_label' => function (HouseholdCompositionType $type) { - return $this->translatableStringHelper->localize( - $type->getLabel() - ); - }, - 'multiple' => true, - 'expanded' => true, - ]) - ->add('on_date', ChillDateType::class, [ - 'data' => new \DateTime('now'), - ]) - ; - } - - /** - * @inheritDoc - */ - public function getTitle(): string - { - return 'Filter by composition'; - } - - /** - * @inheritDoc - */ - public function describeAction($data, $format = 'string'): array - { - $compositions = []; - - foreach ($data['accepted_composition'] as $c) { - $compositions[] = $this->translatableStringHelper->localize( - $c->getLabel() - ); - } - - return ['Filtered by composition: only %compositions% on %ondate%', [ - '%compositions%' => implode(", ou ", $compositions), - '%ondate%' => $data['on_date']->format('d-m-Y') - ]]; - } - - /** - * @inheritDoc - */ public function addRole() { return null; } - /** - * @inheritDoc - */ public function alterQuery(QueryBuilder $qb, $data) { - if (!in_array('composition', $qb->getAllAliases())) { + if (!in_array('composition', $qb->getAllAliases(), true)) { $qb->join('household.compositions', 'composition'); } @@ -113,11 +69,47 @@ class CompositionFilter implements FilterInterface $qb->setParameter('ondate', $data['on_date'], Types::DATE_MUTABLE); } - /** - * @inheritDoc - */ public function applyOn(): string { return Declarations::HOUSEHOLD_TYPE; } -} \ No newline at end of file + + public function buildForm(FormBuilderInterface $builder) + { + $builder + ->add('accepted_composition', EntityType::class, [ + 'class' => HouseholdCompositionType::class, + 'choice_label' => function (HouseholdCompositionType $type) { + return $this->translatableStringHelper->localize( + $type->getLabel() + ); + }, + 'multiple' => true, + 'expanded' => true, + ]) + ->add('on_date', ChillDateType::class, [ + 'data' => new DateTime('now'), + ]); + } + + public function describeAction($data, $format = 'string'): array + { + $compositions = []; + + foreach ($data['accepted_composition'] as $c) { + $compositions[] = $this->translatableStringHelper->localize( + $c->getLabel() + ); + } + + return ['Filtered by composition: only %compositions% on %ondate%', [ + '%compositions%' => implode(', ou ', $compositions), + '%ondate%' => $data['on_date']->format('d-m-Y'), + ]]; + } + + public function getTitle(): string + { + return 'Filter by composition'; + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AgeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AgeFilter.php index 47fb37214..e07d03e04 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AgeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AgeFilter.php @@ -6,7 +6,7 @@ * For the full copyright and license information, please view * the LICENSE file that was distributed with this source code. */ - + declare(strict_types=1); namespace Chill\PersonBundle\Export\Filter\PersonFilters; @@ -38,10 +38,12 @@ class AgeFilter implements ExportElementValidatedInterface, FilterInterface $calc = $data['date_calc']; $clause = $qb->expr()->andX( - $qb->expr()->gte('DATE_DIFF(:calc_date, person.birthdate)/365', + $qb->expr()->gte( + 'DATE_DIFF(:calc_date, person.birthdate)/365', ':min_age' ), - $qb->expr()->lte('DATE_DIFF(:calc_date, person.birthdate)/365', + $qb->expr()->lte( + 'DATE_DIFF(:calc_date, person.birthdate)/365', ':max_age' ) ); diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/BirthdateFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/BirthdateFilter.php index e26e3697d..2ab482039 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/BirthdateFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/BirthdateFilter.php @@ -17,7 +17,6 @@ use Chill\MainBundle\Form\Type\ChillDateType; use Chill\PersonBundle\Export\Declarations; use DateTime; use Doctrine\ORM\Query\Expr; -use Symfony\Component\Form\Extension\Core\Type\DateType; use Symfony\Component\Validator\Context\ExecutionContextInterface; class BirthdateFilter implements ExportElementValidatedInterface, FilterInterface @@ -56,12 +55,12 @@ class BirthdateFilter implements ExportElementValidatedInterface, FilterInterfac { $builder->add('date_from', ChillDateType::class, [ 'label' => 'Born after this date', - 'data' => new DateTime() + 'data' => new DateTime(), ]); $builder->add('date_to', ChillDateType::class, [ 'label' => 'Born before this date', - 'data' => new DateTime() + 'data' => new DateTime(), ]); } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/DeadOrAliveFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/DeadOrAliveFilter.php index aaef76436..457378731 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/DeadOrAliveFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/DeadOrAliveFilter.php @@ -34,15 +34,15 @@ class DeadOrAliveFilter implements FilterInterface $personState = $data['person_state']; $calc = $data['date_calc']; - if ($personState == 'alive') { + if ('alive' === $personState) { $clause = $qb->expr()->orX( - $qb->expr()->andX( - $qb->expr()->isNull('person.deathdate'), - $qb->expr()->lte( + $qb->expr()->andX( + $qb->expr()->isNull('person.deathdate'), + $qb->expr()->lte( 'person.birthdate', ':date_calc' ) - ), + ), $qb->expr()->andX( $qb->expr()->isNotNull('person.deathdate'), $qb->expr()->gt( diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/FamilySituationFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/FamilySituationFilter.php index e1a6c7529..895f83e9d 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/FamilySituationFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/FamilySituationFilter.php @@ -12,7 +12,6 @@ declare(strict_types=1); namespace Chill\PersonBundle\Export\Filter\PersonFilters; use Chill\MainBundle\Export\FilterInterface; -use Chill\PersonBundle\Entity\Household\HouseholdCompositionType; use Chill\PersonBundle\Export\Declarations; use DateTime; use Symfony\Component\Form\Extension\Core\Type\DateType; @@ -27,7 +26,6 @@ class FamilySituationFilter implements FilterInterface public function alterQuery(\Doctrine\ORM\QueryBuilder $qb, $data) { - } public function applyOn() diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php index d8c0e1343..b2eef5285 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php @@ -36,24 +36,6 @@ class ResidentialAddressAtThirdpartyFilter implements FilterInterface return null; } - public function buildForm(FormBuilderInterface $builder) - { - $builder->add('thirdparty_cat', EntityType::class, [ - 'class' => ThirdPartyCategory::class, - 'label' => 'Category', - 'choice_label' => function (ThirdPartyCategory $tpc) { - return $this->translatableStringHelper->localize($tpc->getName()); - }, - 'multiple' => true, - 'expanded' => true - ]); - - $builder->add('date_calc', ChillDateType::class, [ - 'label' => 'Date during which residential address was valid', - 'data' => new DateTime('now'), - ]); - } - public function alterQuery(QueryBuilder $qb, $data) { $qb->resetDQLPart('from'); @@ -63,7 +45,7 @@ class ResidentialAddressAtThirdpartyFilter implements FilterInterface $qb->join('person.center', 'center'); $qb->join('ra.hostThirdParty', 't'); $qb->join('t.categories', 'tc'); - + $where = $qb->getDQLPart('where'); $clause = $qb->expr()->andX( $qb->expr()->isNotNull('ra.hostThirdParty'), @@ -87,17 +69,34 @@ class ResidentialAddressAtThirdpartyFilter implements FilterInterface return Declarations::PERSON_TYPE; } + public function buildForm(FormBuilderInterface $builder) + { + $builder->add('thirdparty_cat', EntityType::class, [ + 'class' => ThirdPartyCategory::class, + 'label' => 'Category', + 'choice_label' => function (ThirdPartyCategory $tpc) { + return $this->translatableStringHelper->localize($tpc->getName()); + }, + 'multiple' => true, + 'expanded' => true, + ]); + + $builder->add('date_calc', ChillDateType::class, [ + 'label' => 'Date during which residential address was valid', + 'data' => new DateTime('now'), + ]); + } public function describeAction($data, $format = 'string') { return ['Filtered by person\'s who have a residential address located at a thirdparty of type %thirdparty_type% and valid on %date_calc%', [ '%thirdparty_type%' => $this->translatableStringHelper->localize($data['thirdparty_cat'][0]->getName()), '%date_calc%' => $data['date_calc']->format('d-m-Y'), - ],]; + ]]; } public function getTitle() { return 'Filtered by person\'s who have a residential address located at a thirdparty of type'; } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtUserFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtUserFilter.php index 835185db5..38825e022 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtUserFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtUserFilter.php @@ -13,7 +13,6 @@ namespace Chill\PersonBundle\Export\Filter\PersonFilters; use Chill\MainBundle\Export\FilterInterface; use Chill\PersonBundle\Export\Declarations; -use Doctrine\ORM\Query\Expr; use Doctrine\ORM\Query\Expr\Andx; use Doctrine\ORM\QueryBuilder; @@ -31,7 +30,7 @@ class ResidentialAddressAtUserFilter implements FilterInterface $qb->join('ra.person', 'person'); $qb->join('person.center', 'center'); - + $where = $qb->getDQLPart('where'); $clause = $qb->expr()->isNotNull('ra.hostPerson'); @@ -42,7 +41,6 @@ class ResidentialAddressAtUserFilter implements FilterInterface } $qb->add('where', $where); - } public function applyOn() @@ -64,4 +62,4 @@ class ResidentialAddressAtUserFilter implements FilterInterface { return 'Filtered by person\'s who have a residential address located at another user'; } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/JobFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/JobFilter.php index 80efd03e3..8986d4676 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/JobFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/JobFilter.php @@ -19,12 +19,10 @@ use Doctrine\ORM\Query\Expr\Andx; use Doctrine\ORM\QueryBuilder; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Security\Core\Security; use Symfony\Contracts\Translation\TranslatorInterface; class JobFilter implements FilterInterface { - protected TranslatorInterface $translator; private TranslatableStringHelper $translatableStringHelper; @@ -37,34 +35,6 @@ class JobFilter implements FilterInterface $this->translatableStringHelper = $translatableStringHelper; } - public function buildForm(FormBuilderInterface $builder) - { - $builder->add('job', EntityType::class, [ - 'class' => UserJob::class, - 'choice_label' => function (UserJob $j) { - return $this->translatableStringHelper->localize( - $j->getLabel() - ); - }, - 'multiple' => true, - 'expanded' => true - ]); - } - - public function describeAction($data, $format = 'string') - { - $userjobs = []; - - foreach ($data['job'] as $j) { - $userjobs[] = $this->translatableStringHelper->localize( - $j->getLabel()); - } - - return ['Filtered by treating agent job: only %jobs%', [ - '%jobs%' => implode(', ou ', $userjobs) - ]]; - } - public function addRole() { return null; @@ -92,9 +62,37 @@ class JobFilter implements FilterInterface return Declarations::SOCIAL_WORK_ACTION_TYPE; } + public function buildForm(FormBuilderInterface $builder) + { + $builder->add('job', EntityType::class, [ + 'class' => UserJob::class, + 'choice_label' => function (UserJob $j) { + return $this->translatableStringHelper->localize( + $j->getLabel() + ); + }, + 'multiple' => true, + 'expanded' => true, + ]); + } + + public function describeAction($data, $format = 'string') + { + $userjobs = []; + + foreach ($data['job'] as $j) { + $userjobs[] = $this->translatableStringHelper->localize( + $j->getLabel() + ); + } + + return ['Filtered by treating agent job: only %jobs%', [ + '%jobs%' => implode(', ou ', $userjobs), + ]]; + } public function getTitle(): string { return 'Filter by treating agent job'; } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ReferrerFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ReferrerFilter.php index 1ca1d39d2..efe193a6e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ReferrerFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ReferrerFilter.php @@ -1,5 +1,14 @@ userRender = $userRender; } - /** - * @inheritDoc - */ - public function buildForm(FormBuilderInterface $builder) - { - $builder->add('accepted_agents', EntityType::class, [ - 'class' => User::class, - 'choice_label' => function (User $u) { - return $this->userRender->renderString($u, []); - }, - 'multiple' => true, - 'expanded' => true - ]); - - } - - /** - * @inheritDoc - */ - public function getTitle(): string - { - return 'Filter by treating agent'; - } - - /** - * @inheritDoc - */ - public function describeAction($data, $format = 'string'): array - { - $users = []; - - foreach ($data['accepted_agents'] as $r) { - $users[] = $r; - } - - return [ - 'Filtered by treating agent: only %agents%', [ - '%agents' => implode(", ou ", $users) - ]]; - } - - /** - * @inheritDoc - */ public function addRole() { return null; } - /** - * @inheritDoc - */ public function alterQuery(QueryBuilder $qb, $data) { $qb->join('acpw.referrers', 'u'); @@ -90,11 +51,39 @@ class ReferrerFilter implements FilterInterface $qb->setParameter('agents', $data['accepted_agents']); } - /** - * @inheritDoc - */ public function applyOn(): string { return Declarations::SOCIAL_WORK_ACTION_TYPE; } -} \ No newline at end of file + + public function buildForm(FormBuilderInterface $builder) + { + $builder->add('accepted_agents', EntityType::class, [ + 'class' => User::class, + 'choice_label' => function (User $u) { + return $this->userRender->renderString($u, []); + }, + 'multiple' => true, + 'expanded' => true, + ]); + } + + public function describeAction($data, $format = 'string'): array + { + $users = []; + + foreach ($data['accepted_agents'] as $r) { + $users[] = $r; + } + + return [ + 'Filtered by treating agent: only %agents%', [ + '%agents' => implode(', ou ', $users), + ], ]; + } + + public function getTitle(): string + { + return 'Filter by treating agent'; + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ScopeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ScopeFilter.php index 6588efc18..b828a6c47 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ScopeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ScopeFilter.php @@ -23,7 +23,6 @@ use Symfony\Contracts\Translation\TranslatorInterface; class ScopeFilter implements FilterInterface { - protected TranslatorInterface $translator; private TranslatableStringHelper $translatableStringHelper; @@ -36,34 +35,6 @@ class ScopeFilter implements FilterInterface $this->translatableStringHelper = $translatableStringHelper; } - public function buildForm(FormBuilderInterface $builder) - { - $builder->add('scope', EntityType::class, [ - 'class' => Scope::class, - 'choice_label' => function (Scope $s) { - return $this->translatableStringHelper->localize( - $s->getName() - ); - }, - 'multiple' => true, - 'expanded' => true - ]); - } - - public function describeAction($data, $format = 'string') - { - $scopes = []; - - foreach ($data['scope'] as $s) { - $scopes[] = $this->translatableStringHelper->localize( - $s->getName()); - } - - return ['Filtered by treating agent scope: only %scopes%', [ - '%scopes%' => implode(', ou ', $scopes) - ]]; - } - public function addRole() { return null; @@ -91,9 +62,37 @@ class ScopeFilter implements FilterInterface return Declarations::SOCIAL_WORK_ACTION_TYPE; } + public function buildForm(FormBuilderInterface $builder) + { + $builder->add('scope', EntityType::class, [ + 'class' => Scope::class, + 'choice_label' => function (Scope $s) { + return $this->translatableStringHelper->localize( + $s->getName() + ); + }, + 'multiple' => true, + 'expanded' => true, + ]); + } + + public function describeAction($data, $format = 'string') + { + $scopes = []; + + foreach ($data['scope'] as $s) { + $scopes[] = $this->translatableStringHelper->localize( + $s->getName() + ); + } + + return ['Filtered by treating agent scope: only %scopes%', [ + '%scopes%' => implode(', ou ', $scopes), + ]]; + } public function getTitle() { return 'Filter by treating agent scope'; } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/SocialWorkTypeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/SocialWorkTypeFilter.php index efd8c93af..348e1e9b8 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/SocialWorkTypeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/SocialWorkTypeFilter.php @@ -1,24 +1,27 @@ socialActionRender = $socialActionRender; $this->translatableStringHelper = $translatableStringHelper; $this->socialActionRepository = $socialActionRepository; } - public function buildForm(FormBuilderInterface $builder) - { - $socialActions = $this->socialActionRepository->findAll(); - - $builder->add('actionType', ChoiceType::class, [ - 'choices' => $socialActions, - 'choice_label' => function (SocialAction $sa) { - return $this->socialActionRender->renderString($sa, []); - }, - 'multiple' => true, - 'expanded' => true - ]); - - $refreshGoals = function (FormInterface $form, SocialAction $actionType = null) { - - $goals = null === $actionType ? [] : $actionType->getGoals(); - - $form->add('goal', ChoiceType::class, [ - 'placeholder' => '', - 'choices' => $goals, - 'choice_label' => function (Goal $g) { - return $this->translatableStringHelper->localize($g->getTitle()); - }, - ]); - }; - - $builder->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) use ($refreshGoals) { - $data = $event->getData(); - dump($data); - - $refreshGoals($event->getForm(), $data); - }); - -/* $builder->get('actionType')->addEventListener( - FormEvents::POST_SUBMIT, - function (FormEvent $event) use ($refreshGoals) { - $actionType = $event->getForm()->getData(); - dump($actionType); - $refreshGoals($event->getForm()->getParent(), $actionType); - } - );*/ - } - - public function getTitle(): string - { - return 'Filter by type of action, objectives and results'; - } - - public function describeAction($data, $format = 'string'): array - { - $actionTypes = []; - $objectives = []; - $results = []; - - foreach ($data['actionType'] as $at) { - $actionTypes[] = $at->getTitle(); - } - foreach ($data['objectives'] as $o) { - $objectives[] = $o->getTitle(); - } - foreach ($data['results'] as $r) { - $results[] = $r->getTitle(); - } - - return ['Filtered by referrers: only %actionTypes%', [ - '%actionTypes%' => implode(', ou ', $actionTypes) - ]]; - } - public function addRole() { return null; @@ -136,4 +68,74 @@ class SocialWorkTypeFilter implements FilterInterface { return Declarations::SOCIAL_WORK_ACTION_TYPE; } + + public function buildForm(FormBuilderInterface $builder) + { + $socialActions = $this->socialActionRepository->findAll(); + + $builder->add('actionType', ChoiceType::class, [ + 'choices' => $socialActions, + 'choice_label' => function (SocialAction $sa) { + return $this->socialActionRender->renderString($sa, []); + }, + 'multiple' => true, + 'expanded' => true, + ]); + + $refreshGoals = function (FormInterface $form, ?SocialAction $actionType = null) { + $goals = null === $actionType ? [] : $actionType->getGoals(); + + $form->add('goal', ChoiceType::class, [ + 'placeholder' => '', + 'choices' => $goals, + 'choice_label' => function (Goal $g) { + return $this->translatableStringHelper->localize($g->getTitle()); + }, + ]); + }; + + $builder->addEventListener(FormEvents::PRE_SUBMIT, static function (FormEvent $event) use ($refreshGoals) { + $data = $event->getData(); + dump($data); + + $refreshGoals($event->getForm(), $data); + }); + + /* $builder->get('actionType')->addEventListener( + FormEvents::POST_SUBMIT, + function (FormEvent $event) use ($refreshGoals) { + $actionType = $event->getForm()->getData(); + dump($actionType); + $refreshGoals($event->getForm()->getParent(), $actionType); + } + );*/ + } + + public function describeAction($data, $format = 'string'): array + { + $actionTypes = []; + $objectives = []; + $results = []; + + foreach ($data['actionType'] as $at) { + $actionTypes[] = $at->getTitle(); + } + + foreach ($data['objectives'] as $o) { + $objectives[] = $o->getTitle(); + } + + foreach ($data['results'] as $r) { + $results[] = $r->getTitle(); + } + + return ['Filtered by referrers: only %actionTypes%', [ + '%actionTypes%' => implode(', ou ', $actionTypes), + ]]; + } + + public function getTitle(): string + { + return 'Filter by type of action, objectives and results'; + } } diff --git a/src/Bundle/ChillPersonBundle/Form/HouseholdCompositionTypeType.php b/src/Bundle/ChillPersonBundle/Form/HouseholdCompositionTypeType.php index f5d26da7f..ad95c9f7a 100644 --- a/src/Bundle/ChillPersonBundle/Form/HouseholdCompositionTypeType.php +++ b/src/Bundle/ChillPersonBundle/Form/HouseholdCompositionTypeType.php @@ -15,7 +15,6 @@ use Chill\MainBundle\Form\Type\TranslatableStringFormType; use Chill\PersonBundle\Entity\Household\HouseholdCompositionType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\CheckboxType; -use Symfony\Component\Form\Extension\Core\Type\NumberType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -36,4 +35,4 @@ class HouseholdCompositionTypeType extends AbstractType $resolver ->setDefault('class', HouseholdCompositionType::class); } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php index c2826485e..8a9fd42cd 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php @@ -35,11 +35,6 @@ final class AccompanyingPeriodWorkRepository implements ObjectRepository $this->repository = $entityManager->getRepository(AccompanyingPeriodWork::class); } - public function createQueryBuilder(string $alias, ?string $indexBy = null): QueryBuilder - { - return $this->repository->createQueryBuilder($alias, $indexBy); - } - public function countByAccompanyingPeriod(AccompanyingPeriod $period): int { return $this->repository->countByAccompanyingPeriod($period); @@ -61,6 +56,11 @@ final class AccompanyingPeriodWorkRepository implements ObjectRepository ->select('count(w)')->getQuery()->getSingleScalarResult(); } + public function createQueryBuilder(string $alias, ?string $indexBy = null): QueryBuilder + { + return $this->repository->createQueryBuilder($alias, $indexBy); + } + public function find($id): ?AccompanyingPeriodWork { return $this->repository->find($id); diff --git a/src/Bundle/ChillPersonBundle/Repository/PersonRepository.php b/src/Bundle/ChillPersonBundle/Repository/PersonRepository.php index 309e5f086..144cea507 100644 --- a/src/Bundle/ChillPersonBundle/Repository/PersonRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/PersonRepository.php @@ -31,11 +31,6 @@ final class PersonRepository implements ObjectRepository $this->repository = $entityManager->getRepository(Person::class); } - public function createQueryBuilder(string $alias, ?string $indexBy = null): QueryBuilder - { - return $this->repository->createQueryBuilder($alias, $indexBy); - } - /** * @param $centers * @@ -56,6 +51,11 @@ final class PersonRepository implements ObjectRepository return $qb->getQuery()->getSingleScalarResult(); } + public function createQueryBuilder(string $alias, ?string $indexBy = null): QueryBuilder + { + return $this->repository->createQueryBuilder($alias, $indexBy); + } + public function find($id, $lockMode = null, $lockVersion = null): ?Person { return $this->repository->find($id, $lockMode, $lockVersion); diff --git a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php index 2144db5a3..8da2036d7 100644 --- a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php +++ b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php @@ -41,9 +41,9 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH ]; /** - * Give the ability to see statistics + * Give the ability to see all confidential courses. */ - public const STATS = 'CHILL_PERSON_ACCOMPANYING_PERIOD_STATS'; + public const CONFIDENTIAL_CRUD = 'CHILL_PERSON_ACCOMPANYING_PERIOD_CRUD_CONFIDENTIAL'; public const CREATE = 'CHILL_PERSON_ACCOMPANYING_PERIOD_CREATE'; @@ -88,6 +88,11 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH */ public const SEE_DETAILS = 'CHILL_PERSON_ACCOMPANYING_PERIOD_SEE_DETAILS'; + /** + * Give the ability to see statistics. + */ + public const STATS = 'CHILL_PERSON_ACCOMPANYING_PERIOD_STATS'; + /** * Right to toggle confidentiality. */ @@ -95,11 +100,6 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH public const TOGGLE_CONFIDENTIAL_ALL = 'CHILL_PERSON_ACCOMPANYING_PERIOD_TOGGLE_CONFIDENTIAL_ALL'; - /** - * Give the ability to see all confidential courses. - */ - public const CONFIDENTIAL_CRUD = 'CHILL_PERSON_ACCOMPANYING_PERIOD_CRUD_CONFIDENTIAL'; - /** * Right to toggle urgency of parcours. */ @@ -218,7 +218,6 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH return $token->getUser() === $subject->getUser(); } - } return $this->voterHelper->voteOnAttribute($attribute, $subject, $token); diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Export/CountAccompanyingCourseTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Export/CountAccompanyingCourseTest.php index d6fa9a843..6ce9827f3 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Export/CountAccompanyingCourseTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Export/CountAccompanyingCourseTest.php @@ -1,11 +1,24 @@ export = self::$container->get('chill.person.export.count_accompanyingcourse'); } - /** - * @inheritDoc - */ public function getExport() { return $this->export; } - /** - * @inheritDoc - */ public function getFormData(): array { return [[]]; } - /** - * @inheritDoc - */ public function getModifiersCombination() { return [[Declarations::ACP_TYPE]]; } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Export/CountSocialWorkActionsTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Export/CountSocialWorkActionsTest.php index d904f2eeb..6fd26ff74 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Export/CountSocialWorkActionsTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Export/CountSocialWorkActionsTest.php @@ -1,11 +1,23 @@ export = self::$container->get('chill.person.export.count_social_work_actions'); } - /** - * @inheritDoc - */ public function getExport() { return $this->export; } - /** - * @inheritDoc - */ public function getFormData(): array { return [[]]; } - /** - * @inheritDoc - */ public function getModifiersCombination() { return [[Declarations::SOCIAL_WORK_ACTION_TYPE]]; } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Export/StatAccompanyingCourseDurationTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Export/StatAccompanyingCourseDurationTest.php index 7c1420c86..543c938f2 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Export/StatAccompanyingCourseDurationTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Export/StatAccompanyingCourseDurationTest.php @@ -1,11 +1,25 @@ \DateTime::createFromFormat('Y-m-d', '2022-06-30')], + ['closingdate' => DateTime::createFromFormat('Y-m-d', '2022-06-30')], ]; } @@ -33,4 +47,4 @@ final class StatAccompanyingCourseDurationTest extends AbstractExportTest { return [[Declarations::ACP_TYPE]]; } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/ActiveOnDateFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/ActiveOnDateFilterTest.php index b66de0f28..81c132f7c 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/ActiveOnDateFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/ActiveOnDateFilterTest.php @@ -1,13 +1,27 @@ filter = self::$container->get('chill.person.export.filter_activeondate'); } - /** - * @inheritDoc - */ public function getFilter() { return $this->filter; } - /** - * @inheritDoc - */ public function getFormData(): array { return [ [ - 'on_date' => \DateTime::createFromFormat('Y-m-d', '2022-05-01'), + 'on_date' => DateTime::createFromFormat('Y-m-d', '2022-05-01'), ], ]; } - /** - * @inheritDoc - */ public function getQueryBuilders(): array { if (null === self::$kernel) { @@ -62,4 +67,4 @@ class ActiveOnDateFilterTest extends AbstractFilterTest ->select('acp.id'), ]; } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/ActiveOneDayBetweenDatesFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/ActiveOneDayBetweenDatesFilterTest.php index 051db8635..ab173d0b1 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/ActiveOneDayBetweenDatesFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/ActiveOneDayBetweenDatesFilterTest.php @@ -1,13 +1,27 @@ filter = self::$container->get('chill.person.export.filter_activeonedaybetweendates'); } - /** - * @inheritDoc - */ public function getFilter() { return $this->filter; } - /** - * @inheritDoc - */ public function getFormData(): array { return [ [ - 'date_from' => \DateTime::createFromFormat('Y-m-d', '2022-05-01'), - 'date_to' => \DateTime::createFromFormat('Y-m-d', '2022-06-01'), + 'date_from' => DateTime::createFromFormat('Y-m-d', '2022-05-01'), + 'date_to' => DateTime::createFromFormat('Y-m-d', '2022-06-01'), ], ]; } - /** - * @inheritDoc - */ public function getQueryBuilders(): array { if (null === self::$kernel) { @@ -63,4 +68,4 @@ class ActiveOneDayBetweenDatesFilterTest extends AbstractFilterTest ->select('acp.id'), ]; } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/ActivityTypeFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/ActivityTypeFilterTest.php index 315592ee9..f59039f35 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/ActivityTypeFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/ActivityTypeFilterTest.php @@ -1,5 +1,14 @@ filter = self::$container->get('chill.person.export.filter_activitytype'); } - /** - * @inheritDoc - */ public function getFilter() { return $this->filter; } - /** - * @inheritDoc - */ public function getFormData(): array { - $em = self::$container->get(EntityManagerInterface::class); $array = $em->createQueryBuilder() @@ -50,16 +56,13 @@ class ActivityTypeFilterTest extends AbstractFilterTest $data = []; - foreach($array as $t) { + foreach ($array as $t) { $data[] = ['accepted_activitytypes' => $t]; } return $data; } - /** - * @inheritDoc - */ public function getQueryBuilders(): array { if (null === self::$kernel) { @@ -74,4 +77,4 @@ class ActivityTypeFilterTest extends AbstractFilterTest ->select('acp.id'), ]; } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AdministrativeLocationFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AdministrativeLocationFilterTest.php index f974919aa..190729161 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AdministrativeLocationFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AdministrativeLocationFilterTest.php @@ -1,5 +1,14 @@ filter = self::$container->get('chill.person.export.filter_administrative_location'); } - /** - * @inheritDoc - */ public function getFilter() { return $this->filter; } - /** - * @inheritDoc - */ public function getFormData(): array { $em = self::$container->get(EntityManagerInterface::class); @@ -49,16 +56,13 @@ class AdministrativeLocationFilterTest extends AbstractFilterTest $data = []; - foreach($array as $l) { + foreach ($array as $l) { $data[] = ['accepted_locations' => $l]; } return $data; } - /** - * @inheritDoc - */ public function getQueryBuilders(): array { if (null === self::$kernel) { @@ -73,4 +77,4 @@ class AdministrativeLocationFilterTest extends AbstractFilterTest ->select('acp.id'), ]; } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/ClosingMotiveFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/ClosingMotiveFilterTest.php index cbfa1c306..d9403506d 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/ClosingMotiveFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/ClosingMotiveFilterTest.php @@ -1,5 +1,14 @@ filter = self::$container->get('chill.person.export.filter_closingmotive'); } - /** - * @inheritDoc - */ public function getFilter() { return $this->filter; } - /** - * @inheritDoc - */ public function getFormData(): array { $em = self::$container->get(EntityManagerInterface::class); @@ -47,19 +54,15 @@ class ClosingMotiveFilterTest extends AbstractFilterTest $data = []; - foreach($array as $m) { + foreach ($array as $m) { $data[] = ['accepted_closingmotives' => $m]; } return $data; } - /** - * @inheritDoc - */ public function getQueryBuilders(): array { - if (null === self::$kernel) { self::bootKernel(); } @@ -72,4 +75,4 @@ class ClosingMotiveFilterTest extends AbstractFilterTest ->from('ChillPersonBundle:AccompanyingPeriod', 'acp'), ]; } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/ConfidentialFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/ConfidentialFilterTest.php index 1d8573916..6229989fe 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/ConfidentialFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/ConfidentialFilterTest.php @@ -1,12 +1,25 @@ filter = self::$container->get('chill.person.export.filter_confidential'); } - /** - * @inheritDoc - */ public function getFilter() { return $this->filter; } - /** - * @inheritDoc - */ public function getFormData(): array { return [ ['accepted_confidentials' => true], - ['accepted_confidentials' => false] + ['accepted_confidentials' => false], ]; } - /** - * @inheritDoc - */ public function getQueryBuilders(): array { - if (null === self::$kernel) { self::bootKernel(); } @@ -60,4 +63,4 @@ class ConfidentialFilterTest extends AbstractFilterTest ->from('ChillPersonBundle:AccompanyingPeriod', 'acp'), ]; } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/EmergencyFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/EmergencyFilterTest.php index 0533a604a..7ed43ea65 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/EmergencyFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/EmergencyFilterTest.php @@ -1,12 +1,25 @@ true], - ['accepted_emergencies' => false] + ['accepted_emergencies' => false], ]; } public function getQueryBuilders(): array { - if (null === self::$kernel) { self::bootKernel(); } @@ -51,4 +63,4 @@ class EmergencyFilterTest extends AbstractFilterTest ->from('ChillPersonBundle:AccompanyingPeriod', 'acp'), ]; } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/EvaluationFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/EvaluationFilterTest.php index 310fde2c9..a4e39792c 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/EvaluationFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/EvaluationFilterTest.php @@ -1,5 +1,14 @@ filter = self::$container->get('chill.person.export.filter_evaluation'); } - /** - * @inheritDoc - */ public function getFilter() { return $this->filter; } - /** - * @inheritDoc - */ public function getFormData(): array { $em = self::$container->get(EntityManagerInterface::class); @@ -49,16 +56,13 @@ class EvaluationFilterTest extends AbstractFilterTest $data = []; - foreach($array as $e) { + foreach ($array as $e) { $data[] = ['accepted_evaluations' => $e]; } return $data; } - /** - * @inheritDoc - */ public function getQueryBuilders(): array { if (null === self::$kernel) { @@ -73,4 +77,4 @@ class EvaluationFilterTest extends AbstractFilterTest ->select('acp.id'), ]; } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/GeographicalUnitStatFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/GeographicalUnitStatFilterTest.php index 8a205e9ac..a2eef9038 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/GeographicalUnitStatFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/GeographicalUnitStatFilterTest.php @@ -1,13 +1,27 @@ filter = self::$container->get('chill.person.export.filter_geographicalunitstat'); } - /** - * @inheritDoc - */ public function getFilter() { return $this->filter; } - /** - * @inheritDoc - */ public function getFormData(): array { return [ [ - 'date' => \DateTime::createFromFormat('Y-m-d', '2022-05-01'), - 'accepted_loctype' => 'center' + 'date' => DateTime::createFromFormat('Y-m-d', '2022-05-01'), + 'accepted_loctype' => 'center', ], ]; } - /** - * @inheritDoc - */ public function getQueryBuilders(): array { if (null === self::$kernel) { @@ -63,4 +68,4 @@ class GeographicalUnitStatFilterTest extends AbstractFilterTest ->select('acp.id'), ]; } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/IntensityFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/IntensityFilterTest.php index c39602cf8..65d2c6880 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/IntensityFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/IntensityFilterTest.php @@ -1,12 +1,25 @@ filter = self::$container->get('chill.person.export.filter_intensity'); } - /** - * @inheritDoc - */ public function getFilter() { return $this->filter; } - /** - * @inheritDoc - */ public function getFormData(): array { return [ ['accepted_intensities' => 'occasional'], - ['accepted_intensities' => 'regular'] + ['accepted_intensities' => 'regular'], ]; } - /** - * @inheritDoc - */ public function getQueryBuilders(): array { - if (null === self::$kernel) { self::bootKernel(); } @@ -60,4 +63,4 @@ class IntensityFilterTest extends AbstractFilterTest ->from('ChillPersonBundle:AccompanyingPeriod', 'acp'), ]; } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/JobFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/JobFilterTest.php index 6f7546b4b..9a9bb2498 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/JobFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/JobFilterTest.php @@ -1,12 +1,24 @@ filter = self::$container->get('chill.person.export.filter_job'); } - /** - * @inheritDoc - */ public function getFilter() { return $this->filter; } - /** - * @inheritDoc - */ public function getFormData(): array { return []; } - /** - * @inheritDoc - */ public function getQueryBuilders(): array { - if (null === self::$kernel) { self::bootKernel(); } @@ -57,4 +59,4 @@ class JobFilterTest extends AbstractFilterTest ->from('ChillPersonBundle:AccompanyingPeriodWork', 'acpw'), ]; } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/OpenBetweenDatesFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/OpenBetweenDatesFilterTest.php index ccb7e38da..5e4ae3d0a 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/OpenBetweenDatesFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/OpenBetweenDatesFilterTest.php @@ -1,13 +1,27 @@ filter = self::$container->get('chill.person.export.filter_openbetweendates'); } - /** - * @inheritDoc - */ public function getFilter() { return $this->filter; } - /** - * @inheritDoc - */ public function getFormData(): array { return [ [ - 'date_from' => \DateTime::createFromFormat('Y-m-d', '2022-05-01'), - 'date_to' => \DateTime::createFromFormat('Y-m-d', '2022-06-01'), + 'date_from' => DateTime::createFromFormat('Y-m-d', '2022-05-01'), + 'date_to' => DateTime::createFromFormat('Y-m-d', '2022-06-01'), ], ]; } - /** - * @inheritDoc - */ public function getQueryBuilders(): array { if (null === self::$kernel) { @@ -63,4 +68,4 @@ class OpenBetweenDatesFilterTest extends AbstractFilterTest ->select('acp.id'), ]; } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/OriginFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/OriginFilterTest.php index 7aa1f1c7a..f37cebc72 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/OriginFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/OriginFilterTest.php @@ -1,5 +1,14 @@ filter = self::$container->get('chill.person.export.filter_origin'); } - /** - * @inheritDoc - */ public function getFilter() { return $this->filter; } - /** - * @inheritDoc - */ public function getFormData(): array { $em = self::$container->get(EntityManagerInterface::class); @@ -47,19 +54,15 @@ class OriginFilterTest extends AbstractFilterTest $data = []; - foreach($array as $l) { + foreach ($array as $l) { $data[] = ['accepted_origins' => $l]; } return $data; } - /** - * @inheritDoc - */ public function getQueryBuilders(): array { - if (null === self::$kernel) { self::bootKernel(); } @@ -72,4 +75,4 @@ class OriginFilterTest extends AbstractFilterTest ->from('ChillPersonBundle:AccompanyingPeriod', 'acp'), ]; } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/ReferrerFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/ReferrerFilterTest.php index ec84c7027..84340e267 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/ReferrerFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/ReferrerFilterTest.php @@ -1,5 +1,14 @@ filter = self::$container->get('chill.person.export.filter_referrer'); } - /** - * @inheritDoc - */ public function getFilter() { return $this->filter; } - /** - * @inheritDoc - */ public function getFormData(): array { $em = self::$container->get(EntityManagerInterface::class); @@ -48,16 +55,13 @@ class ReferrerFilterTest extends AbstractFilterTest $data = []; - foreach($array as $u) { + foreach ($array as $u) { $data[] = ['accepted_referrers' => $u]; } return $data; } - /** - * @inheritDoc - */ public function getQueryBuilders(): array { if (null === self::$kernel) { @@ -79,4 +83,4 @@ class ReferrerFilterTest extends AbstractFilterTest ->select('r.id'), ]; } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/RequestorFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/RequestorFilterTest.php index f8b01aea1..50dcb20f5 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/RequestorFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/RequestorFilterTest.php @@ -1,14 +1,26 @@ filter = self::$container->get('chill.person.export.filter_requestor'); } - /** - * @inheritDoc - */ public function getFilter() { return $this->filter; } - /** - * @inheritDoc - */ public function getFormData(): array { return [ @@ -47,9 +53,6 @@ class RequestorFilterTest extends AbstractFilterTest ]; } - /** - * @inheritDoc - */ public function getQueryBuilders(): array { if (null === self::$kernel) { @@ -64,4 +67,4 @@ class RequestorFilterTest extends AbstractFilterTest ->select('acp.id'), ]; } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/ScopeFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/ScopeFilterTest.php index d387769cc..1269f0372 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/ScopeFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/ScopeFilterTest.php @@ -1,12 +1,24 @@ getLocale()->willReturn('fr'); $this->filter = self::$container->get('chill.person.export.filter_scope'); - } - /** - * @inheritDoc - */ public function getFilter() { return $this->filter; } - /** - * @inheritDoc - */ public function getFormData(): array { return []; } - /** - * @inheritDoc - */ public function getQueryBuilders(): array { - if (null === self::$kernel) { self::bootKernel(); } @@ -58,4 +59,4 @@ class ScopeFilterTest extends AbstractFilterTest ->from('ChillPersonBundle:AccompanyingPeriodWork', 'acpw'), ]; } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialActionFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialActionFilterTest.php index 6de54c23a..c7834a33a 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialActionFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialActionFilterTest.php @@ -1,5 +1,14 @@ filter = self::$container->get('chill.person.export.filter_socialaction'); } - /** - * @inheritDoc - */ public function getFilter() { return $this->filter; } - /** - * @inheritDoc - */ public function getFormData(): array { $em = self::$container->get(EntityManagerInterface::class); @@ -49,16 +56,13 @@ class SocialActionFilterTest extends AbstractFilterTest $data = []; - foreach($array as $a) { + foreach ($array as $a) { $data[] = ['accepted_socialactions' => $a]; } return $data; } - /** - * @inheritDoc - */ public function getQueryBuilders(): array { if (null === self::$kernel) { @@ -73,4 +77,4 @@ class SocialActionFilterTest extends AbstractFilterTest ->select('acp.id'), ]; } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialIssueFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialIssueFilterTest.php index ac092884b..16e77381f 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialIssueFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialIssueFilterTest.php @@ -1,5 +1,14 @@ filter = self::$container->get('chill.person.export.filter_socialissue'); } - /** - * @inheritDoc - */ public function getFilter() { return $this->filter; } - /** - * @inheritDoc - */ public function getFormData(): array { $em = self::$container->get(EntityManagerInterface::class); @@ -47,19 +54,15 @@ class SocialIssueFilterTest extends AbstractFilterTest $data = []; - foreach($array as $i) { + foreach ($array as $i) { $data[] = ['accepted_socialissues' => $i]; } return $data; } - /** - * @inheritDoc - */ public function getQueryBuilders(): array { - if (null === self::$kernel) { self::bootKernel(); } @@ -72,4 +75,4 @@ class SocialIssueFilterTest extends AbstractFilterTest ->from('ChillPersonBundle:AccompanyingPeriod', 'acp'), ]; } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/StepFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/StepFilterTest.php index 1a8dfd2ff..ac75b2123 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/StepFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/StepFilterTest.php @@ -1,12 +1,25 @@ filter = self::$container->get('chill.person.export.filter_step'); } - /** - * @inheritDoc - */ public function getFilter() { return $this->filter; } - /** - * @inheritDoc - */ public function getFormData(): array { return [ @@ -43,12 +50,8 @@ class StepFilterTest extends AbstractFilterTest ]; } - /** - * @inheritDoc - */ public function getQueryBuilders(): array { - if (null === self::$kernel) { self::bootKernel(); } @@ -61,4 +64,4 @@ class StepFilterTest extends AbstractFilterTest ->from('ChillPersonBundle:AccompanyingPeriod', 'acp'), ]; } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/UserJobFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/UserJobFilterTest.php index 452728384..3c91c8efa 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/UserJobFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/UserJobFilterTest.php @@ -1,12 +1,25 @@ filter = self::$container->get('chill.person.export.filter_userjob'); } - /** - * @inheritDoc - */ public function getFilter() { return $this->filter; } - /** - * @inheritDoc - */ public function getFormData(): array { return []; } - /** - * @inheritDoc - */ public function getQueryBuilders(): array { - if (null === self::$kernel) { self::bootKernel(); } @@ -57,4 +60,4 @@ class UserJobFilterTest extends AbstractFilterTest ->from('ChillPersonBundle:AccompanyingPeriod', 'acp'), ]; } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/UserScopeFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/UserScopeFilterTest.php index fd22ded6e..72d5eaf57 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/UserScopeFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/UserScopeFilterTest.php @@ -1,12 +1,25 @@ getLocale()->willReturn('fr'); $this->filter = self::$container->get('chill.person.export.filter_userscope'); - } - /** - * @inheritDoc - */ public function getFilter() { return $this->filter; } - /** - * @inheritDoc - */ public function getFormData(): array { return []; } - /** - * @inheritDoc - */ public function getQueryBuilders(): array { - if (null === self::$kernel) { self::bootKernel(); } @@ -58,4 +60,4 @@ class UserScopeFilterTest extends AbstractFilterTest ->from('ChillPersonBundle:AccompanyingPeriod', 'acp'), ]; } -} \ No newline at end of file +} From a967e1ed17f5df6cba4c6f58847dcddaedd3ac8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 5 Oct 2022 15:23:28 +0200 Subject: [PATCH 3/3] fix cs --- .../ACPAggregators/DateAggregator.php | 5 +- .../Aggregator/ActivityTypeAggregator.php | 1 - .../Aggregator/ActivityUserAggregator.php | 2 +- .../ActivityReasonAggregator.php | 4 +- .../LinkedToACP/AvgActivityDuration.php | 10 +- .../LinkedToACP/AvgActivityVisitDuration.php | 13 +- .../Export/LinkedToACP/CountActivity.php | 7 +- .../LinkedToACP/SumActivityDuration.php | 10 +- .../LinkedToACP/SumActivityVisitDuration.php | 10 +- .../Export/LinkedToPerson/CountActivity.php | 3 +- .../Filter/ACPFilters/ActivityTypeFilter.php | 2 +- .../Export/Filter/ActivityTypeFilter.php | 6 +- .../PersonFilters/ActivityReasonFilter.php | 3 +- .../Form/Type/TranslatableActivityType.php | 3 - .../Repository/ActivityTypeRepository.php | 23 +- .../ActivityTypeRepositoryInterface.php | 12 +- .../Authorization/ActivityStatsVoter.php | 10 +- .../BySocialActionAggregatorTest.php | 7 +- .../BySocialIssueAggregatorTest.php | 7 +- .../ByThirdpartyAggregatorTest.php | 7 +- .../ACPAggregators/ByUserAggregatorTest.php | 7 +- .../ACPAggregators/DateAggregatorTest.php | 9 +- .../LocationTypeAggregatorTest.php | 7 +- .../UserScopeAggregatorTest.php | 7 +- .../ActivityReasonAggregatorTest.php | 9 +- .../LinkedToPerson/ListActivityTest.php | 2 +- .../ACPFilters/ActivityTypeFilterTest.php | 2 +- .../ACPFilters/BySocialActionFilterTest.php | 2 +- .../ACPFilters/BySocialIssueFilterTest.php | 5 +- .../Filter/ACPFilters/ByUserFilterTest.php | 2 +- .../Filter/ACPFilters/EmergencyFilterTest.php | 4 +- .../ACPFilters/LocationTypeFilterTest.php | 2 +- .../ACPFilters/SentReceivedFilterTest.php | 4 +- .../Filter/ACPFilters/UserFilterTest.php | 2 +- .../Filter/ACPFilters/UserScopeFilterTest.php | 2 +- .../Export/Filter/ActivityDateFilterTest.php | 7 +- .../Filter/ActivityReasonFilterTest.php | 4 +- .../Export/Filter/ActivityTypeFilterTest.php | 2 +- .../ActivityReasonFilterTest.php | 2 +- ...sonHavingActivityBetweenDateFilterTest.php | 7 +- .../Config/ConfigRepository.php | 4 +- .../Export/Aggregator/AgentAggregator.php | 1 + .../Aggregator/CancelReasonAggregator.php | 1 + .../Export/Aggregator/JobAggregator.php | 1 + .../Export/Aggregator/LocationAggregator.php | 2 +- .../Aggregator/LocationTypeAggregator.php | 1 + .../Export/Aggregator/MonthYearAggregator.php | 1 - .../Export/Aggregator/ScopeAggregator.php | 1 + .../Export/Filter/JobFilter.php | 1 + .../Export/Filter/ScopeFilter.php | 1 + .../Controller/ExportController.php | 2 +- .../Entity/GeographicalUnit.php | 55 ++--- .../Entity/GeographicalUnitLayer.php | 42 ++-- .../ChillMainBundle/Export/ExportManager.php | 5 +- .../Form/Type/Export/PickCenterType.php | 5 - .../Repository/CenterRepository.php | 1 - .../Repository/CenterRepositoryInterface.php | 13 +- .../GeographicalUnitLayerLayerRepository.php | 31 ++- ...ographicalUnitLayerRepositoryInterface.php | 11 +- .../Repository/GeographicalUnitRepository.php | 20 +- .../GeographicalUnitRepositoryInterface.php | 12 +- .../Repository/ScopeRepository.php | 1 - .../Repository/ScopeRepositoryInterface.php | 14 +- .../Authorization/ChillExportVoter.php | 1 - .../Import/AddressReferenceBaseImporter.php | 5 +- .../Import/GeographicalUnitBaseImporter.php | 32 +-- .../Test/Export/AbstractAggregatorTest.php | 1 + .../Test/Export/AbstractFilterTest.php | 1 + .../ChillMainBundle/Test/ProphecyTrait.php | 1 + .../AddressReferenceBaseImporterTest.php | 34 ++- .../GeographicalUnitBaseImporterTest.php | 31 ++- .../Import/PostalCodeBaseImporterTest.php | 36 ++- .../NotificationOnTransitionTest.php | 34 ++- ...ntityWorkflowTransitionEventSubscriber.php | 35 +-- .../NotificationOnTransition.php | 8 +- .../migrations/Version20220730204216.php | 17 +- .../migrations/Version20220913174922.php | 17 +- .../migrations/Version20221003112151.php | 66 ++--- .../migrations/Version20221003132620.php | 21 +- .../ChillPersonBundle/Entity/Person.php | 117 +++++---- .../Entity/Person/PersonCenterCurrent.php | 78 +++--- .../Entity/Person/PersonCenterHistory.php | 139 +++++------ .../AdministrativeLocationAggregator.php | 1 + .../ClosingMotiveAggregator.php | 5 +- .../GeographicalUnitStatAggregator.php | 164 ++++++------- .../JobAggregator.php | 1 + .../OriginAggregator.php | 1 + .../ReferrerAggregator.php | 1 + .../ReferrerScopeAggregator.php | 141 +++++------ .../ScopeAggregator.php | 1 + .../SocialIssueAggregator.php | 1 + .../StepAggregator.php | 2 +- .../ChildrenNumberAggregator.php | 3 +- .../CompositionAggregator.php | 1 - .../GeographicalUnitAggregator.php | 163 ++++++------- .../HouseholdPositionAggregator.php | 1 + .../MaritalStatusAggregator.php | 1 + .../ActionTypeAggregator.php | 1 + .../SocialWorkAggregators/GoalAggregator.php | 1 + .../GoalResultAggregator.php | 147 +++++------ .../SocialWorkAggregators/JobAggregator.php | 1 + .../ReferrerAggregator.php | 1 + .../ResultAggregator.php | 1 + .../SocialWorkAggregators/ScopeAggregator.php | 1 + .../Export/Export/CountAccompanyingCourse.php | 7 +- .../Export/Export/CountEvaluation.php | 8 +- .../Export/Export/CountHousehold.php | 10 +- .../Export/Export/CountPerson.php | 5 +- .../CountPersonWithAccompanyingCourse.php | 3 +- .../Export/Export/CountSocialWorkActions.php | 7 +- .../Export/Export/ListPersonDuplicate.php | 1 - .../Export/StatAccompanyingCourseDuration.php | 7 +- .../ActiveOneDayBetweenDatesFilter.php | 1 - .../CurrentUserScopeFilter.php | 1 + .../EvaluationFilter.php | 1 + .../GeographicalUnitStatFilter.php | 29 +-- .../OpenBetweenDatesFilter.php | 1 - .../RequestorFilter.php | 2 +- .../SocialIssueFilter.php | 1 + .../HouseholdFilters/CompositionFilter.php | 1 - .../Export/Filter/PersonFilters/AgeFilter.php | 11 +- .../PersonFilters/DeadOrAliveFilter.php | 6 +- .../PersonFilters/GeographicalUnitFilter.php | 133 +++++----- .../PersonFilters/MaritalStatusFilter.php | 6 +- .../ResidentialAddressAtThirdpartyFilter.php | 1 + .../ResidentialAddressAtUserFilter.php | 4 +- .../Filter/SocialWorkFilters/JobFilter.php | 1 + .../SocialWorkFilters/ReferrerFilter.php | 1 + .../Filter/SocialWorkFilters/ScopeFilter.php | 1 + .../SocialWorkTypeFilter.php | 185 +++++++------- .../ClosingMotiveRepository.php | 53 ++-- .../ClosingMotiveRepositoryInterface.php | 9 + .../Person/PersonCenterHistoryInterface.php | 10 +- .../Person/PersonCenterHistoryRepository.php | 9 + .../Repository/PersonACLAwareRepository.php | 1 - .../Security/Authorization/HouseholdVoter.php | 13 +- .../AdministrativeLocationAggregatorTest.php | 9 +- .../ClosingMotiveAggregatorTest.php | 9 +- .../ConfidentialAggregatorTest.php | 9 +- .../DurationAggregatorTest.php | 9 +- .../EmergencyAggregatorTest.php | 9 +- .../EvaluationAggregatorTest.php | 9 +- .../GeographicalUnitStatAggregatorTest.php | 9 +- .../IntensityAggregatorTest.php | 9 +- .../JobAggregatorTest.php | 9 +- .../OriginAggregatorTest.php | 9 +- .../ReferrerAggregatorTest.php | 9 +- .../ReferrerScopeAggregatorTest.php | 26 +- .../RequestorAggregatorTest.php | 9 +- .../ScopeAggregatorTest.php | 9 +- .../SocialActionAggregatorTest.php | 9 +- .../SocialIssueAggregatorTest.php | 9 +- .../StepAggregatorTest.php | 12 +- .../EvaluationTypeAggregatorTest.php | 9 +- .../ChildrenNumberAggregatorTest.php | 12 +- .../CompositionAggregatorTest.php | 12 +- .../CountryOfBirthAggregatorTest.php | 9 +- .../HouseholdPositionAggregatorTest.php | 10 +- .../MaritalStatusAggregatorTest.php | 7 +- .../ActionTypeAggregatorTest.php | 3 +- .../GoalAggregatorTest.php | 3 +- .../GoalResultAggregatorTest.php | 9 +- .../JobAggregatorTest.php | 9 +- .../ReferrerAggregatorTest.php | 3 +- .../ResultAggregatorTest.php | 3 +- .../ScopeAggregatorTest.php | 9 +- .../ActiveOnDateFilterTest.php | 1 - .../ActiveOneDayBetweenDatesFilterTest.php | 1 - .../AdministrativeLocationFilterTest.php | 3 +- .../EvaluationFilterTest.php | 1 - .../GeographicalUnitStatFilterTest.php | 1 - .../OpenBetweenDatesFilterTest.php | 1 - .../ReferrerFilterTest.php | 1 - .../RequestorFilterTest.php | 1 - .../SocialActionFilterTest.php | 1 - .../EvaluationTypeFilterTest.php | 2 +- .../EvaluationFilters/MaxDateFilterTest.php | 5 +- .../CompositionFilterTest.php | 5 +- .../AccompanyingPeriodClosingFilterTest.php | 7 +- .../AccompanyingPeriodOpeningFilterTest.php | 7 +- .../Filter/PersonFilters/AgeFilterTest.php | 5 +- .../PersonFilters/DeadOrAliveFilterTest.php | 7 +- .../PersonFilters/DeathdateFilterTest.php | 9 +- .../PersonFilters/MaritalStatusFilterTest.php | 4 +- .../PersonFilters/NationalityFilterTest.php | 5 +- ...sidentialAddressAtThirdpartyFilterTest.php | 8 +- .../ResidentialAddressAtUserFilterTest.php | 4 +- .../SocialWorkFilters/ReferrerFilterTest.php | 5 +- .../SocialWorkTypeFilterTest.php | 8 +- .../PersonACLAwareRepositoryTest.php | 38 ++- .../migrations/Version20220926154347.php | 21 +- .../Export/Filter/ReportDateFilterTest.php | 9 +- .../SingleTaskAclAwareRepository.php | 4 +- .../SingleTaskACLAwareRepositoryTest.php | 229 ++++++++++-------- 194 files changed, 1580 insertions(+), 1386 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/DateAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/DateAggregator.php index 982f0d6ed..058b1fc15 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/DateAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/DateAggregator.php @@ -13,7 +13,6 @@ namespace Chill\ActivityBundle\Export\Aggregator\ACPAggregators; use Chill\ActivityBundle\Export\Declarations; use Chill\MainBundle\Export\AggregatorInterface; -use DateTime; use Doctrine\ORM\QueryBuilder; use RuntimeException; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; @@ -50,14 +49,17 @@ class DateAggregator implements AggregatorInterface switch ($data['frequency']) { case 'month': $fmt = 'YYYY-MM'; + break; case 'week': $fmt = 'YYYY-IW'; + break; case 'year': $fmt = 'YYYY'; $order = 'DESC'; + break; // order DESC does not works ! default: @@ -98,7 +100,6 @@ class DateAggregator implements AggregatorInterface switch ($data['frequency']) { case 'month': - case 'week': //return $this->translator->trans('for week') .' '. $value ; diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php index 74df67d22..04ce2014c 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php @@ -16,7 +16,6 @@ use Chill\ActivityBundle\Repository\ActivityTypeRepositoryInterface; use Chill\MainBundle\Export\AggregatorInterface; use Chill\MainBundle\Templating\TranslatableStringHelperInterface; use Closure; -use Doctrine\ORM\Query\Expr\Join; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; use function in_array; diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUserAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUserAggregator.php index 8e29f9cb0..86e9e77bb 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUserAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUserAggregator.php @@ -61,7 +61,7 @@ class ActivityUserAggregator implements AggregatorInterface public function getLabels($key, $values, $data): Closure { - return function ($value) { + return function ($value) { if ('_header' === $value) { return 'Activity user'; } diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/PersonAggregators/ActivityReasonAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/PersonAggregators/ActivityReasonAggregator.php index f82793e71..bf6b3ca02 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/PersonAggregators/ActivityReasonAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/PersonAggregators/ActivityReasonAggregator.php @@ -25,8 +25,8 @@ use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Validator\Context\ExecutionContextInterface; -use function array_key_exists; use function count; +use function in_array; class ActivityReasonAggregator implements AggregatorInterface, ExportElementValidatedInterface { @@ -67,7 +67,7 @@ class ActivityReasonAggregator implements AggregatorInterface, ExportElementVali $qb->addSelect($elem . ' as ' . $alias); // make a jointure only if needed - if (!in_array( 'actreasons', $qb->getAllAliases(), true)) { + if (!in_array('actreasons', $qb->getAllAliases(), true)) { $qb->innerJoin('activity.reasons', 'actreasons'); } diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php index f45adc0b3..326033013 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php @@ -23,6 +23,7 @@ use Chill\PersonBundle\Export\Declarations as PersonDeclarations; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; use Doctrine\ORM\Query; +use LogicException; use Symfony\Component\Form\FormBuilderInterface; class AvgActivityDuration implements ExportInterface, GroupedExportInterface @@ -57,7 +58,7 @@ class AvgActivityDuration implements ExportInterface, GroupedExportInterface public function getLabels($key, array $values, $data) { if ('export_avg_activity_duration' !== $key) { - throw new \LogicException("the key {$key} is not used by this export"); + throw new LogicException("the key {$key} is not used by this export"); } return static fn ($value) => '_header' === $value ? 'Average activities linked to an accompanying period duration' : $value; @@ -99,14 +100,13 @@ class AvgActivityDuration implements ExportInterface, GroupedExportInterface $qb ->andWhere( $qb->expr()->exists( - 'SELECT 1 FROM '.AccompanyingPeriodParticipation::class.' acl_count_part - JOIN '.PersonCenterHistory::class.' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person) + 'SELECT 1 FROM ' . AccompanyingPeriodParticipation::class . ' acl_count_part + JOIN ' . PersonCenterHistory::class . ' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person) WHERE acl_count_part.accompanyingPeriod = acp.id AND acl_count_person_history.center IN (:authorized_centers) ' ) ) - ->setParameter('authorized_centers', $centers) - ; + ->setParameter('authorized_centers', $centers); return $qb; } diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php index 661f169dd..6514be3e0 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php @@ -23,6 +23,7 @@ use Chill\PersonBundle\Export\Declarations as PersonDeclarations; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; use Doctrine\ORM\Query; +use LogicException; use Symfony\Component\Form\FormBuilderInterface; class AvgActivityVisitDuration implements ExportInterface, GroupedExportInterface @@ -58,7 +59,7 @@ class AvgActivityVisitDuration implements ExportInterface, GroupedExportInterfac public function getLabels($key, array $values, $data) { if ('export_avg_activity_visit_duration' !== $key) { - throw new \LogicException("the key {$key} is not used by this export"); + throw new LogicException("the key {$key} is not used by this export"); } return static fn ($value) => '_header' === $value ? 'Average activities linked to an accompanying period visit duration' : $value; @@ -95,20 +96,18 @@ class AvgActivityVisitDuration implements ExportInterface, GroupedExportInterfac $qb ->join('activity.accompanyingPeriod', 'acp') ->select('AVG(activity.travelTime) as export_avg_activity_visit_duration') - ->andWhere($qb->expr()->isNotNull('activity.travelTime')) - ; + ->andWhere($qb->expr()->isNotNull('activity.travelTime')); $qb ->andWhere( $qb->expr()->exists( - 'SELECT 1 FROM '.AccompanyingPeriodParticipation::class.' acl_count_part - JOIN '.PersonCenterHistory::class.' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person) + 'SELECT 1 FROM ' . AccompanyingPeriodParticipation::class . ' acl_count_part + JOIN ' . PersonCenterHistory::class . ' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person) WHERE acl_count_part.accompanyingPeriod = acp.id AND acl_count_person_history.center IN (:authorized_centers) ' ) ) - ->setParameter('authorized_centers', $centers) - ; + ->setParameter('authorized_centers', $centers); return $qb; } diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php index 46d2f3c33..92e8cdc27 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php @@ -97,14 +97,13 @@ class CountActivity implements ExportInterface, GroupedExportInterface $qb ->andWhere( $qb->expr()->exists( - 'SELECT 1 FROM '.AccompanyingPeriodParticipation::class.' acl_count_part - JOIN '.PersonCenterHistory::class.' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person) + 'SELECT 1 FROM ' . AccompanyingPeriodParticipation::class . ' acl_count_part + JOIN ' . PersonCenterHistory::class . ' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person) WHERE acl_count_part.accompanyingPeriod = acp.id AND acl_count_person_history.center IN (:authorized_centers) ' ) ) - ->setParameter('authorized_centers', $centers) - ; + ->setParameter('authorized_centers', $centers); $qb->select('COUNT(DISTINCT activity.id) as export_count_activity'); diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php index 405b54885..692ff5530 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php @@ -23,6 +23,7 @@ use Chill\PersonBundle\Export\Declarations as PersonDeclarations; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; use Doctrine\ORM\Query; +use LogicException; use Symfony\Component\Form\FormBuilderInterface; class SumActivityDuration implements ExportInterface, GroupedExportInterface @@ -58,7 +59,7 @@ class SumActivityDuration implements ExportInterface, GroupedExportInterface public function getLabels($key, array $values, $data) { if ('export_sum_activity_duration' !== $key) { - throw new \LogicException("the key {$key} is not used by this export"); + throw new LogicException("the key {$key} is not used by this export"); } return static fn ($value) => '_header' === $value ? 'Sum activities linked to an accompanying period duration' : $value; @@ -100,14 +101,13 @@ class SumActivityDuration implements ExportInterface, GroupedExportInterface $qb ->andWhere( $qb->expr()->exists( - 'SELECT 1 FROM '.AccompanyingPeriodParticipation::class.' acl_count_part - JOIN '.PersonCenterHistory::class.' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person) + 'SELECT 1 FROM ' . AccompanyingPeriodParticipation::class . ' acl_count_part + JOIN ' . PersonCenterHistory::class . ' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person) WHERE acl_count_part.accompanyingPeriod = acp.id AND acl_count_person_history.center IN (:authorized_centers) ' ) ) - ->setParameter('authorized_centers', $centers) - ; + ->setParameter('authorized_centers', $centers); return $qb; } diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php index 40020cb4b..e9be03003 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php @@ -23,6 +23,7 @@ use Chill\PersonBundle\Export\Declarations as PersonDeclarations; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; use Doctrine\ORM\Query; +use LogicException; use Symfony\Component\Form\FormBuilderInterface; class SumActivityVisitDuration implements ExportInterface, GroupedExportInterface @@ -58,7 +59,7 @@ class SumActivityVisitDuration implements ExportInterface, GroupedExportInterfac public function getLabels($key, array $values, $data) { if ('export_sum_activity_visit_duration' !== $key) { - throw new \LogicException("the key {$key} is not used by this export"); + throw new LogicException("the key {$key} is not used by this export"); } return static fn ($value) => '_header' === $value ? 'Sum activities linked to an accompanying period visit duration' : $value; @@ -100,14 +101,13 @@ class SumActivityVisitDuration implements ExportInterface, GroupedExportInterfac $qb ->andWhere( $qb->expr()->exists( - 'SELECT 1 FROM '.AccompanyingPeriodParticipation::class.' acl_count_part - JOIN '.PersonCenterHistory::class.' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person) + 'SELECT 1 FROM ' . AccompanyingPeriodParticipation::class . ' acl_count_part + JOIN ' . PersonCenterHistory::class . ' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person) WHERE acl_count_part.accompanyingPeriod = acp.id AND acl_count_person_history.center IN (:authorized_centers) ' ) ) - ->setParameter('authorized_centers', $centers) - ; + ->setParameter('authorized_centers', $centers); return $qb; } diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/CountActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/CountActivity.php index 116fa4b6a..fec2b8617 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/CountActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/CountActivity.php @@ -87,8 +87,7 @@ class CountActivity implements ExportInterface, GroupedExportInterface $qb = $this->activityRepository ->createQueryBuilder('activity') ->join('activity.person', 'person') - ->join('person.centerHistory', 'centerHistory') - ; + ->join('person.centerHistory', 'centerHistory'); $qb->select('COUNT(activity.id) as export_count_activity'); diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php index d17a6af99..b6e26dfdb 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php @@ -18,10 +18,10 @@ use Chill\MainBundle\Export\FilterInterface; use Chill\MainBundle\Templating\TranslatableStringHelperInterface; use Chill\PersonBundle\Export\Declarations; use Doctrine\ORM\Query\Expr; -use Doctrine\ORM\Query\Expr\Andx; use Doctrine\ORM\QueryBuilder; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\FormBuilderInterface; +use function in_array; class ActivityTypeFilter implements FilterInterface { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php index 7442fabb7..9bcae2b46 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php @@ -17,8 +17,6 @@ use Chill\ActivityBundle\Repository\ActivityTypeRepositoryInterface; use Chill\MainBundle\Export\ExportElementValidatedInterface; use Chill\MainBundle\Export\FilterInterface; use Chill\MainBundle\Templating\TranslatableStringHelperInterface; -use Doctrine\ORM\Query\Expr; -use Doctrine\ORM\Query\Expr\Join; use Doctrine\ORM\QueryBuilder; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\FormBuilderInterface; @@ -79,8 +77,8 @@ class ActivityTypeFilter implements ExportElementValidatedInterface, FilterInter 'multiple' => true, 'expanded' => false, 'attr' => [ - 'class' => 'select2' - ] + 'class' => 'select2', + ], ]); } diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/ActivityReasonFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/ActivityReasonFilter.php index 6d78b3b38..871c5a829 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/ActivityReasonFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/ActivityReasonFilter.php @@ -19,14 +19,13 @@ use Chill\MainBundle\Export\FilterInterface; use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\MainBundle\Templating\TranslatableStringHelperInterface; use Doctrine\ORM\Query\Expr; -use Doctrine\ORM\Query\Expr\Join; use Doctrine\ORM\QueryBuilder; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Validator\Context\ExecutionContextInterface; -use function array_key_exists; use function count; +use function in_array; class ActivityReasonFilter implements ExportElementValidatedInterface, FilterInterface { diff --git a/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityType.php b/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityType.php index 8140043a4..fd2784338 100644 --- a/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityType.php +++ b/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityType.php @@ -14,11 +14,8 @@ namespace Chill\ActivityBundle\Form\Type; use Chill\ActivityBundle\Entity\ActivityType; use Chill\ActivityBundle\Repository\ActivityTypeRepositoryInterface; use Chill\MainBundle\Templating\TranslatableStringHelperInterface; -use Doctrine\DBAL\Types\Types; -use Doctrine\ORM\QueryBuilder; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; class TranslatableActivityType extends AbstractType diff --git a/src/Bundle/ChillActivityBundle/Repository/ActivityTypeRepository.php b/src/Bundle/ChillActivityBundle/Repository/ActivityTypeRepository.php index aee3706cf..7bd679e8b 100644 --- a/src/Bundle/ChillActivityBundle/Repository/ActivityTypeRepository.php +++ b/src/Bundle/ChillActivityBundle/Repository/ActivityTypeRepository.php @@ -12,11 +12,8 @@ declare(strict_types=1); namespace Chill\ActivityBundle\Repository; use Chill\ActivityBundle\Entity\ActivityType; -use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; -use Doctrine\Persistence\ManagerRegistry; -use UnexpectedValueException; final class ActivityTypeRepository implements ActivityTypeRepositoryInterface { @@ -24,15 +21,7 @@ final class ActivityTypeRepository implements ActivityTypeRepositoryInterface public function __construct(EntityManagerInterface $em) { - $this->repository = $em->getRepository(ActivityType::class); - } - - /** - * @return array|ActivityType[] - */ - public function findAllActive(): array - { - return $this->findBy(['active' => true]); + $this->repository = $em->getRepository(ActivityType::class); } public function find($id): ?ActivityType @@ -48,6 +37,14 @@ final class ActivityTypeRepository implements ActivityTypeRepositoryInterface return $this->repository->findAll(); } + /** + * @return array|ActivityType[] + */ + public function findAllActive(): array + { + return $this->findBy(['active' => true]); + } + /** * @return array|ActivityType[] */ @@ -65,6 +62,4 @@ final class ActivityTypeRepository implements ActivityTypeRepositoryInterface { return ActivityType::class; } - - } diff --git a/src/Bundle/ChillActivityBundle/Repository/ActivityTypeRepositoryInterface.php b/src/Bundle/ChillActivityBundle/Repository/ActivityTypeRepositoryInterface.php index 533798e5e..6172fe257 100644 --- a/src/Bundle/ChillActivityBundle/Repository/ActivityTypeRepositoryInterface.php +++ b/src/Bundle/ChillActivityBundle/Repository/ActivityTypeRepositoryInterface.php @@ -1,5 +1,14 @@ getAttributes(); } - protected function voteOnAttribute($attribute, $subject, TokenInterface $token) - { - return $this->helper->voteOnAttribute($attribute, $subject, $token); - } - protected function supports($attribute, $subject) { return $this->helper->supports($attribute, $subject); } + protected function voteOnAttribute($attribute, $subject, TokenInterface $token) + { + return $this->helper->voteOnAttribute($attribute, $subject, $token); + } + private function getAttributes() { return [self::STATS, self::LISTS]; diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/BySocialActionAggregatorTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/BySocialActionAggregatorTest.php index d9b3a8cfb..2d28d0967 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/BySocialActionAggregatorTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/BySocialActionAggregatorTest.php @@ -16,6 +16,10 @@ use Chill\ActivityBundle\Export\Aggregator\ACPAggregators\BySocialActionAggregat use Chill\MainBundle\Test\Export\AbstractAggregatorTest; use Doctrine\ORM\EntityManagerInterface; +/** + * @internal + * @coversNothing + */ final class BySocialActionAggregatorTest extends AbstractAggregatorTest { private BySocialActionAggregator $aggregator; @@ -52,8 +56,7 @@ final class BySocialActionAggregatorTest extends AbstractAggregatorTest ->select('count(activity.id)') ->from(Activity::class, 'activity') ->join('activity.accompanyingPeriod', 'acp') - ->join('activity.socialActions', 'actsocialaction') - , + ->join('activity.socialActions', 'actsocialaction'), ]; } } diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/BySocialIssueAggregatorTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/BySocialIssueAggregatorTest.php index 87e8462db..36a7c7ceb 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/BySocialIssueAggregatorTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/BySocialIssueAggregatorTest.php @@ -16,6 +16,10 @@ use Chill\ActivityBundle\Export\Aggregator\ACPAggregators\BySocialIssueAggregato use Chill\MainBundle\Test\Export\AbstractAggregatorTest; use Doctrine\ORM\EntityManagerInterface; +/** + * @internal + * @coversNothing + */ final class BySocialIssueAggregatorTest extends AbstractAggregatorTest { private BySocialIssueAggregator $aggregator; @@ -52,8 +56,7 @@ final class BySocialIssueAggregatorTest extends AbstractAggregatorTest ->select('count(activity.id)') ->from(Activity::class, 'activity') ->join('activity.accompanyingPeriod', 'acp') - ->join('activity.socialIssues', 'actsocialissue') - , + ->join('activity.socialIssues', 'actsocialissue'), ]; } } diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/ByThirdpartyAggregatorTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/ByThirdpartyAggregatorTest.php index c9a824dc3..89c853e55 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/ByThirdpartyAggregatorTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/ByThirdpartyAggregatorTest.php @@ -16,6 +16,10 @@ use Chill\ActivityBundle\Export\Aggregator\ACPAggregators\ByThirdpartyAggregator use Chill\MainBundle\Test\Export\AbstractAggregatorTest; use Doctrine\ORM\EntityManagerInterface; +/** + * @internal + * @coversNothing + */ final class ByThirdpartyAggregatorTest extends AbstractAggregatorTest { private ByThirdpartyAggregator $aggregator; @@ -52,8 +56,7 @@ final class ByThirdpartyAggregatorTest extends AbstractAggregatorTest ->select('count(activity.id)') ->from(Activity::class, 'activity') ->join('activity.accompanyingPeriod', 'acp') - ->join('activity.thirdParties', 'acttparty') - , + ->join('activity.thirdParties', 'acttparty'), ]; } } diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/ByUserAggregatorTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/ByUserAggregatorTest.php index 00243ce68..2ee78b2bf 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/ByUserAggregatorTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/ByUserAggregatorTest.php @@ -16,6 +16,10 @@ use Chill\ActivityBundle\Export\Aggregator\ACPAggregators\ByUserAggregator; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; use Doctrine\ORM\EntityManagerInterface; +/** + * @internal + * @coversNothing + */ final class ByUserAggregatorTest extends AbstractAggregatorTest { private ByUserAggregator $aggregator; @@ -52,8 +56,7 @@ final class ByUserAggregatorTest extends AbstractAggregatorTest ->select('count(activity.id)') ->from(Activity::class, 'activity') ->join('activity.accompanyingPeriod', 'acp') - ->join('activity.users', 'actusers') - , + ->join('activity.users', 'actusers'), ]; } } diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/DateAggregatorTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/DateAggregatorTest.php index c5a1b083c..8b682487b 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/DateAggregatorTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/DateAggregatorTest.php @@ -16,6 +16,10 @@ use Chill\ActivityBundle\Export\Aggregator\ACPAggregators\DateAggregator; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; use Doctrine\ORM\EntityManagerInterface; +/** + * @internal + * @coversNothing + */ final class DateAggregatorTest extends AbstractAggregatorTest { private DateAggregator $aggregator; @@ -43,7 +47,7 @@ final class DateAggregatorTest extends AbstractAggregatorTest ], [ 'frequency' => 'year', - ] + ], ]; } @@ -59,8 +63,7 @@ final class DateAggregatorTest extends AbstractAggregatorTest $em->createQueryBuilder() ->select('count(activity.id)') ->from(Activity::class, 'activity') - ->join('activity.accompanyingPeriod', 'acp') - , + ->join('activity.accompanyingPeriod', 'acp'), ]; } } diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/LocationTypeAggregatorTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/LocationTypeAggregatorTest.php index 69be2c900..81f7be13b 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/LocationTypeAggregatorTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/LocationTypeAggregatorTest.php @@ -16,6 +16,10 @@ use Chill\ActivityBundle\Export\Aggregator\ACPAggregators\LocationTypeAggregator use Chill\MainBundle\Test\Export\AbstractAggregatorTest; use Doctrine\ORM\EntityManagerInterface; +/** + * @internal + * @coversNothing + */ final class LocationTypeAggregatorTest extends AbstractAggregatorTest { private LocationTypeAggregator $aggregator; @@ -52,8 +56,7 @@ final class LocationTypeAggregatorTest extends AbstractAggregatorTest ->select('count(activity.id)') ->from(Activity::class, 'activity') ->join('activity.accompanyingPeriod', 'acp') - ->join('activity.location', 'actloc') - , + ->join('activity.location', 'actloc'), ]; } } diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/UserScopeAggregatorTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/UserScopeAggregatorTest.php index 73943ce7f..28f13028f 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/UserScopeAggregatorTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/UserScopeAggregatorTest.php @@ -16,6 +16,10 @@ use Chill\ActivityBundle\Export\Aggregator\ACPAggregators\UserScopeAggregator; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; use Doctrine\ORM\EntityManagerInterface; +/** + * @internal + * @coversNothing + */ final class UserScopeAggregatorTest extends AbstractAggregatorTest { private UserScopeAggregator $aggregator; @@ -52,8 +56,7 @@ final class UserScopeAggregatorTest extends AbstractAggregatorTest ->select('count(activity.id)') ->from(Activity::class, 'activity') ->join('activity.accompanyingPeriod', 'acp') - ->join('activity.user', 'actuser') - , + ->join('activity.user', 'actuser'), ]; } } diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/PersonAggregators/ActivityReasonAggregatorTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/PersonAggregators/ActivityReasonAggregatorTest.php index f89c20e31..69a82cffc 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/PersonAggregators/ActivityReasonAggregatorTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/PersonAggregators/ActivityReasonAggregatorTest.php @@ -11,16 +11,19 @@ declare(strict_types=1); namespace Chill\ActivityBundle\Tests\Export\Aggregator\PersonAggregators; -use Chill\ActivityBundle\Entity\Activity; use Chill\ActivityBundle\Export\Aggregator\PersonAggregators\ActivityReasonAggregator; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; use Doctrine\ORM\EntityManagerInterface; use Prophecy\PhpUnit\ProphecyTrait; +/** + * @internal + * @coversNothing + */ final class ActivityReasonAggregatorTest extends AbstractAggregatorTest { use ProphecyTrait; - + private ActivityReasonAggregator $aggregator; protected function setUp(): void @@ -33,7 +36,7 @@ final class ActivityReasonAggregatorTest extends AbstractAggregatorTest ->willExtend(\Symfony\Component\HttpFoundation\Request::class); $request->getLocale()->willReturn('fr'); - + self::$container->get('request_stack') ->push($request->reveal()); } diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Export/LinkedToPerson/ListActivityTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Export/LinkedToPerson/ListActivityTest.php index a613bc083..d39592b5e 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Export/LinkedToPerson/ListActivityTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Export/LinkedToPerson/ListActivityTest.php @@ -22,7 +22,7 @@ use Prophecy\PhpUnit\ProphecyTrait; final class ListActivityTest extends AbstractExportTest { use ProphecyTrait; - + private ListActivity $export; protected function setUp(): void diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/ActivityTypeFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/ActivityTypeFilterTest.php index e38d4cf5c..70918fb54 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/ActivityTypeFilterTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/ActivityTypeFilterTest.php @@ -53,7 +53,7 @@ final class ActivityTypeFilterTest extends AbstractFilterTest foreach ($array as $a) { $data[] = [ - 'accepted_activitytypes' => $a + 'accepted_activitytypes' => $a, ]; } diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/BySocialActionFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/BySocialActionFilterTest.php index d8091d068..9beb48082 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/BySocialActionFilterTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/BySocialActionFilterTest.php @@ -51,7 +51,7 @@ final class BySocialActionFilterTest extends AbstractFilterTest foreach ($array as $a) { $data[] = [ - 'accepted_socialactions' => $a + 'accepted_socialactions' => $a, ]; } diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/BySocialIssueFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/BySocialIssueFilterTest.php index 61e5d4715..f92a143ee 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/BySocialIssueFilterTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/BySocialIssueFilterTest.php @@ -51,7 +51,7 @@ final class BySocialIssueFilterTest extends AbstractFilterTest foreach ($array as $a) { $data[] = [ - 'accepted_socialissues' => $a + 'accepted_socialissues' => $a, ]; } @@ -70,8 +70,7 @@ final class BySocialIssueFilterTest extends AbstractFilterTest $em->createQueryBuilder() ->select('count(activity.id)') ->from(Activity::class, 'activity') - ->join('activity.socialIssues', 'actsocialissue') - , + ->join('activity.socialIssues', 'actsocialissue'), ]; } } diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/ByUserFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/ByUserFilterTest.php index aaf852b14..6765a918d 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/ByUserFilterTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/ByUserFilterTest.php @@ -51,7 +51,7 @@ final class ByUserFilterTest extends AbstractFilterTest foreach ($array as $a) { $data[] = [ - 'accepted_users' => $a + 'accepted_users' => $a, ]; } diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/EmergencyFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/EmergencyFilterTest.php index 07810efbe..845bb6490 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/EmergencyFilterTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/EmergencyFilterTest.php @@ -39,8 +39,8 @@ final class EmergencyFilterTest extends AbstractFilterTest public function getFormData(): array { return [ - ['accepted_emergency' => true ], - ['accepted_emergency' => false ], + ['accepted_emergency' => true], + ['accepted_emergency' => false], ]; } diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/LocationTypeFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/LocationTypeFilterTest.php index 6888e6cf7..18558b7ee 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/LocationTypeFilterTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/LocationTypeFilterTest.php @@ -51,7 +51,7 @@ final class LocationTypeFilterTest extends AbstractFilterTest foreach ($array as $a) { $data[] = [ - 'accepted_locationtype' => $a + 'accepted_locationtype' => $a, ]; } diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/SentReceivedFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/SentReceivedFilterTest.php index d9a24dc27..a3cc6a941 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/SentReceivedFilterTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/SentReceivedFilterTest.php @@ -39,8 +39,8 @@ final class SentReceivedFilterTest extends AbstractFilterTest public function getFormData(): array { return [ - ['accepted_sentreceived' => Activity::SENTRECEIVED_SENT ], - ['accepted_sentreceived' => Activity::SENTRECEIVED_RECEIVED ] + ['accepted_sentreceived' => Activity::SENTRECEIVED_SENT], + ['accepted_sentreceived' => Activity::SENTRECEIVED_RECEIVED], ]; } diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/UserFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/UserFilterTest.php index 838973caa..6dca9e18a 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/UserFilterTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/UserFilterTest.php @@ -51,7 +51,7 @@ final class UserFilterTest extends AbstractFilterTest foreach ($array as $a) { $data[] = [ - 'accepted_users' => $a + 'accepted_users' => $a, ]; } diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/UserScopeFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/UserScopeFilterTest.php index 6b1040036..9a869206e 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/UserScopeFilterTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/UserScopeFilterTest.php @@ -51,7 +51,7 @@ final class UserScopeFilterTest extends AbstractFilterTest foreach ($array as $a) { $data[] = [ - 'accepted_userscope' => $a + 'accepted_userscope' => $a, ]; } diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ActivityDateFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ActivityDateFilterTest.php index e95fd7c20..150ec30f0 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ActivityDateFilterTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ActivityDateFilterTest.php @@ -14,6 +14,7 @@ namespace Chill\ActivityBundle\Tests\Export\Filter; use Chill\ActivityBundle\Entity\Activity; use Chill\ActivityBundle\Export\Filter\ActivityDateFilter; use Chill\MainBundle\Test\Export\AbstractFilterTest; +use DateTime; use Doctrine\ORM\EntityManagerInterface; /** @@ -40,9 +41,9 @@ final class ActivityDateFilterTest extends AbstractFilterTest { return [ [ - 'date_from' => \DateTime::createFromFormat('Y-m-d', '2020-01-01'), - 'date_to' => \DateTime::createFromFormat('Y-m-d', '2021-01-01'), - ] + 'date_from' => DateTime::createFromFormat('Y-m-d', '2020-01-01'), + 'date_to' => DateTime::createFromFormat('Y-m-d', '2021-01-01'), + ], ]; } diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ActivityReasonFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ActivityReasonFilterTest.php index d45ecfbb2..0a7d059a6 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ActivityReasonFilterTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ActivityReasonFilterTest.php @@ -23,7 +23,7 @@ use Prophecy\PhpUnit\ProphecyTrait; final class ActivityReasonFilterTest extends AbstractFilterTest { use ProphecyTrait; - + private ActivityReasonFilter $filter; protected function setUp(): void @@ -34,7 +34,7 @@ final class ActivityReasonFilterTest extends AbstractFilterTest $request = $this->prophesize() ->willExtend(\Symfony\Component\HttpFoundation\Request::class); - + $request->getLocale()->willReturn('fr'); self::$container->get('request_stack') diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ActivityTypeFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ActivityTypeFilterTest.php index 1bee8532e..97d63ddc9 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ActivityTypeFilterTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ActivityTypeFilterTest.php @@ -51,7 +51,7 @@ final class ActivityTypeFilterTest extends AbstractFilterTest foreach ($array as $a) { $data[] = [ - 'types' => $a + 'types' => $a, ]; } diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/PersonFilters/ActivityReasonFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/PersonFilters/ActivityReasonFilterTest.php index fc7dbbd00..c47b0a0a7 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/PersonFilters/ActivityReasonFilterTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/PersonFilters/ActivityReasonFilterTest.php @@ -51,7 +51,7 @@ final class ActivityReasonFilterTest extends AbstractFilterTest foreach ($array as $a) { $data[] = [ - 'reasons' => $a + 'reasons' => $a, ]; } diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/PersonFilters/PersonHavingActivityBetweenDateFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/PersonFilters/PersonHavingActivityBetweenDateFilterTest.php index 42cf9d884..c705c5462 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/PersonFilters/PersonHavingActivityBetweenDateFilterTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/PersonFilters/PersonHavingActivityBetweenDateFilterTest.php @@ -15,6 +15,7 @@ use Chill\ActivityBundle\Entity\Activity; use Chill\ActivityBundle\Entity\ActivityReason; use Chill\ActivityBundle\Export\Filter\PersonFilters\PersonHavingActivityBetweenDateFilter; use Chill\MainBundle\Test\Export\AbstractFilterTest; +use DateTime; use Doctrine\ORM\EntityManagerInterface; /** @@ -51,9 +52,9 @@ final class PersonHavingActivityBetweenDateFilterTest extends AbstractFilterTest foreach ($array as $a) { $data[] = [ - 'date_from' => \DateTime::createFromFormat('Y-m-d', '2021-07-01'), - 'date_to' => \DateTime::createFromFormat('Y-m-d', '2022-07-01'), - 'reasons' => $a + 'date_from' => DateTime::createFromFormat('Y-m-d', '2021-07-01'), + 'date_to' => DateTime::createFromFormat('Y-m-d', '2022-07-01'), + 'reasons' => $a, ]; } diff --git a/src/Bundle/ChillBudgetBundle/Config/ConfigRepository.php b/src/Bundle/ChillBudgetBundle/Config/ConfigRepository.php index e498ba5a3..6443eeaf7 100644 --- a/src/Bundle/ChillBudgetBundle/Config/ConfigRepository.php +++ b/src/Bundle/ChillBudgetBundle/Config/ConfigRepository.php @@ -70,14 +70,14 @@ class ConfigRepository private function getCharges(bool $onlyActive = false): array { return $onlyActive ? - array_filter($this->charges, function ($el) { return $el['active']; }) + array_filter($this->charges, static function ($el) { return $el['active']; }) : $this->charges; } private function getResources(bool $onlyActive = false): array { return $onlyActive ? - array_filter($this->resources, function ($el) { return $el['active']; }) + array_filter($this->resources, static function ($el) { return $el['active']; }) : $this->resources; } diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/AgentAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/AgentAggregator.php index 57ec33cdd..d1cdd56b1 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/AgentAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/AgentAggregator.php @@ -18,6 +18,7 @@ use Chill\MainBundle\Templating\Entity\UserRender; use Closure; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; +use function in_array; final class AgentAggregator implements AggregatorInterface { diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/CancelReasonAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/CancelReasonAggregator.php index a07f052bf..502f8000c 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/CancelReasonAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/CancelReasonAggregator.php @@ -18,6 +18,7 @@ use Chill\MainBundle\Templating\TranslatableStringHelper; use Closure; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; +use function in_array; class CancelReasonAggregator implements AggregatorInterface { diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/JobAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/JobAggregator.php index 17905cf35..d5471d36e 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/JobAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/JobAggregator.php @@ -18,6 +18,7 @@ use Chill\MainBundle\Templating\TranslatableStringHelper; use Closure; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; +use function in_array; final class JobAggregator implements AggregatorInterface { diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationAggregator.php index 236b1b74f..7746bc7f2 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationAggregator.php @@ -17,7 +17,7 @@ use Chill\MainBundle\Repository\LocationRepository; use Closure; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Security\Core\Role\Role; +use function in_array; final class LocationAggregator implements AggregatorInterface { diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationTypeAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationTypeAggregator.php index c8d02160f..f48eafd79 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationTypeAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationTypeAggregator.php @@ -18,6 +18,7 @@ use Chill\MainBundle\Templating\TranslatableStringHelper; use Closure; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; +use function in_array; final class LocationTypeAggregator implements AggregatorInterface { diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/MonthYearAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/MonthYearAggregator.php index 26329ad13..a74853119 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/MonthYearAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/MonthYearAggregator.php @@ -16,7 +16,6 @@ use Chill\MainBundle\Export\AggregatorInterface; use Closure; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Security\Core\Role\Role; class MonthYearAggregator implements AggregatorInterface { diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/ScopeAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/ScopeAggregator.php index 7605c3d5d..3b8123b65 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/ScopeAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/ScopeAggregator.php @@ -18,6 +18,7 @@ use Chill\MainBundle\Templating\TranslatableStringHelper; use Closure; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; +use function in_array; final class ScopeAggregator implements AggregatorInterface { diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php index 03cd4857d..ed4c2dadd 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php @@ -20,6 +20,7 @@ use Doctrine\ORM\QueryBuilder; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Contracts\Translation\TranslatorInterface; +use function in_array; class JobFilter implements FilterInterface { diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php index cbd566e9e..0093865aa 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php @@ -20,6 +20,7 @@ use Doctrine\ORM\QueryBuilder; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Contracts\Translation\TranslatorInterface; +use function in_array; class ScopeFilter implements FilterInterface { diff --git a/src/Bundle/ChillMainBundle/Controller/ExportController.php b/src/Bundle/ChillMainBundle/Controller/ExportController.php index 4ced2cacc..3d861fdfa 100644 --- a/src/Bundle/ChillMainBundle/Controller/ExportController.php +++ b/src/Bundle/ChillMainBundle/Controller/ExportController.php @@ -445,7 +445,7 @@ class ExportController extends AbstractController $this->logger->notice('[export] choices for an export unserialized', [ 'key' => $key, - 'rawData' => json_encode($rawData) + 'rawData' => json_encode($rawData), ]); $alias = $rawData['alias']; diff --git a/src/Bundle/ChillMainBundle/Entity/GeographicalUnit.php b/src/Bundle/ChillMainBundle/Entity/GeographicalUnit.php index 49414db27..bd49fe892 100644 --- a/src/Bundle/ChillMainBundle/Entity/GeographicalUnit.php +++ b/src/Bundle/ChillMainBundle/Entity/GeographicalUnit.php @@ -15,7 +15,7 @@ use Doctrine\ORM\Mapping as ORM; /** * @ORM\Table(name="chill_main_geographical_unit", uniqueConstraints={ - * @ORM\UniqueConstraint(name="geographical_unit_refid", columns={"layer_id", "unitRefId"}) + * @ORM\UniqueConstraint(name="geographical_unit_refid", columns={"layer_id", "unitRefId"}) * }) * @ORM\Entity(readOnly=true) */ @@ -33,6 +33,11 @@ class GeographicalUnit */ private ?int $id = null; + /** + * @ORM\ManyToOne(targetEntity=GeographicalUnitLayer::class, inversedBy="units") + */ + private ?GeographicalUnitLayer $layer; + /** * @ORM\Column(type="text", nullable=false, options={"default": ""}) */ @@ -43,21 +48,14 @@ class GeographicalUnit */ private string $unitRefId; - /** - * @ORM\ManyToOne(targetEntity=GeographicalUnitLayer::class, inversedBy="units") - */ - private ?GeographicalUnitLayer $layer; - public function getId(): ?int { return $this->id; } - protected function setId(int $id): self + public function getLayer(): ?GeographicalUnitLayer { - $this->id = $id; - - return $this; + return $this->layer; } public function getUnitName(): ?string @@ -65,31 +63,10 @@ class GeographicalUnit return $this->unitName; } - /** - * @return GeographicalUnitLayer|null - */ - public function getLayer(): ?GeographicalUnitLayer - { - return $this->layer; - } - - /** - * @param string $unitRefId - * @return GeographicalUnit - */ - public function setUnitRefId(string $unitRefId): GeographicalUnit - { - $this->unitRefId = $unitRefId; - return $this; - } - - /** - * @param GeographicalUnitLayer|null $layer - * @return GeographicalUnit - */ public function setLayer(?GeographicalUnitLayer $layer): GeographicalUnit { $this->layer = $layer; + return $this; } @@ -99,4 +76,18 @@ class GeographicalUnit return $this; } + + public function setUnitRefId(string $unitRefId): GeographicalUnit + { + $this->unitRefId = $unitRefId; + + return $this; + } + + protected function setId(int $id): self + { + $this->id = $id; + + return $this; + } } diff --git a/src/Bundle/ChillMainBundle/Entity/GeographicalUnitLayer.php b/src/Bundle/ChillMainBundle/Entity/GeographicalUnitLayer.php index 162d6ccf4..961a0e79a 100644 --- a/src/Bundle/ChillMainBundle/Entity/GeographicalUnitLayer.php +++ b/src/Bundle/ChillMainBundle/Entity/GeographicalUnitLayer.php @@ -1,5 +1,14 @@ units = new ArrayCollection(); } - /** - * @return int|null - */ public function getId(): ?int { return $this->id; } - /** - * @return array - */ public function getName(): array { return $this->name; } - /** - * @param array $name - * @return GeographicalUnitLayer - */ - public function setName(array $name): GeographicalUnitLayer - { - $this->name = $name; - return $this; - } - - /** - * @return string - */ public function getRefId(): string { return $this->refId; } - /** - * @return Collection - */ public function getUnits(): Collection { return $this->units; } -} \ No newline at end of file + + public function setName(array $name): GeographicalUnitLayer + { + $this->name = $name; + + return $this; + } +} diff --git a/src/Bundle/ChillMainBundle/Export/ExportManager.php b/src/Bundle/ChillMainBundle/Export/ExportManager.php index ba15d0cc0..37aa39695 100644 --- a/src/Bundle/ChillMainBundle/Export/ExportManager.php +++ b/src/Bundle/ChillMainBundle/Export/ExportManager.php @@ -13,7 +13,6 @@ namespace Chill\MainBundle\Export; use Chill\MainBundle\Form\Type\Export\ExportType; use Chill\MainBundle\Form\Type\Export\PickCenterType; -use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\QueryBuilder; @@ -265,16 +264,14 @@ class ExportManager $this->handleAggregators($export, $query, $data[ExportType::AGGREGATOR_KEY], $centers); $this->logger->notice('[export] will execute this qb in export', [ - 'dql' => $query->getDQL() + 'dql' => $query->getDQL(), ]); - } else { throw new UnexpectedValueException('The method `intiateQuery` should return ' . 'a `\\Doctrine\\ORM\\NativeQuery` or a `Doctrine\\ORM\\QueryBuilder` ' . 'object.'); } - $result = $export->getResult($query, $data[ExportType::EXPORT_KEY]); if (!is_iterable($result)) { diff --git a/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php b/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php index 07776cb71..e74d8e8f4 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php @@ -14,9 +14,7 @@ namespace Chill\MainBundle\Form\Type\Export; use Chill\MainBundle\Center\GroupingCenterInterface; use Chill\MainBundle\Entity\Center; use Chill\MainBundle\Export\ExportManager; -use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface; -use Doctrine\ORM\EntityRepository; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\CallbackTransformer; @@ -49,9 +47,6 @@ class PickCenterType extends AbstractType */ protected array $groupingCenters = []; - /** - * @var \Symfony\Component\Security\Core\User\UserInterface - */ protected UserInterface $user; public function __construct( diff --git a/src/Bundle/ChillMainBundle/Repository/CenterRepository.php b/src/Bundle/ChillMainBundle/Repository/CenterRepository.php index d8e54d1c4..6a52f3399 100644 --- a/src/Bundle/ChillMainBundle/Repository/CenterRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/CenterRepository.php @@ -14,7 +14,6 @@ namespace Chill\MainBundle\Repository; use Chill\MainBundle\Entity\Center; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; -use Doctrine\Persistence\ObjectRepository; final class CenterRepository implements CenterRepositoryInterface { diff --git a/src/Bundle/ChillMainBundle/Repository/CenterRepositoryInterface.php b/src/Bundle/ChillMainBundle/Repository/CenterRepositoryInterface.php index 27ba64caf..eb656f322 100644 --- a/src/Bundle/ChillMainBundle/Repository/CenterRepositoryInterface.php +++ b/src/Bundle/ChillMainBundle/Repository/CenterRepositoryInterface.php @@ -1,5 +1,14 @@ repository->findAll(); } + public function findAllHavingUnits(): array + { + $qb = $this->repository->createQueryBuilder('l'); + + return $qb->where($qb->expr()->gt('SIZE(l.units)', 0)) + ->getQuery() + ->getResult(); + } + /** * @return array|GeographicalUnitLayer[] */ @@ -47,13 +63,4 @@ final class GeographicalUnitLayerLayerRepository implements GeographicalUnitLaye { return GeographicalUnitLayer::class; } - - public function findAllHavingUnits(): array - { - $qb = $this->repository->createQueryBuilder('l'); - - return $qb->where($qb->expr()->gt('SIZE(l.units)', 0)) - ->getQuery() - ->getResult(); - } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillMainBundle/Repository/GeographicalUnitLayerRepositoryInterface.php b/src/Bundle/ChillMainBundle/Repository/GeographicalUnitLayerRepositoryInterface.php index e7c5abdd9..dbc100bf7 100644 --- a/src/Bundle/ChillMainBundle/Repository/GeographicalUnitLayerRepositoryInterface.php +++ b/src/Bundle/ChillMainBundle/Repository/GeographicalUnitLayerRepositoryInterface.php @@ -1,5 +1,14 @@ repository = $em->getRepository($this->getClassName()); $this->em = $em; } - public function find($id): ?GeographicalUnit { return $this->repository->find($id); } /** - * Will return only partial object, where the @link{GeographicalUnit::geom} property is not loaded + * Will return only partial object, where the @see{GeographicalUnit::geom} property is not loaded. * * @return array|GeographicalUnit[] */ @@ -56,4 +62,4 @@ class GeographicalUnitRepository implements GeographicalUnitRepositoryInterface { return GeographicalUnit::class; } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillMainBundle/Repository/GeographicalUnitRepositoryInterface.php b/src/Bundle/ChillMainBundle/Repository/GeographicalUnitRepositoryInterface.php index 10d07893b..76db33422 100644 --- a/src/Bundle/ChillMainBundle/Repository/GeographicalUnitRepositoryInterface.php +++ b/src/Bundle/ChillMainBundle/Repository/GeographicalUnitRepositoryInterface.php @@ -1,10 +1,18 @@ executeStatement(array_merge(...$this->waitingForInsert)); - if ($affected === 0) { - throw new \RuntimeException('no row affected'); + if (0 === $affected) { + throw new RuntimeException('no row affected'); } } catch (Exception $e) { // in some case, we can add debug code here diff --git a/src/Bundle/ChillMainBundle/Service/Import/GeographicalUnitBaseImporter.php b/src/Bundle/ChillMainBundle/Service/Import/GeographicalUnitBaseImporter.php index 539e69028..2668d2c2e 100644 --- a/src/Bundle/ChillMainBundle/Service/Import/GeographicalUnitBaseImporter.php +++ b/src/Bundle/ChillMainBundle/Service/Import/GeographicalUnitBaseImporter.php @@ -13,11 +13,10 @@ namespace Chill\MainBundle\Service\Import; use Doctrine\DBAL\Connection; use Doctrine\DBAL\Statement; -use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Types; use Exception; -use LogicException; use Psr\Log\LoggerInterface; +use RuntimeException; use function array_key_exists; use function count; @@ -77,7 +76,7 @@ final class GeographicalUnitBaseImporter string $unitName, string $unitKey, string $geomAsWKT, - int $srid = null + ?int $srid = null ): void { $this->initialize(); @@ -87,7 +86,7 @@ final class GeographicalUnitBaseImporter 'unitName' => $unitName, 'unitKey' => $unitKey, 'geomAsWKT' => $geomAsWKT, - 'srid' => $srid + 'srid' => $srid, ]; if (100 <= count($this->waitingForInsert)) { @@ -138,8 +137,10 @@ final class GeographicalUnitBaseImporter } $statement = $this->cachingStatements[$forNumber]; + try { $i = 0; + foreach ($this->waitingForInsert as $insert) { $statement->bindValue(++$i, $insert['layerKey'], Types::STRING); $statement->bindValue(++$i, $insert['layerName'], Types::JSON); @@ -151,8 +152,8 @@ final class GeographicalUnitBaseImporter $affected = $statement->executeStatement(); - if ($affected === 0) { - throw new \RuntimeException('no row affected'); + if (0 === $affected) { + throw new RuntimeException('no row affected'); } } catch (Exception $e) { throw $e; @@ -182,10 +183,10 @@ final class GeographicalUnitBaseImporter private function updateGeographicalUnitTable(): void { $this->defaultConnection->transactional( - function() { + function () { // 0) create new layers $this->defaultConnection->executeStatement( - " + " WITH unique_layers AS ( SELECT DISTINCT layerKey, layerName FROM geographical_unit_temp ) @@ -195,14 +196,15 @@ final class GeographicalUnitBaseImporter layerName, layerKey FROM unique_layers - ON CONFLICT (refid) + ON CONFLICT (refid) DO UPDATE SET name=EXCLUDED.name - "); + " + ); //1) Add new units $this->logger->info(self::LOG_PREFIX . 'upsert new units'); - $affected = $this->defaultConnection->executeStatement("INSERT INTO chill_main_geographical_unit - (id, geom, unitname, layer_id, unitrefid) + $affected = $this->defaultConnection->executeStatement("INSERT INTO chill_main_geographical_unit + (id, geom, unitname, layer_id, unitrefid) SELECT nextval('chill_main_geographical_unit_id_seq'), geom, @@ -210,7 +212,7 @@ final class GeographicalUnitBaseImporter layer.id, unitKey FROM geographical_unit_temp JOIN chill_main_geographical_unit_layer AS layer ON layer.refid = layerKey - ON CONFLICT (layer_id, unitrefid) + ON CONFLICT (layer_id, unitrefid) DO UPDATE SET geom = EXCLUDED.geom, unitname = EXCLUDED.unitname "); @@ -219,9 +221,9 @@ final class GeographicalUnitBaseImporter //3) Delete units $this->logger->info(self::LOG_PREFIX . 'soft delete adresses'); $affected = $this->defaultConnection->executeStatement('WITH to_delete AS ( - SELECT cmgu.id + SELECT cmgu.id FROM chill_main_geographical_unit AS cmgu - JOIN chill_main_geographical_unit_layer AS cmgul ON cmgul.id = cmgu.layer_id + JOIN chill_main_geographical_unit_layer AS cmgul ON cmgul.id = cmgu.layer_id JOIN geographical_unit_temp AS gut ON cmgul.refid = gut.layerKey AND cmgu.unitrefid = gut.unitKey ) DELETE FROM chill_main_geographical_unit diff --git a/src/Bundle/ChillMainBundle/Test/Export/AbstractAggregatorTest.php b/src/Bundle/ChillMainBundle/Test/Export/AbstractAggregatorTest.php index 40792a1c6..cf5fe5c31 100644 --- a/src/Bundle/ChillMainBundle/Test/Export/AbstractAggregatorTest.php +++ b/src/Bundle/ChillMainBundle/Test/Export/AbstractAggregatorTest.php @@ -25,6 +25,7 @@ use function is_string; /** * Helper which creates a set of test for aggregators. * + * @internal */ abstract class AbstractAggregatorTest extends KernelTestCase { diff --git a/src/Bundle/ChillMainBundle/Test/Export/AbstractFilterTest.php b/src/Bundle/ChillMainBundle/Test/Export/AbstractFilterTest.php index 8e9761c67..bef4fd200 100644 --- a/src/Bundle/ChillMainBundle/Test/Export/AbstractFilterTest.php +++ b/src/Bundle/ChillMainBundle/Test/Export/AbstractFilterTest.php @@ -24,6 +24,7 @@ use function is_string; /** * Helper to test filters. * + * @internal */ abstract class AbstractFilterTest extends KernelTestCase { diff --git a/src/Bundle/ChillMainBundle/Test/ProphecyTrait.php b/src/Bundle/ChillMainBundle/Test/ProphecyTrait.php index ae274ca1d..82a2c434f 100644 --- a/src/Bundle/ChillMainBundle/Test/ProphecyTrait.php +++ b/src/Bundle/ChillMainBundle/Test/ProphecyTrait.php @@ -18,6 +18,7 @@ namespace Chill\MainBundle\Test; * and use tearDownTrait after usage. * * @codeCoverageIgnore + * * @deprecated use @class{Prophecy\PhpUnit\ProphecyTrait} instead */ trait ProphecyTrait diff --git a/src/Bundle/ChillMainBundle/Tests/Services/Import/AddressReferenceBaseImporterTest.php b/src/Bundle/ChillMainBundle/Tests/Services/Import/AddressReferenceBaseImporterTest.php index cb23634f1..0ed1f2059 100644 --- a/src/Bundle/ChillMainBundle/Tests/Services/Import/AddressReferenceBaseImporterTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Services/Import/AddressReferenceBaseImporterTest.php @@ -1,5 +1,14 @@ setRefPostalCodeId($postalCodeId = '1234'.uniqid()) + ->setRefPostalCodeId($postalCodeId = '1234' . uniqid()) ->setPostalCodeSource('testing') ->setCode('TEST456') ->setName('testing'); @@ -54,7 +70,8 @@ class AddressReferenceBaseImporterTest extends KernelTestCase $addresses = $this->addressReferenceRepository->findByPostalCodePattern( $postalCode, - 'Rue test abcc guessed'); + 'Rue test abcc guessed' + ); $this->assertCount(1, $addresses); $this->assertEquals('Rue test abccc-guessed', $addresses[0]->getStreet()); @@ -79,12 +96,11 @@ class AddressReferenceBaseImporterTest extends KernelTestCase $addresses = $this->addressReferenceRepository->findByPostalCodePattern( $postalCode, - 'abcc guessed fixed'); + 'abcc guessed fixed' + ); $this->assertCount('1', $addresses); - $this->assertEquals( 'Rue test abccc guessed fixed', $addresses[0]->getStreet()); + $this->assertEquals('Rue test abccc guessed fixed', $addresses[0]->getStreet()); $this->assertEquals($previousAddressId, $addresses[0]->getId()); } - - -} \ No newline at end of file +} diff --git a/src/Bundle/ChillMainBundle/Tests/Services/Import/GeographicalUnitBaseImporterTest.php b/src/Bundle/ChillMainBundle/Tests/Services/Import/GeographicalUnitBaseImporterTest.php index bc66c3691..60ad20fc5 100644 --- a/src/Bundle/ChillMainBundle/Tests/Services/Import/GeographicalUnitBaseImporterTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Services/Import/GeographicalUnitBaseImporterTest.php @@ -1,5 +1,14 @@ finalize(); - $unit = $this->connection->executeQuery(" + $unit = $this->connection->executeQuery(' SELECT unitname, unitrefid, cmgul.refid AS layerrefid, cmgul.name AS layername, ST_AsText(ST_snapToGrid(ST_Transform(u.geom, 3812), 1)) AS geom - FROM chill_main_geographical_unit u JOIN chill_main_geographical_unit_layer cmgul on u.layer_id = cmgul.id - WHERE u.unitrefid = ?", ['layer_one']); + FROM chill_main_geographical_unit u JOIN chill_main_geographical_unit_layer cmgul on u.layer_id = cmgul.id + WHERE u.unitrefid = ?', ['layer_one']); $results = $unit->fetchAssociative(); @@ -71,10 +84,10 @@ class GeographicalUnitBaseImporterTest extends KernelTestCase $importer->finalize(); - $unit = $this->connection->executeQuery(" + $unit = $this->connection->executeQuery(' SELECT unitname, unitrefid, cmgul.refid AS layerrefid, cmgul.name AS layername, ST_AsText(ST_snapToGrid(ST_Transform(u.geom, 3812), 1)) AS geom - FROM chill_main_geographical_unit u JOIN chill_main_geographical_unit_layer cmgul on u.layer_id = cmgul.id - WHERE u.unitrefid = ?", ['layer_one']); + FROM chill_main_geographical_unit u JOIN chill_main_geographical_unit_layer cmgul on u.layer_id = cmgul.id + WHERE u.unitrefid = ?', ['layer_one']); $results = $unit->fetchAssociative(); @@ -83,7 +96,5 @@ class GeographicalUnitBaseImporterTest extends KernelTestCase $this->assertEquals(json_decode($results['layername'], true), ['fr' => 'Test Layer fixed']); $this->assertEquals($results['layerrefid'], 'test'); $this->assertEquals($results['geom'], 'MULTIPOLYGON(((130 120,45 40,10 40,130 120)),((0 0,15 5,40 10,10 20,0 0)))'); - } - -} \ No newline at end of file +} diff --git a/src/Bundle/ChillMainBundle/Tests/Services/Import/PostalCodeBaseImporterTest.php b/src/Bundle/ChillMainBundle/Tests/Services/Import/PostalCodeBaseImporterTest.php index 826e581ac..ce40d40bf 100644 --- a/src/Bundle/ChillMainBundle/Tests/Services/Import/PostalCodeBaseImporterTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Services/Import/PostalCodeBaseImporterTest.php @@ -1,5 +1,14 @@ importer->importCode( 'BE', - 'tested with pattern '. ($uniqid = uniqid()), + 'tested with pattern ' . ($uniqid = uniqid()), '12345', - $refPostalCodeId = 'test'.uniqid(), + $refPostalCodeId = 'test' . uniqid(), 'test', 50.0, 5.0, @@ -46,8 +59,8 @@ class PostalCodeBaseImporterTest extends KernelTestCase $this->importer->finalize(); $postalCodes = $this->postalCodeRepository->findByPattern( - 'with pattern '.$uniqid, - $this->countryRepository->findOneBy(['countryCode' => 'BE']) + 'with pattern ' . $uniqid, + $this->countryRepository->findOneBy(['countryCode' => 'BE']) ); $this->assertCount(1, $postalCodes); @@ -59,7 +72,7 @@ class PostalCodeBaseImporterTest extends KernelTestCase $this->importer->importCode( 'BE', - 'tested with adapted pattern '. ($uniqid = uniqid()), + 'tested with adapted pattern ' . ($uniqid = uniqid()), '12345', $refPostalCodeId, 'test', @@ -71,7 +84,7 @@ class PostalCodeBaseImporterTest extends KernelTestCase $this->importer->finalize(); $postalCodes = $this->postalCodeRepository->findByPattern( - 'with pattern '.$uniqid, + 'with pattern ' . $uniqid, $this->countryRepository->findOneBy(['countryCode' => 'BE']) ); @@ -79,7 +92,4 @@ class PostalCodeBaseImporterTest extends KernelTestCase $this->assertStringStartsWith('tested with adapted pattern', $postalCodes[0]->getName()); $this->assertEquals($previousId, $postalCodes[0]->getId()); } - - - -} \ No newline at end of file +} diff --git a/src/Bundle/ChillMainBundle/Tests/Workflow/EventSubscriber/NotificationOnTransitionTest.php b/src/Bundle/ChillMainBundle/Tests/Workflow/EventSubscriber/NotificationOnTransitionTest.php index 3aa2c71b1..365b01a67 100644 --- a/src/Bundle/ChillMainBundle/Tests/Workflow/EventSubscriber/NotificationOnTransitionTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Workflow/EventSubscriber/NotificationOnTransitionTest.php @@ -1,5 +1,14 @@ setWorkflowName('workflow_name') - ->setRelatedEntityClass(\stdClass::class) - ->setRelatedEntityId(1) - ; + ->setRelatedEntityClass(stdClass::class) + ->setRelatedEntityId(1); // force an id to entityWorkflow: - $reflection = new \ReflectionClass($entityWorkflow); + $reflection = new ReflectionClass($entityWorkflow); $id = $reflection->getProperty('id'); $id->setAccessible(true); $id->setValue($entityWorkflow, 1); @@ -48,12 +62,11 @@ class NotificationOnTransitionTest extends TestCase $step = new EntityWorkflowStep(); $entityWorkflow->addStep($step); $step->addDestUser($dest) - ->setCurrentStep('to_state') - ; + ->setCurrentStep('to_state'); $em = $this->prophesize(EntityManagerInterface::class); $em->persist(Argument::type(Notification::class))->should( - function($args) use ($dest) { + static function ($args) use ($dest) { /** @var Call[] $args */ if (1 !== count($args)) { throw new FailedPredictionException('no notification sent'); @@ -68,7 +81,8 @@ class NotificationOnTransitionTest extends TestCase if (!$notification->getAddressees()->contains($dest)) { throw new FailedPredictionException('the dest is not notified'); } - }); + } + ); $engine = $this->prophesize(EngineInterface::class); $engine->render(Argument::type('string'), Argument::type('array')) diff --git a/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/EntityWorkflowTransitionEventSubscriber.php b/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/EntityWorkflowTransitionEventSubscriber.php index 2510f9460..0f6a4799a 100644 --- a/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/EntityWorkflowTransitionEventSubscriber.php +++ b/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/EntityWorkflowTransitionEventSubscriber.php @@ -41,6 +41,24 @@ class EntityWorkflowTransitionEventSubscriber implements EventSubscriberInterfac $this->userRender = $userRender; } + public function addDests(Event $event): void + { + if (!$event->getSubject() instanceof EntityWorkflow) { + return; + } + + /** @var EntityWorkflow $entityWorkflow */ + $entityWorkflow = $event->getSubject(); + + foreach ($entityWorkflow->futureDestUsers as $user) { + $entityWorkflow->getCurrentStep()->addDestUser($user); + } + + foreach ($entityWorkflow->futureDestEmails as $email) { + $entityWorkflow->getCurrentStep()->addDestEmail($email); + } + } + public static function getSubscribedEvents(): array { return [ @@ -55,23 +73,6 @@ class EntityWorkflowTransitionEventSubscriber implements EventSubscriberInterfac ]; } - public function addDests(Event $event): void - { - if (!$event->getSubject() instanceof EntityWorkflow) { - return; - } - - /** @var EntityWorkflow $entityWorkflow */ - $entityWorkflow = $event->getSubject(); - foreach ($entityWorkflow->futureDestUsers as $user) { - $entityWorkflow->getCurrentStep()->addDestUser($user); - } - - foreach ($entityWorkflow->futureDestEmails as $email) { - $entityWorkflow->getCurrentStep()->addDestEmail($email); - } - } - public function guardEntityWorkflow(GuardEvent $event) { if (!$event->getSubject() instanceof EntityWorkflow) { diff --git a/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/NotificationOnTransition.php b/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/NotificationOnTransition.php index 982a7024e..c56dc34ce 100644 --- a/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/NotificationOnTransition.php +++ b/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/NotificationOnTransition.php @@ -57,14 +57,15 @@ class NotificationOnTransition implements EventSubscriberInterface } /** - * Send a notification to: + * Send a notification to:. * * * the dests of the new step; * * the users which subscribed to workflow, on each step, or on final * * **Warning** take care that this method must be executed **after** the dest users are added to - * the step (@link{EntityWorkflowStep::addDestUser}). Currently, this is done during - * @link{EntityWorkflowTransitionEventSubscriber::addDests}. + * the step (@see{EntityWorkflowStep::addDestUser}). Currently, this is done during + * + * @see{EntityWorkflowTransitionEventSubscriber::addDests}. */ public function onCompletedSendNotification(Event $event): void { @@ -77,6 +78,7 @@ class NotificationOnTransition implements EventSubscriberInterface /** @var array $dests array of unique values, where keys is the object's hash */ $dests = []; + foreach (array_merge( // the subscriber to each step $entityWorkflow->getSubscriberToStep()->toArray(), diff --git a/src/Bundle/ChillMainBundle/migrations/Version20220730204216.php b/src/Bundle/ChillMainBundle/migrations/Version20220730204216.php index 4ed1b2918..e4ad98318 100644 --- a/src/Bundle/ChillMainBundle/migrations/Version20220730204216.php +++ b/src/Bundle/ChillMainBundle/migrations/Version20220730204216.php @@ -1,5 +1,12 @@ addSql('DROP INDEX chill_main_address_reference_unicity'); + } + public function getDescription(): string { return 'Add an unique constraint on addresses references'; @@ -18,9 +30,4 @@ final class Version20220730204216 extends AbstractMigration { $this->addSql('CREATE UNIQUE INDEX chill_main_address_reference_unicity ON chill_main_address_reference (refId, source)'); } - - public function down(Schema $schema): void - { - $this->addSql('DROP INDEX chill_main_address_reference_unicity'); - } } diff --git a/src/Bundle/ChillMainBundle/migrations/Version20220913174922.php b/src/Bundle/ChillMainBundle/migrations/Version20220913174922.php index cabc7f1f8..f00cb5aa1 100644 --- a/src/Bundle/ChillMainBundle/migrations/Version20220913174922.php +++ b/src/Bundle/ChillMainBundle/migrations/Version20220913174922.php @@ -1,5 +1,12 @@ addSql('ALTER TABLE chill_main_geographical_unit ALTER COLUMN geom SET DATA TYPE TEXT'); + } + public function getDescription(): string { return 'Geographical Unit correction'; @@ -21,9 +33,4 @@ final class Version20220913174922 extends AbstractMigration { $this->addSql('ALTER TABLE chill_main_geographical_unit ALTER COLUMN geom SET DATA TYPE GEOMETRY(MULTIPOLYGON, 4326)'); } - - public function down(Schema $schema): void - { - $this->addSql('ALTER TABLE chill_main_geographical_unit ALTER COLUMN geom SET DATA TYPE TEXT'); - } } diff --git a/src/Bundle/ChillMainBundle/migrations/Version20221003112151.php b/src/Bundle/ChillMainBundle/migrations/Version20221003112151.php index 36b1834ea..b9753ce8c 100644 --- a/src/Bundle/ChillMainBundle/migrations/Version20221003112151.php +++ b/src/Bundle/ChillMainBundle/migrations/Version20221003112151.php @@ -1,5 +1,12 @@ addSql('CREATE SEQUENCE chill_main_geographical_unit_layer_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); - $this->addSql('CREATE TABLE chill_main_geographical_unit_layer (id INT NOT NULL, name JSONB DEFAULT \'[]\'::jsonb NOT NULL, refid TEXT DEFAULT \'\' NOT NULL, PRIMARY KEY(id))'); - $this->addSql("COMMENT ON COLUMN chill_main_geographical_unit_layer.name IS '(DC2Type:json)';"); - - $this->addSql('INSERT INTO chill_main_geographical_unit_layer (id, name, refid) - SELECT DISTINCT nextval(\'chill_main_geographical_unit_layer_id_seq\'), jsonb_build_object(\'fr\', layername), layername FROM chill_main_geographical_unit'); - - $this->addSql('ALTER TABLE chill_main_geographical_unit ADD layer_id INT DEFAULT NULL'); - - $this->addSql('UPDATE chill_main_geographical_unit SET layer_id = layer.id FROM chill_main_geographical_unit_layer AS layer WHERE layer.refid = chill_main_geographical_unit.layername'); - - $this->addSql('ALTER TABLE chill_main_geographical_unit ADD unitRefId TEXT DEFAULT \'\' NOT NULL'); - $this->addSql('ALTER TABLE chill_main_geographical_unit DROP layername'); - $this->addSql("COMMENT ON COLUMN chill_main_geographical_unit.geom IS '(DC2Type:text)';"); - $this->addSql('ALTER TABLE chill_main_geographical_unit ALTER unitname TYPE TEXT'); - $this->addSql('ALTER TABLE chill_main_geographical_unit ALTER unitname SET DEFAULT \'\''); - $this->addSql('ALTER TABLE chill_main_geographical_unit ALTER unitname SET NOT NULL'); - $this->addSql('ALTER TABLE chill_main_geographical_unit ADD CONSTRAINT FK_360A2B2FEA6EFDCD FOREIGN KEY (layer_id) REFERENCES chill_main_geographical_unit_layer (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); - $this->addSql('CREATE INDEX IDX_360A2B2FEA6EFDCD ON chill_main_geographical_unit (layer_id)'); - - } - public function down(Schema $schema): void { $this->throwIrreversibleMigrationException(); @@ -53,6 +31,34 @@ final class Version20221003112151 extends AbstractMigration $this->addSql('ALTER TABLE chill_main_geographical_unit ALTER unitName TYPE VARCHAR(255)'); $this->addSql('ALTER TABLE chill_main_geographical_unit ALTER unitName DROP DEFAULT'); $this->addSql('ALTER TABLE chill_main_geographical_unit ALTER unitName DROP NOT NULL'); - */ + */ + } + + public function getDescription(): string + { + return 'Add a proper entity for GeographicalUnitLayer'; + } + + public function up(Schema $schema): void + { + $this->addSql('CREATE SEQUENCE chill_main_geographical_unit_layer_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE TABLE chill_main_geographical_unit_layer (id INT NOT NULL, name JSONB DEFAULT \'[]\'::jsonb NOT NULL, refid TEXT DEFAULT \'\' NOT NULL, PRIMARY KEY(id))'); + $this->addSql("COMMENT ON COLUMN chill_main_geographical_unit_layer.name IS '(DC2Type:json)';"); + + $this->addSql('INSERT INTO chill_main_geographical_unit_layer (id, name, refid) + SELECT DISTINCT nextval(\'chill_main_geographical_unit_layer_id_seq\'), jsonb_build_object(\'fr\', layername), layername FROM chill_main_geographical_unit'); + + $this->addSql('ALTER TABLE chill_main_geographical_unit ADD layer_id INT DEFAULT NULL'); + + $this->addSql('UPDATE chill_main_geographical_unit SET layer_id = layer.id FROM chill_main_geographical_unit_layer AS layer WHERE layer.refid = chill_main_geographical_unit.layername'); + + $this->addSql('ALTER TABLE chill_main_geographical_unit ADD unitRefId TEXT DEFAULT \'\' NOT NULL'); + $this->addSql('ALTER TABLE chill_main_geographical_unit DROP layername'); + $this->addSql("COMMENT ON COLUMN chill_main_geographical_unit.geom IS '(DC2Type:text)';"); + $this->addSql('ALTER TABLE chill_main_geographical_unit ALTER unitname TYPE TEXT'); + $this->addSql('ALTER TABLE chill_main_geographical_unit ALTER unitname SET DEFAULT \'\''); + $this->addSql('ALTER TABLE chill_main_geographical_unit ALTER unitname SET NOT NULL'); + $this->addSql('ALTER TABLE chill_main_geographical_unit ADD CONSTRAINT FK_360A2B2FEA6EFDCD FOREIGN KEY (layer_id) REFERENCES chill_main_geographical_unit_layer (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('CREATE INDEX IDX_360A2B2FEA6EFDCD ON chill_main_geographical_unit (layer_id)'); } } diff --git a/src/Bundle/ChillMainBundle/migrations/Version20221003132620.php b/src/Bundle/ChillMainBundle/migrations/Version20221003132620.php index e07885dce..8186ce7ed 100644 --- a/src/Bundle/ChillMainBundle/migrations/Version20221003132620.php +++ b/src/Bundle/ChillMainBundle/migrations/Version20221003132620.php @@ -1,5 +1,12 @@ addSql('DROP INDEX geographical_unit_layer_refid'); + $this->addSql('DROP INDEX geographical_unit_refid'); + $this->addSql('DROP INDEX chill_internal_geographical_unit_layer_geom_idx'); + } + public function getDescription(): string { return 'Create indexes and unique constraints on geographical unit entities'; @@ -20,11 +34,4 @@ final class Version20221003132620 extends AbstractMigration $this->addSql('CREATE UNIQUE INDEX geographical_unit_refid ON chill_main_geographical_unit (layer_id, unitRefId)'); $this->addSql('CREATE INDEX chill_internal_geographical_unit_layer_geom_idx ON chill_main_geographical_unit USING GIST (layer_id, geom)'); } - - public function down(Schema $schema): void - { - $this->addSql('DROP INDEX geographical_unit_layer_refid'); - $this->addSql('DROP INDEX geographical_unit_refid'); - $this->addSql('DROP INDEX chill_internal_geographical_unit_layer_geom_idx'); - } } diff --git a/src/Bundle/ChillPersonBundle/Entity/Person.php b/src/Bundle/ChillPersonBundle/Entity/Person.php index dc311ad07..731b41905 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person.php @@ -46,6 +46,7 @@ use libphonenumber\PhoneNumber; use Symfony\Component\Serializer\Annotation\DiscriminatorMap; use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Context\ExecutionContextInterface; +use UnexpectedValueException; use function count; use function in_array; @@ -182,21 +183,23 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * The person's center. * * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Center") + * * @deprecated */ private ?Center $center = null; - /** - * @ORM\OneToMany(targetEntity=PersonCenterHistory::class, mappedBy="person", cascade={"persist"}) - * @var Collection|PersonCenterHistory[] - */ - private Collection $centerHistory; - /** * @ORM\OneToOne(targetEntity=PersonCenterCurrent::class, mappedBy="person") */ private ?PersonCenterCurrent $centerCurrent = null; + /** + * @ORM\OneToMany(targetEntity=PersonCenterHistory::class, mappedBy="person", cascade={"persist"}) + * + * @var Collection|PersonCenterHistory[] + */ + private Collection $centerHistory; + /** * Array where customfield's data are stored. * @@ -910,32 +913,6 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI return $this->budgetResources; } - private function getCurrentCenterHistory(): ?PersonCenterHistory - { - if (0 === $this->centerHistory->count()) { - return null; - } - - $criteria = Criteria::create(); - $now = new DateTimeImmutable('now'); - $criteria->where(Criteria::expr()->lte('startDate', $now)) - ->andWhere(Criteria::expr()->orX( - Criteria::expr()->isNull('endDate'), - Criteria::expr()->gt('endDate', $now) - )); - - $histories = $this->centerHistory->matching($criteria); - - switch ($histories->count()) { - case 0: - return null; - case 1: - return $histories->first(); - default: - throw new \UnexpectedValueException('It should not contains more than one center at a time'); - } - } - public function getCenter(): ?Center { if (null !== $this->centerCurrent) { @@ -949,6 +926,24 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI return $currentCenterHistory->getCenter(); } + public function getCenterCurrent(): ?PersonCenterCurrent + { + if (null !== $this->centerCurrent) { + return $this->centerCurrent; + } + + if (null === $currentCenterHistory = $this->getCurrentCenterHistory()) { + return null; + } + + return new PersonCenterCurrent($currentCenterHistory); + } + + public function getCenterHistory(): Collection + { + return $this->centerHistory; + } + public function getCFData(): ?array { if (null === $this->cFData) { @@ -1562,7 +1557,6 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI /** * Associate the center with the person. The association start on 'now'. * - * @param Center $center * @return $this */ public function setCenter(Center $center): self @@ -1582,40 +1576,13 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI return $this; } - /** - * @return Collection - */ - public function getCenterHistory(): Collection - { - return $this->centerHistory; - } - - /** - * @param Collection $centerHistory - * @return Person - */ public function setCenterHistory(Collection $centerHistory): Person { $this->centerHistory = $centerHistory; + return $this; } - /** - * @return PersonCenterCurrent|null - */ - public function getCenterCurrent(): ?PersonCenterCurrent - { - if (null !== $this->centerCurrent) { - return $this->centerCurrent; - } - - if (null === $currentCenterHistory = $this->getCurrentCenterHistory()) { - return null; - } - - return new PersonCenterCurrent($currentCenterHistory); - } - /** * @return Person */ @@ -1818,6 +1785,34 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI return $this; } + private function getCurrentCenterHistory(): ?PersonCenterHistory + { + if (0 === $this->centerHistory->count()) { + return null; + } + + $criteria = Criteria::create(); + $now = new DateTimeImmutable('now'); + $criteria->where(Criteria::expr()->lte('startDate', $now)) + ->andWhere(Criteria::expr()->orX( + Criteria::expr()->isNull('endDate'), + Criteria::expr()->gt('endDate', $now) + )); + + $histories = $this->centerHistory->matching($criteria); + + switch ($histories->count()) { + case 0: + return null; + + case 1: + return $histories->first(); + + default: + throw new UnexpectedValueException('It should not contains more than one center at a time'); + } + } + /** * This private function scan accompanyingPeriodParticipations Collection, * searching for a given AccompanyingPeriod. diff --git a/src/Bundle/ChillPersonBundle/Entity/Person/PersonCenterCurrent.php b/src/Bundle/ChillPersonBundle/Entity/Person/PersonCenterCurrent.php index 690ff025e..30de1f55a 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person/PersonCenterCurrent.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person/PersonCenterCurrent.php @@ -1,15 +1,19 @@ id = $history->getId(); } + public function getCenter(): Center + { + return $this->center; + } + + public function getEndDate(): ?DateTimeImmutable + { + return $this->endDate; + } + /** - * The id will be the same as the current @link{PersonCenterHistory::class} - * - * @return int + * The id will be the same as the current @see{PersonCenterHistory::class}. */ public function getId(): int { return $this->id; } - /** - * @return Person - */ public function getPerson(): Person { return $this->person; } - /** - * @return Center - */ - public function getCenter(): Center - { - return $this->center; - } - - /** - * @return \DateTimeImmutable - */ - public function getStartDate(): \DateTimeImmutable + public function getStartDate(): DateTimeImmutable { return $this->startDate; } - - /** - * @return \DateTimeImmutable|null - */ - public function getEndDate(): ?\DateTimeImmutable - { - return $this->endDate; - } - } diff --git a/src/Bundle/ChillPersonBundle/Entity/Person/PersonCenterHistory.php b/src/Bundle/ChillPersonBundle/Entity/Person/PersonCenterHistory.php index 6bfb28cc6..a9ec61251 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person/PersonCenterHistory.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person/PersonCenterHistory.php @@ -1,5 +1,14 @@ person = $person; $this->center = $center; $this->startDate = $startDate; } - - /** - * @return int|null - */ - public function getId(): ?int - { - return $this->id; - } - - /** - * @return Person|null - */ - public function getPerson(): ?Person - { - return $this->person; - } - - /** - * @param Person|null $person - */ - public function setPerson(?Person $person): self - { - $this->person = $person; - - return $this; - } - - /** - * @return Center|null - */ public function getCenter(): ?Center { return $this->center; } - /** - * @param Center|null $center - */ + public function getEndDate(): ?DateTimeImmutable + { + return $this->endDate; + } + + public function getId(): ?int + { + return $this->id; + } + + public function getPerson(): ?Person + { + return $this->person; + } + + public function getStartDate(): ?DateTimeImmutable + { + return $this->startDate; + } + public function setCenter(?Center $center): self { $this->center = $center; @@ -105,38 +98,24 @@ class PersonCenterHistory implements TrackCreationInterface, TrackUpdateInterfac return $this; } - /** - * @return \DateTimeImmutable|null - */ - public function getStartDate(): ?\DateTimeImmutable - { - return $this->startDate; - } - - /** - * @param \DateTimeImmutable|null $startDate - */ - public function setStartDate(?\DateTimeImmutable $startDate): self - { - $this->startDate = $startDate; - return $this; - } - - /** - * @return \DateTimeImmutable|null - */ - public function getEndDate(): ?\DateTimeImmutable - { - return $this->endDate; - } - - /** - * @param \DateTimeImmutable|null $endDate - */ - public function setEndDate(?\DateTimeImmutable $endDate): self + public function setEndDate(?DateTimeImmutable $endDate): self { $this->endDate = $endDate; return $this; } + + public function setPerson(?Person $person): self + { + $this->person = $person; + + return $this; + } + + public function setStartDate(?DateTimeImmutable $startDate): self + { + $this->startDate = $startDate; + + return $this; + } } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/AdministrativeLocationAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/AdministrativeLocationAggregator.php index c0d20e7c7..b51b31c60 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/AdministrativeLocationAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/AdministrativeLocationAggregator.php @@ -17,6 +17,7 @@ use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\PersonBundle\Export\Declarations; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; +use function in_array; class AdministrativeLocationAggregator implements AggregatorInterface { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregator.php index de276f007..de3075747 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregator.php @@ -13,11 +13,8 @@ namespace Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators; use Chill\MainBundle\Export\AggregatorInterface; use Chill\MainBundle\Templating\TranslatableStringHelper; -use Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive; use Chill\PersonBundle\Export\Declarations; -use Chill\PersonBundle\Repository\AccompanyingPeriod\ClosingMotiveRepository; use Chill\PersonBundle\Repository\AccompanyingPeriod\ClosingMotiveRepositoryInterface; -use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; @@ -63,7 +60,7 @@ class ClosingMotiveAggregator implements AggregatorInterface return 'Closing motive'; } - if (NULL === $value) { + if (null === $value) { return ''; } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php index 9f1ff1ba4..884b9c8e9 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php @@ -1,5 +1,14 @@ translatableStringHelper = $translatableStringHelper; } - /** - * @inheritDoc - */ - public function getLabels($key, array $values, $data) - { - switch ($key) { - case 'acp_geog_agg_unitname': - return function ($value): string { - if ('_header' === $value) { - return 'acp_geog_agg_unitname'; - } - - if (null === $value) { - return ''; - } - - return $value; - }; - case 'acp_geog_agg_unitrefid': - return function ($value): string { - if ('_header' === $value) { - return 'acp_geog_agg_unitrefid'; - } - - if (null === $value) { - return ''; - } - - return $value; - }; - default: - throw new \UnexpectedValueException('this value should not happens'); - } - } - - /** - * @inheritDoc - */ - public function getQueryKeys($data): array - { - return ['acp_geog_agg_unitname', 'acp_geog_agg_unitrefid']; - } - - /** - * @inheritDoc - */ - public function buildForm(FormBuilderInterface $builder) - { - $builder - ->add('date_calc', ChillDateType::class, [ - 'label' => 'Compute geographical location at date', - 'required' => true, - 'data' => new \DateTimeImmutable('today'), - 'input' => 'datetime_immutable', - ]) - ->add('level', EntityType::class, [ - 'label' => 'Geographical layer', - 'placeholder' => 'Select a geographical layer', - 'class' => GeographicalUnitLayer::class, - 'choices' => $this->geographicalUnitLayerRepository->findAllHavingUnits(), - 'choice_label' => function(GeographicalUnitLayer $item) { - return $this->translatableStringHelper->localize($item->getName()); - }, - ]); - } - - /** - * @inheritDoc - */ - public function getTitle(): string - { - return 'Group by geographical unit'; - } - - /** - * @inheritDoc - */ public function addRole(): ?string { return null; } - /** - * @inheritDoc - */ public function alterQuery(QueryBuilder $qb, $data) { if (!in_array('acp_geog_agg_location_history', $qb->getAllAliases(), true)) { @@ -181,15 +111,75 @@ final class GeographicalUnitStatAggregator implements AggregatorInterface ->addSelect('acp_geog_units.unitName AS acp_geog_agg_unitname') ->addSelect('acp_geog_units.unitRefId AS acp_geog_agg_unitrefid') ->addGroupBy('acp_geog_agg_unitname') - ->addGroupBy('acp_geog_agg_unitrefid') - ; + ->addGroupBy('acp_geog_agg_unitrefid'); } - /** - * @inheritDoc - */ public function applyOn(): string { return Declarations::ACP_TYPE; } + + public function buildForm(FormBuilderInterface $builder) + { + $builder + ->add('date_calc', ChillDateType::class, [ + 'label' => 'Compute geographical location at date', + 'required' => true, + 'data' => new DateTimeImmutable('today'), + 'input' => 'datetime_immutable', + ]) + ->add('level', EntityType::class, [ + 'label' => 'Geographical layer', + 'placeholder' => 'Select a geographical layer', + 'class' => GeographicalUnitLayer::class, + 'choices' => $this->geographicalUnitLayerRepository->findAllHavingUnits(), + 'choice_label' => function (GeographicalUnitLayer $item) { + return $this->translatableStringHelper->localize($item->getName()); + }, + ]); + } + + public function getLabels($key, array $values, $data) + { + switch ($key) { + case 'acp_geog_agg_unitname': + return static function ($value): string { + if ('_header' === $value) { + return 'acp_geog_agg_unitname'; + } + + if (null === $value) { + return ''; + } + + return $value; + }; + + case 'acp_geog_agg_unitrefid': + return static function ($value): string { + if ('_header' === $value) { + return 'acp_geog_agg_unitrefid'; + } + + if (null === $value) { + return ''; + } + + return $value; + }; + + default: + throw new UnexpectedValueException('this value should not happens'); + } + } + + public function getQueryKeys($data): array + { + return ['acp_geog_agg_unitname', 'acp_geog_agg_unitrefid']; + } + + public function getTitle(): string + { + return 'Group by geographical unit'; + } } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/JobAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/JobAggregator.php index 0809f7654..df48d61af 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/JobAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/JobAggregator.php @@ -17,6 +17,7 @@ use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\PersonBundle\Export\Declarations; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; +use function in_array; final class JobAggregator implements AggregatorInterface { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/OriginAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/OriginAggregator.php index c7a178fa3..e9c2ef878 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/OriginAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/OriginAggregator.php @@ -19,6 +19,7 @@ use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; +use function in_array; final class OriginAggregator implements AggregatorInterface { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerAggregator.php index 7851fe203..26e724526 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerAggregator.php @@ -17,6 +17,7 @@ use Chill\MainBundle\Templating\Entity\UserRender; use Chill\PersonBundle\Export\Declarations; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; +use function in_array; final class ReferrerAggregator implements AggregatorInterface { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerScopeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerScopeAggregator.php index 3701371a7..b56f70614 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerScopeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerScopeAggregator.php @@ -1,25 +1,34 @@ translatableStringHelper = $translatableStringHelper; } - /** - * @inheritDoc - */ + public function addRole(): ?string + { + return null; + } + + public function alterQuery(QueryBuilder $qb, $data) + { + $userHistory = 'acp_agg_refscope_user_history'; + $ref = 'acp_agg_refscope_user_history_ref'; + $scopeName = self::SCOPE_KEY; + $dateCalc = 'acp_agg_refscope_user_history_date_calc'; + + $qb + ->leftJoin('acp.userHistories', $userHistory) + ->leftJoin($userHistory . '.user', $ref) + ->andWhere( + $qb->expr()->orX( + $qb->expr()->isNull($userHistory), + $qb->expr()->andX( + $qb->expr()->lte($userHistory . '.startDate', ':' . $dateCalc), + $qb->expr()->orX( + $qb->expr()->isNull($userHistory . '.endDate'), + $qb->expr()->lt($userHistory . '.endDate', ':' . $dateCalc) + ) + ) + ) + ) + ->setParameter($dateCalc, $data['date_calc']); + + // add groups + $qb + ->addSelect('IDENTITY(' . $ref . '.mainScope) AS ' . $scopeName) + ->addGroupBy($scopeName); + } + + public function applyOn() + { + return Declarations::ACP_TYPE; + } + + public function buildForm(FormBuilderInterface $builder) + { + $builder->add('date_calc', ChillDateType::class, [ + 'input' => 'datetime_immutable', + 'data' => new DateTimeImmutable('now'), + 'label' => 'export.aggregator.course.by_user_scope.Computation date for referrer', + 'required' => true, + ]); + } + public function getLabels($key, array $values, $data) { return function ($value) { @@ -45,89 +101,20 @@ class ReferrerScopeAggregator implements AggregatorInterface $scope = $this->scopeRepository->find($value); if (null === $scope) { - throw new \LogicException('no scope found with this id: ' . $value); + throw new LogicException('no scope found with this id: ' . $value); } return $this->translatableStringHelper->localize($scope->getName()); }; } - /** - * @inheritDoc - */ public function getQueryKeys($data) { return [self::SCOPE_KEY]; } - /** - * @inheritDoc - */ - public function buildForm(FormBuilderInterface $builder) - { - $builder->add('date_calc', ChillDateType::class, [ - 'input' => 'datetime_immutable', - 'data' => new \DateTimeImmutable('now'), - 'label' => 'export.aggregator.course.by_user_scope.Computation date for referrer', - 'required' => true, - ]); - } - - /** - * @inheritDoc - */ public function getTitle() { return 'export.aggregator.course.by_user_scope.Group course by referrer\'s scope'; } - - /** - * @inheritDoc - */ - public function addRole(): ?string - { - return null; - } - - /** - * @inheritDoc - */ - public function alterQuery(QueryBuilder $qb, $data) - { - $userHistory = 'acp_agg_refscope_user_history'; - $ref = 'acp_agg_refscope_user_history_ref'; - $scopeName = self::SCOPE_KEY; - $dateCalc = 'acp_agg_refscope_user_history_date_calc'; - - $qb - ->leftJoin('acp.userHistories', $userHistory) - ->leftJoin($userHistory.'.user', $ref) - ->andWhere( - $qb->expr()->orX( - $qb->expr()->isNull($userHistory), - $qb->expr()->andX( - $qb->expr()->lte($userHistory.'.startDate', ':'.$dateCalc), - $qb->expr()->orX( - $qb->expr()->isNull($userHistory.'.endDate'), - $qb->expr()->lt($userHistory.'.endDate', ':'.$dateCalc) - ) - ) - ) - ) - ->setParameter($dateCalc, $data['date_calc']); - - // add groups - $qb - ->addSelect('IDENTITY('.$ref.'.mainScope) AS '.$scopeName) - ->addGroupBy($scopeName) - ; - } - - /** - * @inheritDoc - */ - public function applyOn() - { - return Declarations::ACP_TYPE; - } } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ScopeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ScopeAggregator.php index 77eb06835..f711cf9ef 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ScopeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ScopeAggregator.php @@ -17,6 +17,7 @@ use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\PersonBundle\Export\Declarations; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; +use function in_array; final class ScopeAggregator implements AggregatorInterface { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialIssueAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialIssueAggregator.php index 98fdbad0c..e013f94d3 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialIssueAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialIssueAggregator.php @@ -17,6 +17,7 @@ use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository; use Chill\PersonBundle\Templating\Entity\SocialIssueRender; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; +use function in_array; final class SocialIssueAggregator implements AggregatorInterface { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/StepAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/StepAggregator.php index 2a1a3db25..809bb9645 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/StepAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/StepAggregator.php @@ -63,7 +63,7 @@ final class StepAggregator implements AggregatorInterface //, FilterInterface $qb->add('where', $where); $qb->setParameter('ondate', $data['on_date'], Types::DATE_MUTABLE); - */ + */ } public function applyOn(): string diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/ChildrenNumberAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/ChildrenNumberAggregator.php index 2343b2bab..d51575d6e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/ChildrenNumberAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/ChildrenNumberAggregator.php @@ -17,7 +17,6 @@ use Chill\PersonBundle\Export\Declarations; use DateTime; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Query\Expr; -use Doctrine\ORM\Query\Expr\Andx; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Contracts\Translation\TranslatorInterface; @@ -73,7 +72,7 @@ class ChildrenNumberAggregator implements AggregatorInterface public function getLabels($key, array $values, $data) { - return function ($value): string { + return static function ($value): string { if ('_header' === $value) { return 'Number of children'; } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/CompositionAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/CompositionAggregator.php index 7e10ea429..6e180934b 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/CompositionAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/CompositionAggregator.php @@ -19,7 +19,6 @@ use Chill\PersonBundle\Repository\Household\HouseholdCompositionTypeRepository; use DateTime; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Query\Expr; -use Doctrine\ORM\Query\Expr\Andx; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; use function in_array; diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GeographicalUnitAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GeographicalUnitAggregator.php index 816666e2f..feccafe50 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GeographicalUnitAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GeographicalUnitAggregator.php @@ -1,5 +1,14 @@ translatableStringHelper = $translatableStringHelper; } - /** - * @inheritDoc - */ - public function getLabels($key, array $values, $data) - { - switch ($key) { - case 'geog_unit_name': - return function ($value): string { - if ('_header' === $value) { - return 'acp_geog_agg_unitname'; - } - - if (null === $value) { - return ''; - } - - return $value; - }; - - case 'geog_unit_key': - return function ($value): string { - if ('_header' === $value) { - return 'acp_geog_agg_unitrefid'; - } - - if (null === $value) { - return ''; - } - - return $value; - }; - - default: - throw new \LogicException('key not supported'); - } - } - - /** - * @inheritDoc - */ - public function getQueryKeys($data) - { - return ['geog_unit_name', 'geog_unit_key']; - } - - /** - * @inheritDoc - */ - public function buildForm(FormBuilderInterface $builder) - { - $builder - ->add('date_calc', ChillDateType::class, [ - 'label' => 'Address valid at this date', - 'required' => true, - 'data' => new \DateTimeImmutable('today'), - 'input' => 'datetime_immutable', - ]) - ->add('level', EntityType::class, [ - 'label' => 'Geographical layer', - 'placeholder' => 'Select a geographical layer', - 'class' => GeographicalUnitLayer::class, - 'choices' => $this->geographicalUnitLayerRepository->findAllHavingUnits(), - 'choice_label' => function(GeographicalUnitLayer $item) { - return $this->translatableStringHelper->localize($item->getName()); - }, - ]); - } - - /** - * @inheritDoc - */ - public function getTitle() - { - return 'Group people by geographical unit based on his address'; - } - - /** - * @inheritDoc - */ public function addRole(): ?string { return null; } - /** - * @inheritDoc - */ public function alterQuery(QueryBuilder $qb, $data): void { $qb @@ -144,20 +73,80 @@ class GeographicalUnitAggregator implements AggregatorInterface ->addSelect('person_geog_agg_geog_unit.unitName AS geog_unit_name') ->addSelect('person_geog_agg_geog_unit.unitRefId AS geog_unit_key') ->addGroupBy('geog_unit_name') - ->addGroupBy('geog_unit_key') - ; + ->addGroupBy('geog_unit_key'); } - /** - * @inheritDoc - */ public function applyOn() { return Declarations::PERSON_TYPE; } + public function buildForm(FormBuilderInterface $builder) + { + $builder + ->add('date_calc', ChillDateType::class, [ + 'label' => 'Address valid at this date', + 'required' => true, + 'data' => new DateTimeImmutable('today'), + 'input' => 'datetime_immutable', + ]) + ->add('level', EntityType::class, [ + 'label' => 'Geographical layer', + 'placeholder' => 'Select a geographical layer', + 'class' => GeographicalUnitLayer::class, + 'choices' => $this->geographicalUnitLayerRepository->findAllHavingUnits(), + 'choice_label' => function (GeographicalUnitLayer $item) { + return $this->translatableStringHelper->localize($item->getName()); + }, + ]); + } + public static function getDefaultAlias(): string { return 'person_geog_agg'; } + + public function getLabels($key, array $values, $data) + { + switch ($key) { + case 'geog_unit_name': + return static function ($value): string { + if ('_header' === $value) { + return 'acp_geog_agg_unitname'; + } + + if (null === $value) { + return ''; + } + + return $value; + }; + + case 'geog_unit_key': + return static function ($value): string { + if ('_header' === $value) { + return 'acp_geog_agg_unitrefid'; + } + + if (null === $value) { + return ''; + } + + return $value; + }; + + default: + throw new LogicException('key not supported'); + } + } + + public function getQueryKeys($data) + { + return ['geog_unit_name', 'geog_unit_key']; + } + + public function getTitle() + { + return 'Group people by geographical unit based on his address'; + } } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/HouseholdPositionAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/HouseholdPositionAggregator.php index 89c0bb8f5..1f902357e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/HouseholdPositionAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/HouseholdPositionAggregator.php @@ -24,6 +24,7 @@ use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Validator\Context\ExecutionContextInterface; use Symfony\Contracts\Translation\TranslatorInterface; +use function in_array; final class HouseholdPositionAggregator implements AggregatorInterface, ExportElementValidatedInterface { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/MaritalStatusAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/MaritalStatusAggregator.php index 2ed1752b0..333523487 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/MaritalStatusAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/MaritalStatusAggregator.php @@ -17,6 +17,7 @@ use Chill\PersonBundle\Export\Declarations; use Chill\PersonBundle\Repository\MaritalStatusRepository; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; +use function in_array; final class MaritalStatusAggregator implements AggregatorInterface { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregator.php index fc96b9e6b..38fd40071 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregator.php @@ -17,6 +17,7 @@ use Chill\PersonBundle\Repository\SocialWork\SocialActionRepository; use Chill\PersonBundle\Templating\Entity\SocialActionRender; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; +use function in_array; final class ActionTypeAggregator implements AggregatorInterface { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalAggregator.php index 0f418a678..353602db9 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalAggregator.php @@ -17,6 +17,7 @@ use Chill\PersonBundle\Export\Declarations; use Chill\PersonBundle\Repository\SocialWork\GoalRepository; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; +use function in_array; final class GoalAggregator implements AggregatorInterface { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalResultAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalResultAggregator.php index 48075c38b..97745f576 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalResultAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalResultAggregator.php @@ -1,5 +1,14 @@ translatableStringHelper = $translatableStringHelper; } - - /** - * @inheritDoc - */ - public function getLabels($key, array $values, $data) - { - return function ($value) use ($key): string { - if (null === $value) { - return ''; - } - - switch ($key) { - case 'goal_aggregator': - - if ('_header' === $value) { - return 'Goal Type'; - } - - $g = $this->goalRepository->find($value); - - return $this->translatableStringHelper->localize( - $g->getTitle() - ); - - case 'result_aggregator': - - if ('_header' === $value) { - return 'Result Type'; - } - - $r = $this->resultRepository->find($value); - - return $this->translatableStringHelper->localize( - $r->getTitle() - ); - - default: - throw new \LogicException(); - } - }; - } - - /** - * @inheritDoc - */ - public function getQueryKeys($data): array - { - return [ - 'goal_aggregator', - 'result_aggregator' - ]; - } - - /** - * @inheritDoc - */ - public function buildForm(FormBuilderInterface $builder) - { - // no form - } - - /** - * @inheritDoc - */ - public function getTitle(): string - { - return 'Group social work actions by goal and result'; - } - - /** - * @inheritDoc - */ public function addRole(): ?string { return null; } - /** - * @inheritDoc - */ public function alterQuery(QueryBuilder $qb, $data) { if (!in_array('goal', $qb->getAllAliases(), true)) { @@ -123,11 +59,62 @@ class GoalResultAggregator implements AggregatorInterface $qb->addGroupBy('goal_aggregator')->addGroupBy('result_aggregator'); } - /** - * @inheritDoc - */ public function applyOn(): string { return Declarations::SOCIAL_WORK_ACTION_TYPE; } + + public function buildForm(FormBuilderInterface $builder) + { + // no form + } + + public function getLabels($key, array $values, $data) + { + return function ($value) use ($key): string { + if (null === $value) { + return ''; + } + + switch ($key) { + case 'goal_aggregator': + if ('_header' === $value) { + return 'Goal Type'; + } + + $g = $this->goalRepository->find($value); + + return $this->translatableStringHelper->localize( + $g->getTitle() + ); + + case 'result_aggregator': + if ('_header' === $value) { + return 'Result Type'; + } + + $r = $this->resultRepository->find($value); + + return $this->translatableStringHelper->localize( + $r->getTitle() + ); + + default: + throw new LogicException(); + } + }; + } + + public function getQueryKeys($data): array + { + return [ + 'goal_aggregator', + 'result_aggregator', + ]; + } + + public function getTitle(): string + { + return 'Group social work actions by goal and result'; + } } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/JobAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/JobAggregator.php index ca2e36d97..c95f4bf50 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/JobAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/JobAggregator.php @@ -17,6 +17,7 @@ use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\PersonBundle\Export\Declarations; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; +use function in_array; final class JobAggregator implements AggregatorInterface { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ReferrerAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ReferrerAggregator.php index 46ef78035..33469f719 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ReferrerAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ReferrerAggregator.php @@ -17,6 +17,7 @@ use Chill\MainBundle\Templating\Entity\UserRender; use Chill\PersonBundle\Export\Declarations; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; +use function in_array; final class ReferrerAggregator implements AggregatorInterface { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ResultAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ResultAggregator.php index 4b190e0a5..215c51c3c 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ResultAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ResultAggregator.php @@ -17,6 +17,7 @@ use Chill\PersonBundle\Export\Declarations; use Chill\PersonBundle\Repository\SocialWork\ResultRepository; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; +use function in_array; final class ResultAggregator implements AggregatorInterface { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ScopeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ScopeAggregator.php index 1cf29d46f..9db70af91 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ScopeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ScopeAggregator.php @@ -17,6 +17,7 @@ use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\PersonBundle\Export\Declarations; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; +use function in_array; final class ScopeAggregator implements AggregatorInterface { diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php b/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php index 02682c3a9..f3995a335 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php @@ -101,14 +101,13 @@ class CountAccompanyingCourse implements ExportInterface, GroupedExportInterface $qb ->andWhere( $qb->expr()->exists( - 'SELECT 1 FROM '.AccompanyingPeriodParticipation::class.' acl_count_part - JOIN '.PersonCenterHistory::class.' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person) + 'SELECT 1 FROM ' . AccompanyingPeriodParticipation::class . ' acl_count_part + JOIN ' . PersonCenterHistory::class . ' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person) WHERE acl_count_part.accompanyingPeriod = acp.id AND acl_count_person_history.center IN (:authorized_centers) ' ) ) - ->setParameter('authorized_centers', $centers) - ; + ->setParameter('authorized_centers', $centers); $qb->select('COUNT(DISTINCT acp.id) AS export_result'); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php b/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php index 7ff5349f6..544734055 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php @@ -23,6 +23,7 @@ use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; use Doctrine\ORM\Query; use Symfony\Component\Form\FormBuilderInterface; +use function in_array; class CountEvaluation implements ExportInterface, GroupedExportInterface { @@ -107,14 +108,13 @@ class CountEvaluation implements ExportInterface, GroupedExportInterface $qb ->andWhere( $qb->expr()->exists( - 'SELECT 1 FROM '.AccompanyingPeriodParticipation::class.' acl_count_part - JOIN '.PersonCenterHistory::class.' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person) + 'SELECT 1 FROM ' . AccompanyingPeriodParticipation::class . ' acl_count_part + JOIN ' . PersonCenterHistory::class . ' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person) WHERE acl_count_part.accompanyingPeriod = acp.id AND acl_count_person_history.center IN (:authorized_centers) ' ) ) - ->setParameter('authorized_centers', $centers) - ; + ->setParameter('authorized_centers', $centers); $qb->select('COUNT(DISTINCT workeval.id) AS export_result'); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php b/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php index e1c7adf88..2b358634f 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php @@ -100,20 +100,18 @@ class CountHousehold implements ExportInterface, GroupedExportInterface ->join('acp.participations', 'acppart') // little optimization: we remove joins and make a direct join between participations and household members ->join(HouseholdMember::class, 'member', Query\Expr\Join::WITH, 'IDENTITY(acppart.person) = IDENTITY(member.person)') - ->join('member.household', 'household') - ; + ->join('member.household', 'household'); $qb ->andWhere( $qb->expr()->exists( - 'SELECT 1 FROM '.AccompanyingPeriodParticipation::class.' acl_count_part - JOIN '.PersonCenterHistory::class.' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person) + 'SELECT 1 FROM ' . AccompanyingPeriodParticipation::class . ' acl_count_part + JOIN ' . PersonCenterHistory::class . ' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person) WHERE acl_count_part.accompanyingPeriod = acp.id AND acl_count_person_history.center IN (:authorized_centers) ' ) ) - ->setParameter('authorized_centers', $centers) - ; + ->setParameter('authorized_centers', $centers); $qb->select('COUNT(DISTINCT household.id) AS export_result'); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountPerson.php b/src/Bundle/ChillPersonBundle/Export/Export/CountPerson.php index 3b2e47bdd..c411fad2e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountPerson.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountPerson.php @@ -18,7 +18,6 @@ use Chill\PersonBundle\Entity\Person\PersonCenterHistory; use Chill\PersonBundle\Export\Declarations; use Chill\PersonBundle\Repository\PersonRepository; use Chill\PersonBundle\Security\Authorization\PersonVoter; -use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Query; use Doctrine\ORM\QueryBuilder; use LogicException; @@ -104,10 +103,10 @@ class CountPerson implements ExportInterface, GroupedExportInterface $qb->select('COUNT(person.id) AS export_result') ->andWhere( $qb->expr()->exists( - 'SELECT 1 FROM '.PersonCenterHistory::class.' pch WHERE pch.person = person.id AND pch.center IN (:authorized_centers)' + 'SELECT 1 FROM ' . PersonCenterHistory::class . ' pch WHERE pch.person = person.id AND pch.center IN (:authorized_centers)' ) ) - ->setParameter('authorized_centers', $centers); + ->setParameter('authorized_centers', $centers); return $qb; } diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountPersonWithAccompanyingCourse.php b/src/Bundle/ChillPersonBundle/Export/Export/CountPersonWithAccompanyingCourse.php index fa28e2abe..df48fe7c6 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountPersonWithAccompanyingCourse.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountPersonWithAccompanyingCourse.php @@ -22,6 +22,7 @@ use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; use Doctrine\ORM\Query; use Symfony\Component\Form\FormBuilderInterface; +use function in_array; class CountPersonWithAccompanyingCourse implements ExportInterface, GroupedExportInterface { @@ -105,7 +106,7 @@ class CountPersonWithAccompanyingCourse implements ExportInterface, GroupedExpor $qb->andWhere( $qb->expr()->exists( - 'SELECT 1 FROM '.PersonCenterHistory::class.' pch WHERE pch.person = person.id AND pch.center IN (:authorized_centers)' + 'SELECT 1 FROM ' . PersonCenterHistory::class . ' pch WHERE pch.person = person.id AND pch.center IN (:authorized_centers)' ) )->setParameter('authorized_centers', $centers); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountSocialWorkActions.php b/src/Bundle/ChillPersonBundle/Export/Export/CountSocialWorkActions.php index 4ba071d3b..caf6cdbc2 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountSocialWorkActions.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountSocialWorkActions.php @@ -102,14 +102,13 @@ class CountSocialWorkActions implements ExportInterface, GroupedExportInterface $qb ->andWhere( $qb->expr()->exists( - 'SELECT 1 FROM '.AccompanyingPeriodParticipation::class.' acl_count_part - JOIN '.PersonCenterHistory::class.' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person) + 'SELECT 1 FROM ' . AccompanyingPeriodParticipation::class . ' acl_count_part + JOIN ' . PersonCenterHistory::class . ' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person) WHERE acl_count_part.accompanyingPeriod = acp.id AND acl_count_person_history.center IN (:authorized_centers) ' ) ) - ->setParameter('authorized_centers', $centers) - ; + ->setParameter('authorized_centers', $centers); $qb->select('COUNT(DISTINCT acpw.id) as export_result'); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListPersonDuplicate.php b/src/Bundle/ChillPersonBundle/Export/Export/ListPersonDuplicate.php index 75d757f9e..543be933c 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListPersonDuplicate.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListPersonDuplicate.php @@ -24,7 +24,6 @@ use Symfony\Component\HttpFoundation\BinaryFileResponse; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\ResponseHeaderBag; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; -use Symfony\Component\Security\Core\Role\Role; use Symfony\Component\Validator\Context\ExecutionContextInterface; use Symfony\Contracts\Translation\TranslatorInterface; diff --git a/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php b/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php index 3b2036797..f59be8399 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php @@ -105,14 +105,13 @@ class StatAccompanyingCourseDuration implements ExportInterface, GroupedExportIn $qb ->andWhere( $qb->expr()->exists( - 'SELECT 1 FROM '.AccompanyingPeriodParticipation::class.' acl_count_part - JOIN '.PersonCenterHistory::class.' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person) + 'SELECT 1 FROM ' . AccompanyingPeriodParticipation::class . ' acl_count_part + JOIN ' . PersonCenterHistory::class . ' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person) WHERE acl_count_part.accompanyingPeriod = acp.id AND acl_count_person_history.center IN (:authorized_centers) ' ) ) - ->setParameter('authorized_centers', $centers) - ; + ->setParameter('authorized_centers', $centers); $qb ->select('AVG( diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOneDayBetweenDatesFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOneDayBetweenDatesFilter.php index ae9535a67..3ec26183c 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOneDayBetweenDatesFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOneDayBetweenDatesFilter.php @@ -16,7 +16,6 @@ use Chill\MainBundle\Form\Type\ChillDateType; use Chill\PersonBundle\Export\Declarations; use DateTime; use Doctrine\DBAL\Types\Types; -use Doctrine\ORM\Query\Expr\Andx; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CurrentUserScopeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CurrentUserScopeFilter.php index 569146614..8e164d668 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CurrentUserScopeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CurrentUserScopeFilter.php @@ -20,6 +20,7 @@ use Doctrine\ORM\Query\Expr\Andx; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Security\Core\Security; +use function in_array; class CurrentUserScopeFilter implements FilterInterface { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EvaluationFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EvaluationFilter.php index c04d5bcd0..3b95261db 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EvaluationFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EvaluationFilter.php @@ -19,6 +19,7 @@ use Doctrine\ORM\Query\Expr\Andx; use Doctrine\ORM\QueryBuilder; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\FormBuilderInterface; +use function in_array; class EvaluationFilter implements FilterInterface { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php index 5b2478f19..f720896c4 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php @@ -20,27 +20,23 @@ use Chill\MainBundle\Templating\TranslatableStringHelperInterface; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\Household\PersonHouseholdAddress; use Chill\PersonBundle\Export\Declarations; -use DateTime; -use Doctrine\DBAL\Types\Types; +use DateTimeImmutable; use Doctrine\ORM\EntityManagerInterface; -use Doctrine\ORM\Query\Expr; -use Doctrine\ORM\Query\Expr\Andx; use Doctrine\ORM\QueryBuilder; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\FormBuilderInterface; /** - * Filter accompanying period by geographical zone + * Filter accompanying period by geographical zone. */ class GeographicalUnitStatFilter implements FilterInterface { + private EntityManagerInterface $em; private GeographicalUnitRepositoryInterface $geographicalUnitRepository; private TranslatableStringHelperInterface $translatableStringHelper; - private EntityManagerInterface $em; - public function __construct( EntityManagerInterface $em, GeographicalUnitRepositoryInterface $geographicalUnitRepository, @@ -61,12 +57,12 @@ class GeographicalUnitStatFilter implements FilterInterface $subQueryDql = 'SELECT 1 - FROM '.AccompanyingPeriod\AccompanyingPeriodLocationHistory::class.' acp_geog_filter_location_history - LEFT JOIN '.PersonHouseholdAddress::class.' acp_geog_filter_address_person_location + FROM ' . AccompanyingPeriod\AccompanyingPeriodLocationHistory::class . ' acp_geog_filter_location_history + LEFT JOIN ' . PersonHouseholdAddress::class . ' acp_geog_filter_address_person_location WITH IDENTITY(acp_geog_filter_location_history.personLocation) = IDENTITY(acp_geog_filter_address_person_location.person) - LEFT JOIN '.Address::class.' acp_geog_filter_address + LEFT JOIN ' . Address::class . ' acp_geog_filter_address WITH COALESCE(IDENTITY(acp_geog_filter_address_person_location.address), IDENTITY(acp_geog_filter_location_history.addressLocation)) = acp_geog_filter_address.id - LEFT JOIN '.GeographicalUnit::class.' acp_geog_filter_units WITH ST_CONTAINS(acp_geog_units.geom, acp_geog_filter_address.point) = TRUE + LEFT JOIN ' . GeographicalUnit::class . ' acp_geog_filter_units WITH ST_CONTAINS(acp_geog_units.geom, acp_geog_filter_address.point) = TRUE WHERE (acp_geog_filter_location_history.startDate <= :acp_geog_filter_date AND ( acp_geog_filter_location_history.endDate IS NULL OR acp_geog_filter_location_history.endDate < :acp_geog_filter_date @@ -82,8 +78,7 @@ class GeographicalUnitStatFilter implements FilterInterface $qb ->andWhere($qb->expr()->exists($subQueryDql)) ->setParameter('acp_geog_filter_date', $data['date_calc']) - ->setParameter('acp_geog_filter_units', $data['units']) - ; + ->setParameter('acp_geog_filter_units', $data['units']); } public function applyOn(): string @@ -97,7 +92,7 @@ class GeographicalUnitStatFilter implements FilterInterface ->add('date_calc', ChillDateType::class, [ 'label' => 'Compute geographical location at date', 'required' => true, - 'data' => new \DateTimeImmutable('today'), + 'data' => new DateTimeImmutable('today'), 'input' => 'datetime_immutable', ]) ->add('units', EntityType::class, [ @@ -105,7 +100,7 @@ class GeographicalUnitStatFilter implements FilterInterface 'placeholder' => 'Select a geographical unit', 'class' => GeographicalUnit::class, 'choices' => $this->geographicalUnitRepository->findAll(), - 'choice_label' => function(GeographicalUnit $item) { + 'choice_label' => function (GeographicalUnit $item) { return $this->translatableStringHelper->localize($item->getLayer()->getName()) . ' > ' . $item->getUnitName(); }, 'attr' => [ @@ -122,12 +117,12 @@ class GeographicalUnitStatFilter implements FilterInterface '%units' => implode( ', ', array_map( - function(GeographicalUnit $item) { + function (GeographicalUnit $item) { return $this->translatableStringHelper->localize($item->getLayer()->getName()) . ' > ' . $item->getUnitName(); }, $data['units'] ) - ) + ), ]]; } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OpenBetweenDatesFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OpenBetweenDatesFilter.php index b47f2020d..814819a57 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OpenBetweenDatesFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OpenBetweenDatesFilter.php @@ -16,7 +16,6 @@ use Chill\MainBundle\Form\Type\ChillDateType; use Chill\PersonBundle\Export\Declarations; use DateTime; use Doctrine\DBAL\Types\Types; -use Doctrine\ORM\Query\Expr\Andx; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/RequestorFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/RequestorFilter.php index e81cf3114..299dbafb6 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/RequestorFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/RequestorFilter.php @@ -20,6 +20,7 @@ use Exception; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Contracts\Translation\TranslatorInterface; +use function in_array; final class RequestorFilter implements FilterInterface { @@ -55,7 +56,6 @@ final class RequestorFilter implements FilterInterface switch ($data['accepted_choices']) { case 'participation': - if (!in_array('acppart', $qb->getAllAliases(), true)) { $qb->join('acp.participations', 'acppart'); } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php index ad232d7c2..598652ff8 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php @@ -21,6 +21,7 @@ use Doctrine\ORM\QueryBuilder; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Contracts\Translation\TranslatorInterface; +use function in_array; class SocialIssueFilter implements FilterInterface { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/HouseholdFilters/CompositionFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/HouseholdFilters/CompositionFilter.php index 1ca78d669..94b55b67c 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/HouseholdFilters/CompositionFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/HouseholdFilters/CompositionFilter.php @@ -19,7 +19,6 @@ use Chill\PersonBundle\Export\Declarations; use DateTime; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Query\Expr; -use Doctrine\ORM\Query\Expr\Andx; use Doctrine\ORM\QueryBuilder; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\FormBuilderInterface; diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AgeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AgeFilter.php index eb83f3ff0..394ccddcb 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AgeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AgeFilter.php @@ -15,7 +15,8 @@ use Chill\MainBundle\Export\ExportElementValidatedInterface; use Chill\MainBundle\Export\FilterInterface; use Chill\MainBundle\Form\Type\ChillDateType; use Chill\PersonBundle\Export\Declarations; -use DateTime; +use DateInterval; +use DateTimeImmutable; use Doctrine\ORM\Query\Expr; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\Extension\Core\Type\IntegerType; @@ -37,8 +38,8 @@ class AgeFilter implements ExportElementValidatedInterface, FilterInterface $max = null !== $data['max_age'] ? $data['max_age'] : 3000; $calc = $data['date_calc']; - $minDate = $calc->sub(new \DateInterval('P' . $max . 'Y')); - $maxDate = $calc->sub(new \DateInterval('P' . $min . 'Y')); + $minDate = $calc->sub(new DateInterval('P' . $max . 'Y')); + $maxDate = $calc->sub(new DateInterval('P' . $min . 'Y')); $clause = $qb->expr()->andX( $qb->expr()->gte( @@ -79,8 +80,8 @@ class AgeFilter implements ExportElementValidatedInterface, FilterInterface $builder->add('date_calc', ChillDateType::class, [ 'label' => 'Calculate age in relation to this date', - 'data' => new \DateTimeImmutable('now'), - 'input' => 'datetime_immutable' + 'data' => new DateTimeImmutable('now'), + 'input' => 'datetime_immutable', ]); } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/DeadOrAliveFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/DeadOrAliveFilter.php index a161df44f..e069af849 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/DeadOrAliveFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/DeadOrAliveFilter.php @@ -39,9 +39,9 @@ class DeadOrAliveFilter implements FilterInterface $qb->expr()->andX( $qb->expr()->isNull('person.deathdate'), $qb->expr()->lte( - 'person.birthdate', - ':date_calc' - ) + 'person.birthdate', + ':date_calc' + ) ), $qb->expr()->andX( $qb->expr()->isNotNull('person.deathdate'), diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GeographicalUnitFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GeographicalUnitFilter.php index e95aff798..7463c36a9 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GeographicalUnitFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GeographicalUnitFilter.php @@ -1,15 +1,23 @@ translatableStringHelper = $translatableStringHelper; } - /** - * @inheritDoc - */ - public function buildForm(FormBuilderInterface $builder) - { - $builder - ->add('date_calc', ChillDateType::class, [ - 'label' => 'Compute geographical location at date', - 'required' => true, - 'data' => new \DateTimeImmutable('today'), - 'input' => 'datetime_immutable', - ]) - ->add('units', EntityType::class, [ - 'label' => 'Geographical unit', - 'placeholder' => 'Select a geographical unit', - 'class' => GeographicalUnit::class, - 'choices' => $this->geographicalUnitRepository->findAll(), - 'choice_label' => function(GeographicalUnit $item) { - return $this->translatableStringHelper->localize($item->getLayer()->getName()) . ' > ' . $item->getUnitName(); - }, - 'attr' => [ - 'class' => 'select2', - ], - 'multiple' => true, - ]); - } - - /** - * @inheritDoc - */ - public function getTitle(): string - { - return 'Filter by person\'s geographical unit (based on address)'; - } - - /** - * @inheritDoc - */ - public function describeAction($data, $format = 'string') - { - return [ - 'exports.by_person.Filtered by person\'s geographical unit (based on address) computed at datecalc, only units', - [ - 'datecalc' => $data['date_calc']->format('Y-m-d'), - 'units' => implode( - ', ', - array_map( - function (GeographicalUnit $item) { - return $this->translatableStringHelper->localize($item->getLayer()->getName()) . ' > ' . $item->getUnitName(); - }, - $data['units']->toArray() - ) - ) - ] - ]; - } - - /** - * @inheritDoc - */ public function addRole(): ?string { return null; } - /** - * @inheritDoc - */ public function alterQuery(QueryBuilder $qb, $data) { $subQuery = 'SELECT 1 - FROM '.PersonHouseholdAddress::class.' person_filter_geog_person_household_address + FROM ' . PersonHouseholdAddress::class . ' person_filter_geog_person_household_address JOIN person_filter_geog_person_household_address.address person_filter_geog_address - JOIN '.GeographicalUnit::class.' person_filter_geog_unit + JOIN ' . GeographicalUnit::class . ' person_filter_geog_unit WITH ST_CONTAINS(person_filter_geog_unit.geom, person_filter_geog_address.point) = TRUE WHERE person_filter_geog_person_household_address.validFrom <= :person_filter_geog_date @@ -120,15 +65,59 @@ class GeographicalUnitFilter implements \Chill\MainBundle\Export\FilterInterface $qb->expr()->exists($subQuery) ) ->setParameter('person_filter_geog_date', $data['date_calc']) - ->setParameter('person_filter_geog_units', $data['units']) - ; + ->setParameter('person_filter_geog_units', $data['units']); } - /** - * @inheritDoc - */ public function applyOn() { return Declarations::PERSON_TYPE; } + + public function buildForm(FormBuilderInterface $builder) + { + $builder + ->add('date_calc', ChillDateType::class, [ + 'label' => 'Compute geographical location at date', + 'required' => true, + 'data' => new DateTimeImmutable('today'), + 'input' => 'datetime_immutable', + ]) + ->add('units', EntityType::class, [ + 'label' => 'Geographical unit', + 'placeholder' => 'Select a geographical unit', + 'class' => GeographicalUnit::class, + 'choices' => $this->geographicalUnitRepository->findAll(), + 'choice_label' => function (GeographicalUnit $item) { + return $this->translatableStringHelper->localize($item->getLayer()->getName()) . ' > ' . $item->getUnitName(); + }, + 'attr' => [ + 'class' => 'select2', + ], + 'multiple' => true, + ]); + } + + public function describeAction($data, $format = 'string') + { + return [ + 'exports.by_person.Filtered by person\'s geographical unit (based on address) computed at datecalc, only units', + [ + 'datecalc' => $data['date_calc']->format('Y-m-d'), + 'units' => implode( + ', ', + array_map( + function (GeographicalUnit $item) { + return $this->translatableStringHelper->localize($item->getLayer()->getName()) . ' > ' . $item->getUnitName(); + }, + $data['units']->toArray() + ) + ), + ], + ]; + } + + public function getTitle(): string + { + return 'Filter by person\'s geographical unit (based on address)'; + } } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/MaritalStatusFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/MaritalStatusFilter.php index a7c637bda..5d136c0e6 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/MaritalStatusFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/MaritalStatusFilter.php @@ -11,18 +11,14 @@ declare(strict_types=1); namespace Chill\PersonBundle\Export\Filter\PersonFilters; -use Chill\MainBundle\Entity\UserJob; use Chill\MainBundle\Export\FilterInterface; use Chill\MainBundle\Form\Type\ChillDateType; use Chill\MainBundle\Templating\TranslatableStringHelper; -use Chill\PersonBundle\Entity\Household\HouseholdCompositionType; use Chill\PersonBundle\Entity\MaritalStatus; use Chill\PersonBundle\Export\Declarations; use DateTime; use Doctrine\ORM\Query\Expr\Andx; use Symfony\Bridge\Doctrine\Form\Type\EntityType; -use Symfony\Component\Form\Extension\Core\Type\DateType; -use Symfony\Contracts\Translation\TranslatorInterface; class MaritalStatusFilter implements FilterInterface { @@ -77,7 +73,7 @@ class MaritalStatusFilter implements FilterInterface ); }, 'multiple' => true, - 'expanded' => true + 'expanded' => true, ]); $builder->add('calc_date', ChillDateType::class, [ diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php index 2770ae82f..ce632ddd0 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php @@ -22,6 +22,7 @@ use Doctrine\ORM\Query\Expr; use Doctrine\ORM\QueryBuilder; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\FormBuilderInterface; +use function in_array; class ResidentialAddressAtThirdpartyFilter implements FilterInterface { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtUserFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtUserFilter.php index 7c07121e1..53e9de406 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtUserFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtUserFilter.php @@ -15,9 +15,11 @@ use Chill\MainBundle\Export\FilterInterface; use Chill\MainBundle\Form\Type\ChillDateType; use Chill\PersonBundle\Entity\Person\ResidentialAddress; use Chill\PersonBundle\Export\Declarations; +use DateTime; use Doctrine\ORM\Query\Expr; use Doctrine\ORM\Query\Expr\Andx; use Doctrine\ORM\QueryBuilder; +use function in_array; class ResidentialAddressAtUserFilter implements FilterInterface { @@ -68,7 +70,7 @@ class ResidentialAddressAtUserFilter implements FilterInterface { $builder->add('date_calc', ChillDateType::class, [ 'label' => 'Date during which residential address was valid', - 'data' => new \DateTime('now'), + 'data' => new DateTime('now'), ]); } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/JobFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/JobFilter.php index a93dae54d..f43cc458a 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/JobFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/JobFilter.php @@ -20,6 +20,7 @@ use Doctrine\ORM\QueryBuilder; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Contracts\Translation\TranslatorInterface; +use function in_array; class JobFilter implements FilterInterface { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ReferrerFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ReferrerFilter.php index e1ddd70fd..a52b9e177 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ReferrerFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ReferrerFilter.php @@ -19,6 +19,7 @@ use Doctrine\ORM\Query\Expr\Andx; use Doctrine\ORM\QueryBuilder; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\FormBuilderInterface; +use function in_array; class ReferrerFilter implements FilterInterface { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ScopeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ScopeFilter.php index ae525a4e5..6efaf9989 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ScopeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ScopeFilter.php @@ -20,6 +20,7 @@ use Doctrine\ORM\QueryBuilder; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Contracts\Translation\TranslatorInterface; +use function in_array; class ScopeFilter implements FilterInterface { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/SocialWorkTypeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/SocialWorkTypeFilter.php index 0cf7f979d..41125cfe1 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/SocialWorkTypeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/SocialWorkTypeFilter.php @@ -13,121 +13,38 @@ namespace Chill\PersonBundle\Export\Filter\SocialWorkFilters; use Chill\MainBundle\Export\FilterInterface; use Chill\MainBundle\Templating\TranslatableStringHelper; -use Chill\PersonBundle\Entity\SocialWork\SocialAction; use Chill\PersonBundle\Entity\SocialWork\Goal; use Chill\PersonBundle\Entity\SocialWork\Result; +use Chill\PersonBundle\Entity\SocialWork\SocialAction; use Chill\PersonBundle\Export\Declarations; +use Chill\PersonBundle\Templating\Entity\SocialActionRender; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Query\Expr\Andx; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\CallbackTransformer; use Symfony\Component\Form\Extension\Core\Type\HiddenType; use Symfony\Component\Form\FormBuilderInterface; -use Chill\PersonBundle\Templating\Entity\SocialActionRender; +use function count; +use function in_array; class SocialWorkTypeFilter implements FilterInterface { + private EntityManagerInterface $em; + private SocialActionRender $socialActionRender; private TranslatableStringHelper $translatableStringHelper; - private EntityManagerInterface $em; - - public function __construct - ( + public function __construct( SocialActionRender $socialActionRender, TranslatableStringHelper $translatableStringHelper, EntityManagerInterface $em - ) - { + ) { $this->socialActionRender = $socialActionRender; $this->translatableStringHelper = $translatableStringHelper; $this->em = $em; } - public function buildForm(FormBuilderInterface $builder) - { - $builder - ->add('actionType', HiddenType::class) - ->get('actionType') - ->addModelTransformer( - $this->iterableToIdTransformer(SocialAction::class) - ) - ; - $builder - ->add('goal', HiddenType::class) - ->get('goal') - ->addModelTransformer( - $this->iterableToIdTransformer(Goal::class) - ) - ; - $builder - ->add('result', HiddenType::class) - ->get('result') - ->addModelTransformer( - $this->iterableToIdTransformer(Result::class) - ) - ; - } - - private function iterableToIdTransformer(string $entity): CallbackTransformer - { - return new CallbackTransformer( - static function (?iterable $asIterable): string { - if (null === $asIterable) { return ''; } - $ids = []; - foreach ($asIterable as $value) { - $ids[] = $value->getId(); - } - return implode(',', $ids); - }, - function (?string $asString) use ($entity): array { - if (null === $asString) { return []; } - return array_map( - fn (string $id) - => $this->em - ->getRepository($entity) - ->findOneBy(['id' => (int) $id]), - explode(',', $asString) - ); - } - ); - } - - public function getTitle(): string - { - return 'Filter by type of action, goals and results'; - } - - public function describeAction($data, $format = 'string'): array - { - $actionTypes = []; - $goals = []; - $results = []; - - foreach ($data['actionType'] as $at) { - $actionTypes[] = $this->translatableStringHelper->localize( - $at->getTitle() - ); - } - - foreach ($data['goal'] as $g) { - $goals[] = $this->translatableStringHelper->localize( - $g->getTitle() - ); - } - - foreach ($data['result'] as $r) { - $results[] = $this->translatableStringHelper->localize( - $r->getTitle() - ); - } - - return ['Filtered actions by type, goals and results: %selected%', [ - '%selected%' => implode(', ', array_merge($actionTypes, $goals, $results)) - ]]; - } - public function addRole(): ?string { return null; @@ -180,4 +97,90 @@ class SocialWorkTypeFilter implements FilterInterface { return Declarations::SOCIAL_WORK_ACTION_TYPE; } + + public function buildForm(FormBuilderInterface $builder) + { + $builder + ->add('actionType', HiddenType::class) + ->get('actionType') + ->addModelTransformer( + $this->iterableToIdTransformer(SocialAction::class) + ); + $builder + ->add('goal', HiddenType::class) + ->get('goal') + ->addModelTransformer( + $this->iterableToIdTransformer(Goal::class) + ); + $builder + ->add('result', HiddenType::class) + ->get('result') + ->addModelTransformer( + $this->iterableToIdTransformer(Result::class) + ); + } + + public function describeAction($data, $format = 'string'): array + { + $actionTypes = []; + $goals = []; + $results = []; + + foreach ($data['actionType'] as $at) { + $actionTypes[] = $this->translatableStringHelper->localize( + $at->getTitle() + ); + } + + foreach ($data['goal'] as $g) { + $goals[] = $this->translatableStringHelper->localize( + $g->getTitle() + ); + } + + foreach ($data['result'] as $r) { + $results[] = $this->translatableStringHelper->localize( + $r->getTitle() + ); + } + + return ['Filtered actions by type, goals and results: %selected%', [ + '%selected%' => implode(', ', array_merge($actionTypes, $goals, $results)), + ]]; + } + + public function getTitle(): string + { + return 'Filter by type of action, goals and results'; + } + + private function iterableToIdTransformer(string $entity): CallbackTransformer + { + return new CallbackTransformer( + static function (?iterable $asIterable): string { + if (null === $asIterable) { + return ''; + } + $ids = []; + + foreach ($asIterable as $value) { + $ids[] = $value->getId(); + } + + return implode(',', $ids); + }, + function (?string $asString) use ($entity): array { + if (null === $asString) { + return []; + } + + return array_map( + fn (string $id) => $this->em + ->getRepository($entity) + ->findOneBy(['id' => (int) $id]), + explode(',', $asString) + ); + } + ); + } } diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/ClosingMotiveRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/ClosingMotiveRepository.php index 283dac151..5cf394df6 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/ClosingMotiveRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/ClosingMotiveRepository.php @@ -15,7 +15,6 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; use Doctrine\ORM\Query\ResultSetMappingBuilder; -use UnexpectedValueException; final class ClosingMotiveRepository implements ClosingMotiveRepositoryInterface { @@ -29,6 +28,32 @@ final class ClosingMotiveRepository implements ClosingMotiveRepositoryInterface $this->repository = $entityManager->getRepository(ClosingMotive::class); } + public function find($id): ?ClosingMotive + { + return $this->repository->find($id); + } + + /** + * @return array|ClosingMotive[] + */ + public function findAll(): array + { + return $this->repository->findAll(); + } + + /** + * @return array|ClosingMotive[] + */ + public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array + { + return $this->repository->findBy($criteria, $orderBy, $limit, $offset); + } + + public function findOneBy(array $criteria): ?ClosingMotive + { + return $this->findOneBy($criteria); + } + /** * @return mixed */ @@ -56,32 +81,6 @@ final class ClosingMotiveRepository implements ClosingMotiveRepositoryInterface ->getResult(); } - public function find($id): ?ClosingMotive - { - return $this->repository->find($id); - } - - /** - * @return array|ClosingMotive[] - */ - public function findAll(): array - { - return $this->repository->findAll(); - } - - /** - * @return array|ClosingMotive[] - */ - public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array - { - return $this->repository->findBy($criteria, $orderBy, $limit, $offset); - } - - public function findOneBy(array $criteria): ?ClosingMotive - { - return $this->findOneBy($criteria); - } - public function getClassName(): string { return ClosingMotive::class; diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/ClosingMotiveRepositoryInterface.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/ClosingMotiveRepositoryInterface.php index fbea29a0b..73bc3ff5d 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/ClosingMotiveRepositoryInterface.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/ClosingMotiveRepositoryInterface.php @@ -1,5 +1,14 @@ build(); } - public function getRolesWithHierarchy(): array - { - return [ 'Person' => $this->getRoles() ]; - } - public function getRoles(): array { return [self::STATS]; } + public function getRolesWithHierarchy(): array + { + return ['Person' => $this->getRoles()]; + } + public function getRolesWithoutScope(): array { return $this->getRoles(); @@ -72,8 +72,7 @@ class HouseholdVoter extends Voter implements ProvideRoleHierarchyInterface { return ($subject instanceof Household && in_array($attribute, self::ALL, true)) - || $this->helper->supports($attribute, $subject) - ; + || $this->helper->supports($attribute, $subject); } protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/AdministrativeLocationAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/AdministrativeLocationAggregatorTest.php index 82a879b19..84487b0b6 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/AdministrativeLocationAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/AdministrativeLocationAggregatorTest.php @@ -11,11 +11,15 @@ declare(strict_types=1); namespace Chill\PersonBundle\Tests\Export\Aggregator\AccompanyingCourseAggregators; -use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; +use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\AdministrativeLocationAggregator; use Doctrine\ORM\EntityManagerInterface; +/** + * @internal + * @coversNothing + */ final class AdministrativeLocationAggregatorTest extends AbstractAggregatorTest { private AdministrativeLocationAggregator $aggregator; @@ -51,8 +55,7 @@ final class AdministrativeLocationAggregatorTest extends AbstractAggregatorTest $em->createQueryBuilder() ->select('count(acp.id)') ->from(AccompanyingPeriod::class, 'acp') - ->join('acp.administrativeLocation', 'acploc') - , + ->join('acp.administrativeLocation', 'acploc'), ]; } } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregatorTest.php index 279b621d4..2aa4e3e3e 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregatorTest.php @@ -11,11 +11,15 @@ declare(strict_types=1); namespace Chill\PersonBundle\Tests\Export\Aggregator\AccompanyingCourseAggregators; -use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; +use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\ClosingMotiveAggregator; use Doctrine\ORM\EntityManagerInterface; +/** + * @internal + * @coversNothing + */ final class ClosingMotiveAggregatorTest extends AbstractAggregatorTest { private ClosingMotiveAggregator $aggregator; @@ -51,8 +55,7 @@ final class ClosingMotiveAggregatorTest extends AbstractAggregatorTest $em->createQueryBuilder() ->select('count(acp.id)') ->from(AccompanyingPeriod::class, 'acp') - ->join('acp.closingMotive', 'acpmotive') - , + ->join('acp.closingMotive', 'acpmotive'), ]; } } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ConfidentialAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ConfidentialAggregatorTest.php index ab0e3dae3..a96b14d28 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ConfidentialAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ConfidentialAggregatorTest.php @@ -11,11 +11,15 @@ declare(strict_types=1); namespace Chill\PersonBundle\Tests\Export\Aggregator\AccompanyingCourseAggregators; -use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; +use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\ConfidentialAggregator; use Doctrine\ORM\EntityManagerInterface; +/** + * @internal + * @coversNothing + */ final class ConfidentialAggregatorTest extends AbstractAggregatorTest { private ConfidentialAggregator $aggregator; @@ -50,8 +54,7 @@ final class ConfidentialAggregatorTest extends AbstractAggregatorTest return [ $em->createQueryBuilder() ->select('count(acp.id)') - ->from(AccompanyingPeriod::class, 'acp') - , + ->from(AccompanyingPeriod::class, 'acp'), ]; } } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/DurationAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/DurationAggregatorTest.php index 056c396e0..616ee83c5 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/DurationAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/DurationAggregatorTest.php @@ -11,11 +11,15 @@ declare(strict_types=1); namespace Chill\PersonBundle\Tests\Export\Aggregator\AccompanyingCourseAggregators; -use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; +use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\DurationAggregator; use Doctrine\ORM\EntityManagerInterface; +/** + * @internal + * @coversNothing + */ final class DurationAggregatorTest extends AbstractAggregatorTest { private DurationAggregator $aggregator; @@ -50,8 +54,7 @@ final class DurationAggregatorTest extends AbstractAggregatorTest return [ $em->createQueryBuilder() ->select('count(acp.id)') - ->from(AccompanyingPeriod::class, 'acp') - , + ->from(AccompanyingPeriod::class, 'acp'), ]; } } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/EmergencyAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/EmergencyAggregatorTest.php index 0b8ff2b12..c4a2fc74e 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/EmergencyAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/EmergencyAggregatorTest.php @@ -11,11 +11,15 @@ declare(strict_types=1); namespace Chill\PersonBundle\Tests\Export\Aggregator\AccompanyingCourseAggregators; -use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; +use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\EmergencyAggregator; use Doctrine\ORM\EntityManagerInterface; +/** + * @internal + * @coversNothing + */ final class EmergencyAggregatorTest extends AbstractAggregatorTest { private EmergencyAggregator $aggregator; @@ -50,8 +54,7 @@ final class EmergencyAggregatorTest extends AbstractAggregatorTest return [ $em->createQueryBuilder() ->select('count(acp.id)') - ->from(AccompanyingPeriod::class, 'acp') - , + ->from(AccompanyingPeriod::class, 'acp'), ]; } } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/EvaluationAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/EvaluationAggregatorTest.php index 8c67eb649..cd5b1f4c7 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/EvaluationAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/EvaluationAggregatorTest.php @@ -11,11 +11,15 @@ declare(strict_types=1); namespace Chill\PersonBundle\Tests\Export\Aggregator\AccompanyingCourseAggregators; -use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; +use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\EvaluationAggregator; use Doctrine\ORM\EntityManagerInterface; +/** + * @internal + * @coversNothing + */ final class EvaluationAggregatorTest extends AbstractAggregatorTest { private EvaluationAggregator $aggregator; @@ -52,8 +56,7 @@ final class EvaluationAggregatorTest extends AbstractAggregatorTest ->select('count(acp.id)') ->from(AccompanyingPeriod::class, 'acp') ->join('acp.works', 'acpw') - ->join('acpw.accompanyingPeriodWorkEvaluations', 'workeval') - , + ->join('acpw.accompanyingPeriodWorkEvaluations', 'workeval'), ]; } } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregatorTest.php index 84204e629..8808961bf 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregatorTest.php @@ -11,11 +11,15 @@ declare(strict_types=1); namespace Chill\PersonBundle\Tests\Export\Aggregator\AccompanyingCourseAggregators; -use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; +use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\GeographicalUnitStatAggregator; use Doctrine\ORM\EntityManagerInterface; +/** + * @internal + * @coversNothing + */ final class GeographicalUnitStatAggregatorTest extends AbstractAggregatorTest { private GeographicalUnitStatAggregator $aggregator; @@ -50,8 +54,7 @@ final class GeographicalUnitStatAggregatorTest extends AbstractAggregatorTest return [ $em->createQueryBuilder() ->select('count(acp.id)') - ->from(AccompanyingPeriod::class, 'acp') - , + ->from(AccompanyingPeriod::class, 'acp'), ]; } } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/IntensityAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/IntensityAggregatorTest.php index b3da8ea13..e4c976cc9 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/IntensityAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/IntensityAggregatorTest.php @@ -11,11 +11,15 @@ declare(strict_types=1); namespace Chill\PersonBundle\Tests\Export\Aggregator\AccompanyingCourseAggregators; -use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; +use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\IntensityAggregator; use Doctrine\ORM\EntityManagerInterface; +/** + * @internal + * @coversNothing + */ final class IntensityAggregatorTest extends AbstractAggregatorTest { private IntensityAggregator $aggregator; @@ -50,8 +54,7 @@ final class IntensityAggregatorTest extends AbstractAggregatorTest return [ $em->createQueryBuilder() ->select('count(acp.id)') - ->from(AccompanyingPeriod::class, 'acp') - , + ->from(AccompanyingPeriod::class, 'acp'), ]; } } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/JobAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/JobAggregatorTest.php index 8e14ffe4c..f1b980640 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/JobAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/JobAggregatorTest.php @@ -11,11 +11,15 @@ declare(strict_types=1); namespace Chill\PersonBundle\Tests\Export\Aggregator\AccompanyingCourseAggregators; -use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; +use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\JobAggregator; use Doctrine\ORM\EntityManagerInterface; +/** + * @internal + * @coversNothing + */ final class JobAggregatorTest extends AbstractAggregatorTest { private JobAggregator $aggregator; @@ -51,8 +55,7 @@ final class JobAggregatorTest extends AbstractAggregatorTest $em->createQueryBuilder() ->select('count(acp.id)') ->from(AccompanyingPeriod::class, 'acp') - ->join('acp.job', 'acpjob') - , + ->join('acp.job', 'acpjob'), ]; } } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/OriginAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/OriginAggregatorTest.php index cdd709226..a2126c47c 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/OriginAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/OriginAggregatorTest.php @@ -11,11 +11,15 @@ declare(strict_types=1); namespace Chill\PersonBundle\Tests\Export\Aggregator\AccompanyingCourseAggregators; -use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; +use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\OriginAggregator; use Doctrine\ORM\EntityManagerInterface; +/** + * @internal + * @coversNothing + */ final class OriginAggregatorTest extends AbstractAggregatorTest { private OriginAggregator $aggregator; @@ -51,8 +55,7 @@ final class OriginAggregatorTest extends AbstractAggregatorTest $em->createQueryBuilder() ->select('count(acp.id)') ->from(AccompanyingPeriod::class, 'acp') - ->join('acp.origin', 'acporigin') - , + ->join('acp.origin', 'acporigin'), ]; } } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ReferrerAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ReferrerAggregatorTest.php index 789baa228..c5c04374f 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ReferrerAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ReferrerAggregatorTest.php @@ -11,11 +11,15 @@ declare(strict_types=1); namespace Chill\PersonBundle\Tests\Export\Aggregator\AccompanyingCourseAggregators; -use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; +use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\ReferrerAggregator; use Doctrine\ORM\EntityManagerInterface; +/** + * @internal + * @coversNothing + */ final class ReferrerAggregatorTest extends AbstractAggregatorTest { private ReferrerAggregator $aggregator; @@ -51,8 +55,7 @@ final class ReferrerAggregatorTest extends AbstractAggregatorTest $em->createQueryBuilder() ->select('count(acp.id)') ->from(AccompanyingPeriod::class, 'acp') - ->join('acp.user', 'acpuser') - , + ->join('acp.user', 'acpuser'), ]; } } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ReferrerScopeAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ReferrerScopeAggregatorTest.php index 6069a024d..f91fedad9 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ReferrerScopeAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ReferrerScopeAggregatorTest.php @@ -1,19 +1,32 @@ new \DateTimeImmutable('now') - ] + 'date_calc' => new DateTimeImmutable('now'), + ], ]; } @@ -54,10 +67,7 @@ class ReferrerScopeAggregatorTest extends AbstractAggregatorTest $em->createQueryBuilder() ->select('count(acp.id)') ->from(AccompanyingPeriod::class, 'acp') - ->join('acp.scopes', 'acpscope') - , + ->join('acp.scopes', 'acpscope'), ]; } - - } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/RequestorAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/RequestorAggregatorTest.php index f888e2535..84924e262 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/RequestorAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/RequestorAggregatorTest.php @@ -11,11 +11,15 @@ declare(strict_types=1); namespace Chill\PersonBundle\Tests\Export\Aggregator\AccompanyingCourseAggregators; -use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; +use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\RequestorAggregator; use Doctrine\ORM\EntityManagerInterface; +/** + * @internal + * @coversNothing + */ final class RequestorAggregatorTest extends AbstractAggregatorTest { private RequestorAggregator $aggregator; @@ -51,8 +55,7 @@ final class RequestorAggregatorTest extends AbstractAggregatorTest $em->createQueryBuilder() ->select('count(acp.id)') ->from(AccompanyingPeriod::class, 'acp') - ->join('acp.participations', 'acppart') - , + ->join('acp.participations', 'acppart'), ]; } } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ScopeAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ScopeAggregatorTest.php index 05fe5e980..066ff2bc5 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ScopeAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ScopeAggregatorTest.php @@ -11,11 +11,15 @@ declare(strict_types=1); namespace Chill\PersonBundle\Tests\Export\Aggregator\AccompanyingCourseAggregators; -use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; +use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\ScopeAggregator; use Doctrine\ORM\EntityManagerInterface; +/** + * @internal + * @coversNothing + */ final class ScopeAggregatorTest extends AbstractAggregatorTest { private ScopeAggregator $aggregator; @@ -51,8 +55,7 @@ final class ScopeAggregatorTest extends AbstractAggregatorTest $em->createQueryBuilder() ->select('count(acp.id)') ->from(AccompanyingPeriod::class, 'acp') - ->join('acp.scopes', 'acpscope') - , + ->join('acp.scopes', 'acpscope'), ]; } } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/SocialActionAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/SocialActionAggregatorTest.php index cdf27c1a5..66b59e5f9 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/SocialActionAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/SocialActionAggregatorTest.php @@ -11,11 +11,15 @@ declare(strict_types=1); namespace Chill\PersonBundle\Tests\Export\Aggregator\AccompanyingCourseAggregators; -use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; +use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\SocialActionAggregator; use Doctrine\ORM\EntityManagerInterface; +/** + * @internal + * @coversNothing + */ final class SocialActionAggregatorTest extends AbstractAggregatorTest { private SocialActionAggregator $aggregator; @@ -51,8 +55,7 @@ final class SocialActionAggregatorTest extends AbstractAggregatorTest $em->createQueryBuilder() ->select('count(acp.id)') ->from(AccompanyingPeriod::class, 'acp') - ->join('acp.works', 'acpw') - , + ->join('acp.works', 'acpw'), ]; } } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/SocialIssueAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/SocialIssueAggregatorTest.php index 912a2b7c6..360937cac 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/SocialIssueAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/SocialIssueAggregatorTest.php @@ -11,11 +11,15 @@ declare(strict_types=1); namespace Chill\PersonBundle\Tests\Export\Aggregator\AccompanyingCourseAggregators; -use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; +use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\SocialIssueAggregator; use Doctrine\ORM\EntityManagerInterface; +/** + * @internal + * @coversNothing + */ final class SocialIssueAggregatorTest extends AbstractAggregatorTest { private SocialIssueAggregator $aggregator; @@ -51,8 +55,7 @@ final class SocialIssueAggregatorTest extends AbstractAggregatorTest $em->createQueryBuilder() ->select('count(acp.id)') ->from(AccompanyingPeriod::class, 'acp') - ->join('acp.socialIssues', 'acpsocialissue') - , + ->join('acp.socialIssues', 'acpsocialissue'), ]; } } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/StepAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/StepAggregatorTest.php index ee11eeee4..f038c8a1c 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/StepAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/StepAggregatorTest.php @@ -11,11 +11,16 @@ declare(strict_types=1); namespace Chill\PersonBundle\Tests\Export\Aggregator\AccompanyingCourseAggregators; -use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; +use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\StepAggregator; +use DateTime; use Doctrine\ORM\EntityManagerInterface; +/** + * @internal + * @coversNothing + */ final class StepAggregatorTest extends AbstractAggregatorTest { private StepAggregator $aggregator; @@ -36,7 +41,7 @@ final class StepAggregatorTest extends AbstractAggregatorTest { return [ [ - 'on_date' => \DateTime::createFromFormat('Y-m-d', '2022-01-01'), + 'on_date' => DateTime::createFromFormat('Y-m-d', '2022-01-01'), ], ]; } @@ -52,8 +57,7 @@ final class StepAggregatorTest extends AbstractAggregatorTest return [ $em->createQueryBuilder() ->select('count(acp.id)') - ->from(AccompanyingPeriod::class, 'acp') - , + ->from(AccompanyingPeriod::class, 'acp'), ]; } } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/EvaluationAggregators/EvaluationTypeAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/EvaluationAggregators/EvaluationTypeAggregatorTest.php index 60b8d838c..624f03ef5 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/EvaluationAggregators/EvaluationTypeAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/EvaluationAggregators/EvaluationTypeAggregatorTest.php @@ -11,11 +11,15 @@ declare(strict_types=1); namespace Chill\PersonBundle\Tests\Export\Aggregator\EvaluationAggregators; -use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; +use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Export\Aggregator\EvaluationAggregators\EvaluationTypeAggregator; use Doctrine\ORM\EntityManagerInterface; +/** + * @internal + * @coversNothing + */ final class EvaluationTypeAggregatorTest extends AbstractAggregatorTest { private EvaluationTypeAggregator $aggregator; @@ -52,8 +56,7 @@ final class EvaluationTypeAggregatorTest extends AbstractAggregatorTest ->select('count(acp.id)') ->from(AccompanyingPeriod::class, 'acp') ->join('acp.works', 'acpw') - ->join('acpw.accompanyingPeriodWorkEvaluations', 'workeval') - , + ->join('acpw.accompanyingPeriodWorkEvaluations', 'workeval'), ]; } } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/HouseholdAggregators/ChildrenNumberAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/HouseholdAggregators/ChildrenNumberAggregatorTest.php index bef052329..429cf825b 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/HouseholdAggregators/ChildrenNumberAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/HouseholdAggregators/ChildrenNumberAggregatorTest.php @@ -11,11 +11,16 @@ declare(strict_types=1); namespace Chill\PersonBundle\Tests\Export\Aggregator\HouseholdAggregators; -use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; +use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Export\Aggregator\HouseholdAggregators\ChildrenNumberAggregator; +use DateTime; use Doctrine\ORM\EntityManagerInterface; +/** + * @internal + * @coversNothing + */ final class ChildrenNumberAggregatorTest extends AbstractAggregatorTest { private ChildrenNumberAggregator $aggregator; @@ -36,7 +41,7 @@ final class ChildrenNumberAggregatorTest extends AbstractAggregatorTest { return [ [ - 'on_date' => \DateTime::createFromFormat('Y-m-d', '2022-07-01') + 'on_date' => DateTime::createFromFormat('Y-m-d', '2022-07-01'), ], ]; } @@ -57,8 +62,7 @@ final class ChildrenNumberAggregatorTest extends AbstractAggregatorTest ->join('acppart.person', 'partperson') ->join('partperson.householdParticipations', 'member') ->join('member.household', 'household') - ->join('household.compositions', 'composition') - , + ->join('household.compositions', 'composition'), ]; } } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/HouseholdAggregators/CompositionAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/HouseholdAggregators/CompositionAggregatorTest.php index fc808c03d..5e017144e 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/HouseholdAggregators/CompositionAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/HouseholdAggregators/CompositionAggregatorTest.php @@ -11,11 +11,16 @@ declare(strict_types=1); namespace Chill\PersonBundle\Tests\Export\Aggregator\HouseholdAggregators; -use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; +use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Export\Aggregator\HouseholdAggregators\CompositionAggregator; +use DateTime; use Doctrine\ORM\EntityManagerInterface; +/** + * @internal + * @coversNothing + */ final class CompositionAggregatorTest extends AbstractAggregatorTest { private CompositionAggregator $aggregator; @@ -36,7 +41,7 @@ final class CompositionAggregatorTest extends AbstractAggregatorTest { return [ [ - 'on_date' => \DateTime::createFromFormat('Y-m-d', '2022-07-01') + 'on_date' => DateTime::createFromFormat('Y-m-d', '2022-07-01'), ], ]; } @@ -57,8 +62,7 @@ final class CompositionAggregatorTest extends AbstractAggregatorTest ->join('acppart.person', 'partperson') ->join('partperson.householdParticipations', 'member') ->join('member.household', 'household') - ->join('household.compositions', 'composition') - , + ->join('household.compositions', 'composition'), ]; } } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/CountryOfBirthAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/CountryOfBirthAggregatorTest.php index 90596d892..a22135ec5 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/CountryOfBirthAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/CountryOfBirthAggregatorTest.php @@ -16,6 +16,10 @@ use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Export\Aggregator\PersonAggregators\CountryOfBirthAggregator; use Doctrine\ORM\EntityManagerInterface; +/** + * @internal + * @coversNothing + */ final class CountryOfBirthAggregatorTest extends AbstractAggregatorTest { private CountryOfBirthAggregator $aggregator; @@ -36,7 +40,7 @@ final class CountryOfBirthAggregatorTest extends AbstractAggregatorTest { return [ ['group_by_level' => 'continent'], - ['group_by_level' => 'country',], + ['group_by_level' => 'country'], ]; } @@ -52,8 +56,7 @@ final class CountryOfBirthAggregatorTest extends AbstractAggregatorTest $em->createQueryBuilder() ->select('count(person.id)') ->from(Person::class, 'person') - ->leftJoin('person.countryOfBirth', 'countryOfBirth') - , + ->leftJoin('person.countryOfBirth', 'countryOfBirth'), ]; } } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/HouseholdPositionAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/HouseholdPositionAggregatorTest.php index 91a22d05a..036b00302 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/HouseholdPositionAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/HouseholdPositionAggregatorTest.php @@ -15,9 +15,14 @@ use Chill\MainBundle\Test\Export\AbstractAggregatorTest; use Chill\PersonBundle\Entity\Household\HouseholdMember; use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Export\Aggregator\PersonAggregators\HouseholdPositionAggregator; +use DateTime; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Query\Expr; +/** + * @internal + * @coversNothing + */ final class HouseholdPositionAggregatorTest extends AbstractAggregatorTest { private HouseholdPositionAggregator $aggregator; @@ -38,7 +43,7 @@ final class HouseholdPositionAggregatorTest extends AbstractAggregatorTest { return [ [ - 'date_position' => \DateTime::createFromFormat('Y-m-d', '2022-07-01') + 'date_position' => DateTime::createFromFormat('Y-m-d', '2022-07-01'), ], ]; } @@ -56,8 +61,7 @@ final class HouseholdPositionAggregatorTest extends AbstractAggregatorTest ->select('count(person.id)') ->from(Person::class, 'person') ->join(HouseholdMember::class, 'householdmember', Expr\Join::WITH, 'householdmember.person = person') - ->join('person.center', 'center') - , + ->join('person.center', 'center'), ]; } } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/MaritalStatusAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/MaritalStatusAggregatorTest.php index 25ddb602d..a24210fb4 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/MaritalStatusAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/MaritalStatusAggregatorTest.php @@ -16,6 +16,10 @@ use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Export\Aggregator\PersonAggregators\MaritalStatusAggregator; use Doctrine\ORM\EntityManagerInterface; +/** + * @internal + * @coversNothing + */ final class MaritalStatusAggregatorTest extends AbstractAggregatorTest { private MaritalStatusAggregator $aggregator; @@ -51,8 +55,7 @@ final class MaritalStatusAggregatorTest extends AbstractAggregatorTest $em->createQueryBuilder() ->select('count(person.id)') ->from(Person::class, 'person') - ->join('person.maritalStatus', 'personmarital') - , + ->join('person.maritalStatus', 'personmarital'), ]; } } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregatorTest.php index ed83c3af7..3ba391d60 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregatorTest.php @@ -54,8 +54,7 @@ final class ActionTypeAggregatorTest extends AbstractAggregatorTest return [ $em->createQueryBuilder() ->select('count(acpw.id)') - ->from(AccompanyingPeriodWork::class, 'acpw') - , + ->from(AccompanyingPeriodWork::class, 'acpw'), ]; } } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/GoalAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/GoalAggregatorTest.php index 979f3c488..deef482ee 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/GoalAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/GoalAggregatorTest.php @@ -54,8 +54,7 @@ final class GoalAggregatorTest extends AbstractAggregatorTest return [ $em->createQueryBuilder() ->select('count(acpw.id)') - ->from(AccompanyingPeriodWork::class, 'acpw') - , + ->from(AccompanyingPeriodWork::class, 'acpw'), ]; } } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/GoalResultAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/GoalResultAggregatorTest.php index 37642fa33..429833569 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/GoalResultAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/GoalResultAggregatorTest.php @@ -11,11 +11,15 @@ declare(strict_types=1); namespace Chill\PersonBundle\Tests\Export\Aggregator\SocialWorkAggregators; -use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; +use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\GoalResultAggregator; use Doctrine\ORM\EntityManagerInterface; +/** + * @internal + * @coversNothing + */ final class GoalResultAggregatorTest extends AbstractAggregatorTest { private GoalResultAggregator $aggregator; @@ -53,8 +57,7 @@ final class GoalResultAggregatorTest extends AbstractAggregatorTest ->from(AccompanyingPeriod::class, 'acp') ->join('acp.works', 'acpw') ->join('acpw.goals', 'goal') - ->join('goal.results', 'goalresult') - , + ->join('goal.results', 'goalresult'), ]; } } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/JobAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/JobAggregatorTest.php index c686e66b6..e8ed02aa1 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/JobAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/JobAggregatorTest.php @@ -11,11 +11,15 @@ declare(strict_types=1); namespace Chill\PersonBundle\Tests\Export\Aggregator\SocialWorkAggregators; -use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; +use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\JobAggregator; use Doctrine\ORM\EntityManagerInterface; +/** + * @internal + * @coversNothing + */ final class JobAggregatorTest extends AbstractAggregatorTest { private JobAggregator $aggregator; @@ -52,8 +56,7 @@ final class JobAggregatorTest extends AbstractAggregatorTest ->select('count(acp.id)') ->from(AccompanyingPeriod::class, 'acp') ->join('acp.works', 'acpw') - ->join('acpw.referrers', 'acpwuser') - , + ->join('acpw.referrers', 'acpwuser'), ]; } } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/ReferrerAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/ReferrerAggregatorTest.php index b8070398a..060655eb3 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/ReferrerAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/ReferrerAggregatorTest.php @@ -54,8 +54,7 @@ final class ReferrerAggregatorTest extends AbstractAggregatorTest return [ $em->createQueryBuilder() ->select('count(acpw.id)') - ->from(AccompanyingPeriodWork::class, 'acpw') - , + ->from(AccompanyingPeriodWork::class, 'acpw'), ]; } } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/ResultAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/ResultAggregatorTest.php index 984e296bc..cca033b5b 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/ResultAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/ResultAggregatorTest.php @@ -54,8 +54,7 @@ final class ResultAggregatorTest extends AbstractAggregatorTest return [ $em->createQueryBuilder() ->select('count(acpw.id)') - ->from(AccompanyingPeriodWork::class, 'acpw') - , + ->from(AccompanyingPeriodWork::class, 'acpw'), ]; } } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/ScopeAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/ScopeAggregatorTest.php index 3cece9ed9..95b3a784c 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/ScopeAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/ScopeAggregatorTest.php @@ -11,11 +11,15 @@ declare(strict_types=1); namespace Chill\PersonBundle\Tests\Export\Aggregator\SocialWorkAggregators; -use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; +use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\ScopeAggregator; use Doctrine\ORM\EntityManagerInterface; +/** + * @internal + * @coversNothing + */ final class ScopeAggregatorTest extends AbstractAggregatorTest { private ScopeAggregator $aggregator; @@ -52,8 +56,7 @@ final class ScopeAggregatorTest extends AbstractAggregatorTest ->select('count(acp.id)') ->from(AccompanyingPeriod::class, 'acp') ->join('acp.works', 'acpw') - ->join('acpw.referrers', 'acpwuser') - , + ->join('acpw.referrers', 'acpwuser'), ]; } } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/ActiveOnDateFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/ActiveOnDateFilterTest.php index fa03315d2..ac94a9c33 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/ActiveOnDateFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/ActiveOnDateFilterTest.php @@ -15,7 +15,6 @@ use Chill\MainBundle\Test\Export\AbstractFilterTest; use Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\ActiveOnDateFilter; use DateTime; use Doctrine\ORM\EntityManagerInterface; -use Symfony\Component\HttpFoundation\Request; /** * @internal diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/ActiveOneDayBetweenDatesFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/ActiveOneDayBetweenDatesFilterTest.php index 44f55e69f..5c25abefc 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/ActiveOneDayBetweenDatesFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/ActiveOneDayBetweenDatesFilterTest.php @@ -15,7 +15,6 @@ use Chill\MainBundle\Test\Export\AbstractFilterTest; use Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\ActiveOneDayBetweenDatesFilter; use DateTime; use Doctrine\ORM\EntityManagerInterface; -use Symfony\Component\HttpFoundation\Request; /** * @internal diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/AdministrativeLocationFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/AdministrativeLocationFilterTest.php index 3bd7518f2..df301537c 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/AdministrativeLocationFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/AdministrativeLocationFilterTest.php @@ -9,13 +9,12 @@ declare(strict_types=1); -namespace Chill\PersonBundle\Tests\Export\Filter\AccompanyingCourseFilters;; +namespace Chill\PersonBundle\Tests\Export\Filter\AccompanyingCourseFilters; use Chill\MainBundle\Entity\Location; use Chill\MainBundle\Test\Export\AbstractFilterTest; use Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\AdministrativeLocationFilter; use Doctrine\ORM\EntityManagerInterface; -use Symfony\Component\HttpFoundation\Request; /** * @internal diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/EvaluationFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/EvaluationFilterTest.php index b1436f345..b0fdb24b9 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/EvaluationFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/EvaluationFilterTest.php @@ -15,7 +15,6 @@ use Chill\MainBundle\Test\Export\AbstractFilterTest; use Chill\PersonBundle\Entity\SocialWork\Evaluation; use Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\EvaluationFilter; use Doctrine\ORM\EntityManagerInterface; -use Symfony\Component\HttpFoundation\Request; /** * @internal diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilterTest.php index 247cb870b..72a838f1e 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilterTest.php @@ -15,7 +15,6 @@ use Chill\MainBundle\Test\Export\AbstractFilterTest; use Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\GeographicalUnitStatFilter; use DateTime; use Doctrine\ORM\EntityManagerInterface; -use Symfony\Component\HttpFoundation\Request; /** * @internal diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/OpenBetweenDatesFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/OpenBetweenDatesFilterTest.php index a402b1f6a..e11e8228f 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/OpenBetweenDatesFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/OpenBetweenDatesFilterTest.php @@ -15,7 +15,6 @@ use Chill\MainBundle\Test\Export\AbstractFilterTest; use Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\OpenBetweenDatesFilter; use DateTime; use Doctrine\ORM\EntityManagerInterface; -use Symfony\Component\HttpFoundation\Request; /** * @internal diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/ReferrerFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/ReferrerFilterTest.php index 71cfd44da..ade7de2f9 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/ReferrerFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/ReferrerFilterTest.php @@ -15,7 +15,6 @@ use Chill\MainBundle\Entity\User; use Chill\MainBundle\Test\Export\AbstractFilterTest; use Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\ReferrerFilter; use Doctrine\ORM\EntityManagerInterface; -use Symfony\Component\HttpFoundation\Request; /** * @internal diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/RequestorFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/RequestorFilterTest.php index 318bccf0a..d56c57741 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/RequestorFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/RequestorFilterTest.php @@ -14,7 +14,6 @@ namespace Chill\PersonBundle\Tests\Export\Filter\AccompanyingCourseFilters; use Chill\MainBundle\Test\Export\AbstractFilterTest; use Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\RequestorFilter; use Doctrine\ORM\EntityManagerInterface; -use Symfony\Component\HttpFoundation\Request; /** * @internal diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/SocialActionFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/SocialActionFilterTest.php index 7b9a8b63e..15454c899 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/SocialActionFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/SocialActionFilterTest.php @@ -15,7 +15,6 @@ use Chill\MainBundle\Test\Export\AbstractFilterTest; use Chill\PersonBundle\Entity\SocialWork\SocialAction; use Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\SocialActionFilter; use Doctrine\ORM\EntityManagerInterface; -use Symfony\Component\HttpFoundation\Request; /** * @internal diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/EvaluationFilters/EvaluationTypeFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/EvaluationFilters/EvaluationTypeFilterTest.php index 81c764c99..c6c407348 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/EvaluationFilters/EvaluationTypeFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/EvaluationFilters/EvaluationTypeFilterTest.php @@ -51,7 +51,7 @@ final class EvaluationTypeFilterTest extends AbstractFilterTest foreach ($array as $r) { $data[] = [ - 'accepted_evaluationtype' => $r + 'accepted_evaluationtype' => $r, ]; } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/EvaluationFilters/MaxDateFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/EvaluationFilters/MaxDateFilterTest.php index be4b3580a..71658d711 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/EvaluationFilters/MaxDateFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/EvaluationFilters/MaxDateFilterTest.php @@ -13,7 +13,6 @@ namespace Chill\PersonBundle\Tests\Export\Filter\EvaluationFilters; use Chill\MainBundle\Test\Export\AbstractFilterTest; use Chill\PersonBundle\Entity\AccompanyingPeriod; -use Chill\PersonBundle\Entity\SocialWork\Evaluation; use Chill\PersonBundle\Export\Filter\EvaluationFilters\MaxDateFilter; use Doctrine\ORM\EntityManagerInterface; @@ -40,8 +39,8 @@ final class MaxDateFilterTest extends AbstractFilterTest public function getFormData(): array { return [ - ['maxdate' => false ], - ['maxdate' => true ] + ['maxdate' => false], + ['maxdate' => true], ]; } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/HouseholdFilters/CompositionFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/HouseholdFilters/CompositionFilterTest.php index e71949958..c0eccef81 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/HouseholdFilters/CompositionFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/HouseholdFilters/CompositionFilterTest.php @@ -15,6 +15,7 @@ use Chill\MainBundle\Test\Export\AbstractFilterTest; use Chill\PersonBundle\Entity\Household\Household; use Chill\PersonBundle\Entity\Household\HouseholdCompositionType; use Chill\PersonBundle\Export\Filter\HouseholdFilters\CompositionFilter; +use DateTime; use Doctrine\ORM\EntityManagerInterface; /** @@ -52,7 +53,7 @@ final class CompositionFilterTest extends AbstractFilterTest foreach ($array as $r) { $data[] = [ 'accepted_composition' => $r, - 'on_date' => \DateTime::createFromFormat('Y-m-d', '2022-05-01'), + 'on_date' => DateTime::createFromFormat('Y-m-d', '2022-05-01'), ]; } @@ -73,4 +74,4 @@ final class CompositionFilterTest extends AbstractFilterTest ->from(Household::class, 'h'), ]; } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/AccompanyingPeriodClosingFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/AccompanyingPeriodClosingFilterTest.php index bf975c5a1..1440eca51 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/AccompanyingPeriodClosingFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/AccompanyingPeriodClosingFilterTest.php @@ -13,6 +13,7 @@ namespace Chill\PersonBundle\Tests\Export\Filter\PersonFilters; use Chill\MainBundle\Test\Export\AbstractFilterTest; use Chill\PersonBundle\Export\Filter\PersonFilters\AccompanyingPeriodClosingFilter; +use DateTime; use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException; /** @@ -43,8 +44,8 @@ final class AccompanyingPeriodClosingFilterTest extends AbstractFilterTest { return [ [ - 'date_from' => \DateTime::createFromFormat('Y-m-d', '2000-01-01'), - 'date_to' => \DateTime::createFromFormat('Y-m-d', '2010-01-01'), + 'date_from' => DateTime::createFromFormat('Y-m-d', '2000-01-01'), + 'date_to' => DateTime::createFromFormat('Y-m-d', '2010-01-01'), ], ]; } @@ -86,4 +87,4 @@ final class AccompanyingPeriodClosingFilterTest extends AbstractFilterTest ->join('person.center', 'center'), ]; } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/AccompanyingPeriodOpeningFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/AccompanyingPeriodOpeningFilterTest.php index 54ed981ec..1cb46257d 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/AccompanyingPeriodOpeningFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/AccompanyingPeriodOpeningFilterTest.php @@ -13,6 +13,7 @@ namespace Chill\PersonBundle\Tests\Export\Filter\PersonFilters; use Chill\MainBundle\Test\Export\AbstractFilterTest; use Chill\PersonBundle\Export\Filter\PersonFilters\AccompanyingPeriodOpeningFilter; +use DateTime; use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException; /** @@ -43,8 +44,8 @@ final class AccompanyingPeriodOpeningFilterTest extends AbstractFilterTest { return [ [ - 'date_from' => \DateTime::createFromFormat('Y-m-d', '2000-01-01'), - 'date_to' => \DateTime::createFromFormat('Y-m-d', '2010-01-01'), + 'date_from' => DateTime::createFromFormat('Y-m-d', '2000-01-01'), + 'date_to' => DateTime::createFromFormat('Y-m-d', '2010-01-01'), ], ]; } @@ -86,4 +87,4 @@ final class AccompanyingPeriodOpeningFilterTest extends AbstractFilterTest ->join('person.center', 'center'), ]; } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/AgeFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/AgeFilterTest.php index 30c3ed86d..0131016ab 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/AgeFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/AgeFilterTest.php @@ -14,6 +14,7 @@ namespace Chill\PersonBundle\Tests\Export\Filter\PersonFilters; use Chill\MainBundle\Test\Export\AbstractFilterTest; use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Export\Filter\PersonFilters\AgeFilter; +use DateTime; use Doctrine\ORM\EntityManagerInterface; /** @@ -42,12 +43,12 @@ final class AgeFilterTest extends AbstractFilterTest [ 'min_age' => '18', 'max_age' => '60', - 'date_calc' => \DateTime::createFromFormat('Y-m-d', '2020-05-01'), + 'date_calc' => DateTime::createFromFormat('Y-m-d', '2020-05-01'), ], [ // ça devrait faire boum ! 'min_age' => '35', 'max_age' => '30', - 'date_calc' => \DateTime::createFromFormat('Y-m-d', '2020-05-01'), + 'date_calc' => DateTime::createFromFormat('Y-m-d', '2020-05-01'), ], ]; } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/DeadOrAliveFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/DeadOrAliveFilterTest.php index 0cbb22be7..ce48394c6 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/DeadOrAliveFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/DeadOrAliveFilterTest.php @@ -14,6 +14,7 @@ namespace Chill\PersonBundle\Tests\Export\Filter\PersonFilters; use Chill\MainBundle\Test\Export\AbstractFilterTest; use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Export\Filter\PersonFilters\DeadOrAliveFilter; +use DateTime; use Doctrine\ORM\EntityManagerInterface; /** @@ -41,11 +42,11 @@ final class DeadOrAliveFilterTest extends AbstractFilterTest return [ [ 'person_state' => 'alive', - 'date_calc' => \DateTime::createFromFormat('Y-m-d', '2021-05-01'), + 'date_calc' => DateTime::createFromFormat('Y-m-d', '2021-05-01'), ], [ 'person_state' => 'deceased', - 'date_calc' => \DateTime::createFromFormat('Y-m-d', '2021-05-01'), + 'date_calc' => DateTime::createFromFormat('Y-m-d', '2021-05-01'), ], ]; } @@ -64,4 +65,4 @@ final class DeadOrAliveFilterTest extends AbstractFilterTest ->from(Person::class, 'p'), ]; } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/DeathdateFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/DeathdateFilterTest.php index 17742dcd6..6562233e4 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/DeathdateFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/DeathdateFilterTest.php @@ -14,6 +14,7 @@ namespace Chill\PersonBundle\Tests\Export\Filter\PersonFilters; use Chill\MainBundle\Test\Export\AbstractFilterTest; use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Export\Filter\PersonFilters\DeathdateFilter; +use DateTime; use Doctrine\ORM\EntityManagerInterface; /** @@ -40,9 +41,9 @@ final class DeathdateFilterTest extends AbstractFilterTest { return [ [ - 'date_from' => \DateTime::createFromFormat('Y-m-d', '2020-05-01'), - 'date_to' => \DateTime::createFromFormat('Y-m-d', '2022-05-01'), - ] + 'date_from' => DateTime::createFromFormat('Y-m-d', '2020-05-01'), + 'date_to' => DateTime::createFromFormat('Y-m-d', '2022-05-01'), + ], ]; } @@ -60,4 +61,4 @@ final class DeathdateFilterTest extends AbstractFilterTest ->from(Person::class, 'p'), ]; } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/MaritalStatusFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/MaritalStatusFilterTest.php index 40fa814b1..a01566ba8 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/MaritalStatusFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/MaritalStatusFilterTest.php @@ -15,6 +15,7 @@ use Chill\MainBundle\Test\Export\AbstractFilterTest; use Chill\PersonBundle\Entity\MaritalStatus; use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Export\Filter\PersonFilters\MaritalStatusFilter; +use DateTime; use Doctrine\ORM\EntityManagerInterface; /** @@ -52,7 +53,7 @@ final class MaritalStatusFilterTest extends AbstractFilterTest foreach ($array as $m) { $data[] = [ 'maritalStatus' => $m, - 'calc_date' => \DateTime::createFromFormat('Y-m-d', '2022-05-01'), + 'calc_date' => DateTime::createFromFormat('Y-m-d', '2022-05-01'), ]; } @@ -74,4 +75,3 @@ final class MaritalStatusFilterTest extends AbstractFilterTest ]; } } - diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/NationalityFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/NationalityFilterTest.php index 6dd1a944e..e142fa9a0 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/NationalityFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/NationalityFilterTest.php @@ -47,7 +47,7 @@ final class NationalityFilterTest extends AbstractFilterTest foreach ($countries as $c) { $data[] = [ - 'nationalities' => $c + 'nationalities' => $c, ]; } @@ -68,5 +68,4 @@ final class NationalityFilterTest extends AbstractFilterTest ->from(Person::class, 'p'), ]; } - -} \ No newline at end of file +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilterTest.php index 8444f6865..1c9225f80 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilterTest.php @@ -16,6 +16,7 @@ use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Entity\Person\ResidentialAddress; use Chill\PersonBundle\Export\Filter\PersonFilters\ResidentialAddressAtThirdpartyFilter; use Chill\ThirdPartyBundle\Entity\ThirdPartyCategory; +use DateTime; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Query\Expr; @@ -54,7 +55,7 @@ final class ResidentialAddressAtThirdpartyFilterTest extends AbstractFilterTest foreach ($array as $r) { $data[] = [ 'thirdparty_cat' => $r, - 'date_calc' => \DateTime::createFromFormat('Y-m-d', '2022-05-01'), + 'date_calc' => DateTime::createFromFormat('Y-m-d', '2022-05-01'), ]; } @@ -76,8 +77,7 @@ final class ResidentialAddressAtThirdpartyFilterTest extends AbstractFilterTest ->join(ResidentialAddress::class, 'resaddr', Expr\Join::WITH, 'resaddr.person = p') ->join('p.center', 'center') ->join('resaddr.hostThirdParty', 'tparty') - ->join('tparty.categories', 'tpartycat') - , + ->join('tparty.categories', 'tpartycat'), ]; } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/ResidentialAddressAtUserFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/ResidentialAddressAtUserFilterTest.php index ba3ededca..4ce578ca2 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/ResidentialAddressAtUserFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/ResidentialAddressAtUserFilterTest.php @@ -13,9 +13,7 @@ namespace Chill\PersonBundle\Tests\Export\Filter\PersonFilters; use Chill\MainBundle\Test\Export\AbstractFilterTest; use Chill\PersonBundle\Entity\Person; -use Chill\PersonBundle\Export\Filter\PersonFilters\ResidentialAddressAtThirdpartyFilter; use Chill\PersonBundle\Export\Filter\PersonFilters\ResidentialAddressAtUserFilter; -use Chill\ThirdPartyBundle\Entity\ThirdPartyCategory; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Query\Expr; @@ -60,4 +58,4 @@ final class ResidentialAddressAtUserFilterTest extends AbstractFilterTest ->join('p.center', 'center'), ]; } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialWorkFilters/ReferrerFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialWorkFilters/ReferrerFilterTest.php index dd4a17c72..8b4a69c98 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialWorkFilters/ReferrerFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialWorkFilters/ReferrerFilterTest.php @@ -47,9 +47,10 @@ final class ReferrerFilterTest extends AbstractFilterTest foreach ($users as $u) { $data[] = [ - 'accepted_agents' => $u + 'accepted_agents' => $u, ]; } + return $data; } @@ -68,4 +69,4 @@ final class ReferrerFilterTest extends AbstractFilterTest ->join('acp.works', 'acpw'), ]; } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialWorkFilters/SocialWorkTypeFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialWorkFilters/SocialWorkTypeFilterTest.php index b9def05cd..99fb3aae9 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialWorkFilters/SocialWorkTypeFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialWorkFilters/SocialWorkTypeFilterTest.php @@ -50,17 +50,21 @@ final class SocialWorkTypeFilterTest extends AbstractFilterTest $results = []; $social_actions = $action_repository->findAll(); + foreach ($social_actions as $action) { $actions[] = $action->getId(); $goals_by_action = $goal_repository->findBySocialActionWithDescendants($action); + foreach ($goals_by_action as $goal) { $goals[] = $goal->getId(); $results_by_goal = $result_repository->findByGoal($goal); + foreach ($results_by_goal as $result) { $results[] = $result->getId(); } } $results_by_action = $result_repository->findBySocialActionWithDescendants($action); + foreach ($results_by_action as $result) { $results[] = $result->getId(); } @@ -79,7 +83,7 @@ final class SocialWorkTypeFilterTest extends AbstractFilterTest 'actionType' => implode(',', $actions), 'goal' => implode(',', $goals), 'result' => implode(',', $results), - ] + ], ]; /// TODO ne fonctionne pas var_dump($data); @@ -102,4 +106,4 @@ final class SocialWorkTypeFilterTest extends AbstractFilterTest ->join('acp.works', 'acpw'), ]; } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Repository/PersonACLAwareRepositoryTest.php b/src/Bundle/ChillPersonBundle/Tests/Repository/PersonACLAwareRepositoryTest.php index 4540e3716..3f7ac3027 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Repository/PersonACLAwareRepositoryTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Repository/PersonACLAwareRepositoryTest.php @@ -1,5 +1,14 @@ entityManager = self::$container->get(EntityManagerInterface::class); $this->countryRepository = self::$container->get(CountryRepository::class); $this->centerRepository = self::$container->get(CenterRepositoryInterface::class); - } public function testCountByCriteria() @@ -46,8 +59,12 @@ class PersonACLAwareRepositoryTest extends KernelTestCase $security = $this->prophesize(Security::class); $security->getUser()->willReturn($user); - $repository = new PersonACLAwareRepository($security->reveal(), $this->entityManager, $this->countryRepository, - $authorizationHelper->reveal()); + $repository = new PersonACLAwareRepository( + $security->reveal(), + $this->entityManager, + $this->countryRepository, + $authorizationHelper->reveal() + ); $number = $repository->countBySearchCriteria('diallo'); @@ -65,13 +82,18 @@ class PersonACLAwareRepositoryTest extends KernelTestCase $security = $this->prophesize(Security::class); $security->getUser()->willReturn($user); - $repository = new PersonACLAwareRepository($security->reveal(), $this->entityManager, $this->countryRepository, - $authorizationHelper->reveal()); + $repository = new PersonACLAwareRepository( + $security->reveal(), + $this->entityManager, + $this->countryRepository, + $authorizationHelper->reveal() + ); $results = $repository->findBySearchCriteria(0, 5, false, 'diallo'); $this->assertGreaterThan(0, count($results)); $this->assertContainsOnlyInstancesOf(Person::class, $results); + foreach ($results as $person) { $this->assertStringContainsString('diallo', strtolower($person->getFirstName() . ' ' . $person->getLastName())); } diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20220926154347.php b/src/Bundle/ChillPersonBundle/migrations/Version20220926154347.php index b308c22e3..e04d6b90a 100644 --- a/src/Bundle/ChillPersonBundle/migrations/Version20220926154347.php +++ b/src/Bundle/ChillPersonBundle/migrations/Version20220926154347.php @@ -1,5 +1,12 @@ addSql('DROP VIEW view_chill_person_person_center_history_current'); + $this->addSql('DROP SEQUENCE chill_person_person_center_history_id_seq CASCADE'); + $this->addSql('DROP TABLE chill_person_person_center_history'); + } + public function getDescription(): string { return 'Add a center history on person'; @@ -59,11 +73,4 @@ final class Version20220926154347 extends AbstractMigration SELECT nextval(\'chill_person_person_center_history_id_seq\'), id, center_id, COALESCE(createdat, NOW()) FROM chill_person_person WHERE center_id IS NOT NULL'); } - - public function down(Schema $schema): void - { - $this->addSql('DROP VIEW view_chill_person_person_center_history_current'); - $this->addSql('DROP SEQUENCE chill_person_person_center_history_id_seq CASCADE'); - $this->addSql('DROP TABLE chill_person_person_center_history'); - } } diff --git a/src/Bundle/ChillReportBundle/Tests/Export/Filter/ReportDateFilterTest.php b/src/Bundle/ChillReportBundle/Tests/Export/Filter/ReportDateFilterTest.php index 54291a02f..b8d4510de 100644 --- a/src/Bundle/ChillReportBundle/Tests/Export/Filter/ReportDateFilterTest.php +++ b/src/Bundle/ChillReportBundle/Tests/Export/Filter/ReportDateFilterTest.php @@ -14,6 +14,7 @@ namespace Chill\ReportBundle\Tests\Export\Filter; use Chill\MainBundle\Test\Export\AbstractFilterTest; use Chill\ReportBundle\Entity\Report; use Chill\ReportBundle\Export\Filter\ReportDateFilter; +use DateTime; use Doctrine\ORM\EntityManagerInterface; /** @@ -40,9 +41,9 @@ final class ReportDateFilterTest extends AbstractFilterTest { return [ [ - 'date_from' => \DateTime::createFromFormat('Y-m-d', '2021-07-01'), - 'date_to' => \DateTime::createFromFormat('Y-m-d', '2022-07-01'), - ] + 'date_from' => DateTime::createFromFormat('Y-m-d', '2021-07-01'), + 'date_to' => DateTime::createFromFormat('Y-m-d', '2022-07-01'), + ], ]; } @@ -57,7 +58,7 @@ final class ReportDateFilterTest extends AbstractFilterTest return [ $em->createQueryBuilder() ->select('r.id') - ->from(Report::class, 'r') + ->from(Report::class, 'r'), ]; } } diff --git a/src/Bundle/ChillTaskBundle/Repository/SingleTaskAclAwareRepository.php b/src/Bundle/ChillTaskBundle/Repository/SingleTaskAclAwareRepository.php index dca83eb71..11fd1aa4c 100644 --- a/src/Bundle/ChillTaskBundle/Repository/SingleTaskAclAwareRepository.php +++ b/src/Bundle/ChillTaskBundle/Repository/SingleTaskAclAwareRepository.php @@ -12,7 +12,6 @@ declare(strict_types=1); namespace Chill\TaskBundle\Repository; use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface; -use Chill\MainBundle\Security\Resolver\CenterResolverDispatcherInterface; use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\Person; @@ -336,8 +335,7 @@ final class SingleTaskAclAwareRepository implements SingleTaskAclAwareRepository ->leftJoin('course.participations', 'participation') ->leftJoin('participation.person', 'person_p') ->leftJoin('person.centerCurrent', 'center_current_person') - ->leftJoin('person_p.centerCurrent', 'center_current_participation') - ; + ->leftJoin('person_p.centerCurrent', 'center_current_participation'); $qb->distinct(true); $k = 0; diff --git a/src/Bundle/ChillTaskBundle/Tests/Repository/SingleTaskACLAwareRepositoryTest.php b/src/Bundle/ChillTaskBundle/Tests/Repository/SingleTaskACLAwareRepositoryTest.php index f4c54b6cc..2cd0788ac 100644 --- a/src/Bundle/ChillTaskBundle/Tests/Repository/SingleTaskACLAwareRepositoryTest.php +++ b/src/Bundle/ChillTaskBundle/Tests/Repository/SingleTaskACLAwareRepositoryTest.php @@ -1,5 +1,14 @@ personRepository = self::$container->get(PersonRepository::class); } - public function testCountByPerson(): void - { - $centerA = $this->centerRepository->findOneBy(['name' => 'Center A']); - $user = new User(); - $scopes = $this->scopeRepository->findAll(); - $person = $this->getRandomPerson($this->em); - - $security = $this->prophesize(Security::class); - $security->getUser()->willReturn($user); - - $centerResolverDispatcher = $this->prophesize(CenterResolverManagerInterface::class); - $centerResolverDispatcher->resolveCenters(Argument::type(Person::class), Argument::any()) - ->willReturn([$centerA]); - - $authorizationHelper = $this->prophesize(AuthorizationHelperInterface::class); - $authorizationHelper->getReachableScopes(Argument::exact($user), Argument::exact(TaskVoter::SHOW), Argument::exact($centerA)) - ->willReturn($scopes); - - $repository = new SingleTaskAclAwareRepository( - $centerResolverDispatcher->reveal(), - $this->em, - $security->reveal(), - $authorizationHelper->reveal() - ); - - $nb = $repository->countByPerson($person, null, []); - - $this->assertGreaterThanOrEqual(0, $nb); - } - - public function testFindByPerson(): void - { - $centerA = $this->centerRepository->findOneBy(['name' => 'Center A']); - $user = new User(); - $scopes = $this->scopeRepository->findAll(); - $person = $this->getRandomPerson($this->em); - - $security = $this->prophesize(Security::class); - $security->getUser()->willReturn($user); - - $centerResolverDispatcher = $this->prophesize(CenterResolverManagerInterface::class); - $centerResolverDispatcher->resolveCenters(Argument::type(Person::class), Argument::any()) - ->willReturn([$centerA]); - - $authorizationHelper = $this->prophesize(AuthorizationHelperInterface::class); - $authorizationHelper->getReachableScopes(Argument::exact($user), Argument::exact(TaskVoter::SHOW), Argument::exact($centerA)) - ->willReturn($scopes); - - $repository = new SingleTaskAclAwareRepository( - $centerResolverDispatcher->reveal(), - $this->em, - $security->reveal(), - $authorizationHelper->reveal() - ); - - $tasks = $repository->findByPerson($person, null, []); - - $this->assertGreaterThanOrEqual(0, count($tasks)); - } - - public function testFindByAllViewable(): void - { - $centerA = $this->centerRepository->findOneBy(['name' => 'Center A']); - $user = new User(); - $scopes = $this->scopeRepository->findAll(); - - $security = $this->prophesize(Security::class); - $security->getUser()->willReturn($user); - - $centerResolverDispatcher = $this->prophesize(CenterResolverManagerInterface::class); - $centerResolverDispatcher->resolveCenters(Argument::type(Person::class), Argument::any()) - ->willReturn([$centerA]); - - $authorizationHelper = $this->prophesize(AuthorizationHelperInterface::class); - $authorizationHelper->getReachableCenters(Argument::exact($user), Argument::exact(TaskVoter::SHOW)) - ->willReturn([$centerA]); - $authorizationHelper->getReachableScopes(Argument::exact($user), Argument::exact(TaskVoter::SHOW), Argument::exact($centerA)) - ->willReturn($scopes); - - $repository = new SingleTaskAclAwareRepository( - $centerResolverDispatcher->reveal(), - $this->em, - $security->reveal(), - $authorizationHelper->reveal() - ); - - $tasks = $repository->findByAllViewable(null, []); - - $this->assertGreaterThanOrEqual(0, count($tasks)); - } - public function testCountByAllViewable(): void { $centerA = $this->centerRepository->findOneBy(['name' => 'Center A']); @@ -169,6 +94,67 @@ class SingleTaskACLAwareRepositoryTest extends KernelTestCase $this->assertGreaterThanOrEqual(0, $nb); } + public function testCountByPerson(): void + { + $centerA = $this->centerRepository->findOneBy(['name' => 'Center A']); + $user = new User(); + $scopes = $this->scopeRepository->findAll(); + $person = $this->getRandomPerson($this->em); + + $security = $this->prophesize(Security::class); + $security->getUser()->willReturn($user); + + $centerResolverDispatcher = $this->prophesize(CenterResolverManagerInterface::class); + $centerResolverDispatcher->resolveCenters(Argument::type(Person::class), Argument::any()) + ->willReturn([$centerA]); + + $authorizationHelper = $this->prophesize(AuthorizationHelperInterface::class); + $authorizationHelper->getReachableScopes(Argument::exact($user), Argument::exact(TaskVoter::SHOW), Argument::exact($centerA)) + ->willReturn($scopes); + + $repository = new SingleTaskAclAwareRepository( + $centerResolverDispatcher->reveal(), + $this->em, + $security->reveal(), + $authorizationHelper->reveal() + ); + + $nb = $repository->countByPerson($person, null, []); + + $this->assertGreaterThanOrEqual(0, $nb); + } + + public function testFindByAllViewable(): void + { + $centerA = $this->centerRepository->findOneBy(['name' => 'Center A']); + $user = new User(); + $scopes = $this->scopeRepository->findAll(); + + $security = $this->prophesize(Security::class); + $security->getUser()->willReturn($user); + + $centerResolverDispatcher = $this->prophesize(CenterResolverManagerInterface::class); + $centerResolverDispatcher->resolveCenters(Argument::type(Person::class), Argument::any()) + ->willReturn([$centerA]); + + $authorizationHelper = $this->prophesize(AuthorizationHelperInterface::class); + $authorizationHelper->getReachableCenters(Argument::exact($user), Argument::exact(TaskVoter::SHOW)) + ->willReturn([$centerA]); + $authorizationHelper->getReachableScopes(Argument::exact($user), Argument::exact(TaskVoter::SHOW), Argument::exact($centerA)) + ->willReturn($scopes); + + $repository = new SingleTaskAclAwareRepository( + $centerResolverDispatcher->reveal(), + $this->em, + $security->reveal(), + $authorizationHelper->reveal() + ); + + $tasks = $repository->findByAllViewable(null, []); + + $this->assertGreaterThanOrEqual(0, count($tasks)); + } + public function testFindByCourse(): void { $centerA = $this->centerRepository->findOneBy(['name' => 'Center A']); @@ -176,14 +162,13 @@ class SingleTaskACLAwareRepositoryTest extends KernelTestCase $scopes = $this->scopeRepository->findAll(); /** @var Person $person */ $person = $this->em->createQuery( - 'SELECT p FROM '.Person::class.' p JOIN p.centerCurrent cc - WHERE SIZE(p.accompanyingPeriodParticipations) > 0 + 'SELECT p FROM ' . Person::class . ' p JOIN p.centerCurrent cc + WHERE SIZE(p.accompanyingPeriodParticipations) > 0 AND cc.center = :center' ) ->setParameter('center', $centerA) ->setMaxResults(1) - ->getSingleResult() - ; + ->getSingleResult(); $period = $person->getAccompanyingPeriodParticipations()->first()->getAccompanyingPeriod(); $security = $this->prophesize(Security::class); @@ -208,4 +193,34 @@ class SingleTaskACLAwareRepositoryTest extends KernelTestCase $this->assertGreaterThanOrEqual(0, count($tasks)); } -} \ No newline at end of file + + public function testFindByPerson(): void + { + $centerA = $this->centerRepository->findOneBy(['name' => 'Center A']); + $user = new User(); + $scopes = $this->scopeRepository->findAll(); + $person = $this->getRandomPerson($this->em); + + $security = $this->prophesize(Security::class); + $security->getUser()->willReturn($user); + + $centerResolverDispatcher = $this->prophesize(CenterResolverManagerInterface::class); + $centerResolverDispatcher->resolveCenters(Argument::type(Person::class), Argument::any()) + ->willReturn([$centerA]); + + $authorizationHelper = $this->prophesize(AuthorizationHelperInterface::class); + $authorizationHelper->getReachableScopes(Argument::exact($user), Argument::exact(TaskVoter::SHOW), Argument::exact($centerA)) + ->willReturn($scopes); + + $repository = new SingleTaskAclAwareRepository( + $centerResolverDispatcher->reveal(), + $this->em, + $security->reveal(), + $authorizationHelper->reveal() + ); + + $tasks = $repository->findByPerson($person, null, []); + + $this->assertGreaterThanOrEqual(0, count($tasks)); + } +}