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

@@ -38,19 +38,13 @@ final readonly class FilterListAccompanyingPeriodHelper implements FilterListAcc
$this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
}
public function addFilterAccompanyingPeriods(QueryBuilder &$qb, array $requiredModifiers, array $acl, array $data = []): void
public function addFilterAccompanyingPeriods(QueryBuilder &$qb, array $requiredModifiers, array $acl, User $user, array $data = []): void
{
$centers = match ($this->filterStatsByCenters) {
true => array_map(static fn ($el) => $el['center'], $acl),
false => $this->centerRepository->findAll(),
};
$user = $this->security->getUser();
if (!$user instanceof User) {
throw new \RuntimeException('only a regular user can run this export');
}
// add filtering on confidential accompanying period. The confidential is applyed on the current status of
// the accompanying period (we do not use the 'calc_date' here
$aclConditionsOrX = $qb->expr()->orX(

View File

@@ -11,6 +11,7 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Export\Helper;
use Chill\MainBundle\Entity\User;
use Doctrine\ORM\QueryBuilder;
/**
@@ -19,5 +20,5 @@ use Doctrine\ORM\QueryBuilder;
*/
interface FilterListAccompanyingPeriodHelperInterface
{
public function addFilterAccompanyingPeriods(QueryBuilder &$qb, array $requiredModifiers, array $acl, array $data = []): void;
public function addFilterAccompanyingPeriods(QueryBuilder &$qb, array $requiredModifiers, array $acl, User $user, array $data = []): void;
}