mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-31 12:03:48 +00:00
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:
@@ -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(
|
||||
|
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user