Refactor exports to include ExportGenerationContext.

Updated initiateQuery methods to pass ExportGenerationContext, enabling better user-specific query filtering. Removed redundant user retrieval in FilterListAccompanyingPeriodHelper, now relying on context-provided user data.
This commit is contained in:
2025-04-05 00:35:42 +02:00
parent b5fd9cf4af
commit 3b0a4e9c73
10 changed files with 23 additions and 22 deletions

View File

@@ -17,6 +17,7 @@ use Chill\ActivityBundle\Export\Export\ListActivityHelper;
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
use Chill\MainBundle\Entity\Scope;
use Chill\MainBundle\Export\AccompanyingCourseExportHelper;
use Chill\MainBundle\Export\ExportGenerationContext;
use Chill\MainBundle\Export\GroupedExportInterface;
use Chill\MainBundle\Export\Helper\TranslatableStringExportLabelHelper;
use Chill\MainBundle\Export\ListInterface;
@@ -115,7 +116,7 @@ final readonly class ListActivity implements ListInterface, GroupedExportInterfa
return $this->helper->getType();
}
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
public function initiateQuery(array $requiredModifiers, array $acl, array $data, ExportGenerationContext $context)
{
$centers = array_map(static fn ($el) => $el['center'], $acl);
@@ -129,7 +130,7 @@ final readonly class ListActivity implements ListInterface, GroupedExportInterfa
->leftJoin('acppart.person', 'person')
->andWhere('acppart.startDate != acppart.endDate OR acppart.endDate IS NULL');
$this->filterListAccompanyingPeriodHelper->addFilterAccompanyingPeriods($qb, $requiredModifiers, $acl, $data);
$this->filterListAccompanyingPeriodHelper->addFilterAccompanyingPeriods($qb, $requiredModifiers, $acl, $context->byUser, $data);
$qb
// some grouping are necessary