diff --git a/exports_alias_conventions.csv b/exports_alias_conventions.csv index 59b4c0fee..ab32cda8e 100644 --- a/exports_alias_conventions.csv +++ b/exports_alias_conventions.csv @@ -39,7 +39,7 @@ Household::class,,,household ,HouseholdComposition::class,household.compositions,composition Activity::class,,,activity ,Person::class,activity.person,actperson -,AccompanyingPeriod::class,activity.accompanyingPeriod,actacp +,AccompanyingPeriod::class,activity.accompanyingPeriod,acp ,Person::class,activity_person_having_activity.person,person_person_having_activity ,ActivityReason::class,activity_person_having_activity.reasons,reasons_person_having_activity ,ActivityType::class,activity.activityType,acttype diff --git a/exports_alias_conventions.md b/exports_alias_conventions.md index f04c97ff2..579d004a5 100644 --- a/exports_alias_conventions.md +++ b/exports_alias_conventions.md @@ -47,7 +47,7 @@ These are alias conventions : | | HouseholdComposition::class | household.compositions | composition | | Activity::class | | | activity | | | Person::class | activity.person | actperson | -| | AccompanyingPeriod::class | activity.accompanyingPeriod | actacp | +| | AccompanyingPeriod::class | activity.accompanyingPeriod | acp | | | Person::class | activity\_person\_having\_activity.person | person\_person\_having\_activity | | | ActivityReason::class | activity\_person\_having\_activity.reasons | reasons\_person\_having\_activity | | | ActivityType::class | activity.activityType | acttype | diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialActionAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialActionAggregator.php index f35fe6e6b..251f2e9d4 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialActionAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialActionAggregator.php @@ -41,18 +41,11 @@ class BySocialActionAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { if (!in_array('actsocialaction', $qb->getAllAliases(), true)) { - $qb->join('activity.socialActions', 'actsocialaction'); + $qb->leftJoin('activity.socialActions', 'actsocialaction'); } $qb->addSelect('actsocialaction.id AS socialaction_aggregator'); - - $groupBy = $qb->getDQLPart('groupBy'); - - if (!empty($groupBy)) { - $qb->addGroupBy('socialaction_aggregator'); - } else { - $qb->groupBy('socialaction_aggregator'); - } + $qb->addGroupBy('socialaction_aggregator'); } public function applyOn(): string @@ -72,6 +65,10 @@ class BySocialActionAggregator implements AggregatorInterface return 'Social action'; } + if (null === $value) { + return ''; + } + $sa = $this->actionRepository->find($value); return $this->actionRender->renderString($sa, []); diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialIssueAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialIssueAggregator.php index 1126b9373..d7abcfd49 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialIssueAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialIssueAggregator.php @@ -41,18 +41,11 @@ class BySocialIssueAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { if (!in_array('actsocialissue', $qb->getAllAliases(), true)) { - $qb->join('activity.socialIssues', 'actsocialissue'); + $qb->leftJoin('activity.socialIssues', 'actsocialissue'); } $qb->addSelect('actsocialissue.id AS socialissue_aggregator'); - - $groupBy = $qb->getDQLPart('groupBy'); - - if (!empty($groupBy)) { - $qb->addGroupBy('socialissue_aggregator'); - } else { - $qb->groupBy('socialissue_aggregator'); - } + $qb->addGroupBy('socialissue_aggregator'); } public function applyOn(): string @@ -72,6 +65,10 @@ class BySocialIssueAggregator implements AggregatorInterface return 'Social issues'; } + if (null === $value) { + return ''; + } + $i = $this->issueRepository->find($value); return $this->issueRender->renderString($i, []); diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByThirdpartyAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByThirdpartyAggregator.php index 4b56c6fc7..ebd813af4 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByThirdpartyAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByThirdpartyAggregator.php @@ -41,18 +41,11 @@ class ByThirdpartyAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { if (!in_array('acttparty', $qb->getAllAliases(), true)) { - $qb->join('activity.thirdParties', 'acttparty'); + $qb->leftJoin('activity.thirdParties', 'acttparty'); } $qb->addSelect('acttparty.id AS thirdparty_aggregator'); - - $groupBy = $qb->getDQLPart('groupBy'); - - if (!empty($groupBy)) { - $qb->addGroupBy('thirdparty_aggregator'); - } else { - $qb->groupBy('thirdparty_aggregator'); - } + $qb->addGroupBy('thirdparty_aggregator'); } public function applyOn(): string @@ -72,6 +65,10 @@ class ByThirdpartyAggregator implements AggregatorInterface return 'Accepted thirdparty'; } + if (null === $value) { + return ''; + } + $tp = $this->thirdPartyRepository->find($value); return $this->thirdPartyRender->renderString($tp, []); diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByUserAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByUserAggregator.php index 3787e5286..9eb5c307e 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByUserAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByUserAggregator.php @@ -41,18 +41,11 @@ class ByUserAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { if (!in_array('actusers', $qb->getAllAliases(), true)) { - $qb->join('activity.users', 'actusers'); + $qb->leftJoin('activity.users', 'actusers'); } $qb->addSelect('actusers.id AS users_aggregator'); - - $groupBy = $qb->getDQLPart('groupBy'); - - if (!empty($groupBy)) { - $qb->addGroupBy('users_aggregator'); - } else { - $qb->groupBy('users_aggregator'); - } + $qb->addGroupBy('users_aggregator'); } public function applyOn(): string @@ -72,6 +65,10 @@ class ByUserAggregator implements AggregatorInterface return 'Accepted users'; } + if (null === $value) { + return ''; + } + $u = $this->userRepository->find($value); return $this->userRender->renderString($u, []); diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/DateAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/DateAggregator.php index 5147936c9..982f0d6ed 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/DateAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/DateAggregator.php @@ -49,11 +49,11 @@ class DateAggregator implements AggregatorInterface switch ($data['frequency']) { case 'month': - $fmt = 'MM'; + $fmt = 'YYYY-MM'; break; case 'week': - $fmt = 'IW'; + $fmt = 'YYYY-IW'; break; case 'year': @@ -65,22 +65,8 @@ class DateAggregator implements AggregatorInterface } $qb->addSelect(sprintf("TO_CHAR(activity.date, '%s') AS date_aggregator", $fmt)); - - $groupBy = $qb->getDQLPart('groupBy'); - - if (!empty($groupBy)) { - $qb->addGroupBy('date_aggregator'); - } else { - $qb->groupBy('date_aggregator'); - } - - $orderBy = $qb->getDQLPart('orderBy'); - - if (!empty($orderBy)) { - $qb->addOrderBy('date_aggregator', $order); - } else { - $qb->orderBy('date_aggregator', $order); - } + $qb->addGroupBy('date_aggregator'); + $qb->addOrderBy('date_aggregator', $order); } public function applyOn(): string @@ -106,15 +92,12 @@ class DateAggregator implements AggregatorInterface return 'by ' . $data['frequency']; } + if (null === $value) { + return ''; + } + 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 ; diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/LocationTypeAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/LocationTypeAggregator.php index d05c0eb41..a4c1087db 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/LocationTypeAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/LocationTypeAggregator.php @@ -41,18 +41,11 @@ class LocationTypeAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { if (!in_array('actloc', $qb->getAllAliases(), true)) { - $qb->join('activity.location', 'actloc'); + $qb->leftJoin('activity.location', 'actloc'); } $qb->addSelect('IDENTITY(actloc.locationType) AS locationtype_aggregator'); - - $groupBy = $qb->getDQLPart('groupBy'); - - if (!empty($groupBy)) { - $qb->addGroupBy('locationtype_aggregator'); - } else { - $qb->groupBy('locationtype_aggregator'); - } + $qb->addGroupBy('locationtype_aggregator'); } public function applyOn(): string @@ -72,6 +65,10 @@ class LocationTypeAggregator implements AggregatorInterface return 'Accepted locationtype'; } + if (null === $value) { + return ''; + } + $lt = $this->locationTypeRepository->find($value); return $this->translatableStringHelper->localize( diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/UserScopeAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/UserScopeAggregator.php index faaa08b8e..1b7041d9d 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/UserScopeAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/UserScopeAggregator.php @@ -41,18 +41,11 @@ class UserScopeAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { if (!in_array('actuser', $qb->getAllAliases(), true)) { - $qb->join('activity.user', 'actuser'); + $qb->leftJoin('activity.user', 'actuser'); } $qb->addSelect('IDENTITY(actuser.mainScope) AS userscope_aggregator'); - - $groupBy = $qb->getDQLPart('groupBy'); - - if (!empty($groupBy)) { - $qb->addGroupBy('userscope_aggregator'); - } else { - $qb->groupBy('userscope_aggregator'); - } + $qb->addGroupBy('userscope_aggregator'); } public function applyOn(): string @@ -72,6 +65,10 @@ class UserScopeAggregator implements AggregatorInterface return 'Scope'; } + if (null === $value) { + return ''; + } + $s = $this->scopeRepository->find($value); return $this->translatableStringHelper->localize( diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php index cada50387..74df67d22 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php @@ -49,14 +49,7 @@ class ActivityTypeAggregator implements AggregatorInterface } $qb->addSelect(sprintf('IDENTITY(activity.activityType) AS %s', self::KEY)); - - $groupby = $qb->getDQLPart('groupBy'); - - if (!empty($groupBy)) { - $qb->addGroupBy(self::KEY); - } else { - $qb->groupBy(self::KEY); - } + $qb->addGroupBy(self::KEY); } public function applyOn(): string @@ -79,6 +72,10 @@ class ActivityTypeAggregator implements AggregatorInterface return 'Activity type'; } + if (null === $value) { + return ''; + } + $t = $this->activityTypeRepository->find($value); return $this->translatableStringHelper->localize($t->getName()); diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUserAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUserAggregator.php index 39c7c52cb..8e29f9cb0 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUserAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUserAggregator.php @@ -61,14 +61,15 @@ class ActivityUserAggregator implements AggregatorInterface public function getLabels($key, $values, $data): Closure { - // preload users at once - $this->userRepository->findBy(['id' => $values]); - - return function ($value) { + return function ($value) { if ('_header' === $value) { return 'Activity user'; } + if (null === $value) { + return ''; + } + $u = $this->userRepository->find($value); return $this->userRender->renderString($u, []); diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php index 566ee1ef4..2162b8b58 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php @@ -86,7 +86,7 @@ class CountActivity implements ExportInterface, GroupedExportInterface { $qb = $this->repository->createQueryBuilder('activity'); - if (!in_array('actacp', $qb->getAllAliases(), true)) { + if (!in_array('acp', $qb->getAllAliases(), true)) { $qb->join('activity.accompanyingPeriod', 'acp'); } diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php index 021966d90..5c85046ae 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php @@ -85,7 +85,7 @@ class SumActivityDuration implements ExportInterface, GroupedExportInterface { $qb = $this->repository->createQueryBuilder('activity'); - if (!in_array('actacp', $qb->getAllAliases(), true)) { + if (!in_array('acp', $qb->getAllAliases(), true)) { $qb->join('activity.accompanyingPeriod', 'acp'); } diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php index d64ac9200..af1a0c30a 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php @@ -85,7 +85,7 @@ class SumActivityVisitDuration implements ExportInterface, GroupedExportInterfac { $qb = $this->repository->createQueryBuilder('activity'); - if (!in_array('actacp', $qb->getAllAliases(), true)) { + if (!in_array('acp', $qb->getAllAliases(), true)) { $qb->join('activity.accompanyingPeriod', 'acp'); } diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/BySocialActionAggregatorTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/BySocialActionAggregatorTest.php index b4da861e8..d9b3a8cfb 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/BySocialActionAggregatorTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/BySocialActionAggregatorTest.php @@ -51,7 +51,7 @@ final class BySocialActionAggregatorTest extends AbstractAggregatorTest $em->createQueryBuilder() ->select('count(activity.id)') ->from(Activity::class, 'activity') - ->join('activity.accompanyingPeriod', 'actacp') + ->join('activity.accompanyingPeriod', 'acp') ->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 ab447739e..87e8462db 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/BySocialIssueAggregatorTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/BySocialIssueAggregatorTest.php @@ -51,7 +51,7 @@ final class BySocialIssueAggregatorTest extends AbstractAggregatorTest $em->createQueryBuilder() ->select('count(activity.id)') ->from(Activity::class, 'activity') - ->join('activity.accompanyingPeriod', 'actacp') + ->join('activity.accompanyingPeriod', 'acp') ->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 e65ffec62..c9a824dc3 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/ByThirdpartyAggregatorTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/ByThirdpartyAggregatorTest.php @@ -51,7 +51,7 @@ final class ByThirdpartyAggregatorTest extends AbstractAggregatorTest $em->createQueryBuilder() ->select('count(activity.id)') ->from(Activity::class, 'activity') - ->join('activity.accompanyingPeriod', 'actacp') + ->join('activity.accompanyingPeriod', 'acp') ->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 da1f0ecac..00243ce68 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/ByUserAggregatorTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/ByUserAggregatorTest.php @@ -51,7 +51,7 @@ final class ByUserAggregatorTest extends AbstractAggregatorTest $em->createQueryBuilder() ->select('count(activity.id)') ->from(Activity::class, 'activity') - ->join('activity.accompanyingPeriod', 'actacp') + ->join('activity.accompanyingPeriod', 'acp') ->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 f8775b8bf..c5a1b083c 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/DateAggregatorTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/DateAggregatorTest.php @@ -59,7 +59,7 @@ final class DateAggregatorTest extends AbstractAggregatorTest $em->createQueryBuilder() ->select('count(activity.id)') ->from(Activity::class, 'activity') - ->join('activity.accompanyingPeriod', 'actacp') + ->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 8f8b866bc..69be2c900 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/LocationTypeAggregatorTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/LocationTypeAggregatorTest.php @@ -51,7 +51,7 @@ final class LocationTypeAggregatorTest extends AbstractAggregatorTest $em->createQueryBuilder() ->select('count(activity.id)') ->from(Activity::class, 'activity') - ->join('activity.accompanyingPeriod', 'actacp') + ->join('activity.accompanyingPeriod', 'acp') ->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 3434f1a1c..73943ce7f 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/UserScopeAggregatorTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/UserScopeAggregatorTest.php @@ -51,7 +51,7 @@ final class UserScopeAggregatorTest extends AbstractAggregatorTest $em->createQueryBuilder() ->select('count(activity.id)') ->from(Activity::class, 'activity') - ->join('activity.accompanyingPeriod', 'actacp') + ->join('activity.accompanyingPeriod', 'acp') ->join('activity.user', 'actuser') , ]; diff --git a/src/Bundle/ChillMainBundle/Export/Formatter/SpreadSheetFormatter.php b/src/Bundle/ChillMainBundle/Export/Formatter/SpreadSheetFormatter.php index 6d6a685b7..ab9b2d660 100644 --- a/src/Bundle/ChillMainBundle/Export/Formatter/SpreadSheetFormatter.php +++ b/src/Bundle/ChillMainBundle/Export/Formatter/SpreadSheetFormatter.php @@ -496,8 +496,13 @@ class SpreadSheetFormatter implements FormatterInterface // 3. iterate on `keysExportElementAssociation` to store the callable // in cache foreach ($keysExportElementAssociation as $key => [$element, $data]) { - $this->cacheDisplayableResult[$key] = - $element->getLabels($key, array_unique($allValues[$key]), $data); + // handle the case when there is not results lines (query is empty) + if ([] === $allValues) { + $this->cacheDisplayableResult[$key] = $element->getLabels($key, ['_header'], $data); + } else { + $this->cacheDisplayableResult[$key] = + $element->getLabels($key, array_unique($allValues[$key]), $data); + } } // the cache is initialized ! diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregator.php index f9923c554..de276f007 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregator.php @@ -16,18 +16,19 @@ 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; class ClosingMotiveAggregator implements AggregatorInterface { - private EntityManagerInterface $em; + private ClosingMotiveRepositoryInterface $motiveRepository; private TranslatableStringHelper $translatableStringHelper; public function __construct( - ClosingMotiveRepository $motiveRepository, + ClosingMotiveRepositoryInterface $motiveRepository, TranslatableStringHelper $translatableStringHelper ) { $this->motiveRepository = $motiveRepository; diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/ClosingMotiveRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/ClosingMotiveRepository.php index ea5b1feff..283dac151 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/ClosingMotiveRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/ClosingMotiveRepository.php @@ -15,8 +15,9 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; use Doctrine\ORM\Query\ResultSetMappingBuilder; +use UnexpectedValueException; -final class ClosingMotiveRepository +final class ClosingMotiveRepository implements ClosingMotiveRepositoryInterface { private EntityManagerInterface $entityManager; @@ -54,4 +55,35 @@ final class ClosingMotiveRepository ->createNativeQuery($sql, $rsm) ->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 new file mode 100644 index 000000000..fbea29a0b --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/ClosingMotiveRepositoryInterface.php @@ -0,0 +1,13 @@ +