From 42122f5832217bc2df7dc85a5b1483a721de15ef Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Tue, 16 Aug 2022 15:30:56 +0200 Subject: [PATCH] exports: use Declarations in activity exports --- .../Export/Aggregator/ActivityReasonAggregator.php | 5 +++-- .../Export/Aggregator/ActivityTypeAggregator.php | 5 +++-- .../Export/Aggregator/ActivityUserAggregator.php | 3 ++- .../ChillActivityBundle/Export/Export/CountActivity.php | 7 ++++++- .../Export/Export/CountActivityLinkedToACP.php | 2 +- .../ChillActivityBundle/Export/Export/ListActivity.php | 7 ++++++- .../Export/Export/StatActivityDuration.php | 8 ++++---- .../Export/Filter/ActivityDateFilter.php | 5 +++-- .../Export/Filter/ActivityReasonFilter.php | 5 +++-- .../Export/Filter/ActivityTypeFilter.php | 2 +- .../Filter/PersonHavingActivityBetweenDateFilter.php | 2 +- 11 files changed, 33 insertions(+), 18 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityReasonAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityReasonAggregator.php index 19811f584..b4d2f8e52 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityReasonAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityReasonAggregator.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\ActivityBundle\Export\Aggregator; +use Chill\ActivityBundle\Export\Declarations; use Chill\ActivityBundle\Repository\ActivityReasonCategoryRepository; use Chill\ActivityBundle\Repository\ActivityReasonRepository; use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter; @@ -104,9 +105,9 @@ class ActivityReasonAggregator implements AggregatorInterface, ExportElementVali } } - public function applyOn() + public function applyOn(): string { - return 'activity'; + return Declarations::ACTIVITY; } public function buildForm(FormBuilderInterface $builder) diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php index 83b5f71e2..8a5ce4d01 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\ActivityBundle\Export\Aggregator; +use Chill\ActivityBundle\Export\Declarations; use Chill\ActivityBundle\Repository\ActivityTypeRepository; use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter; use Chill\MainBundle\Export\AggregatorInterface; @@ -51,9 +52,9 @@ class ActivityTypeAggregator implements AggregatorInterface $qb->addGroupBy(self::KEY); } - public function applyOn() + public function applyOn(): string { - return 'activity'; + return Declarations::ACTIVITY; } public function buildForm(FormBuilderInterface $builder) diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUserAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUserAggregator.php index 312456104..3cdeee0f9 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUserAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUserAggregator.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\ActivityBundle\Export\Aggregator; +use Chill\ActivityBundle\Export\Declarations; use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter; use Chill\MainBundle\Export\AggregatorInterface; use Chill\MainBundle\Repository\UserRepository; @@ -47,7 +48,7 @@ class ActivityUserAggregator implements AggregatorInterface public function applyOn(): string { - return 'activity'; + return Declarations::ACTIVITY; } public function buildForm(FormBuilderInterface $builder) diff --git a/src/Bundle/ChillActivityBundle/Export/Export/CountActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/CountActivity.php index 92e15e8bb..39710953c 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/CountActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/CountActivity.php @@ -16,6 +16,8 @@ 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; use Symfony\Component\Form\FormBuilderInterface; @@ -98,7 +100,10 @@ class CountActivity implements ExportInterface, GroupedExportInterface public function supportsModifiers() { - return ['person', 'activity']; + return [ + Declarations::ACTIVITY, + //PersonDeclarations::PERSON_TYPE, + ]; } public function getGroup(): string diff --git a/src/Bundle/ChillActivityBundle/Export/Export/CountActivityLinkedToACP.php b/src/Bundle/ChillActivityBundle/Export/Export/CountActivityLinkedToACP.php index f17ced0fd..91a2dd285 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/CountActivityLinkedToACP.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/CountActivityLinkedToACP.php @@ -101,7 +101,7 @@ class CountActivityLinkedToACP implements ExportInterface, GroupedExportInterfac { return [ Declarations::ACTIVITY, - PersonDeclarations::PERSON_TYPE, + //PersonDeclarations::PERSON_TYPE, //PersonDeclarations::ACP_TYPE, ]; } diff --git a/src/Bundle/ChillActivityBundle/Export/Export/ListActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/ListActivity.php index 438a879c4..773c4bee1 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/ListActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/ListActivity.php @@ -28,6 +28,8 @@ 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; @@ -275,7 +277,10 @@ class ListActivity implements ListInterface, GroupedExportInterface public function supportsModifiers() { - return ['activity', 'person']; + return [ + Declarations::ACTIVITY, + //PersonDeclarations::PERSON_TYPE, + ]; } public function getGroup(): string diff --git a/src/Bundle/ChillActivityBundle/Export/Export/StatActivityDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/StatActivityDuration.php index 5793c2b06..5f02928c6 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/StatActivityDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/StatActivityDuration.php @@ -17,8 +17,8 @@ use Chill\MainBundle\Entity\Center; use Chill\MainBundle\Export\ExportInterface; use Chill\MainBundle\Export\FormatterInterface; use Chill\MainBundle\Export\GroupedExportInterface; -use Chill\PersonBundle\Export\Declarations as Person_Declarations; -use Chill\ActivityBundle\Export\Declarations as Activity_Declarations; +use Chill\PersonBundle\Export\Declarations as PersonDeclarations; +use Chill\ActivityBundle\Export\Declarations; use Doctrine\ORM\Query; use LogicException; use Symfony\Component\Form\FormBuilderInterface; @@ -130,8 +130,8 @@ class StatActivityDuration implements ExportInterface, GroupedExportInterface public function supportsModifiers() { return [ - Person_Declarations::PERSON_TYPE, - Activity_Declarations::ACTIVITY + Declarations::ACTIVITY, + //PersonDeclarations::PERSON_TYPE, ]; } diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityDateFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityDateFilter.php index 6048a1cc0..7a7fed3ee 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityDateFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityDateFilter.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\ActivityBundle\Export\Filter; +use Chill\ActivityBundle\Export\Declarations; use Chill\MainBundle\Export\FilterInterface; use Chill\MainBundle\Form\Type\Export\FilterType; use DateTime; @@ -57,9 +58,9 @@ class ActivityDateFilter implements FilterInterface $qb->setParameter('date_to', $data['date_to']); } - public function applyOn() + public function applyOn(): string { - return 'activity'; + return Declarations::ACTIVITY; } public function buildForm(FormBuilderInterface $builder) diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityReasonFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityReasonFilter.php index 467471a8d..de6baac03 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityReasonFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityReasonFilter.php @@ -12,6 +12,7 @@ declare(strict_types=1); namespace Chill\ActivityBundle\Export\Filter; use Chill\ActivityBundle\Entity\ActivityReason; +use Chill\ActivityBundle\Export\Declarations; use Chill\ActivityBundle\Repository\ActivityReasonRepository; use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter; use Chill\MainBundle\Export\ExportElementValidatedInterface; @@ -79,9 +80,9 @@ class ActivityReasonFilter implements ExportElementValidatedInterface, FilterInt $qb->setParameter('selected_activity_reasons', $data['reasons']); } - public function applyOn() + public function applyOn(): string { - return 'activity'; + return Declarations::ACTIVITY; } public function buildForm(FormBuilderInterface $builder) diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php index 6b7e4eab5..9019bf3cd 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php @@ -62,7 +62,7 @@ class ActivityTypeFilter implements ExportElementValidatedInterface, FilterInter $qb->setParameter('selected_activity_types', $data['types']); } - public function applyOn() + public function applyOn(): string { return Declarations::ACTIVITY; } diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/PersonHavingActivityBetweenDateFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/PersonHavingActivityBetweenDateFilter.php index 312486b49..2c47d1c91 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/PersonHavingActivityBetweenDateFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/PersonHavingActivityBetweenDateFilter.php @@ -102,7 +102,7 @@ class PersonHavingActivityBetweenDateFilter implements ExportElementValidatedInt $qb->setParameter('person_having_activity_reasons', $data['reasons']); } - public function applyOn() + public function applyOn(): string { return Declarations::PERSON_IMPLIED_IN; }