Remove usage of setParameters in various filters

This commit is contained in:
Julien Fastré 2023-10-16 14:28:04 +02:00
parent efcb903d10
commit 304bf4258b
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB
12 changed files with 60 additions and 43 deletions

View File

@ -59,9 +59,10 @@ class UserScopeFilter implements FilterInterface
->andWhere( ->andWhere(
$qb->expr()->in("{$p}_history.scope", ":{$p}_scopes") $qb->expr()->in("{$p}_history.scope", ":{$p}_scopes")
) )
->setParameters([ ->setParameter(
"{$p}_scopes" => $data["scopes"], "{$p}_scopes",
]); $data["scopes"],
);
} }
public function applyOn(): string public function applyOn(): string

View File

@ -51,9 +51,10 @@ class UsersJobFilter implements FilterInterface
. "AND {$p}_history.job IN ( :{$p}_jobs )" . "AND {$p}_history.job IN ( :{$p}_jobs )"
) )
) )
->setParameters([ ->setParameter(
"{$p}_jobs" => $data["jobs"], "{$p}_jobs",
]); $data["jobs"]
);
} }
public function applyOn() public function applyOn()

View File

@ -53,9 +53,10 @@ class UsersScopeFilter implements FilterInterface
. "AND {$p}_history.scope IN ( :{$p}_scopes )" . "AND {$p}_history.scope IN ( :{$p}_scopes )"
) )
) )
->setParameters([ ->setParameter(
"{$p}_scopes" => $data["scopes"], "{$p}_scopes",
]); $data["scopes"]
);
} }
public function applyOn(): string public function applyOn(): string

View File

@ -51,9 +51,10 @@ class ByUserJobFilter implements FilterInterface
. "AND {$p}_history.job IN ( :{$p}_jobs )" . "AND {$p}_history.job IN ( :{$p}_jobs )"
) )
) )
->setParameters([ ->setParameter(
"{$p}_jobs" => $data["jobs"], "{$p}_jobs",
]); $data["jobs"],
);
} }
public function applyOn(): string public function applyOn(): string

View File

@ -53,9 +53,10 @@ class ByUserScopeFilter implements FilterInterface
. "AND {$p}_history.scope IN ( :{$p}_scopes )" . "AND {$p}_history.scope IN ( :{$p}_scopes )"
) )
) )
->setParameters([ ->setParameter(
"{$p}_scopes" => $data["scopes"], "{$p}_scopes",
]); $data["scopes"],
);
} }
public function applyOn(): string public function applyOn(): string

View File

@ -22,13 +22,12 @@ use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Contracts\Translation\TranslatorInterface; use Symfony\Contracts\Translation\TranslatorInterface;
class JobFilter implements FilterInterface final readonly class JobFilter implements FilterInterface
{ {
private const PREFIX = 'cal_filter_job'; private const PREFIX = 'cal_filter_job';
public function __construct( public function __construct(
protected TranslatorInterface $translator, private TranslatableStringHelper $translatableStringHelper
private readonly TranslatableStringHelper $translatableStringHelper
) {} ) {}
public function addRole(): ?string public function addRole(): ?string
@ -59,9 +58,10 @@ class JobFilter implements FilterInterface
) )
) )
->andWhere($qb->expr()->in("{$p}_history.job", ":{$p}_job")) ->andWhere($qb->expr()->in("{$p}_history.job", ":{$p}_job"))
->setParameters([ ->setParameter(
"{$p}_job" => $data["job"], "{$p}_job",
]); $data["job"]
);
} }

View File

@ -59,9 +59,10 @@ class ScopeFilter implements FilterInterface
) )
) )
->andWhere($qb->expr()->in("{$p}_history.scope", ":{$p}_scope")) ->andWhere($qb->expr()->in("{$p}_history.scope", ":{$p}_scope"))
->setParameters([ ->setParameter(
"{$p}_scope" => $data["scope"], "{$p}_scope",
]); $data["scope"]
);
} }
public function applyOn(): string public function applyOn(): string

View File

@ -72,9 +72,10 @@ class CreatorJobFilter implements FilterInterface
) )
) )
->andWhere($qb->expr()->in("{$p}_history.job", ":{$p}_jobs")) ->andWhere($qb->expr()->in("{$p}_history.job", ":{$p}_jobs"))
->setParameters([ ->setParameter(
"{$p}_jobs" => $data["creator_job"], "{$p}_jobs",
]); $data["creator_job"],
);
} }
public function applyOn(): string public function applyOn(): string

View File

@ -63,11 +63,15 @@ readonly class JobWorkingOnCourseFilter implements FilterInterface
. "AND {$p}_info.infoDate >= :{$p}_start and {$p}_info.infoDate < :{$p}_end" . "AND {$p}_info.infoDate >= :{$p}_start and {$p}_info.infoDate < :{$p}_end"
) )
) )
->setParameters([ ->setParameter("{$p}_jobs", $data['jobs'])
"{$p}_jobs" => $data['jobs'], ->setParameter(
"{$p}_start" => $this->rollingDateConverter->convert($data['start_date']), "{$p}_start",
"{$p}_end" => $this->rollingDateConverter->convert($data['end_date']) $this->rollingDateConverter->convert($data['start_date']),
]) )
->setParameter(
"{$p}_end",
$this->rollingDateConverter->convert($data['end_date'])
)
; ;
} }

View File

@ -63,11 +63,15 @@ readonly class ScopeWorkingOnCourseFilter implements FilterInterface
. "AND {$p}_info.infoDate >= :{$p}_start AND {$p}_info.infoDate < :{$p}_end" . "AND {$p}_info.infoDate >= :{$p}_start AND {$p}_info.infoDate < :{$p}_end"
) )
) )
->setParameters([ ->setParameter("{$p}_scopes", $data["scopes"])
"{$p}_scopes" => $data["scopes"], ->setParameter(
"{$p}_start" => $this->rollingDateConverter->convert($data["start_date"]), "{$p}_start",
"{$p}_end" => $this->rollingDateConverter->convert($data["end_date"]) $this->rollingDateConverter->convert($data["start_date"]),
]) )
->setParameter(
"{$p}_end",
$this->rollingDateConverter->convert($data["end_date"])
)
; ;
} }

View File

@ -72,9 +72,10 @@ class UserJobFilter implements FilterInterface
) )
) )
->andWhere($qb->expr()->in("{$p}_jobHistory.job", ":{$p}_job")) ->andWhere($qb->expr()->in("{$p}_jobHistory.job", ":{$p}_job"))
->setParameters([ ->setParameter(
"{$p}_job" => $data["jobs"], "{$p}_job",
]) $data["jobs"],
)
; ;
} }

View File

@ -72,9 +72,10 @@ class UserScopeFilter implements FilterInterface
) )
) )
->andWhere($qb->expr()->in("{$p}_scopeHistory.scope", ":{$p}_scopes")) ->andWhere($qb->expr()->in("{$p}_scopeHistory.scope", ":{$p}_scopes"))
->setParameters([ ->setParameter(
"{$p}_scopes" => $data["scopes"], "{$p}_scopes",
]) $data["scopes"],
)
; ;
} }