From 8e44f20535990beb34e178dfcde7ffb9cf70393f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 10 Nov 2022 15:21:56 +0100 Subject: [PATCH] Features: [export] Remove old unnecessary filters for person with accompanying period Those filters applyed on persons and allowed to select person which has a new, closing, or active accompanying period. But this is deprecated: there are now a dedicated Export for that ( CountPersonWithAccompanyingCourse) --- .../ChillPersonExtension.php | 12 ++- .../AccompanyingPeriodClosingFilter.php | 78 ---------------- .../AccompanyingPeriodFilter.php | 87 ------------------ .../AccompanyingPeriodOpeningFilter.php | 78 ---------------- .../AccompanyingPeriodClosingFilterTest.php | 90 ------------------- .../AccompanyingPeriodFilterTest.php | 90 ------------------- .../AccompanyingPeriodOpeningFilterTest.php | 90 ------------------- .../services/exports_accompanying_period.yaml | 16 ---- 8 files changed, 5 insertions(+), 536 deletions(-) delete mode 100644 src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AccompanyingPeriodClosingFilter.php delete mode 100644 src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AccompanyingPeriodFilter.php delete mode 100644 src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AccompanyingPeriodOpeningFilter.php delete mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/AccompanyingPeriodClosingFilterTest.php delete mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/AccompanyingPeriodFilterTest.php delete mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/AccompanyingPeriodOpeningFilterTest.php delete mode 100644 src/Bundle/ChillPersonBundle/config/services/exports_accompanying_period.yaml diff --git a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php index 932f5b9f9..d60e15e41 100644 --- a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php +++ b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php @@ -97,11 +97,11 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac $loader->load('services/exports_person.yaml'); if ($container->getParameter('chill_person.accompanying_period') !== 'hidden') { - $loader->load('services/exports_accompanying_period.yaml'); + $loader->load('services/exports_accompanying_course.yaml'); + $loader->load('services/exports_social_actions.yaml'); + $loader->load('services/exports_evaluation.yaml'); } - $loader->load('services/exports_accompanying_course.yaml'); - $loader->load('services/exports_social_actions.yaml'); - $loader->load('services/exports_evaluation.yaml'); + $loader->load('services/exports_household.yaml'); } @@ -944,10 +944,8 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac /** * Add a widget "add a person" on the homepage, automatically. - * - * @param \Chill\PersonBundle\DependencyInjection\containerBuilder $container */ - protected function prependHomepageWidget(containerBuilder $container) + protected function prependHomepageWidget(ContainerBuilder $container) { $container->prependExtensionConfig('chill_main', [ 'widgets' => [ diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AccompanyingPeriodClosingFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AccompanyingPeriodClosingFilter.php deleted file mode 100644 index 8c6c132b7..000000000 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AccompanyingPeriodClosingFilter.php +++ /dev/null @@ -1,78 +0,0 @@ -addJoinAccompanyingPeriod($qb); - - $clause = $qb->expr()->andX( - $qb->expr()->lte('acp.closingDate', ':date_to'), - $qb->expr()->gte('acp.closingDate', ':date_from') - ); - - $qb->andWhere($clause); - $qb->setParameter('date_from', $data['date_from'], Types::DATE_MUTABLE); - $qb->setParameter('date_to', $data['date_to'], Types::DATE_MUTABLE); - } - - public function applyOn(): string - { - return Declarations::PERSON_TYPE; - } - - public function buildForm(FormBuilderInterface $builder) - { - $builder->add('date_from', ChillDateType::class, [ - 'label' => 'Having an accompanying period closed after this date', - 'data' => new DateTime('-1 month'), - ]); - - $builder->add('date_to', ChillDateType::class, [ - 'label' => 'Having an accompanying period closed before this date', - 'data' => new DateTime(), - ]); - } - - public function describeAction($data, $format = 'string') - { - return [ - 'Filtered by accompanying period: persons having an accompanying period' - . ' closed between the %date_from% and %date_to%', - [ - '%date_from%' => $data['date_from']->format('d-m-Y'), - '%date_to%' => $data['date_to']->format('d-m-Y'), - ], - ]; - } - - public function getTitle(): string - { - return 'Filter by accompanying period: closed between two dates'; - } -} diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AccompanyingPeriodFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AccompanyingPeriodFilter.php deleted file mode 100644 index 05cf7fd1e..000000000 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AccompanyingPeriodFilter.php +++ /dev/null @@ -1,87 +0,0 @@ -addJoinAccompanyingPeriod($qb); - - $clause = $qb->expr()->andX(); - - $clause->add( - $qb->expr()->lte('acp.openingDate', ':date_to') - ); - $clause->add( - $qb->expr()->orX( - $qb->expr()->gte('acp.closingDate', ':date_from'), - $qb->expr()->isNull('acp.closingDate') - ) - ); - - $qb->andWhere($clause); - $qb->setParameter('date_from', $data['date_from'], Types::DATE_MUTABLE); - $qb->setParameter('date_to', $data['date_to'], Types::DATE_MUTABLE); - } - - public function applyOn(): string - { - return Declarations::PERSON_TYPE; - } - - public function buildForm(FormBuilderInterface $builder) - { - $builder->add('date_from', ChillDateType::class, [ - 'label' => 'Having an accompanying period opened after this date', - 'data' => new DateTime('-1 month'), - ]); - - $builder->add('date_to', ChillDateType::class, [ - 'label' => 'Having an accompanying period ending before this date, or ' - . 'still opened at this date', - 'data' => new DateTime(), - ]); - } - - public function describeAction($data, $format = 'string') - { - return [ - 'Filtered by accompanying period: persons having an accompanying period' - . ' opened after the %date_from% and closed before the %date_to% (or still opened ' - . 'at the %date_to%)', - [ - '%date_from%' => $data['date_from']->format('d-m-Y'), - '%date_to%' => $data['date_to']->format('d-m-Y'), - ], - ]; - } - - public function getTitle(): string - { - return 'Filter by accompanying period: active period'; - } -} diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AccompanyingPeriodOpeningFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AccompanyingPeriodOpeningFilter.php deleted file mode 100644 index b6d895233..000000000 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AccompanyingPeriodOpeningFilter.php +++ /dev/null @@ -1,78 +0,0 @@ -addJoinAccompanyingPeriod($qb); - - $clause = $qb->expr()->andX( - $qb->expr()->lte('acp.openingDate', ':date_to'), - $qb->expr()->gte('acp.openingDate', ':date_from') - ); - - $qb->andWhere($clause); - $qb->setParameter('date_from', $data['date_from'], Types::DATE_MUTABLE); - $qb->setParameter('date_to', $data['date_to'], Types::DATE_MUTABLE); - } - - public function applyOn(): string - { - return Declarations::PERSON_TYPE; - } - - public function buildForm(FormBuilderInterface $builder) - { - $builder->add('date_from', ChillDateType::class, [ - 'label' => 'Having an accompanying period opened after this date', - 'data' => new DateTime('-1 month'), - ]); - - $builder->add('date_to', ChillDateType::class, [ - 'label' => 'Having an accompanying period opened before this date', - 'data' => new DateTime(), - ]); - } - - public function describeAction($data, $format = 'string') - { - return [ - 'Filtered by accompanying period: persons having an accompanying period' - . ' opened between the %date_from% and %date_to%', - [ - '%date_from%' => $data['date_from']->format('d-m-Y'), - '%date_to%' => $data['date_to']->format('d-m-Y'), - ], - ]; - } - - public function getTitle(): string - { - return 'Filter by accompanying period: starting between two dates'; - } -} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/AccompanyingPeriodClosingFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/AccompanyingPeriodClosingFilterTest.php deleted file mode 100644 index 76c3b40b5..000000000 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/AccompanyingPeriodClosingFilterTest.php +++ /dev/null @@ -1,90 +0,0 @@ -filter = self::$container->get('chill.person.export.filter_accompanying_period_closing'); - } catch (ServiceNotFoundException $e) { - $this->markTestSkipped('The current configuration does not use accompanying_periods'); - } - } - - public function getFilter() - { - return $this->filter; - } - - public function getFormData(): array - { - return [ - [ - 'date_from' => DateTime::createFromFormat('Y-m-d', '2000-01-01'), - 'date_to' => DateTime::createFromFormat('Y-m-d', '2010-01-01'), - ], - ]; - } - - public function getQueryBuilders(): array - { - if (null === self::$kernel) { - self::bootKernel(); - } - - $em = self::$container - ->get('doctrine.orm.entity_manager'); - - return [ - $em->createQueryBuilder() - ->select('person.firstName') - ->from('ChillPersonBundle:Person', 'person'), - $em->createQueryBuilder() - ->select('person.firstName') - ->from('ChillPersonBundle:Person', 'person') - // add a dummy where clause - ->where('person.firstname IS NOT NULL'), - $em->createQueryBuilder() - ->select('count(IDENTITY(p))') - ->from('ChillPersonBundle:Person', 'person') - // add a dummy where clause - ->where('person.firstname IS NOT NULL'), - $em->createQueryBuilder() - ->select('count(IDENTITY(p))') - ->from('ChillPersonBundle:Person', 'person') - ->join('person.accompanyingPeriods', 'accompanying_period') - // add a dummy where clause - ->where('person.firstname IS NOT NULL'), - $em->createQueryBuilder() - ->select('activity.date AS date') - ->select('activity.attendee as attendee') - ->from('ChillActivityBundle:Activity', 'activity') - ->join('activity.person', 'person') - ->join('person.center', 'center'), - ]; - } -} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/AccompanyingPeriodFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/AccompanyingPeriodFilterTest.php deleted file mode 100644 index 582d090e8..000000000 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/AccompanyingPeriodFilterTest.php +++ /dev/null @@ -1,90 +0,0 @@ -filter = self::$container->get('chill.person.export.filter_accompanying_period'); - } catch (ServiceNotFoundException $e) { - $this->markTestSkipped('The current configuration does not use accompanying_periods'); - } - } - - public function getFilter() - { - return $this->filter; - } - - public function getFormData() - { - return [ - [ - 'date_from' => DateTime::createFromFormat('Y-m-d', '2000-01-01'), - 'date_to' => DateTime::createFromFormat('Y-m-d', '2010-01-01'), - ], - ]; - } - - public function getQueryBuilders() - { - if (null === self::$kernel) { - self::bootKernel(); - } - - $em = self::$container - ->get('doctrine.orm.entity_manager'); - - return [ - $em->createQueryBuilder() - ->select('person.firstName') - ->from('ChillPersonBundle:Person', 'person'), - $em->createQueryBuilder() - ->select('person.firstName') - ->from('ChillPersonBundle:Person', 'person') - // add a dummy where clause - ->where('person.firstname IS NOT NULL'), - $em->createQueryBuilder() - ->select('count(IDENTITY(p))') - ->from('ChillPersonBundle:Person', 'person') - // add a dummy where clause - ->where('person.firstname IS NOT NULL'), - $em->createQueryBuilder() - ->select('count(IDENTITY(p))') - ->from('ChillPersonBundle:Person', 'person') - ->join('person.accompanyingPeriods', 'accompanying_period') - // add a dummy where clause - ->where('person.firstname IS NOT NULL'), - $em->createQueryBuilder() - ->select('activity.date AS date') - ->select('activity.attendee as attendee') - ->from('ChillActivityBundle:Activity', 'activity') - ->join('activity.person', 'person') - ->join('person.center', 'center'), - ]; - } -} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/AccompanyingPeriodOpeningFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/AccompanyingPeriodOpeningFilterTest.php deleted file mode 100644 index 9262d0757..000000000 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/AccompanyingPeriodOpeningFilterTest.php +++ /dev/null @@ -1,90 +0,0 @@ -filter = self::$container->get('chill.person.export.filter_accompanying_period_opening'); - } catch (ServiceNotFoundException $e) { - $this->markTestSkipped('The current configuration does not use accompanying_periods'); - } - } - - public function getFilter() - { - return $this->filter; - } - - public function getFormData() - { - return [ - [ - 'date_from' => DateTime::createFromFormat('Y-m-d', '2000-01-01'), - 'date_to' => DateTime::createFromFormat('Y-m-d', '2010-01-01'), - ], - ]; - } - - public function getQueryBuilders() - { - if (null === self::$kernel) { - self::bootKernel(); - } - - $em = self::$container - ->get('doctrine.orm.entity_manager'); - - return [ - $em->createQueryBuilder() - ->select('person.firstName') - ->from('ChillPersonBundle:Person', 'person'), - $em->createQueryBuilder() - ->select('person.firstName') - ->from('ChillPersonBundle:Person', 'person') - // add a dummy where clause - ->where('person.firstname IS NOT NULL'), - $em->createQueryBuilder() - ->select('count(IDENTITY(p))') - ->from('ChillPersonBundle:Person', 'person') - // add a dummy where clause - ->where('person.firstname IS NOT NULL'), - $em->createQueryBuilder() - ->select('count(IDENTITY(p))') - ->from('ChillPersonBundle:Person', 'person') - ->join('person.accompanyingPeriods', 'accompanying_period') - // add a dummy where clause - ->where('person.firstname IS NOT NULL'), - $em->createQueryBuilder() - ->select('activity.date AS date') - ->select('activity.attendee as attendee') - ->from('ChillActivityBundle:Activity', 'activity') - ->join('activity.person', 'person') - ->join('person.center', 'center'), - ]; - } -} diff --git a/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_period.yaml b/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_period.yaml deleted file mode 100644 index 42ddd2181..000000000 --- a/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_period.yaml +++ /dev/null @@ -1,16 +0,0 @@ -services: - - chill.person.export.filter_accompanying_period: - class: Chill\PersonBundle\Export\Filter\PersonFilters\AccompanyingPeriodFilter - tags: - - { name: chill.export_filter, alias: person_accc_period_filter } - - chill.person.export.filter_accompanying_period_opening: - class: Chill\PersonBundle\Export\Filter\PersonFilters\AccompanyingPeriodOpeningFilter - tags: - - { name: chill.export_filter, alias: person_acc_pe_op_filter } - - chill.person.export.filter_accompanying_period_closing: - class: Chill\PersonBundle\Export\Filter\PersonFilters\AccompanyingPeriodClosingFilter - tags: - - { name: chill.export_filter, alias: person_acc_pe_cl_filter }