mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +00:00
DX: simplify creatorJobFilter
This commit is contained in:
parent
be75cdce55
commit
be215bd135
@ -13,9 +13,9 @@ namespace Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters;
|
||||
|
||||
use Chill\MainBundle\Entity\UserJob;
|
||||
use Chill\MainBundle\Export\FilterInterface;
|
||||
use Chill\MainBundle\Repository\UserJobRepositoryInterface;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Doctrine\ORM\Query\Expr\Andx;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
@ -25,10 +25,14 @@ class CreatorJobFilter implements FilterInterface
|
||||
{
|
||||
private TranslatableStringHelper $translatableStringHelper;
|
||||
|
||||
private UserJobRepositoryInterface $userJobRepository;
|
||||
|
||||
public function __construct(
|
||||
TranslatableStringHelper $translatableStringHelper
|
||||
TranslatableStringHelper $translatableStringHelper,
|
||||
UserJobRepositoryInterface $userJobRepository
|
||||
) {
|
||||
$this->translatableStringHelper = $translatableStringHelper;
|
||||
$this->userJobRepository = $userJobRepository;
|
||||
}
|
||||
|
||||
public function addRole(): ?string
|
||||
@ -42,17 +46,9 @@ class CreatorJobFilter implements FilterInterface
|
||||
$qb->join('acp.createdBy', 'acp_creator');
|
||||
}
|
||||
|
||||
$where = $qb->getDQLPart('where');
|
||||
$clause = $qb->expr()->in('acp_creator.userJob', ':creator_job');
|
||||
|
||||
if ($where instanceof Andx) {
|
||||
$where->add($clause);
|
||||
} else {
|
||||
$where = $qb->expr()->andX($clause);
|
||||
}
|
||||
|
||||
$qb->add('where', $where);
|
||||
$qb->setParameter('creator_job', $data['creator_job']);
|
||||
$qb
|
||||
->andWhere($qb->expr()->in('acp_creator.userJob', ':creator_job'))
|
||||
->setParameter('creator_job', $data['creator_job']);
|
||||
}
|
||||
|
||||
public function applyOn(): string
|
||||
@ -64,6 +60,7 @@ class CreatorJobFilter implements FilterInterface
|
||||
{
|
||||
$builder->add('creator_job', EntityType::class, [
|
||||
'class' => UserJob::class,
|
||||
'choices' => $this->userJobRepository->findAllActive(),
|
||||
'choice_label' => function (UserJob $j) {
|
||||
return $this->translatableStringHelper->localize(
|
||||
$j->getLabel()
|
||||
@ -84,7 +81,7 @@ class CreatorJobFilter implements FilterInterface
|
||||
);
|
||||
}
|
||||
|
||||
return ['Filtered by creator job: only %jobs%', [
|
||||
return ['export.filter.course.creator_job.Filtered by creator job: only %jobs%', [
|
||||
'%jobs%' => implode(', ', $creatorJobs),
|
||||
]];
|
||||
}
|
||||
|
@ -1023,6 +1023,8 @@ export:
|
||||
Having a temporarily location: Ayant une localisation temporaire
|
||||
Having a person's location: Ayant une localisation auprès d'un usager
|
||||
Calculation date: Date de la localisation
|
||||
creator_job:
|
||||
'Filtered by creator job: only %jobs%': 'Filtré par métier du créateur: seulement %jobs%'
|
||||
list:
|
||||
person_with_acp:
|
||||
List peoples having an accompanying period: Liste des personnes ayant un parcours d'accompagnement
|
||||
|
Loading…
x
Reference in New Issue
Block a user